furkot-directions
Advanced tools
Comparing version 1.3.2 to 1.4.0
1.4.0 / 2020-10-28 | ||
================== | ||
* upgrade openrouteservice to version 2 | ||
* support passing authorization header | ||
* support POST as well as GET | ||
1.3.2 / 2020-01-26 | ||
@@ -3,0 +10,0 @@ ================== |
@@ -22,5 +22,13 @@ var fetchagent = require('fetchagent'); | ||
function request(url, req, fn) { | ||
return fetchagent | ||
.get(url) | ||
.query(req) | ||
var options = this, fa = fetchagent; | ||
if (options.post) { | ||
fa = fa.post(url).send(req); | ||
} | ||
else { | ||
fa = fa.get(url).query(req); | ||
} | ||
if (options.authorization) { | ||
fa.set('authorization', options.authorization); | ||
} | ||
return fa | ||
.set('accept', 'application/json') | ||
@@ -27,0 +35,0 @@ .end(fn); |
@@ -20,7 +20,2 @@ const { pathType } = require("../../model"); | ||
function prepareWaypoint(p) { | ||
// waypoint format is lon,lat | ||
return p[0] + ',' + p[1]; | ||
} | ||
function extractStep(result, { distance, duration, instruction, way_points }) { | ||
@@ -80,3 +75,3 @@ const { directions: { segments }, path } = result; | ||
if (restrictions.axle_load !== undefined) { | ||
restrictions.axleload= restrictions.axle_load; | ||
restrictions.axleload = restrictions.axle_load; | ||
delete restrictions.axle_load; | ||
@@ -89,7 +84,13 @@ } | ||
function prepareUrl(query) { | ||
return [ | ||
options.openroute_url, | ||
profile[query.mode] || profile[0], | ||
'json' | ||
].join('/'); | ||
} | ||
function prepareRequest(query) { | ||
const req = { | ||
api_key: options.openroute_key, | ||
profile: profile[query.mode] || profile[0], | ||
coordinates: query.points.map(prepareWaypoint).join('|') | ||
coordinates: query.points | ||
}; | ||
@@ -107,3 +108,3 @@ if (!query.turnbyturn && query.path !== pathType.smooth && query.path !== pathType.coarse) { | ||
} | ||
if (req.profile === 'driving-car') { | ||
if ((profile[query.mode] || profile[0]) === 'driving-car') { | ||
if (query.avoidHighways) { | ||
@@ -120,8 +121,2 @@ req.options = req.options || { | ||
} | ||
if (req.options) { | ||
if (req.options.avoid_features) { | ||
req.options.avoid_features = req.options.avoid_features.join('|'); | ||
} | ||
req.options = JSON.stringify(req.options); | ||
} | ||
@@ -165,3 +160,5 @@ return req; | ||
maxPoints: 10, // unknown maximum | ||
url: options.openroute_url, | ||
post: true, | ||
authorization: options.openroute_key, | ||
url: prepareUrl, | ||
status: getStatus, | ||
@@ -168,0 +165,0 @@ prepareRequest, |
{ | ||
"name": "furkot-directions", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Directions service for Furkot", | ||
@@ -5,0 +5,0 @@ "author": { |
82179
1419