@opentripplanner/core-utils 8.2.3 → 8.3.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/esm/query-gen.js +16 -5
- package/esm/query-gen.js.map +1 -1
- package/lib/query-gen.d.ts +7 -1
- package/lib/query-gen.d.ts.map +1 -1
- package/lib/query-gen.js +15 -5
- package/lib/query-gen.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/query-params.ts +20 -0
- package/src/otpSchema.json +12940 -0
- package/src/planQuery.graphql +109 -102
- package/src/query-gen.ts +27 -16
- package/tsconfig.tsbuildinfo +1 -1
package/src/planQuery.graphql
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
query
|
|
1
|
+
query Plan(
|
|
2
2
|
$fromPlace: String!
|
|
3
3
|
$toPlace: String!
|
|
4
4
|
$modes: [TransportMode]
|
|
@@ -16,161 +16,168 @@ query PlanQuery(
|
|
|
16
16
|
$numItineraries: Int
|
|
17
17
|
) {
|
|
18
18
|
plan(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
transportModes: $modes
|
|
22
|
-
# Currently only supporting EN locale, used for times and text
|
|
23
|
-
locale: "en"
|
|
24
|
-
time: $time
|
|
25
|
-
date: $date
|
|
26
|
-
wheelchair: $wheelchair
|
|
19
|
+
arriveBy: $arriveBy
|
|
20
|
+
banned: $banned
|
|
27
21
|
bikeReluctance: $bikeReluctance
|
|
28
22
|
carReluctance: $carReluctance
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
date: $date
|
|
24
|
+
fromPlace: $fromPlace
|
|
31
25
|
intermediatePlaces: $intermediatePlaces
|
|
26
|
+
# Currently only supporting EN locale, used for times and text
|
|
27
|
+
locale: "en"
|
|
28
|
+
numItineraries: $numItineraries
|
|
32
29
|
preferred: $preferred
|
|
30
|
+
time: $time
|
|
31
|
+
toPlace: $toPlace
|
|
32
|
+
transportModes: $modes
|
|
33
33
|
unpreferred: $unpreferred
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
walkReluctance: $walkReluctance
|
|
35
|
+
wheelchair: $wheelchair
|
|
36
36
|
) {
|
|
37
|
-
routingErrors {
|
|
38
|
-
code
|
|
39
|
-
inputField
|
|
40
|
-
description
|
|
41
|
-
}
|
|
42
37
|
itineraries {
|
|
38
|
+
accessibilityScore
|
|
43
39
|
duration
|
|
44
40
|
endTime
|
|
45
|
-
|
|
46
|
-
waitingTime
|
|
47
|
-
walkTime
|
|
48
|
-
accessibilityScore
|
|
49
|
-
legs {
|
|
50
|
-
pickupType
|
|
51
|
-
dropoffType
|
|
52
|
-
pickupBookingInfo {
|
|
53
|
-
earliestBookingTime {
|
|
54
|
-
daysPrior
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
rentedBike
|
|
58
|
-
interlineWithPreviousLeg
|
|
59
|
-
departureDelay
|
|
60
|
-
arrivalDelay
|
|
61
|
-
distance
|
|
62
|
-
duration
|
|
63
|
-
endTime
|
|
64
|
-
mode
|
|
65
|
-
realTime
|
|
66
|
-
realtimeState
|
|
67
|
-
startTime
|
|
68
|
-
transitLeg
|
|
41
|
+
legs {
|
|
69
42
|
accessibilityScore
|
|
70
|
-
trip {
|
|
71
|
-
id
|
|
72
|
-
gtfsId
|
|
73
|
-
tripHeadsign
|
|
74
|
-
}
|
|
75
43
|
agency {
|
|
76
|
-
name
|
|
77
|
-
id
|
|
78
|
-
timezone
|
|
79
|
-
url
|
|
80
44
|
alerts {
|
|
81
|
-
alertHeaderText
|
|
82
45
|
alertDescriptionText
|
|
46
|
+
alertHeaderText
|
|
83
47
|
alertUrl
|
|
84
48
|
effectiveStartDate
|
|
49
|
+
id
|
|
85
50
|
}
|
|
51
|
+
id
|
|
52
|
+
name
|
|
53
|
+
timezone
|
|
54
|
+
url
|
|
86
55
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
56
|
+
arrivalDelay
|
|
57
|
+
departureDelay
|
|
58
|
+
distance
|
|
59
|
+
dropoffType
|
|
60
|
+
duration
|
|
61
|
+
endTime
|
|
62
|
+
from {
|
|
63
|
+
lat
|
|
64
|
+
lon
|
|
65
|
+
name
|
|
66
|
+
rentalVehicle {
|
|
67
|
+
id
|
|
68
|
+
network
|
|
69
|
+
}
|
|
70
|
+
stop {
|
|
71
|
+
alerts {
|
|
72
|
+
alertDescriptionText
|
|
73
|
+
alertHeaderText
|
|
74
|
+
alertUrl
|
|
75
|
+
effectiveStartDate
|
|
76
|
+
id
|
|
77
|
+
}
|
|
78
|
+
code
|
|
79
|
+
gtfsId
|
|
80
|
+
id
|
|
81
|
+
}
|
|
82
|
+
vertexType
|
|
90
83
|
}
|
|
84
|
+
interlineWithPreviousLeg
|
|
91
85
|
intermediateStops {
|
|
92
86
|
lat
|
|
87
|
+
locationType
|
|
93
88
|
lon
|
|
94
89
|
name
|
|
95
90
|
stopCode: code
|
|
96
91
|
stopId: id
|
|
97
|
-
locationType
|
|
98
92
|
}
|
|
93
|
+
legGeometry {
|
|
94
|
+
length
|
|
95
|
+
points
|
|
96
|
+
}
|
|
97
|
+
mode
|
|
98
|
+
pickupBookingInfo {
|
|
99
|
+
earliestBookingTime {
|
|
100
|
+
daysPrior
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
pickupType
|
|
104
|
+
realTime
|
|
105
|
+
realtimeState
|
|
106
|
+
rentedBike
|
|
99
107
|
route {
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
alerts {
|
|
109
|
+
alertDescriptionText
|
|
110
|
+
alertHeaderText
|
|
111
|
+
alertUrl
|
|
112
|
+
effectiveStartDate
|
|
113
|
+
id
|
|
114
|
+
}
|
|
102
115
|
color
|
|
103
|
-
textColor
|
|
104
116
|
id
|
|
117
|
+
longName
|
|
118
|
+
shortName
|
|
119
|
+
textColor
|
|
105
120
|
type
|
|
121
|
+
}
|
|
122
|
+
startTime
|
|
123
|
+
steps {
|
|
124
|
+
absoluteDirection
|
|
106
125
|
alerts {
|
|
107
|
-
alertHeaderText
|
|
108
126
|
alertDescriptionText
|
|
127
|
+
alertHeaderText
|
|
109
128
|
alertUrl
|
|
110
129
|
effectiveStartDate
|
|
130
|
+
id
|
|
131
|
+
}
|
|
132
|
+
area
|
|
133
|
+
distance
|
|
134
|
+
elevationProfile {
|
|
135
|
+
distance
|
|
136
|
+
elevation
|
|
111
137
|
}
|
|
112
|
-
}
|
|
113
|
-
from {
|
|
114
138
|
lat
|
|
115
139
|
lon
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
network
|
|
120
|
-
}
|
|
121
|
-
stop {
|
|
122
|
-
id
|
|
123
|
-
code
|
|
124
|
-
gtfsId
|
|
125
|
-
alerts {
|
|
126
|
-
alertHeaderText
|
|
127
|
-
alertDescriptionText
|
|
128
|
-
alertUrl
|
|
129
|
-
effectiveStartDate
|
|
130
|
-
}
|
|
131
|
-
}
|
|
140
|
+
relativeDirection
|
|
141
|
+
stayOn
|
|
142
|
+
streetName
|
|
132
143
|
}
|
|
133
144
|
to {
|
|
134
145
|
lat
|
|
135
146
|
lon
|
|
136
147
|
name
|
|
137
|
-
vertexType
|
|
138
148
|
rentalVehicle {
|
|
149
|
+
id
|
|
139
150
|
network
|
|
140
151
|
}
|
|
141
152
|
stop {
|
|
142
|
-
id
|
|
143
|
-
code
|
|
144
|
-
gtfsId
|
|
145
153
|
alerts {
|
|
146
|
-
alertHeaderText
|
|
147
154
|
alertDescriptionText
|
|
155
|
+
alertHeaderText
|
|
148
156
|
alertUrl
|
|
149
157
|
effectiveStartDate
|
|
158
|
+
id
|
|
150
159
|
}
|
|
160
|
+
code
|
|
161
|
+
gtfsId
|
|
162
|
+
id
|
|
151
163
|
}
|
|
164
|
+
vertexType
|
|
152
165
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
absoluteDirection
|
|
159
|
-
stayOn
|
|
160
|
-
streetName
|
|
161
|
-
area
|
|
162
|
-
alerts {
|
|
163
|
-
alertHeaderText
|
|
164
|
-
alertDescriptionText
|
|
165
|
-
alertUrl
|
|
166
|
-
effectiveStartDate
|
|
167
|
-
}
|
|
168
|
-
elevationProfile {
|
|
169
|
-
distance
|
|
170
|
-
elevation
|
|
171
|
-
}
|
|
166
|
+
transitLeg
|
|
167
|
+
trip {
|
|
168
|
+
gtfsId
|
|
169
|
+
id
|
|
170
|
+
tripHeadsign
|
|
172
171
|
}
|
|
173
172
|
}
|
|
173
|
+
startTime
|
|
174
|
+
waitingTime
|
|
175
|
+
walkTime
|
|
176
|
+
}
|
|
177
|
+
routingErrors {
|
|
178
|
+
code
|
|
179
|
+
description
|
|
180
|
+
inputField
|
|
174
181
|
}
|
|
175
182
|
}
|
|
176
183
|
}
|
package/src/query-gen.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
TransportMode
|
|
7
7
|
} from "@opentripplanner/types";
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import DefaultPlanQuery from "./planQuery.graphql";
|
|
10
10
|
|
|
11
11
|
type InputBanned = {
|
|
12
12
|
routes?: string;
|
|
@@ -127,7 +127,7 @@ const VALID_COMBOS = [
|
|
|
127
127
|
["TRANSIT", "CAR"]
|
|
128
128
|
];
|
|
129
129
|
|
|
130
|
-
const BANNED_TOGETHER = ["SCOOTER", "BICYCLE"];
|
|
130
|
+
const BANNED_TOGETHER = ["SCOOTER", "BICYCLE", "CAR"];
|
|
131
131
|
|
|
132
132
|
export const TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(
|
|
133
133
|
mode => SIMPLIFICATIONS[mode] === "TRANSIT" && mode !== "TRANSIT"
|
|
@@ -168,7 +168,9 @@ function isCombinationValid(
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// OTP doesn't support multiple non-walk modes
|
|
171
|
-
if (BANNED_TOGETHER.
|
|
171
|
+
if (BANNED_TOGETHER.filter(m => combo.find(c => c.mode === m)).length > 1) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
172
174
|
|
|
173
175
|
return !!VALID_COMBOS.find(
|
|
174
176
|
vc =>
|
|
@@ -199,18 +201,27 @@ export function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {
|
|
|
199
201
|
.map(combo => ({ ...params, modes: combo }));
|
|
200
202
|
}
|
|
201
203
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Generates a query for OTP GraphQL API based on parameters.
|
|
206
|
+
* @param param0 OTP2 Parameters for the query
|
|
207
|
+
* @param planQuery Override the default query for OTP
|
|
208
|
+
* @returns A fully formed query+variables ready to be sent to GraphQL backend
|
|
209
|
+
*/
|
|
210
|
+
export function generateOtp2Query(
|
|
211
|
+
{
|
|
212
|
+
arriveBy,
|
|
213
|
+
banned,
|
|
214
|
+
date,
|
|
215
|
+
from,
|
|
216
|
+
modes,
|
|
217
|
+
modeSettings,
|
|
218
|
+
numItineraries,
|
|
219
|
+
preferred,
|
|
220
|
+
time,
|
|
221
|
+
to
|
|
222
|
+
}: OTPQueryParams,
|
|
223
|
+
planQuery = DefaultPlanQuery
|
|
224
|
+
): GraphQLQuery {
|
|
214
225
|
// This extracts the values from the mode settings to key value pairs
|
|
215
226
|
const modeSettingValues = modeSettings.reduce((prev, cur) => {
|
|
216
227
|
if (cur.type === "SLIDER" && cur.inverseKey) {
|
|
@@ -228,7 +239,7 @@ export function generateOtp2Query({
|
|
|
228
239
|
} = modeSettingValues;
|
|
229
240
|
|
|
230
241
|
return {
|
|
231
|
-
query: print(
|
|
242
|
+
query: print(planQuery),
|
|
232
243
|
variables: {
|
|
233
244
|
arriveBy,
|
|
234
245
|
banned,
|