-
Notifications
You must be signed in to change notification settings - Fork 0
/
vvs.go
653 lines (589 loc) · 22.3 KB
/
vvs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
package govvs
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"time"
)
const (
baseURLJourney = "https://www3.vvs.de/mngvvs/XML_TRIP_REQUEST2"
baseURLWidgetDM = "https://www3.vvs.de/vvs/widget/XML_DM_REQUEST"
baseURLStopFinder = "https://www3.vvs.de/mngvvs/XML_STOPFINDER_REQUEST"
baseURLGeoObject = "https://www3.vvs.de/mngvvs/XML_GEOOBJECT_REQUEST"
baseURLServingLines = "https://www3.vvs.de/mngvvs/XML_SERVINGLINES_REQUEST"
)
const (
defaultDepartureLimit = 100
defaultArrivalLimit = 100
defaultJourneyLimit = 100
)
// GetJourney initiates a request to retrieve journey information between two locations at a specified time.
// It uses the VVS (Verkehrs- und Tarifverbund Stuttgart) API to calculate routes, taking into account various transport options and preferences.
//
// Parameters:
// - r JourneyRequest: Struct containing the essential information for the journey request.
// - OrigId: The ID or code representing the origin location for the journey. This should be in the format recognized by the VVS API, e.g., "de:08111:2599".
// - DstId: The ID or code representing the destination location for the journey, formatted similarly to OrigId.
// - TimeAt: Pointer to a time.Time object specifying the desired departure or arrival time for the journey.
// - Limit: Pointer to an integer specifying the maximum number of journey options to return. If nil, a default value defined by the API will be used.
// - LangCode: Pointer to a string specifying the language code for the response, e.g., "de" for German. If nil, the API's default language will be used.
//
// - reqParams ...ReqParam: An optional slice of ReqParam structs allowing for additional parameters to be specified for the journey request. These can include:
// - Name: The name of the parameter, matching the constant names defined for VVS API parameters, e.g., ParamCalcOneDirection.
// - Value: The value of the parameter, as a string, e.g., "1" for true or specific values like "EPSG:4326" for coordinate formats.
//
// The function supports various optional parameters that can be used to refine the journey search, including but not limited to:
// - ChangeSpeed: Adjusts the assumed speed of changing between transport modes.
// - RouteType: Determines the criteria for route selection, such as "LEASTTIME" for the shortest overall journey time.
// - UseRealtime: Specifies whether to include real-time data in the journey calculation.
//
// Returns:
// - *JourneyResponse: A pointer to a JourneyResponse struct containing the journey options found based on the request parameters. This includes detailed route information, timings, and any applicable fare information.
// - error: An error object that will be non-nil if there was an issue processing the request or communicating with the VVS API.
//
// Example usage:
//
// journeyReq := JourneyRequest{
// OrigId: "de:08111:2599",
// DstId: "de:08111:6075",
// TimeAt: time.Now(),
// Limit: 10,
// LangCode: "de",
// }
//
// journeyResp, err := GetJourney(journeyReq, ReqParam{Name: ParamRouteType, Value: "leasttime"})
//
// if err != nil {
// // Handle error
// }
//
// // Process journeyResp
func GetJourney(r JourneyRequest, reqParams ...ReqParam) (*JourneyResponse, error) {
// Prepare query parameters
params := url.Values{}
// set default params
setDefaultJourneyReqParams(params)
// Set dynamic values separately
limit := defaultJourneyLimit
if r.Limit != nil {
limit = *r.Limit
}
limitParam := strconv.Itoa(limit)
timeAt := time.Now()
if r.TimeAt != nil {
timeAt = *r.TimeAt
}
orig := r.OrigId
dst := r.DstId
params.Set(ParamItdDate, timeAt.Format("20060102"))
params.Set(ParamItdTime, timeAt.Format("1504"))
params.Set(ParamNameDestination, dst)
params.Set(ParamNameOrigin, orig)
params.Set(ParamLimit, limitParam)
// override optional params6
overrideReqParams(params, reqParams...)
// Build the URL with encoded query parameters
url := baseURLJourney + "?" + params.Encode()
// Make the GET request
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Error making GET request: %v\n", err)
return nil, err
}
defer resp.Body.Close()
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error reading response body: %v\n", err)
return nil, err
}
// Unmarshal the JSON response into the JourneyResponse struct
var journeyResponse JourneyResponse
err = json.Unmarshal(body, &journeyResponse)
if err != nil {
fmt.Printf("Error unmarshalling JSON: %v\n", err)
return nil, err
}
// Return the populated JourneyResponse struct
return &journeyResponse, nil
}
// GetArrivals sends a request to retrieve arrival information for a specified station or location.
// The function takes an ArrivalRequest struct containing essential request parameters and
// a variable number of ReqParam structs to specify additional request options.
//
// Parameters:
// - r ArrivalRequest: A struct containing the base request parameters such as station ID and request time.
//
// - OrigId (string): The origin station identifier. Not used in this context but can be set for consistency.
//
// - DstId (string): The destination station identifier. This is typically the station ID for which arrivals are requested.
//
// - TimeAt (*time.Time): The specific date and time for which arrival information is requested. If nil, current time is assumed.
//
// - Limit (*int): The maximum number of arrival entries to retrieve. If nil, a default limit is applied.
//
// - LangCode (*string): The language code for the response (e.g., "de" for German). If nil, a default language is used.
//
// - reqParams ...ReqParam: Optional parameters to further customize the request. Each ReqParam consists of a Name and Value.
// Supported optional parameters (refer to constants for parameter names):
//
// - ParamLocationServerActive: Activates the location server for processing the request.
//
// - ParamLsShowTrainsExplicit: Specifies whether trains should be shown explicitly in the response.
//
// - ParamStateless: Indicates if the request should be processed without maintaining state.
//
// - ParamLanguage: Sets the language of the response.
//
// - ParamSpEncId: Security parameter, typically "0".
//
// - ParamAnySigWhenPerfectNoOtherMatches: Used to refine search results.
//
// - ParamLimit: Controls the maximum number of results returned.
//
// - ParamDepArr: Indicates whether departure or arrival times are requested ("arrival" for arrivals).
//
// - ParamTypeDm: Specifies the type of data management request.
//
// - ParamAnyObjFilterDm: Filters objects based on specified criteria.
//
// - ParamDeleteAssignedStops: Indicates whether assigned stops should be removed from the response.
//
// - ParamNameDm: The name or ID of the station for which arrivals are being requested.
//
// - ParamMode: Specifies the mode of transport.
//
// - ParamDmLineSelectionAll: Determines if all lines should be selected in the request.
//
// - ParamUseRealtime: Specifies whether real-time data should be used.
//
// - ParamOutputFormat: Defines the output format of the response.
//
// - ParamCoordOutputFormat: Sets the coordinate format for the response.
//
// - ParamItdDateTimeDepArr: Specifies the desired time for departure or arrival.
//
// - Additional parameters related to date and time of the request: ParamItdDateYear, ParamItdDateMonth, ParamItdDateDay, ParamItdTimeHour, ParamItdTimeMinute.
//
// Returns:
// - (*ArrivalResponse, error): A pointer to an ArrivalResponse struct containing the requested arrival information, or an error if the request fails.
//
// Example usage:
// response, err := GetArrivals(ArrivalRequest{DstId: "stationID", TimeAt: &time.Now()}, ReqParam{Name: ParamLimit, Value: "5"})
//
// if err != nil {
// // handle error
// }
//
// // process response
func GetArrivals(r ArrivalRequest, reqParams ...ReqParam) (*ArrivalResponse, error) {
// Prepare query parameters
params := url.Values{}
setDefaultArrivalReqParams(params)
limit := defaultArrivalLimit
if r.Limit != nil {
limit = *r.Limit
}
limitParam := strconv.Itoa(limit)
timeAt := time.Now()
if r.TimeAt != nil {
timeAt = *r.TimeAt
}
year := timeAt.Format("2006")
month := timeAt.Format("01")
day := timeAt.Format("02")
hour := timeAt.Format("15")
minute := timeAt.Format("04")
stationId := r.StationId
params.Set(ParamItdDateYear, year)
params.Set(ParamItdDateMonth, month)
params.Set(ParamItdDateDay, day)
params.Set(ParamItdTimeHour, hour)
params.Set(ParamItdTimeMinute, minute)
params.Set(ParamNameDm, stationId)
params.Set(ParamLimit, limitParam)
overrideReqParams(params, reqParams...)
// Build the URL with encoded query parameters
url := baseURLWidgetDM + "?" + params.Encode()
// Make the GET request
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Error making GET request: %v\n", err)
return nil, err
}
defer resp.Body.Close()
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error reading response body: %v\n", err)
return nil, err
}
// Unmarshal the JSON response into the ArrivalResponse struct
var arrivalResponse ArrivalResponse
err = json.Unmarshal(body, &arrivalResponse)
if err != nil {
fmt.Printf("Error unmarshalling JSON: %v\n", err)
return nil, err
}
// Return the populated ArrivalResponse struct
return &arrivalResponse, nil
}
// GetDepartures sends a request to retrieve departure information for a specified station or location.
// The function takes a DepartureRequest struct containing essential request parameters and
// a variable number of ReqParam structs to specify additional request options.
//
// Parameters:
// - r DepartureRequest: A struct containing the base request parameters such as station ID and request time.
//
// - OrigId (string): The origin station identifier. In the context of departures, this is the station ID from which departures are requested.
//
// - DstId (string): The destination station identifier. Not typically used for departure requests but can be set for API consistency.
//
// - TimeAt (*time.Time): The specific date and time for which departure information is requested. If nil, the current time is assumed.
//
// - Limit (*int): The maximum number of departure entries to retrieve. If nil, a default limit is applied.
//
// - LangCode (*string): The language code for the response (e.g., "de" for German). If nil, a default language is used.
//
// - reqParams ...ReqParam: Optional parameters to further customize the request. Each ReqParam consists of a Name and Value.
// Supported optional parameters (refer to constants for parameter names):
//
// - ParamLocationServerActive: Activates the location server for processing the request.
//
// - ParamLsShowTrainsExplicit: Specifies whether trains should be shown explicitly in the response.
//
// - ParamStateless: Indicates if the request should be processed without maintaining state.
//
// - ParamLanguage: Sets the language of the response.
//
// - ParamSpEncId: Security parameter, typically "0".
//
// - ParamAnySigWhenPerfectNoOtherMatches: Used to refine search results.
//
// - ParamLimit: Controls the maximum number of results returned.
//
// - ParamDepArr: Indicates whether departure or arrival times are requested ("departure" for departures).
//
// - ParamTypeDm: Specifies the type of data management request.
//
// - ParamAnyObjFilterDm: Filters objects based on specified criteria.
//
// - ParamDeleteAssignedStops: Indicates whether assigned stops should be removed from the response.
//
// - ParamNameDm: The name or ID of the station for which departures are being requested.
//
// - ParamMode: Specifies the mode of transport.
//
// - ParamDmLineSelectionAll: Determines if all lines should be selected in the request.
//
// - ParamUseRealtime: Specifies whether real-time data should be used.
//
// - ParamOutputFormat: Defines the output format of the response.
//
// - ParamCoordOutputFormat: Sets the coordinate format for the response.
//
// - Additional parameters related to date and time of the request: ParamItdDateYear, ParamItdDateMonth, ParamItdDateDay, ParamItdTimeHour, ParamItdTimeMinute.
//
// Returns:
// - (*DepartureResponse, error): A pointer to a DepartureResponse struct containing the requested departure information, or an error if the request fails.
//
// Example usage:
// response, err := GetDepartures(DepartureRequest{OrigId: "stationID", TimeAt: &time.Now()}, ReqParam{Name: ParamLimit, Value: "10"})
//
// if err != nil {
// // handle error
// }
//
// // process response
func GetDepartures(r DepartureRequest, reqParams ...ReqParam) (*DepartureResponse, error) {
// Assemble the query parameters
params := url.Values{}
setDefaultDepartureReqParams(params)
limit := defaultDepartureLimit
if r.Limit != nil {
limit = *r.Limit
}
limitParam := strconv.Itoa(limit)
timeAt := time.Now()
if r.TimeAt != nil {
timeAt = *r.TimeAt
}
year := timeAt.Format("2006")
month := timeAt.Format("01")
day := timeAt.Format("02")
hour := timeAt.Format("15")
minute := timeAt.Format("04")
stationId := r.StationId
params.Set(ParamItdDateYear, year)
params.Set(ParamItdDateMonth, month)
params.Set(ParamItdDateDay, day)
params.Set(ParamItdTimeHour, hour)
params.Set(ParamItdTimeMinute, minute)
params.Set(ParamNameDm, stationId)
params.Set(ParamLimit, limitParam)
overrideReqParams(params, reqParams...)
// Build the complete URL with the encoded query parameters
fullURL := baseURLWidgetDM + "?" + params.Encode()
// Perform the GET request
resp, err := http.Get(fullURL)
if err != nil {
fmt.Println("Error making GET request:", err)
return nil, err
}
defer resp.Body.Close()
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return nil, err
}
// Unmarshal the JSON response into the DepartureResponse struct
var departureResponse DepartureResponse
err = json.Unmarshal(body, &departureResponse)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return nil, err
}
return &departureResponse, nil
}
// GetStopFinder sends a request to retrieve stop information for a specified location.
// The function takes a StopFinderRequest struct containing essential request parameters and
// a variable number of ReqParam structs to specify additional request options.
//
// Parameters:
// - r StopFinderRequest: A struct containing the base request parameters such as stop name and type.
//
// - Name (string): The name of the stop or location to search for.
//
// - Type (string): The type of location being queried (e.g., "any" for any type).
//
// - CoordOutputFormat (string): The format in which coordinates should be returned (e.g., "EPSG:4326").
//
// - OutputFormat (string): Specifies the format of the response (e.g., "rapidJSON").
//
// - ServerInfo (*bool): Whether to include server information in the response. If nil, the default value is used.
//
// - Language (*string): The language for the response (e.g., "de" for German). If nil, the default language is used.
//
// - UseRealtime (*bool): Whether to use real-time data in the response. If nil, the default value is used.
//
// - reqParams ...ReqParam: Optional parameters to further customize the request.
//
// Supported optional parameters (refer to constants for parameter names):
//
// - ParamCoordOutputFormat: Specifies the coordinate format (e.g., "EPSG:4326").
//
// - ParamOutputFormat: Specifies the response format (e.g., "rapidJSON").
//
// - ParamServerInfo: Indicates if server info should be included in the response.
//
// - ParamUseRealtime: Specifies whether to use real-time data.
//
// - ParamLanguage: The language of the response.
//
// Returns:
// - (*StopFinderResponse, error): A pointer to a StopFinderResponse struct containing the stop information, or an error if the request fails.
//
// Example usage:
// response, err := GetStopFinder(StopFinderRequest{Name: "Fred-Uhlman-Str 11", Type: "any"}, ReqParam{Name: ParamLimit, Value: "10"})
//
// if err != nil {
// // handle error
// }
//
// // process response
func GetStopFinder(r StopFinderRequest, reqParams ...ReqParam) (*StopFinderResponse, error) {
// Assemble the query parameters
params := url.Values{}
// Set default StopFinder parameters
setDefaultStopFinderReqParams(params)
// Use provided StopFinderRequest fields
params.Set(ParamNameSF, r.Name)
params.Set(ParamTypeSF, r.Type)
// Optional parameters handling
if r.CoordOutputFormat != "" {
params.Set(ParamCoordOutputFormat, r.CoordOutputFormat)
}
if r.OutputFormat != "" {
params.Set(ParamOutputFormat, r.OutputFormat)
}
if r.ServerInfo != nil {
params.Set(ParamServerInfo, boolToString(*r.ServerInfo))
}
if r.Language != nil {
params.Set(ParamLanguage, *r.Language)
}
if r.UseRealtime != nil {
params.Set(ParamUseRealtime, boolToString(*r.UseRealtime))
}
// Apply any additional optional request parameters
overrideReqParams(params, reqParams...)
// Build the complete URL with the encoded query parameters
fullURL := baseURLStopFinder + "?" + params.Encode()
// Perform the GET request
resp, err := http.Get(fullURL)
if err != nil {
fmt.Println("Error making GET request:", err)
return nil, err
}
defer resp.Body.Close()
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return nil, err
}
// Unmarshal the JSON response into the StopFinderResponse struct
var stopFinderResponse StopFinderResponse
err = json.Unmarshal(body, &stopFinderResponse)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return nil, err
}
return &stopFinderResponse, nil
}
// GetGeoObject fetches geographical and transportation data for a specified line or object from the VVS API.
//
// Parameters:
// - r GeoObjectRequest: Struct containing the parameters for the geo-object request.
// - LineID: The ID of the line or transportation object to fetch data for. For example, "vvs:20007:+:H:j24:1".
//
// - reqParams ...ReqParam: Additional optional parameters that can be included in the request.
//
// Returns:
// - *GeoObjectResponse: A pointer to the GeoObjectResponse struct containing the transportation data and associated details.
// - error: An error object that will be non-nil if there was an issue processing the request or communicating with the VVS API.
//
// Example usage:
//
// geoReq := GeoObjectRequest{
// LineID: "vvs:20007:+:H:j24:1",
// }
//
// geoResp, err := GetGeoObject(geoReq, ReqParam{Name: ParamServerInfo, Value: "1"})
//
// if err != nil {
// // Handle error
// }
//
// // Process geoResp
func GetGeoObject(r GeoObjectRequest, reqParams ...ReqParam) (*GeoObjectResponse, error) {
// Prepare query parameters
params := url.Values{}
// Set mandatory parameters
params.Set(ParamOutputFormat, "rapidJSON")
params.Set(ParamCoordOutputFormat, "EPSG:4326")
params.Set(ParamVersion, "10.2.10.139")
params.Set(ParamSpEncId, "0")
params.Set(ParamServerInfo, "1")
params.Set(ParamStFaZon, "1")
params.Set(ParamVSL, "1")
// Override optional parameters if provided
overrideReqParams(params, reqParams...)
// Build the request URL
url := baseURLGeoObject + "?" + params.Encode() + "&" + fmt.Sprintf("%s=%s", ParamLineID, r.LineID)
// Make the GET request
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Error making GET request: %v\n", err)
return nil, err
}
defer resp.Body.Close()
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error reading response body: %v\n", err)
return nil, err
}
// Unmarshal the JSON response into the GeoObjectResponse struct
var geoResponse GeoObjectResponse
err = json.Unmarshal(body, &geoResponse)
if err != nil {
fmt.Printf("Error unmarshalling JSON: %v\n", err)
return nil, err
}
// Return the populated GeoObjectResponse struct
return &geoResponse, nil
}
// GetServingLines sends a request to the VVS API to retrieve serving lines for a specified line name.
//
// Parameters:
// - r ServingLinesRequest: The parameters for the API request, including line name and network.
// - reqParams ...ReqParam: Additional optional parameters.
//
// Returns:
// - (*ServingLinesResponse, error): A pointer to the response containing line details or an error if the request fails.
func GetServingLines(r ServingLinesRequest, reqParams ...ReqParam) (*ServingLinesResponse, error) {
// Prepare query parameters
params := url.Values{}
params.Set(ParamNet, "vvs")
params.Set(ParamMode, "line")
params.Set(ParamCoordOutputFormat, "EPSG:4326")
params.Set(ParamSpEncId, "0")
params.Set(ParamCommand, "direct")
params.Set(ParamLineName, r.LineName)
params.Set(ParamLsShowTrainsExplicit, "1")
params.Set(ParamOutputFormat, "rapidJSON")
params.Set(ParamServerInfo, "1")
params.Set(ParamVersion, "10.2.10.139")
// Override optional parameters
overrideReqParams(params, reqParams...)
// Build the URL
fullURL := baseURLServingLines + "?" + params.Encode()
// Make the GET request
resp, err := http.Get(fullURL)
if err != nil {
fmt.Println("Error making GET request:", err)
return nil, err
}
defer resp.Body.Close()
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return nil, err
}
// Unmarshal the JSON response into ServingLinesResponse
var servingLinesResponse ServingLinesResponse
err = json.Unmarshal(body, &servingLinesResponse)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return nil, err
}
return &servingLinesResponse, nil
}
func overrideReqParams(urlParams url.Values, params ...ReqParam) {
for _, param := range params {
urlParams.Set(param.Name, param.Value)
}
}
func setDefaultArrivalReqParams(urlParams url.Values) {
for param, defaultValue := range defaultArrivalParams {
urlParams.Set(param, defaultValue)
}
}
func setDefaultDepartureReqParams(urlParams url.Values) {
for param, defaultValue := range defaultDepartureParams {
urlParams.Set(param, defaultValue)
}
}
func setDefaultJourneyReqParams(urlParams url.Values) {
for param, defaultValue := range defaultJourneyParams {
urlParams.Set(param, defaultValue)
}
}
func setDefaultStopFinderReqParams(params url.Values) {
for key, value := range defaultStopFinderParams {
params.Set(key, value)
}
}
// boolToString converts a boolean value to "1" or "0" for use in query parameters.
func boolToString(b bool) string {
if b {
return "1"
}
return "0"
}