@wemap/routers 10.4.0 → 10.5.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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/routers"
13
13
  },
14
14
  "name": "@wemap/routers",
15
- "version": "10.4.0",
15
+ "version": "10.5.0",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -30,10 +30,10 @@
30
30
  "@turf/boolean-point-in-polygon": "^6.5.0",
31
31
  "@turf/convex": "^6.5.0",
32
32
  "@turf/helpers": "^6.5.0",
33
- "@wemap/geo": "^10.3.1",
33
+ "@wemap/geo": "^10.5.0",
34
34
  "@wemap/logger": "^10.0.0",
35
35
  "@wemap/maths": "^10.3.1",
36
- "@wemap/osm": "^10.3.1"
36
+ "@wemap/osm": "^10.5.0"
37
37
  },
38
- "gitHead": "00c259754b234de1d75a307f543badda8f6f0771"
38
+ "gitHead": "da571076de6bd9f4f2653d097763ff1244a36ebb"
39
39
  }
@@ -3,7 +3,7 @@ import convexHullFn from '@turf/convex';
3
3
  import { polygon as turfPolygon } from '@turf/helpers';
4
4
 
5
5
  import { Coordinates, GraphNode, GraphRouter, Network, NoRouteFoundError } from '@wemap/geo';
6
- import { OsmParser, OsmNetworkUtils } from '@wemap/osm';
6
+ import { OsmParser, OsmNetworkUtils, OsmElement } from '@wemap/osm';
7
7
  import { Itinerary, WemapRouterOptions, WemapRouterUtils } from '@wemap/routers';
8
8
 
9
9
  import Constants from '../Constants.js';
@@ -13,16 +13,22 @@ class IOMap {
13
13
  /** @type {?string} */
14
14
  name;
15
15
 
16
- /** @type {!GraphRouter} */
16
+ /** @type {!Network<OsmElement>} */
17
+ network;
18
+
19
+ /** @type {!GraphRouter<OsmElement>} */
17
20
  router;
18
21
 
19
22
  /** @type {!([number, number][])} */
20
23
  bounds;
21
24
 
22
25
 
23
- /** @type {!(GraphNode[])} */
26
+ /** @type {!(GraphNode<OsmElement>[])} */
24
27
  entryPoints;
25
28
 
29
+ /** @type {number[]} */
30
+ disabledWays = [];
31
+
26
32
  /**
27
33
  * @param {Network} network The network of the map
28
34
  * @param {GraphNode[]} entryPoints The map vertex that can be used to go inside / outside a IOMap
@@ -33,6 +39,7 @@ class IOMap {
33
39
  constructor(network, entryPoints, bounds = null, name = null) {
34
40
 
35
41
  this.name = name;
42
+ this.network = network;
36
43
  this.router = new GraphRouter(network);
37
44
 
38
45
  // Entry points
@@ -189,6 +196,16 @@ class IOMap {
189
196
  // Transform a network itinerary (nodes, edges...) to a router itinerary (legs, steps...)
190
197
  return WemapRouterUtils.createItineraryFromGraphItinerary(graphItinerary, Constants.ROUTING_MODE.WALK);
191
198
  }
199
+
200
+ enableWay(osmId) {
201
+ const edges = this.network.edges.filter(edge => edge.builtFrom.id === osmId);
202
+ this.router.disabledEdges = this.router.disabledEdges.filter(edge => !edges.includes(edge));
203
+ }
204
+
205
+ disableWay(osmId) {
206
+ const edges = this.network.edges.filter(edge => edge.builtFrom.id === osmId);
207
+ this.router.disabledEdges.push(...edges);
208
+ }
192
209
  }
193
210
 
194
211
  export default IOMap;