Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artonge/Go-gtfs
Load GTFS files in golang
https://github.com/artonge/Go-gtfs
go gtfs hacktoberfest
Last synced: about 2 months ago
JSON representation
Load GTFS files in golang
- Host: GitHub
- URL: https://github.com/artonge/Go-gtfs
- Owner: artonge
- License: gpl-3.0
- Created: 2017-07-09T09:30:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-16T07:58:40.000Z (over 1 year ago)
- Last Synced: 2024-07-31T01:24:51.645Z (5 months ago)
- Topics: go, gtfs, hacktoberfest
- Language: Go
- Homepage:
- Size: 404 KB
- Stars: 45
- Watchers: 4
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# go-gtfs
Load GTFS files in Go.[![godoc for artonge/go-gtfs](https://godoc.org/github.com/artonge/go-gtfs?status.svg)](http://godoc.org/github.com/artonge/go-gtfs)
![Go](https://github.com/artonge/go-gtfs/workflows/Go/badge.svg)
[![goreportcard for artonge/go-gtfs](https://goreportcard.com/badge/github.com/artonge/go-gtfs)](https://goreportcard.com/report/artonge/go-gtfs)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
**The project is in maintenance mode.**
It is kept compatible with changes in the Go ecosystem but no new features will be developed. PR could be accepted.
# Install
`go get github.com/artonge/go-gtfs`# Examples
## Load one directory containing GTFS files:
```bash
path/to/gtfs_files
├── agency.txt
├── attributions.txt
├── calendar_dates.txt
├── calendar.txt
├── fare_attributes.txt
├── fare_rules.txt
├── feed_info.txt
├── frequencies.txt
├── levels.txt
├── pathways.txt
├── routes.txt
├── shapes.txt
├── stops.txt
├── stop_times.txt
├── transfers.txt
└── trips.txt
```
```go
g, err := gtfs.Load("path/to/gtfs_files", nil)
```## Load a directory containing sub directories containing GTFS files:
```bash
path/to/gtfs_directories
├── gtfs1
│ ├── agency.txt
│ ├── attributions.txt
│ ├── calendar_dates.txt
│ ├── calendar.txt
│ ├── fare_attributes.txt
│ ├── fare_rules.txt
│ ├── feed_info.txt
│ ├── frequencies.txt
│ ├── levels.txt
│ ├── pathways.txt
│ ├── routes.txt
│ ├── shapes.txt
│ ├── stops.txt
│ ├── stop_times.txt
│ ├── transfers.txt
│ └── trips.txt
└── gtfs2
├── agency.txt
├── attributions.txt
├── calendar_dates.txt
├── calendar.txt
├── fare_attributes.txt
├── fare_rules.txt
├── feed_info.txt
├── frequencies.txt
├── levels.txt
├── pathways.txt
├── routes.txt
├── shapes.txt
├── stops.txt
├── stop_times.txt
├── transfers.txt
└── trips.txt```
```go
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.
```go
type GTFS struct {
Path string // The path to the containing directory
Agency Agency
Agencies []Agency
Attributions []Attribution
Calendars []Calendar
CalendarDates []CalendarDate
FareAttributes []FareAttribute
FareRules []FareRule
FeedInfos []FeedInfo
Frequencies []Frequency
Levels []Level
Routes []Route
Pathways []Pathway
Shapes []Shape
Stops []Stop
StopsTimes []StopTime
Trips []Trip
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_desc"`
URL string `csv:"route_url"`
Color string `csv:"route_color"`
TextColor string `csv:"route_text_color"`
}...
```# Contributions
Pull requests are welcome ! :)