$ npm install gjtk
gjtk
is a library for working with GeoJSON.
gjtk
is available on npm.
npm install gjtk
var gjtk = require('gjtk');
All validation methods take a single argument.
returns true
when passed a valid GeoJSON object, otherwise false
GeoJSON always consists of a single object. This object (referred to as the GeoJSON object [above]) represents a geometry, feature, or collection of features.
returns true
when passed a valid GeoJSON Geometry, otherwise false
A geometry is a GeoJSON object where the type member's value is one of the following strings: "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", or "GeometryCollection".
returns true
when passed a valid GeoJSON Position, otherwise false
A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification.
returns true
when passed valid GeoJSON Point coordinates, otherwise false
[100.0, 0.0]
returns true
when passed valid GeoJSON MultiPoint coordinates, otherwise false
[ [100.0, 0.0], [101.0, 1.0], [102.0, 2.0] ]
returns true
when passed valid GeoJSON LineString coordinates, otherwise false
[ [100.0, 0.0], [101.0, 1.0] ]
returns true
when passed valid GeoJSON LinearRing coordinates, otherwise false
A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
returns true
when passed valid GeoJSON MultiLineString coordinates, otherwise false
[
[ [100.0, 0.0], [101.0, 1.0] ],
[ [102.0, 2.0], [103.0, 3.0] ]
]
returns true
when passed valid GeoJSON Polygon coordinates, otherwise false
[
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
[
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
returns true
when passed valid GeoJSON MultiPolygon coordinates, otherwise false
[
[
[ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0] ]
],
[
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
]
returns true
when passed a valid GeoJSON Point, otherwise false
{ "type": "Point", "coordinates": [100.0, 0.0] }
returns true
when passed a valid GeoJSON MultiPoint, otherwise false
{ "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }
returns true
when passed a valid GeoJSON LineString, otherwise false
{
"type": "LineString",
"coordinates": [ [100.0, 0.0], [101.0, 1.0] ]
}
returns true
when passed a valid GeoJSON MultiLineString, otherwise false
{
"type": "MultiLineString",
"coordinates": [
[ [100.0, 0.0], [101.0, 1.0] ],
[ [102.0, 2.0], [103.0, 3.0] ]
]
}
returns true
when passed a valid GeoJSON Polygon, otherwise false
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
returns true
when passed a valid GeoJSON MultiPolygon, otherwise false
{
"type": "MultiPolygon",
"coordinates": [
[
[ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0] ]
],
[
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
]
}
returns true
when passed a valid GeoJSON Geometry Collection, otherwise false
{
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [100.0, 0.0]
},
{
"type": "LineString",
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}
returns true
when passed a valid GeoJSON Feature, otherwise false
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
returns true
when passed a valid GeoJSON Feature Collection, otherwise false
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"prop0": "value0"
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [ [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0] ]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
},
"properties": {
"prop0": "value0",
"prop1": {
"this": "that"
}
}
}
]
}
returns true
when passed a valid GeoJSON Coordinate Reference System, otherwise false
{
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
}
{
"type": "link",
"properties": {
"href": "http://example.com/crs/42",
"type": "proj4"
}
}
returns true
when passed an object that validly specifies a GeoJSON Coordinate Reference System, otherwise false
The coordinate reference system (CRS) of a GeoJSON object is determined by its "crs" member (referred to as the CRS object below). If an object has no crs member, then its parent or grandparent object's crs member may be acquired. If no crs member can be so acquired, the default CRS shall apply to the GeoJSON object.
returns true
when passed a valid GeoJSON Link, otherwise false
{
"type": "link",
"properties": {
"href": "data.crs",
"type": "ogcwkt"
}
}
returns true
when passed a valid GeoJSON Bounding Box, otherwise false
[-180.0, -90.0, 180.0, 90.0]
returns true
when passed an object that validly specifies a GeoJSON Bounding Box, otherwise false
{
"type": "Feature",
"bbox": [-180.0, -90.0, 180.0, 90.0],
"geometry": {
"type": "Polygon",
"coordinates": [
[ [-180.0, 10.0], [20.0, 90.0], [180.0, -5.0], [-30.0, -90.0] ]
]
}
}
returns true
when all parameters are identical GeoJSON Positions, otherwise false
returns true
when one GeoJSON LinearRing contains another, otherwise false
returns a GeoJSON Point object
returns a GeoJSON Feature object
returns a GeoJSON FeatureCollection object
returns a GeoJSON GeometryCollection object
These methods all take a single argument: a valid GeoJSON object.
returns all the Positions in a valid GeoJSON object
returns all the Features in a valid GeoJSON object
returns all the Geometries in a valid GeoJSON object
© 2010 - cnpmjs.org x YWFE | Home | YWFE