Handle new special route listing for mtr buses
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
type BusStop struct {
|
type BusStop struct {
|
||||||
RouteId string
|
RouteId string
|
||||||
|
ReferenceId string
|
||||||
Direction string
|
Direction string
|
||||||
StationSeq int
|
StationSeq int
|
||||||
StationId string
|
StationId string
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package bus
|
package bus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -55,11 +56,20 @@ func readBusStopData( r io.Reader ) ( *map[string] *BusStop, error ) {
|
|||||||
entry.Name_zh = value
|
entry.Name_zh = value
|
||||||
case "STATION_NAME_ENG":
|
case "STATION_NAME_ENG":
|
||||||
entry.Name_en = value
|
entry.Name_en = value
|
||||||
|
case "REFERENCE_ID":
|
||||||
|
entry.ReferenceId = value
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Unknown header \"%s\"", headers[j])
|
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 {
|
if busStops[entry.StationId] != nil {
|
||||||
return nil, fmt.Errorf("Duplicated entry %+v", entry)
|
return nil, fmt.Errorf("Duplicated entry %+v", entry)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user