Skip to content

Python fast encoding/decoding of google encoded polylines

Notifications You must be signed in to change notification settings

mthh/polyline_ggl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python fast encoding/decoding of google encoded polylines

Just a cython implementation trying to obtain better performances when dealing with Google encoded polylines (nothing too serious but it works fine, python 2 & 3, written with py3 in mind though).

Usage:

Decoding

In [1]: from polyline_ggl import decode_polyline

In [2]: decode_polyline("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
Out[2]: [(38.5, -120.2), (40.7, -120.95), (43.252, -126.453)]

Directly decoding with a custom factorization (like routes from OSRM)

In [3]: decode_polyline("wthhiAjez|qC[E?oc@?}m@", factor=1e6)
Out[3]: 
[(38.949724, -77.03511),
 (38.949738, -77.035107),
 (38.949738, -77.034523),
 (38.949738, -77.033772)]

Encoding

In [4]: from polyline_ggl import encode_polyline

In [5]: encode_polyline([(38.5, -120.2), (40.7, -120.95), (43.252, -126.453)])
Out[5]: '_p~iF~ps|U_ulLnnqC_mqNvxq`@'

Requirements :

Running tests :

$ python3 setup.py test

Installation :

$ git clone http://github.com/mthh/polyline_ggl
$ cd polyline_ggl
$ python3 setup.py install

References :

About

Python fast encoding/decoding of google encoded polylines

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages