Move `Quay` and `Route` to their own files
							parent
							
								
									be4b6d8aa2
								
							
						
					
					
						commit
						8df1ac94b5
					
				
							
								
								
									
										29
									
								
								main.go
								
								
								
								
							
							
						
						
									
										29
									
								
								main.go
								
								
								
								
							|  | @ -2,38 +2,9 @@ package main | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"flag" | 	"flag" | ||||||
| 	"fmt" |  | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/url" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type Route struct { |  | ||||||
| 	RouteShortName string `json:"route_short_name"` |  | ||||||
| 	RouteLongName  string `json:"route_long_name"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type Quay struct { |  | ||||||
| 	ID               string `json:"quayid"` |  | ||||||
| 	Name             string `json:"name"` |  | ||||||
| 	Town             string `json:"town"` |  | ||||||
| 	RoutesOfInterest []Route |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (q Quay) IsInterestingDeparture(d Departure) bool { |  | ||||||
| 	for _, route := range q.RoutesOfInterest { |  | ||||||
| 		if (route.RouteShortName == d.RouteShortName) && (route.RouteLongName == d.StopHeadsign) { |  | ||||||
| 			return true |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return false |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (q Quay) GetBrengUrl() string { |  | ||||||
| 	param := fmt.Sprintf("{\"quayid\":\"%s\",\"name\":\"%s\",\"town\":\"%s\"}", q.ID, q.Name, q.Town) |  | ||||||
| 	return fmt.Sprint("https://www.breng.nl/nl/resultaten/halte-informatie/?stop=%s", url.QueryEscape(param)) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| var BusClient *http.Client | var BusClient *http.Client | ||||||
| var Quays []Quay = []Quay{} | var Quays []Quay = []Quay{} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,28 @@ | ||||||
|  | package main | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"net/url" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | type Quay struct { | ||||||
|  | 	ID               string `json:"quayid"` | ||||||
|  | 	Name             string `json:"name"` | ||||||
|  | 	Town             string `json:"town"` | ||||||
|  | 	RoutesOfInterest []Route | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (q Quay) IsInterestingDeparture(d Departure) bool { | ||||||
|  | 	for _, route := range q.RoutesOfInterest { | ||||||
|  | 		if (route.RouteShortName == d.RouteShortName) && (route.RouteLongName == d.StopHeadsign) { | ||||||
|  | 			return true | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return false | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (q Quay) GetBrengUrl() string { | ||||||
|  | 	param := fmt.Sprintf("{\"quayid\":\"%s\",\"name\":\"%s\",\"town\":\"%s\"}", q.ID, q.Name, q.Town) | ||||||
|  | 	return fmt.Sprintf("https://www.breng.nl/nl/resultaten/halte-informatie/?stop=%s", url.QueryEscape(param)) | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue