Time aware polylines in python
The google encoded polyline algorithm converts location coordinates into an ascii string. We have extended the algorithm to convert location coordinates with time stamps into ascii strings. The time aware polyline is also available in javascript.
Time aware polylines can be used to mark time events on polylines, or run a trip replay, like in the HyperTrack dashboard.
Install
pip install time_aware_polyline
Encoder
from time_aware_polyline import encode_time_aware_polyline
points = [
[19.13626, 72.92506, '2016-07-21T05:43:09+00:00'],
[19.13597, 72.92495, '2016-07-21T05:43:15+00:00'],
[19.13553, 72.92469, '2016-07-21T05:43:21+00:00'],
]
encoded = encode_time_aware_polyline(points)
Decoder
from time_aware_polyline import decode_time_aware_polyline
polyline = 'spxsBsdb|Lymo`qvAx@TKvAr@K'
decoded = decode_time_aware_polyline(polyline)
Testing
To run the tests, you will need to install pytest.
pip install pytest
For running the tests, run the following command.
py.test