Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
Browse files Browse the repository at this point in the history
…023-09-21
  • Loading branch information
leonardehrenfried committed Sep 25, 2023
2 parents 10dbb7b + be789e3 commit 79d1b62
Show file tree
Hide file tree
Showing 34 changed files with 591 additions and 191 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ src/ext/resources/reportapi/report.csv

streetGraph.obj
graph.obj
# IntelliJ creates these pid files when you attach the debugger to tests
.attach_pid*

smoke-tests/*.jar
smoke-tests/**/*.obj
Expand Down
3 changes: 3 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Gracefully handle nullable fields in TransitAlert [#5349](https://github.com/opentripplanner/OpenTripPlanner/pull/5349)
- Remove transit with higher cost than best on-street itinerary filter [#5222](https://github.com/opentripplanner/OpenTripPlanner/pull/5222)
- Remove banDiscouragedCycling and banDiscouragedWalking [#5341](https://github.com/opentripplanner/OpenTripPlanner/pull/5341)
- Fix rental scooter access [#5361](https://github.com/opentripplanner/OpenTripPlanner/pull/5361)
- De-duplicate stops returned by `stopsByRadius` [#5366](https://github.com/opentripplanner/OpenTripPlanner/pull/5366)
- Fix value mapping for bikesAllowed in GTFS GraphQL API [#5368](https://github.com/opentripplanner/OpenTripPlanner/pull/5368)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.4.0 (2023-09-13)
Expand Down
1 change: 1 addition & 0 deletions docs/GraphQL-Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GraphQL query in the left hand panel of the page:
name
}
mode
bikesAllowed
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
properly if some input files are missing a terminating newline) -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.opentripplanner.ext.gtfsgraphqlapi.mapping;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Arrays;
import org.junit.jupiter.api.Test;
import org.opentripplanner.transit.model.network.BikeAccess;

class BikesAllowedMapperTest {

@Test
void mapping() {
Arrays
.stream(BikeAccess.values())
.filter(ba -> ba != BikeAccess.UNKNOWN)
.forEach(d -> {
var mapped = BikesAllowedMapper.map(d);
assertEquals(d.toString(), mapped.toString());
});
}
}
42 changes: 28 additions & 14 deletions src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "CARPOOL"
"mode" : "CARPOOL",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for SUBWAY",
Expand All @@ -19,7 +20,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "SUBWAY"
"mode" : "SUBWAY",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for BUS",
Expand All @@ -29,7 +31,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "BUS"
"mode" : "BUS",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for FERRY",
Expand All @@ -39,7 +42,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "FERRY"
"mode" : "FERRY",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for COACH",
Expand All @@ -49,7 +53,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "COACH"
"mode" : "COACH",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for TRAM",
Expand All @@ -59,7 +64,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "TRAM"
"mode" : "TRAM",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for CABLE_CAR",
Expand All @@ -69,7 +75,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "CABLE_CAR"
"mode" : "CABLE_CAR",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for FUNICULAR",
Expand All @@ -79,7 +86,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "FUNICULAR"
"mode" : "FUNICULAR",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for RAIL",
Expand All @@ -89,7 +97,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "RAIL"
"mode" : "RAIL",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for MONORAIL",
Expand All @@ -99,7 +108,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "MONORAIL"
"mode" : "MONORAIL",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for GONDOLA",
Expand All @@ -109,7 +119,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "GONDOLA"
"mode" : "GONDOLA",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for TROLLEYBUS",
Expand All @@ -119,7 +130,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "TROLLEYBUS"
"mode" : "TROLLEYBUS",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for AIRPLANE",
Expand All @@ -129,7 +141,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "AIRPLANE"
"mode" : "AIRPLANE",
"bikesAllowed" : "NO_INFORMATION"
},
{
"longName" : "Long name for TAXI",
Expand All @@ -139,7 +152,8 @@
"gtfsId" : "F:A1",
"name" : "Agency Test"
},
"mode" : "TAXI"
"mode" : "TAXI",
"bikesAllowed" : "NO_INFORMATION"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
name
}
mode
bikesAllowed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.framework.lang.PredicateUtils;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.site.StopLocationsGroup;
import org.opentripplanner.transit.service.TransitService;
Expand Down Expand Up @@ -44,7 +41,7 @@ Stream<StopCluster> generateStopClusters(
.filter(sl -> sl.getName() != null)
// if they are very close to each other and have the same name, only one is chosen (at random)
.filter(
distinctByKey(sl ->
PredicateUtils.distinctByKey(sl ->
new DeduplicationKey(sl.getName(), sl.getCoordinate().roundToApproximate10m())
)
)
Expand Down Expand Up @@ -84,10 +81,5 @@ private static StopCluster.Coordinate toCoordinate(WgsCoordinate c) {
return new StopCluster.Coordinate(c.latitude(), c.longitude());
}

private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = ConcurrentHashMap.newKeySet();
return t -> seen.add(keyExtractor.apply(t));
}

private record DeduplicationKey(I18NString name, WgsCoordinate coordinate) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLQueryTypeStopsByRadiusArgs;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.RouteRequestMapper;
import org.opentripplanner.framework.time.ServiceDateUtils;
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
Expand Down Expand Up @@ -721,7 +722,7 @@ public DataFetcher<Iterable<Object>> stopsByBbox() {
public DataFetcher<Connection<NearbyStop>> stopsByRadius() {
return environment -> {
// TODO implement rest of the args
GraphQLTypes.GraphQLQueryTypeStopsByRadiusArgs args = new GraphQLTypes.GraphQLQueryTypeStopsByRadiusArgs(
GraphQLQueryTypeStopsByRadiusArgs args = new GraphQLQueryTypeStopsByRadiusArgs(
environment.getArguments()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper;
import org.opentripplanner.routing.alertpatch.EntitySelector;
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.routing.services.TransitAlertService;
Expand Down Expand Up @@ -131,13 +133,8 @@ public DataFetcher<Iterable<TransitAlert>> alerts() {
}

@Override
public DataFetcher<String> bikesAllowed() {
return environment ->
switch (getSource(environment).getBikesAllowed()) {
case UNKNOWN -> "NO_INFORMATION";
case ALLOWED -> "POSSIBLE";
case NOT_ALLOWED -> "NOT_POSSIBLE";
};
public DataFetcher<GraphQLBikesAllowed> bikesAllowed() {
return environment -> BikesAllowedMapper.map(getSource(environment).getBikesAllowed());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding;
import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper;
import org.opentripplanner.framework.time.ServiceDateUtils;
import org.opentripplanner.model.Timetable;
import org.opentripplanner.model.TripTimeOnDate;
Expand Down Expand Up @@ -165,13 +167,8 @@ public DataFetcher<TripTimeOnDate> arrivalStoptime() {
}

@Override
public DataFetcher<String> bikesAllowed() {
return environment ->
switch (getSource(environment).getBikesAllowed()) {
case UNKNOWN -> "NO_INFORMATION";
case ALLOWED -> "POSSIBLE";
case NOT_ALLOWED -> "NOT_POSSIBLE";
};
public DataFetcher<GraphQLBikesAllowed> bikesAllowed() {
return environment -> BikesAllowedMapper.map(getSource(environment).getBikesAllowed());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertCauseType;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertEffectType;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertSeverityLevelType;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLInputField;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRelativeDirection;
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRoutingErrorCode;
Expand Down Expand Up @@ -309,9 +310,12 @@ public interface GraphQLDefaultFareProduct {
}

/**
* Departure row is a location, which lists departures of a certain pattern from a
* stop. Departure rows are identified with the pattern, so querying departure rows
* will return only departures from one stop per pattern
* Departure row is a combination of a pattern and a stop of that pattern.
*
* They are de-duplicated so for each pattern there will only be a single departure row.
*
* This is useful if you want to show a list of stop/pattern combinations but want each pattern to be
* listed only once.
*/
public interface GraphQLDepartureRow {
public DataFetcher<graphql.relay.Relay.ResolvedGlobalId> id();
Expand Down Expand Up @@ -789,7 +793,7 @@ public interface GraphQLRoute {

public DataFetcher<Iterable<TransitAlert>> alerts();

public DataFetcher<String> bikesAllowed();
public DataFetcher<GraphQLBikesAllowed> bikesAllowed();

public DataFetcher<String> color();

Expand Down Expand Up @@ -1015,7 +1019,7 @@ public interface GraphQLTrip {

public DataFetcher<TripTimeOnDate> arrivalStoptime();

public DataFetcher<String> bikesAllowed();
public DataFetcher<GraphQLBikesAllowed> bikesAllowed();

public DataFetcher<String> blockId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ config:
VehicleRentalStation: org.opentripplanner.service.vehiclerental.model.VehicleRentalStation#VehicleRentalStation
RentalVehicle: org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle#VehicleRentalVehicle
VehicleRentalUris: org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris#VehicleRentalStationUris
BikesAllowed: String
BikesAllowed: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed#GraphQLBikesAllowed
BookingInfo: org.opentripplanner.model.BookingInfo
BookingTime: org.opentripplanner.model.BookingTime
CarPark: org.opentripplanner.routing.vehicle_parking.VehicleParking#VehicleParking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"@graphql-codegen/cli": "4.0.1",
"@graphql-codegen/java": "3.3.6",
"@graphql-codegen/java-resolvers": "2.3.6",
"graphql": "16.7.1"
"graphql": "16.8.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2051,10 +2051,10 @@ graphql-ws@^5.14.0:
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.14.0.tgz#766f249f3974fc2c48fae0d1fb20c2c4c79cd591"
integrity sha512-itrUTQZP/TgswR4GSSYuwWUzrE/w5GhbwM2GX3ic2U7aw33jgEsayfIlvaj7/GcIvZgNMzsPTrE5hqPuFUiE5g==

graphql@16.7.1:
version "16.7.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.7.1.tgz#11475b74a7bff2aefd4691df52a0eca0abd9b642"
integrity sha512-DRYR9tf+UGU0KOsMcKAlXeFfX89UiiIZ0dRU3mR0yJfu6OjZqUcp68NnFLnqQU5RexygFoDy1EW+ccOYcPfmHg==
graphql@16.8.1:
version "16.8.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07"
integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==

has-flag@^3.0.0:
version "3.0.0"
Expand Down
Loading

0 comments on commit 79d1b62

Please sign in to comment.