Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"github.com/heimdalr/gtfs"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
func main() {
const dbPath = "_fixture/test.db"
// open the DB
db, _ := gorm.Open(sqlite.Open(dbPath), &gorm.Config{
Logger: logger.Default.LogMode(logger.Error),
})
// SELECT * FROM agencies WHERE id = 1;
agency := gtfs.Agency{}
db.First(&agency, "id = ?", 1)
fmt.Println(agency)
}
Output: {1 S-Bahn Berlin GmbH https://sbahn.berlin/}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agency ¶
type Agency struct {
ID string `csv:"agency_id"`
Name string `csv:"agency_name"`
URL string `csv:"agency_url"`
}
Agency model.
type Calendar ¶
type Calendar struct {
ID uint `gorm:"primaryKey,autoIncrement"`
ServiceID string `csv:"service_id"`
Monday int `csv:"monday"`
Tuesday int `csv:"tuesday"`
Wednesday int `csv:"wednesday"`
Thursday int `csv:"thursday"`
Friday int `csv:"friday"`
Saturday int `csv:"saturday"`
Sunday int `csv:"sunday"`
StartDate string `csv:"start_date"`
EndDate string `csv:"end_date"`
}
Calendar model.
type CalendarDate ¶
type CalendarDate struct {
ID uint `gorm:"primaryKey,autoIncrement"`
ServiceID string `csv:"service_id"`
Date string `csv:"date"`
ExceptionType int `csv:"exception_type"`
}
CalendarDate model.
type DateTime ¶
type DateTime struct {
Int32 int32
}
DateTime is used to represent GTFS times (hh:mm) (in the DB) as seconds since midnight.
func (*DateTime) MarshalCSV ¶
MarshalCSV marshals DateTime to CSV (i.e. when writing to CSV).
func (*DateTime) UnmarshalCSV ¶
UnmarshalCSV unmarshalls CSV to DateTime (i.e. when reading from CSV).
type ItemType ¶
type ItemType uint32
ItemType enumerates different item types.
const ( // Agencies the item type for agency items. Agencies ItemType = iota // Routes the item type for route items. Routes // Trips the item type for trip items. Trips // Stops the item type for stop items. Stops // StopTimes the item type for stop time items. StopTimes // Shapes the item type for shape items. Shapes // Calendars the item type for shape items. Calendars // CalendarDates the item type for shape items. CalendarDates )
type Route ¶
type Route struct {
ID string `csv:"route_id"`
AgencyID string `csv:"agency_id"`
Agency Agency
ShortName string `csv:"route_short_name"`
LongName string `csv:"route_long_name"`
Type int `csv:"route_type"`
}
Route model.
type Shape ¶
type Shape struct {
ID uint `gorm:"primaryKey,autoIncrement"`
ShapeID string `csv:"shape_id"`
PtLat float64 `csv:"shape_pt_lat"`
PtLon float64 `csv:"shape_pt_lon"`
PtSequence int `csv:"shape_pt_sequence"`
}
Shape model.
type Stop ¶
type Stop struct {
ID string `csv:"stop_id"`
Name string `csv:"stop_name"`
Latitude float64 `csv:"stop_lat"`
Longitude float64 `csv:"stop_lon"`
}
Stop model.
Click to show internal directories.
Click to hide internal directories.