0

We are using Here MapsRoute Matching API (https://developer.here.com/documentation/route-matching/dev_guide/index.html) to calculate the most sensible route based on many trace points. We use the POST endpoint and we pass the tracepoints in GeoJSON format, including coordinates, timestamp and speed value for each point.

We would like to get the (estimated) speed of the vehicle in each of the links along the route.

This is an example of our request to the API: https://routematching.hereapi.com/v8/calculateroute.json?routeMatch=1&mode=fastest;truck;traffic:disabled&routeAttributes=mo,wp,sm,fl,sp,sc&drivingReport=1&apiKey=whatever&alignToGpsTime=0&legAttributes=mn&linkAttributes=ma

We tried to use the remaining time and remaining distance attributes of each link to calculate the speed on each link, but the results dont correlate with the original trace points.

Is this the right approach to calculate a speeding profile of a route?

1 Answers1

0

Please refer to the following codes to get the speed limits along the routes, more detailed code is available in the example.

function GPXParser(xmlDoc, map,  draw)
{
this.xmlDoc = xmlDoc;
this.map = map;
this.trackcolor = "#ff00ff";
this.markercolor = "ff00ff";
this.trackwidth = 5;
this.mintrackpointdelta = 0.0001;
this.objectContainer = new H.map.Group();
this.pointsWithSpeed = [];
if(draw)
this.map.addObjects(this.objectContainer);
}

.....

var speed = 0;


var tmp = trackpoints[0].getElementsByTagName("speed")[0];
if(tmp && tmp.length != 0)
speed = tmp.childNodes[0].nodeValue;

speed = parseFloat(speed);

var heading = -1;

tmp = trackpoints[0].getElementsByTagName("course")[0];
if(tmp)
heading = tmp.childNodes[0].nodeValue;

heading = parseFloat(heading);

if(heading > 0)
this.pointsWithSpeed.push({coord: latlng, speed: speed, heading: heading});
else
this.pointsWithSpeed.push({coord: latlng, speed: speed});

for (var i=1; i < trackpoints.length; i++)
{
var lon = parseFloat(trackpoints[i].getAttribute("lon"));
var lat = parseFloat(trackpoints[i].getAttribute("lat"));

speed = 0;

tmp = trackpoints[i].getElementsByTagName("speed")[0];
if(tmp && tmp.length != 0)
    speed = tmp.childNodes[0].nodeValue;

speed = parseFloat(speed);

....

if(heading > 0)
        this.pointsWithSpeed.push({coord: latlng, speed: speed, heading: heading});
    else
        this.pointsWithSpeed.push({coord: latlng, speed: speed});

    this.objectContainer.addObject(polyline);
    lastlon = lon;
    lastlat = lat;
}
}
}

 GPXParser.prototype.GetPointsWithSpeed = function()
{
 return this.pointsWithSpeed;
}