From 740b654be6ac3e61fa0911ad05fecfc69733ba8c Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Fri, 25 Apr 2025 13:37:01 +0200 Subject: [PATCH] Add bwegt efa client --- main.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/main.go b/main.go index 967b8e2..5e08305 100644 --- a/main.go +++ b/main.go @@ -111,6 +111,38 @@ func (c KVVEFAClient) BuildRequest(stopId string) (*http.Request, error) { return req, nil } +type BwegtEFAClient struct { +} + +func (c BwegtEFAClient) GetName() string { + return "bwegt" +} + +func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) { + // Create request object + req, err := http.NewRequest("GET", "https://www.bwegt.de/bwegt-efa/XML_DM_REQUEST", nil) + if err != nil { + return nil, err + } + + // Configure our request + query := url.Values{} + query.Set("coordOutputFormat", "EPSG:4326") + query.Set("depType", "stopEvents") + query.Set("includeCompleteStopSeq", "0") + query.Set("limit", "10") + query.Set("locationServerActive", "0") + query.Set("mode", "direct") + query.Set("name_dm", stopId) + query.Set("outputFormat", "json") + query.Set("type_dm", "stop") + query.Set("useOnlyStops", "1") + query.Set("useRealtime", "1") + req.URL.RawQuery = query.Encode() + + return req, nil +} + func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) { req, err := c.BuildRequest(stopId) if err != nil { @@ -206,6 +238,7 @@ func main() { // Use round-robin to send incoming requests to different servers var efaClient atomic.Uint64 efaClients := []EFAClient{ + BwegtEFAClient{}, VRNEFAClient{}, KVVEFAClient{}, }