Return an array with meta-data for each coordinate.

Currently supports duration and distance for each coordinate.

This is particularly useful in map-matching, comparing how
a trip progresses compared to a real GPS trace that is
map-matched.
This commit is contained in:
Daniel Patterson
2016-05-08 22:58:13 -07:00
committed by Patrick Niklaus
parent 0f2bb5dde5
commit fa525ad610
13 changed files with 121 additions and 10 deletions
+13 -1
View File
@@ -33,7 +33,9 @@ module.exports = function () {
var subMatchings = [],
turns = '',
route = '',
duration = '';
duration = '',
annotation = '';
if (res.statusCode === 200) {
if (headers.has('matchings')) {
@@ -54,6 +56,11 @@ module.exports = function () {
if (json.matchings.length != 1) throw new Error('*** Checking duration only supported for matchings with one subtrace');
duration = json.matchings[0].duration;
}
if (headers.has('annotation')) {
if (json.matchings.length != 1) throw new Error('*** Checking annotation only supported for matchings with one subtrace');
annotation = this.annotationList(json.matchings[0]);
}
}
if (headers.has('turns')) {
@@ -68,6 +75,10 @@ module.exports = function () {
got.duration = duration.toString();
}
if (headers.has('annotation')) {
got.annotation = annotation.toString();
}
var ok = true;
var encodedResult = '',
extendedTarget = '';
@@ -134,6 +145,7 @@ module.exports = function () {
this.requestUrl(row.request, afterRequest);
} else {
var params = this.queryParams;
params['annotate'] = 'true';
got = {};
for (var k in row) {
var match = k.match(/param:(.*)/);
+10
View File
@@ -141,6 +141,16 @@ module.exports = function () {
return this.extractInstructionList(instructions, s => s.maneuver.bearing_after);
};
this.annotationList = (instructions) => {
// Pull out all the distinct segment distances, skipping the arrive
// instructions, and the leading 0 on all timestamps arrays.
var pairs = [];
for (var i in instructions.annotation.duration) {
pairs.push(instructions.annotation.duration[i]+":"+instructions.annotation.distance[i]);
}
return pairs.join(",");
};
this.turnList = (instructions) => {
return instructions.legs.reduce((m, v) => m.concat(v.steps), [])
.map(v => {
+15
View File
@@ -104,3 +104,18 @@ Feature: Basic Map Matching
| trace | matchings |
| dcba | hg,gf,fe |
| efgh | ab,bc,cd |
Scenario: Testbot - Duration details
Given the node map
| a | b | c | d | e | | g | h |
| | | i | | | | | |
And the ways
| nodes | oneway |
| abcdegh | no |
| ci | no |
When I match I should get
| trace | matchings | annotation |
| abeh | abcedgh | 1:9.897633,0:0,1:10.008842,1:10.008842,1:10.008842,0:0,2:20.017685,1:10.008842 |
| abci | abc,ci | 1:9.897633,0:0,1:10.008842,0:0.111209,1:10.121593 |