Popularity
3.5
Growing
Activity
4.6
-
39
4
23

Programming language: Go
License: GNU General Public License v3.0 only
Tags: Files    
Latest version: v1.1.0

go-gtfs alternatives and similar packages

Based on the "Files" category.
Alternatively, view go-gtfs alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of go-gtfs or a related project?

Add another 'Files' Package

README

go-gtfs

Load GTFS files in golang

godoc for artonge/go-gtfs

Build Status cover.run go goreportcard for artonge/go-gtfs

Sourcegraph for artonge/go-gtfs

Install

go get github.com/artonge/go-gtfs

Examples

Load one directory containing GTFS files:

path/to/gtfs_files
โ”œโ”€โ”€ agency.txt
โ”œโ”€โ”€ calendar_dates.txt
โ”œโ”€โ”€ calendar.txt
โ”œโ”€โ”€ routes.txt
โ”œโ”€โ”€ stops.txt
โ”œโ”€โ”€ stop_times.txt
โ”œโ”€โ”€ transfers.txt
โ””โ”€โ”€ trips.txt
g, err := gtfs.Load("path/to/gtfs_files", nil)

Load a directory containing sub directories containing GTFS files:

path/to/gtfs_directories
โ”œโ”€โ”€ gtfs1
โ”‚ย ย  โ”œโ”€โ”€ agency.txt
โ”‚ย ย  โ”œโ”€โ”€ calendar_dates.txt
โ”‚ย ย  โ”œโ”€โ”€ routes.txt
โ”‚ย ย  โ”œโ”€โ”€ stops.txt
โ”‚ย ย  โ”œโ”€โ”€ stop_times.txt
โ”‚ย ย  โ”œโ”€โ”€ transfers.txt
โ”‚ย ย  โ””โ”€โ”€ trips.txt
โ””โ”€โ”€ gtfs2
    โ”œโ”€โ”€ agency.txt
    โ”œโ”€โ”€ calendar_dates.txt
    โ”œโ”€โ”€ calendar.txt
    โ”œโ”€โ”€ routes.txt
    โ”œโ”€โ”€ stops.txt
    โ”œโ”€โ”€ stop_times.txt
    โ”œโ”€โ”€ transfers.txt
    โ””โ”€โ”€ trips.txt

gs, err := gtfs.LoadSplitted("path/to/gtfs_directories", nil)

You can then access the data through the GTFS structure. That structure contains arrays of approriate structures for each files.

type GTFS struct {
    Path       string // The path to the containing directory
    Agency     Agency
    Routes     []Route
    Stops      []Stop
    StopsTimes []Stop
    Trips      []Trip
    Calendars  []Calendar
    Transfers  []Transfer
}

type Route struct {
    ID        string `csv:"route_id"`
    AgencyID  string `csv:"agency_id"`
    ShortName string `csv:"route_short_name"`
    LongName  string `csv:"route_long_name"`
    Type      int    `csv:"route_type"`
    Desc      string `csv:"route_url"`
    URL       string `csv:"route_desc"`
    Color     string `csv:"route_color"`
    TextColor string `csv:"route_text_color"`
}

...

Contributions

Pull requests are welcome ! :)