@wemap/routers 12.11.6 → 12.12.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.
@@ -1,3 +1,4 @@
1
+ import { MultiPolygon } from 'geojson';
1
2
  import { BoundingBox, Coordinates, UserPosition, Level_t } from '@wemap/geo';
2
3
  import { default as Edge } from './Edge.js';
3
4
  import { default as GraphProjection } from './GraphProjection.js';
@@ -7,6 +8,8 @@ import { GraphProjectionOptions } from './GraphProjectionOptions.js';
7
8
  declare class Graph {
8
9
  readonly vertices: Vertex[];
9
10
  readonly edges: Edge[];
11
+ readonly routingBounds: MultiPolygon | null;
12
+ readonly routingBoundsEntryPoints: Vertex[];
10
13
  /**
11
14
  * exitVertices are vertices that have at least one indoor edge and one outdoor edge
12
15
  * They are stored because the Level model cannot handle an indoor and outdoor state like [null, 1] or [null, [1,2]]
@@ -15,12 +18,14 @@ declare class Graph {
15
18
  * - if projection origin is not null, the intersection level with an exit vertex can be used
16
19
  */
17
20
  readonly exitVertices: Set<Vertex>;
18
- constructor(vertices: Vertex[], edges: Edge[]);
21
+ constructor(vertices: Vertex[], edges: Edge[], routingBounds?: MultiPolygon | null, routingBoundsEntryPoints?: Vertex[]);
19
22
  getEdgeByVertices(vertex1: Vertex, vertex2: Vertex): Edge | undefined;
20
23
  getVertexByCoords(coords: Coordinates): Vertex | undefined;
21
24
  static getVertexByCoords(vertices: Vertex[], coords: Coordinates): Vertex | undefined;
22
25
  getVertexByName(name: string): Vertex | undefined;
26
+ getVerticesByName(name: string): Vertex[];
23
27
  getEdgeByName(name: string): Edge | undefined;
28
+ getEdgesByName(name: string): Edge[];
24
29
  getBoundingBox(extendedMeasure?: number): BoundingBox | null;
25
30
  getProjection<U extends (Coordinates | UserPosition)>(origin: U, options?: GraphProjectionOptions): GraphProjection<U> | null;
26
31
  toJson(): GeoGraphJson;
@@ -15,5 +15,11 @@ export default class Vertex {
15
15
  distanceTo(other: Vertex): number;
16
16
  bearingTo(other: Vertex): number;
17
17
  toJson(): GraphVertexJson;
18
+ /**
19
+ * Check if two vertices are equal. It only checks the coordinates (not the properties)
20
+ * @param other - The other vertex to compare to
21
+ * @returns True if the vertices are equal, false otherwise
22
+ */
23
+ equals(other: Vertex): boolean;
18
24
  static fromJson(json: GraphVertexJson): Vertex;
19
25
  }
@@ -0,0 +1,12 @@
1
+ import { Feature, GeoJSON, Point } from 'geojson';
2
+ import { default as Graph } from '../../graph/Graph.js';
3
+ import { EdgeProperties } from '../../graph/Edge.js';
4
+ import { VertexProperties } from '../../graph/Vertex.js';
5
+ export default class GeoJsonGraphUtils {
6
+ static RESTRICTED_PEDESTRIANS_HIGHWAYS: string[];
7
+ static DEFAULT_FEATURE_SELECTOR: (feature: Feature) => boolean;
8
+ static parsePointProperties(feature: Feature<Point>): VertexProperties;
9
+ static parseLineStringProperties(feature: Feature): EdgeProperties;
10
+ static createGraphFromGeojsonString(geojsonString: string): Graph;
11
+ static createGraphFromGeojson(geojson: GeoJSON, featureSelectionFilter?: (feature: Feature<import('geojson').Geometry, import('geojson').GeoJsonProperties>) => boolean): Graph;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { LineString } from 'geojson';
2
+ export declare function osmStringToGeojson(osmString: string): import('geojson').FeatureCollection<import('geojson').Geometry, import('geojson').GeoJsonProperties>;
3
+ export declare function lineStringToPolygon(lineString: LineString): {
4
+ type: string;
5
+ coordinates: import('geojson').Position[][];
6
+ };
@@ -1,11 +1,12 @@
1
1
  import { OsmModel, OsmNode, OsmWay } from '@wemap/osm';
2
- import { default as Graph } from '../graph/Graph.js';
3
- import { EdgeProperties } from '../graph/Edge.js';
4
- import { default as Vertex, VertexProperties } from '../graph/Vertex.js';
2
+ import { default as Graph } from '../../graph/Graph.js';
3
+ import { EdgeProperties } from '../../graph/Edge.js';
4
+ import { default as Vertex, VertexProperties } from '../../graph/Vertex.js';
5
5
  export default class OsmGraphUtils {
6
6
  static RESTRICTED_PEDESTRIANS_HIGHWAYS: string[];
7
7
  static DEFAULT_WAY_SELECTOR: (way: OsmWay) => boolean;
8
8
  static parseNodeProperties(osmNode: OsmNode): VertexProperties;
9
9
  static parseWayProperties(osmWay: OsmWay): EdgeProperties;
10
+ static createGraphFromOsmXmlString(osmXmlString: string): Graph;
10
11
  static createGraphFromOsmModel(osmModel: OsmModel, waySelectionFilter?: (way: OsmWay) => boolean, callbackVerticesMapping?: (mapping: [nodeId: number, vertex: Vertex][]) => void): Graph;
11
12
  }
@@ -1,3 +1,4 @@
1
+ import { MultiPolygon } from 'geojson';
1
2
  import { CoordinatesCompressedJson } from '@wemap/geo';
2
3
  import { EdgeProperties } from './graph/Edge.js';
3
4
  import { VertexProperties } from './graph/Vertex.js';
@@ -15,6 +16,8 @@ export type GraphEdgeJson = {
15
16
  export type GeoGraphJson = {
16
17
  vertices: GraphVertexJson[];
17
18
  edges: GraphEdgeJson[];
19
+ routingBounds?: MultiPolygon;
20
+ routingBoundsEntryPoints?: number[];
18
21
  };
19
22
  export type CompressedGraphVertexJson = CoordinatesCompressedJson;
20
23
  export type CompressedGeoGraphJson = {
@@ -1,23 +1,14 @@
1
- import { MultiPolygon } from '@turf/helpers';
2
1
  import { Coordinates } from '@wemap/geo';
3
- import { OsmNode } from '@wemap/osm';
4
2
  import { default as Graph } from '../graph/Graph.js';
5
3
  import { default as GraphRouter } from '../graph/GraphRouter.js';
6
4
  import { GraphRouterOptions } from '../graph/GraphRouterOptions.js';
7
- import { default as Vertex } from '../graph/Vertex.js';
8
- export type ParsingErrors = {
9
- couldNotParseFile?: string;
10
- routingIoNotFound: OsmNode[];
11
- routingBoundsNotFound: boolean;
12
- };
13
5
  export default class CustomGraphMap {
14
- name: string | null;
15
6
  graph: Graph;
7
+ name: string | null;
16
8
  router: GraphRouter;
17
- bounds: MultiPolygon;
18
- entryPoints: Vertex[];
19
- constructor(graph: Graph, entryPoints: Vertex[], bounds?: MultiPolygon | null, name?: string | null);
20
- static fromOsmXml(osmXmlString: string, name?: string | null, callbackErrors?: (errors: ParsingErrors) => void): CustomGraphMap | undefined;
9
+ get routingBounds(): import('geojson').MultiPolygon | null;
10
+ get entryPoints(): import('../graph/Vertex.js').default[];
11
+ constructor(graph: Graph, name?: string | null);
21
12
  isPointInside(coordinates: Coordinates): boolean;
22
13
  /**
23
14
  * Get the list of entry points sorted by the lowest distance between:
@@ -25,7 +16,7 @@ export default class CustomGraphMap {
25
16
  * (as the crow flies)
26
17
  *
27
18
  */
28
- getOrderedEntryPointsSortedByDistance(start: Coordinates, end: Coordinates): Vertex[];
19
+ getOrderedEntryPointsSortedByDistance(start: Coordinates, end: Coordinates): import('../graph/Vertex.js').default[];
29
20
  /**
30
21
  * Get the best itinerary from any entry point to an end coordinates.
31
22
  *
@@ -1,11 +1,11 @@
1
- import { OsmNode } from '@wemap/osm';
1
+ import { GeoJSON } from 'geojson';
2
2
  import { default as CustomGraphMap } from './CustomGraphMap.js';
3
3
  import { default as Vertex } from '../graph/Vertex.js';
4
4
  export type Report = {
5
5
  customGraphMap?: CustomGraphMap;
6
6
  errors: Error[];
7
7
  };
8
- export type Error = CouldNotParseFileError | MultipleGraphComponentsError | RoutingBoundsNotFoundError | RoutingIoNotOnGraphError;
8
+ export type Error = CouldNotParseFileError | MultipleGraphComponentsError | RoutingBoundsNotFoundError | RoutingBoundsEntryPointsNotFoundError;
9
9
  export type CouldNotParseFileError = {
10
10
  type: 'could-not-parse-file';
11
11
  details: string | undefined;
@@ -17,22 +17,27 @@ export type MultipleGraphComponentsError = {
17
17
  export type RoutingBoundsNotFoundError = {
18
18
  type: 'routing-bounds-not-found';
19
19
  };
20
- export type RoutingIoNotOnGraphError = {
21
- type: 'routing-io-not-on-graph';
22
- data: OsmNode[];
20
+ export type RoutingBoundsEntryPointsNotFoundError = {
21
+ type: 'routing-bounds-entry-points-not-found';
23
22
  };
24
23
  export default class CustomGraphMapTester {
25
- static createReport(osmXmlString: string): Report;
24
+ static createReportFromOsmXmlString(osmXmlString: string): Report;
25
+ static createReportFromGeoJsonString(geojsonString: string): Report;
26
+ static createReportFromGeoJson(geojson: GeoJSON): Report;
27
+ private static createReportFromCustomGraphMap;
26
28
  static reportToJson(report: Report): {
27
- graph: import('../types.js').CompressedGeoGraphJson | undefined;
29
+ graph: import('../types.js').GeoGraphJson | undefined;
28
30
  errors: ({
29
31
  type: "multiple-graph-components";
30
32
  data: number[][];
31
33
  } | {
32
- type: "routing-io-not-on-graph";
33
- data: number[];
34
+ type: "routing-bounds-entry-points-not-found";
35
+ data?: undefined;
36
+ } | {
37
+ type: "routing-bounds-not-found";
38
+ data?: undefined;
34
39
  } | {
35
- type: "could-not-parse-file" | "routing-bounds-not-found";
40
+ type: "could-not-parse-file";
36
41
  data?: undefined;
37
42
  })[];
38
43
  };
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/routers"
13
13
  },
14
14
  "name": "@wemap/routers",
15
- "version": "12.11.6",
15
+ "version": "12.12.0",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -34,16 +34,18 @@
34
34
  "@turf/convex": "^6.5.0",
35
35
  "@turf/helpers": "^6.5.0",
36
36
  "@types/mapbox__polyline": "^1.0.2",
37
- "@wemap/geo": "^12.11.3",
37
+ "@wemap/geo": "^12.12.0",
38
38
  "@wemap/logger": "^12.10.9",
39
39
  "@wemap/maths": "^12.10.9",
40
- "@wemap/osm": "^12.11.3",
40
+ "@wemap/osm": "^12.12.0",
41
41
  "@wemap/salesman.js": "^2.1.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/fetch-mock": "^7.3.5",
45
+ "@xmldom/xmldom": "^0.9.8",
45
46
  "fetch-mock": "^9.11.0",
46
- "geojson": "^0.5.0"
47
+ "geojson": "^0.5.0",
48
+ "osmtogeojson": "^3.0.0-beta.5"
47
49
  },
48
50
  "files": [
49
51
  "dist",
@@ -60,5 +62,5 @@
60
62
  "types": "./dist/helpers/*.d.ts"
61
63
  }
62
64
  },
63
- "gitHead": "f42a97330c016910c50dac0d10edb478c073d117"
65
+ "gitHead": "37e99664e922120a00c513e7c6eb7897b50dbe45"
64
66
  }