transitland-lib
is a library and command-line tool for reading, writing, and processing transit data in GTFS and related formats. The library is structured as a set of data sources, filters, and transformations that can be mixed together in a variety of ways to create processing pipelines. The library supports the DMFR format to describe feed resources.
- Installation
- Usage as a CLI tool
- Usage as a library
- Database migrations
- Usage as a Web Service
- Included Readers and Writers
- Development
- Licenses
The transitland
binaries for Linux and macOS are attached to each release.
The transitland
binary can be installed using homebrew. The executable is code-signed and notarized.
brew install interline-io/transitland-lib/transitland-lib
go get github.com/interline-io/transitland-lib/cmd/transitland
This package uses Go Modules and will also install required dependencies.
Main dependencies:
twpayne/go-geom
jmoiron/sqlx
Masterminds/squirrel
jackc/pgx
mattn/go-sqlite3
(requires CGO)
The main subcommands are:
- transitland copy - Copy performs a basic copy from a reader to a writer.
- transitland diff - Calculate difference between two feeds, writing output in a GTFS-like format
- transitland dmfr-format - Lint DMFR files
- transitland dmfr-lint - Format a DMFR file
- transitland extract - Extract a subset of a GTFS feed
- transitland fetch - Fetch GTFS data and create feed versions
- transitland import - Import feed versions
- transitland merge - Merge multiple GTFS feeds
- transitland sync - Sync DMFR files to database
- transitland unimport - Unimport feed versions
- transitland validate - Validate a GTFS feed
Note: as of v0.17, we moved from Go standard library flags
to Cobra's pflags
; this is a breaking change in that single-dash (-flag
) command flags are no longer supported, only double-dash (--flag
).
See library examples.
Migrations are supported for PostgreSQL, using the schema files in internal/schema/postgres/migrations
. These files can be read and applied using golang-migrate, which will store the most recently applied migration version in schema_migrations
. See the bootstrap.sh
script in that directory for an example, as well as details on how to import Natural Earth data files for associating agencies with places.
SQLite database are intended to be short-lived. They can be created on an as needed basis by passing the -create
flag to some commands that accept a writer. They use a single executable schema, defined in internal/schema/sqlite.sql
.
See transitland-server documentation.
Target | Module | Supports Read | Supports Write |
---|---|---|---|
CSV | tlcsv |
✅ | ✅ |
SQLite | tldb |
✅ | ✅ |
PostgreSQL (with PostGIS) | tldb |
✅ | ✅ |
We welcome the addition of more readers and writers.
transitland-lib
follows Go coding conventions.
GitHub Actions runs all tests, stores code coverage reports as artifacts, and prepares releases.
Releases follow Semantic Versioning conventions.
To cut a new release:
- Run
go generate ./...
to update auto-generated documentation. - Create a GitHub release. This will create a tag and GitHub Actions will create & attach code-signed binaries.
- Download the files from the release, and update the homebrew formula with the updated sha256 hashes and version tag.
transitland-lib
is released under a "dual license" model: