@furkot/directions
Advanced tools
Comparing version 2.1.1 to 2.1.2
const travelMode = require('./model').travelMode; | ||
const { defaults: defaults, withTimeout } = require('./service/util'); | ||
const prepareQuery = require('./profile'); | ||
@@ -89,3 +90,3 @@ module.exports = furkotDirections; | ||
if (query?.points?.length > 1) { | ||
return requestDirections(query, options.timeout); | ||
return requestDirections(prepareQuery(query), options.timeout); | ||
} | ||
@@ -92,0 +93,0 @@ |
@@ -12,4 +12,2 @@ // https://docs.graphhopper.com/#tag/Routing-API | ||
const vehicle = { | ||
'-1': 'car', | ||
0: 'car', | ||
1: 'bike', | ||
@@ -19,2 +17,3 @@ 2: 'foot', | ||
}; | ||
const defaultVehicle = 'car'; | ||
@@ -135,5 +134,10 @@ const weighting = { | ||
function vehicleType(query) { | ||
const { mode, proposedMode } = query; | ||
return vehicle[proposedMode ?? mode] || defaultVehicle; | ||
} | ||
function vehicleSize(query, options) { | ||
const { mode, vehicle } = query; | ||
if (!(vehicle && mode === travelMode.rv)) { | ||
const { initialMode, mode, vehicle } = query; | ||
if (!(vehicle && (initialMode ?? mode) === travelMode.rv)) { | ||
return; | ||
@@ -148,3 +152,3 @@ } | ||
} | ||
['height', 'width', 'length', 'weight', 'axle_load'].forEach(p => { | ||
['height', 'width', 'length', 'weight'].forEach(p => { | ||
if (vehicle[p]) { | ||
@@ -172,3 +176,3 @@ options.push({ | ||
let req = { | ||
vehicle: vehicle[mode] || vehicle[0], | ||
vehicle: vehicleType(query), | ||
points, | ||
@@ -175,0 +179,0 @@ details: ['road_environment', 'toll'] |
@@ -169,5 +169,10 @@ // https://github.com/valhalla/valhalla-docs | ||
function costingType(query) { | ||
const { mode, proposedMode } = query; | ||
return costing[proposedMode ?? mode] || defaultCosting; | ||
} | ||
function vehicleSize(query, options) { | ||
const { mode, vehicle } = query; | ||
if (!(vehicle && mode === travelMode.rv)) { | ||
const { initialMode, mode, vehicle } = query; | ||
if (!(vehicle && (initialMode ?? mode) === travelMode.rv)) { | ||
return; | ||
@@ -183,3 +188,3 @@ } | ||
locations: query.points.map(prepareWaypoint), | ||
costing: costing[query.mode] || defaultCosting, | ||
costing: costingType(query), | ||
costing_options: {}, | ||
@@ -267,1 +272,2 @@ directions_options: { | ||
} | ||
{ | ||
"name": "@furkot/directions", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Directions service for Furkot", | ||
@@ -5,0 +5,0 @@ "author": { |
51579
19
1775