Cardboard is a JavaScript library for managing the storage of GeoJSON features on an AWS backend. It relies on DynamoDB for indexing and small-feature storage, and S3 for large-feature storage. Cardboard provides functions to create, read, update, and delete single features or in batch, as well as simple bounding-box spatial query capabilities.
npm install cardboard
# or globally
npm install -g cardboard
Generate a client by passing the following configuration options to cardboard:
option | required | description |
---|---|---|
mainTable | X | the name of the DynamoDB table to use |
region | X | the region containing the given DynamoDB table |
accessKeyId | AWS credentials | |
secretAccessKey | AWS credentials | |
sessionToken | AWS credentials | |
dyno | a pre-configured dyno client to use for DynamoDB interactions |
Providing AWS credentials is optional. Cardboard depends on the AWS SDK for JavaScript, and so credentials can be provided in any way supported by that library. See configuring the SDK in Node.js for more configuration options.
If you provide a preconfigured dyno client, you do not need to specify table
and region
when initializing cardboard.
var Cardboard = require('cardboard');
var cardboard = Cardboard({
mainTable: 'my-cardboard-table',
region: 'us-east-1',
});- '6.9'
Once you've initialized the client, you can use it to create a table for you:
cardboard.createTable(callback);
You don't have to create the table each time; you can provide the name of a pre-existing table to your configuration options to use that table.
See api.md.
Most cardboard functions require you to specify a dataset
. This is a way of grouping sets of features within a single Cardboard table. It is similar in concept to "layers" in many other GIS systems, but there are no restrictions on the types of features that can be associated with each other in a single dataset
. Each feature managed by cardboard can only belong to one dataset
.
Features within a single dataset
must each have a unique id
. Cardboard uses a GeoJSON feature's top-level id
property to determine and persist the feature's identifier. If you provide a cardboard function with a GeoJSON feature that does not have an id
property, it will assign one for you, otherwise, it will use the id
that you provide. Be aware that inserting two features to a single dataset with the same id
value will result in only the last feature being persisted in cardboard.
Whenever dealing with individual GeoJSON features, cardboard will expect or return a GeoJSON object of type Feature
. In batch situations, or in any request that returns multiple features, cardboard will expect/return a FeatureCollection
.
Cardboard retains the precision of a feature's coordinates to six decimal places.