Allow users to specify a class for each way

This adds the ability to mark ways with a user-defined
class in the profile. This class information will be included
in the response as property of the RouteStep object.
This commit is contained in:
Patrick Niklaus
2017-06-27 22:01:05 +00:00
committed by Patrick Niklaus
parent d52d530cbe
commit 44739f2dc3
39 changed files with 614 additions and 57 deletions
+4
View File
@@ -260,6 +260,10 @@ module.exports = function () {
return this.extractInstructionList(instructions, s => s.mode);
};
this.classesList = (instructions) => {
return this.extractInstructionList(instructions, s => s.classes ? s.classes.join(';') : '');
};
this.timeList = (instructions) => {
return this.extractInstructionList(instructions, s => s.duration + 's');
};
+3 -1
View File
@@ -34,7 +34,7 @@ module.exports = function () {
var afterRequest = (err, res, body) => {
if (err) return cb(err);
if (body && body.length) {
let destinations, exits, pronunciations, instructions, refs, bearings, turns, modes, times,
let destinations, exits, pronunciations, instructions, refs, bearings, turns, modes, times, classes,
distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches;
let json = JSON.parse(body);
@@ -53,6 +53,7 @@ module.exports = function () {
turns = this.turnList(json.routes[0]);
intersections = this.intersectionList(json.routes[0]);
modes = this.modeList(json.routes[0]);
classes = this.classesList(json.routes[0]);
times = this.timeList(json.routes[0]);
distances = this.distanceList(json.routes[0]);
lanes = this.lanesList(json.routes[0]);
@@ -174,6 +175,7 @@ module.exports = function () {
putValue('bearing', bearings);
putValue('turns', turns);
putValue('modes', modes);
putValue('classes', classes);
putValue('times', times);
putValue('distances', distances);
putValue('pronunciations', pronunciations);