diff --git a/README.md b/README.md index db0547f..ef92952 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 : diff --git a/bin/polyline.bin.js b/bin/polyline.bin.js index c209332..9a6d8d4 100755 --- a/bin/polyline.bin.js +++ b/bin/polyline.bin.js @@ -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 = ''; @@ -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)); }