@wemap/routers 13.1.1 → 13.2.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/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -7
- package/dist/index.mjs.map +1 -1
- package/dist/src/graph/Edge.d.ts +1 -1
- package/dist/src/model/RouterRequest.d.ts +2 -0
- package/dist/src/remote/RemoteRouterManager.d.ts +3 -7
- package/dist/src/remote/tictactrip/TictactripRemoteRouter.d.ts +4 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2392,7 +2392,9 @@ const SURFACE_FACTORS = {
|
|
|
2392
2392
|
asphalt: 1,
|
|
2393
2393
|
// Smooth, ideal surface
|
|
2394
2394
|
concrete: 1,
|
|
2395
|
-
// Equally good as asphalt
|
|
2395
|
+
// Equally good as asphalt, but slightly slower
|
|
2396
|
+
paved: 1,
|
|
2397
|
+
// Paved surface - ideal for wheelchairs
|
|
2396
2398
|
paving_stones: 0.8,
|
|
2397
2399
|
// Slightly slower due to joints/gaps
|
|
2398
2400
|
compacted: 0.7,
|
|
@@ -2413,6 +2415,8 @@ const SURFACE_FACTORS = {
|
|
|
2413
2415
|
// Ideal walking surface
|
|
2414
2416
|
concrete: 1,
|
|
2415
2417
|
// Equally good as asphalt
|
|
2418
|
+
paved: 1,
|
|
2419
|
+
// Paved surface - ideal for wheelchairs
|
|
2416
2420
|
paving_stones: 0.9,
|
|
2417
2421
|
// Slightly slower but good for walking
|
|
2418
2422
|
compacted: 0.8,
|
|
@@ -3123,6 +3127,10 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
3123
3127
|
const toPlace = `ArrivalLatitude=${destination.latitude}&ArrivalLongitude=${destination.longitude}`;
|
|
3124
3128
|
const queryMode = `TripModes=${citywayMode}`;
|
|
3125
3129
|
const url = new URL(endpointUrl);
|
|
3130
|
+
if (routerRequest.departureTime) {
|
|
3131
|
+
url.searchParams.set("Date", routerRequest.departureTime);
|
|
3132
|
+
url.searchParams.set("TypeDate", "Departure");
|
|
3133
|
+
}
|
|
3126
3134
|
let { search } = url;
|
|
3127
3135
|
search = (search ? `${search}&` : "?") + `${fromPlace}&${toPlace}&${queryMode}`;
|
|
3128
3136
|
return `${url.origin}${url.pathname}${search}`;
|
|
@@ -3917,6 +3925,10 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
3917
3925
|
if ((_a = routerRequest.itineraryModifiers) == null ? void 0 : _a.isWheelchair) {
|
|
3918
3926
|
coreParams.set("wheelchair", "true");
|
|
3919
3927
|
}
|
|
3928
|
+
if (routerRequest.departureTime) {
|
|
3929
|
+
coreParams.set("datetime", routerRequest.departureTime);
|
|
3930
|
+
coreParams.set("datetime_represents", "departure");
|
|
3931
|
+
}
|
|
3920
3932
|
let queryParams = new URLSearchParams();
|
|
3921
3933
|
switch (travelMode) {
|
|
3922
3934
|
case "WALK":
|
|
@@ -4535,6 +4547,7 @@ class WemapMultiRemoteRouter extends RemoteRouter {
|
|
|
4535
4547
|
}
|
|
4536
4548
|
}
|
|
4537
4549
|
const WemapMultiRemoteRouter$1 = new WemapMultiRemoteRouter();
|
|
4550
|
+
const OsrmEndpointUrl = "https://routing-osrm.getwemap.com";
|
|
4538
4551
|
class TictactripRemoteRouter extends RemoteRouter {
|
|
4539
4552
|
/**
|
|
4540
4553
|
* @override
|
|
@@ -4542,6 +4555,38 @@ class TictactripRemoteRouter extends RemoteRouter {
|
|
|
4542
4555
|
get rname() {
|
|
4543
4556
|
return "tictactrip";
|
|
4544
4557
|
}
|
|
4558
|
+
async getSegmentItinerary(origin, destination) {
|
|
4559
|
+
const duration = getDurationFromLength(origin.distanceTo(destination));
|
|
4560
|
+
if (duration < 5 * 60) {
|
|
4561
|
+
return null;
|
|
4562
|
+
}
|
|
4563
|
+
let itinerary = null;
|
|
4564
|
+
if (duration < 30 * 60) {
|
|
4565
|
+
itinerary = (await OsrmRemoteRouter$1.getItineraries(OsrmEndpointUrl, {
|
|
4566
|
+
origin,
|
|
4567
|
+
destination,
|
|
4568
|
+
travelMode: "WALK",
|
|
4569
|
+
provideItineraryAlternatives: false,
|
|
4570
|
+
optimizeWaypoints: false
|
|
4571
|
+
}))[0];
|
|
4572
|
+
} else {
|
|
4573
|
+
itinerary = (await OsrmRemoteRouter$1.getItineraries(OsrmEndpointUrl, {
|
|
4574
|
+
origin,
|
|
4575
|
+
destination,
|
|
4576
|
+
travelMode: "CAR",
|
|
4577
|
+
provideItineraryAlternatives: false,
|
|
4578
|
+
optimizeWaypoints: false
|
|
4579
|
+
}))[0];
|
|
4580
|
+
}
|
|
4581
|
+
return itinerary;
|
|
4582
|
+
}
|
|
4583
|
+
getItineraryFromStation(origin, destination) {
|
|
4584
|
+
return OsrmRemoteRouter$1.getItineraries(OsrmEndpointUrl, {
|
|
4585
|
+
origin,
|
|
4586
|
+
destination,
|
|
4587
|
+
travelMode: "WALK"
|
|
4588
|
+
});
|
|
4589
|
+
}
|
|
4545
4590
|
async getItineraries(endpointUrl, routerRequest) {
|
|
4546
4591
|
const bodyParams = this.getBodyParams(routerRequest);
|
|
4547
4592
|
const url = new URL(endpointUrl);
|
|
@@ -4557,7 +4602,7 @@ class TictactripRemoteRouter extends RemoteRouter {
|
|
|
4557
4602
|
const jsonResponse = await res.json().catch(() => {
|
|
4558
4603
|
throw RemoteRoutingError.responseNotParsing(this.rname, url.toString());
|
|
4559
4604
|
});
|
|
4560
|
-
const itineraries = this.parseResponse(jsonResponse);
|
|
4605
|
+
const itineraries = await this.parseResponse(jsonResponse, routerRequest);
|
|
4561
4606
|
return itineraries;
|
|
4562
4607
|
}
|
|
4563
4608
|
getBodyParams(routerRequest) {
|
|
@@ -4571,14 +4616,15 @@ class TictactripRemoteRouter extends RemoteRouter {
|
|
|
4571
4616
|
latitude: destination.lat,
|
|
4572
4617
|
longitude: destination.lng
|
|
4573
4618
|
},
|
|
4574
|
-
outbound_date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4619
|
+
outbound_date: routerRequest.departureTime || (/* @__PURE__ */ new Date()).toISOString(),
|
|
4575
4620
|
passengers: [{ age: 30 }]
|
|
4576
4621
|
};
|
|
4577
4622
|
}
|
|
4578
|
-
parseResponse(json) {
|
|
4623
|
+
async parseResponse(json, routerRequest) {
|
|
4579
4624
|
if (!json || !json.trips)
|
|
4580
4625
|
return [];
|
|
4581
|
-
return Object.values(json.trips).map((trip) => {
|
|
4626
|
+
return await Promise.all(Object.values(json.trips).filter((trip) => trip.transportType === "TRAIN").map(async (trip) => {
|
|
4627
|
+
var _a, _b;
|
|
4582
4628
|
const legs = trip.segments.map((segment) => {
|
|
4583
4629
|
const transitMode = StringUtils.toUpperCase(segment.transportType);
|
|
4584
4630
|
const startSection = new Coordinates(segment.origin.latitude, segment.origin.longitude);
|
|
@@ -4619,15 +4665,39 @@ class TictactripRemoteRouter extends RemoteRouter {
|
|
|
4619
4665
|
steps: stepsBuilder.build()
|
|
4620
4666
|
});
|
|
4621
4667
|
});
|
|
4668
|
+
let startItinerary = null;
|
|
4669
|
+
let endItinerary = null;
|
|
4670
|
+
const mergedLegs = [];
|
|
4671
|
+
const firstStation = (_a = trip.segments[0]) == null ? void 0 : _a.origin;
|
|
4672
|
+
if (firstStation) {
|
|
4673
|
+
const firstStationCoords = new Coordinates(firstStation.latitude, firstStation.longitude);
|
|
4674
|
+
const origin = routerRequest.origin;
|
|
4675
|
+
startItinerary = await this.getSegmentItinerary(origin, firstStationCoords).catch(() => null);
|
|
4676
|
+
if (startItinerary) {
|
|
4677
|
+
startItinerary.legs[0].start.name = firstStation.name;
|
|
4678
|
+
mergedLegs.push(...startItinerary.legs);
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
mergedLegs.push(...legs);
|
|
4682
|
+
const lastStation = (_b = trip.segments[trip.segments.length - 1]) == null ? void 0 : _b.destination;
|
|
4683
|
+
if (lastStation) {
|
|
4684
|
+
const lastStationCoords = new Coordinates(lastStation.latitude, lastStation.longitude);
|
|
4685
|
+
const destination = routerRequest.destination;
|
|
4686
|
+
endItinerary = await this.getSegmentItinerary(lastStationCoords, destination).catch(() => null);
|
|
4687
|
+
if (endItinerary) {
|
|
4688
|
+
endItinerary.legs[endItinerary.legs.length - 1].end.name = lastStation.name;
|
|
4689
|
+
mergedLegs.push(...endItinerary.legs);
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4622
4692
|
return new Itinerary({
|
|
4623
4693
|
origin: new Coordinates(trip.origin.latitude, trip.origin.longitude),
|
|
4624
4694
|
destination: new Coordinates(trip.destination.latitude, trip.destination.longitude),
|
|
4625
4695
|
duration: trip.durationMinutes * 60,
|
|
4626
4696
|
startTime: new Date(trip.departureLocalISO).getTime(),
|
|
4627
4697
|
endTime: new Date(trip.arrivalLocalISO).getTime(),
|
|
4628
|
-
legs
|
|
4698
|
+
legs: mergedLegs
|
|
4629
4699
|
});
|
|
4630
|
-
});
|
|
4700
|
+
}));
|
|
4631
4701
|
}
|
|
4632
4702
|
}
|
|
4633
4703
|
const TictactripRemoteRouter$1 = new TictactripRemoteRouter();
|