Determines if an object is a GeoJSON Object or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isValid(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON Point or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isPoint(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON MultiPoint or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isMultiPoint(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON LineString or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isLineString(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON MultiLineString or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isMultiLineString(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON Polygon or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isPolygon(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON MultiPolygon or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isMultiPolygon(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON GeometryCollection or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isGeometryCollection(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON Feature or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isFeature(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON FeatureCollection or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isFeatureCollection(geojson);
// => true
boolean
true if valid else false
Determines if an object is a GeoJSON geometry or not
Name | Type | Description | |
---|---|---|---|
geojson | object |
valid geojson object | |
cb | Function |
callback to invoke on success or failure | Optional |
isGeometry(geojson);
// => true
boolean
true if valid else false
Calculates the centroid of a geojson feature(s) using the mean of all vertices
Name | Type | Description | |
---|---|---|---|
geojson | object |
feature to be centered |
const point = centroidOf(polygon);
// => { type: 'Point', coordinates: [ ... ] }
object
an Object that can be used as centroid
Create geojson geometry or coordinate array from string
Name | Type | Description | |
---|---|---|---|
coords | string |
string to extract geojson geometry or coordinates | |
optns={} | object |
valid options | Optional |
optns.delimiter=',' | string |
long, lat seperator from string | Optional |
optns.separator=' | string |
'] long, lat pair seperator from string | Optional |
const polygonString = '-4.7,39.3 -5.2,38.6 -6.1,40.1 -4.9,39.8 -4.7,39.3'
const polygon = parseCoordinateString(polygonString);
// => { type: 'Polygon', coordinates: [ ... ] }
const cicleString = '-9.2,39.5 180';
const polygon = parseCoordinateString(cirlceString);
// => { type: 'Polygon', coordinates: [ ... ] }
object
Array
geojson geometry or coordinates
Generate random longitude
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const longitude = randomLongitude();
// => -76.4103176657406
object
valid longitude
Generate random latitude
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const latitude = randomLatitude();
// => 67.07040223216296
object
valid latitude
Generate next random position
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.angle | number |
= (Math.random() * 2 * Math.PI)] valid angle in radian between points | Optional |
optns.distance | number |
= (Math.random() * 0.0001)] valid distance between points | Optional |
optns.longitude | number |
valid longitude on last point | Optional |
optns.latitude | number |
valid latitude on last point | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const position = randomPosition();
// => [ -76.4103176657406, 67.07040223216296 ]
object
valid position
Generate random positions
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.vertices=2 | number |
how many positions. | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomPositions(); // => [ [-76.41031, 67.0704], ...]
object
valid positions
Generate random GeoJSON Point
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomPoint(); // => { type: 'Point', coordinates:[ ... ] }
object
valid GeoJSON Point
Generate random GeoJSON LineString
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.vertices=2 | number |
how many coordinates each LineString will contain. | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomLineString(); // => { type: 'LineString', coordinates:[ ... ] }
object
valid GeoJSON LineString
Generate random GeoJSON Polygon
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.vertices=4 | number |
how many coordinates Polygon will contain. | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomPolygon();
// => { type: 'Polygon', coordinates:[ ... ] }
object
valid GeoJSON Polygon
Generate random GeoJSON MultiPoint
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.vertices=2 | number |
how many points MultiPoint will contain. | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomMultiPoint();
// => { type: 'MultiPoint', coordinates:[ ... ] }
object
valid GeoJSON MultiPoint
Generate random GeoJSON MultiLineString
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.lines=2 | number |
how many LineString. | Optional |
optns.vertices=2 | number |
how many coordinates each LineString will contain. | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomMultiLineString();
// => { type: 'MultiLineString', coordinates:[ ... ] }
object
valid GeoJSON MultiLineString
Generate random GeoJSON MultiPolygon
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
optns.polygons=2 | number |
how many Polygons. | Optional |
optns.vertices=2 | number |
how many coordinates each Polygon will contain. | Optional |
optns.bbox=-180, | Array.<number> |
-90, 180, 90]] a bounding box inside of which geometries are placed. | Optional |
const geo = randomMultiPolygon();
// => {type: 'MultiPolygon', coordinates:[] }
object
valid GeoJSON MultiPolygon
Generate random GeoJSON Geometry
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
const geo = randomGeometry();
// => { type: 'Point', coordinates:[ ... ] }
object
valid GeoJSON Geometry
Generate random GeoJSON GeometryCollection
Name | Type | Description | |
---|---|---|---|
optns={} | object |
valid option | Optional |
const geo = randomGeometryCollection();
// => { type: 'GeometryCollection', geometries: [ ... ] }
object
valid GeoJSON GeometryCollection
Read shapefile stream
Name | Type | Description | |
---|---|---|---|
optns | object |
valid options | |
optns.path | string |
valid shapefile path | |
done | Function |
callback to invoke on feature read |
readShapefile(path, (error, { finished, feature, next }) => {
// handle read error
if(error) { ... }
// handle read finished
else if(finished){ ... }
// process feature
// and read next chunk
else {
//...
return next();
}
});
Void
Read GeoJSON file stream
Name | Type | Description | |
---|---|---|---|
optns | object |
valid options | |
optns.path | string |
valid GeoJSON file path | |
done | Function |
callback to invoke on feature read |
readGeoJSON({ path }, (error, { finished, feature, next }) => {
// handle read error
if(error) { ... }
// handle read finished
else if(finished){ ... }
// process feature
// and read next chunk
else {
//...
return next();
}
});
Void
Read csv file stream
Name | Type | Description | |
---|---|---|---|
optns | object |
valid options | |
optns.path | string |
valid csv file path | |
optns.delimiter | string |
valid csv field delimiter | |
done | Function |
callback to invoke on feature read |
readCsv({ path }, (error, { finished, feature, next }) => {
// handle read error
if(error) { ... }
// handle read finished
else if(finished){ ... }
// process feature
// and read next chunk
else {
//...
return next();
}
});
Void
Read json file
Name | Type | Description | |
---|---|---|---|
optns | object |
valid options | |
optns.path | string |
valid json file path | |
optns.throws | boolean |
whether to ignore error | |
done | Function |
callback to invoke on success read or error |
readJson({ path }, (error, data) => {
// handle read error
if(error) { ... }
// process json data
else { ... }
});
object
Error
error or read json data
Documentation generated with doxdox.