@wemap/routers 11.0.0-alpha.16 → 11.0.0-alpha.18
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 +22 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/wemap-multi/CustomNetworkMap.ts +29 -8
package/dist/index.js
CHANGED
|
@@ -13,7 +13,6 @@ const Logger = require("@wemap/logger");
|
|
|
13
13
|
const Polyline = require("@mapbox/polyline");
|
|
14
14
|
const pointInPolygon = require("@turf/boolean-point-in-polygon");
|
|
15
15
|
const convexHullFn = require("@turf/convex");
|
|
16
|
-
const helpers = require("@turf/helpers");
|
|
17
16
|
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
18
17
|
const Logger__default = /* @__PURE__ */ _interopDefaultLegacy(Logger);
|
|
19
18
|
const Polyline__default = /* @__PURE__ */ _interopDefaultLegacy(Polyline);
|
|
@@ -1793,14 +1792,17 @@ class CustomNetworkMap {
|
|
|
1793
1792
|
});
|
|
1794
1793
|
this.entryPoints = entryPoints;
|
|
1795
1794
|
if (bounds) {
|
|
1796
|
-
this.bounds =
|
|
1795
|
+
this.bounds = bounds;
|
|
1797
1796
|
} else {
|
|
1798
1797
|
const polygon = [network.nodes.map((node) => [node.coords.lng, node.coords.lat])];
|
|
1799
1798
|
const convexHull = convexHullFn__default.default({ type: "polygon", coordinates: polygon });
|
|
1800
1799
|
if (!convexHull) {
|
|
1801
1800
|
throw new Error(`Cannot calculate convexHull of network "${name}"`);
|
|
1802
1801
|
}
|
|
1803
|
-
this.bounds =
|
|
1802
|
+
this.bounds = {
|
|
1803
|
+
type: "MultiPolygon",
|
|
1804
|
+
coordinates: [convexHull.geometry.coordinates]
|
|
1805
|
+
};
|
|
1804
1806
|
}
|
|
1805
1807
|
}
|
|
1806
1808
|
static fromOsmXml(osmXmlString, name = null) {
|
|
@@ -1810,11 +1812,25 @@ class CustomNetworkMap {
|
|
|
1810
1812
|
if (entryPoints.some((el) => el === null) || new Set(entryPoints).size !== entryPoints.length) {
|
|
1811
1813
|
throw new Error("Cannot parse wemap:routing-io correctly");
|
|
1812
1814
|
}
|
|
1813
|
-
const
|
|
1814
|
-
|
|
1815
|
+
const bounds = {
|
|
1816
|
+
type: "MultiPolygon",
|
|
1817
|
+
coordinates: []
|
|
1818
|
+
};
|
|
1819
|
+
osmModel.ways.filter(({ tags }) => tags["wemap:routing-bounds"]).forEach((way) => {
|
|
1820
|
+
bounds.coordinates.push([
|
|
1821
|
+
way.nodes.reduce((acc, node) => {
|
|
1822
|
+
acc.push([node.coords.lng, node.coords.lat]);
|
|
1823
|
+
return acc;
|
|
1824
|
+
}, [])
|
|
1825
|
+
]);
|
|
1826
|
+
});
|
|
1827
|
+
osmModel.relations.filter((rel) => rel.tags["wemap:routing-bounds"] && rel.isMultipolygon()).forEach((rel) => {
|
|
1828
|
+
const polygon = rel.getGeoJsonPolygon();
|
|
1829
|
+
polygon && bounds.coordinates.push(polygon.coordinates);
|
|
1830
|
+
});
|
|
1831
|
+
if (!bounds.coordinates.length) {
|
|
1815
1832
|
throw new Error('Search bounds is undefined. Please use OSM tag : "wemap:routing-bounds=yes"');
|
|
1816
1833
|
}
|
|
1817
|
-
const bounds = wayBounds.nodes.map((node) => node.coords);
|
|
1818
1834
|
return new CustomNetworkMap(network, entryPoints, bounds, name);
|
|
1819
1835
|
}
|
|
1820
1836
|
isPointInside(coordinates) {
|