Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret GTFS extended route types 801-899 also as trolleybus service #6170

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static TransitMode mapMode(int routeType) {
}

/* TPEG Extension https://groups.google.com/d/msg/gtfs-changes/keT5rTPS7Y0/71uMz2l6ke0J */
if (routeType >= 100 && routeType < 200) { // Railway Service
if (routeType >= 100 && routeType < 200) {
// Railway Service
return TransitMode.RAIL;
} else if (routeType >= 200 && routeType < 300) { //Coach Service
return TransitMode.BUS;
Expand All @@ -28,36 +29,46 @@ public static TransitMode mapMode(int routeType) {
return TransitMode.MONORAIL;
}
return TransitMode.RAIL;
} else if (routeType >= 500 && routeType < 700) { //Metro Service and Underground Service
} else if (routeType >= 500 && routeType < 700) {
// Metro Service and Underground Service
return TransitMode.SUBWAY;
} else if (routeType >= 700 && routeType < 900) { //Bus Service and Trolleybus service
if (routeType == 800) {
return TransitMode.TROLLEYBUS;
}
} else if (routeType >= 700 && routeType < 800) {
// Bus Service
return TransitMode.BUS;
} else if (routeType >= 900 && routeType < 1000) { //Tram service
} else if (routeType >= 800 && routeType < 900) {
// Trolleybus Service
return TransitMode.TROLLEYBUS;
} else if (routeType >= 900 && routeType < 1000) {
// Tram service
return TransitMode.TRAM;
} else if (routeType >= 1000 && routeType < 1100) { //Water Transport Service
} else if (routeType >= 1000 && routeType < 1100) {
// Water Transport Service
return TransitMode.FERRY;
} else if (routeType >= 1100 && routeType < 1200) { //Air Service
} else if (routeType >= 1100 && routeType < 1200) {
// Air Service
return TransitMode.AIRPLANE;
} else if (routeType >= 1200 && routeType < 1300) { //Ferry Service
} else if (routeType >= 1200 && routeType < 1300) {
// Ferry Service
return TransitMode.FERRY;
} else if (routeType >= 1300 && routeType < 1400) { //Telecabin Service
} else if (routeType >= 1300 && routeType < 1400) {
// Telecabin Service
return TransitMode.GONDOLA;
} else if (routeType >= 1400 && routeType < 1500) { //Funicular Service
} else if (routeType >= 1400 && routeType < 1500) {
// Funicular Service
return TransitMode.FUNICULAR;
} else if (routeType >= 1551 && routeType < 1561) {
// Carpooling, not defined anywhere, so we've chosen this number space
// see https://groups.google.com/g/gtfs-changes/c/keT5rTPS7Y0/m/71uMz2l6ke0J for an effort to
// standardise
return TransitMode.CARPOOL;
} else if (routeType >= 1500 && routeType < 1599) {
//Taxi Service
// Taxi Service
return TransitMode.TAXI;
} else if (routeType >= 1600 && routeType < 1700) { //Self drive
} else if (routeType >= 1600 && routeType < 1700) {
// Self drive
return TransitMode.BUS;
} else if (routeType >= 1700 && routeType < 1800) { //Miscellaneous Service
} else if (routeType >= 1700 && routeType < 1800) {
// Miscellaneous Service
return null;
}
/* Original GTFS route types. Should these be checked before TPEG types? */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package org.opentripplanner.gtfs.mapping;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opentripplanner.transit.model.basic.TransitMode.AIRPLANE;
import static org.opentripplanner.transit.model.basic.TransitMode.BUS;
import static org.opentripplanner.transit.model.basic.TransitMode.CABLE_CAR;
import static org.opentripplanner.transit.model.basic.TransitMode.CARPOOL;
import static org.opentripplanner.transit.model.basic.TransitMode.FERRY;
import static org.opentripplanner.transit.model.basic.TransitMode.FUNICULAR;
import static org.opentripplanner.transit.model.basic.TransitMode.GONDOLA;
import static org.opentripplanner.transit.model.basic.TransitMode.MONORAIL;
import static org.opentripplanner.transit.model.basic.TransitMode.RAIL;
import static org.opentripplanner.transit.model.basic.TransitMode.SUBWAY;
import static org.opentripplanner.transit.model.basic.TransitMode.TAXI;
import static org.opentripplanner.transit.model.basic.TransitMode.TRAM;
import static org.opentripplanner.transit.model.basic.TransitMode.TROLLEYBUS;

import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -14,6 +25,49 @@ class TransitModeMapperTest {

static Stream<Arguments> testCases() {
return Stream.of(
// base GTFS route types
// https://gtfs.org/documentation/schedule/reference/#routestxt
Arguments.of(0, TRAM),
Arguments.of(1, SUBWAY),
Arguments.of(2, RAIL),
Arguments.of(3, BUS),
Arguments.of(4, FERRY),
Arguments.of(5, CABLE_CAR),
Arguments.of(6, GONDOLA),
Arguments.of(7, FUNICULAR),
Arguments.of(11, TROLLEYBUS),
Arguments.of(12, MONORAIL),
// extended route types
// https://developers.google.com/transit/gtfs/reference/extended-route-types
// https://groups.google.com/g/gtfs-changes/c/keT5rTPS7Y0/m/71uMz2l6ke0J?pli=1
Arguments.of(100, RAIL),
Arguments.of(199, RAIL),
Arguments.of(400, RAIL),
Arguments.of(401, SUBWAY),
Arguments.of(402, SUBWAY),
Arguments.of(403, RAIL),
Arguments.of(404, RAIL),
Arguments.of(405, MONORAIL),
Arguments.of(500, SUBWAY),
Arguments.of(599, SUBWAY),
Arguments.of(600, SUBWAY),
Arguments.of(699, SUBWAY),
Arguments.of(700, BUS),
Arguments.of(799, BUS),
Arguments.of(800, TROLLEYBUS),
Arguments.of(899, TROLLEYBUS),
Arguments.of(900, TRAM),
Arguments.of(999, TRAM),
Arguments.of(1000, FERRY),
Arguments.of(1099, FERRY),
Arguments.of(1100, AIRPLANE),
Arguments.of(1199, AIRPLANE),
Arguments.of(1200, FERRY),
Arguments.of(1299, FERRY),
Arguments.of(1300, GONDOLA),
Arguments.of(1399, GONDOLA),
Arguments.of(1400, FUNICULAR),
Arguments.of(1499, FUNICULAR),
Arguments.of(1500, TAXI),
Arguments.of(1510, TAXI),
Arguments.of(1551, CARPOOL),
Expand Down
Loading