Skip to content

Latest commit

 

History

History
999 lines (459 loc) · 15.8 KB

DOCUMENTATION.md

File metadata and controls

999 lines (459 loc) · 15.8 KB

isValid(geojson[, cb])

Determines if an object is a GeoJSON Object or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isValid(geojson);
// => true
Returns
  • boolean true if valid else false

isPoint(geojson[, cb])

Determines if an object is a GeoJSON Point or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isPoint(geojson);
// => true
Returns
  • boolean true if valid else false

isMultiPoint(geojson[, cb])

Determines if an object is a GeoJSON MultiPoint or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isMultiPoint(geojson);
// => true
Returns
  • boolean true if valid else false

isLineString(geojson[, cb])

Determines if an object is a GeoJSON LineString or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isLineString(geojson);
// => true
Returns
  • boolean true if valid else false

isMultiLineString(geojson[, cb])

Determines if an object is a GeoJSON MultiLineString or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isMultiLineString(geojson);
// => true
Returns
  • boolean true if valid else false

isPolygon(geojson[, cb])

Determines if an object is a GeoJSON Polygon or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isPolygon(geojson);
// => true
Returns
  • boolean true if valid else false

isMultiPolygon(geojson[, cb])

Determines if an object is a GeoJSON MultiPolygon or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isMultiPolygon(geojson);
// => true
Returns
  • boolean true if valid else false

isGeometryCollection(geojson[, cb])

Determines if an object is a GeoJSON GeometryCollection or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isGeometryCollection(geojson);
// => true
Returns
  • boolean true if valid else false

isFeature(geojson[, cb])

Determines if an object is a GeoJSON Feature or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isFeature(geojson);
// => true
Returns
  • boolean true if valid else false

isFeatureCollection(geojson[, cb])

Determines if an object is a GeoJSON FeatureCollection or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isFeatureCollection(geojson);
// => true
Returns
  • boolean true if valid else false

isGeometry(geojson[, cb])

Determines if an object is a GeoJSON geometry or not

Parameters
Name Type Description
geojson object valid geojson object  
cb Function callback to invoke on success or failure Optional
Examples
isGeometry(geojson);
// => true
Returns
  • boolean true if valid else false

centroidOf(geojson)

Calculates the centroid of a geojson feature(s) using the mean of all vertices

Parameters
Name Type Description
geojson object feature to be centered  
Examples
const point = centroidOf(polygon);
// => { type: 'Point', coordinates: [ ... ] }
Returns
  • object an Object that can be used as centroid

parseCoordinateString(coords[, optns={}])

Create geojson geometry or coordinate array from string

Parameters
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
Examples
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: [ ... ] }
Returns
  • object Array geojson geometry or coordinates

randomLongitude([optns={}])

Generate random longitude

Parameters
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
Examples
const longitude = randomLongitude();
// => -76.4103176657406
Returns
  • object valid longitude

randomLatitude([optns={}])

Generate random latitude

Parameters
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
Examples
const latitude = randomLatitude();
// => 67.07040223216296
Returns
  • object valid latitude

randomPosition([optns={}])

Generate next random position

Parameters
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
Examples
const position = randomPosition();
// => [ -76.4103176657406, 67.07040223216296 ]
Returns
  • object valid position

randomPositions([optns={}])

Generate random positions

Parameters
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
Examples
const geo = randomPositions(); // => [ [-76.41031, 67.0704], ...]
Returns
  • object valid positions

randomPoint([optns={}])

Generate random GeoJSON Point

Parameters
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
Examples
const geo = randomPoint(); // => { type: 'Point', coordinates:[ ... ] }
Returns
  • object valid GeoJSON Point

randomLineString([optns={}])

Generate random GeoJSON LineString

Parameters
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
Examples
const geo = randomLineString(); // => { type: 'LineString', coordinates:[ ... ] }
Returns
  • object valid GeoJSON LineString

randomPolygon([optns={}])

Generate random GeoJSON Polygon

Parameters
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
Examples
const geo = randomPolygon();
// => { type: 'Polygon', coordinates:[ ... ] }
Returns
  • object valid GeoJSON Polygon

randomMultiPoint([optns={}])

Generate random GeoJSON MultiPoint

Parameters
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
Examples
const geo = randomMultiPoint();
// => { type: 'MultiPoint', coordinates:[ ... ] }
Returns
  • object valid GeoJSON MultiPoint

randomMultiLineString([optns={}])

Generate random GeoJSON MultiLineString

Parameters
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
Examples
const geo = randomMultiLineString();
// => { type: 'MultiLineString', coordinates:[ ... ] }
Returns
  • object valid GeoJSON MultiLineString

randomMultiPolygon([optns={}])

Generate random GeoJSON MultiPolygon

Parameters
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
Examples
const geo = randomMultiPolygon();
// => {type: 'MultiPolygon', coordinates:[] }
Returns
  • object valid GeoJSON MultiPolygon

randomGeometry([optns={}])

Generate random GeoJSON Geometry

Parameters
Name Type Description
optns={} object valid option Optional
Examples
const geo = randomGeometry();
// => { type: 'Point', coordinates:[ ... ] }
Returns
  • object valid GeoJSON Geometry

randomGeometryCollection([optns={}])

Generate random GeoJSON GeometryCollection

Parameters
Name Type Description
optns={} object valid option Optional
Examples
const geo = randomGeometryCollection();
// => { type: 'GeometryCollection', geometries: [ ... ] }
Returns
  • object valid GeoJSON GeometryCollection

readShapefile(optns, done)

Read shapefile stream

Parameters
Name Type Description
optns object valid options  
optns.path string valid shapefile path  
done Function callback to invoke on feature read  
Examples
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();
 }
});
Returns
  • Void

readGeoJSON(optns, done)

Read GeoJSON file stream

Parameters
Name Type Description
optns object valid options  
optns.path string valid GeoJSON file path  
done Function callback to invoke on feature read  
Examples
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();
 }
});
Returns
  • Void

readCsv(optns, done)

Read csv file stream

Parameters
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  
Examples
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();
 }
});
Returns
  • Void

readJson(optns, done)

Read json file

Parameters
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  
Examples
readJson({ path }, (error, data) => {
 // handle read error
 if(error) { ... }

 // process json data
 else { ... }
});
Returns
  • object Error error or read json data

Documentation generated with doxdox.