Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhermsmeier/node-google-polyline
Encode / decode Google's polyline format
https://github.com/jhermsmeier/node-google-polyline
encoder geodata google-polyline maps parser polyline
Last synced: 2 months ago
JSON representation
Encode / decode Google's polyline format
- Host: GitHub
- URL: https://github.com/jhermsmeier/node-google-polyline
- Owner: jhermsmeier
- License: mit
- Created: 2016-10-11T13:50:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-31T18:52:35.000Z (over 4 years ago)
- Last Synced: 2024-10-11T07:34:14.473Z (3 months ago)
- Topics: encoder, geodata, google-polyline, maps, parser, polyline
- Language: JavaScript
- Size: 45.9 KB
- Stars: 38
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# google-polyline
[![npm](https://img.shields.io/npm/v/google-polyline.svg?style=flat-square)](https://npmjs.com/package/google-polyline)
[![npm license](https://img.shields.io/npm/l/google-polyline.svg?style=flat-square)](https://npmjs.com/package/google-polyline)
[![npm downloads](https://img.shields.io/npm/dm/google-polyline.svg?style=flat-square)](https://npmjs.com/package/google-polyline)
[![build status](https://img.shields.io/travis/jhermsmeier/node-google-polyline.svg?style=flat-square)](https://travis-ci.org/jhermsmeier/node-google-polyline)Encodes and decodes [Google's polyline format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
## Install via [npm](https://npmjs.com)
```sh
$ npm install --save google-polyline
```## Usage
```js
var polyline = require( 'google-polyline' )
``````js
polyline.encode([
[ 38.5, -120.2 ],
[ 40.7, -120.95 ],
[ 43.252, -126.453 ]
])> '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
``````js
polyline.decode( '_p~iF~ps|U_ulLnnqC_mqNvxq`@' )> [
[ 38.5, -120.2 ],
[ 40.7, -120.95 ],
[ 43.252, -126.453 ]
]
```## Benchmarks
```sh
$ npm run benchmark
``````
# decode: 3 points ⨉ 100000
ok ~21 ms (0 s + 21199187 ns)# decode: ~350 points ⨉ 100000
ok ~741 ms (0 s + 740819246 ns)# encode: 3 points ⨉ 100000
ok ~221 ms (0 s + 221480259 ns)# encode: ~350 points ⨉ 100000
ok ~2.4 s (2 s + 403294668 ns)
```