Created
October 20, 2015 18:55
-
-
Save fitnr/53eb580cbe8d78f56585 to your computer and use it in GitHub Desktop.
Quick cli tool for encoding coordinates with Google's encoded polyline algorithm. Requires polyencode (pip install polyencode).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| import gpolyencode | |
| """ | |
| polyencode.py | |
| Encode list of x,y coordinates with Google's encoded polyline algorithm | |
| see: https://developers.google.com/maps/documentation/utilities/polylinealgorithm | |
| usage: python polyencode.py -72,41.9 -73,42.0 -74,42.1 -75,42.3 | |
| :returns string | |
| """ | |
| points = [(float(x), float(y)) for x, y in [point.split(',') for point in sys.argv[1:]]] | |
| print gpolyencode.GPolyEncoder().encode(points).get('points') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment