Transitous Documentation
repository·main·Indexed 20 days ago
https://github.com/public-transport/transitousA community-driven, provider-neutral international public transport routing service using open GTFS and GTFS-RT data feeds. The project includes a CLI for fetching and post-processing transit data (GTFS, GBFS, NETEX) via fetch.py, a MOTIS configuration generator, and tools for GTFS cleaning and validation. It supports multiple source types including Transitland Atlas, Mobility Database, HTTP, and FTP.
What's inside Transitous
- Transitous is a community-run, provider-neutral international public transport routing service. It aims to provide free, privacy-focused routing that uses openly available GTFS/GTFS-RT feeds and FOSS routing engines, operating without regard to national borders.
Timetable data sources for Great Britain
mainTimetable data for Great Britain is provided by Aubin MaaS Limited and includes the following components:
- Bus Data: Data from the Department for Transport, Bus Open Data Service (guidance/requirements).
- Rail Data: Converted National Rail timetable information powered by National Rail Enquiries (terms).
- Location Data: Derived from OpenStreetMap under the ODbL Licence (copyright).
Real-Time data sources for Great Britain
mainReal-time information for Great Britain is based on National Rail timetable information powered by National Rail Enquiries (terms).Set up the Transitous website for development
mainTo run the Transitous website locally for development, ensure you have the hugo (extended version) and npm installed.
Follow these steps:
- Initialize submodules to ensure all dependencies are present.
- Install npm dependencies.
- Start the development server.
Note: Hugo content rebuilds automatically, but if you modify PureScript files, you must restart the process to trigger a rebuild.
git submodule update --init --checkout npm install npm run startHow to add a region to Transitous
mainTo contribute data or add a new region to the Transitous routing service, refer to the official documentation on the Project Website: https://transitous.org/doc/#adding-a-region.Build release versions of the website
mainTo generate a production-ready release build of the website, run the release script. The generated static files will be placed in the
public/directory.npm run releaseHow GTFS feed validity is determined
mainTransitous validates GTFS feeds to ensure they are not expired or set for a future date. The
check_feed_timeframe_validfunction uses the following logic:- Timezone Detection: It attempts to find
agency_timezonein theagency.txtfile within the GTFS zip. - Validity Check:
FeedValidity.IN_FUTURE: If thefeed_start_date(fromfeed_info.txt) is in the future, the feed is considered not yet valid. If a feed is in the future, Transitous will skip the update and keep the old version.FeedValidity.EXPIRED: If the feed's end date (checked viafeed_info.txt,calendar.txt, orcalendar_dates.txt) has passed, the feed is considered expired. Ifextend_calendaris not enabled in the source configuration, an error is raised.
- Timezone Detection: It attempts to find
HTTP Source download behavior and TLS handling
mainWhen downloading from an
HttpSource, thedownload_http_sourcefunction follows these rules:- URL Priority: It tries URLs in this order:
url_override$\rightarrow$url$\rightarrow$cache_url. - TLS/SSL: If
source.options.ignore_tls_errorsis set totrue, it uses aLenientCipherAdapterwhich setscert_reqs=ssl.CERT_NONEand a lower security level (@SECLEVEL=1) to allow connection to servers with problematic certificates. - Conditional Downloads: It uses
If-Modified-Sinceheaders and checks thelast-modifiedserver header against the local file's modification time to avoid redundant downloads. - Embedded ZIPs: If the URL contains a
#followed by a path (e.g.,http://example.com/data.zip#inner.zip), it treats the content after the#as a specific file to extract from the downloaded ZIP.
- URL Priority: It tries URLs in this order:
Configure Source options in Transitous
mainWhen defining a data source in Transitous, you can use several configuration keys to control how GTFS data is processed, fetched, and cleaned. The
Sourceobject (and its specialized subclasses) supports the following configuration parameters:General Processing
fix: Boolean. Whether to apply fixes to the data.use-gtfsclean: Boolean. Whether to use GTFS cleaning logic (defaults totrue).fix-csv-quotes: Boolean. Whether to fix CSV quoting issues.spec: String. The data specification (defaults to"gtfs").skip: Boolean. Whether to skip this source.skip-reason: String. The reason for skipping the source.function: String (optional). A specific function to run.script: String (optional). A specific script to run.drop-too-fast-trips: Boolean. Whether to drop trips that are calculated to be too fast (defaults totrue).drop-shapes: Boolean. Whether to drop shapes (defaults tofalse).drop-agency-names: List of strings. Agency names to drop.keep-agency-names: List of strings. Agency names to keep.keep-additional-fields: Boolean. Whether to keep additional fields (defaults totrue).extend-calendar: Boolean. Whether to extend the calendar.default-timezone: String (optional). The default timezone for the source.use-feed-proxy: Boolean. Whether to use a feed proxy.enable-crowd-sourced-realtime: Boolean. Whether to enable crowd-sourced realtime data.
Display Name Options
Nested under
display-name-options, you can control how names are mapped:copy-trip-names-matching: String. Pattern for copying trip names.keep-route-names-matching: String. Pattern for keeping route names.move-headsigns-matching: String. Pattern for moving headsigns.
License Information
Nested under
license:spdx-identifier: String. The SPDX license ID.url: String. URL to the license.attribution-text: String. Text for attribution.publisher: String. The license publisher.publisher-url: String. URL for the publisher.
Configure GTFS post-processing with gtfsclean
mainWhen fetching GTFS feeds, the
Fetcher.postprocessmethod can apply various transformations using thegtfscleantool. These options are controlled via theSourceobject in your metadata:fix_csv_quotes: Runs./src/fix-csv-quotes.pyon the data.use_gtfsclean: Enables thegtfscleancommand with several sub-options:fix: Applies--fix.drop_too_fast_trips: Applies--drop-too-fast-trips.drop_shapes: Applies--drop-shapes.drop_agency_names: A list of agency names to drop using--drop-agency-names.keep_agency_names: A list of agency names to keep using--keep-agency-names.display_name_options:copy_trip_names_matching: Uses--copy-trip-names-matching.keep_route_names_matching: Uses--keep-route-names-matching.move_headsigns_matching: Uses--move-headsigns-matching.
keep_additional_fields: Applies--keep-additional-fields.
Validate SPDX license identifiers
mainTransitous requires valid SPDX license identifiers for feeds. Thevalidate_spdx_identifierfunction ensures that thespdx_identifierprovided in the source metadata is a valid expression that can be parsed by thelicense_expressionlibrary.Supported Source Types
mainTransitous supports several source types, which determine how data is retrieved. When defining a source in your configuration, set the
typefield to one of the following:transitland-atlas: Uses the Transitland Atlas API. Requirestransitland-atlas-id. Can includeapi-keyandurl-override.mobility-database: Uses the Mobility Database. Requiresmdb-id. Can includeurl-override.http: Fetches data from a specificurl. Supportshttp-optionsandcache-url.ftp: Fetches data from anftpURL.url: Fetches data from aurl. Supportsheadersandderive-trip-updates.