https://github.com/geops/gtfsparser
A GTFS parsing library for Go
https://github.com/geops/gtfsparser
Last synced: 3 months ago
JSON representation
A GTFS parsing library for Go
- Host: GitHub
- URL: https://github.com/geops/gtfsparser
- Owner: geops
- License: gpl-2.0
- Created: 2015-05-05T23:08:40.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T21:22:06.000Z (almost 7 years ago)
- Last Synced: 2024-06-18T21:47:22.367Z (about 1 year ago)
- Language: Go
- Size: 40 KB
- Stars: 43
- Watchers: 14
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go gtfsparser
A complete*, easy to use parsing library for GTFS data. Implemented in go. Accepts folders containing GTFS files and ZIPs. Feeds are validated during parsing. ID references are transformed into pointer references where appropriate.
## Usage
feed := gtfsparser.NewFeed()
error := feed.Parse("sample-feed.zip")
See feed.go for exported fields.## Example
Parsing of the [GTFS example feed](https://developers.google.com/transit/gtfs/examples/gtfs-feed):
```go
import (
"github.com/geops/gtfsparser"
"fmt"
)func main() {
feed := gtfsparser.NewFeed()feed.Parse("sample-feed.zip")
fmt.Printf("Done, parsed %d agencies, %d stops, %d routes, %d trips, %d fare attributes\n\n",
len(feed.Agencies), len(feed.Stops), len(feed.Routes), len(feed.Trips), len(feed.FareAttributes))for k, v := range feed.Stops {
fmt.Printf("[%s] %s (@ %f,%f)\n", k, v.Name, v.Lat, v.Lon)
}
}
```#### Output
```
Done, parsed 1 agencies, 9 stops, 5 routes, 11 trips, 2 fare attributes[BULLFROG] Bullfrog (Demo) (@ 36.881081,-116.817970)
[NADAV] North Ave / D Ave N (Demo) (@ 36.914894,-116.768211)
[NANAA] North Ave / N A Ave (Demo) (@ 36.914944,-116.761475)
[AMV] Amargosa Valley (Demo) (@ 36.641495,-116.400940)
[FUR_CREEK_RES] Furnace Creek Resort (Demo) (@ 36.425289,-117.133163)
[BEATTY_AIRPORT] Nye County Airport (Demo) (@ 36.868446,-116.784584)
[STAGECOACH] Stagecoach Hotel & Casino (Demo) (@ 36.915684,-116.751678)
[DADAN] Doing Ave / D Ave N (Demo) (@ 36.909489,-116.768242)
[EMSI] E Main St / S Irving St (Demo) (@ 36.905697,-116.762177)
```## *Known restrictions
Validation may not be 100% complete. Tests are missing.
## License
GPL v2, see LICENSE