Route traveled

The HyperTrack mobile SDK collects location and activity data for your users. This data is available as various building blocks for your location features. One such building block is the time aware polyline, which stores the route traveled by your users.

Time aware polyline object

The time aware polyline captures the locations and timestamps as a compressed string. The time aware polyline is based on Google's encoded polyline format, which stores static locations (without timestamps) in a string. All route visualisations on HyperTrack are powered using the time aware polyline.

Sample

spxsBsdb|Lymo`qvAx@TKvAr@K

The above string captures the following location data. With this compressed format, thousands of location data is made available in a single API call. This string can be decoded to obtain location data whenever required.

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

Polyline

Benefits of using time aware polyline

  • With this compressed format, thousands of location data is made available in a single API call.
  • Richer visualisation features liek replays can be built using this format as it has timestamps besides locations.

Get the time aware polyline from API

You can get the route traveled as a JSON from our API.

Get polyline for a user

You can get the route traveled by a user by querying the user's placeline API, with the appropriate parameters. The API returns a list of segments called the placeline. Each segment has a field time_aware_polyline that contains the route traveled by the user for that segment.

Get polyline for an action

The Action HTTP entity can be used to represent routes that are useful for your workflow. For example, a sales visit can be an action, and for this action, you can obtain the time aware polyline and distance traveled.

API call HTTP method Request url
Get action details https://api.hypertrack.com/api/v1/actions/ACTION_ID/detailed/
curl "https://app.hypertrack.io/api/v1/actions/41caa9f2-ad63-4a8b-98ed-1414c372e1ce/detailed/"
  -H "Authorization: token YOUR_SECRET_KEY"

Get locations from the time aware 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.

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';
polylineUtil.decodeTimeAwarePolyline(polyline);

Try it out

var polylineUtil = require('time-aware-polyline');

var polyline = 'spxsBsdb|Lymo`qvAx@TKvAr@K';
polylineUtil.decodeTimeAwarePolyline(polyline);

See the route traveled on the map

You can see the polyline on a map on the hypertrack dashboard, or on your own dashboard using widgets or customisable JS library.

Internally, the above views decode the time aware polyline into an encoded polyline. All kinds of maps take input in the encoded polyline format to visualise routes.

How does hypertrack generate the polyline?

Location filtering

Our real-time filtering removes noise, smoothens and improves accuracy of the location data. This ensures that distance metering can be accurate. Read more on how that works.

Example filtering

Encoding the polyline

Each location is a tuple of latitude, longitude and timestamp. A location stream can be encoded into a time aware polyline. We have open sourced the libraries that we use to do this encoding in Python and JavaScript.

Next up

Read about other building blocks, or learn what you can build with them.

results matching ""

    No results matching ""