Skip to content

jhermsmeier/node-google-polyline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-polyline

npm npm license npm downloads build status

Encodes and decodes Google's polyline format

Install via npm

$ npm install --save google-polyline

Usage

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 ]
]

Benchmarks

$ 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)