Handle new special route listing for mtr buses

This commit is contained in:
2025-12-16 11:10:27 +08:00
parent 0ed4c618dc
commit 6e94adbed4
3 changed files with 250 additions and 239 deletions

View File

@@ -6,6 +6,7 @@ import (
type BusStop struct {
RouteId string
ReferenceId string
Direction string
StationSeq int
StationId string

View File

@@ -1,9 +1,9 @@
package bus
import (
"fmt"
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"

View File

@@ -4,6 +4,7 @@ import (
"encoding/csv"
"fmt"
"io"
"log"
"net/http"
"path/filepath"
"strconv"
@@ -55,11 +56,20 @@ func readBusStopData( r io.Reader ) ( *map[string] *BusStop, error ) {
entry.Name_zh = value
case "STATION_NAME_ENG":
entry.Name_en = value
case "REFERENCE_ID":
entry.ReferenceId = value
default:
return nil, fmt.Errorf("Unknown header \"%s\"", headers[j])
}
}
// Ignoring special route for now as getSchedule does not reflect
// which bus is a special route
if entry.ReferenceId != entry.RouteId {
log.Printf("Ignoring special Route: %s", entry.ReferenceId)
continue
}
if busStops[entry.StationId] != nil {
return nil, fmt.Errorf("Duplicated entry %+v", entry)
}