@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
package/src/model/Leg.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Coordinates, CoordinatesCompressedJson, Level, Utils as GeoUtils
|
|
3
|
-
} from '@wemap/geo';
|
|
4
|
-
|
|
5
|
-
import Graph from '../graph/Graph.js';
|
|
6
|
-
import GraphRoute from '../graph/GraphRoute.js';
|
|
7
|
-
import { getDurationFromLength } from '../Utils.js';
|
|
8
|
-
import { TransitMode, isTransitModePublicTransport } from './TransitMode.js';
|
|
9
|
-
|
|
10
|
-
import { jsonToStep, Step, stepEquals, StepJson, stepToJson } from './Step.js'
|
|
11
|
-
import StepsBuilder from './StepsBuilder.js';
|
|
12
|
-
|
|
13
|
-
export type Destination = {
|
|
14
|
-
name: string | null,
|
|
15
|
-
coords: Coordinates
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type DestinationConstructor = {
|
|
19
|
-
name?: string,
|
|
20
|
-
coords: Coordinates
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type DestinationJson = {
|
|
24
|
-
name?: string,
|
|
25
|
-
coords: CoordinatesCompressedJson
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type TransportInfo = {
|
|
29
|
-
name: string,
|
|
30
|
-
routeColor?: string,
|
|
31
|
-
routeTextColor?: string,
|
|
32
|
-
directionName?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type LegCommon = {
|
|
36
|
-
transitMode: TransitMode,
|
|
37
|
-
startTime?: number,
|
|
38
|
-
endTime?: number,
|
|
39
|
-
transportInfo?: TransportInfo,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type LegConstructor =
|
|
43
|
-
{
|
|
44
|
-
start: DestinationConstructor,
|
|
45
|
-
end: DestinationConstructor,
|
|
46
|
-
coords: Coordinates[],
|
|
47
|
-
steps?: Step[],
|
|
48
|
-
duration?: number
|
|
49
|
-
}
|
|
50
|
-
& LegCommon;
|
|
51
|
-
|
|
52
|
-
export type LegJson = {
|
|
53
|
-
start: DestinationJson,
|
|
54
|
-
end: DestinationJson,
|
|
55
|
-
coords: CoordinatesCompressedJson[],
|
|
56
|
-
steps: StepJson[],
|
|
57
|
-
distance: number,
|
|
58
|
-
duration: number
|
|
59
|
-
} & LegCommon;
|
|
60
|
-
|
|
61
|
-
export default class Leg {
|
|
62
|
-
|
|
63
|
-
start: Destination;
|
|
64
|
-
end: Destination;
|
|
65
|
-
coords: Coordinates[];
|
|
66
|
-
distance: number;
|
|
67
|
-
transitMode: TransitMode;
|
|
68
|
-
|
|
69
|
-
duration: number;
|
|
70
|
-
startTime: number | null;
|
|
71
|
-
endTime: number | null;
|
|
72
|
-
|
|
73
|
-
steps: Step[];
|
|
74
|
-
transportInfo: TransportInfo | null;
|
|
75
|
-
|
|
76
|
-
constructor({
|
|
77
|
-
start, end, coords, transitMode, duration,
|
|
78
|
-
startTime, endTime, transportInfo, steps
|
|
79
|
-
}: LegConstructor) {
|
|
80
|
-
this.start = {
|
|
81
|
-
name: start.name || null,
|
|
82
|
-
coords: start.coords
|
|
83
|
-
};
|
|
84
|
-
this.end = {
|
|
85
|
-
name: end.name || null,
|
|
86
|
-
coords: end.coords
|
|
87
|
-
};
|
|
88
|
-
this.coords = coords;
|
|
89
|
-
this.transitMode = transitMode;
|
|
90
|
-
this.distance = GeoUtils.calcDistance(coords)
|
|
91
|
-
this.duration = typeof duration === 'number' ? duration : getDurationFromLength(this.distance);
|
|
92
|
-
this.startTime = typeof startTime === 'number' ? startTime : null;
|
|
93
|
-
this.endTime = typeof endTime === 'number' ? endTime : null;
|
|
94
|
-
this.transportInfo = transportInfo || null;
|
|
95
|
-
this.steps = Array.isArray(steps)
|
|
96
|
-
? steps
|
|
97
|
-
: new StepsBuilder().setStart(start.coords).setEnd(end.coords).setPathCoords(coords).build();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
isPublicTransport() {
|
|
101
|
-
return isTransitModePublicTransport(this.transitMode);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
toGraph() {
|
|
105
|
-
return Graph.fromCoordinatesSegments([this.coords]);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static equals(obj1: Leg, obj2: Leg) {
|
|
109
|
-
const intermediate = obj1.transitMode === obj2.transitMode
|
|
110
|
-
&& Math.abs(obj1.duration - obj2.duration) <= 0.05
|
|
111
|
-
&& obj1.startTime === obj2.startTime
|
|
112
|
-
&& obj1.endTime === obj2.endTime
|
|
113
|
-
&& obj1.start.name === obj2.start.name
|
|
114
|
-
&& obj1.start.coords.equals(obj2.start.coords)
|
|
115
|
-
&& obj1.end.name === obj2.end.name
|
|
116
|
-
&& obj1.end.coords.equals(obj2.end.coords)
|
|
117
|
-
&& obj1.coords.length === obj2.coords.length
|
|
118
|
-
&& (
|
|
119
|
-
obj1.steps === obj2.steps
|
|
120
|
-
|| obj1.steps?.length === obj2.steps?.length
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (!intermediate) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
let i;
|
|
128
|
-
for (i = 0; i < obj1.coords.length; i++) {
|
|
129
|
-
if (!obj1.coords[i].equals(obj2.coords[i])) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
for (i = 0; i < obj1.steps.length; i++) {
|
|
134
|
-
if (!stepEquals(obj1.steps[i], obj2.steps[i])) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (obj1.transportInfo !== obj2.transportInfo) {
|
|
140
|
-
if (obj1.transportInfo === null || obj2.transportInfo === null) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
if (
|
|
144
|
-
obj1.transportInfo.name !== obj2.transportInfo.name
|
|
145
|
-
|| obj1.transportInfo.routeColor !== obj2.transportInfo.routeColor
|
|
146
|
-
|| obj1.transportInfo.routeTextColor !== obj2.transportInfo.routeTextColor
|
|
147
|
-
|| obj1.transportInfo.directionName !== obj2.transportInfo.directionName
|
|
148
|
-
) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
equals(obj: Leg) {
|
|
157
|
-
return Leg.equals(this, obj);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
toJson(): LegJson {
|
|
161
|
-
return {
|
|
162
|
-
transitMode: this.transitMode,
|
|
163
|
-
start: {
|
|
164
|
-
coords: this.start.coords.toCompressedJson(),
|
|
165
|
-
...(this.start.name && { name: this.start.name }),
|
|
166
|
-
},
|
|
167
|
-
end: {
|
|
168
|
-
coords: this.end.coords.toCompressedJson(),
|
|
169
|
-
...(this.end.name && { name: this.end.name }),
|
|
170
|
-
},
|
|
171
|
-
distance: Number(this.distance.toFixed(1)),
|
|
172
|
-
duration: Number(this.duration.toFixed(1)),
|
|
173
|
-
coords: this.coords.map(coords => coords.toCompressedJson()),
|
|
174
|
-
steps: this.steps.map(stepToJson),
|
|
175
|
-
...(this.startTime !== null && { startTime: this.startTime }),
|
|
176
|
-
...(this.endTime !== null && { endTime: this.endTime }),
|
|
177
|
-
...(this.transportInfo !== null && { transportInfo: this.transportInfo }),
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
static fromJson(json: LegJson) {
|
|
182
|
-
const leg = new Leg(Object.assign({}, json, {
|
|
183
|
-
start: {
|
|
184
|
-
coords: Coordinates.fromCompressedJson(json.start.coords),
|
|
185
|
-
name: json.start.name || null
|
|
186
|
-
},
|
|
187
|
-
end: {
|
|
188
|
-
coords: Coordinates.fromCompressedJson(json.end.coords),
|
|
189
|
-
name: json.end.name || null
|
|
190
|
-
},
|
|
191
|
-
coords: json.coords.map(Coordinates.fromCompressedJson),
|
|
192
|
-
steps: json.steps?.map(jsonToStep) || null,
|
|
193
|
-
}));
|
|
194
|
-
|
|
195
|
-
return leg;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
static fromGraphRoute(
|
|
199
|
-
graphRoute: GraphRoute,
|
|
200
|
-
transitMode: TransitMode = 'WALK'
|
|
201
|
-
) {
|
|
202
|
-
return new Leg({
|
|
203
|
-
start: { coords: graphRoute.start },
|
|
204
|
-
end: { coords: graphRoute.end },
|
|
205
|
-
coords: graphRoute.vertices.map(vertex => vertex.coords),
|
|
206
|
-
duration: graphRoute.edgesWeights.reduce((acc, weight) => acc + weight, 0),
|
|
207
|
-
transitMode,
|
|
208
|
-
steps: new StepsBuilder().setGraphRoute(graphRoute).build()
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// TODO: Remove when possible...
|
|
213
|
-
// Livemap specific
|
|
214
|
-
multiplyLevel(levelFactor: number) {
|
|
215
|
-
this.start.coords.level = Level.multiplyBy(this.start.coords.level, levelFactor);
|
|
216
|
-
this.end.coords.level = Level.multiplyBy(this.end.coords.level, levelFactor);
|
|
217
|
-
for (const coords of this.coords) {
|
|
218
|
-
coords.level = Level.multiplyBy(coords.level, levelFactor);
|
|
219
|
-
}
|
|
220
|
-
this.steps.forEach(step => {
|
|
221
|
-
step.coords.level = Level.multiplyBy(step.coords.level, levelFactor);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
|
|
3
|
-
import { LevelChange, areLevelChangeEquals } from './LevelChange.js';
|
|
4
|
-
|
|
5
|
-
const { expect } = chai;
|
|
6
|
-
|
|
7
|
-
const levelChange1: LevelChange = {
|
|
8
|
-
direction: 'up',
|
|
9
|
-
difference: 1,
|
|
10
|
-
type: 'stairs'
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const levelChange2: LevelChange = {
|
|
14
|
-
direction: 'down',
|
|
15
|
-
difference: -1,
|
|
16
|
-
type: 'elevator'
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const levelChange3: LevelChange = {
|
|
20
|
-
direction: 'up',
|
|
21
|
-
difference: 3,
|
|
22
|
-
type: 'escalator'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const levelChange4: LevelChange = {
|
|
26
|
-
direction: 'up',
|
|
27
|
-
difference: 1
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const levelChange5: LevelChange = {
|
|
31
|
-
direction: 'up',
|
|
32
|
-
difference: 1
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
describe('LevelChange', () => {
|
|
36
|
-
|
|
37
|
-
it('equals', () => {
|
|
38
|
-
expect(areLevelChangeEquals(levelChange1, levelChange1)).is.true;
|
|
39
|
-
expect(areLevelChangeEquals(levelChange2, levelChange2)).is.true;
|
|
40
|
-
expect(areLevelChangeEquals(levelChange3, levelChange3)).is.true;
|
|
41
|
-
expect(areLevelChangeEquals(levelChange4, levelChange4)).is.true;
|
|
42
|
-
expect(areLevelChangeEquals(levelChange4, levelChange5)).is.true;
|
|
43
|
-
expect(areLevelChangeEquals(levelChange1, levelChange2)).is.false;
|
|
44
|
-
expect(areLevelChangeEquals(levelChange1, levelChange3)).is.false;
|
|
45
|
-
expect(areLevelChangeEquals(levelChange1, levelChange4)).is.false;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export { levelChange1, levelChange2, levelChange3, levelChange4 };
|
package/src/model/LevelChange.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type LevelChangeType = 'elevator' | 'escalator' | 'stairs' | 'moving walkway' | 'incline plane';
|
|
2
|
-
|
|
3
|
-
export type LevelChange = {
|
|
4
|
-
direction: 'up' | 'down';
|
|
5
|
-
difference: number;
|
|
6
|
-
type?: LevelChangeType;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function areLevelChangeEquals(l1: LevelChange, l2: LevelChange) {
|
|
10
|
-
return l1 === l2
|
|
11
|
-
|| l1.difference === l2.difference
|
|
12
|
-
&& l1.direction === l2.direction
|
|
13
|
-
&& l1.type === l2.type;
|
|
14
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Coordinates } from "@wemap/geo"
|
|
2
|
-
|
|
3
|
-
import { TravelMode, TravelModePreference } from "./TravelMode"
|
|
4
|
-
|
|
5
|
-
export type RouterRequest = {
|
|
6
|
-
origin: Coordinates,
|
|
7
|
-
destination: Coordinates,
|
|
8
|
-
travelMode: TravelMode,
|
|
9
|
-
travelModePreference?: TravelModePreference,
|
|
10
|
-
provideItineraryAlternatives?: boolean,
|
|
11
|
-
waypoints?: Coordinates[],
|
|
12
|
-
optimizeWaypoints?: boolean,
|
|
13
|
-
itineraryModifiers?: {
|
|
14
|
-
avoidStairs?: boolean,
|
|
15
|
-
avoidEscalators?: boolean,
|
|
16
|
-
avoidElevators?: boolean,
|
|
17
|
-
avoidMovingWalkways?: boolean,
|
|
18
|
-
avoidTicketRestrictedAreas?: boolean
|
|
19
|
-
}
|
|
20
|
-
output?: {
|
|
21
|
-
distanceAndDurationOnly?: boolean
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function routerRequestToJson(routerRequest: RouterRequest) {
|
|
26
|
-
const { origin, destination, waypoints, ...rest } = routerRequest;
|
|
27
|
-
return {
|
|
28
|
-
origin: origin.toJson(),
|
|
29
|
-
destination: destination.toJson(),
|
|
30
|
-
...(waypoints && { waypoints: waypoints.map(w => w.toJson()) }),
|
|
31
|
-
...rest
|
|
32
|
-
}
|
|
33
|
-
}
|
package/src/model/Step.spec.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Coordinates } from '@wemap/geo';
|
|
2
|
-
import chai from 'chai';
|
|
3
|
-
|
|
4
|
-
import { jsonToStep, Step, stepEquals, stepToJson } from './Step.js';
|
|
5
|
-
import { levelChange1 } from './LevelChange.spec.js';
|
|
6
|
-
|
|
7
|
-
const { expect } = chai;
|
|
8
|
-
|
|
9
|
-
const step1: Step = {
|
|
10
|
-
firstStep: true,
|
|
11
|
-
lastStep: false,
|
|
12
|
-
number: 1,
|
|
13
|
-
coords: new Coordinates(0, 0),
|
|
14
|
-
angle: 0,
|
|
15
|
-
previousBearing: 0,
|
|
16
|
-
nextBearing: 0,
|
|
17
|
-
distance: 10,
|
|
18
|
-
duration: 0,
|
|
19
|
-
name: null,
|
|
20
|
-
levelChange: null,
|
|
21
|
-
extras: null
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const step2Coords = new Coordinates(1, 0);
|
|
25
|
-
const step2 = {
|
|
26
|
-
...step1,
|
|
27
|
-
firstStep: false,
|
|
28
|
-
number: 2,
|
|
29
|
-
coords: step2Coords,
|
|
30
|
-
distance: step1.coords.distanceTo(step2Coords),
|
|
31
|
-
extras: { subwayEntrance: true, subwayEntranceRef: 'toto', isGate: true }
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const step3Coords = new Coordinates(2, 0, null);
|
|
35
|
-
const step3Distance = step2.coords.distanceTo(step3Coords);
|
|
36
|
-
const step3 = {
|
|
37
|
-
...step2,
|
|
38
|
-
number: 3,
|
|
39
|
-
coords: step3Coords,
|
|
40
|
-
distance: step3Distance,
|
|
41
|
-
duration: step3Distance * 2,
|
|
42
|
-
levelChange: levelChange1,
|
|
43
|
-
extras: { subwayEntrance: false }
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const step4Coords = new Coordinates(3, 0);
|
|
47
|
-
const step4 = {
|
|
48
|
-
...step3,
|
|
49
|
-
lastStep: true,
|
|
50
|
-
number: 4,
|
|
51
|
-
coords: step4Coords,
|
|
52
|
-
distance: step3.coords.distanceTo(step4Coords),
|
|
53
|
-
name: 'end',
|
|
54
|
-
extras: {}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const step5 = Object.assign({}, step4);
|
|
59
|
-
|
|
60
|
-
describe('Step', () => {
|
|
61
|
-
|
|
62
|
-
it('equals', () => {
|
|
63
|
-
expect(stepEquals(step1, step1)).is.true;
|
|
64
|
-
expect(stepEquals(step2, step2)).is.true;
|
|
65
|
-
expect(stepEquals(step3, step3)).is.true;
|
|
66
|
-
expect(stepEquals(step4, step4)).is.true;
|
|
67
|
-
expect(stepEquals(step4, step5)).is.true;
|
|
68
|
-
expect(stepEquals(step1, step2)).is.false;
|
|
69
|
-
expect(stepEquals(step1, step3)).is.false;
|
|
70
|
-
expect(stepEquals(step1, step4)).is.false;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('from / to JSON', () => {
|
|
74
|
-
|
|
75
|
-
const step1Json = stepToJson(step1);
|
|
76
|
-
expect(step1Json).be.an('object');
|
|
77
|
-
const step1Bis = jsonToStep(step1Json);
|
|
78
|
-
expect(stepEquals(step1, step1Bis)).is.true;
|
|
79
|
-
|
|
80
|
-
const step2Json = stepToJson(step2);
|
|
81
|
-
expect(step2Json).be.an('object');
|
|
82
|
-
const step2Bis = jsonToStep(step2Json);
|
|
83
|
-
expect(stepEquals(step2, step2Bis)).is.true;
|
|
84
|
-
|
|
85
|
-
const step3Json = stepToJson(step3);
|
|
86
|
-
expect(step3Json).be.an('object');
|
|
87
|
-
const step3Bis = jsonToStep(step3Json);
|
|
88
|
-
expect(stepEquals(step3, step3Bis)).is.true;
|
|
89
|
-
|
|
90
|
-
const step4Json = stepToJson(step4);
|
|
91
|
-
expect(step4Json).be.an('object');
|
|
92
|
-
const step4Bis = jsonToStep(step4Json);
|
|
93
|
-
expect(stepEquals(step4, step4Bis)).is.true;
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
export { step1, step2, step3, step4 };
|
package/src/model/Step.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Coordinates, CoordinatesCompressedJson } from '@wemap/geo';
|
|
2
|
-
|
|
3
|
-
import { LevelChange } from './LevelChange.js';
|
|
4
|
-
import { StepExtra } from './StepExtra.js';
|
|
5
|
-
|
|
6
|
-
export type Step = {
|
|
7
|
-
|
|
8
|
-
firstStep: boolean;
|
|
9
|
-
lastStep: boolean;
|
|
10
|
-
number: number;
|
|
11
|
-
|
|
12
|
-
angle: number;
|
|
13
|
-
previousBearing: number;
|
|
14
|
-
nextBearing: number;
|
|
15
|
-
distance: number;
|
|
16
|
-
duration: number;
|
|
17
|
-
|
|
18
|
-
readonly coords: Coordinates;
|
|
19
|
-
readonly name: string | null;
|
|
20
|
-
readonly levelChange: LevelChange | null;
|
|
21
|
-
readonly extras: StepExtra | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type StepJson = {
|
|
25
|
-
firstStep?: boolean,
|
|
26
|
-
lastStep?: boolean
|
|
27
|
-
number: number,
|
|
28
|
-
coords: CoordinatesCompressedJson,
|
|
29
|
-
name?: string,
|
|
30
|
-
angle: number,
|
|
31
|
-
previousBearing: number,
|
|
32
|
-
nextBearing: number,
|
|
33
|
-
distance: number,
|
|
34
|
-
duration: number
|
|
35
|
-
levelChange?: LevelChange
|
|
36
|
-
extras?: StepExtra,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type MinStepInfo = {
|
|
40
|
-
coords: Coordinates,
|
|
41
|
-
name?: string,
|
|
42
|
-
levelChange?: LevelChange
|
|
43
|
-
extras?: StepExtra,
|
|
44
|
-
distance?: number,
|
|
45
|
-
duration?: number
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export function stepToJson(step: Step): StepJson {
|
|
49
|
-
return {
|
|
50
|
-
...(step.firstStep && { firstStep: true }),
|
|
51
|
-
...(step.lastStep && { lastStep: true }),
|
|
52
|
-
number: step.number,
|
|
53
|
-
coords: step.coords.toCompressedJson(),
|
|
54
|
-
...(step.name !== null && { name: step.name }),
|
|
55
|
-
angle: Number(step.angle.toFixed(2)),
|
|
56
|
-
previousBearing: Number(step.previousBearing.toFixed(2)),
|
|
57
|
-
nextBearing: Number(step.nextBearing.toFixed(2)),
|
|
58
|
-
distance: Number(step.distance.toFixed(1)),
|
|
59
|
-
duration: Number(step.duration.toFixed(1)),
|
|
60
|
-
...(step.levelChange !== null && { levelChange: step.levelChange }),
|
|
61
|
-
...(step.extras && Object.keys(step.extras).length !== 0 && { extras: step.extras }),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function jsonToStep(json: StepJson): Step {
|
|
66
|
-
return Object.assign({}, json, {
|
|
67
|
-
coords: Coordinates.fromCompressedJson(json.coords),
|
|
68
|
-
firstStep: Boolean(json.firstStep),
|
|
69
|
-
lastStep: Boolean(json.lastStep),
|
|
70
|
-
name: json.name || null,
|
|
71
|
-
levelChange: json.levelChange || null,
|
|
72
|
-
extras: json.extras || null
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function stepEquals(step1: Step, step2: Step) {
|
|
77
|
-
return step1.coords.equals(step2.coords)
|
|
78
|
-
&& Math.abs(step1.angle - step2.angle) <= 0.005
|
|
79
|
-
&& Math.abs(step1.distance - step2.distance) <= 0.05
|
|
80
|
-
&& Math.abs(step1.duration - step2.duration) <= 0.05
|
|
81
|
-
&& step1.firstStep === step2.firstStep
|
|
82
|
-
&& step1.lastStep === step2.lastStep
|
|
83
|
-
&& step1.levelChange?.difference === step2.levelChange?.difference
|
|
84
|
-
&& step1.levelChange?.direction === step2.levelChange?.direction
|
|
85
|
-
&& step1.levelChange?.type === step2.levelChange?.type
|
|
86
|
-
&& step1.name === step2.name
|
|
87
|
-
&& Math.abs(step1.nextBearing - step2.nextBearing) <= 0.005
|
|
88
|
-
&& step1.number === step2.number
|
|
89
|
-
&& Math.abs(step1.previousBearing - step2.previousBearing) <= 0.005
|
|
90
|
-
}
|
package/src/model/StepExtra.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type StepExtra = { [key: string]: number | string | boolean | null }
|