@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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create and return a date with a given timezone
|
|
3
|
+
* timeZone - timezone name (e.g. 'Europe/Paris')
|
|
4
|
+
*/
|
|
5
|
+
export declare function dateWithTimeZone(year: number, month: number, day: number, hour: number, minute: number, second: number, timeZone?: string): Date;
|
|
6
|
+
export declare function isRoutingError(e: unknown): e is Error;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
2
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
3
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
4
|
+
type CitywayCoordinates = {
|
|
5
|
+
Lat: number;
|
|
6
|
+
Long: number;
|
|
7
|
+
};
|
|
8
|
+
type CitywayLeg = {
|
|
9
|
+
TransportMode: string;
|
|
10
|
+
Duration: string;
|
|
11
|
+
Departure: {
|
|
12
|
+
Time: string;
|
|
13
|
+
Site: {
|
|
14
|
+
Name: string;
|
|
15
|
+
Position: CitywayCoordinates;
|
|
16
|
+
};
|
|
17
|
+
StopPlace: {
|
|
18
|
+
Name: string;
|
|
19
|
+
Position: CitywayCoordinates;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
Arrival: {
|
|
23
|
+
Time: string;
|
|
24
|
+
Site: {
|
|
25
|
+
Name: string;
|
|
26
|
+
Position: CitywayCoordinates;
|
|
27
|
+
};
|
|
28
|
+
StopPlace: {
|
|
29
|
+
Name: string;
|
|
30
|
+
Position: CitywayCoordinates;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
Line: {
|
|
34
|
+
Name: string;
|
|
35
|
+
Number: string;
|
|
36
|
+
Color: string;
|
|
37
|
+
TextColor: string;
|
|
38
|
+
};
|
|
39
|
+
Destination: string;
|
|
40
|
+
Distance: number;
|
|
41
|
+
steps: {
|
|
42
|
+
Step: {
|
|
43
|
+
Geometry: string;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
pathLinks: {
|
|
47
|
+
PathLink: {
|
|
48
|
+
Departure: {
|
|
49
|
+
Site: {
|
|
50
|
+
Name: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
Distance: number;
|
|
54
|
+
Geometry: string | 'Null';
|
|
55
|
+
}[];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
type CitywayJson = {
|
|
59
|
+
StatusCode: number;
|
|
60
|
+
Message: string;
|
|
61
|
+
Data: {
|
|
62
|
+
response: {
|
|
63
|
+
trips: {
|
|
64
|
+
Trip: {
|
|
65
|
+
Duration: string;
|
|
66
|
+
Departure: {
|
|
67
|
+
Time: string;
|
|
68
|
+
Site: {
|
|
69
|
+
Position: CitywayCoordinates;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
Arrival: {
|
|
73
|
+
Time: string;
|
|
74
|
+
Site: {
|
|
75
|
+
Position: CitywayCoordinates;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
sections: {
|
|
79
|
+
Section: {
|
|
80
|
+
Leg?: CitywayLeg;
|
|
81
|
+
PTRide: CitywayLeg;
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
PlanTripType?: string;
|
|
88
|
+
}[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Singleton.
|
|
92
|
+
*/
|
|
93
|
+
declare class CitywayRemoteRouter extends RemoteRouter {
|
|
94
|
+
get rname(): "cityway";
|
|
95
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
96
|
+
getURL(endpointUrl: string, routerRequest: RouterRequest): string;
|
|
97
|
+
/**
|
|
98
|
+
* Generate multi itineraries from Cityway JSON
|
|
99
|
+
* @example https://preprod.api.lia2.cityway.fr/journeyplanner/api/opt/PlanTrips/json?DepartureLatitude=49.51509388236216&DepartureLongitude=0.09341749619366316&ArrivalLatitude=49.5067090188444&ArrivalLongitude=0.1694842115417831&DepartureType=COORDINATES&ArrivalType=COORDINATES
|
|
100
|
+
*/
|
|
101
|
+
parseResponse(json: CitywayJson): Itinerary[];
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} iso8601Duration
|
|
104
|
+
* @see https://stackoverflow.com/a/29153059/2239938
|
|
105
|
+
*/
|
|
106
|
+
parseDuration(iso8601Duration: string): number;
|
|
107
|
+
}
|
|
108
|
+
declare const _default: CitywayRemoteRouter;
|
|
109
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Coordinates } from '@wemap/geo';
|
|
2
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
3
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
4
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
5
|
+
type DBJson = {
|
|
6
|
+
segments: {
|
|
7
|
+
fromLevel: number;
|
|
8
|
+
toLevel: number;
|
|
9
|
+
polyline: {
|
|
10
|
+
lat: number;
|
|
11
|
+
lon: number;
|
|
12
|
+
}[];
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Singleton.
|
|
17
|
+
*/
|
|
18
|
+
declare class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
19
|
+
/**
|
|
20
|
+
* @override
|
|
21
|
+
*/
|
|
22
|
+
get rname(): "deutsche-bahn";
|
|
23
|
+
/**
|
|
24
|
+
* @override
|
|
25
|
+
*/
|
|
26
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
27
|
+
getURL(endpointUrl: string, routerRequest: RouterRequest): string;
|
|
28
|
+
parseResponse(json: DBJson, origin: Coordinates, destination: Coordinates): Itinerary[];
|
|
29
|
+
}
|
|
30
|
+
declare const _default: DeutscheBahnRemoteRouter;
|
|
31
|
+
export default _default;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
2
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
3
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
4
|
+
type DistanceDetails = {
|
|
5
|
+
total: number;
|
|
6
|
+
normalRoads: number;
|
|
7
|
+
recommendedRoads: number;
|
|
8
|
+
discouragedRoads: number;
|
|
9
|
+
cycleway: number;
|
|
10
|
+
greenway: number;
|
|
11
|
+
lane: number;
|
|
12
|
+
livingstreet: number;
|
|
13
|
+
sharebusway: number;
|
|
14
|
+
footway: number;
|
|
15
|
+
pedestrian: number;
|
|
16
|
+
opposite: number;
|
|
17
|
+
steps: number;
|
|
18
|
+
zone30: number;
|
|
19
|
+
residential: number;
|
|
20
|
+
};
|
|
21
|
+
type Waypoint = {
|
|
22
|
+
longitude: number;
|
|
23
|
+
latitude: number;
|
|
24
|
+
title?: string | null;
|
|
25
|
+
};
|
|
26
|
+
type Instruction = Array<string | number>;
|
|
27
|
+
type SectionWithInstructions = {
|
|
28
|
+
transportMode: 'BIKE' | 'PEDESTRIAN';
|
|
29
|
+
duration: number;
|
|
30
|
+
waypointsIndices: number[] | null;
|
|
31
|
+
geometry: string;
|
|
32
|
+
estimatedDatetimeOfDeparture: string;
|
|
33
|
+
estimatedDatetimeOfArrival: string;
|
|
34
|
+
details: SectionDetails;
|
|
35
|
+
waypoints: Waypoint[];
|
|
36
|
+
};
|
|
37
|
+
type SectionDetails = {
|
|
38
|
+
distances: DistanceDetails;
|
|
39
|
+
instructions: Instruction[];
|
|
40
|
+
profile: string;
|
|
41
|
+
direction: string;
|
|
42
|
+
verticalGain: number;
|
|
43
|
+
verticalLoss: number;
|
|
44
|
+
calories: number;
|
|
45
|
+
elevations: string | null;
|
|
46
|
+
ridesets: any[];
|
|
47
|
+
averageSpeed: number;
|
|
48
|
+
bikeType: string;
|
|
49
|
+
};
|
|
50
|
+
type Route = {
|
|
51
|
+
sections: SectionWithInstructions[];
|
|
52
|
+
distances: {
|
|
53
|
+
total: number;
|
|
54
|
+
normalRoads: number;
|
|
55
|
+
recommendedRoads: number;
|
|
56
|
+
discouragedRoads: number;
|
|
57
|
+
};
|
|
58
|
+
title: string;
|
|
59
|
+
waypoints: Waypoint[];
|
|
60
|
+
estimatedDatetimeOfDeparture: string;
|
|
61
|
+
estimatedDatetimeOfArrival: string;
|
|
62
|
+
duration: number;
|
|
63
|
+
id: string;
|
|
64
|
+
};
|
|
65
|
+
type Routes = Route[];
|
|
66
|
+
type QueryParams = {
|
|
67
|
+
instructions: boolean;
|
|
68
|
+
elevations: boolean;
|
|
69
|
+
geometry: boolean;
|
|
70
|
+
single_result: boolean;
|
|
71
|
+
bike_stations: boolean;
|
|
72
|
+
objects_as_ids: boolean;
|
|
73
|
+
merge_instructions: boolean;
|
|
74
|
+
show_pushing_bike_instructions: boolean;
|
|
75
|
+
};
|
|
76
|
+
type RequestBodyParams = {
|
|
77
|
+
datetimeOfDeparture?: string;
|
|
78
|
+
datetimeOfArrival?: string;
|
|
79
|
+
bikeDetails?: {
|
|
80
|
+
profile: string;
|
|
81
|
+
bikeType: string;
|
|
82
|
+
averageSpeed: number;
|
|
83
|
+
eBike: boolean;
|
|
84
|
+
bikeStations: Array<{
|
|
85
|
+
from: number;
|
|
86
|
+
to: number;
|
|
87
|
+
}>;
|
|
88
|
+
};
|
|
89
|
+
transportModes: Array<'BIKE' | 'PEDESTRIAN'>;
|
|
90
|
+
waypoints: Waypoint[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Singleton.
|
|
94
|
+
*/
|
|
95
|
+
declare class GeoveloRemoteRouter extends RemoteRouter {
|
|
96
|
+
/**
|
|
97
|
+
* @override
|
|
98
|
+
*/
|
|
99
|
+
get rname(): "geovelo";
|
|
100
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
101
|
+
getQueryParams(): QueryParams;
|
|
102
|
+
getBodyParams(routerRequest: RouterRequest): RequestBodyParams;
|
|
103
|
+
parseResponse(json: Routes): Itinerary[];
|
|
104
|
+
}
|
|
105
|
+
declare const _default: GeoveloRemoteRouter;
|
|
106
|
+
export default _default;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Coordinates } from '@wemap/geo';
|
|
2
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
3
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
4
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
5
|
+
type IdfmCoordinates = {
|
|
6
|
+
lat: number | string;
|
|
7
|
+
lon: number | string;
|
|
8
|
+
};
|
|
9
|
+
type IdfmPath = {
|
|
10
|
+
name: string;
|
|
11
|
+
length: number;
|
|
12
|
+
} & ({
|
|
13
|
+
instruction_start_coordinate: IdfmCoordinates;
|
|
14
|
+
} | {
|
|
15
|
+
via_uri: string;
|
|
16
|
+
});
|
|
17
|
+
type IdfmWaypoint = {
|
|
18
|
+
name: string;
|
|
19
|
+
} & ({
|
|
20
|
+
stop_point: {
|
|
21
|
+
coord: IdfmCoordinates;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
address: {
|
|
25
|
+
coord: IdfmCoordinates;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
poi: {
|
|
29
|
+
coord: IdfmCoordinates;
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
type IdfmSection = {
|
|
33
|
+
id: string;
|
|
34
|
+
type: 'waiting' | 'transfer' | string;
|
|
35
|
+
mode: string;
|
|
36
|
+
departure_date_time: string;
|
|
37
|
+
arrival_date_time: string;
|
|
38
|
+
duration: number;
|
|
39
|
+
geojson: {
|
|
40
|
+
coordinates: [number, number][];
|
|
41
|
+
properties: {
|
|
42
|
+
length: number;
|
|
43
|
+
}[];
|
|
44
|
+
};
|
|
45
|
+
path: IdfmPath[];
|
|
46
|
+
display_informations: {
|
|
47
|
+
code: string;
|
|
48
|
+
color: string;
|
|
49
|
+
text_color: string;
|
|
50
|
+
direction: string;
|
|
51
|
+
physical_mode: string;
|
|
52
|
+
};
|
|
53
|
+
from: IdfmWaypoint;
|
|
54
|
+
to: IdfmWaypoint;
|
|
55
|
+
vias?: {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
access_point: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
coord: {
|
|
62
|
+
lon: string;
|
|
63
|
+
lat: string;
|
|
64
|
+
};
|
|
65
|
+
embedded_type: string;
|
|
66
|
+
};
|
|
67
|
+
is_entrance: boolean;
|
|
68
|
+
is_exit: boolean;
|
|
69
|
+
length: number;
|
|
70
|
+
traversal_time: number;
|
|
71
|
+
pathway_mode: number;
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
74
|
+
type IdfmJson = {
|
|
75
|
+
journeys: {
|
|
76
|
+
duration: number;
|
|
77
|
+
departure_date_time: string;
|
|
78
|
+
arrival_date_time: string;
|
|
79
|
+
sections: IdfmSection[];
|
|
80
|
+
}[];
|
|
81
|
+
context: {
|
|
82
|
+
timezone: string;
|
|
83
|
+
};
|
|
84
|
+
error: {
|
|
85
|
+
message?: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
type IdfmIntermediateStep = {
|
|
89
|
+
name: string;
|
|
90
|
+
distance: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Singleton.
|
|
94
|
+
*/
|
|
95
|
+
declare class IdfmRemoteRouter extends RemoteRouter {
|
|
96
|
+
/**
|
|
97
|
+
* @override
|
|
98
|
+
*/
|
|
99
|
+
get rname(): "idfm";
|
|
100
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
101
|
+
getURL(endpointUrl: string, routerRequest: RouterRequest): string;
|
|
102
|
+
getCarQuery(): URLSearchParams;
|
|
103
|
+
getWalkingQuery(): URLSearchParams;
|
|
104
|
+
getBikeQuery(): URLSearchParams;
|
|
105
|
+
getSectionCoords(section: IdfmSection): {
|
|
106
|
+
from: Coordinates;
|
|
107
|
+
to: Coordinates;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Since the IDFM API does not provide coords for each step, we need to compute them
|
|
111
|
+
* We trim the coordinates of the leg with the distance of each step and keep the last result as the coords of the step
|
|
112
|
+
* @param {Leg} leg
|
|
113
|
+
*/
|
|
114
|
+
findStepsCoord(legCoords: Coordinates[], steps: IdfmIntermediateStep[]): {
|
|
115
|
+
coords: Coordinates;
|
|
116
|
+
name: string;
|
|
117
|
+
distance: number;
|
|
118
|
+
}[];
|
|
119
|
+
findStepCoords(step: IdfmSection['path'][number], section: IdfmSection): Coordinates | undefined;
|
|
120
|
+
parseResponse(json: IdfmJson): Itinerary[];
|
|
121
|
+
}
|
|
122
|
+
declare const _default: IdfmRemoteRouter;
|
|
123
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Coordinates } from '@wemap/geo';
|
|
2
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
3
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
4
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
5
|
+
import { NavitiaJson, NavitiaSection, NavitiaIntermediateStep } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Singleton.
|
|
8
|
+
*/
|
|
9
|
+
declare class NavitiaRemoteRouter extends RemoteRouter {
|
|
10
|
+
get rname(): "navitia";
|
|
11
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
12
|
+
getURL(endpointUrl: string, routerRequest: RouterRequest): URL;
|
|
13
|
+
getCarQuery(): URLSearchParams;
|
|
14
|
+
getWalkingQuery(): URLSearchParams;
|
|
15
|
+
getBikeQuery(): URLSearchParams;
|
|
16
|
+
getSectionCoords(section: NavitiaSection): {
|
|
17
|
+
from: Coordinates;
|
|
18
|
+
to: Coordinates;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Since the navitia API does not provide coords for each step, we need to compute them
|
|
22
|
+
* We trim the coordinates of the leg with the distance of each step and keep the last result as the coords of the step
|
|
23
|
+
* @param {Leg} leg
|
|
24
|
+
*/
|
|
25
|
+
findStepsCoord(legCoords: Coordinates[], steps: NavitiaIntermediateStep[]): {
|
|
26
|
+
coords: Coordinates;
|
|
27
|
+
name: string;
|
|
28
|
+
distance: number;
|
|
29
|
+
}[];
|
|
30
|
+
findStepCoords(step: NavitiaSection['path'][number], section: NavitiaSection): Coordinates | undefined;
|
|
31
|
+
parseResponse(json: NavitiaJson): Itinerary[];
|
|
32
|
+
}
|
|
33
|
+
declare const _default: NavitiaRemoteRouter;
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type NavitiaCoordinates = {
|
|
2
|
+
lat: number | string;
|
|
3
|
+
lon: number | string;
|
|
4
|
+
};
|
|
5
|
+
export type NavitiaPath = {
|
|
6
|
+
name: string;
|
|
7
|
+
length: number;
|
|
8
|
+
} & ({
|
|
9
|
+
instruction_start_coordinate: NavitiaCoordinates;
|
|
10
|
+
} | {
|
|
11
|
+
via_uri: string;
|
|
12
|
+
});
|
|
13
|
+
export type NavitiaWaypoint = {
|
|
14
|
+
name: string;
|
|
15
|
+
} & ({
|
|
16
|
+
stop_point: {
|
|
17
|
+
coord: NavitiaCoordinates;
|
|
18
|
+
};
|
|
19
|
+
} | {
|
|
20
|
+
address: {
|
|
21
|
+
coord: NavitiaCoordinates;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
poi: {
|
|
25
|
+
coord: NavitiaCoordinates;
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
export type NavitiaSection = {
|
|
29
|
+
id: string;
|
|
30
|
+
type: 'waiting' | 'transfer' | string;
|
|
31
|
+
mode: string;
|
|
32
|
+
departure_date_time: string;
|
|
33
|
+
arrival_date_time: string;
|
|
34
|
+
duration: number;
|
|
35
|
+
geojson: {
|
|
36
|
+
coordinates: [number, number][];
|
|
37
|
+
properties: {
|
|
38
|
+
length: number;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
path: NavitiaPath[];
|
|
42
|
+
display_informations: {
|
|
43
|
+
code: string;
|
|
44
|
+
color: string;
|
|
45
|
+
text_color: string;
|
|
46
|
+
direction: string;
|
|
47
|
+
physical_mode: string;
|
|
48
|
+
};
|
|
49
|
+
from: NavitiaWaypoint;
|
|
50
|
+
to: NavitiaWaypoint;
|
|
51
|
+
vias?: {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
access_point: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
coord: {
|
|
58
|
+
lon: string;
|
|
59
|
+
lat: string;
|
|
60
|
+
};
|
|
61
|
+
embedded_type: string;
|
|
62
|
+
};
|
|
63
|
+
is_entrance: boolean;
|
|
64
|
+
is_exit: boolean;
|
|
65
|
+
length: number;
|
|
66
|
+
traversal_time: number;
|
|
67
|
+
pathway_mode: number;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
export type NavitiaJson = {
|
|
71
|
+
journeys: {
|
|
72
|
+
duration: number;
|
|
73
|
+
departure_date_time: string;
|
|
74
|
+
arrival_date_time: string;
|
|
75
|
+
sections: NavitiaSection[];
|
|
76
|
+
}[];
|
|
77
|
+
context: {
|
|
78
|
+
timezone: string;
|
|
79
|
+
};
|
|
80
|
+
error: {
|
|
81
|
+
message?: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type NavitiaIntermediateStep = {
|
|
85
|
+
name: string;
|
|
86
|
+
distance: number;
|
|
87
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Coordinates } from '@wemap/geo';
|
|
2
|
+
import { LineString, Position } from 'geojson';
|
|
3
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
4
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
5
|
+
import { TravelMode } from '../../model/TravelMode.js';
|
|
6
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
7
|
+
type OsrmCoordinates = Position;
|
|
8
|
+
type OsrmModifier = 'sharp right' | 'sharp left' | 'slight right' | 'slight left' | 'right' | 'left' | 'u turn' | 'straight';
|
|
9
|
+
type OsrmManeuverType = 'depart' | 'turn' | 'arrive';
|
|
10
|
+
type OsrmStep = {
|
|
11
|
+
geometry: LineString;
|
|
12
|
+
distance: number;
|
|
13
|
+
duration: number;
|
|
14
|
+
name?: string;
|
|
15
|
+
maneuver: {
|
|
16
|
+
bearing_before: number;
|
|
17
|
+
bearing_after: number;
|
|
18
|
+
location: OsrmCoordinates;
|
|
19
|
+
modifier: OsrmModifier;
|
|
20
|
+
type: OsrmManeuverType;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type OsrmJson = {
|
|
24
|
+
code?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
routes?: {
|
|
27
|
+
geometry: LineString;
|
|
28
|
+
legs: {
|
|
29
|
+
distance: number;
|
|
30
|
+
duration: number;
|
|
31
|
+
steps: OsrmStep[];
|
|
32
|
+
}[];
|
|
33
|
+
distance: number;
|
|
34
|
+
duration: number;
|
|
35
|
+
weight_name: string;
|
|
36
|
+
weight: number;
|
|
37
|
+
}[];
|
|
38
|
+
waypoints?: [];
|
|
39
|
+
};
|
|
40
|
+
type OsrmMode = 'driving' | 'walking' | 'bike' | 'pmr' | 'bike-safest' | 'bike-fastest';
|
|
41
|
+
/**
|
|
42
|
+
* Singleton.
|
|
43
|
+
*/
|
|
44
|
+
declare class OsrmRemoteRouter extends RemoteRouter {
|
|
45
|
+
get rname(): "osrm";
|
|
46
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
47
|
+
/**
|
|
48
|
+
* @throws {TravelModeCorrespondanceNotFound}
|
|
49
|
+
*/
|
|
50
|
+
getURL(endpointUrl: string, routerRequest: RouterRequest): string;
|
|
51
|
+
inputModeCorrespondance: (routerRequest: RouterRequest) => OsrmMode;
|
|
52
|
+
coordinatesToJson({ lat, lng, level }: Coordinates): OsrmCoordinates;
|
|
53
|
+
/**
|
|
54
|
+
* @param {object} json
|
|
55
|
+
* @returns {Coordinates}
|
|
56
|
+
*/
|
|
57
|
+
jsonToCoordinates(json: OsrmCoordinates): Coordinates;
|
|
58
|
+
getModifierFromAngle(_angle: number): OsrmModifier;
|
|
59
|
+
noRouteFoundJson(message: object): {
|
|
60
|
+
code: string;
|
|
61
|
+
message: object;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
*/
|
|
66
|
+
itineraryToOsrmJson(itinerary: Itinerary): OsrmJson;
|
|
67
|
+
parseResponse(json: OsrmJson, origin: Coordinates, destination: Coordinates, travelMode: TravelMode): Itinerary[];
|
|
68
|
+
}
|
|
69
|
+
declare const _default: OsrmRemoteRouter;
|
|
70
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
2
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
3
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
4
|
+
type OtpCoordinates = {
|
|
5
|
+
lat: number;
|
|
6
|
+
lon: number;
|
|
7
|
+
};
|
|
8
|
+
type FromTo = OtpCoordinates & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
type FromToPT = FromTo & {
|
|
12
|
+
stopId: string;
|
|
13
|
+
stopCode: string;
|
|
14
|
+
};
|
|
15
|
+
type CommonLeg = {
|
|
16
|
+
startTime: number;
|
|
17
|
+
endTime: number;
|
|
18
|
+
legGeometry: {
|
|
19
|
+
points: string;
|
|
20
|
+
length: number;
|
|
21
|
+
};
|
|
22
|
+
duration: number;
|
|
23
|
+
};
|
|
24
|
+
type LegWalk = CommonLeg & {
|
|
25
|
+
mode: 'WALK';
|
|
26
|
+
from: FromTo;
|
|
27
|
+
to: FromTo;
|
|
28
|
+
steps: (OtpCoordinates & {
|
|
29
|
+
distance: number;
|
|
30
|
+
streetName: string;
|
|
31
|
+
})[];
|
|
32
|
+
};
|
|
33
|
+
type LegPT = CommonLeg & {
|
|
34
|
+
mode: 'BUS' | 'TRAM';
|
|
35
|
+
from: FromToPT;
|
|
36
|
+
to: FromToPT;
|
|
37
|
+
intermediateStops: FromToPT;
|
|
38
|
+
routeShortName: 'string';
|
|
39
|
+
routeColor?: 'string';
|
|
40
|
+
routeTextColor?: 'string';
|
|
41
|
+
headsign: 'string';
|
|
42
|
+
};
|
|
43
|
+
type OtpJson = {
|
|
44
|
+
plan: {
|
|
45
|
+
from: FromTo;
|
|
46
|
+
to: FromTo;
|
|
47
|
+
itineraries: {
|
|
48
|
+
duration: number;
|
|
49
|
+
startTime: number;
|
|
50
|
+
endTime: number;
|
|
51
|
+
walkDistance: number;
|
|
52
|
+
legs: (LegWalk | LegPT)[];
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Singleton.
|
|
58
|
+
*/
|
|
59
|
+
declare class OtpRemoteRouter extends RemoteRouter {
|
|
60
|
+
get rname(): "otp";
|
|
61
|
+
getItineraries(endpointUrl: string, routerRequest: RouterRequest): Promise<Itinerary[]>;
|
|
62
|
+
getURL(endpointUrl: string, routerRequest: RouterRequest): string;
|
|
63
|
+
/**
|
|
64
|
+
* Generate multi itineraries from OTP JSON
|
|
65
|
+
*/
|
|
66
|
+
parseResponse(json: OtpJson): Itinerary[];
|
|
67
|
+
}
|
|
68
|
+
declare const _default: OtpRemoteRouter;
|
|
69
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Coordinates } from '@wemap/geo';
|
|
2
|
+
import { default as RemoteRouter } from '../RemoteRouter.js';
|
|
3
|
+
import { RouterRequest } from '../../model/RouterRequest.js';
|
|
4
|
+
import { default as Itinerary } from '../../model/Itinerary.js';
|
|
5
|
+
type WemapRouterRequest = Omit<RouterRequest, 'origin' | 'destination' | 'waypoints'> & {
|
|
6
|
+
mapId?: number;
|
|
7
|
+
origin: Coordinates | number | string;
|
|
8
|
+
destination: Coordinates | number | string;
|
|
9
|
+
waypoints?: (Coordinates | number | string)[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Singleton.
|
|
13
|
+
*/
|
|
14
|
+
declare class WemapMultiRemoteRouter extends RemoteRouter {
|
|
15
|
+
get rname(): "wemap-multi";
|
|
16
|
+
getItineraries(endpointUrl: string, routerRequest: WemapRouterRequest): Promise<Itinerary[]>;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: WemapMultiRemoteRouter;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CoordinatesCompressedJson } from '@wemap/geo';
|
|
2
|
+
import { EdgeProperties } from './graph/Edge.js';
|
|
3
|
+
import { VertexProperties } from './graph/Vertex.js';
|
|
4
|
+
export type GraphVertexJson = {
|
|
5
|
+
id: number;
|
|
6
|
+
coords: CoordinatesCompressedJson;
|
|
7
|
+
properties?: VertexProperties;
|
|
8
|
+
};
|
|
9
|
+
export type GraphEdgeJson = {
|
|
10
|
+
id: number;
|
|
11
|
+
vertex1Idx: number;
|
|
12
|
+
vertex2Idx: number;
|
|
13
|
+
properties?: EdgeProperties;
|
|
14
|
+
};
|
|
15
|
+
export type GeoGraphJson = {
|
|
16
|
+
vertices: GraphVertexJson[];
|
|
17
|
+
edges: GraphEdgeJson[];
|
|
18
|
+
};
|
|
19
|
+
export type CompressedGraphVertexJson = CoordinatesCompressedJson;
|
|
20
|
+
export type CompressedGeoGraphJson = {
|
|
21
|
+
vertices: CompressedGraphVertexJson[];
|
|
22
|
+
verticesIds: (string | number)[];
|
|
23
|
+
edges: ([
|
|
24
|
+
number,
|
|
25
|
+
number
|
|
26
|
+
] | [
|
|
27
|
+
number,
|
|
28
|
+
number,
|
|
29
|
+
EdgeProperties
|
|
30
|
+
])[];
|
|
31
|
+
};
|