@wemap/routers 11.7.0 → 11.8.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/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/wemap-multi/CustomNetworkMap.ts +5 -0
- package/src/wemap-multi/WemapMultiRouter.ts +25 -0
- package/src/wemap-osm/OsmRouter.ts +28 -1
package/dist/index.js
CHANGED
|
@@ -839,6 +839,21 @@ const _WemapOsmRouter = class _WemapOsmRouter extends geo.GeoGraphRouter {
|
|
|
839
839
|
const graphItinerary = this.getShortestPath(start, end, options);
|
|
840
840
|
return Itinerary.fromGraphItinerary(graphItinerary, "WALK", buildStepsRules(graphItinerary));
|
|
841
841
|
}
|
|
842
|
+
getShortestPaths(start, ends, options = _WemapOsmRouter.DEFAULT_OPTIONS) {
|
|
843
|
+
return super.getShortestPaths(start, ends, options);
|
|
844
|
+
}
|
|
845
|
+
getItineraries(start, ends, options = _WemapOsmRouter.DEFAULT_OPTIONS) {
|
|
846
|
+
const graphItineraries = this.getShortestPaths(start, ends, options);
|
|
847
|
+
return graphItineraries.map((graphItinerary, idx) => {
|
|
848
|
+
if (graphItinerary === null || !graphItinerary.edges.length) {
|
|
849
|
+
const startCoords = start instanceof geo.GeoGraphVertex ? start.coords : start;
|
|
850
|
+
const end = ends[idx];
|
|
851
|
+
const endCoords = end instanceof geo.GeoGraphVertex ? end.coords : end;
|
|
852
|
+
return new Itinerary({ from: startCoords, to: endCoords, legs: [] });
|
|
853
|
+
}
|
|
854
|
+
return Itinerary.fromGraphItinerary(graphItinerary, "WALK", buildStepsRules(graphItinerary));
|
|
855
|
+
});
|
|
856
|
+
}
|
|
842
857
|
static getTurnInfoFromAngle(_angle) {
|
|
843
858
|
let direction, directionExtra;
|
|
844
859
|
const directionAngle = maths.rad2deg(maths.diffAngle(_angle, Math.PI));
|
|
@@ -2054,6 +2069,22 @@ class WemapMultiRouter {
|
|
|
2054
2069
|
itineraries: [tripItinerary]
|
|
2055
2070
|
});
|
|
2056
2071
|
}
|
|
2072
|
+
async getItinerariesMultipleDestinations(start, ends, options = null) {
|
|
2073
|
+
const ioMapsToTest = this.getIoMapsFromOptions(options);
|
|
2074
|
+
const mapOfWaypoints = [start, ...ends].reduce((map, waypoint) => {
|
|
2075
|
+
const mapOfThisWaypoint = ioMapsToTest.find((map2) => map2.isPointInside(waypoint)) || null;
|
|
2076
|
+
if (mapOfThisWaypoint && map && mapOfThisWaypoint !== map) {
|
|
2077
|
+
throw Error(`Cannot handle this itineraries, because two points are on different maps (${mapOfThisWaypoint} and ${mapOfWaypoints}). Multi-map multiple destinations are not implemented.`);
|
|
2078
|
+
}
|
|
2079
|
+
return mapOfThisWaypoint;
|
|
2080
|
+
}, null);
|
|
2081
|
+
const wemapOsmRouterOptions = this.convertOptionsToWemapOsmOptions(options);
|
|
2082
|
+
const itineraries = mapOfWaypoints.getItinerariesMultipleDestinationsInsideMap(start, ends, wemapOsmRouterOptions);
|
|
2083
|
+
return {
|
|
2084
|
+
routerName: this.rname,
|
|
2085
|
+
itineraries
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2057
2088
|
async getItineraries(mode, waypoints, options = null) {
|
|
2058
2089
|
var _a;
|
|
2059
2090
|
if (waypoints.length > 2) {
|
|
@@ -2352,6 +2383,9 @@ class CustomNetworkMap {
|
|
|
2352
2383
|
getTripInsideMap(waypoints, options) {
|
|
2353
2384
|
return this.router.getTripItinerary(waypoints, options);
|
|
2354
2385
|
}
|
|
2386
|
+
getItinerariesMultipleDestinationsInsideMap(start, ends, options) {
|
|
2387
|
+
return this.router.getItineraries(start, ends, options);
|
|
2388
|
+
}
|
|
2355
2389
|
enableWay(osmId) {
|
|
2356
2390
|
this.graph.edges.filter((edge) => edge.data.id === osmId).forEach((e) => this.router.disabledEdges.delete(e));
|
|
2357
2391
|
this.disabledWays.delete(osmId);
|