Handle new special route listing for mtr buses
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
type BusStop struct {
|
||||
RouteId string
|
||||
ReferenceId string
|
||||
Direction string
|
||||
StationSeq int
|
||||
StationId string
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package bus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user