@wemap/routers 14.5.4 → 14.5.6
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/dist/index.js
CHANGED
|
@@ -852,27 +852,25 @@ var Logger = _Logger, SKIP_STEP_ANGLE_MAX = deg2rad(20), StepsBuilder = class {
|
|
|
852
852
|
for (let n = 0; n < e.vertices.length - 1; n++) {
|
|
853
853
|
let i = e.vertices[n], l = i.coords, u = e.vertices[n + 1], d = u.coords, f = e.edges[n], p = i.bearingTo(u), m = diffAngle(s, p + Math.PI), h = t.length ? t[t.length - 1] : null, g = n > 0 ? e.edges[n - 1] : null, _ = OsmTagsUtils.isGate(i.rawTags), v = OsmTagsUtils.isTurnstile(i.rawTags), y = OsmTagsUtils.isTactilePaving(f.rawTags), b = g ? OsmTagsUtils.isTactilePaving(g.rawTags) : !1, x = y && !b ? "entrance" : !y && b ? "exit" : void 0, S = OsmTagsUtils.isFunicular(f.rawTags), C = g ? OsmTagsUtils.isFunicular(g.rawTags) : !1, w = S && !C ? "entrance" : !S && C ? "exit" : void 0, { isElevator: T, areEscalators: E, areStairs: D, isMovingWalkway: O, incline: k } = f.properties, A;
|
|
854
854
|
(D || T) && k && (h?.levelDifference === null || h?.levelDifference === void 0) && (A = k);
|
|
855
|
-
let ee = g?.properties || {};
|
|
856
|
-
|
|
857
|
-
let j = OsmTagsUtils.isSubwayEntrance(i.rawTags), N = OsmTagsUtils.isEntrance(i.rawTags), P = N || j, F;
|
|
858
|
-
if (N) {
|
|
855
|
+
let ee = g?.properties || {}, j = !!(ee.incline && ee.areStairs && (!k || !D)), N = OsmTagsUtils.isSubwayEntrance(i.rawTags), P = OsmTagsUtils.isEntrance(i.rawTags), F = P || N, I;
|
|
856
|
+
if (P) {
|
|
859
857
|
if (n > 0) {
|
|
860
858
|
let t = e.vertices[n - 1].coords.level, r = d.level;
|
|
861
|
-
t === null && r !== null ?
|
|
859
|
+
t === null && r !== null ? I = "entrance" : t !== null && r === null && (I = "exit");
|
|
862
860
|
}
|
|
863
|
-
|
|
861
|
+
I ||= a.level === null ? "exit" : "entrance";
|
|
864
862
|
}
|
|
865
|
-
let
|
|
866
|
-
|
|
867
|
-
let
|
|
868
|
-
if (!o ||
|
|
863
|
+
let L = f.properties.name || i.properties.name || OsmTagsUtils.getRef(i.rawTags), te = e.edgesWeights[n], R = Math.abs(diffAngle(Math.PI, m)) >= SKIP_STEP_ANGLE_MAX, B = Level.isRange(f.level) && !Level.isRange(l.level) || A;
|
|
864
|
+
R &&= !(l.level && Level.isRange(l.level));
|
|
865
|
+
let V = isStepLevelChange(h) && !Level.isRange(l.level) || j, H = !!(B || V || F || w || v || _), ne = H || x || R && g?.length !== 0;
|
|
866
|
+
if (!o || ne) {
|
|
869
867
|
let e = null, i = null, a = null;
|
|
870
|
-
T ? a = "elevator" : E ? a = "escalator" : D ? a = "stairs" :
|
|
868
|
+
T ? a = "elevator" : E ? a = "escalator" : D ? a = "stairs" : N ? a = "subway-entrance" : _ ? a = "gate" : v ? a = "turnstile" : O ? a = "moving-walkway" : B ? a = "incline-plane" : I ? a = I : n > 0 && (a = "turn");
|
|
871
869
|
let s = getDirectionFromAngle(m);
|
|
872
|
-
|
|
870
|
+
B && (e = Level.diff(l.level, d.level) || 0, i = l.level + e, s = e > 0 ? "up" : "down", A && (s = A)), o = {
|
|
873
871
|
coords: l,
|
|
874
|
-
...
|
|
875
|
-
important:
|
|
872
|
+
...L && { name: L },
|
|
873
|
+
important: H,
|
|
876
874
|
type: a,
|
|
877
875
|
direction: s,
|
|
878
876
|
levelDifference: e,
|
|
@@ -883,7 +881,7 @@ var Logger = _Logger, SKIP_STEP_ANGLE_MAX = deg2rad(20), StepsBuilder = class {
|
|
|
883
881
|
duration: 0
|
|
884
882
|
}, t.push(o);
|
|
885
883
|
}
|
|
886
|
-
o.distance += l.distanceTo(d), o.duration +=
|
|
884
|
+
o.distance += l.distanceTo(d), o.duration += te, s = p;
|
|
887
885
|
}
|
|
888
886
|
let l = e.vertices[e.vertices.length - 1].coords;
|
|
889
887
|
return Coordinates.equals(l, a) || t.push({
|
|
@@ -2763,7 +2761,10 @@ var default_rules_default = { rules: [{
|
|
|
2763
2761
|
value: .5
|
|
2764
2762
|
}
|
|
2765
2763
|
]
|
|
2766
|
-
}] },
|
|
2764
|
+
}] }, pathSegmentsCache = /* @__PURE__ */ new Map(), getPathSegments = (e) => {
|
|
2765
|
+
let t = pathSegmentsCache.get(e);
|
|
2766
|
+
return t || (t = e.split("."), pathSegmentsCache.set(e, t)), t;
|
|
2767
|
+
}, matchAll = (e, t) => t.every(({ path: t, value: n }) => getPathSegments(t).reduce((e, t) => {
|
|
2767
2768
|
if (e != null) return e[t];
|
|
2768
2769
|
}, e) === n), createEdgeScope = (e) => ({
|
|
2769
2770
|
tags: e.rawTags,
|
|
@@ -2806,11 +2807,12 @@ var default_rules_default = { rules: [{
|
|
|
2806
2807
|
return this.edgeAcceptOnlyRules.length > 0 ? this.edgeAcceptOnlyRules.some((e) => matchAll(t, e.match)) : this.evaluateAcceptRules(t, this.edgeAcceptRules);
|
|
2807
2808
|
};
|
|
2808
2809
|
weightEdgeFn = (e) => {
|
|
2809
|
-
let t =
|
|
2810
|
-
for (let e of this.edgeWeightRules) if (matchAll(
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2810
|
+
let t = createEdgeScope(e), n = getDurationFromLength(e.length, this.baseSpeedKmh);
|
|
2811
|
+
for (let e of this.edgeWeightRules) if (matchAll(t, e.match)) {
|
|
2812
|
+
if (e.action === "set") return e.value;
|
|
2813
|
+
e.action === "multiply" && (n *= e.value);
|
|
2814
|
+
}
|
|
2815
|
+
return n;
|
|
2814
2816
|
};
|
|
2815
2817
|
weightVertexFn = (e) => {
|
|
2816
2818
|
let t = createVertexScope(e);
|
|
@@ -2916,7 +2918,39 @@ var RoutingError = class e extends Error {
|
|
|
2916
2918
|
}
|
|
2917
2919
|
};
|
|
2918
2920
|
const DefaultGraphRouterRules = new GraphRouterRulesBuilder().build();
|
|
2919
|
-
var
|
|
2921
|
+
var MinHeap = class {
|
|
2922
|
+
dists = [];
|
|
2923
|
+
verts = [];
|
|
2924
|
+
get size() {
|
|
2925
|
+
return this.dists.length;
|
|
2926
|
+
}
|
|
2927
|
+
push(e, t) {
|
|
2928
|
+
this.dists.push(e), this.verts.push(t);
|
|
2929
|
+
let n = this.dists.length - 1;
|
|
2930
|
+
for (; n > 0;) {
|
|
2931
|
+
let e = n - 1 >> 1;
|
|
2932
|
+
if (this.dists[e] <= this.dists[n]) break;
|
|
2933
|
+
this.swap(e, n), n = e;
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
pop() {
|
|
2937
|
+
let e = this.verts[0], t = this.dists.length - 1;
|
|
2938
|
+
this.dists[0] = this.dists[t], this.verts[0] = this.verts[t], this.dists.pop(), this.verts.pop();
|
|
2939
|
+
let n = 0, r = this.dists.length;
|
|
2940
|
+
for (;;) {
|
|
2941
|
+
let e = n, t = 2 * n + 1, i = 2 * n + 2;
|
|
2942
|
+
if (t < r && this.dists[t] < this.dists[e] && (e = t), i < r && this.dists[i] < this.dists[e] && (e = i), e === n) break;
|
|
2943
|
+
this.swap(e, n), n = e;
|
|
2944
|
+
}
|
|
2945
|
+
return e;
|
|
2946
|
+
}
|
|
2947
|
+
swap(e, t) {
|
|
2948
|
+
let n = this.dists[e];
|
|
2949
|
+
this.dists[e] = this.dists[t], this.dists[t] = n;
|
|
2950
|
+
let r = this.verts[e];
|
|
2951
|
+
this.verts[e] = this.verts[t], this.verts[t] = r;
|
|
2952
|
+
}
|
|
2953
|
+
}, GraphRouterEngineResults = class {
|
|
2920
2954
|
prev;
|
|
2921
2955
|
dist;
|
|
2922
2956
|
source;
|
|
@@ -2988,20 +3022,26 @@ var GraphRouterEngineResults = class {
|
|
|
2988
3022
|
e.vertices.forEach((e) => e.id = t++);
|
|
2989
3023
|
}
|
|
2990
3024
|
calculateShortestPathToMultipleDestinationsByVertex(e, t, n = DefaultGraphRouterRules, r = this.graph.vertices, i = this.graph.edges) {
|
|
2991
|
-
let a =
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3025
|
+
let a = r.length, o = Array(a).fill(Number.MAX_VALUE), s = Array(a).fill(null), c = i.filter((e) => (n.acceptEdgeFn?.(e) ?? DefaultGraphRouterRules.acceptEdgeFn?.(e)) && !this.disabledEdges.has(e)), l = n.weightEdgeFn ?? DefaultGraphRouterRules.weightEdgeFn, u = n.weightVertexFn ?? DefaultGraphRouterRules.weightVertexFn, d = Array.from({ length: a }, () => []);
|
|
3026
|
+
for (let e of c) d[e.vertex1.id].push({
|
|
3027
|
+
edge: e,
|
|
3028
|
+
neighbor: e.vertex2
|
|
3029
|
+
}), e.properties.isOneway || d[e.vertex2.id].push({
|
|
3030
|
+
edge: e,
|
|
3031
|
+
neighbor: e.vertex1
|
|
3032
|
+
});
|
|
3033
|
+
let f = Array(a).fill(!1), p = new Set(t);
|
|
3034
|
+
o[e.id] = 0;
|
|
3035
|
+
let m = new MinHeap();
|
|
3036
|
+
for (m.push(0, e); m.size > 0;) {
|
|
3037
|
+
let e = m.pop();
|
|
3038
|
+
if (!f[e.id]) {
|
|
3039
|
+
if (f[e.id] = !0, p.has(e) && (p.delete(e), p.size === 0)) break;
|
|
3040
|
+
for (let { edge: t, neighbor: n } of d[e.id]) {
|
|
3041
|
+
let r = l(t) + u(n), i = o[e.id] + r;
|
|
3042
|
+
i < o[n.id] && (o[n.id] = i, s[n.id] = e, m.push(i, n));
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3005
3045
|
}
|
|
3006
3046
|
return new GraphRouterEngineResults(s, o, e, t, c);
|
|
3007
3047
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphRouterEngine.d.ts","sourceRoot":"","sources":["../../../src/graph/GraphRouterEngine.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"GraphRouterEngine.d.ts","sourceRoot":"","sources":["../../../src/graph/GraphRouterEngine.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAqDlD,qBAAa,wBAAwB;IAC1B,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,IAAI,EAAE,CAAC;gBAGjB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,EAC1B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,EAAE,IAAI,EAAE;IASjB,aAAa,CAAC,EAAE,SAAkB,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE;IAMlE,gBAAgB,CAAC,EAAE,SAAkB;IAKrC,KAAK,CAAC,EAAE,SAAkB;IAqB1B,SAAS,CAAC,KAAK,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDzB;AAED,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAElC,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,CAAa;IACrC,SAAgB,KAAK,EAAE,KAAK,CAAC;gBAEjB,KAAK,EAAE,KAAK;IAMxB,mDAAmD,CAC/C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,GAAE,gBAA+B,EACtC,aAAa,WAAsB,EACnC,UAAU,SAAmB,GAC9B,wBAAwB;IA2D3B,6BAA6B,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,gBAA+B,EACtC,aAAa,WAAsB,EACnC,UAAU,SAAmB,GAC9B,wBAAwB;IAK3B,mBAAmB;IAuCnB,SAAS;;;;;;;;;;;;;CA0BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphRouterRules.d.ts","sourceRoot":"","sources":["../../../src/graph/GraphRouterRules.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAElK,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"GraphRouterRules.d.ts","sourceRoot":"","sources":["../../../src/graph/GraphRouterRules.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAElK,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AA+BxE,MAAM,CAAC,OAAO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AY,CAAC;AAK9D,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"StepsBuilder.d.ts","sourceRoot":"","sources":["../../../src/model/StepsBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,YAAY,CAAC;AAK9D,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAA2B,MAAM,QAAQ,CAAC;AAGzE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAI7C,MAAM,CAAC,OAAO,OAAO,YAAY;IAE7B,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,SAAS,CAAqB;IAEtC,QAAQ,CAAC,KAAK,EAAE,WAAW;IAK3B,MAAM,CAAC,GAAG,EAAE,WAAW;IAKvB,aAAa,CAAC,UAAU,EAAE,WAAW,EAAE;IAKvC,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE;IAKrC,WAAW,CAAC,QAAQ,EAAE,WAAW;IAKjC,aAAa,CAAC,UAAU,EAAE,UAAU;IAuKpC,KAAK,IAAI,IAAI,EAAE;CA6GlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wemap/routers",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@turf/convex": "^6.5.0",
|
|
24
24
|
"@turf/helpers": "^6.5.0",
|
|
25
25
|
"@types/mapbox__polyline": "^1.0.2",
|
|
26
|
-
"@wemap/core": "14.5.
|
|
27
|
-
"@wemap/geo": "14.5.
|
|
28
|
-
"@wemap/osm": "14.5.
|
|
26
|
+
"@wemap/core": "14.5.6",
|
|
27
|
+
"@wemap/geo": "14.5.6",
|
|
28
|
+
"@wemap/osm": "14.5.6",
|
|
29
29
|
"@wemap/salesman.js": "^2.1.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|