2 function FOSSGISValhallaEngine(id, costing) {
8 14, // kDestination = 4;
9 14, // kDestinationRight = 5;
10 14, // kDestinationLeft = 6;
13 1, // kSlightRight = 9;
15 3, // kSharpRight = 11;
16 4, // kUturnRight = 12;
17 4, // kUturnLeft = 13;
18 7, // kSharpLeft = 14;
20 5, // kSlightLeft = 16;
21 0, // kRampStraight = 17;
22 24, // kRampRight = 18;
23 25, // kRampLeft = 19;
24 24, // kExitRight = 20;
25 25, // kExitLeft = 21;
26 0, // kStayStraight = 22;
27 1, // kStayRight = 23;
30 10, // kRoundaboutEnter = 26;
31 10, // kRoundaboutExit = 27;
32 17, // kFerryEnter = 28;
33 0, // kFerryExit = 29;
34 null, // kTransit = 30;
35 null, // kTransitTransfer = 31;
36 null, // kTransitRemainOn = 32;
37 null, // kTransitConnectionStart = 33;
38 null, // kTransitConnectionTransfer = 34;
39 null, // kTransitConnectionDestination = 35;
40 null, // kPostTransitConnectionDestination = 36;
41 21, // kMergeRight = 37;
42 20 // kMergeLeft = 38;
45 function _processDirections(tripLegs) {
51 for (const leg of tripLegs) {
52 const legLine = L.PolylineUtil.decode(leg.shape, {
56 const legSteps = leg.maneuvers.map(function (manoeuvre, idx) {
57 const num = `<b>${idx + 1}.</b> `;
58 const lineseg = legLine
59 .slice(manoeuvre.begin_shape_index, manoeuvre.end_shape_index + 1)
60 .map(([lat, lng]) => ({ lat, lng }));
63 INSTR_MAP[manoeuvre.type],
64 num + manoeuvre.instruction,
65 manoeuvre.length * 1000,
70 line = line.concat(legLine);
71 steps = steps.concat(legSteps);
72 distance += leg.summary.length;
73 time += leg.summary.time;
79 distance: distance * 1000,
87 "<a href='https://gis-ops.com/global-open-valhalla-server-online/' target='_blank'>Valhalla (FOSSGIS)</a>",
90 getRoute: function (points, callback) {
92 json: JSON.stringify({
93 locations: points.map(function (p) {
94 return { lat: p.lat, lon: p.lng, radius: 5 };
99 language: I18n.currentLocale()
104 url: OSM.FOSSGIS_VALHALLA_URL,
107 success: function ({ trip }) {
108 if (trip.status === 0) {
109 callback(false, _processDirections(trip.legs));
122 OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_car", "auto"), true);
123 OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_bicycle", "bicycle"), true);
124 OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_foot", "pedestrian"), true);