Skip to content

GTFS-Flex: database, copier, validation support#527

Merged
irees merged 17 commits intomainfrom
flex-db
Dec 4, 2025
Merged

GTFS-Flex: database, copier, validation support#527
irees merged 17 commits intomainfrom
flex-db

Conversation

@drewda
Copy link
Copy Markdown
Member

@drewda drewda commented Nov 22, 2025

@irees irees marked this pull request as ready for review December 4, 2025 00:17
Copilot AI review requested due to automatic review settings December 4, 2025 00:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements comprehensive support for the GTFS-Flex specification, enabling handling of flexible transit services (demand-responsive, deviated route, etc.). The implementation covers the officially adopted GTFS-Flex spec and includes two proposed columns for future compatibility. The changes span database schema, entity definitions, CSV/GeoJSON parsing, and validation rules.

Key Changes

  • Added four new GTFS-Flex entity types: Location, LocationGroup, LocationGroupStop, and BookingRule with full database schema support
  • Extended StopTime entity with 10 new GTFS-Flex fields including time windows, booking rules, and duration calculation parameters
  • Implemented GeoJSON reader for locations.geojson file (GTFS-Flex zones use GeoJSON instead of CSV)
  • Added comprehensive validation rules for GTFS-Flex: stop location type checking, location group emptiness, geography ID uniqueness, and enhanced stop time sequence validation supporting time windows

Reviewed changes

Copilot reviewed 44 out of 45 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gtfs/stop_time.go Extended StopTime with 10 GTFS-Flex fields, implemented comprehensive conditional validation for time windows vs fixed times, mutual exclusion of location identifiers
gtfs/location_group_stop.go New entity for associating stops with location groups
tt/key.go Added Set() method to Key type to validate non-empty values on assignment
tlcsv/geojson.go Generic GeoJSON reader with feature parser pattern for extensibility
tlcsv/geojson_test.go Comprehensive tests for GeoJSON reading including Polygon and MultiPolygon geometries
tlcsv/reader.go Added Locations() method that reads from locations.geojson
tldb/reader.go Added reader methods for 4 new GTFS-Flex entity types
rules/stop_time_sequence.go Enhanced validation to handle GTFS-Flex time windows, skips time progression checks for flex stops
rules/stop_time_sequence_test.go Completely rewritten with 30+ test cases covering scheduled, flex, and mixed trips
rules/flex_*.go Five new validation rule files for GTFS-Flex constraints
schema/sqlite/sqlite.sql Added 4 new tables and 10 new columns to stop_times with proper indexing
schema/postgres/migrations/*.pgsql PostgreSQL migration script mirroring SQLite schema changes
testdata/gtfs-external/ctran-flex.zip Real-world GTFS-Flex feed for integration testing
testdata/gtfs-examples/bad-entities/*.txt Test data files for validation error cases
validator/validator.go Integrated FlexLocationGroupEmptyCheck at validation level 1
internal/testutil/*.go Added ParseExpectErrors helper and updated minimal feed to use tt.NewKey

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@irees irees merged commit 1ad679c into main Dec 4, 2025
6 checks passed
@irees irees deleted the flex-db branch December 4, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add support to transitland-lib for GTFS-Flex

3 participants