@wemap/routers 12.12.0 → 12.12.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.mjs CHANGED
@@ -2403,6 +2403,12 @@ const _GraphRouterOptionsBuilder = class _GraphRouterOptionsBuilder {
2403
2403
  }
2404
2404
  return duration;
2405
2405
  };
2406
+ const weightVertexFn = (vertex) => {
2407
+ if (vertex.properties.isTurnstile) {
2408
+ return 5;
2409
+ }
2410
+ return 0;
2411
+ };
2406
2412
  const acceptEdgeFn = (edge) => {
2407
2413
  if (edge.properties.wheelchair) {
2408
2414
  if (this.isWheelchair && edge.properties.wheelchair === "no")
@@ -2441,6 +2447,7 @@ const _GraphRouterOptionsBuilder = class _GraphRouterOptionsBuilder {
2441
2447
  projectionMaxDistance: this.projectionMaxDistance
2442
2448
  },
2443
2449
  weightEdgeFn,
2450
+ weightVertexFn,
2444
2451
  acceptEdgeFn,
2445
2452
  projectionMaxDistance: this.projectionMaxDistance,
2446
2453
  useMultiLevelSegments: this.useMultiLevelSegments
@@ -2552,6 +2559,7 @@ class GraphRouterEngine {
2552
2559
  return (((_a = options.acceptEdgeFn) == null ? void 0 : _a.call(options, e)) ?? true) && !this.disabledEdges.has(e);
2553
2560
  });
2554
2561
  const weightEdgeFn = options.weightEdgeFn || ((edge) => edge.length);
2562
+ const weightVertexFn = options.weightVertexFn || ((vertex) => 0);
2555
2563
  const getVertexWithMinDistance = (vertices) => {
2556
2564
  let minDistance = Number.MAX_VALUE;
2557
2565
  let vertex = null;
@@ -2577,7 +2585,7 @@ class GraphRouterEngine {
2577
2585
  }
2578
2586
  edges.filter((edge) => edge.vertex1 == u || !edge.properties.isOneway && edge.vertex2 == u).forEach((edge) => {
2579
2587
  const v = u === edge.vertex1 ? edge.vertex2 : edge.vertex1;
2580
- const distance = weightEdgeFn(edge);
2588
+ const distance = weightEdgeFn(edge) + weightVertexFn(v);
2581
2589
  const alt = dist[u.id] + distance;
2582
2590
  if (alt < dist[v.id]) {
2583
2591
  dist[v.id] = alt;
@@ -13268,7 +13276,7 @@ const _GeoJsonGraphUtils = class _GeoJsonGraphUtils {
13268
13276
  return {
13269
13277
  ...feature.properties.id && { externalId: feature.properties.id },
13270
13278
  ...feature.id && { externalId: feature.id },
13271
- ...OsmTagsUtils.name(feature.properties) && { name: OsmTagsUtils.name(feature.properties) },
13279
+ ...OsmTagsUtils.elementName(feature.properties) && { name: OsmTagsUtils.elementName(feature.properties) },
13272
13280
  ...OsmTagsUtils.isOneway(feature.properties) && { isOneway: true },
13273
13281
  ...OsmTagsUtils.areStairs(feature.properties) && { areStairs: true },
13274
13282
  ...OsmTagsUtils.isElevator(feature.properties) && { isElevator: true },
@@ -13476,7 +13484,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
13476
13484
  static parseNodeProperties(osmNode) {
13477
13485
  return {
13478
13486
  ...osmNode.id && { externalId: osmNode.id },
13479
- ...OsmTagsUtils.name(osmNode.tags) && { name: OsmTagsUtils.name(osmNode.tags) },
13487
+ ...OsmTagsUtils.elementName(osmNode.tags) && { name: OsmTagsUtils.elementName(osmNode.tags) },
13480
13488
  ...OsmTagsUtils.isGate(osmNode.tags) && { isGate: true },
13481
13489
  ...OsmTagsUtils.isSubwayEntrance(osmNode.tags) && { isSubwayEntrance: true },
13482
13490
  ...OsmTagsUtils.getRef(osmNode.tags) && { subwayEntrsanceRef: OsmTagsUtils.getRef(osmNode.tags) }
@@ -13485,7 +13493,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
13485
13493
  static parseWayProperties(osmWay) {
13486
13494
  return {
13487
13495
  ...osmWay.id && { externalId: osmWay.id },
13488
- ...OsmTagsUtils.name(osmWay.tags) && { name: OsmTagsUtils.name(osmWay.tags) },
13496
+ ...OsmTagsUtils.elementName(osmWay.tags) && { name: OsmTagsUtils.elementName(osmWay.tags) },
13489
13497
  ...OsmTagsUtils.isOneway(osmWay.tags) && { isOneway: OsmTagsUtils.isOneway(osmWay.tags) },
13490
13498
  ...OsmTagsUtils.areStairs(osmWay.tags) && { areStairs: OsmTagsUtils.areStairs(osmWay.tags) },
13491
13499
  ...OsmTagsUtils.isElevator(osmWay.tags) && { isElevator: OsmTagsUtils.isElevator(osmWay.tags) },
@@ -13608,22 +13616,17 @@ const _OsmGraphUtils = class _OsmGraphUtils {
13608
13616
  });
13609
13617
  let routingBounds = {
13610
13618
  type: "MultiPolygon",
13611
- coordinates: [
13612
- ...osmModel.ways.filter((way) => OsmTagsUtils.isRoutingBounds(way.tags) && way.isGeometryClosed).map((way) => {
13613
- var _a;
13614
- return (_a = way.getGeoJsonPolygon()) == null ? void 0 : _a.coordinates;
13615
- }),
13616
- ...osmModel.relations.filter((rel) => OsmTagsUtils.isRoutingBounds(rel.tags) && rel.isMultipolygon()).map((rel) => {
13617
- var _a;
13618
- return (_a = rel.getGeoJsonPolygon()) == null ? void 0 : _a.coordinates;
13619
- })
13620
- ].filter((it) => typeof it === "object")
13619
+ coordinates: []
13621
13620
  };
13622
- if (routingBounds.coordinates.length === 0) {
13623
- routingBounds = void 0;
13624
- }
13621
+ osmModel.ways.filter((way) => OsmTagsUtils.isRoutingBounds(way.tags)).map((way) => way.getGeoJsonPolygon()).forEach((polygon) => polygon && routingBounds.coordinates.push(polygon.coordinates));
13622
+ osmModel.relations.filter((rel) => OsmTagsUtils.isRoutingBounds(rel.tags)).map((rel) => rel.getGeoJsonPolygon()).forEach((polygon) => polygon && routingBounds.coordinates.push(polygon.coordinates));
13625
13623
  callbackVerticesMapping == null ? void 0 : callbackVerticesMapping(verticesMapping);
13626
- return new Graph(verticesMapping.map((v) => v[1]), edges, routingBounds, Array.from(routingBoundsEntryPoints));
13624
+ return new Graph(
13625
+ verticesMapping.map((v) => v[1]),
13626
+ edges,
13627
+ routingBounds.coordinates.length > 0 ? routingBounds : void 0,
13628
+ Array.from(routingBoundsEntryPoints)
13629
+ );
13627
13630
  }
13628
13631
  };
13629
13632
  __publicField(_OsmGraphUtils, "RESTRICTED_PEDESTRIANS_HIGHWAYS", ["motorway", "motorway_link"]);