@wemap/routers 11.0.1 → 11.0.3
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 +23 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/wemap-multi/WemapMultiRouter.ts +9 -3
- package/src/wemap-multi/WemapMultiRouterOptions.ts +2 -0
- package/src/wemap-osm/OsmRouter.ts +24 -10
package/dist/index.js
CHANGED
|
@@ -700,11 +700,23 @@ let OsmGraph = _OsmGraph;
|
|
|
700
700
|
__publicField(OsmGraph, "HIGHWAYS_PEDESTRIANS", HIGHWAYS_PEDESTRIANS);
|
|
701
701
|
__publicField(OsmGraph, "DEFAULT_WAY_SELECTOR", DEFAULT_WAY_SELECTOR);
|
|
702
702
|
const DEFAULT_OPTIONS = Object.assign({}, geo.GeoGraphRouter.DEFAULT_OPTIONS, {
|
|
703
|
-
weightEdgeFn: (edge) =>
|
|
703
|
+
weightEdgeFn: (edge) => {
|
|
704
|
+
if (edge.data instanceof osm.OsmNode && edge.data.isElevator) {
|
|
705
|
+
return 90;
|
|
706
|
+
}
|
|
707
|
+
let duration = getDurationFromLength(edge.length, 4);
|
|
708
|
+
if (edge.data instanceof osm.OsmWay && edge.data.areStairs) {
|
|
709
|
+
duration *= 3;
|
|
710
|
+
}
|
|
711
|
+
return duration;
|
|
712
|
+
}
|
|
704
713
|
});
|
|
705
714
|
const WITHOUT_STAIRS_OPTIONS = Object.assign({}, DEFAULT_OPTIONS, {
|
|
706
715
|
acceptEdgeFn: (edge) => edge.data.tags.highway !== "steps"
|
|
707
716
|
});
|
|
717
|
+
const DEFAULT_TRIP_OPTIONS = Object.assign({}, {
|
|
718
|
+
tspTempCoeff: 0.99
|
|
719
|
+
}, geo.GeoGraphRouter.DEFAULT_OPTIONS);
|
|
708
720
|
const buildStepsRules = (graphItinerary) => (currentCoords, nextCoords, previousStep) => {
|
|
709
721
|
var _a, _b, _c, _d, _e;
|
|
710
722
|
const edges = graphItinerary.edges;
|
|
@@ -789,14 +801,14 @@ class WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
789
801
|
}
|
|
790
802
|
return { direction, directionExtra };
|
|
791
803
|
}
|
|
792
|
-
getShortestTrip(waypoints, options =
|
|
804
|
+
getShortestTrip(waypoints, options = DEFAULT_TRIP_OPTIONS) {
|
|
793
805
|
const points = waypoints.map((waypoint) => {
|
|
794
806
|
const point = new salesman__default.default.Point(0, 0);
|
|
795
807
|
point.coords = waypoint;
|
|
796
808
|
return point;
|
|
797
809
|
});
|
|
798
810
|
const cache = [];
|
|
799
|
-
const solution = salesman__default.default.solve(points,
|
|
811
|
+
const solution = salesman__default.default.solve(points, options.tspTempCoeff, void 0, (p, q) => {
|
|
800
812
|
const osmItinerary = this.getShortestPath(
|
|
801
813
|
p.coords,
|
|
802
814
|
q.coords,
|
|
@@ -807,9 +819,9 @@ class WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
807
819
|
});
|
|
808
820
|
const orderedPoints = solution.map((i) => points[i]);
|
|
809
821
|
const orderedItineraries = [];
|
|
810
|
-
for (let i = 0; i < orderedPoints.length
|
|
822
|
+
for (let i = 0; i < orderedPoints.length; i++) {
|
|
811
823
|
const p = orderedPoints[i];
|
|
812
|
-
const q = orderedPoints[i + 1];
|
|
824
|
+
const q = orderedPoints[(i + 1) % orderedPoints.length];
|
|
813
825
|
let cachedItinerary = cache.find((itinerary) => itinerary.start === p.coords && itinerary.end === q.coords || itinerary.end === p.coords && itinerary.start === q.coords);
|
|
814
826
|
if (cachedItinerary.end === p.coords) {
|
|
815
827
|
cachedItinerary = geo.GeoGraphItinerary.fromGraphVertices(
|
|
@@ -823,7 +835,7 @@ class WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
823
835
|
}
|
|
824
836
|
return orderedItineraries;
|
|
825
837
|
}
|
|
826
|
-
getTripItinerary(waypoints, options =
|
|
838
|
+
getTripItinerary(waypoints, options = DEFAULT_TRIP_OPTIONS) {
|
|
827
839
|
const shortestTrip = this.getShortestTrip(waypoints, options);
|
|
828
840
|
return new Itinerary({
|
|
829
841
|
from: shortestTrip[0].start,
|
|
@@ -1814,7 +1826,11 @@ class WemapMultiRouter {
|
|
|
1814
1826
|
return ioMapsToTest;
|
|
1815
1827
|
}
|
|
1816
1828
|
convertOptionsToWemapOsmOptions(options) {
|
|
1817
|
-
|
|
1829
|
+
const outputOptions = !options || !("useStairs" in options) || options.useStairs ? WemapOsmRouter.DEFAULT_OPTIONS : WemapOsmRouter.WITHOUT_STAIRS_OPTIONS;
|
|
1830
|
+
if (typeof (options == null ? void 0 : options.tspTempCoeff) !== "undefined") {
|
|
1831
|
+
outputOptions.tspTempCoeff = options.tspTempCoeff;
|
|
1832
|
+
}
|
|
1833
|
+
return outputOptions;
|
|
1818
1834
|
}
|
|
1819
1835
|
async getTrip(mode, waypoints, options = null) {
|
|
1820
1836
|
const ioMapsToTest = this.getIoMapsFromOptions(options);
|