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

Handle reverse search when starting in no-drop-off zone #5201

Merged

Conversation

leonardehrenfried
Copy link
Member

@leonardehrenfried leonardehrenfried commented Jun 19, 2023

Summary

When implementing GBFS geofencing zones in #4805 I had to cut out a complex feature, because a refactoring had to happen first (#4841) to make it work.

Since the preparatory work has not been completed, I can implement the following edge case: a reverse (arrive by) search has started in a no-drop off zone.

We note this case when speculatively starting the rental and have to make sure in the rental edge that we don't allow for the vehicle to be picked up.

Refactoring

  • getNonTransitMode has been renamed to currentMode
  • the extraction of "base case" states in StateData was moved into a separate method and made explicit
  • @NotNull annotation for all edges
  • removed overriden methods that repeat the parent implementation

Unit tests

Lots added.

@leonardehrenfried leonardehrenfried added improvement IBI Developed by or important for IBI Group labels Jun 19, 2023
@codecov
Copy link

codecov bot commented Jun 19, 2023

Codecov Report

Patch coverage: 77.90% and project coverage change: -0.01 ⚠️

Comparison is base (c1e2da5) 65.57% compared to head (3b58c24) 65.57%.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5201      +/-   ##
=============================================
- Coverage      65.57%   65.57%   -0.01%     
- Complexity     14629    14633       +4     
=============================================
  Files           1762     1761       -1     
  Lines          68359    68368       +9     
  Branches        7289     7290       +1     
=============================================
+ Hits           44827    44829       +2     
- Misses         21045    21054       +9     
+ Partials        2487     2485       -2     
Impacted Files Coverage Δ
...pentripplanner/ext/flex/edgetype/FlexTripEdge.java 90.00% <ø> (ø)
.../opentripplanner/ext/traveltime/spt/SPTWalker.java 0.00% <0.00%> (ø)
...ostopheuristics/VehicleToStopSkipEdgeStrategy.java 0.00% <0.00%> (ø)
.../vehiclerental/street/GeofencingZoneExtension.java 59.25% <0.00%> (+4.08%) ⬆️
.../vehiclerental/street/StreetVehicleRentalLink.java 93.75% <ø> (-0.70%) ⬇️
...pplanner/street/model/edge/ElevatorAlightEdge.java 93.33% <ø> (ø)
...ipplanner/street/model/edge/ElevatorBoardEdge.java 81.25% <ø> (-1.11%) ⬇️
...rg/opentripplanner/street/model/edge/FreeEdge.java 87.50% <ø> (-2.50%) ⬇️
...ner/street/model/edge/StreetTransitEntityLink.java 78.18% <0.00%> (ø)
...ipplanner/street/model/edge/TemporaryFreeEdge.java 66.66% <ø> (ø)
... and 13 more

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work on PDX data. A search for rental scooter starting in a no-parking (no-drop-off) area correctly returns an itinerary where you have to walk to a scooter outside the area boundary, whereas the reverse search (still) takes the scooter to inside the no-parking area.

Copy link
Member

@optionsome optionsome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and often (if not always) the rental scooter suggestions slightly differ with arriveBy true/false when there are these geofencing zones. However, the suggestions still seemed quite reasonable so I don't know if we need to fix the issue within this pr.

Comment on lines +526 to +528
// null is a special rental network that speculatively assumes that you can take any vehicle
// you have to check in the rental edge if this has search has been started in a no-drop off zone
Stream.of((String) null),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if having this as null or some hardcoded value is better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that using null is terrible for a number of reasons. My eventual goal is to refactor the StateData in a way that this is not needed anymore.

I'm thinking of something like this:

interface State

class Walking implements State
class ForwardRenting(String network) implements State
class BackwardsRentingLookingForVehicle implements State
class BackwardsSpeculativelyRenting implements State

That way we can get rid of these magic values and don't carry around all the variables (rentalNetwork, formFactor, rentalState...) for the searches where we don't use them.

The big question is the performance of all of this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now documenting this nightmare is difficult and having explicit classes with Javadoc might help.

final State speculativeRenting = states[0];
assertEquals(RENTING_FLOATING, speculativeRenting.getVehicleRentalState());
assertEquals(BICYCLE, speculativeRenting.currentMode());
// null means that the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

means what?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Fleshed out in 0c103bc

Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still good

@leonardehrenfried leonardehrenfried merged commit fcb8962 into opentripplanner:dev-2.x Jul 11, 2023
5 checks passed
@leonardehrenfried leonardehrenfried deleted the multiple-geofencing branch July 11, 2023 15:32
t2gran pushed a commit that referenced this pull request Jul 11, 2023
@t2gran t2gran added this to the 2.4 (next release) milestone Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IBI Developed by or important for IBI Group improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants