@furkot/directions 2.1.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +1 -1
- package/lib/directions.js +14 -11
- package/lib/model.js +4 -11
- package/lib/profile/index.js +4 -4
- package/lib/profile/rv/dimensions.js +2 -7
- package/lib/profile/rv/index.js +3 -4
- package/lib/service/graphhopper/index.js +7 -8
- package/lib/service/index.js +8 -8
- package/lib/service/mapquest/index.js +8 -9
- package/lib/service/openroute/index.js +8 -9
- package/lib/service/osrm/index.js +8 -9
- package/lib/service/partition.js +2 -4
- package/lib/service/simplify.js +4 -6
- package/lib/service/status.js +4 -6
- package/lib/service/tag-route.js +1 -3
- package/lib/service/util.js +18 -32
- package/lib/service/valhalla/index.js +7 -8
- package/package.json +9 -8
- package/index.js +0 -1
package/Readme.md
CHANGED
package/lib/directions.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { travelMode } from './model.js';
|
|
2
|
+
import prepareQuery from './profile/index.js';
|
|
3
|
+
import graphhopper from './service/graphhopper/index.js';
|
|
4
|
+
import mapquest from './service/mapquest/index.js';
|
|
5
|
+
import openroute from './service/openroute/index.js';
|
|
6
|
+
import osrm from './service/osrm/index.js';
|
|
7
|
+
import { defaults, withTimeout } from './service/util.js';
|
|
8
|
+
import valhalla from './service/valhalla/index.js';
|
|
6
9
|
|
|
7
10
|
function skip(options, query) {
|
|
8
11
|
// if service is disabled
|
|
@@ -14,23 +17,23 @@ function skip(options, query) {
|
|
|
14
17
|
// it should be skipped or applied to a given request
|
|
15
18
|
const services = {
|
|
16
19
|
graphhopper: {
|
|
17
|
-
service:
|
|
20
|
+
service: graphhopper,
|
|
18
21
|
skip
|
|
19
22
|
},
|
|
20
23
|
mapquest: {
|
|
21
|
-
service:
|
|
24
|
+
service: mapquest,
|
|
22
25
|
skip
|
|
23
26
|
},
|
|
24
27
|
openroute: {
|
|
25
|
-
service:
|
|
28
|
+
service: openroute,
|
|
26
29
|
skip
|
|
27
30
|
},
|
|
28
31
|
valhalla: {
|
|
29
|
-
service:
|
|
32
|
+
service: valhalla,
|
|
30
33
|
skip
|
|
31
34
|
},
|
|
32
35
|
osrm: {
|
|
33
|
-
service:
|
|
36
|
+
service: osrm,
|
|
34
37
|
skip(options, query) {
|
|
35
38
|
// or asking for walking or biking directions (OSRM doesn't do it well)
|
|
36
39
|
return skip(options, query) || (query.mode !== travelMode.car && query.mode !== travelMode.motorcycle);
|
|
@@ -41,7 +44,7 @@ const services = {
|
|
|
41
44
|
// default timeout to complete operation
|
|
42
45
|
const defaultTimeout = 20 * 1000;
|
|
43
46
|
|
|
44
|
-
function furkotDirections(options) {
|
|
47
|
+
export default function furkotDirections(options) {
|
|
45
48
|
options = {
|
|
46
49
|
timeout: defaultTimeout,
|
|
47
50
|
order: ['osrm', 'mapquest', 'valhalla', 'graphhopper', 'openroute'],
|
package/lib/model.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// path simplification constants
|
|
2
|
-
const pathType = {
|
|
2
|
+
export const pathType = {
|
|
3
3
|
none: 'none', // don't include the path in route (default)
|
|
4
4
|
coarse: 'coarse', // include heavily simplified path
|
|
5
5
|
smooth: 'smooth', // include path that is somewhat simplified
|
|
@@ -7,7 +7,7 @@ const pathType = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// travel mode constants
|
|
10
|
-
const travelMode = {
|
|
10
|
+
export const travelMode = {
|
|
11
11
|
motorcycle: -1,
|
|
12
12
|
car: 0,
|
|
13
13
|
bicycle: 1,
|
|
@@ -17,7 +17,7 @@ const travelMode = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// template for directions query object
|
|
20
|
-
const directionsQuery = {
|
|
20
|
+
export const directionsQuery = {
|
|
21
21
|
mode: travelMode.car, // numeric value of travel mode
|
|
22
22
|
avoidHighways: false, // true to avoid highways
|
|
23
23
|
avoidTolls: false, // true to avoid toll roads
|
|
@@ -33,7 +33,7 @@ const directionsQuery = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
// template for directions results object
|
|
36
|
-
const directionsResult = {
|
|
36
|
+
export const directionsResult = {
|
|
37
37
|
query: directionsQuery, // query parameters
|
|
38
38
|
places: [], // addresses or place names corresponding to points (if directions service performs reverse geocoding)
|
|
39
39
|
name: '', // human-readable name of directions (if available)
|
|
@@ -59,10 +59,3 @@ const directionsResult = {
|
|
|
59
59
|
stats: [], // list of providers that requests have been sent to to obtain directions
|
|
60
60
|
provider: '' // identifies service providing the directions
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
module.exports = {
|
|
64
|
-
directionsQuery,
|
|
65
|
-
directionsResult,
|
|
66
|
-
pathType,
|
|
67
|
-
travelMode
|
|
68
|
-
};
|
package/lib/profile/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import rv from './rv/index.js';
|
|
2
|
+
|
|
1
3
|
const profiles = {
|
|
2
|
-
5:
|
|
4
|
+
5: rv
|
|
3
5
|
};
|
|
4
6
|
|
|
5
|
-
module.exports = prepareQuery;
|
|
6
|
-
|
|
7
7
|
/**
|
|
8
8
|
* Prepares query depending on the mode.
|
|
9
9
|
* @param {Object} query - The query object.
|
|
10
10
|
* @returns {Object} The prepared query.
|
|
11
11
|
*/
|
|
12
|
-
function prepareQuery(query) {
|
|
12
|
+
export default function prepareQuery(query) {
|
|
13
13
|
const { mode } = query;
|
|
14
14
|
return profiles[mode]?.(query) || query;
|
|
15
15
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Default RV dimensions based on Valhalla defaults for truck:
|
|
3
3
|
* https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#automobile-and-bus-costing-options
|
|
4
4
|
*/
|
|
5
|
-
const defaultRV = {
|
|
5
|
+
export const defaultRV = {
|
|
6
6
|
axle_load: 9.07,
|
|
7
7
|
hazmat: true,
|
|
8
8
|
height: 4.11,
|
|
@@ -11,14 +11,9 @@ const defaultRV = {
|
|
|
11
11
|
width: 2.6
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const passengerCar = {
|
|
14
|
+
export const passengerCar = {
|
|
15
15
|
height: 3.8,
|
|
16
16
|
length: 8,
|
|
17
17
|
weight: 6,
|
|
18
18
|
width: 2.5
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
defaultRV,
|
|
23
|
-
passengerCar
|
|
24
|
-
};
|
package/lib/profile/rv/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const passengerCarEntries = Object.entries(passengerCar);
|
|
1
|
+
import { defaultRV, passengerCar } from './dimensions.js';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const passengerCarEntries = Object.entries(passengerCar);
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Treat RV as passenger car when it doesn't carry hazmat and all its dimensions
|
|
@@ -58,7 +57,7 @@ function prepareVehicle(vehicle) {
|
|
|
58
57
|
* @param {Object} query - The query object.
|
|
59
58
|
* @returns {Object} The prepared query.
|
|
60
59
|
*/
|
|
61
|
-
function prepareQuery(query) {
|
|
60
|
+
export default function prepareQuery(query) {
|
|
62
61
|
const { mode: initialMode, vehicle: initialVehicle } = query;
|
|
63
62
|
return Object.assign(
|
|
64
63
|
{
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// https://docs.graphhopper.com/#tag/Routing-API
|
|
2
2
|
// https://github.com/boldtrn/kurviger-api-documentation
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.exports = init;
|
|
4
|
+
import { pathType, travelMode } from '../../model.js';
|
|
5
|
+
import initService from '../index.js';
|
|
6
|
+
import * as status from '../status.js';
|
|
7
|
+
import tagRoute from '../tag-route.js';
|
|
8
|
+
import * as util from '../util.js';
|
|
10
9
|
|
|
11
10
|
const vehicle = {
|
|
12
11
|
1: 'bike',
|
|
@@ -162,7 +161,7 @@ function vehicleSize(query, options) {
|
|
|
162
161
|
});
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
function init(options) {
|
|
164
|
+
export default function init(options) {
|
|
166
165
|
function prepareUrl(url) {
|
|
167
166
|
return `${url}?key=${options.graphhopper_key}`;
|
|
168
167
|
}
|
|
@@ -273,5 +272,5 @@ function init(options) {
|
|
|
273
272
|
processResponse
|
|
274
273
|
});
|
|
275
274
|
options.parameters = options.graphhopper_parameters || {};
|
|
276
|
-
return
|
|
275
|
+
return initService(options);
|
|
277
276
|
}
|
package/lib/service/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
import fetchagent from 'fetchagent';
|
|
3
|
+
import makeLimiter from 'limiter-component';
|
|
4
|
+
import { pathType } from '../model.js';
|
|
5
|
+
import makeSimplify from './simplify.js';
|
|
6
|
+
import * as status from './status.js';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const debug = Debug('furkot:directions:service');
|
|
9
9
|
|
|
10
10
|
const limiters = {};
|
|
11
11
|
|
|
12
12
|
const ERROR = 'input error';
|
|
13
13
|
|
|
14
|
-
function init(options) {
|
|
14
|
+
export default function init(options) {
|
|
15
15
|
options = {
|
|
16
16
|
interval: 340,
|
|
17
17
|
penaltyInterval: 2000,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = init;
|
|
1
|
+
import { pathType } from '../../model.js';
|
|
2
|
+
import initService from '../index.js';
|
|
3
|
+
import * as status from '../status.js';
|
|
4
|
+
import * as util from '../util.js';
|
|
6
5
|
|
|
7
6
|
const units = {
|
|
8
7
|
km: 'k',
|
|
@@ -102,17 +101,17 @@ function getStatus(_err, response) {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
function init(options) {
|
|
104
|
+
export default function init(options) {
|
|
106
105
|
function getProvider(query) {
|
|
107
106
|
if (query.alternate) {
|
|
108
107
|
return options.name;
|
|
109
108
|
}
|
|
110
|
-
return
|
|
109
|
+
return `open${options.name}`;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
function getUrl(query) {
|
|
114
113
|
return (
|
|
115
|
-
options[getProvider(query)
|
|
114
|
+
options[`${getProvider(query)}_url`] +
|
|
116
115
|
'/directions/v2/' +
|
|
117
116
|
(query.alternate && query.points.length <= 2 ? 'alternateroutes' : 'route')
|
|
118
117
|
);
|
|
@@ -205,5 +204,5 @@ function init(options) {
|
|
|
205
204
|
prepareRequest,
|
|
206
205
|
processResponse
|
|
207
206
|
});
|
|
208
|
-
return
|
|
207
|
+
return initService(options);
|
|
209
208
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// https://openrouteservice.org/dev/#/api-docs/directions
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.exports = init;
|
|
3
|
+
import LatLon from 'geodesy/latlon-spherical.js';
|
|
4
|
+
import { pathType, travelMode } from '../../model.js';
|
|
5
|
+
import initService from '../index.js';
|
|
6
|
+
import * as status from '../status.js';
|
|
7
|
+
import tagRoute from '../tag-route.js';
|
|
8
|
+
import * as util from '../util.js';
|
|
10
9
|
|
|
11
10
|
const profile = {
|
|
12
11
|
'-1': 'driving-car',
|
|
@@ -183,7 +182,7 @@ function vehicleSize(query, restrictions) {
|
|
|
183
182
|
return restrictions;
|
|
184
183
|
}
|
|
185
184
|
|
|
186
|
-
function init(options) {
|
|
185
|
+
export default function init(options) {
|
|
187
186
|
function prepareUrl(query) {
|
|
188
187
|
return [options.openroute_url, profile[query.mode] || profile[0], 'json'].join('/');
|
|
189
188
|
}
|
|
@@ -272,5 +271,5 @@ function init(options) {
|
|
|
272
271
|
prepareRequest,
|
|
273
272
|
processResponse
|
|
274
273
|
});
|
|
275
|
-
return
|
|
274
|
+
return initService(options);
|
|
276
275
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { pathType } from '../../model.js';
|
|
2
|
+
import initService from '../index.js';
|
|
3
|
+
import * as status from '../status.js';
|
|
4
|
+
import * as util from '../util.js';
|
|
4
5
|
|
|
5
6
|
const code2status = {
|
|
6
7
|
Ok: status.success,
|
|
@@ -9,8 +10,6 @@ const code2status = {
|
|
|
9
10
|
};
|
|
10
11
|
const RADIUS = 1000; // search radius for nearby roads
|
|
11
12
|
|
|
12
|
-
module.exports = init;
|
|
13
|
-
|
|
14
13
|
function convertPlace(wpt) {
|
|
15
14
|
return wpt.name;
|
|
16
15
|
}
|
|
@@ -20,7 +19,7 @@ function convertStep(step) {
|
|
|
20
19
|
duration: step.duration,
|
|
21
20
|
distance: step.distance,
|
|
22
21
|
path: util.decode(step.geometry),
|
|
23
|
-
instructions: step.maneuver.type
|
|
22
|
+
instructions: `${step.maneuver.type} ${step.maneuver.modifier}`
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -76,7 +75,7 @@ const profile = {
|
|
|
76
75
|
|
|
77
76
|
function prepareUrl(baseUrl, query) {
|
|
78
77
|
function coords2string(c) {
|
|
79
|
-
return c[0].toFixed(5)
|
|
78
|
+
return `${c[0].toFixed(5)},${c[1].toFixed(5)}`;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
const path = query.points.map(coords2string).join(';');
|
|
@@ -84,7 +83,7 @@ function prepareUrl(baseUrl, query) {
|
|
|
84
83
|
return [baseUrl, 'route/v1', profile[query.mode], path].join('/');
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
function init(options) {
|
|
86
|
+
export default function init(options) {
|
|
88
87
|
function processResponse(response, query) {
|
|
89
88
|
const directions = {
|
|
90
89
|
query,
|
|
@@ -130,5 +129,5 @@ function init(options) {
|
|
|
130
129
|
prepareRequest,
|
|
131
130
|
processResponse
|
|
132
131
|
});
|
|
133
|
-
return
|
|
132
|
+
return initService(options);
|
|
134
133
|
}
|
package/lib/service/partition.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports = partition;
|
|
1
|
+
import * as util from './util.js';
|
|
4
2
|
|
|
5
3
|
function distanceSquare(p1, p2) {
|
|
6
4
|
return (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2;
|
|
@@ -71,7 +69,7 @@ function cut(prev, next) {
|
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
// divide path into routes
|
|
74
|
-
function partition(path, routes, segments) {
|
|
72
|
+
export default function partition(path, routes, segments) {
|
|
75
73
|
path.segments = segments;
|
|
76
74
|
routes[0].path = path;
|
|
77
75
|
routes.reduce(cut);
|
package/lib/service/simplify.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import simplifyPolyline from 'vis-why';
|
|
2
|
+
import { pathType } from '../model.js';
|
|
3
|
+
import * as util from './util.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function init(options = {}) {
|
|
5
|
+
export default function init(options = {}) {
|
|
8
6
|
const algorithm = options.algorithm || simplifyPolyline;
|
|
9
7
|
const endPoints = options.endPoints || 25; // how many points keep at ends
|
|
10
8
|
const maxPoints = options.pathPoints || 100; // maximum number of points kept per path
|
package/lib/service/status.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
empty: 'empty' // no result
|
|
6
|
-
};
|
|
1
|
+
export const success = 'success'; // success
|
|
2
|
+
export const failure = 'failure'; // ultimate failure
|
|
3
|
+
export const error = 'error'; // temporary error
|
|
4
|
+
export const empty = 'empty'; // no result
|
package/lib/service/tag-route.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
module.exports = tagRoute;
|
|
2
|
-
|
|
3
1
|
function splitSegment(result, length) {
|
|
4
2
|
const { segments, seg } = result;
|
|
5
3
|
const { distance, duration, path } = segments[seg];
|
|
@@ -48,7 +46,7 @@ function extractRouteType(result, [from, to, type]) {
|
|
|
48
46
|
return result;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
function tagRoute(tagSegments, params) {
|
|
49
|
+
export default function tagRoute(tagSegments, params) {
|
|
52
50
|
params.seg = params.running = 0;
|
|
53
51
|
return tagSegments?.reduce(extractRouteType, params);
|
|
54
52
|
}
|
package/lib/service/util.js
CHANGED
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
distance,
|
|
9
|
-
indexAt,
|
|
10
|
-
isFuture,
|
|
11
|
-
join,
|
|
12
|
-
last,
|
|
13
|
-
metersInKm: 1000,
|
|
14
|
-
metersInMile: 1609.34,
|
|
15
|
-
split2object,
|
|
16
|
-
collateResults,
|
|
17
|
-
withTimeout,
|
|
18
|
-
timeout
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function concat(result, path) {
|
|
1
|
+
import * as polyline from '@pirxpilot/google-polyline';
|
|
2
|
+
import LatLon from 'geodesy/latlon-spherical.js';
|
|
3
|
+
|
|
4
|
+
export const metersInKm = 1000;
|
|
5
|
+
export const metersInMile = 1609.34;
|
|
6
|
+
|
|
7
|
+
export function concat(result, path) {
|
|
22
8
|
if (path) {
|
|
23
9
|
Array.prototype.push.apply(result, path);
|
|
24
10
|
}
|
|
25
11
|
return result;
|
|
26
12
|
}
|
|
27
13
|
|
|
28
|
-
function decode(poly, factor) {
|
|
14
|
+
export function decode(poly, factor) {
|
|
29
15
|
return poly && polyline.decode(poly, factor);
|
|
30
16
|
}
|
|
31
17
|
|
|
32
|
-
function defaults(obj, source) {
|
|
18
|
+
export function defaults(obj, source) {
|
|
33
19
|
return Object.assign({}, source, obj);
|
|
34
20
|
}
|
|
35
21
|
|
|
@@ -37,11 +23,11 @@ function toLatLon(p) {
|
|
|
37
23
|
return new LatLon(p[1], p[0]);
|
|
38
24
|
}
|
|
39
25
|
|
|
40
|
-
function distance(p1, p2) {
|
|
26
|
+
export function distance(p1, p2) {
|
|
41
27
|
return toLatLon(p1).distanceTo(toLatLon(p2));
|
|
42
28
|
}
|
|
43
29
|
|
|
44
|
-
function indexAt(path, distance) {
|
|
30
|
+
export function indexAt(path, distance) {
|
|
45
31
|
let index = 1;
|
|
46
32
|
let p1 = toLatLon(path[0]);
|
|
47
33
|
let d = 0;
|
|
@@ -57,29 +43,29 @@ function indexAt(path, distance) {
|
|
|
57
43
|
return index;
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
function isFuture(time) {
|
|
46
|
+
export function isFuture(time) {
|
|
61
47
|
time = time && Date.parse(time);
|
|
62
48
|
return time && time >= Date.now();
|
|
63
49
|
}
|
|
64
50
|
|
|
65
51
|
// like normal join but with optional filter fn
|
|
66
|
-
function join(arr, conn, fn) {
|
|
52
|
+
export function join(arr, conn, fn) {
|
|
67
53
|
fn = fn || (it => it);
|
|
68
54
|
return arr.filter(fn).join(conn);
|
|
69
55
|
}
|
|
70
56
|
|
|
71
|
-
function last(arr) {
|
|
57
|
+
export function last(arr) {
|
|
72
58
|
return arr[arr.length - 1];
|
|
73
59
|
}
|
|
74
60
|
|
|
75
|
-
function split2object(str, conn, obj) {
|
|
61
|
+
export function split2object(str, conn, obj) {
|
|
76
62
|
return str.split(conn || '-').reduce((result, word) => {
|
|
77
63
|
result[word] = word;
|
|
78
64
|
return result;
|
|
79
65
|
}, obj || {});
|
|
80
66
|
}
|
|
81
67
|
|
|
82
|
-
function collateResults(results, query) {
|
|
68
|
+
export function collateResults(results, query) {
|
|
83
69
|
return results.reduce(
|
|
84
70
|
(result, r) => {
|
|
85
71
|
concatArrayProp(result, r, 'segments');
|
|
@@ -107,7 +93,7 @@ function collateResults(results, query) {
|
|
|
107
93
|
}
|
|
108
94
|
}
|
|
109
95
|
|
|
110
|
-
function withTimeout(promise, millis, signal) {
|
|
96
|
+
export function withTimeout(promise, millis, signal) {
|
|
111
97
|
let id;
|
|
112
98
|
let resolve;
|
|
113
99
|
let reject;
|
|
@@ -129,6 +115,6 @@ function withTimeout(promise, millis, signal) {
|
|
|
129
115
|
}
|
|
130
116
|
}
|
|
131
117
|
|
|
132
|
-
function timeout(millis = 0) {
|
|
118
|
+
export function timeout(millis = 0) {
|
|
133
119
|
return new Promise(resolve => setTimeout(resolve, millis));
|
|
134
120
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// https://github.com/valhalla/valhalla-docs
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = init;
|
|
3
|
+
import LatLon from 'geodesy/latlon-spherical.js';
|
|
4
|
+
import { pathType, travelMode } from '../../model.js';
|
|
5
|
+
import initService from '../index.js';
|
|
6
|
+
import * as status from '../status.js';
|
|
7
|
+
import * as util from '../util.js';
|
|
9
8
|
|
|
10
9
|
const units = {
|
|
11
10
|
km: 'kilometers',
|
|
@@ -180,7 +179,7 @@ function vehicleSize(query, options) {
|
|
|
180
179
|
Object.assign(options, vehicle);
|
|
181
180
|
}
|
|
182
181
|
|
|
183
|
-
function init(options) {
|
|
182
|
+
export default function init(options) {
|
|
184
183
|
function prepareRequest(query) {
|
|
185
184
|
let req = {
|
|
186
185
|
locations: query.points.map(prepareWaypoint),
|
|
@@ -265,5 +264,5 @@ function init(options) {
|
|
|
265
264
|
prepareRequest,
|
|
266
265
|
processResponse
|
|
267
266
|
});
|
|
268
|
-
return
|
|
267
|
+
return initService(options);
|
|
269
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furkot/directions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Directions service for Furkot",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
@@ -17,22 +17,23 @@
|
|
|
17
17
|
"furkot",
|
|
18
18
|
"directions"
|
|
19
19
|
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": "./lib/directions.js",
|
|
20
22
|
"dependencies": {
|
|
21
|
-
"@pirxpilot/google-polyline": "
|
|
22
|
-
"debug": "~
|
|
23
|
-
"fetchagent": "~
|
|
24
|
-
"geodesy": "
|
|
25
|
-
"limiter-component": "
|
|
23
|
+
"@pirxpilot/google-polyline": "~4",
|
|
24
|
+
"debug": "~4",
|
|
25
|
+
"fetchagent": "~3",
|
|
26
|
+
"geodesy": "~2",
|
|
27
|
+
"limiter-component": "~2",
|
|
26
28
|
"vis-why": "~2"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"@biomejs/biome": "^
|
|
31
|
+
"@biomejs/biome": "^2.3.13"
|
|
30
32
|
},
|
|
31
33
|
"scripts": {
|
|
32
34
|
"test": "make check"
|
|
33
35
|
},
|
|
34
36
|
"files": [
|
|
35
|
-
"index.js",
|
|
36
37
|
"lib"
|
|
37
38
|
]
|
|
38
39
|
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lib/directions');
|