Encodes and decodes Google's polyline format
Install via npm
$ npm install --save google-polyline
var polyline = require( 'google-polyline' )
polyline.encode([
[ 38.5, -120.2 ],
[ 40.7, -120.95 ],
[ 43.252, -126.453 ]
])
> '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
polyline.decode( '_p~iF~ps|U_ulLnnqC_mqNvxq`@' )
> [
[ 38.5, -120.2 ],
[ 40.7, -120.95 ],
[ 43.252, -126.453 ]
]
$ npm run benchmark
decode
3 points ....................................... 2,147,574 op/s
~350 points .................................... 52,926 op/s
encode
3 points ....................................... 1,840,679 op/s
~350 points .................................... 34,159 op/s