State-based geofencing zone enforcement for vehicle rental routing#7544
Draft
testower wants to merge 6 commits into
Draft
State-based geofencing zone enforcement for vehicle rental routing#7544testower wants to merge 6 commits into
testower wants to merge 6 commits into
Conversation
2fee8ef to
2877da0
Compare
bdb8a09 to
8e5fe6e
Compare
460f8e5 to
a79222b
Compare
a79222b to
c99e5a8
Compare
b951c49 to
e59cf6d
Compare
e59cf6d to
2b3f993
Compare
47ed737 to
ca45088
Compare
1a11e3c to
2c3431d
Compare
…ofencing Convert GeofencingZone from a record to a final class with nullable Boolean restriction fields (dropOffBanned, traversalBanned, rideStartBanned), enabling per-field precedence resolution across overlapping zones per the GBFS spec. Add priority (from GBFS feature array position), explicit businessArea flag (computed at mapping time instead of inferred from absence of restrictions), vehicleTypeIds, and maximumSpeedKph fields. Custom equals/hashCode on id+priority only, excluding expensive JTS Geometry comparison. Add static resolveField() for per-field precedence: for each restriction field independently, the highest-priority zone that specifies the field wins. Update GBFS mappers (base, v2, v3) to support per-vehicle-type-scope grouping, nullable field mapping, and priority assignment. Update GeofencingZoneExtension and GeofencingZonesPropertyMapper for nullable Boolean API. Add TestGeofencingZoneBuilder in test-fixtures for readable test zone construction.
…cking Add GeofencingBoundaryExtension record (zone, entering) for marking boundary-crossing vertices. Add GeofencingZoneIndex (STRtree spatial index with PreparedGeometry.covers()) for efficient containment queries. Add GeofencingZoneApplier replacing GeofencingVertexUpdater. Detects boundary-crossing edges via vertex containment with caching, places paired boundary extensions on both vertices with opposite entering flags. Retains BusinessAreaBorder placement for business area zones. Add geofencing zone index storage on Graph with per-datasource registration. Add initialGeofencingZones on VehicleRentalPlaceVertex, pre-resolved from spatial index at updater time. Add geofencing boundary fields and methods on Vertex alongside the existing RentalRestrictionExtension system. Update BusinessAreaBorder to support multiple networks (Set<String>). Update VertexLinker to compute geofencing boundaries spatially for split vertices instead of blind-copying from parent vertices. Update VehicleRentalUpdater to use GeofencingZoneApplier with zone change detection via isEquivalentTo() deep comparison. Add factory methods on StreetVehicleRentalLink and VehicleRentalEdge.
…cing Add currentGeofencingZones and committedNetworks to StateData, with boundary transition logic in StateEditor.updateGeofencingZones() using paired boundary detection and XOR trick for arriveBy direction. Per-field enforcement methods on State (isDropOffBannedByCurrentZones, isTraversalBannedByCurrentZones) resolve restrictions via priority-based precedence. VehicleRentalEdge initializes zones on pickup and checks committedNetworks for generic state blocking. StreetEdge.doTraverse calls updateGeofencingZones at boundary edges. Routing request plumbing precomputes destination zones for arriveBy searches via GeofencingZoneIndex, propagated through GraphPathFinder. Delete superseded GeofencingVertexUpdater (replaced by GeofencingZoneApplier).
…specific routing decisions Replace the 220-line StreetEdge geofencing if-chain with a three-layer architecture using the Strategy pattern: - Layer 0: Zone state tracking (StateEditor.updateGeofencingZones, from commit 3) - Layer 1: Network commitment for generic arriveBy states - Layer 2: GeofencingEnforcement strategy per zone type New enforcement implementations: - RestrictedZoneEnforcement: no-drop-off and no-traversal zones (fork, block, drop) - BusinessAreaEnforcement: inverted logic (exit = restrict) - DeferredForkHandler: backState zone exit detection for deferred renting branches The traversal skeleton iterates paired boundary extensions on fromv, delegates to the appropriate enforcement via GeofencingEnforcement.forZone(), and handles network commitment for generic states separately. Delete old per-edge geofencing system: RentalRestrictionExtension, GeofencingZoneExtension, NoRestriction, CompositeRentalRestrictionExtension, BusinessAreaBorder, and all associated Vertex/State/StreetEdge methods.
Wire up the existing applyBusinessAreas flag in GeofencingZoneApplier to a per-source configuration parameter. When disabled, boundary extensions are not created for business-area-only zones, suppressing drop-off enforcement at their boundary while keeping the zones in the index for state tracking, speed limits, and debug tiles. Defaults to true for backward compatibility.
2c3431d to
b6ada49
Compare
…dropping The geofencing enforcement gated on isRentingVehicle() (covers both station and floating rentals) but every drop branch called dropFloatingVehicle(), which would synthesize a HAVE_RENTED state at a non-station vertex. For station rentals this is illegal — the rider must return the vehicle to a same-network station. Add station-rental-aware branches in the forward enforcement and the bidirectional pre-guard: - Pre-guard inside a no-traversal zone: block (not force-drop) - Forward entering a no-traversal zone: block - Forward entering a no-drop-off zone: pass through (restriction irrelevant for station rentals — they never drop mid-street) - Forward exiting a business area: block (both at-boundary and fallback paths) - Forward entering a business area: pass through (unchanged) Arrive-by remains correct via existing State.empty() checks for committed renting states; phantom RENTING_FLOATING branches created by the deferred fork for station-only networks self-correct by failing at pickup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements state-based geofencing zone tracking with boundary-crossing vertices and an enforcement strategy pattern. Zone membership is tracked in routing
Stateand updated at boundary crossings, enabling correct per-field precedence for overlapping zones as specified by GBFS v2.3+. Zone-type-specific routing decisions (fork, block, force drop-off) are dispatched throughGeofencingEnforcementstrategies, orchestrated byGeofencingInterceptor.This PR also fixes a pre-existing bug in the dev-2.x edge-based implementation where station rentals hitting a geofencing zone were force-dropped mid-street, producing illegal itineraries. The enforcement is now station-rental-aware: forward direction blocks at no-traversal zones and business-area boundaries, passes through no-drop-off zones (where the restriction doesn't apply), and leaves arrive-by unchanged (the existing
State.empty()checks handle committed states correctly).Issue
Closes #7578
Unit tests
StreetEdgeGeofencingTest: 27 tests covering forward/arriveBy traversal through no-drop-off, no-traversal, and business area zones, including overlapping zones and adjacent zone edge casesRestrictedZoneEnforcementTest: 14 tests for the restricted zone enforcement strategy in isolation usingEdgeTraversallambda (no real graph needed), including station-rental casesBusinessAreaEnforcementTest: 11 tests for business-area enforcement including station-rental cases (exit blocked, boundary exit blocked, enter passes)GeofencingInterceptorTest: 11 tests for the orchestrator dispatch logic, including station-rental pre-guard caseStateEditorGeofencingZoneTest: 9 tests for zone state tracking inStateEditorStateGeofencingEnforcementTest: 10 tests for zone-based restriction queries onStateScooterRentalGeofencingTest: 10 integration tests with real graph routing through geofencing zonesDocumentation
package.mdadded to thegeofencingpackage documenting the interceptor/strategy architecture, boundary infrastructure, and zone state trackingBumping the serialization version id
This PR changes graph serialization by adding
geofencingBoundariestoVertexand removingRentalRestrictionExtensionfields from edges and vertices. The+Bump Serialization Idlabel should be added.