Retrieving polylines

Every Trip has a location stream, which is available after real-time filtering on the location data sent by the SDKs. Our real-time filtering removes noise, smoothens and improves accuracy of the location data. This location data for a Trip can be retrieved using the time aware polyline property of the trip. This property captures the locations and respective time stamps of a trip as a compressed string. With a compressed format, location stream from a long trip is made available in a single API call.

This guide will show how the polyline can be retrieved and decoded to obtain the location stream.


Retrieve polyline

Every Trip object has the time aware polyline field which captures the location stream. To retrieve the polyline, retrieve the Trip object using the id.

The response has a field called the time_aware_polyline, which will look like a long string of characters. As the polyline is updated in real-time, the stream is available right after the trip starts, and grows as the trip progresses.

curl ""
  -H "Authorization: token YOUR_TOKEN"

Example polyline

  "time_aware_polyline": "spxsBsdb|Lymo`qvAx@TKvAr@K"

Decoding the polyline

The time aware polyline can be decoded to get the latitude, longitude and timestamp data of the location stream as given below. To decode, you can use our open source libraries in Python and JavaScript.

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

If your language of choice is not available, let us know and we would be happy to ship it quickly.

$ pip install time_aware_polyline
from time_aware_polyline import decode_time_aware_polyline

polyline = 'spxsBsdb|Lymo`qvAx@TKvAr@K'
decoded = decode_time_aware_polyline(polyline)
$ npm i time-aware-polyline
var polylineUtil = require('time-aware-polyline');

var polyline = 'spxsBsdb|Lymo`qvAx@TKvAr@K';

results matching ""

    No results matching ""