@wemap/routers 12.10.8 → 12.11.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/helpers/InstructionManager.d.ts +20 -0
- package/dist/helpers/InstructionManagerV1.d.ts +7 -0
- package/{index.ts → dist/index.d.ts} +1 -11
- package/dist/index.js +1 -5099
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -5
- package/dist/index.mjs.map +1 -1
- package/dist/src/ItineraryInfoManager.d.ts +31 -0
- package/dist/src/RoutingError.d.ts +24 -0
- package/{src/StatusCode.ts → dist/src/StatusCode.d.ts} +2 -3
- package/dist/src/Utils.d.ts +6 -0
- package/dist/src/graph/Edge.d.ts +38 -0
- package/dist/src/graph/Graph.d.ts +40 -0
- package/dist/src/graph/GraphProjection.d.ts +11 -0
- package/dist/src/graph/GraphProjectionOptions.d.ts +7 -0
- package/dist/src/graph/GraphRoute.d.ts +19 -0
- package/dist/src/graph/GraphRouter.d.ts +20 -0
- package/dist/src/graph/GraphRouterEngine.d.ts +80 -0
- package/{src/graph/GraphRouterOptions.ts → dist/src/graph/GraphRouterOptions.d.ts} +6 -7
- package/dist/src/graph/GraphRouterOptionsBuilder.d.ts +23 -0
- package/dist/src/graph/GraphRouterOptionsFactors.d.ts +8 -0
- package/dist/src/graph/NoRouteFoundError.d.ts +12 -0
- package/dist/src/graph/Vertex.d.ts +19 -0
- package/dist/src/model/Itinerary.d.ts +81 -0
- package/dist/src/model/Leg.d.ts +66 -0
- package/dist/src/model/LevelChange.d.ts +7 -0
- package/dist/src/model/RouterRequest.d.ts +42 -0
- package/dist/src/model/Step.d.ts +42 -0
- package/dist/src/model/StepExtra.d.ts +3 -0
- package/dist/src/model/StepsBuilder.d.ts +16 -0
- package/dist/src/model/TransitMode.d.ts +5 -0
- package/{src/model/TravelMode.ts → dist/src/model/TravelMode.d.ts} +1 -2
- package/dist/src/model/generateSteps.d.ts +0 -0
- package/{src/remote/RemoteRouter.ts → dist/src/remote/RemoteRouter.d.ts} +2 -7
- package/dist/src/remote/RemoteRouterManager.d.ts +731 -0
- package/dist/src/remote/RemoteRouterUtils.d.ts +6 -0
- package/dist/src/remote/cityway/CitywayRemoteRouter.d.ts +109 -0
- package/dist/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.d.ts +31 -0
- package/dist/src/remote/geovelo/GeoveloRemoteRouter.d.ts +106 -0
- package/dist/src/remote/idfm/IdfmRemoteRouter.d.ts +123 -0
- package/dist/src/remote/navitia/NavitiaRemoteRouter.d.ts +34 -0
- package/dist/src/remote/navitia/types.d.ts +87 -0
- package/dist/src/remote/osrm/OsrmRemoteRouter.d.ts +70 -0
- package/dist/src/remote/otp/OtpRemoteRouter.d.ts +69 -0
- package/dist/src/remote/wemap-multi/WemapMultiRemoteRouter.d.ts +19 -0
- package/dist/src/types.d.ts +31 -0
- package/dist/src/wemap-multi/CustomGraphMap.d.ts +56 -0
- package/dist/src/wemap-multi/CustomGraphMapTester.d.ts +39 -0
- package/dist/src/wemap-multi/WemapMultiRouter.d.ts +14 -0
- package/dist/src/wemap-osm/OsmGraphUtils.d.ts +11 -0
- package/dist/tests/CommonTest.d.ts +8 -0
- package/package.json +11 -8
- package/assets/biocbon-bergere-rdc-network.osm +0 -163
- package/assets/bureaux-wemap-montpellier-network.osm +0 -174
- package/assets/components.osm +0 -146
- package/assets/elevator-models-4.osm +0 -89
- package/assets/elevator-models.osm +0 -354
- package/assets/exit-graph.osm +0 -25
- package/assets/gare-de-lest-network-pp-bounds.osm +0 -1613
- package/assets/gare-de-lyon-extract.osm +0 -174
- package/assets/geovelo-montpellier.json +0 -1144
- package/assets/horizontal-elevator.osm +0 -12
- package/assets/itinerary-deutsche-bahn-1.json +0 -368
- package/assets/itinerary-grenoble-otp-1.json +0 -1536
- package/assets/itinerary-grenoble-otp-2.json +0 -1092
- package/assets/itinerary-info-two-points-proj.osm +0 -39
- package/assets/itinerary-info-two-points.osm +0 -24
- package/assets/itinerary-lehavre-cityway-1.json +0 -6799
- package/assets/itinerary-lehavre-cityway-2.json +0 -2133
- package/assets/itinerary-lehavre-cityway-3.json +0 -12577
- package/assets/itinerary-lehavre-cityway-4.json +0 -1451
- package/assets/itinerary-lehavre-cityway-5.json +0 -5925
- package/assets/itinerary-lemans-navitia.json +0 -7768
- package/assets/itinerary-montpellier-osrm-3.json +0 -185
- package/assets/itinerary-montpellier-outdoor-without-steps.json +0 -110
- package/assets/itinerary-montpellier-outdoor.json +0 -513
- package/assets/itinerary-paris-idfm-2.json +0 -1838
- package/assets/itinerary-paris-idfm.json +0 -27727
- package/assets/itinerary-step-not-on-path-osrm.json +0 -457
- package/assets/itinerary-with-duplicate-nodes.json +0 -110
- package/assets/network-conveying-backward.osm +0 -74
- package/assets/network-elevator.osm +0 -48
- package/assets/network-escalators.osm +0 -50
- package/assets/network-simple.osm +0 -27
- package/assets/network-steps-same-level.osm +0 -283
- package/assets/network-with-modifiers.osm +0 -39
- package/assets/one-way.osm +0 -46
- package/assets/report-map-1.osm +0 -36
- package/assets/report-map-2.osm +0 -29
- package/assets/report-map-3.osm +0 -15
- package/assets/rr-wemap-multi-indoor-outdoor-indoor.json +0 -1352
- package/assets/rr-wemap-multi-indoor-outdoor.json +0 -145
- package/assets/rr-wemap-multi-multi-level.json +0 -262
- package/assets/rr-wemap-multi-outdoor-indoor.json +0 -145
- package/assets/rr-wemap-multi-outdoor-outdoor.json +0 -207
- package/assets/rr-wemap-multi-remote-indoor-indoor.json +0 -155
- package/assets/rr-wemap-multi-remote-indoor-outdoor-indoor.json +0 -668
- package/assets/rr-wemap-multi-remote-indoor-outdoor.json +0 -154
- package/assets/rr-wemap-multi-remote-outdoor-indoor.json +0 -179
- package/assets/rr-wemap-multi-remote-outdoor-outdoor.json +0 -109
- package/assets/stairs-and-exit.osm +0 -47
- package/helpers/InstructionManager.ts +0 -184
- package/helpers/InstructionManagerV1.ts +0 -95
- package/src/ItineraryInfoManager.spec.ts +0 -183
- package/src/ItineraryInfoManager.ts +0 -181
- package/src/RoutingError.ts +0 -60
- package/src/Utils.ts +0 -8
- package/src/graph/Edge.spec.ts +0 -32
- package/src/graph/Edge.ts +0 -64
- package/src/graph/Graph.spec.ts +0 -509
- package/src/graph/Graph.ts +0 -272
- package/src/graph/GraphProjection.ts +0 -15
- package/src/graph/GraphProjectionOptions.ts +0 -8
- package/src/graph/GraphRoute.spec.ts +0 -15
- package/src/graph/GraphRoute.ts +0 -43
- package/src/graph/GraphRouter.spec.ts +0 -317
- package/src/graph/GraphRouter.ts +0 -229
- package/src/graph/GraphRouterEngine.ts +0 -248
- package/src/graph/GraphRouterOptionsBuilder.ts +0 -98
- package/src/graph/NoRouteFoundError.ts +0 -39
- package/src/graph/Vertex.spec.ts +0 -42
- package/src/graph/Vertex.ts +0 -45
- package/src/model/Itinerary.spec.ts +0 -134
- package/src/model/Itinerary.ts +0 -370
- package/src/model/Leg.spec.ts +0 -107
- package/src/model/Leg.ts +0 -224
- package/src/model/LevelChange.spec.ts +0 -50
- package/src/model/LevelChange.ts +0 -14
- package/src/model/RouterRequest.ts +0 -33
- package/src/model/Step.spec.ts +0 -99
- package/src/model/Step.ts +0 -90
- package/src/model/StepExtra.ts +0 -1
- package/src/model/StepsBuilder.ts +0 -242
- package/src/model/TransitMode.spec.ts +0 -31
- package/src/model/TransitMode.ts +0 -28
- package/src/model/generateSteps.ts +0 -102
- package/src/remote/RemoteRouterManager.spec.ts +0 -178
- package/src/remote/RemoteRouterManager.ts +0 -72
- package/src/remote/RemoteRouterUtils.ts +0 -25
- package/src/remote/cityway/CitywayRemoteRouter.spec.ts +0 -122
- package/src/remote/cityway/CitywayRemoteRouter.ts +0 -435
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.spec.ts +0 -52
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.ts +0 -85
- package/src/remote/geovelo/GeoveloRemoteRouter.spec.ts +0 -54
- package/src/remote/geovelo/GeoveloRemoteRouter.ts +0 -293
- package/src/remote/idfm/IdfmRemoteRouter.spec.ts +0 -102
- package/src/remote/idfm/IdfmRemoteRouter.ts +0 -523
- package/src/remote/navitia/NavitiaRemoteRouter.spec.ts +0 -116
- package/src/remote/navitia/NavitiaRemoteRouter.ts +0 -445
- package/src/remote/navitia/types.ts +0 -73
- package/src/remote/osrm/OsrmRemoteRouter.spec.ts +0 -127
- package/src/remote/osrm/OsrmRemoteRouter.ts +0 -303
- package/src/remote/otp/OtpRemoteRouter.spec.ts +0 -103
- package/src/remote/otp/OtpRemoteRouter.ts +0 -223
- package/src/remote/wemap-multi/WemapMultiRemoteRouter.spec.ts +0 -103
- package/src/remote/wemap-multi/WemapMultiRemoteRouter.ts +0 -56
- package/src/types.ts +0 -32
- package/src/wemap-multi/CustomGraphMap.spec.ts +0 -40
- package/src/wemap-multi/CustomGraphMap.ts +0 -213
- package/src/wemap-multi/CustomGraphMapTester.spec.ts +0 -48
- package/src/wemap-multi/CustomGraphMapTester.ts +0 -90
- package/src/wemap-multi/WemapMultiRouter.spec.ts +0 -138
- package/src/wemap-multi/WemapMultiRouter.ts +0 -329
- package/src/wemap-osm/OsmGraphUtils.spec.ts +0 -165
- package/src/wemap-osm/OsmGraphUtils.ts +0 -173
- package/src/wemap-osm/OsmRouter.elevators.spec.ts +0 -106
- package/src/wemap-osm/OsmRouter.spec.ts +0 -292
- package/tests/CommonTest.ts +0 -78
- package/tsconfig.json +0 -3
- package/vite.config.ts +0 -4
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Coordinates, Level, Level_t } from '@wemap/geo';
|
|
2
|
-
import { OsmModel, OsmNode, OsmWay } from '@wemap/osm';
|
|
3
|
-
|
|
4
|
-
import Graph from '../graph/Graph.js';
|
|
5
|
-
import { default as Edge, type EdgeProperties } from '../graph/Edge.js';
|
|
6
|
-
import { default as Vertex, type VertexProperties } from '../graph/Vertex.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default class OsmGraphUtils {
|
|
10
|
-
|
|
11
|
-
static RESTRICTED_PEDESTRIANS_HIGHWAYS = ['motorway', 'motorway_link'];
|
|
12
|
-
|
|
13
|
-
static DEFAULT_WAY_SELECTOR = (way: OsmWay) => {
|
|
14
|
-
if (way.isArea) return false;
|
|
15
|
-
if (way.tags.foot === 'yes') return true;
|
|
16
|
-
if (['no', 'private'].includes(way.tags.access)) return false;
|
|
17
|
-
|
|
18
|
-
const isElevatorArea = way.tags.highway === 'elevator' && way.isGeometryClosed
|
|
19
|
-
return way.tags.highway && !OsmGraphUtils.RESTRICTED_PEDESTRIANS_HIGHWAYS.includes(way.tags.highway) && !isElevatorArea
|
|
20
|
-
|| way.tags.footway === 'sidewalk'
|
|
21
|
-
|| way.tags.public_transport === 'platform'
|
|
22
|
-
|| way.tags.railway === 'platform';
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
static parseNodeProperties(osmNode: OsmNode): VertexProperties {
|
|
26
|
-
return {
|
|
27
|
-
...(osmNode.name && { name: osmNode.name }),
|
|
28
|
-
...(osmNode.id && { externalId: osmNode.id }),
|
|
29
|
-
...(osmNode.isGate && { isGate: osmNode.isGate }),
|
|
30
|
-
...(osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance }),
|
|
31
|
-
...(osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef })
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static parseWayProperties(osmWay: OsmWay): EdgeProperties {
|
|
36
|
-
return {
|
|
37
|
-
...(osmWay.name && { name: osmWay.name }),
|
|
38
|
-
...(osmWay.id && { externalId: osmWay.id }),
|
|
39
|
-
...(osmWay.isOneway && { isOneway: osmWay.isOneway }),
|
|
40
|
-
...(osmWay.areStairs && { areStairs: osmWay.areStairs }),
|
|
41
|
-
...(osmWay.isElevator && { isElevator: osmWay.isElevator }),
|
|
42
|
-
...(osmWay.areEscalators && { areEscalators: osmWay.areEscalators }),
|
|
43
|
-
...(osmWay.isMovingWalkway && { isMovingWalkway: osmWay.isMovingWalkway }),
|
|
44
|
-
...(osmWay.needTicket && { needTicket: osmWay.needTicket }),
|
|
45
|
-
...(osmWay.incline && { incline: osmWay.incline })
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static createGraphFromOsmModel(
|
|
50
|
-
osmModel: OsmModel,
|
|
51
|
-
waySelectionFilter = OsmGraphUtils.DEFAULT_WAY_SELECTOR,
|
|
52
|
-
callbackVerticesMapping?: (mapping: [nodeId: number, vertex: Vertex][]) => void
|
|
53
|
-
) {
|
|
54
|
-
|
|
55
|
-
const edges: Edge[] = [];
|
|
56
|
-
const verticesMapping: [nodeId: number, vertex: Vertex][] = [];
|
|
57
|
-
const elevatorVertices: [id: number, name: string | undefined, vertices: Vertex[]][] = [];
|
|
58
|
-
|
|
59
|
-
// 1. Create a function to retrieve a vertex which has already been created and avoid duplicates
|
|
60
|
-
const getOrCreateVertex = (osmNode: OsmNode, nodeLevel: Level_t) => {
|
|
61
|
-
|
|
62
|
-
// Check if a vertex with same coordinates already exists
|
|
63
|
-
let vertex: Vertex | null = verticesMapping
|
|
64
|
-
.find(([nodeId, v]) => {
|
|
65
|
-
if (nodeId !== osmNode.id) return false;
|
|
66
|
-
if (Level.intersect(v.coords.level, nodeLevel)) return true;
|
|
67
|
-
// Specific case of exits
|
|
68
|
-
return v.coords.level === null || nodeLevel === null;
|
|
69
|
-
})?.[1] || null;
|
|
70
|
-
|
|
71
|
-
// If the vertex already exists, return it
|
|
72
|
-
if (vertex) {
|
|
73
|
-
// In the case where vertices are linked to edges with level change
|
|
74
|
-
if (!Level.equals(vertex.coords.level, nodeLevel)) {
|
|
75
|
-
vertex.coords.level = Level.intersection(vertex.coords.level, nodeLevel);
|
|
76
|
-
if (vertex.coords.level === null) {
|
|
77
|
-
vertex.coords.level = nodeLevel;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return vertex;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// If it does not exist, create it
|
|
84
|
-
const newCoords = new Coordinates(osmNode.coords.lat, osmNode.coords.lng, null, nodeLevel)
|
|
85
|
-
vertex = new Vertex(newCoords, this.parseNodeProperties(osmNode));
|
|
86
|
-
|
|
87
|
-
verticesMapping.push([osmNode.id, vertex]);
|
|
88
|
-
|
|
89
|
-
if (osmNode.isElevator) {
|
|
90
|
-
let elevatorEntry = elevatorVertices.find(([id]) => osmNode.id === id);
|
|
91
|
-
if (!elevatorEntry) {
|
|
92
|
-
elevatorEntry = [osmNode.id, osmNode.name, []];
|
|
93
|
-
elevatorVertices.push(elevatorEntry);
|
|
94
|
-
}
|
|
95
|
-
elevatorEntry[2].push(vertex);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return vertex;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// 2. Go through OSM ways to create edges and vertices
|
|
102
|
-
osmModel.ways.forEach(way => {
|
|
103
|
-
if (!waySelectionFilter(way)) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const edgeProperties = this.parseWayProperties(way);
|
|
108
|
-
|
|
109
|
-
const processWayForLevel = (_level: Level_t) => {
|
|
110
|
-
for (let i = 1; i < way.nodes.length; i++) {
|
|
111
|
-
|
|
112
|
-
let firstVertex = getOrCreateVertex(way.nodes[i - 1], _level);
|
|
113
|
-
let secondVertex = getOrCreateVertex(way.nodes[i], _level);
|
|
114
|
-
|
|
115
|
-
if (way.isOnewayBackward) {
|
|
116
|
-
const tmpVertex = secondVertex;
|
|
117
|
-
secondVertex = firstVertex;
|
|
118
|
-
firstVertex = tmpVertex;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const edge = new Edge(firstVertex, secondVertex, edgeProperties);
|
|
122
|
-
edges.push(edge);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
processWayForLevel(way.level);
|
|
127
|
-
if ('repeat_on' in way.tags) {
|
|
128
|
-
way.tags.repeat_on.split(';').map(Level.fromString).forEach(processWayForLevel);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// 3. Manage elevators without explicit navigation graph inside.
|
|
134
|
-
// It creates a graph from entries to the center of the elevator shape.
|
|
135
|
-
let fakeOsmNodeId = -1;
|
|
136
|
-
osmModel.ways
|
|
137
|
-
.filter(way => way.isElevator && way.isGeometryClosed)
|
|
138
|
-
.forEach(way => {
|
|
139
|
-
const entryVertices = way.nodes.map(node => verticesMapping.filter(([osmId]) => osmId === node.id).map(vm => vm[1])).flat();
|
|
140
|
-
|
|
141
|
-
// Horrible method but works for macro-problems
|
|
142
|
-
const elevatorCenter = way.nodes
|
|
143
|
-
.reduce((acc, node) => [acc[0] + node.coords.lat, acc[1] + node.coords.lng], [0, 0])
|
|
144
|
-
.map(val => val / way.nodes.length);
|
|
145
|
-
const elevatorLevel = entryVertices.reduce((acc, v) => Level.union(acc, v.coords.level), null as Level_t);
|
|
146
|
-
const elevatorCenterCoords = new Coordinates(elevatorCenter[0], elevatorCenter[1], null, elevatorLevel);
|
|
147
|
-
|
|
148
|
-
const elevatorCenterFakeOsmNode = new OsmNode(fakeOsmNodeId--, elevatorCenterCoords, { highway: 'elevator' });
|
|
149
|
-
|
|
150
|
-
entryVertices.forEach(entryVertex => {
|
|
151
|
-
const vertexCenter = getOrCreateVertex(elevatorCenterFakeOsmNode, entryVertex.coords.level);
|
|
152
|
-
edges.push(new Edge(vertexCenter, entryVertex, { externalId: way.id }));
|
|
153
|
-
})
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// 4. Link elevators vertices
|
|
158
|
-
elevatorVertices.forEach(([id, name, verticesOfEachLevel]) => {
|
|
159
|
-
const elevatorEdgeProps = { name, isElevator: true, externalId: id };
|
|
160
|
-
// Link vertices of each level together
|
|
161
|
-
for (let i = 0; i < verticesOfEachLevel.length; i++) {
|
|
162
|
-
for (let j = i + 1; j < verticesOfEachLevel.length; j++) {
|
|
163
|
-
edges.push(new Edge(verticesOfEachLevel[i], verticesOfEachLevel[j], elevatorEdgeProps));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
callbackVerticesMapping?.(verticesMapping);
|
|
169
|
-
|
|
170
|
-
return new Graph(verticesMapping.map(v => v[1]), edges);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
import chaiAlmost from 'chai-almost';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
|
|
7
|
-
import { OsmParser } from '@wemap/osm';
|
|
8
|
-
|
|
9
|
-
import OsmGraphUtils from './OsmGraphUtils.js';
|
|
10
|
-
import GraphRouter from '../graph/GraphRouter.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const { expect } = chai;
|
|
14
|
-
chai.use(chaiAlmost(0.01));
|
|
15
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const filePath = path.resolve(__dirname, '../../assets/elevator-models.osm');
|
|
19
|
-
const osmXmlString = fs.readFileSync(filePath, 'utf8');
|
|
20
|
-
const osmModel = OsmParser.parseOsmXmlString(osmXmlString);
|
|
21
|
-
const graph = OsmGraphUtils.createGraphFromOsmModel(osmModel);
|
|
22
|
-
const router = new GraphRouter(graph);
|
|
23
|
-
|
|
24
|
-
const n = (vertexName: string) => graph.getVertexByName(vertexName)!.coords
|
|
25
|
-
|
|
26
|
-
describe('OsmRouter Elevators - Case 1', () => {
|
|
27
|
-
|
|
28
|
-
it('Itinerary 1', () => {
|
|
29
|
-
expect(router.calculateShortestPath(n('s1'), n('f1a')).route().hasRoute).true
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('Itinerary 2', () => {
|
|
33
|
-
expect(router.calculateShortestPath(n('s1'), n('f1b')).route().hasRoute).true
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('Itinerary 3', () => {
|
|
37
|
-
expect(router.calculateShortestPath(n('s1'), n('f1c')).route().hasRoute).true
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
describe('OsmRouter Elevators - Case 2', () => {
|
|
44
|
-
|
|
45
|
-
it('Itinerary 1', () => {
|
|
46
|
-
expect(router.calculateShortestPath(n('s2'), n('f2a')).route().hasRoute).true
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('Itinerary 2', () => {
|
|
50
|
-
expect(router.calculateShortestPath(n('s2'), n('f2b')).route().hasRoute).true
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('Itinerary 3', () => {
|
|
54
|
-
expect(router.calculateShortestPath(n('s2'), n('f2c')).route().hasRoute).true
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
describe('OsmRouter Elevators - Case 3', () => {
|
|
61
|
-
|
|
62
|
-
it('Itinerary 1', () => {
|
|
63
|
-
expect(router.calculateShortestPath(n('s3'), n('f3a')).route().hasRoute).true
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('Itinerary 2', () => {
|
|
67
|
-
expect(router.calculateShortestPath(n('s3'), n('f3b')).route().hasRoute).true
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('Itinerary 3', () => {
|
|
71
|
-
expect(router.calculateShortestPath(n('s3'), n('f3c')).route().hasRoute).true
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe('OsmRouter Elevators - Case 4', () => {
|
|
77
|
-
|
|
78
|
-
it('Itinerary 1', () => {
|
|
79
|
-
expect(router.calculateShortestPath(n('s4'), n('f4a')).route().hasRoute).true
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('Itinerary 2', () => {
|
|
83
|
-
expect(router.calculateShortestPath(n('s4'), n('f4b')).route().hasRoute).true
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('Itinerary 3', () => {
|
|
87
|
-
expect(router.calculateShortestPath(n('s4'), n('f4c')).route().hasRoute).true
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('OsmRouter Elevators - Case 5', () => {
|
|
93
|
-
|
|
94
|
-
it('Itinerary 1', () => {
|
|
95
|
-
expect(router.calculateShortestPath(n('s5'), n('f5a')).route().hasRoute).true
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('Itinerary 2', () => {
|
|
99
|
-
expect(router.calculateShortestPath(n('s5'), n('f5b')).route().hasRoute).true
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('Itinerary 3', () => {
|
|
103
|
-
expect(router.calculateShortestPath(n('s5'), n('f5c')).route().hasRoute).true
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
});
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
import chaiAlmost from 'chai-almost';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
|
|
7
|
-
import { Coordinates } from '@wemap/geo';
|
|
8
|
-
import { OsmParser } from '@wemap/osm';
|
|
9
|
-
|
|
10
|
-
import { LevelChange } from '../model/LevelChange.js';
|
|
11
|
-
import { Step } from '../model/Step.js';
|
|
12
|
-
import OsmGraphUtils from './OsmGraphUtils.js';
|
|
13
|
-
import GraphRouter from '../graph/GraphRouter.js';
|
|
14
|
-
import Vertex from '../graph/Vertex.js';
|
|
15
|
-
import GraphRouterOptionsBuilder from '../graph/GraphRouterOptionsBuilder.js';
|
|
16
|
-
import GraphRoute from '../graph/GraphRoute.js';
|
|
17
|
-
import Itinerary from '../model/Itinerary.js';
|
|
18
|
-
|
|
19
|
-
const { expect } = chai;
|
|
20
|
-
chai.use(chaiAlmost(0.01));
|
|
21
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const getVerticesNames = (graphRoute: GraphRoute) => {
|
|
25
|
-
return graphRoute.vertices.map(vertex => vertex.properties.name || null);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const itineraryStart = new Coordinates(43.6092754, 3.8842306, null, 2);
|
|
30
|
-
const itineraryEnd = new Coordinates(43.6092602, 3.8842669, null, 1);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const loadGraph = (fileName: string) => {
|
|
34
|
-
const filePath = path.resolve(__dirname, '../../assets/' + fileName);
|
|
35
|
-
const osmXmlString = fs.readFileSync(filePath, 'utf8');
|
|
36
|
-
const osmModel = OsmParser.parseOsmXmlString(osmXmlString);
|
|
37
|
-
return OsmGraphUtils.createGraphFromOsmModel(osmModel);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const generateVertexNames = (start: number, end: number) =>
|
|
41
|
-
new Array(end - start + 1).fill(null).map((_, idx) => 'p' + (idx + start));
|
|
42
|
-
|
|
43
|
-
describe('OsmRouter - Multi-level itinerary', () => {
|
|
44
|
-
|
|
45
|
-
const graph = loadGraph('bureaux-wemap-montpellier-network.osm');
|
|
46
|
-
const router = new GraphRouter(graph);
|
|
47
|
-
|
|
48
|
-
const route = router.calculateShortestPath(itineraryStart, itineraryEnd).route();
|
|
49
|
-
const itinerary = Itinerary.fromGraphRoute(route);
|
|
50
|
-
|
|
51
|
-
const p: Vertex[] = [];
|
|
52
|
-
|
|
53
|
-
it('Search for vertices', () => {
|
|
54
|
-
for (let i = 1; i <= 16; i++) {
|
|
55
|
-
p[i] = graph.getVertexByName('p' + i) as Vertex;
|
|
56
|
-
expect(p[i]).instanceOf(Vertex);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('Router return shortest path', () => {
|
|
61
|
-
expect(getVerticesNames(route)).deep.equals(
|
|
62
|
-
['proj on w2 (tmp)', ...generateVertexNames(7, 16)]
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('Verify steps', () => {
|
|
67
|
-
|
|
68
|
-
const steps = itinerary.steps;
|
|
69
|
-
expect(steps.length).equal(8);
|
|
70
|
-
|
|
71
|
-
expect(steps[0].coords.equals(itineraryStart.getSegmentProjection(p[6].coords, p[7].coords) as Coordinates)).true;
|
|
72
|
-
expect(steps[0].name).equals('w2');
|
|
73
|
-
expect(steps[0].number).equals(1);
|
|
74
|
-
expect(steps[0].angle).almost.equals(-1.57);
|
|
75
|
-
expect(steps[0].previousBearing).almost.equals(1.778);
|
|
76
|
-
expect(steps[0].nextBearing).almost.equals(0.207);
|
|
77
|
-
expect(steps[0].distance).almost.equals(2.328);
|
|
78
|
-
expect(steps[0].duration).almost.equals(2.095);
|
|
79
|
-
expect(steps[0].firstStep).true;
|
|
80
|
-
expect(steps[0].lastStep).false;
|
|
81
|
-
expect(steps[0].levelChange).is.null;
|
|
82
|
-
expect(steps[0].extras).is.empty;
|
|
83
|
-
|
|
84
|
-
expect(steps[1].coords.equals(p[8].coords)).true;
|
|
85
|
-
expect(steps[1].name).equals('w3');
|
|
86
|
-
expect(steps[1].number).equals(2);
|
|
87
|
-
expect(steps[1].distance).almost.equals(1.764);
|
|
88
|
-
expect(steps[1].firstStep).false;
|
|
89
|
-
expect(steps[1].lastStep).false;
|
|
90
|
-
|
|
91
|
-
expect(steps[2].coords.equals(p[9].coords)).true;
|
|
92
|
-
expect(steps[2].name).equals('w3');
|
|
93
|
-
|
|
94
|
-
expect(steps[3].coords.equals(p[10].coords)).true;
|
|
95
|
-
expect(steps[3].name).equals('w5');
|
|
96
|
-
|
|
97
|
-
expect(steps[4].coords.equals(p[11].coords)).true;
|
|
98
|
-
expect(steps[4].name).equals('w6');
|
|
99
|
-
expect(steps[4].levelChange).is.not.null;
|
|
100
|
-
expect((steps[4].levelChange as LevelChange).difference).equals(-1);
|
|
101
|
-
expect((steps[4].levelChange as LevelChange).direction).equals('down');
|
|
102
|
-
expect((steps[4].levelChange as LevelChange).type).equals('stairs');
|
|
103
|
-
|
|
104
|
-
expect(steps[5].coords.equals(p[14].coords)).true;
|
|
105
|
-
expect(steps[5].name).equals('w7');
|
|
106
|
-
|
|
107
|
-
expect(steps[6].coords.equals(p[15].coords)).true;
|
|
108
|
-
expect(steps[6].name).equals('w9');
|
|
109
|
-
|
|
110
|
-
expect(steps[7].coords.equals(p[16].coords)).true;
|
|
111
|
-
expect(steps[7].name).is.null;
|
|
112
|
-
expect(steps[7].lastStep).true;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
it('router returns shortest path 2', () => {
|
|
117
|
-
|
|
118
|
-
const start = new Coordinates(43.609219, 3.8841743, null, 2);
|
|
119
|
-
const end = new Coordinates(43.60917216742, 3.8842355275, null, 2);
|
|
120
|
-
const itinerary2 = router.calculateShortestPath(start, end).route();
|
|
121
|
-
|
|
122
|
-
expect(getVerticesNames(itinerary2)).deep.equals(['proj on w1 (tmp)', 'p6', 'p5']);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('do not use stairs', () => {
|
|
126
|
-
|
|
127
|
-
const itineraryWithoutStairs = router.calculateShortestPath(
|
|
128
|
-
itineraryStart, itineraryEnd,
|
|
129
|
-
GraphRouterOptionsBuilder.WITHOUT_STAIRS
|
|
130
|
-
).route();
|
|
131
|
-
expect(itineraryWithoutStairs.vertices.length).equal(11);
|
|
132
|
-
itineraryWithoutStairs.edges.forEach((edge) => {
|
|
133
|
-
expect(edge.properties.areStairs).is.not.true;
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// it('toCompressedJson / fromCompressedJson', () => {
|
|
138
|
-
// const json = itinerary.toJson();
|
|
139
|
-
// expect(() => JSON.stringify(json)).not.throw(Error);
|
|
140
|
-
|
|
141
|
-
// const itineraryBis = Itinerary.fromJson(json);
|
|
142
|
-
// verifyCoherence(itineraryBis);
|
|
143
|
-
// expect(itineraryBis.vertices.length).equal(11);
|
|
144
|
-
// verifyVerticesOrder(itineraryBis.vertices, ['w2', ...generateVertexNames(7, 16)]);
|
|
145
|
-
// });
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe('OsmRouter - One Way itinerary', () => {
|
|
150
|
-
|
|
151
|
-
const networkModel = loadGraph('one-way.osm');
|
|
152
|
-
const router = new GraphRouter(networkModel);
|
|
153
|
-
|
|
154
|
-
it('do not use oneway', () => {
|
|
155
|
-
|
|
156
|
-
const start = new Coordinates(43.6094542, 3.8842072);
|
|
157
|
-
const end = new Coordinates(43.6093792, 3.8841889);
|
|
158
|
-
|
|
159
|
-
const route = router.calculateShortestPath(start, end).route();
|
|
160
|
-
expect(route).is.not.undefined;
|
|
161
|
-
expect(getVerticesNames(route)).deep.equals(['p0', 'p1', 'p2', 'p3']);
|
|
162
|
-
|
|
163
|
-
const routeOtherWay = router.calculateShortestPath(end, start).route();
|
|
164
|
-
expect(routeOtherWay).is.not.undefined;
|
|
165
|
-
expect(getVerticesNames(routeOtherWay)).deep.equals(['p3', 'p2', 'p5', 'p4', 'p1', 'p0']);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
describe('OsmRouter - Conveying', () => {
|
|
171
|
-
|
|
172
|
-
const networkModel = loadGraph('gare-de-lyon-extract.osm');
|
|
173
|
-
const router = new GraphRouter(networkModel);
|
|
174
|
-
|
|
175
|
-
it('do not use oneway conveying', () => {
|
|
176
|
-
|
|
177
|
-
const start = new Coordinates(48.8445715, 2.3718927, null, 0);
|
|
178
|
-
const end = new Coordinates(48.8444574, 2.3720728, null, -1);
|
|
179
|
-
|
|
180
|
-
const route = router.calculateShortestPath(start, end).route();
|
|
181
|
-
expect(getVerticesNames(route)).deep.equals(['p11', 'p12', 'p9', 'p8', 'p6', 'proj on null (tmp)']);
|
|
182
|
-
|
|
183
|
-
const routeOtherWay = router.calculateShortestPath(end, start).route();
|
|
184
|
-
expect(routeOtherWay).is.not.undefined;
|
|
185
|
-
expect(getVerticesNames(routeOtherWay)).deep.equals(['proj on null (tmp)', 'p7', 'p10', 'p11']);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
describe('OsmRouter - Conveying - backward', () => {
|
|
191
|
-
|
|
192
|
-
const networkModel = loadGraph('network-conveying-backward.osm');
|
|
193
|
-
const router = new GraphRouter(networkModel);
|
|
194
|
-
|
|
195
|
-
it('do not use oneway conveying', () => {
|
|
196
|
-
|
|
197
|
-
const start = networkModel.getVertexByName('p6')!;
|
|
198
|
-
const end = networkModel.getVertexByName('p13')!;
|
|
199
|
-
|
|
200
|
-
const route = router.calculateShortestPathByVertex(start, end).route();
|
|
201
|
-
expect(route).is.not.undefined;
|
|
202
|
-
expect(getVerticesNames(route)).deep.equals(['p6', 'p7', 'p10', 'p11', 'p12', 'p13']);
|
|
203
|
-
|
|
204
|
-
const routeOtherWay = router.calculateShortestPathByVertex(end, start).route();
|
|
205
|
-
expect(routeOtherWay).is.not.undefined;
|
|
206
|
-
expect(getVerticesNames(routeOtherWay)).deep.equals(['p13', 'p12', 'p9', 'p8', 'p6']);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
describe('OsmRouter - Instruction stairs same level', () => {
|
|
212
|
-
|
|
213
|
-
const networkModel = loadGraph('network-steps-same-level.osm');
|
|
214
|
-
const router = new GraphRouter(networkModel);
|
|
215
|
-
|
|
216
|
-
const getItinerary = (startName: string, endName: string) => {
|
|
217
|
-
const start = networkModel.getVertexByName(startName)!;
|
|
218
|
-
const end = networkModel.getVertexByName(endName)!;
|
|
219
|
-
return Itinerary.fromGraphRoute(router.calculateShortestPathByVertex(start, end).route());
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const expectLevelChangeAtSecondStep = (steps: Step[], direction: 'up' | 'down', difference: number) => {
|
|
223
|
-
expect(steps.length).equals(3);
|
|
224
|
-
expect(steps[1].levelChange).is.not.null;
|
|
225
|
-
expect(steps[1].levelChange?.direction).equal(direction);
|
|
226
|
-
expect(steps[1].levelChange?.difference).equal(difference);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
it('generate instructions for steps at same level', () => {
|
|
230
|
-
|
|
231
|
-
expect(getItinerary('start1', 'end1').steps.length).equal(1);
|
|
232
|
-
expect(getItinerary('start2', 'end2').steps.length).equal(1);
|
|
233
|
-
|
|
234
|
-
expectLevelChangeAtSecondStep(getItinerary('start3', 'end3').steps, 'up', 0);
|
|
235
|
-
expectLevelChangeAtSecondStep(getItinerary('start4', 'end4').steps, 'down', 0);
|
|
236
|
-
expectLevelChangeAtSecondStep(getItinerary('start5', 'end5').steps, 'down', 0);
|
|
237
|
-
expectLevelChangeAtSecondStep(getItinerary('start6', 'end6').steps, 'up', 0);
|
|
238
|
-
|
|
239
|
-
expectLevelChangeAtSecondStep(getItinerary('start7', 'end7').steps, 'up', 1);
|
|
240
|
-
expect(getItinerary('start8', 'end8').steps.length).equal(1);
|
|
241
|
-
expectLevelChangeAtSecondStep(getItinerary('start9', 'end9').steps, 'up', 1);
|
|
242
|
-
expectLevelChangeAtSecondStep(getItinerary('start10', 'end10').steps, 'down', 1); // incline > diff of levels
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
describe('OsmRouter - getTrip', () => {
|
|
248
|
-
|
|
249
|
-
const networkModel = loadGraph('gare-de-lest-network-pp-bounds.osm');
|
|
250
|
-
const router = new GraphRouter(networkModel);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const p1 = new Coordinates(48.87694226286171, 2.358214642814393, null, 0);
|
|
254
|
-
const p2 = new Coordinates(48.877231170388875, 2.358976282564408, null, 0);
|
|
255
|
-
const p3 = new Coordinates(48.876686873477645, 2.359162193531473, null, -1);
|
|
256
|
-
const p4 = new Coordinates(48.87644529052338, 2.3592866339368475, null, 0);
|
|
257
|
-
const p5 = new Coordinates(48.87686732039252, 2.3599553137054845, null, -1);
|
|
258
|
-
|
|
259
|
-
it('getTrip - Success', () => {
|
|
260
|
-
expect(router.getShortestTrip([p1, p2, p3, p4, p5])).is.not.empty;
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it('getTrip - No route', () => {
|
|
264
|
-
const p6 = new Coordinates(0, 0);
|
|
265
|
-
expect(router.getShortestTrip([p1, p2, p3, p4, p5, p6])).is.empty;
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
describe('OsmRouter - create graph components', () => {
|
|
271
|
-
|
|
272
|
-
const networkModel = loadGraph('components.osm');
|
|
273
|
-
const router = new GraphRouter(networkModel);
|
|
274
|
-
|
|
275
|
-
const arraysEqual = <T>(a: T[], b: T[]) => JSON.stringify(a.sort()) === JSON.stringify(b.sort());
|
|
276
|
-
const findComponent = (components: Vertex[][], vertexNames: string[]) =>
|
|
277
|
-
components.find(c => arraysEqual(c.map(v => v.properties.name), vertexNames))
|
|
278
|
-
|
|
279
|
-
it('createComponents()', () => {
|
|
280
|
-
const components = router.calculateComponents();
|
|
281
|
-
|
|
282
|
-
// console.log(JSON.stringify(components.map(c => c.map(v => v.properties.name)), null, 4));
|
|
283
|
-
expect(components.length).equal(6);
|
|
284
|
-
expect(findComponent(components, ['p1', 'p2', 'p3', 'p4'])).to.be.not.undefined;
|
|
285
|
-
expect(findComponent(components, ['p11', 'p12', 'p13'])).to.be.not.undefined;
|
|
286
|
-
expect(findComponent(components, ['p13', 'p14'])).to.be.not.undefined;
|
|
287
|
-
expect(findComponent(components, ['p21', 'p22'])).to.be.not.undefined;
|
|
288
|
-
expect(findComponent(components, ['p31', 'p32', 'p32', 'p33', 'p34'])).to.be.not.undefined;
|
|
289
|
-
expect(findComponent(components, ['p41', 'p42', 'p43', 'p44', 'p45', 'p46', 'p47', 'p48'])).to.be.not.undefined;
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
});
|
package/tests/CommonTest.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Coordinates } from '@wemap/geo';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
|
|
4
|
-
import Edge from '../src/graph/Edge.js';
|
|
5
|
-
import Vertex from '../src/graph/Vertex.js';
|
|
6
|
-
import Graph from '../src/graph/Graph.js';
|
|
7
|
-
|
|
8
|
-
const vertices = [
|
|
9
|
-
new Vertex(new Coordinates(43.6092404, 3.884099, null, 2), { name: 'p0' }), // 0
|
|
10
|
-
new Vertex(new Coordinates(43.6091965, 3.8841285, null, 2), { name: 'p1' }),
|
|
11
|
-
new Vertex(new Coordinates(43.6091888, 3.8841263, null, 2), { name: 'p2' }),
|
|
12
|
-
new Vertex(new Coordinates(43.6091361, 3.8841109, null, 2), { name: 'p3' }),
|
|
13
|
-
new Vertex(new Coordinates(43.6091194, 3.8842202, null, 2), { name: 'p4' }),
|
|
14
|
-
new Vertex(new Coordinates(43.6091722, 3.8842355, null, 2), { name: 'p5' }),
|
|
15
|
-
new Vertex(new Coordinates(43.6091749, 3.8842173, null, 2), { name: 'p6' }),
|
|
16
|
-
new Vertex(new Coordinates(43.609276, 3.8842467, null, 2), { name: 'p7' }),
|
|
17
|
-
new Vertex(new Coordinates(43.6092935, 3.8842518, null, 2), { name: 'p8' }),
|
|
18
|
-
new Vertex(new Coordinates(43.6093022, 3.8842702, null, 2), { name: 'p9' }),
|
|
19
|
-
new Vertex(new Coordinates(43.6093123, 3.8842731, null, 2), { name: 'p10' }), // 10
|
|
20
|
-
new Vertex(new Coordinates(43.6093234, 3.8842009, null, 2), { name: 'p11' }),
|
|
21
|
-
new Vertex(new Coordinates(43.6093629, 3.8842127, null, [1, 2]), { name: 'p12' }),
|
|
22
|
-
new Vertex(new Coordinates(43.6093597, 3.8842336, null, [1, 2]), { name: 'p13' }),
|
|
23
|
-
new Vertex(new Coordinates(43.6093202, 3.8842218, null, 1), { name: 'p14' }),
|
|
24
|
-
new Vertex(new Coordinates(43.6093123, 3.8842731, null, 1), { name: 'p15' }),
|
|
25
|
-
new Vertex(new Coordinates(43.6092681, 3.8842604, null, 1), { name: 'p16' }),
|
|
26
|
-
new Vertex(new Coordinates(43.6093279, 3.8842777, null, 1), { name: 'p17' }),
|
|
27
|
-
new Vertex(new Coordinates(43.6093279, 3.8842777, null, 2), { name: 'p18' }),
|
|
28
|
-
new Vertex(new Coordinates(43.6093323, 3.8842483, null, 2), { name: 'p19a' }),
|
|
29
|
-
new Vertex(new Coordinates(43.6093323, 3.8842483, null, 1), { name: 'p19b' }), // 20
|
|
30
|
-
new Vertex(new Coordinates(43.6093323, 3.8842483, null, 0), { name: 'p19c' }),
|
|
31
|
-
new Vertex(new Coordinates(43.6093032, 3.8844388, null, 0), { name: 'p21' }),
|
|
32
|
-
new Vertex(new Coordinates(43.6095297, 3.8845039, null, 0), { name: 'p26' }),
|
|
33
|
-
new Vertex(new Coordinates(43.6095624, 3.8845134), { name: 'p27' })
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
const n = (name: string) => vertices.find(vertex => vertex.properties.name === name) as Vertex;
|
|
37
|
-
|
|
38
|
-
const edges = [
|
|
39
|
-
new Edge(n('p1'), n('p2'), { name: 'e0' }),
|
|
40
|
-
new Edge(n('p2'), n('p3'), { name: 'e1' }),
|
|
41
|
-
new Edge(n('p3'), n('p4'), { name: 'e2' }),
|
|
42
|
-
new Edge(n('p4'), n('p5'), { name: 'e3' }),
|
|
43
|
-
new Edge(n('p5'), n('p6'), { name: 'e4' }),
|
|
44
|
-
new Edge(n('p6'), n('p2'), { name: 'e5' }),
|
|
45
|
-
new Edge(n('p6'), n('p7'), { name: 'e6' }),
|
|
46
|
-
new Edge(n('p7'), n('p8'), { name: 'e7' }),
|
|
47
|
-
new Edge(n('p8'), n('p9'), { name: 'e8' }),
|
|
48
|
-
new Edge(n('p9'), n('p10'), { name: 'e9' }),
|
|
49
|
-
new Edge(n('p10'), n('p11'), { name: 'e10' }),
|
|
50
|
-
new Edge(n('p11'), n('p12'), { name: 'e11' }),
|
|
51
|
-
new Edge(n('p12'), n('p13'), { name: 'e12' }),
|
|
52
|
-
new Edge(n('p13'), n('p14'), { name: 'e13' }),
|
|
53
|
-
new Edge(n('p14'), n('p15'), { name: 'e14' }),
|
|
54
|
-
new Edge(n('p15'), n('p16'), { name: 'e15' }),
|
|
55
|
-
new Edge(n('p15'), n('p17'), { name: 'e16' }),
|
|
56
|
-
new Edge(n('p19b'), n('p17'), { name: 'e17' }),
|
|
57
|
-
new Edge(n('p10'), n('p18'), { name: 'e18' }),
|
|
58
|
-
new Edge(n('p19a'), n('p18'), { name: 'e19' }),
|
|
59
|
-
new Edge(n('p19a'), n('p19b'), { name: 'e20' }),
|
|
60
|
-
new Edge(n('p19b'), n('p19c'), { name: 'e21'}),
|
|
61
|
-
new Edge(n('p19c'), n('p21'), { name: 'e22' }),
|
|
62
|
-
new Edge(n('p21'), n('p26'), { name: 'e23' }),
|
|
63
|
-
new Edge(n('p26'), n('p27'), { name: 'e24' })
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
const graph = new Graph(vertices, edges);
|
|
67
|
-
|
|
68
|
-
function verifyCoherence(graph: Graph) {
|
|
69
|
-
graph.edges.forEach(edge => {
|
|
70
|
-
expect(edge.vertex1).not.equal(edge.vertex2);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export {
|
|
75
|
-
vertices, edges, graph,
|
|
76
|
-
verifyCoherence,
|
|
77
|
-
Graph, Vertex, Edge
|
|
78
|
-
};
|
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED