@wemap/routers 12.10.8 → 12.10.9
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/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 +32 -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 +77 -0
- package/{src/graph/GraphRouterOptions.ts → dist/src/graph/GraphRouterOptions.d.ts} +5 -7
- package/dist/src/graph/GraphRouterOptionsBuilder.d.ts +20 -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 +40 -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
package/src/graph/Graph.spec.ts
DELETED
|
@@ -1,509 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
|
|
3
|
-
import { BoundingBox, Coordinates, Level, UserPosition, Level_t, Constants as GeoConstants } from '@wemap/geo';
|
|
4
|
-
import { deg2rad } from '@wemap/maths';
|
|
5
|
-
|
|
6
|
-
import { vertices, edges, graph, Vertex, Edge } from '../../tests/CommonTest.js';
|
|
7
|
-
|
|
8
|
-
import Graph from './Graph.js';
|
|
9
|
-
import GraphProjection from './GraphProjection.js';
|
|
10
|
-
|
|
11
|
-
const { expect } = chai;
|
|
12
|
-
|
|
13
|
-
describe('Graph', () => {
|
|
14
|
-
|
|
15
|
-
const { EPS_MM } = GeoConstants
|
|
16
|
-
|
|
17
|
-
it('creation', () => {
|
|
18
|
-
|
|
19
|
-
expect(() => new Graph(vertices, edges)).not.throw(Error);
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('getVertexByCoords', () => {
|
|
24
|
-
|
|
25
|
-
let vertex = graph.getVertexByCoords(vertices[2].coords.clone());
|
|
26
|
-
expect(vertex).not.undefined;
|
|
27
|
-
expect(vertex!.properties.name).equals('p2');
|
|
28
|
-
|
|
29
|
-
vertex = graph.getVertexByCoords(new Coordinates(43.601888, 3.8841263));
|
|
30
|
-
expect(vertex).is.undefined;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('getEdgeByVertices', () => {
|
|
34
|
-
|
|
35
|
-
let edge = graph.getEdgeByVertices(vertices[1], vertices[2]);
|
|
36
|
-
expect(edge).not.null;
|
|
37
|
-
expect(edge!.properties.name).equals('e0');
|
|
38
|
-
|
|
39
|
-
edge = graph.getEdgeByVertices(vertices[0], vertices[2]);
|
|
40
|
-
expect(edge).undefined;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('getBoundingBox', () => {
|
|
44
|
-
|
|
45
|
-
let resultBoundingBox = graph.getBoundingBox();
|
|
46
|
-
expect(resultBoundingBox).is.not.null;
|
|
47
|
-
let boundingBox = resultBoundingBox as BoundingBox;
|
|
48
|
-
expect(boundingBox.getNorth()).closeTo(43.6093629, EPS_MM);
|
|
49
|
-
expect(boundingBox.getWest()).closeTo(3.884099, EPS_MM);
|
|
50
|
-
expect(boundingBox.getSouth()).closeTo(43.6091194, EPS_MM);
|
|
51
|
-
expect(boundingBox.getEast()).closeTo(3.8842777, EPS_MM);
|
|
52
|
-
|
|
53
|
-
resultBoundingBox = graph.getBoundingBox(50);
|
|
54
|
-
expect(resultBoundingBox).is.not.null;
|
|
55
|
-
boundingBox = resultBoundingBox as BoundingBox;
|
|
56
|
-
expect(boundingBox.getNorth()).closeTo(43.60981205596494, EPS_MM);
|
|
57
|
-
expect(boundingBox.getWest()).closeTo(3.883478669715794, EPS_MM);
|
|
58
|
-
expect(boundingBox.getSouth()).closeTo(43.60867024068086, EPS_MM);
|
|
59
|
-
expect(boundingBox.getEast()).closeTo(3.8848980374280675, EPS_MM);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
it('toDetailedString', () => {
|
|
64
|
-
expect(() => graph.toDetailedString()).not.throw(Error);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('to/from compressedJson', () => {
|
|
68
|
-
|
|
69
|
-
const networkJson = graph.toCompressedJson();
|
|
70
|
-
const networkBis = Graph.fromCompressedJson(networkJson);
|
|
71
|
-
|
|
72
|
-
networkBis.vertices.forEach((vertex, i) => {
|
|
73
|
-
expect(vertex.coords.equals(graph.vertices[i].coords)).is.true;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
networkBis.edges.forEach((edge, i) => {
|
|
77
|
-
expect(edge.vertex1.coords.equals(graph.edges[i].vertex1.coords)).is.true;
|
|
78
|
-
expect(edge.vertex2.coords.equals(graph.edges[i].vertex2.coords)).is.true;
|
|
79
|
-
expect(edge.properties.isOneway).equals(graph.edges[i].properties.isOneway);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
it('getEdgesAtLevel', () => {
|
|
85
|
-
|
|
86
|
-
const _vertices = [
|
|
87
|
-
new Vertex(new Coordinates(43.6091194, 3.884099, null, 0), { name: 'p0' }),
|
|
88
|
-
new Vertex(new Coordinates(43.6093629, 3.8842777, null, 0), { name: 'p1' }),
|
|
89
|
-
new Vertex(new Coordinates(43.6094654, 3.8842167, null, [0, 1]), { name: 'p2' }),
|
|
90
|
-
new Vertex(new Coordinates(43.6094902, 3.8843416, null, 1), { name: 'p3' }),
|
|
91
|
-
new Vertex(new Coordinates(43.6095463, 3.8843837, null, 1), { name: 'p4' }),
|
|
92
|
-
new Vertex(new Coordinates(43.6095552, 3.8844971, null, 2), { name: 'p5' }),
|
|
93
|
-
new Vertex(new Coordinates(43.6095908, 3.8844662, null, 1), { name: 'p6' }),
|
|
94
|
-
new Vertex(new Coordinates(43.6096412, 3.8844706, null, 1), { name: 'p7' })
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
const _edges = [
|
|
98
|
-
new Edge(_vertices[0], _vertices[1], { name: 'e0' }),
|
|
99
|
-
new Edge(_vertices[1], _vertices[2], { name: 'e1' }),
|
|
100
|
-
new Edge(_vertices[2], _vertices[3], { name: 'e2' }),
|
|
101
|
-
new Edge(_vertices[3], _vertices[4], { name: 'e3' }),
|
|
102
|
-
new Edge(_vertices[4], _vertices[5], { name: 'e4' }),
|
|
103
|
-
new Edge(_vertices[5], _vertices[6], { name: 'e5' }),
|
|
104
|
-
new Edge(_vertices[6], _vertices[7], { name: 'e6' })
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
const _network = new Graph(_vertices, _edges);
|
|
108
|
-
|
|
109
|
-
const edgesAtLevel0 = _network.getEdgesAtLevel(0, false);
|
|
110
|
-
expect(edgesAtLevel0.length).equals(1);
|
|
111
|
-
expect(edgesAtLevel0[0].properties.name).equals('e0');
|
|
112
|
-
|
|
113
|
-
const segmentsAtLevel1 = _network.getEdgesAtLevel(1, false);
|
|
114
|
-
expect(segmentsAtLevel1.length).equals(2);
|
|
115
|
-
expect(segmentsAtLevel1[0].properties.name).equals('e3');
|
|
116
|
-
expect(segmentsAtLevel1[1].properties.name).equals('e6');
|
|
117
|
-
|
|
118
|
-
const segmentsAtLevel2 = _network.getEdgesAtLevel(2, false);
|
|
119
|
-
expect(segmentsAtLevel2.length).equals(0);
|
|
120
|
-
const segmentsAtLevel2b = _network.getEdgesAtLevel(2, true);
|
|
121
|
-
expect(segmentsAtLevel2b.length).equals(2);
|
|
122
|
-
|
|
123
|
-
const edgesAtLevel01 = _network.getEdgesAtLevel([0, 1], false);
|
|
124
|
-
expect(edgesAtLevel01.length).equals(5);
|
|
125
|
-
const edgesAtLevel01b = _network.getEdgesAtLevel([0, 1], true);
|
|
126
|
-
expect(edgesAtLevel01b.length).equals(7);
|
|
127
|
-
|
|
128
|
-
const edgesAtLevel12 = _network.getEdgesAtLevel([1, 2], false);
|
|
129
|
-
expect(edgesAtLevel12.length).equals(4);
|
|
130
|
-
|
|
131
|
-
const edgesAtLevel02 = _network.getEdgesAtLevel([0, 2], false);
|
|
132
|
-
expect(edgesAtLevel02.length).equals(7);
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
describe('Graph exits', () => {
|
|
140
|
-
|
|
141
|
-
it('construction 1', () => {
|
|
142
|
-
|
|
143
|
-
const vertices = [
|
|
144
|
-
new Vertex(new Coordinates(0, 0, null, 0), { name: 'p1' }),
|
|
145
|
-
new Vertex(new Coordinates(0, 1, null, 0), { name: 'p2' }),
|
|
146
|
-
new Vertex(new Coordinates(0, 2, null, null), { name: 'p3' })
|
|
147
|
-
];
|
|
148
|
-
|
|
149
|
-
const edges = [
|
|
150
|
-
new Edge(vertices[0], vertices[1], { name: 'e1' }),
|
|
151
|
-
new Edge(vertices[1], vertices[2], { name: 'e2' })
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
const graph = new Graph(vertices, edges);
|
|
155
|
-
|
|
156
|
-
expect(graph.getEdgeByName('e1')!.level).equals(0);
|
|
157
|
-
expect(graph.getEdgeByName('e2')!.level).equals(null);
|
|
158
|
-
expect(graph.exitVertices.size).equals(1);
|
|
159
|
-
expect(graph.exitVertices.has(graph.getVertexByName('p2')!)).is.true;
|
|
160
|
-
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('construction 2', () => {
|
|
164
|
-
|
|
165
|
-
const vertices = [
|
|
166
|
-
new Vertex(new Coordinates(0, 0, null, [0, 1]), { name: 'p1' }),
|
|
167
|
-
new Vertex(new Coordinates(0, 1, null, [0, 1]), { name: 'p2' }),
|
|
168
|
-
new Vertex(new Coordinates(0, 2, null, null), { name: 'p3' })
|
|
169
|
-
];
|
|
170
|
-
|
|
171
|
-
const edges = [
|
|
172
|
-
new Edge(vertices[0], vertices[1], { name: 'e1' }),
|
|
173
|
-
new Edge(vertices[1], vertices[2], { name: 'e2' })
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
const graph = new Graph(vertices, edges);
|
|
177
|
-
|
|
178
|
-
expect(Level.equals(graph.getEdgeByName('e1')!.level, [0, 1])).is.true;
|
|
179
|
-
expect(graph.getEdgeByName('e2')!.level).equals(null);
|
|
180
|
-
expect(graph.exitVertices.size).equals(1);
|
|
181
|
-
expect(graph.exitVertices.has(graph.getVertexByName('p2')!)).is.true;
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
it('construction 3', () => {
|
|
187
|
-
|
|
188
|
-
expect(graph.getEdgeByName('e23')!.level).equals(0);
|
|
189
|
-
expect(graph.getEdgeByName('e24')!.level).equals(null);
|
|
190
|
-
expect(graph.exitVertices.size).equals(1);
|
|
191
|
-
expect(graph.exitVertices.has(graph.getVertexByName('p26')!)).is.true;
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
let projection: GraphProjection | null;
|
|
199
|
-
|
|
200
|
-
const expectProjection = (projectionResult: GraphProjection | null, conditions: {
|
|
201
|
-
isNull?: boolean,
|
|
202
|
-
level?: Level_t,
|
|
203
|
-
alt?: number,
|
|
204
|
-
coords?: Coordinates,
|
|
205
|
-
nearestElementType?: 'edge' | 'vertex',
|
|
206
|
-
name?: string
|
|
207
|
-
}) => {
|
|
208
|
-
if (typeof conditions.isNull !== 'undefined' && conditions.isNull) {
|
|
209
|
-
expect(projectionResult).is.null;
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
expect(projectionResult).is.not.null;
|
|
213
|
-
const projection = projectionResult as GraphProjection;
|
|
214
|
-
if (typeof conditions.coords !== 'undefined') {
|
|
215
|
-
expect(Coordinates.equals(projection.coords, conditions.coords)).true;
|
|
216
|
-
}
|
|
217
|
-
if (conditions.nearestElementType === 'edge') {
|
|
218
|
-
expect(projection.nearestElement).instanceOf(Edge);
|
|
219
|
-
}
|
|
220
|
-
if (conditions.nearestElementType === 'vertex') {
|
|
221
|
-
expect(projection.nearestElement).instanceOf(Vertex);
|
|
222
|
-
}
|
|
223
|
-
if (typeof conditions.level !== 'undefined') {
|
|
224
|
-
expect(Level.equals(projection.coords.level, conditions.level)).true;
|
|
225
|
-
}
|
|
226
|
-
if (typeof conditions.name !== 'undefined') {
|
|
227
|
-
expect(projection.nearestElement.properties.name).equals(conditions.name);
|
|
228
|
-
}
|
|
229
|
-
if (typeof conditions.alt !== 'undefined') {
|
|
230
|
-
expect(projection.coords.alt).equals(conditions.alt);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
describe('Graph Projection', () => {
|
|
235
|
-
|
|
236
|
-
const vertices = [
|
|
237
|
-
new Vertex(new Coordinates(43.6091194, 3.884099), { name: 'p0' }),
|
|
238
|
-
new Vertex(new Coordinates(43.6093629, 3.8842777), { name: 'p1' }),
|
|
239
|
-
new Vertex(new Coordinates(43.6092785, 3.8845052), { name: 'p2' })
|
|
240
|
-
];
|
|
241
|
-
|
|
242
|
-
const edges = [
|
|
243
|
-
new Edge(vertices[0], vertices[1], { name: 'e0' }),
|
|
244
|
-
new Edge(vertices[1], vertices[2], { name: 'e1' })
|
|
245
|
-
];
|
|
246
|
-
|
|
247
|
-
const graph = new Graph(vertices, edges);
|
|
248
|
-
|
|
249
|
-
const location = new UserPosition(43.6092086, 3.8842598);
|
|
250
|
-
let expected: Coordinates;
|
|
251
|
-
|
|
252
|
-
it('not working projections', () => {
|
|
253
|
-
const location2 = location.clone();
|
|
254
|
-
expect(graph.getProjection(location2, { maxBearingAngle: 2 })).is.null;
|
|
255
|
-
expect(graph.getProjection(location, { maxBearingAngle: Math.PI / 8 })).is.null;
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('normal', () => {
|
|
259
|
-
expected = new Coordinates(43.609237204372555, 3.8841854542043253);
|
|
260
|
-
|
|
261
|
-
projection = graph.getProjection(location);
|
|
262
|
-
expectProjection(projection, { name: 'e0', coords: expected, nearestElementType: 'edge' });
|
|
263
|
-
|
|
264
|
-
const owVertices = [
|
|
265
|
-
new Vertex(new Coordinates(43.6091194, 3.884099, 5)),
|
|
266
|
-
new Vertex(new Coordinates(43.6093629, 3.8842777, 10))
|
|
267
|
-
];
|
|
268
|
-
const owNetwork = new Graph(owVertices, [
|
|
269
|
-
new Edge(owVertices[0], owVertices[1])
|
|
270
|
-
]);
|
|
271
|
-
projection = owNetwork.getProjection(new Coordinates(43.6092086, 3.8842598, 7.5));
|
|
272
|
-
expectProjection(projection, { alt: 7.5 });
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('with bearing', () => {
|
|
276
|
-
expected = new Coordinates(43.6093360752685, 3.884350006286521);
|
|
277
|
-
|
|
278
|
-
location.bearing = deg2rad(101.9);
|
|
279
|
-
projection = graph.getProjection(location, { maxBearingAngle: deg2rad(30) });
|
|
280
|
-
expectProjection(projection, { name: 'e1', coords: expected, nearestElementType: 'edge' });
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('with epsilon', () => {
|
|
284
|
-
|
|
285
|
-
let pointToTest;
|
|
286
|
-
|
|
287
|
-
pointToTest = vertices[0].coords.destinationPoint(0.0001, vertices[0].bearingTo(vertices[1]));
|
|
288
|
-
projection = graph.getProjection(pointToTest);
|
|
289
|
-
expectProjection(projection, { name: 'p0', nearestElementType: 'vertex' });
|
|
290
|
-
|
|
291
|
-
pointToTest = vertices[1].coords.destinationPoint(0.0001, vertices[1].bearingTo(vertices[0]));
|
|
292
|
-
projection = graph.getProjection(pointToTest);
|
|
293
|
-
expectProjection(projection, { name: 'p1', nearestElementType: 'vertex' });
|
|
294
|
-
|
|
295
|
-
pointToTest = vertices[0].coords.destinationPoint(0.005, vertices[0].bearingTo(vertices[1]));
|
|
296
|
-
projection = graph.getProjection(pointToTest);
|
|
297
|
-
expectProjection(projection, { name: 'e0', nearestElementType: 'edge', coords: pointToTest });
|
|
298
|
-
|
|
299
|
-
pointToTest = vertices[1].coords.destinationPoint(0.005, vertices[1].bearingTo(vertices[0]));
|
|
300
|
-
projection = graph.getProjection(pointToTest);
|
|
301
|
-
expectProjection(projection, { name: 'e0', nearestElementType: 'edge', coords: pointToTest });
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
describe('Graph Projection - multilevels', () => {
|
|
307
|
-
|
|
308
|
-
const location = new UserPosition(43.6091762, 3.8841239, null, 2);
|
|
309
|
-
|
|
310
|
-
it('normal', () => {
|
|
311
|
-
projection = graph.getProjection(location);
|
|
312
|
-
const expected = new Coordinates(43.609176387963934, 3.884122673088027, null, 2);
|
|
313
|
-
expectProjection(projection, { coords: expected });
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it('with bearing', () => {
|
|
317
|
-
location.bearing = deg2rad(101.9);
|
|
318
|
-
const expected = new Coordinates(43.609188614172005, 3.8841275169229754, null, 2);
|
|
319
|
-
projection = graph.getProjection(location, { maxBearingAngle: deg2rad(30) });
|
|
320
|
-
expectProjection(projection, { coords: expected });
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it('matching vertex levels', () => {
|
|
324
|
-
let currentPosition;
|
|
325
|
-
|
|
326
|
-
currentPosition = new Coordinates(43.6091773, 3.8842584, null, -1);
|
|
327
|
-
projection = graph.getProjection(currentPosition);
|
|
328
|
-
expectProjection(projection, { isNull: true });
|
|
329
|
-
|
|
330
|
-
currentPosition = new Coordinates(43.6091773, 3.8842584, null, null);
|
|
331
|
-
projection = graph.getProjection(currentPosition);
|
|
332
|
-
expectProjection(projection, { level: null, name: 'p26' });
|
|
333
|
-
|
|
334
|
-
currentPosition = new Coordinates(43.6091773, 3.8842584, null, 0);
|
|
335
|
-
projection = graph.getProjection(currentPosition);
|
|
336
|
-
expectProjection(projection, { level: 0, name: 'e22' });
|
|
337
|
-
|
|
338
|
-
currentPosition = new Coordinates(43.6095387, 3.8845434, null, 0);
|
|
339
|
-
projection = graph.getProjection(currentPosition);
|
|
340
|
-
expectProjection(projection, { level: 0, name: 'p26' });
|
|
341
|
-
|
|
342
|
-
currentPosition = new Coordinates(43.6091773, 3.8842584, null, 1);
|
|
343
|
-
projection = graph.getProjection(currentPosition);
|
|
344
|
-
expectProjection(projection, { level: 1, name: 'p16' });
|
|
345
|
-
|
|
346
|
-
currentPosition = new Coordinates(43.6091773, 3.8842584, null, 2);
|
|
347
|
-
projection = graph.getProjection(currentPosition);
|
|
348
|
-
expectProjection(projection, { level: 2, name: 'p5' });
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it('matching edge levels', () => {
|
|
352
|
-
let currentPosition;
|
|
353
|
-
|
|
354
|
-
currentPosition = new Coordinates(43.6092811, 3.8842406, null, -1);
|
|
355
|
-
projection = graph.getProjection(currentPosition);
|
|
356
|
-
expectProjection(projection, { isNull: true });
|
|
357
|
-
|
|
358
|
-
currentPosition = new Coordinates(43.6095474, 3.8844914, null, null);
|
|
359
|
-
projection = graph.getProjection(currentPosition);
|
|
360
|
-
expectProjection(projection, { level: null, name: 'e24' });
|
|
361
|
-
|
|
362
|
-
currentPosition = new Coordinates(43.6095474, 3.8844914, null, 0);
|
|
363
|
-
projection = graph.getProjection(currentPosition);
|
|
364
|
-
expectProjection(projection, { level: 0, name: 'p26' });
|
|
365
|
-
|
|
366
|
-
currentPosition = new Coordinates(43.6092811, 3.8842406, null, 1);
|
|
367
|
-
projection = graph.getProjection(currentPosition);
|
|
368
|
-
expectProjection(projection, { level: 1, name: 'e15' });
|
|
369
|
-
|
|
370
|
-
currentPosition = new Coordinates(43.6092811, 3.8842406, null, 2);
|
|
371
|
-
projection = graph.getProjection(currentPosition);
|
|
372
|
-
expectProjection(projection, { level: 2, name: 'e7' });
|
|
373
|
-
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
it('matching stairs vertices levels', () => {
|
|
377
|
-
let currentPosition;
|
|
378
|
-
|
|
379
|
-
currentPosition = new Coordinates(43.6093691, 3.8842057, null, -1);
|
|
380
|
-
projection = graph.getProjection(currentPosition);
|
|
381
|
-
expectProjection(projection, { isNull: true });
|
|
382
|
-
|
|
383
|
-
currentPosition = new Coordinates(43.6093691, 3.8842057, null, 1);
|
|
384
|
-
projection = graph.getProjection(currentPosition);
|
|
385
|
-
expectProjection(projection, { level: [1, 2], name: 'p12' });
|
|
386
|
-
|
|
387
|
-
currentPosition = new Coordinates(43.6093691, 3.8842057, null, 2);
|
|
388
|
-
projection = graph.getProjection(currentPosition);
|
|
389
|
-
expectProjection(projection, { level: [1, 2], name: 'p12' });
|
|
390
|
-
|
|
391
|
-
currentPosition = new Coordinates(43.6093691, 3.8842057, null, [1, 2]);
|
|
392
|
-
projection = graph.getProjection(currentPosition);
|
|
393
|
-
expectProjection(projection, { level: [1, 2], name: 'p12' });
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('matching stairs edge levels', () => {
|
|
397
|
-
let currentPosition;
|
|
398
|
-
|
|
399
|
-
currentPosition = new Coordinates(43.6093476, 3.8841978, null, -1);
|
|
400
|
-
projection = graph.getProjection(currentPosition);
|
|
401
|
-
expectProjection(projection, { isNull: true });
|
|
402
|
-
|
|
403
|
-
currentPosition = new Coordinates(43.6093476, 3.8841978, null, 1);
|
|
404
|
-
projection = graph.getProjection(currentPosition);
|
|
405
|
-
expectProjection(projection, { level: [1, 2], name: 'e11' });
|
|
406
|
-
|
|
407
|
-
currentPosition = new Coordinates(43.6093476, 3.8841978, null, 2);
|
|
408
|
-
projection = graph.getProjection(currentPosition);
|
|
409
|
-
expectProjection(projection, { level: [1, 2], name: 'e11' });
|
|
410
|
-
|
|
411
|
-
currentPosition = new Coordinates(43.6093476, 3.8841978, null, [1, 2]);
|
|
412
|
-
projection = graph.getProjection(currentPosition);
|
|
413
|
-
expectProjection(projection, { level: [1, 2], name: 'e11' });
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it('useMultiLevelSegments = false', () => {
|
|
417
|
-
let currentPosition;
|
|
418
|
-
|
|
419
|
-
const withoutMultiLevelSegmentsOptions = { useMultiLevelSegments: false }
|
|
420
|
-
const withMultiLevelSegmentsOptions = { useMultiLevelSegments: true }
|
|
421
|
-
|
|
422
|
-
// On Vertices
|
|
423
|
-
|
|
424
|
-
currentPosition = new Coordinates(43.6093381, 3.8841926, null, -1);
|
|
425
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
426
|
-
expectProjection(projection, { isNull: true });
|
|
427
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
428
|
-
expectProjection(projection, { isNull: true });
|
|
429
|
-
|
|
430
|
-
currentPosition = new Coordinates(43.6093381, 3.8841926, null, 0);
|
|
431
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
432
|
-
expectProjection(projection, { level: 0, name: 'p19c' });
|
|
433
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
434
|
-
expectProjection(projection, { name: 'p19c' });
|
|
435
|
-
|
|
436
|
-
currentPosition = new Coordinates(43.6093381, 3.8841926, null, 1);
|
|
437
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
438
|
-
expectProjection(projection, { level: 1, name: 'p14' });
|
|
439
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
440
|
-
expectProjection(projection, { name: 'e11' });
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
currentPosition = new Coordinates(43.6093381, 3.8841926, null, 2);
|
|
444
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
445
|
-
expectProjection(projection, { level: 2, name: 'p11' });
|
|
446
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
447
|
-
expectProjection(projection, { name: 'e11' });
|
|
448
|
-
|
|
449
|
-
// On Segments
|
|
450
|
-
|
|
451
|
-
currentPosition = new Coordinates(43.6093551, 3.88425725, null, -1);
|
|
452
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
453
|
-
expectProjection(projection, { isNull: true });
|
|
454
|
-
|
|
455
|
-
currentPosition = new Coordinates(43.6093551, 3.88425725, null, 0);
|
|
456
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
457
|
-
expectProjection(projection, { level: 0, name: 'e22' });
|
|
458
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
459
|
-
expectProjection(projection, { name: 'e22' });
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
currentPosition = new Coordinates(43.6093551, 3.88425725, null, 1);
|
|
463
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
464
|
-
expectProjection(projection, { level: 1, name: 'e17' });
|
|
465
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
466
|
-
expectProjection(projection, { name: 'e13' });
|
|
467
|
-
|
|
468
|
-
currentPosition = new Coordinates(43.6093258, 3.8842272, null, 2);
|
|
469
|
-
projection = graph.getProjection(currentPosition, withoutMultiLevelSegmentsOptions);
|
|
470
|
-
expectProjection(projection, { level: 2, name: 'e10' });
|
|
471
|
-
projection = graph.getProjection(currentPosition, withMultiLevelSegmentsOptions);
|
|
472
|
-
expectProjection(projection, { name: 'e13' });
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
it('matching exact vertex position with eps', () => {
|
|
477
|
-
let currentPosition;
|
|
478
|
-
|
|
479
|
-
currentPosition = new Coordinates(43.60936289383032, 3.884212691390017, null, -1);
|
|
480
|
-
projection = graph.getProjection(currentPosition);
|
|
481
|
-
expectProjection(projection, { isNull: true });
|
|
482
|
-
|
|
483
|
-
currentPosition = new Coordinates(43.60936289383032, 3.884212691390017, null, null);
|
|
484
|
-
projection = graph.getProjection(currentPosition);
|
|
485
|
-
expectProjection(projection, { name: 'p26', level: null });
|
|
486
|
-
|
|
487
|
-
currentPosition = new Coordinates(43.60936289383032, 3.884212691390017, null, [1, 2]);
|
|
488
|
-
projection = graph.getProjection(currentPosition);
|
|
489
|
-
expectProjection(projection, { name: 'p12', level: [1, 2] });
|
|
490
|
-
|
|
491
|
-
currentPosition = new Coordinates(43.60936289383032, 3.884212691390017, null, 1);
|
|
492
|
-
projection = graph.getProjection(currentPosition);
|
|
493
|
-
expectProjection(projection, { name: 'p12', level: [1, 2] });
|
|
494
|
-
|
|
495
|
-
currentPosition = new Coordinates(43.60936289383032, 3.884212691390017, null, 2);
|
|
496
|
-
projection = graph.getProjection(currentPosition);
|
|
497
|
-
expectProjection(projection, { name: 'p12', level: [1, 2] });
|
|
498
|
-
|
|
499
|
-
currentPosition = new Coordinates(43.60936289383032, 3.884212691390017, null, [0, 3]);
|
|
500
|
-
projection = graph.getProjection(currentPosition);
|
|
501
|
-
expectProjection(projection, { name: 'p12', level: [1, 2] });
|
|
502
|
-
|
|
503
|
-
currentPosition = new Coordinates(43.6093323, 3.8842483, null, 0);
|
|
504
|
-
projection = graph.getProjection(currentPosition);
|
|
505
|
-
expectProjection(projection, { name: 'p19c', level: 0 });
|
|
506
|
-
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
});
|