Skip to content

Commit

Permalink
Merge branch 'dev-2.x' into StreetEdge-null-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Jan 30, 2025
2 parents 4849d5b + c8fbf02 commit 87bc6b2
Show file tree
Hide file tree
Showing 183 changed files with 7,047 additions and 2,330 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/debug-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
working-directory: client
run: |
npm install
npm run build -- --base https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/${VERSION}/
npm run build -- --base https://www.opentripplanner.org/debug-client-assets/${VERSION}/
npm run coverage
- name: Deploy compiled assets to repo
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
cp otp-shaded/target/otp-shaded-*-SNAPSHOT.jar otp.jar
java -Xmx32G -jar otp.jar --build --save test/performance/${{ matrix.location }}/
- name: Run speed test
- name: Run RAPTOR speed test
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
env:
PERFORMANCE_INFLUX_DB_PASSWORD: ${{ secrets.PERFORMANCE_INFLUX_DB_PASSWORD }}
Expand All @@ -113,3 +113,12 @@ jobs:
with:
name: ${{ matrix.location }}-flight-recorder
path: application/${{ matrix.location }}-speed-test.jfr

- name: Run transfer cache speed test
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
env:
PERFORMANCE_INFLUX_DB_PASSWORD: ${{ secrets.PERFORMANCE_INFLUX_DB_PASSWORD }}
SPEEDTEST_LOCATION: ${{ matrix.location }}
MAVEN_OPTS: "-Xmx50g -Dmaven.repo.local=/home/lenni/.m2/repository/"
run: |
mvn --projects application exec:java -Dexec.mainClass="org.opentripplanner.transit.speed_test.TransferCacheTest" -Dexec.classpathScope=test -Dexec.args="--dir=test/performance/${{ matrix.location }}"
2 changes: 1 addition & 1 deletion application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
<dependency>
<groupId>org.onebusaway</groupId>
<artifactId>onebusaway-gtfs</artifactId>
<version>5.0.0</version>
<version>5.0.2</version>
</dependency>
<!-- Processing is used for the debug GUI (though we could probably use just Java2D) -->
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions application/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2025/01/2025-01-11T19:23/assets/index-D--h-dOg.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2025/01/2025-01-11T19:23/assets/index-BDL0-veX.css">
<script type="module" crossorigin src="https://www.opentripplanner.org/debug-client-assets/2025/01/2025-01-28T11:22/assets/index-BHcP0Ndc.js"></script>
<link rel="stylesheet" crossorigin href="https://www.opentripplanner.org/debug-client-assets/2025/01/2025-01-28T11:22/assets/index-DjMJ6mws.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Set;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.opentripplanner.ext.fares.model.Distance;
import org.opentripplanner.transit.model.basic.Distance;
import org.opentripplanner.ext.fares.model.FareDistance;
import org.opentripplanner.ext.fares.model.FareDistance.LinearDistance;
import org.opentripplanner.ext.fares.model.FareLegRule;
Expand Down Expand Up @@ -331,15 +331,22 @@ class DistanceFares {
List<FareLegRule> distanceRules = List.of(
FareLegRule
.of(DISTANCE_ID, tenKmProduct)
.withFareDistance(new LinearDistance(Distance.ofKilometers(7), Distance.ofKilometers(10)))
.withFareDistance(new LinearDistance(
Distance.ofKilometersBoxed(7d, ignore -> {}).orElse(null),
Distance.ofKilometersBoxed(10d, ignore -> {}).orElse(null)))
.build(),
FareLegRule
.of(DISTANCE_ID, threeKmProduct)
.withFareDistance(new LinearDistance(Distance.ofKilometers(3), Distance.ofKilometers(6)))
.withFareDistance(new LinearDistance(
Distance.ofKilometersBoxed(3d, ignore -> {}).orElse(null),
Distance.ofKilometersBoxed(6d, ignore -> {}).orElse(null)))
.build(),
FareLegRule
.of(DISTANCE_ID, twoKmProduct)
.withFareDistance(new LinearDistance(Distance.ofMeters(0), Distance.ofMeters(2000)))
.withFareDistance(new LinearDistance(
Distance.ofMetersBoxed(0d, ignore -> {}).orElse(null),
Distance.ofMetersBoxed(2000d, ignore -> {}).orElse(null))
)
.build()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,11 @@
import java.util.Map;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
import org.opentripplanner.ext.restapi.model.ApiAbsoluteDirection;
import org.opentripplanner.ext.restapi.model.ApiRelativeDirection;
import org.opentripplanner.ext.restapi.model.ApiVertexType;
import org.opentripplanner.model.plan.AbsoluteDirection;
import org.opentripplanner.model.plan.RelativeDirection;
import org.opentripplanner.model.plan.VertexType;

public class EnumMapperTest {

private static final String MSG =
"Assert that the API enums have the exact same values that " +
"the domain enums of the same type, and that the specialized mapper is mapping all " +
"values. If this assumtion does not hold, create a new test.";

@Test
public void map() {
try {
verifyExactMatch(
AbsoluteDirection.class,
ApiAbsoluteDirection.class,
AbsoluteDirectionMapper::mapAbsoluteDirection
);
verifyExactMatch(
RelativeDirection.class,
ApiRelativeDirection.class,
RelativeDirectionMapper::mapRelativeDirection
);
} catch (RuntimeException ex) {
System.out.println(MSG);
throw ex;
}
}

@Test
public void testVertexTypeMapping() {
verifyExplicitMatch(
Expand Down Expand Up @@ -75,17 +47,4 @@ private <D extends Enum<?>, A extends Enum<?>> void verifyExplicitMatch(
assertTrue(rest.isEmpty());
}

private <D extends Enum<?>, A extends Enum<?>> void verifyExactMatch(
Class<D> domainClass,
Class<A> apiClass,
Function<D, A> mapper
) {
List<A> rest = new ArrayList<>(List.of(apiClass.getEnumConstants()));
for (D it : domainClass.getEnumConstants()) {
A result = mapper.apply(it);
assertEquals(result.name(), it.name());
rest.remove(result);
}
assertTrue(rest.isEmpty());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.opentripplanner.ext.fares.model;

import org.opentripplanner.transit.model.basic.Distance;

/** Represents a distance metric used in distance-based fare computation*/
public sealed interface FareDistance {
/** Represents the number of stops as a distance metric in fare computation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public Route getRouteById(FeedScopedId id) {
return routeById.get(id);
}

public boolean contains(Route route) {
return routeById.containsKey(route.getId());
}

public Collection<Route> getAllFlexRoutes() {
return routeById.values();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private FlexAccessEgress createFlexAccessEgress(
return null;
}

final var finalStateOpt = EdgeTraverser.traverseEdges(afterFlexState, transferEdges);
final var finalStateOpt = EdgeTraverser.traverseEdges(afterFlexState[0], transferEdges);

return finalStateOpt
.map(finalState -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private Optional<DirectFlexPath> createDirectGraphPath(

final State[] afterFlexState = flexEdge.traverse(accessNearbyStop.state);

var finalStateOpt = EdgeTraverser.traverseEdges(afterFlexState, egress.edges);
var finalStateOpt = EdgeTraverser.traverseEdges(afterFlexState[0], egress.edges);

if (finalStateOpt.isEmpty()) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static ApiRelativeDirection mapRelativeDirection(RelativeDirection domain
case HARD_LEFT -> ApiRelativeDirection.HARD_LEFT;
case LEFT -> ApiRelativeDirection.LEFT;
case SLIGHTLY_LEFT -> ApiRelativeDirection.SLIGHTLY_LEFT;
case CONTINUE -> ApiRelativeDirection.CONTINUE;
case CONTINUE, ENTER_OR_EXIT_STATION -> ApiRelativeDirection.CONTINUE;
case SLIGHTLY_RIGHT -> ApiRelativeDirection.SLIGHTLY_RIGHT;
case RIGHT -> ApiRelativeDirection.RIGHT;
case HARD_RIGHT -> ApiRelativeDirection.HARD_RIGHT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ApiWalkStep mapWalkStep(WalkStep domain) {
api.streetName = domain.getDirectionText().toString(locale);
api.absoluteDirection =
domain.getAbsoluteDirection().map(AbsoluteDirectionMapper::mapAbsoluteDirection).orElse(null);
api.exit = domain.getExit();
api.exit = domain.highwayExit().orElse(null);
api.stayOn = domain.isStayOn();
api.area = domain.getArea();
api.bogusName = domain.nameIsDerived();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use:
# <TypeName>[.<FieldName>].(description|deprecated)[.append]
#
# Examples
# // Replace the existing type description
# Quay.description=The place for boarding/alighting a vehicle
#
# // Append to the existing type description
# Quay.description.append=Append
#
# // Replace the existing field description
# Quay.name.description=The public name
#
# // Append to the existing field description
# Quay.name.description.append=(Source NSR)
#
# // Insert deprecated reason. Due to a bug in the Java GraphQL lib, an existing deprecated
# // reason cannot be updated. Deleting the reason from the schema, and adding it back using
# // the "default" TransmodelApiDocumentationProfile is a workaround.
# Quay.name.deprecated=This field is deprecated ...


TariffZone.description=A **zone** used to define a zonal fare structure in a zone-counting or \
zone-matrix system. This includes TariffZone, as well as the specialised FareZone elements. \
TariffZones are deprecated, please use FareZones. \
\
**TariffZone data will not be maintained from 1. MAY 2025 (Entur).**
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.opentripplanner.apis.gtfs.datafetchers.CurrencyImpl;
import org.opentripplanner.apis.gtfs.datafetchers.DefaultFareProductImpl;
import org.opentripplanner.apis.gtfs.datafetchers.DepartureRowImpl;
import org.opentripplanner.apis.gtfs.datafetchers.EntranceImpl;
import org.opentripplanner.apis.gtfs.datafetchers.EstimatedTimeImpl;
import org.opentripplanner.apis.gtfs.datafetchers.FareProductTypeResolver;
import org.opentripplanner.apis.gtfs.datafetchers.FareProductUseImpl;
Expand All @@ -58,12 +59,14 @@
import org.opentripplanner.apis.gtfs.datafetchers.QueryTypeImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RealTimeEstimateImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RentalPlaceTypeResolver;
import org.opentripplanner.apis.gtfs.datafetchers.RentalVehicleFuelImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RentalVehicleImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RentalVehicleTypeImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RideHailingEstimateImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RouteImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RouteTypeImpl;
import org.opentripplanner.apis.gtfs.datafetchers.RoutingErrorImpl;
import org.opentripplanner.apis.gtfs.datafetchers.StepFeatureTypeResolver;
import org.opentripplanner.apis.gtfs.datafetchers.StopCallImpl;
import org.opentripplanner.apis.gtfs.datafetchers.StopGeometriesImpl;
import org.opentripplanner.apis.gtfs.datafetchers.StopImpl;
Expand Down Expand Up @@ -137,6 +140,7 @@ protected static GraphQLSchema buildSchema() {
.type("AlertEntity", type -> type.typeResolver(new AlertEntityTypeResolver()))
.type("CallStopLocation", type -> type.typeResolver(new CallStopLocationTypeResolver()))
.type("CallScheduledTime", type -> type.typeResolver(new CallScheduledTimeTypeResolver()))
.type("StepFeature", type -> type.typeResolver(new StepFeatureTypeResolver()))
.type(typeWiring.build(AgencyImpl.class))
.type(typeWiring.build(AlertImpl.class))
.type(typeWiring.build(BikeParkImpl.class))
Expand Down Expand Up @@ -195,6 +199,8 @@ protected static GraphQLSchema buildSchema() {
.type(typeWiring.build(LegTimeImpl.class))
.type(typeWiring.build(RealTimeEstimateImpl.class))
.type(typeWiring.build(EstimatedTimeImpl.class))
.type(typeWiring.build(EntranceImpl.class))
.type(typeWiring.build(RentalVehicleFuelImpl.class))
.build();
SchemaGenerator schemaGenerator = new SchemaGenerator();
return schemaGenerator.makeExecutableSchema(typeRegistry, runtimeWiring);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.opentripplanner.apis.gtfs.datafetchers;

import graphql.schema.DataFetcher;
import org.opentripplanner.apis.gtfs.GraphQLUtils;
import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers;
import org.opentripplanner.apis.gtfs.generated.GraphQLTypes;
import org.opentripplanner.transit.model.site.Entrance;

public class EntranceImpl implements GraphQLDataFetchers.GraphQLEntrance {

@Override
public DataFetcher<String> publicCode() {
return environment -> {
Entrance entrance = environment.getSource();
return entrance.getCode();
};
}

@Override
public DataFetcher<String> entranceId() {
return environment -> {
Entrance entrance = environment.getSource();
return entrance.getId().toString();
};
}

@Override
public DataFetcher<String> name() {
return environment -> {
Entrance entrance = environment.getSource();
return org.opentripplanner.framework.graphql.GraphQLUtils.getTranslation(
entrance.getName(),
environment
);
};
}

@Override
public DataFetcher<GraphQLTypes.GraphQLWheelchairBoarding> wheelchairAccessible() {
return environment -> {
Entrance entrance = environment.getSource();
return GraphQLUtils.toGraphQL(entrance.getWheelchairAccessibility());
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.opentripplanner.apis.gtfs.datafetchers;

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers;
import org.opentripplanner.service.vehiclerental.model.RentalVehicleFuel;

public class RentalVehicleFuelImpl implements GraphQLDataFetchers.GraphQLRentalVehicleFuel {

@Override
public DataFetcher<Double> percent() {
return environment ->
getSource(environment).percent() != null ? getSource(environment).percent().asDouble() : null;
}

@Override
public DataFetcher<Integer> range() {
return environment ->
getSource(environment).range() != null ? getSource(environment).range().toMeters() : null;
}

private RentalVehicleFuel getSource(DataFetchingEnvironment environment) {
return environment.getSource();
}
}
Loading

0 comments on commit 87bc6b2

Please sign in to comment.