update cucumber suport code to return separate annotations headers
This commit is contained in:
committed by
Patrick Niklaus
parent
84261fd214
commit
ab91a05680
@@ -83,7 +83,10 @@ module.exports = function () {
|
||||
duration = json.matchings[0].duration;
|
||||
}
|
||||
|
||||
if (headers.has('annotation')) {
|
||||
// annotation response values are requested by 'a:{type_name}'
|
||||
var found = false;
|
||||
headers.forEach((h) => { if (h.match(/^a:/)) found = true; });
|
||||
if (found) {
|
||||
if (json.matchings.length != 1) throw new Error('*** Checking annotation only supported for matchings with one subtrace');
|
||||
annotation = this.annotationList(json.matchings[0]);
|
||||
}
|
||||
@@ -92,11 +95,6 @@ module.exports = function () {
|
||||
if (json.matchings.length != 1) throw new Error('*** Checking geometry only supported for matchings with one subtrace');
|
||||
geometry = json.matchings[0].geometry;
|
||||
}
|
||||
|
||||
if (headers.has('OSM IDs')) {
|
||||
if (json.matchings.length != 1) throw new Error('*** Checking annotation only supported for matchings with one subtrace');
|
||||
OSMIDs = this.OSMIDList(json.matchings[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (headers.has('turns')) {
|
||||
@@ -111,9 +109,19 @@ module.exports = function () {
|
||||
got.duration = duration.toString();
|
||||
}
|
||||
|
||||
if (headers.has('annotation')) {
|
||||
got.annotation = annotation.toString();
|
||||
}
|
||||
// if header matches 'a:*', parse out the values for *
|
||||
// and return in that header
|
||||
headers.forEach((k) => {
|
||||
let whitelist = ['duration', 'distance', 'datasources', 'nodes', 'weight'];
|
||||
if (k.match(/^a:/)) {
|
||||
let a_type = k.slice(2);
|
||||
if (whitelist.indexOf(a_type) == -1)
|
||||
return cb(new Error('Unrecognized annotation field:' + a_type));
|
||||
if (!annotation[a_type])
|
||||
return cb(new Error('Annotation not found in response: ' + a_type));
|
||||
got[k] = annotation[a_type];
|
||||
}
|
||||
});
|
||||
|
||||
if (headers.has('geometry')) {
|
||||
if (this.queryParams['geometries'] === 'polyline') {
|
||||
|
||||
Reference in New Issue
Block a user