@furkot/directions 3.0.0 → 3.0.2
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.
|
@@ -119,8 +119,8 @@ function getStatus(st, response) {
|
|
|
119
119
|
if (!(st || response)) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
response
|
|
123
|
-
response.status
|
|
122
|
+
response ??= {};
|
|
123
|
+
response.status ||= st;
|
|
124
124
|
// 401 Unauthorized, 429 Too Many Requests
|
|
125
125
|
if (st === 401 || st === 429) {
|
|
126
126
|
// we exceeded the limit
|
package/lib/service/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function extractSegment(result, { distance, index, narrative, time }) {
|
|
|
47
47
|
segments.push({
|
|
48
48
|
duration: time,
|
|
49
49
|
distance: Math.round((distance || 0) * unitMultiplier),
|
|
50
|
-
path: indexes && path
|
|
50
|
+
path: indexes && path?.slice(indexes[index], indexes[index + 1]),
|
|
51
51
|
instructions: narrative
|
|
52
52
|
});
|
|
53
53
|
return result;
|
|
@@ -130,7 +130,7 @@ export default function init(options) {
|
|
|
130
130
|
req.avoids = ['Limited Access'];
|
|
131
131
|
}
|
|
132
132
|
if (query.avoidTolls) {
|
|
133
|
-
req.avoids
|
|
133
|
+
req.avoids ??= [];
|
|
134
134
|
req.avoids.push('Toll Road');
|
|
135
135
|
}
|
|
136
136
|
if (query.begin) {
|
|
@@ -190,8 +190,8 @@ export default function init(options) {
|
|
|
190
190
|
function avoidFeature(result, flag) {
|
|
191
191
|
const { query, req } = result;
|
|
192
192
|
if (query[flag]) {
|
|
193
|
-
req.options
|
|
194
|
-
req.options.avoid_features
|
|
193
|
+
req.options ??= {};
|
|
194
|
+
req.options.avoid_features ??= [];
|
|
195
195
|
req.options.avoid_features.push(avoidFeatures[flag]);
|
|
196
196
|
}
|
|
197
197
|
return result;
|
package/lib/service/util.js
CHANGED
|
@@ -49,13 +49,12 @@ export function isFuture(time) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// like normal join but with optional filter fn
|
|
52
|
-
export function join(arr, conn, fn) {
|
|
53
|
-
fn = fn || (it => it);
|
|
52
|
+
export function join(arr, conn, fn = it => it) {
|
|
54
53
|
return arr.filter(fn).join(conn);
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
export function last(arr) {
|
|
58
|
-
return arr
|
|
57
|
+
return arr.at(-1);
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
export function split2object(str, conn, obj) {
|
|
@@ -27,6 +27,7 @@ const turnDistance = 100; // don't adjust speed of turns
|
|
|
27
27
|
const maxRoundabout = 12 * 60 * 60; // 12 hours maximum for route that is 10 times longer than direct distance
|
|
28
28
|
|
|
29
29
|
const maneuver = {
|
|
30
|
+
start: 1,
|
|
30
31
|
ferryEnter: 28,
|
|
31
32
|
ferryExit: 29
|
|
32
33
|
};
|
|
@@ -42,7 +43,7 @@ function prepareWaypoint(p) {
|
|
|
42
43
|
|
|
43
44
|
function extractSegment(
|
|
44
45
|
result,
|
|
45
|
-
{ type, begin_shape_index, end_shape_index, instruction, length, time, rough, toll, travel_mode }
|
|
46
|
+
{ type, begin_shape_index, end_shape_index, ferry, instruction, length, time, rough, toll, travel_mode }
|
|
46
47
|
) {
|
|
47
48
|
const {
|
|
48
49
|
directions: { segments, routes },
|
|
@@ -82,7 +83,7 @@ function extractSegment(
|
|
|
82
83
|
util.last(segments).mode = travelMode.ferry;
|
|
83
84
|
util.last(routes).ferry = true;
|
|
84
85
|
}
|
|
85
|
-
} else if (type === maneuver.ferryEnter) {
|
|
86
|
+
} else if (type === maneuver.ferryEnter || (type === maneuver.start && ferry)) {
|
|
86
87
|
seg.mode = travelMode.ferry;
|
|
87
88
|
result.ferry = util.last(routes).ferry = true;
|
|
88
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furkot/directions",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Directions service for Furkot",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"vis-why": "~2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@biomejs/biome": "
|
|
31
|
+
"@biomejs/biome": "2.3.13"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "make check"
|