Time Aware polyline

Location time series or time aware polyline is encoded string similar to google's encoded polyline, which when decoded gives array of location and timestamp. This library provides utilities for encoding and decoding location time series and animating a marker over the polyline. Hypertrack entites like placeline segments, actions, etc provide location_time_series which provides a string which can be decoded using this library to obtain location data anotated with timestamps.

Usage

This library exposes a global variable timeAwarePolyline when used in broswer using script tag. If used is es6 modules, the functions and classes can be directly imported.

Decode/encode timeAwarePolyline

TimeAwareEncoder

TimeAwareEncoded class contains functions for encoding and decoding the location time series data from string to timeAwarePath and vice versa.

Decode

TimeAwareEncoder.decodeTimeAwarePolyline(polyline: string): ITimeAwarePoint[]

Encode

TimeAwareEncoder.encodeTimeAwarePolyline(points: ITimeAwarePoint[]): string

Time aware path till a timestamp

TimeAwareEncoder.getLocationsTillTimeStamp(decodedPolyline: ITimeAwarePoint[], timeStamp: string): ITimeAwarePoint[]

Polyline utilities

PolylineUtils

Class which exposes utilities useful for rendering data on the map

Time aware polyline

PolylineUtils.timeAwarePolyline: ITimeAwarePoint[]

Property on PolylineUtils class which stores the decoded timeAwarePoints.

Update timeAwarePolyline

PolylineUtils.updateTimeAwarePolyline(encodedPolyline: string)

Updates timeAwarepolyline property of PolylineUtils class

Get polyline till a timestamp

PolylineUtils.getPolylineToTime(timestamp: string): ITimeAwarePoint[]

This function take ISO string timestamp and returns a polyline trucated from the begining to the timestamp.

Get latest timestamp

PolylineUtils.getPolylineToTime(): string

Returns the latest timestamp of the timeAwarePolyline

Animation over time aware polyline

TimeAwareAnimation

This class exposes functions to enable animating a marker over a time aware polyline in realtime

Update event

TimeAwareAnimation.updateEvent: CustomEvent

On every frame of animation a custom event is fired which return path and bearing required for animating a polyline. The name of custom event fired on every frame of animation is "update"

Usage
import {TimeAwareAnimation} from "time-aware-polyline"

const anim = new TimeAwareAnimation();
anim.updateEvent('update', ({path, bearing}) => {
    // do anything with path and bearing
})
Update data for animation

TimeAwareAnimation.updatePolylineString(timeAwarePolylineString: string) or TimeAwareAnimation.update(timeAwarePolyline: ITimeAwarePoint[])

Call one of the above method whenever a new timeAwarePolyline is available from api

Animation frame rate

TimeAwareanimation.animationSpeed: number = 20

Frame rate for each animation.

results matching ""

    No results matching ""