sharedstreets / sharedstreets-js

SharedStreets (Node.js & Javascript)
https://sharedstreets.io
MIT License
77 stars 25 forks source link

SharedStreets (Node.js & JavaScript)

npm version CircleCI

Node.js & JavaScript implementation of SharedStreets Reference System.

Command Line Interface (CLI)

SharedStreets CLI Matcher

Description

The CLI is the primary tool for users to match GIS data to SharedStreets. The CLI is installed and run locally. Compared to the hosted API, the CLI can process much larger datasets and runs more quickly.

The CLI is currently runs on macOS and Linux. It does not (yet) support Windows.

Usage:

shst <command> [options ... ]

For detailed examples of how to use this tool, see the SharedStreets blog.

Install

The CLI requires Node v10+ on MacOS or Linux. Windows is not currently supported. On supported platforms it can be installed using either npm or yarn, or follow using Docker for unsupported environments.

NPM

To install using npm:

npm install -g sharedstreets

Yarn

To install using yarn:

yarn global add sharedstreets

This will install the CLI as shst.

Docker

To install using Docker create the following Dockerfile:

FROM node:11

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER node
RUN npm install -g sharedstreets

Docker image build:

docker build --tag shst-image .

Run match on local data file:

docker run -it -v [/path/to/data/on/host/]:/data/  --rm  shst-image shst match /data/[input_file.geojson] --out=/data/output.geojson

Available commands

Available commands include:

extract

Extracts SharedStreets streets using polygon boundary and returns GeoJSON routput of all intersecting features from the SharedStreets reference tile set.

The input polygon(s) must be in GeoJSON format, using the WGS84 datum (EPSG:4326) in decimal degrees. "Extracts" includes features that are inside but not fully contained by the polygon.

Output is given as a GeoJSON file:

Usage:

shst extract <path/to/input_polygon.geojson> [options]

help

Displays help for shst

Usage:

shst help

Options:

The following options may be appended to the command:

Example:

shst extract ~/Desktop/project/city_boundary.geojson --out=streets_in_city.geojson

match

Matches point and line features, from GIS, to SharedStreets references. This can be used to match city centerlines, parking meters, and other street features. Input data must be in GeoJSON format, using the WGS84 datum (EPSG:4326) in decimal degrees. Any standard GIS program (e.g. ArcGIS, QGIS) can convert from more common GIS file formats, like shapefile and geodatabase, into GeoJSON.

Output is given as up to three GeoJSON files:

Usage:

shst match <path/to/input_data.geojson> [options]

Options:

Additional options allow users to change the modality for matching, incorporate a city's directionality information to support better matching, snap or offset results, cluster points along a street section, etc.

The following options may be appended to the command:

Examples:

Matching city centerlines to SharedStreets:

$ shst match ~/Desktop/project/city_centerlines.geojson --out=city_centerlines.geojson

Matching city bike facilities to SharedStreets:

$ shst match ~/Desktop/project/city_bikeways.geojson --out=city_bikeways.geojson --match-bike --tile-hierarchy=8

Development

For developers:

Install

git clone https://github.com/sharedstreets/sharedstreets-js.git
yarn install
yarn prepack
yarn global add /Users/username/github/sharedstreets-js

Test

You can test your installation using the following:

yarn test

Troubleshooting

Build docs

yarn run docs

Benchmark

yarn run bench