Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into naming-conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 28, 2024
2 parents 8a9b964 + 669d71f commit aacd1d7
Show file tree
Hide file tree
Showing 123 changed files with 2,117 additions and 968 deletions.
4 changes: 2 additions & 2 deletions application/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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 Client</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-22T08:29/assets/index-CwmtYnAr.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-22T08:29/assets/index-CaBThmWm.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-27T19:19/assets/index-csysh7Fh.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-27T19:19/assets/index-CaBThmWm.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import org.opentripplanner.framework.i18n.TranslatedString;
import org.opentripplanner.inspector.vector.KeyValue;
import org.opentripplanner.inspector.vector.LayerParameters;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingGroup;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingRepository;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingGroup;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.standalone.config.routerconfig.VectorTileConfig;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand Down Expand Up @@ -90,9 +91,8 @@ public void setUp() {

@Test
public void vehicleParkingGroupGeometryTest() {
Graph graph = new Graph();
VehicleParkingService service = graph.getVehicleParkingService();
service.updateVehicleParking(List.of(vehicleParking), List.of());
var repository = new DefaultVehicleParkingRepository();
repository.updateVehicleParking(List.of(vehicleParking), List.of());

var config =
"""
Expand All @@ -116,7 +116,7 @@ public void vehicleParkingGroupGeometryTest() {
var tiles = VectorTileConfig.mapVectorTilesParameters(nodeAdapter, "vectorTiles");
assertEquals(1, tiles.layers().size());
var builder = new VehicleParkingGroupsLayerBuilderWithPublicGeometry(
graph,
new DefaultVehicleParkingService(repository),
tiles.layers().get(0),
Locale.US
);
Expand Down Expand Up @@ -171,11 +171,11 @@ private static class VehicleParkingGroupsLayerBuilderWithPublicGeometry
extends VehicleParkingGroupsLayerBuilder {

public VehicleParkingGroupsLayerBuilderWithPublicGeometry(
Graph graph,
VehicleParkingService service,
LayerParameters<VectorTilesResource.LayerType> layerParameters,
Locale locale
) {
super(graph, layerParameters, locale);
super(service, layerParameters, locale);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.TranslatedString;
import org.opentripplanner.model.calendar.openinghours.OpeningHoursCalendarService;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingRepository;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.standalone.config.routerconfig.VectorTileConfig;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
Expand Down Expand Up @@ -86,9 +86,8 @@ public void setUp() {

@Test
public void vehicleParkingGeometryTest() {
Graph graph = new Graph();
VehicleParkingService service = graph.getVehicleParkingService();
service.updateVehicleParking(List.of(vehicleParking), List.of());
var repo = new DefaultVehicleParkingRepository();
repo.updateVehicleParking(List.of(vehicleParking), List.of());

var config =
"""
Expand All @@ -111,7 +110,7 @@ public void vehicleParkingGeometryTest() {
var nodeAdapter = newNodeAdapterForTest(config);
var tiles = VectorTileConfig.mapVectorTilesParameters(nodeAdapter, "vectorTiles");
assertEquals(1, tiles.layers().size());
var builder = new VehicleParkingsLayerBuilder(graph, tiles.layers().getFirst(), Locale.US);
var builder = new VehicleParkingsLayerBuilder(new DefaultVehicleParkingService(repo), tiles.layers().getFirst(), Locale.US);

List<Geometry> geometries = builder.getGeometries(new Envelope(0.99, 1.01, 1.99, 2.01));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.time.Duration;
import java.util.Locale;
import org.junit.jupiter.api.Test;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.transit.model.basic.Locales;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.opentripplanner._support.time.ZoneIds;
import org.opentripplanner.model.calendar.openinghours.OpeningHoursCalendarService;
import org.opentripplanner.model.calendar.openinghours.OsmOpeningHoursSupport;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.transit.model.framework.Deduplicator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.routing.graphfinder.DirectGraphFinder;
import org.opentripplanner.routing.graphfinder.GraphFinder;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.standalone.api.OtpServerRequestContext;

/**
Expand All @@ -36,7 +36,7 @@ public ParkAndRideResource(
*/
@Deprecated @PathParam("ignoreRouterId") String ignoreRouterId
) {
this.vehicleParkingService = serverContext.graph().getVehicleParkingService();
this.vehicleParkingService = serverContext.vehicleParkingService();

// TODO OTP2 - Why are we using the DirectGraphFinder here, not just
// - serverContext.graphFinder(). This needs at least a comment!
Expand Down Expand Up @@ -73,7 +73,8 @@ public Response getParkAndRide(
}

var prs = vehicleParkingService
.getCarParks()
.listCarParks()
.stream()
.filter(lot -> envelope.contains(lot.getCoordinate().asJtsCoordinate()))
.filter(lot -> hasTransitStopsNearby(maxTransitDistance, lot))
.map(ParkAndRideInfo::ofVehicleParking)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.StopArrival;
import org.opentripplanner.model.plan.VehicleParkingWithEntrance;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;
import org.opentripplanner.transit.model.site.RegularStop;

public class PlaceMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.ext.restapi.mapping.ModeMapper;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehiclerental.VehicleRentalService;
import org.opentripplanner.service.worldenvelope.model.WorldEnvelope;
import org.opentripplanner.transit.service.TransitService;
Expand Down Expand Up @@ -34,10 +34,9 @@ public ApiRouterInfo(
Graph graph,
TransitService transitService,
VehicleRentalService vehicleRentalService,
VehicleParkingService vehicleParkingService,
WorldEnvelope envelope
) {
VehicleParkingService vehicleParkingService = graph.getVehicleParkingService();

this.routerId = routerId;
this.polygon = graph.getConvexHull();
this.buildTime = Date.from(graph.buildTime);
Expand All @@ -51,7 +50,7 @@ public ApiRouterInfo(
this.hasParkRide = this.hasCarPark;
this.hasVehicleParking = mapHasVehicleParking(vehicleParkingService);
this.travelOptions =
ApiTravelOptionsMaker.makeOptions(graph, vehicleRentalService, transitService);
ApiTravelOptionsMaker.makeOptions(graph, vehicleRentalService, vehicleParkingService, transitService);
}

public boolean mapHasBikeSharing(VehicleRentalService service) {
Expand All @@ -67,21 +66,21 @@ public boolean mapHasBikePark(VehicleParkingService service) {
if (service == null) {
return false;
}
return service.getBikeParks().findAny().isPresent();
return service.listBikeParks().stream().findAny().isPresent();
}

public boolean mapHasCarPark(VehicleParkingService service) {
if (service == null) {
return false;
}
return service.getCarParks().findAny().isPresent();
return service.listCarParks().stream().findAny().isPresent();
}

public boolean mapHasVehicleParking(VehicleParkingService service) {
if (service == null) {
return false;
}
return service.getVehicleParkings().findAny().isPresent();
return service.listVehicleParkings().stream().findAny().isPresent();
}

public double getLowerLeftLatitude() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Set;
import org.opentripplanner.api.parameter.ApiRequestMode;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehiclerental.VehicleRentalService;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.service.TransitService;
Expand All @@ -29,14 +30,14 @@ public final class ApiTravelOptionsMaker {
public static List<ApiTravelOption> makeOptions(
Graph graph,
VehicleRentalService vehicleRentalService,
VehicleParkingService vehicleParkingService,
TransitService transitService
) {
var service = graph.getVehicleParkingService();
return makeOptions(
transitService.listTransitModes(),
vehicleRentalService.hasRentalBikes(),
service.hasBikeParking(),
service.hasCarParking()
vehicleParkingService.hasBikeParking(),
vehicleParkingService.hasCarParking()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private ApiRouterInfo getRouterInfo() {
serverContext.graph(),
serverContext.transitService(),
serverContext.vehicleRentalService(),
serverContext.vehicleParkingService(),
serverContext.worldEnvelopeService().envelope().orElseThrow()
);
} catch (GraphNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ private static LayerBuilder<?> createLayerBuilder(
layerParameters
);
case VehicleParking -> new VehicleParkingsLayerBuilder(
context.graph(),
context.vehicleParkingService(),
layerParameters,
locale
);
case VehicleParkingGroup -> new VehicleParkingGroupsLayerBuilder(
context.graph(),
context.vehicleParkingService(),
layerParameters,
locale
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.opentripplanner.apis.support.mapping.PropertyMapper;
import org.opentripplanner.framework.i18n.I18NStringMapper;
import org.opentripplanner.inspector.vector.KeyValue;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;

public class DigitransitVehicleParkingPropertyMapper extends PropertyMapper<VehicleParking> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.opentripplanner.framework.json.ObjectMappers;
import org.opentripplanner.inspector.vector.KeyValue;
import org.opentripplanner.model.calendar.openinghours.OsmOpeningHoursSupport;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;

public class StadtnaviVehicleParkingPropertyMapper extends PropertyMapper<VehicleParking> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.opentripplanner.ext.vectortiles.layers.vehicleparkings;

import java.util.Collection;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingGroup;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingGroup;

/**
* Record that holds {@link VehicleParkingGroup} and a set of {@link VehicleParking} that belong to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.inspector.vector.LayerBuilder;
import org.opentripplanner.inspector.vector.LayerParameters;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;

public class VehicleParkingGroupsLayerBuilder extends LayerBuilder<VehicleParkingAndGroup> {

static Map<VehicleParkingGroupsLayerBuilder.MapperType, Function<Locale, PropertyMapper<VehicleParkingAndGroup>>> mappers = Map.of(
VehicleParkingGroupsLayerBuilder.MapperType.Digitransit,
DigitransitVehicleParkingGroupPropertyMapper::create
);
private final Graph graph;
private final VehicleParkingService service;

public VehicleParkingGroupsLayerBuilder(
Graph graph,
VehicleParkingService service,
LayerParameters<VectorTilesResource.LayerType> layerParameters,
Locale locale
) {
Expand All @@ -33,14 +33,13 @@ public VehicleParkingGroupsLayerBuilder(
layerParameters.name(),
layerParameters.expansionFactor()
);
this.graph = graph;
this.service = service;
}

@Override
protected List<Geometry> getGeometries(Envelope query) {
return graph
.getVehicleParkingService()
.getVehicleParkingGroups()
return service
.listVehicleParkingGroups()
.asMap()
.entrySet()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.inspector.vector.LayerBuilder;
import org.opentripplanner.inspector.vector.LayerParameters;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;

public class VehicleParkingsLayerBuilder extends LayerBuilder<VehicleParking> {

Expand All @@ -28,10 +28,10 @@ public class VehicleParkingsLayerBuilder extends LayerBuilder<VehicleParking> {
),
entry(MapperType.Digitransit, DigitransitVehicleParkingPropertyMapper::create)
);
private final Graph graph;
private final VehicleParkingService service;

public VehicleParkingsLayerBuilder(
Graph graph,
VehicleParkingService service,
LayerParameters<VectorTilesResource.LayerType> layerParameters,
Locale locale
) {
Expand All @@ -40,14 +40,13 @@ public VehicleParkingsLayerBuilder(
layerParameters.name(),
layerParameters.expansionFactor()
);
this.graph = graph;
this.service = service;
}

@Override
protected List<Geometry> getGeometries(Envelope query) {
return graph
.getVehicleParkingService()
.getVehicleParkings()
return service
.listVehicleParkings().stream()
.map(vehicleParking -> {
Coordinate coordinate = vehicleParking.getCoordinate().asJtsCoordinate();
Point point = GeometryUtils.getGeometryFactory().createPoint(coordinate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.NonLocalizedString;
import org.opentripplanner.framework.json.ObjectMappers;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.updater.spi.GenericJsonDataSource;
import org.opentripplanner.utils.tostring.ToStringBuilder;
Expand Down
Loading

0 comments on commit aacd1d7

Please sign in to comment.