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

Distinct coach from bus when reading in GTFS data and in GTFS GraphQL API #6171

Merged
merged 8 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -231,7 +231,7 @@ void carHail() {
@Test
void carHailWithTransit() {
var modeSet = new QualifiedModeSet("CAR_HAIL,BUS,RAIL");
assertEquals(Set.of(COACH, BUS, RAIL), Set.copyOf(modeSet.getTransitModes()));
assertEquals(Set.of(BUS, RAIL), Set.copyOf(modeSet.getTransitModes()));

assertEquals(WALK, modeSet.getRequestModes().directMode);
assertEquals(CAR_HAILING, modeSet.getRequestModes().accessMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Collection;
import java.util.List;
import org.opentripplanner.framework.application.OTPFeature;
miklcct marked this conversation as resolved.
Show resolved Hide resolved
import org.opentripplanner.transit.model.basic.TransitMode;

public enum ApiRequestMode {
Expand All @@ -12,7 +13,8 @@ public enum ApiRequestMode {
TRAM(TransitMode.TRAM),
SUBWAY(TransitMode.SUBWAY),
RAIL(TransitMode.RAIL),
BUS(TransitMode.BUS, TransitMode.COACH),
BUS(TransitMode.BUS),
COACH(TransitMode.COACH),
miklcct marked this conversation as resolved.
Show resolved Hide resolved
FERRY(TransitMode.FERRY),
CABLE_CAR(TransitMode.CABLE_CAR),
GONDOLA(TransitMode.GONDOLA),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.gtfs.mapping;

import org.opentripplanner.framework.application.OTPFeature;
miklcct marked this conversation as resolved.
Show resolved Hide resolved
import org.opentripplanner.transit.model.basic.TransitMode;

public class TransitModeMapper {
Expand All @@ -20,7 +21,7 @@ public static TransitMode mapMode(int routeType) {
// Railway Service
return TransitMode.RAIL;
} else if (routeType >= 200 && routeType < 300) { //Coach Service
return TransitMode.BUS;
return TransitMode.COACH;
} else if (routeType >= 300 && routeType < 500) { //Suburban Railway Service and Urban Railway service
if (routeType >= 401 && routeType <= 402) {
return TransitMode.SUBWAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,15 @@ static Stream<Arguments> transportModesCases() {
of(List.of(mode("BICYCLE")), "[ExcludeAllTransitFilter{}]"),
of(
List.of(mode("BUS")),
"[TransitFilterRequest{select: [SelectRequest{transportModes: [BUS]}]}]"
),
of(
List.of(mode("BUS"), mode("COACH")),
"[TransitFilterRequest{select: [SelectRequest{transportModes: [BUS, COACH]}]}]"
),
of(
List.of(mode("BUS"), mode("MONORAIL")),
"[TransitFilterRequest{select: [SelectRequest{transportModes: [BUS, COACH, MONORAIL]}]}]"
"[TransitFilterRequest{select: [SelectRequest{transportModes: [BUS, MONORAIL]}]}]"
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.COACH;
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;
Expand All @@ -16,9 +17,11 @@
import static org.opentripplanner.transit.model.basic.TransitMode.TROLLEYBUS;

import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
miklcct marked this conversation as resolved.
Show resolved Hide resolved
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.opentripplanner.framework.application.OTPFeature;
miklcct marked this conversation as resolved.
Show resolved Hide resolved
import org.opentripplanner.transit.model.basic.TransitMode;

class TransitModeMapperTest {
Expand All @@ -42,6 +45,8 @@ static Stream<Arguments> testCases() {
// https://groups.google.com/g/gtfs-changes/c/keT5rTPS7Y0/m/71uMz2l6ke0J?pli=1
Arguments.of(100, RAIL),
Arguments.of(199, RAIL),
Arguments.of(200, COACH),
Arguments.of(299, COACH),
Arguments.of(400, RAIL),
Arguments.of(401, SUBWAY),
Arguments.of(402, SUBWAY),
Expand Down
Loading