@wemap/routers 11.2.4 → 11.3.1
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 +53 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -33
- package/dist/index.mjs.map +1 -1
- package/index.ts +1 -0
- package/package.json +4 -4
- package/src/model/LevelChange.spec.ts +1 -0
- package/src/model/LevelChange.ts +2 -1
- package/src/wemap-multi/CustomNetworkMap.ts +5 -5
- package/src/wemap-multi/WemapMultiRouter.ts +5 -8
- package/src/wemap-multi/WemapMultiRouterOptions.ts +2 -7
- package/src/wemap-osm/OsmRouter.ts +61 -33
- package/src/wemap-osm/OsmRouterOptions.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -700,28 +700,6 @@ const _OsmGraph = class extends geo.GeoGraph {
|
|
|
700
700
|
let OsmGraph = _OsmGraph;
|
|
701
701
|
__publicField(OsmGraph, "HIGHWAYS_PEDESTRIANS", HIGHWAYS_PEDESTRIANS);
|
|
702
702
|
__publicField(OsmGraph, "DEFAULT_WAY_SELECTOR", DEFAULT_WAY_SELECTOR);
|
|
703
|
-
const DEFAULT_OPTIONS = Object.assign({}, geo.GeoGraphRouter.DEFAULT_OPTIONS, {
|
|
704
|
-
weightEdgeFn: (edge) => {
|
|
705
|
-
if (edge.data.isElevator) {
|
|
706
|
-
return 90;
|
|
707
|
-
}
|
|
708
|
-
let duration = getDurationFromLength(edge.length, 4);
|
|
709
|
-
if (edge.data instanceof osm.OsmWay && edge.data.areStairs) {
|
|
710
|
-
duration *= 3;
|
|
711
|
-
}
|
|
712
|
-
return duration;
|
|
713
|
-
},
|
|
714
|
-
acceptEdgeFn: (edge) => {
|
|
715
|
-
const accessTag = edge.data.tags.access;
|
|
716
|
-
return typeof accessTag === "undefined" || accessTag === "yes";
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
const WITHOUT_STAIRS_OPTIONS = Object.assign({}, DEFAULT_OPTIONS, {
|
|
720
|
-
acceptEdgeFn: (edge) => edge.data.tags.highway !== "steps"
|
|
721
|
-
});
|
|
722
|
-
const DEFAULT_TRIP_OPTIONS = Object.assign({}, {
|
|
723
|
-
tspTempCoeff: 0.99
|
|
724
|
-
}, geo.GeoGraphRouter.DEFAULT_OPTIONS);
|
|
725
703
|
const buildStepsRules = (graphItinerary) => (currentCoords, nextCoords, previousStep) => {
|
|
726
704
|
var _a, _b, _c, _d, _e;
|
|
727
705
|
const edges = graphItinerary.edges;
|
|
@@ -739,10 +717,12 @@ const buildStepsRules = (graphItinerary) => (currentCoords, nextCoords, previous
|
|
|
739
717
|
let levelChangeType = null;
|
|
740
718
|
if (edge.data.isElevator) {
|
|
741
719
|
levelChangeType = "elevator";
|
|
742
|
-
} else if (edge.data.isConveying) {
|
|
720
|
+
} else if (edge.data instanceof osm.OsmWay && edge.data.isConveying && edge.data.areStairs) {
|
|
743
721
|
levelChangeType = "conveyor";
|
|
744
722
|
} else if (edge.data instanceof osm.OsmWay && edge.data.areStairs) {
|
|
745
723
|
levelChangeType = "stairs";
|
|
724
|
+
} else if (edge.data instanceof osm.OsmWay && edge.data.isConveying) {
|
|
725
|
+
levelChangeType = "moving walkway";
|
|
746
726
|
}
|
|
747
727
|
let forceLevelChange;
|
|
748
728
|
const edgeTags = edge.data.tags || {};
|
|
@@ -782,17 +762,17 @@ const buildStepsRules = (graphItinerary) => (currentCoords, nextCoords, previous
|
|
|
782
762
|
...forceEndOfLevelChange && { forceEndOfLevelChange }
|
|
783
763
|
};
|
|
784
764
|
};
|
|
785
|
-
class
|
|
765
|
+
const _WemapOsmRouter = class extends geo.GeoGraphRouter {
|
|
786
766
|
constructor(graph) {
|
|
787
767
|
super(graph);
|
|
788
768
|
}
|
|
789
769
|
static get rname() {
|
|
790
770
|
return "wemap-osm";
|
|
791
771
|
}
|
|
792
|
-
getShortestPath(start, end, options = DEFAULT_OPTIONS) {
|
|
772
|
+
getShortestPath(start, end, options = _WemapOsmRouter.DEFAULT_OPTIONS) {
|
|
793
773
|
return super.getShortestPath(start, end, options);
|
|
794
774
|
}
|
|
795
|
-
getItinerary(start, end, options = DEFAULT_OPTIONS) {
|
|
775
|
+
getItinerary(start, end, options = _WemapOsmRouter.DEFAULT_OPTIONS) {
|
|
796
776
|
const graphItinerary = this.getShortestPath(start, end, options);
|
|
797
777
|
return Itinerary.fromGraphItinerary(graphItinerary, "WALK", buildStepsRules(graphItinerary));
|
|
798
778
|
}
|
|
@@ -812,7 +792,7 @@ class WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
812
792
|
}
|
|
813
793
|
return { direction, directionExtra };
|
|
814
794
|
}
|
|
815
|
-
getShortestTrip(waypoints, options = DEFAULT_TRIP_OPTIONS) {
|
|
795
|
+
getShortestTrip(waypoints, options = _WemapOsmRouter.DEFAULT_TRIP_OPTIONS) {
|
|
816
796
|
const points = waypoints.map((waypoint) => {
|
|
817
797
|
const point = new salesman__default.default.Point(0, 0);
|
|
818
798
|
point.coords = waypoint;
|
|
@@ -846,7 +826,7 @@ class WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
846
826
|
}
|
|
847
827
|
return orderedItineraries;
|
|
848
828
|
}
|
|
849
|
-
getTripItinerary(waypoints, options = DEFAULT_TRIP_OPTIONS) {
|
|
829
|
+
getTripItinerary(waypoints, options = _WemapOsmRouter.DEFAULT_TRIP_OPTIONS) {
|
|
850
830
|
const shortestTrip = this.getShortestTrip(waypoints, options);
|
|
851
831
|
return new Itinerary({
|
|
852
832
|
from: shortestTrip[0].start,
|
|
@@ -854,9 +834,49 @@ class WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
854
834
|
legs: shortestTrip.map((graphItinerary) => Leg.fromGraphItinerary(graphItinerary))
|
|
855
835
|
});
|
|
856
836
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
837
|
+
static buildOptions(options) {
|
|
838
|
+
const weightEdgeFn = (edge) => {
|
|
839
|
+
var _a;
|
|
840
|
+
if ((_a = edge.data) == null ? void 0 : _a.isElevator) {
|
|
841
|
+
return 90;
|
|
842
|
+
}
|
|
843
|
+
let duration = getDurationFromLength(edge.length, 4);
|
|
844
|
+
if (edge.data instanceof osm.OsmWay && edge.data.areStairs) {
|
|
845
|
+
duration *= 3;
|
|
846
|
+
}
|
|
847
|
+
return duration;
|
|
848
|
+
};
|
|
849
|
+
const acceptEdgeFn = (edge) => {
|
|
850
|
+
var _a, _b, _c;
|
|
851
|
+
const accessTag = (_b = (_a = edge.data) == null ? void 0 : _a.tags) == null ? void 0 : _b.access;
|
|
852
|
+
if (typeof accessTag !== "undefined" && accessTag !== "yes")
|
|
853
|
+
return false;
|
|
854
|
+
if (typeof (options == null ? void 0 : options.useStairs) !== "undefined" && !(options == null ? void 0 : options.useStairs) && edge.data instanceof osm.OsmWay && edge.data.areStairs && !edge.data.isConveying)
|
|
855
|
+
return false;
|
|
856
|
+
if (typeof (options == null ? void 0 : options.useEscalator) !== "undefined" && !(options == null ? void 0 : options.useEscalator) && edge.data instanceof osm.OsmWay && edge.data.areStairs && edge.data.isConveying)
|
|
857
|
+
return false;
|
|
858
|
+
if (typeof (options == null ? void 0 : options.useElevator) !== "undefined" && !(options == null ? void 0 : options.useElevator) && ((_c = edge.data) == null ? void 0 : _c.isElevator))
|
|
859
|
+
return false;
|
|
860
|
+
return true;
|
|
861
|
+
};
|
|
862
|
+
return {
|
|
863
|
+
weightEdgeFn,
|
|
864
|
+
acceptEdgeFn,
|
|
865
|
+
projectionMaxDistance: geo.GeoGraphRouter.DEFAULT_OPTIONS.projectionMaxDistance
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
static buildTripOptions(options) {
|
|
869
|
+
return Object.assign(
|
|
870
|
+
{},
|
|
871
|
+
_WemapOsmRouter.buildOptions(options),
|
|
872
|
+
{ tspTempCoeff: 0.99 }
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
let WemapOsmRouter = _WemapOsmRouter;
|
|
877
|
+
__publicField(WemapOsmRouter, "DEFAULT_OPTIONS", _WemapOsmRouter.buildOptions());
|
|
878
|
+
__publicField(WemapOsmRouter, "WITHOUT_STAIRS_OPTIONS", _WemapOsmRouter.buildOptions({ useStairs: false }));
|
|
879
|
+
__publicField(WemapOsmRouter, "DEFAULT_TRIP_OPTIONS", _WemapOsmRouter.buildTripOptions());
|
|
860
880
|
class RemoteRouter {
|
|
861
881
|
}
|
|
862
882
|
class RemoteRouterServerUnreachable extends Error {
|
|
@@ -1858,8 +1878,8 @@ class WemapMultiRouter {
|
|
|
1858
1878
|
}
|
|
1859
1879
|
return ioMapsToTest;
|
|
1860
1880
|
}
|
|
1861
|
-
convertOptionsToWemapOsmOptions(options) {
|
|
1862
|
-
const outputOptions =
|
|
1881
|
+
convertOptionsToWemapOsmOptions(options = null) {
|
|
1882
|
+
const outputOptions = WemapOsmRouter.buildOptions(options ? options : {});
|
|
1863
1883
|
if (typeof (options == null ? void 0 : options.tspTempCoeff) !== "undefined") {
|
|
1864
1884
|
outputOptions.tspTempCoeff = options.tspTempCoeff;
|
|
1865
1885
|
}
|