@opentripplanner/core-utils 8.2.0 → 8.2.1

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.
@@ -1,146 +1,167 @@
1
1
  query PlanQuery(
2
- $fromPlace: String!,
3
- $toPlace: String!,
4
- $modes: [TransportMode],
5
- $time: String,
6
- $date: String,
7
- $wheelchair: Boolean,
8
- $bikeReluctance: Float,
9
- $carReluctance: Float,
10
- $walkReluctance: Float,
11
- $arriveBy: Boolean,
12
- $intermediatePlaces: [InputCoordinates],
13
- $preferred: InputPreferred,
14
- $unpreferred: InputUnpreferred,
15
- $banned: InputBanned,
2
+ $fromPlace: String!
3
+ $toPlace: String!
4
+ $modes: [TransportMode]
5
+ $time: String
6
+ $date: String
7
+ $wheelchair: Boolean
8
+ $bikeReluctance: Float
9
+ $carReluctance: Float
10
+ $walkReluctance: Float
11
+ $arriveBy: Boolean
12
+ $intermediatePlaces: [InputCoordinates]
13
+ $preferred: InputPreferred
14
+ $unpreferred: InputUnpreferred
15
+ $banned: InputBanned
16
+ $numItineraries: Int
16
17
  ) {
17
- plan(
18
- fromPlace: $fromPlace
19
- toPlace: $toPlace
20
- transportModes: $modes
21
- # Currently only supporting EN locale, used for times and text
22
- locale: "en",
23
- time: $time,
24
- date: $date,
25
- wheelchair: $wheelchair,
26
- bikeReluctance: $bikeReluctance,
27
- carReluctance: $carReluctance,
28
- walkReluctance: $walkReluctance,
29
- arriveBy: $arriveBy,
30
- intermediatePlaces: $intermediatePlaces,
31
- preferred: $preferred,
32
- unpreferred: $unpreferred,
33
- banned: $banned,
34
- ) {
35
- itineraries {
36
- duration
37
- endTime
38
- startTime
39
- waitingTime
40
- walkTime
41
- legs {
42
- distance
43
- duration
44
- endTime
45
- mode
46
- realTime
47
- realtimeState
48
- startTime
49
- transitLeg
50
- trip {
51
- id
52
- gtfsId
53
- }
54
- agency {
55
- name
56
- id
57
- timezone
58
- url
59
- alerts {
18
+ plan(
19
+ fromPlace: $fromPlace
20
+ toPlace: $toPlace
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
27
+ bikeReluctance: $bikeReluctance
28
+ carReluctance: $carReluctance
29
+ walkReluctance: $walkReluctance
30
+ arriveBy: $arriveBy
31
+ intermediatePlaces: $intermediatePlaces
32
+ preferred: $preferred
33
+ unpreferred: $unpreferred
34
+ banned: $banned
35
+ numItineraries: $numItineraries
36
+ ) {
37
+ routingErrors {
38
+ code
39
+ inputField
40
+ description
41
+ }
42
+ itineraries {
43
+ duration
44
+ endTime
45
+ startTime
46
+ waitingTime
47
+ walkTime
48
+ legs {
49
+ rentedBike
50
+ interlineWithPreviousLeg
51
+ departureDelay
52
+ arrivalDelay
53
+ distance
54
+ duration
55
+ endTime
56
+ mode
57
+ realTime
58
+ realtimeState
59
+ startTime
60
+ transitLeg
61
+ trip {
62
+ id
63
+ gtfsId
64
+ tripHeadsign
65
+ }
66
+ agency {
67
+ name
68
+ id
69
+ timezone
70
+ url
71
+ alerts {
60
72
  alertHeaderText
61
73
  alertDescriptionText
62
74
  alertUrl
63
75
  effectiveStartDate
64
76
  }
65
- }
66
- legGeometry {
67
- length
68
- points
69
- }
70
- intermediateStops {
71
- lat
72
- lon
73
- name
74
- stopCode: code
75
- stopId: id
76
- locationType
77
- }
78
- route {
79
- shortName
80
- color
81
- textColor
82
- id
83
- type
84
- alerts {
77
+ }
78
+ legGeometry {
79
+ length
80
+ points
81
+ }
82
+ intermediateStops {
83
+ lat
84
+ lon
85
+ name
86
+ stopCode: code
87
+ stopId: id
88
+ locationType
89
+ }
90
+ route {
91
+ shortName
92
+ longName
93
+ color
94
+ textColor
95
+ id
96
+ type
97
+ alerts {
85
98
  alertHeaderText
86
99
  alertDescriptionText
87
100
  alertUrl
88
101
  effectiveStartDate
89
102
  }
90
- }
91
- from {
92
- lat
93
- lon
94
- name
95
- vertexType
96
- stop {
97
- id
98
- code
99
- alerts {
100
- alertHeaderText
101
- alertDescriptionText
102
- alertUrl
103
- effectiveStartDate
104
- }
105
- }
106
- }
107
- to {
108
- lat
109
- lon
110
- name
111
- vertexType
112
- stop {
113
- id
114
- code
115
- alerts {
116
- alertHeaderText
117
- alertDescriptionText
118
- alertUrl
119
- effectiveStartDate
120
- }
121
- }
122
- }
123
- steps {
124
- distance
125
- lat
126
- lon
103
+ }
104
+ from {
105
+ lat
106
+ lon
107
+ name
108
+ vertexType
109
+ rentalVehicle {
110
+ network
111
+ }
112
+ stop {
113
+ id
114
+ code
115
+ gtfsId
116
+ alerts {
117
+ alertHeaderText
118
+ alertDescriptionText
119
+ alertUrl
120
+ effectiveStartDate
121
+ }
122
+ }
123
+ }
124
+ to {
125
+ lat
126
+ lon
127
+ name
128
+ vertexType
129
+ rentalVehicle {
130
+ network
131
+ }
132
+ stop {
133
+ id
134
+ code
135
+ gtfsId
136
+ alerts {
137
+ alertHeaderText
138
+ alertDescriptionText
139
+ alertUrl
140
+ effectiveStartDate
141
+ }
142
+ }
143
+ }
144
+ steps {
145
+ distance
146
+ lat
147
+ lon
127
148
  relativeDirection
128
149
  absoluteDirection
129
150
  stayOn
130
151
  streetName
131
152
  area
132
- alerts{
153
+ alerts {
133
154
  alertHeaderText
134
155
  alertDescriptionText
135
156
  alertUrl
136
157
  effectiveStartDate
137
158
  }
138
- elevationProfile {
139
- distance
140
- elevation
141
- }
142
- }
143
- }
144
- }
145
- }
159
+ elevationProfile {
160
+ distance
161
+ elevation
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
146
167
  }
package/src/query-gen.ts CHANGED
@@ -8,11 +8,31 @@ import {
8
8
 
9
9
  import PlanQuery from "./planQuery.graphql";
10
10
 
11
+ type InputBanned = {
12
+ routes?: string;
13
+ agencies?: string;
14
+ trips?: string;
15
+ stops?: string;
16
+ stopsHard?: string;
17
+ };
18
+
19
+ type InputPreferred = {
20
+ routes?: string;
21
+ agencies?: string;
22
+ unpreferredCost?: string;
23
+ };
24
+
11
25
  type OTPQueryParams = {
26
+ arriveBy: boolean;
27
+ date?: string;
12
28
  from: LonLatOutput & { name?: string };
13
29
  modes: TransportMode[];
14
30
  modeSettings: ModeSetting[];
31
+ time?: string;
32
+ numItineraries?: number;
15
33
  to: LonLatOutput & { name?: string };
34
+ banned?: InputBanned;
35
+ preferred?: InputPreferred;
16
36
  };
17
37
 
18
38
  type GraphQLQuery = {
@@ -176,13 +196,22 @@ export function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {
176
196
  }
177
197
 
178
198
  export function generateOtp2Query({
199
+ arriveBy,
200
+ banned,
201
+ date,
179
202
  from,
180
- modeSettings,
181
203
  modes,
204
+ modeSettings,
205
+ numItineraries,
206
+ preferred,
207
+ time,
182
208
  to
183
209
  }: OTPQueryParams): GraphQLQuery {
184
210
  // This extracts the values from the mode settings to key value pairs
185
211
  const modeSettingValues = modeSettings.reduce((prev, cur) => {
212
+ if (cur.type === "SLIDER" && cur.inverseKey) {
213
+ prev[cur.inverseKey] = cur.high - cur.value + cur.low;
214
+ }
186
215
  prev[cur.key] = cur.value;
187
216
  return prev;
188
217
  }, {}) as ModeSettingValues;
@@ -197,10 +226,16 @@ export function generateOtp2Query({
197
226
  return {
198
227
  query: print(PlanQuery),
199
228
  variables: {
229
+ arriveBy,
230
+ banned,
200
231
  bikeReluctance,
201
232
  carReluctance,
233
+ date,
202
234
  fromPlace: `${from.name}::${from.lat},${from.lon}}`,
203
235
  modes,
236
+ numItineraries,
237
+ preferred,
238
+ time,
204
239
  toPlace: `${to.name}::${to.lat},${to.lon}}`,
205
240
  walkReluctance,
206
241
  wheelchair