Repository navigation
Merge B+R and P+R functionality into vehicle parking - #3480
Conversation
c041e3e to
c7e411b
Compare
leonardehrenfried
left a comment
There was a problem hiding this comment.
I have a few smaller requests but this is a good PR.
|
Is a VehicleParking either a CarParking or a BikeParking, or could one instance be both? The reason I ask is that the VehicleParking classes have car/bike specific attributes. A cleaner design would put those attributes into separate classes. If the VehicleParking is either or, then you may use inheritance, if not, "part-of" classes like During routing, I expect the super type will simplify the code, but on the API I am not so sure. I don´t know the use cases. An alternative to the suggested implementation is to have a |
a4665ca to
6e36b4a
Compare
One instance could be both, it is allowed to have both car and bicycle parking in one
The distinct I've added commits to restore two of the sandbox APIs to their previous functionality, so that there is no API change. |
leonardehrenfried
left a comment
There was a problem hiding this comment.
Now that the two APIs a backwards compatible I approve this.
If someone wants to use the combined vehicle parking then they can use the new entity.
leonardehrenfried
left a comment
There was a problem hiding this comment.
I had a change of heart and would like the legacy graphql API to stay 100% compatible as it would otherwise cause our frontend migration to run into problems.
|
Why do I think that is important? I used to think that we never request the bikePark entity but after having thought it through, I noticed that it's used in places like this: https://github.com/HSLdevcom/digitransit-ui/blob/next/app/component/SummaryPage.js#L697-L700 It will be difficult for us to find all the places where this is used so would it be possible to add a translation layer to emulate the old API? |
|
One way would be to add the new types and fields and mark the old fields as deprecated with the |
|
|
||
| """The car parking related to the place""" | ||
| carPark: CarPark | ||
| carPark: VehicleParking |
There was a problem hiding this comment.
In order to keep backwards compatibility with digitransit we need to keep this a CarPark. Can you please change that?
|
|
||
| """The bike parking related to the place""" | ||
| bikePark: BikePark | ||
| bikePark: VehicleParking |
There was a problem hiding this comment.
In order to keep backwards compatibility with digitransit we need to keep this a BikePark. Can you please change that type and adapt output?
leonardehrenfried
left a comment
There was a problem hiding this comment.
I had a think about it and would like to keep the LegacyGraphQl API 100% compatible.
|
Thanks for the backwards compat. I'm still seeing errors when createing routes with a VEHICLEPARK vertex type. Query Error |
|
I've added a commit to correctly use |
leonardehrenfried
left a comment
There was a problem hiding this comment.
I tested this again with @flaktack's latest changes and I fulfills all the backwards-compatibility guarantees that we expect as the legacy GraphQL API stays almost 100% compatible. Great work!
To answer your question: no the vertex type can stay as it is.
|
I recommend this to be merged. |
|
|
||
| // Used to explicitly specify the intersection to link to instead of using (x, y) | ||
| @EqualsAndHashCode.Exclude | ||
| private final transient StreetVertex vertex; |
There was a problem hiding this comment.
I merged this PR and strangely I'm observing the graph serialization test to fail: https://github.com/mfdz/OpenTripPlanner/runs/2682942115?check_suite_focus=true#step:6:3086
What is the reason to make this field transient?
There was a problem hiding this comment.
Because when I remove the transient keyword, the test passes.
There was a problem hiding this comment.
I've added a commit to explicitly clear the value of VehicleParkingEntrance#vertex, which is used when linking entrances to OSM.
The test fails due to #3910 modifying the builtin Portland graph to serialize bike rental stations and park and ride places. ObjectDiffer doesn't ignore transient fields, and so the missing transient value is caught after loading the graph and comparing it to the version in-memory.
| } | ||
|
|
||
| private VehicleParking getVehicleParking(DataFetchingEnvironment environment) { | ||
| FeedScopedId vehiclePlaceId = getSource(environment).place.stopId; |
There was a problem hiding this comment.
I don't think stopId is the correct field to use here. It should be vehicleParkId but that doesn't seem to exist.
There was a problem hiding this comment.
Yes, this would be fixed in a subsequent PR of this branch:
https://github.com/realCity/OpenTripPlanner/commits/feature/vehicle-parking-api
t2gran
left a comment
There was a problem hiding this comment.
I read trough this looking for code smells. I only found a few minor things. The main thing is that we want to remove lombok in the near future, so starting to use it here seems to be a bit unnecessary. I think this is big PR with many code changes, but instead of going through it in detail to verify everything I would like to merge it. I have added the Entur test label, so we make sure we include this PR in our next release at Entur - so we can test it.
Co-authored-by: Thomas Gran <t2gran@gmail.com>
A few typos were also fixed along the way.
optionsome
left a comment
There was a problem hiding this comment.
I reviewed the legacy graphql api changes and quickly tested this.
| if (o instanceof Agency) { return schema.getObjectType("Agency"); } | ||
| if (o instanceof TransitAlert) { return schema.getObjectType("Alert"); } | ||
| if (o instanceof BikePark) { return schema.getObjectType("BikePark"); } | ||
| if (o instanceof VehicleParking) { |
There was a problem hiding this comment.
This should probably also take into account the possibility that there is a CarPark fragment and return that in that case. I think it would be best to check if the object has car or bicycle places and return the appropriate schema. There is a line in this file commented out for CarPark, it can be removed.
There was a problem hiding this comment.
I've updated the handling here to preserve compatibility with BikePark / CarPark being preferred if specified in the request.
| GraphQLSchema schema = environment.getSchema(); | ||
|
|
||
| if (o instanceof BikePark) { return schema.getObjectType("BikePark"); } | ||
| if (o instanceof VehicleParking) { |
There was a problem hiding this comment.
Same as with the NodeInterfaceTypeResolver.
There was a problem hiding this comment.
I've used the same logic as in NodeInterfaceTypeResolver, but since StreetGraphFinder doesn't handle B+R/P+R nodes is has no effect.
| }; | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
Merge artifact, I've restored it.
| """ | ||
| state: VehicleParkingState | ||
|
|
||
| bicyclePlaces: Boolean |
There was a problem hiding this comment.
Descriptions missing for fields here.
There was a problem hiding this comment.
I've added the missing documentation.
|
|
||
| anyCarPlaces: Boolean | ||
|
|
||
| carPlaces: Boolean |
There was a problem hiding this comment.
Not sure if this should renamed to something like normalCarPlaces so it can be understood that it doesn't include wheelchairAccessibleCarPlaces. I don't have a strong opinion on this but I think it's easy to miss that there is also this anyCarPlaces field that might be what the developer is actually looking for. However, a case where a park would have wheelchair accessible car places but no regular places sounds unlikely.
There was a problem hiding this comment.
In Herrenberg (where this is used) there are several wheelchair only parking places.
I've updated the comments to maybe be a bit cleaner.
| } | ||
|
|
||
| type VehicleParkingSpaces { | ||
| bicycleSpaces: Int |
There was a problem hiding this comment.
I've added the missing documentation.
| """TRANSIT""" | ||
| TRANSIT | ||
|
|
||
| """BIKEPARK""" |
There was a problem hiding this comment.
This breaks backwards compatability a bit. We could leave this as it was with the BIKEPARK and PARKANDRIDE, and add a new type with those replaced with VEHICLEPARKING (and at the same time rename BIKESHARE as VEHICLERENTAL). Although, I'm not quite sure what are all the use cases for this vertexType. Maybe it makes sense to be able to differentiate between bike and car parks based on this value but in theory, now they can have both cars and bicycles.
There was a problem hiding this comment.
PARKANDRIDE is not present in VertexTypes, so it wouldn't have been returned in the API. I've renamed VEHICLERENTAL to BIKEPARK which should preserve the backward compatibility.
PARKANDRIDE is not present in VertexType, and so it is not mapped to the GraphQL type.
optionsome
left a comment
There was a problem hiding this comment.
Looks good. Just one more thing I forgot yesterday, you could mark the fields and queries that use BikePark/CarPark as deprecated in the schema and suggest that the VehicleParking counterpart should be used.
optionsome
left a comment
There was a problem hiding this comment.
Found some new things that should be fixed. Sorry, I should have noticed these earlier...
|
|
||
| """The bike parking related to the place""" | ||
| bikePark: BikePark | ||
| bikePark: BikePark @deprecated("bikePark is deprecated. Use vehicleParking instead.") |
There was a problem hiding this comment.
The schema build fails currently. I think you have to add "reason:" prefix to the deprecation comments.
| bikePark: BikePark @deprecated("bikePark is deprecated. Use vehicleParking instead.") | |
| bikePark: BikePark @deprecated(reason: "bikePark is deprecated. Use vehicleParking instead.") |
| @Override | ||
| public DataFetcher<String> bikeParkId() { | ||
| return environment -> getSource(environment).id; | ||
| return environment -> getSource(environment).getId().toString(); |
There was a problem hiding this comment.
I realized that maybe we should return the ids without the "feed id" in these legacy bikepark/carpark types like we have done with the BikeRentalStation vs VehicleRentalStation for backward compatibility.
|
|
||
| @Override | ||
| public DataFetcher<String> carParkId() { | ||
| return environment -> getSource(environment).getId().toString(); |
|
|
||
| if (vehicleParkingService == null) { return null; } | ||
|
|
||
| var carParkId = FeedScopedId.parseId(args.getLegacyGraphQLId()); |
There was a problem hiding this comment.
Again here I think we shouldn't use the feed scoped version of the id.
| if (vehicleParkingService == null) { return null; } | ||
|
|
||
| return vehicleRentalStationService | ||
| var bikeParkId = FeedScopedId.parseId(args.getLegacyGraphQLId()); |
There was a problem hiding this comment.
We shouldn't use the feedscoped id here.
|
|
||
| if (!idList.isEmpty()) { | ||
| Map<String, VehicleParking> carParkMap = vehicleParkingService.getCarParks() | ||
| .collect(Collectors.toMap(station -> station.getId().toString(), station -> station)); |
There was a problem hiding this comment.
Forgot the carParks query also had ids parameter so this needs to be changed as well.
optionsome
left a comment
There was a problem hiding this comment.
Everything looks good now at least from the legacy graphql api point of view and I like the refactoring overall.
leonardehrenfried
left a comment
There was a problem hiding this comment.
We've been running this in production for a few months now and are also satisfied.
|
🍾 |
Summary
B+R and P+R functionality is merged into a unified vehicle parking.
Major changes:
RoutingRequest#bikeParkAndRideis removed so that onlyRouteingRequest#parkAndRideis usedcarParkTimeandcarParkCostare added toRoutingRequestto matchbikeParkTimeandbikeParkCostamenity=parking, while areas are handled foramenity=bicycle_parking. The area handling / code is updated to allow linking to inner rings. If present, capacity information is also parsed.VehicleParkingEntranceVertexconnected to the street network with aStreetVehicleParkingLink. Between entrances (including itself) there areVehicleParkingEdges.Before and After pictures of the graph:
Issue
This is the first part of #3432
closes #3423
Unit tests
The existing tests were updated where needed and
BikeParkAndRideandCarParkAndRidetests are added.Code style
☑️
Documentation
No changes.
Changelog
Not yet - TODO.