Skip to content

Commit

Permalink
support TPEG-PTI route_type scheme 📝💚
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Dec 14, 2022
1 parent 66cbacd commit 81d3ba8
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
feed-import-glob:
required: true
type: string
feed-import-flags:
required: true
type: string

jobs:
smoke-test:
Expand Down Expand Up @@ -71,7 +74,7 @@ jobs:
${{ inputs.feed-download-cmd }}
${{ inputs.feed-extract-cmd }}
# import GTFS
./cli.js -d -- ${{ inputs.feed-import-glob }} | sponge | psql -b
./cli.js -d ${{ inputs.feed-import-flags }} -- ${{ inputs.feed-import-glob }} | sponge | psql -b
# test if data has been imported
psql --csv -c 'SELECT * FROM service_days LIMIT 1' | wc -l
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
feed-name: VBB
feed-download-cmd: 'wget -nv --compression auto -r --no-parent --no-directories -R .csv.gz -P gtfs -N "https://vbb-gtfs.jannisr.de/latest/"'
feed-extract-cmd: ''
feed-import-flags: ''
feed-import-glob: 'gtfs/*.csv'
smoke-test-entur:
name: run Entur smoke test
Expand All @@ -21,4 +22,5 @@ jobs:
feed-name: Entur
feed-download-cmd: 'wget -nv "https://storage.googleapis.com/marduk-production/outbound/gtfs/rb_norway-aggregated-gtfs.zip" -O gtfs.zip'
feed-extract-cmd: 'unzip -d gtfs gtfs.zip'
feed-import-flags: '--route-types-scheme tpeg-pti'
feed-import-glob: 'gtfs/*.txt'
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Options:
--route-types-scheme Set of route_type values to support.
- basic: core route types in the GTFS spec
- google-extended: Extended GTFS Route Types [1]
- tpeg-pti: proposed TPEG-PTI-based route types [2]
Default: google-extended
--trips-without-shape-id Don't require trips.txt items to have a shape_id.
--routes-without-agency-id Don't require routes.txt items to have an agency_id.
Expand All @@ -79,6 +80,7 @@ Examples:
gtfs-to-sql -u -- some-gtfs/*.txt | gzip >gtfs.sql # generate a gzipped SQL dump
[1] https://developers.google.com/transit/gtfs/reference/extended-route-types
[2] https://groups.google.com/g/gtfs-changes/c/keT5rTPS7Y0/m/71uMz2l6ke0J
\n`)
process.exit(0)
}
Expand Down
145 changes: 145 additions & 0 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,154 @@ const googleExtendedRouteTypes = [
['1702', 'Horse-drawn Carriage', null],
]

// proposed TPEG-PTI-derived route types
// https://groups.google.com/g/gtfs-changes/c/keT5rTPS7Y0/m/71uMz2l6ke0J
const tpegPtiExtendedRouteTypes = [
['100', 'Railway Service'],
['101', 'High Speed Rail Service'],
['102', 'Long Distance Trains'],
['103', 'Inter Regional Rail Service'],
['104', 'Car Transport Rail Service'],
['105', 'Sleeper Rail Service'],
['106', 'Regional Rail Service'],
['107', 'Tourist Railway Service'],
['108', 'Rail Shuttle (Within Complex)'],
['109', 'Suburban Railway'],
['110', 'Replacement Rail Service'],
['111', 'Special Rail Service'],
['112', 'Lorry Transport Rail Service'],
['113', 'All Rail Services'],
['114', 'Cross-Country Rail Service'],
['115', 'Vehicle Transport Rail Service'],
['116', 'Rack and Pinion Railway'],
['117', 'Additional Rail Service'],

['200', 'Coach Service'],
['201', 'International Coach Service'],
['202', 'National Coach Service'],
['203', 'Shuttle Coach Service'],
['204', 'Regional Coach Service'],
['205', 'Special Coach Service'],
['206', 'Sightseeing Coach Service'],
['207', 'Tourist Coach Service'],
['208', 'Commuter Coach Service'],
['209', 'All Coach Services'],

['300', 'Suburban Railway Service'],

['400', 'Urban Railway Service'],
['401', 'Metro Service'],
['402', 'Underground Service'],
['403', 'Urban Railway Service'],
['404', 'All Urban Railway Services'],

['500', 'Metro Service'],

['600', 'Underground Service'],

['700', 'Bus Service'],
['701', 'Regional Bus Service'],
['702', 'Express Bus Service'],
['703', 'Stopping Bus Service'],
['704', 'Local Bus Service'],
['705', 'Night Bus Service'],
['706', 'Post Bus Service'],
['707', 'Special Needs Bus'],
['708', 'Mobility Bus Service'],
['709', 'Mobility Bus for Registered Disabled'],
['710', 'Sightseeing Bus'],
['711', 'Shuttle Bus'],
['712', 'School Bus'],
['713', 'School and Public Service Bus'],
['714', 'Rail Replacement Bus Service'],
['715', 'Demand and Response Bus Service'],
['716', 'All Bus Services'],

['800', 'Trolleybus Service'],

['900', 'Tram Service'],
['901', 'City Tram Service'],
['902', 'Local Tram Service'],
['903', 'Regional Tram Service'],
['904', 'Sightseeing Tram Service'],
['905', 'Shuttle Tram Service'],
['906', 'All Tram Services'],

['1000', 'Water Transport Service'],
['1001', 'International Car Ferry Service'],
['1002', 'National Car Ferry Service'],
['1003', 'Regional Car Ferry Service'],
['1004', 'Local Car Ferry Service'],
['1005', 'International Passenger Ferry Service'],
['1006', 'National Passenger Ferry Service'],
['1007', 'Regional Passenger Ferry Service'],
['1008', 'Local Passenger Ferry Service'],
['1009', 'Post Boat Service'],
['1010', 'Train Ferry Service'],
['1011', 'Road-Link Ferry Service'],
['1012', 'Airport-Link Ferry Service'],
['1013', 'Car High-Speed Ferry Service'],
['1014', 'Passenger High-Speed Ferry Service'],
['1015', 'Sightseeing Boat Service'],
['1016', 'School Boat'],
['1017', 'Cable-Drawn Boat Service'],
['1018', 'River Bus Service'],
['1019', 'Scheduled Ferry Service'],
['1020', 'Shuttle Ferry Service'],
['1021', 'All Water Transport Services'],

['1100', 'Air Service'],
['1101', 'International Air Service'],
['1102', 'Domestic Air Service'],
['1103', 'Intercontinental Air Service'],
['1104', 'Domestic Scheduled Air Service'],
['1105', 'Shuttle Air Service'],
['1106', 'Intercontinental Charter Air Service'],
['1107', 'International Charter Air Service'],
['1108', 'Round-Trip Charter Air Service'],
['1109', 'Sightseeing Air Service'],
['1110', 'Helicopter Air Service'],
['1111', 'Domestic Charter Air Service'],
['1112', 'Schengen-Area Air Service'],
['1113', 'Airship Service'],
['1114', 'All Air Services'],

['1200', 'Ferry Service'],

['1300', 'Telecabin Service'],
['1301', 'Telecabin Service'],
['1302', 'Cable Car Service'],
['1303', 'Elevator Service'],
['1304', 'Chair Lift Service'],
['1305', 'Drag Lift Service'],
['1306', 'Small Telecabin Service'],
['1307', 'All Telecabin Services'],

['1400', 'Funicular Service'],
['1401', 'Funicular Service'],
['1402', 'All Funicular Service'],

['1500', 'Taxi Service'],
['1501', 'Communal Taxi Service'],
['1502', 'Water Taxi Service'],
['1503', 'Rail Taxi Service'],
['1504', 'Bike Taxi Service'],
['1505', 'Licensed Taxi Service'],
['1506', 'Private Hire Service Vehicle'],
['1507', 'All Taxi Services'],

['1600', 'Self Drive'],
['1601', 'Hire Car'],
['1602', 'Hire Van'],
['1603', 'Hire Motorbike'],
['1604', 'Hire Cycle'],
['1605', 'All Self-Drive Vehicles'],
]

const routeTypesSchemes = Object.assign(Object.create(null), {
'basic': [],
'google-extended': googleExtendedRouteTypes,
'tpeg-pti': tpegPtiExtendedRouteTypes,
})

// https://developers.google.com/transit/gtfs/reference#routestxt
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Options:
--route-types-scheme Set of route_type values to support.
- basic: core route types in the GTFS spec
- google-extended: Extended GTFS Route Types [1]
- tpeg-pti: proposed TPEG-PTI-based route types [2]
Default: google-extended
--trips-without-shape-id Don't require trips.txt items to have a shape_id.
--routes-without-agency-id Don't require routes.txt items to have an agency_id.
Expand All @@ -161,6 +162,7 @@ Examples:
gtfs-to-sql -u -- some-gtfs/*.txt | gzip >gtfs.sql # generate a gzipped SQL dump
[1] https://developers.google.com/transit/gtfs/reference/extended-route-types
[2] https://groups.google.com/g/gtfs-changes/c/keT5rTPS7Y0/m/71uMz2l6ke0J
```

Some notable limitations mentioned in the [PostgreSQL 14 documentation on date/time types](https://www.postgresql.org/docs/14/datatype-datetime.html):
Expand Down

0 comments on commit 81d3ba8

Please sign in to comment.