Skip to content

Commit

Permalink
Add --toGeoJSON option
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Apr 1, 2018
1 parent 09b934f commit 54aeca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -5,7 +5,8 @@
A simple [google-esque polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
implementation in Javascript. Compatible with nodejs (`npm install @mapbox/polyline` and the browser (copy `src/polyline.js`)).

Encodes/decodes into lat/lng coordinate pairs. Use `fromGeoJSON()` to encode from GeoJSON objects.
Encodes/decodes into [lat, lng] coordinate pairs. Use `fromGeoJSON()` to encode from GeoJSON objects, or `toGeoJSON` to
decode to a GeoJSON LineString.

## Installation

Expand Down Expand Up @@ -36,7 +37,7 @@ polyline.fromGeoJSON({ "type": "Feature",

Install globally or run `./node_modules/.bin/polyline`.

Send input via stdin and use `--decode`, `--encode`, or `--fromGeoJSON` flags. If omitted will default to `--decode`.
Send input via stdin and use `--decode`, `--encode`, `--toGeoJSON`, or `--fromGeoJSON` flags. If omitted will default to `--decode`.

Example :

Expand Down
4 changes: 3 additions & 1 deletion bin/polyline.bin.js
Expand Up @@ -2,7 +2,7 @@

var polyline = require('../');

var HELP = 'Provide data from stdin and use with --decode (default), --encode, or --fromGeoJSON\n';
var HELP = 'Provide data from stdin and use with --decode (default), --encode, --toGeoJSON, or --fromGeoJSON\n';

var mode = process.argv[2] || '--decode';
var rawInput = '';
Expand Down Expand Up @@ -34,6 +34,8 @@ function convert(rawString, mode) {
return polyline.decode(rawString);
case '--encode' :
return polyline.encode(rawString);
case '--toGeoJSON':
return polyline.toGeoJSON(rawString);
case '--fromGeoJSON' :
return polyline.fromGeoJSON(JSON.parse(rawString));
}
Expand Down

0 comments on commit 54aeca2

Please sign in to comment.