A simple feature model for working with geospatial data
Typically, you'll add
simple-features as a dependency of another package.
npm install simple-features --save
--save option if you are installing locally just to try it out.)
Create a new feature with one string property and one geometry.
var assert = require'assert';var simple = require'simple-features';var feature =name: 'Bozeman'loc: -111.04 45.68;
Features can have arbitrary properties. To access a property value, use the
var value = featureget'name';assertstrictEqualvalue 'Bozeman';
Features typically have a single geometry, but they can have more. In cases where a feature has more than one geometry, the first one is considered the "default" geometry. The default geometry can be accessed by using the
get method with the property name or with the
var loc = featureget'loc';var geom = featuregetGeometry;assertstrictEqualloc geom;
Geometries have multi-dimensional coordinate arrays of the same form as GeoJSON.
var coords = featuregetGeometrycoordinates;assertdeepEqualcoordinates -111.04 45.68;
Until there are more docs here, see the tests for more detail.
Run tests with the
You can also set up a watcher to run tests continuously during development.
npm run watch