furkot-directions
Advanced tools
Comparing version 1.3.0 to 1.3.1
1.3.1 / 2019-10-25 | ||
================== | ||
* confugurable maximum points for GraphHopper | ||
* restrict calculating curvy roads to configured maximum distance | ||
* extended road curvature options for GraphHopper | ||
* more tests for aborting requests | ||
1.3.0 / 2019-09-25 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -16,3 +16,5 @@ const { pathType } = require("../../model"); | ||
const weighting = { | ||
true: 'curvature' | ||
true: 'curvature', | ||
1: 'curvature', | ||
2: 'curvaturefastest' | ||
}; | ||
@@ -82,3 +84,3 @@ | ||
function prepareUrl(url, { avoidHighways, avoidTolls, mode, path, points, turnbyturn, curvy }) { | ||
function prepareUrl(url, { avoidHighways, avoidTolls, avoidUnpaved, curvy, mode, path, points, turnbyturn }) { | ||
let req = { | ||
@@ -91,2 +93,8 @@ vehicle: vehicle[mode] || vehicle[0], | ||
req.weighting = weighting[curvy]; | ||
if (options.parameters.app_type) { | ||
req['app.type'] = options.parameters.app_type; | ||
} | ||
if (avoidUnpaved) { | ||
req.avoid_unpaved_roads = true; | ||
} | ||
} | ||
@@ -115,4 +123,5 @@ if (!turnbyturn && path !== pathType.smooth && path !== pathType.coarse) { | ||
function prepareRequest() { | ||
return true; | ||
function prepareRequest({ mode, points, curvy }) { | ||
return !(options.parameters.max_curvy_distance && curvy && mode === -1 && points.length === 2 && | ||
util.distance(points[0], points[1]) > options.parameters.max_curvy_distance); | ||
} | ||
@@ -151,3 +160,3 @@ | ||
options = util.defaults(options, { | ||
maxPoints: 5, // max 5 points for free and 30-150 for paid plan | ||
maxPoints: options.graphhopper_max_points || 5, // max 5 points for free and 30-150 for paid plan | ||
url: prepareUrl.bind(undefined, options.graphhopper_url), | ||
@@ -154,0 +163,0 @@ status: getStatus, |
@@ -5,13 +5,14 @@ var LatLon = require('geodesy/latlon-spherical'); | ||
module.exports = { | ||
concat: concat, | ||
decode: decode, | ||
defaults: defaults, | ||
indexAt: indexAt, | ||
isFuture: isFuture, | ||
join: join, | ||
last: last, | ||
concat, | ||
decode, | ||
defaults, | ||
distance, | ||
indexAt, | ||
isFuture, | ||
join, | ||
last, | ||
metersInKm: 1000, | ||
metersInMile: 1609.34, | ||
split2object: split2object, | ||
splitPoints: splitPoints | ||
split2object, | ||
splitPoints | ||
}; | ||
@@ -34,6 +35,14 @@ | ||
function toLatLon(p) { | ||
return new LatLon(p[1], p[0]); | ||
} | ||
function distance(p1, p2) { | ||
return toLatLon(p1).distanceTo(toLatLon(p2)); | ||
} | ||
function indexAt(path, distance) { | ||
var index = 1, p1 = new LatLon(path[0][1], path[0][0]), d = 0, p2; | ||
var index = 1, p1 = toLatLon(path[0]), d = 0, p2; | ||
while (index < path.length) { | ||
p2 = new LatLon(path[index][1], path[index][0]); | ||
p2 = toLatLon(path[index]); | ||
d += p1.distanceTo(p2); | ||
@@ -40,0 +49,0 @@ if (d > distance) { |
{ | ||
"name": "furkot-directions", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Directions service for Furkot", | ||
@@ -5,0 +5,0 @@ "author": { |
81392
1403