Simple Features
A simple feature model for working with geospatial data in JavaScript.
Note that this doesn't strictly follow the OGC Simple Features spec(s). Instead, see GeoJSON for inspiration.
Installation
Typically, you'll add simple-features
as a dependency of another package.
npm install simple-features --save
(Exclude the --save
option if you are installing locally just to try it out.)
Simple Example
Create a new feature with one string property and one geometry.
var assert = ;var simple = ; var feature = name: 'Bozeman' loc: -11104 4568;
Features can have arbitrary properties. To access a property value, use the get
method.
var value = feature; assert;
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 getGeometry
method.
var loc = feature;var geom = feature; assert;
Geometries have multi-dimensional coordinate arrays of the same form as GeoJSON.
var coords = featurecoordinates; assert;
Until there are more docs here, see the tests for more detail.
Development
Run tests with the test
script:
npm test
You can also set up a watcher to run tests continuously during development.
npm run watch