Skip to content

fix: avoid roads reserved to customers #2060

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aoles
Copy link
Member

@aoles aoles commented May 16, 2025

Pull Request Checklist

  • 1. I have rebased the latest version of the main branch into my feature branch and all conflicts
    have been resolved.
  • 2. I have added information about the change/addition to functionality to the CHANGELOG.md file under the
    [Unreleased] heading.
  • 3. I have documented my code using JDocs tags.
  • 4. I have removed unnecessary commented out code, imports and System.out.println statements.
  • 5. I have written JUnit tests for any new methods/classes and ensured that they pass.
  • 6. I have created API tests for any new functionality exposed to the API.
  • 7. If changes/additions are made to the ors-config.json file, I have added these to the ors config documentation
    along with a short description of what it is for, and documented this in the Pull Request (below).
  • 8. I have built graphs with my code of the Heidelberg.osm.gz file and run the api-tests with all test passing
  • 9. I have referenced the Issue Number in the Pull Request (if the changes were from an issue).
  • 10. For new features or changes involving building of graphs, I have tested on a larger dataset
    (at least Germany), and the graphs build without problems (i.e. no out-of-memory errors).
  • 11. For new features or changes involving the graphbuilding process (i.e. changing encoders, updating the
    importer etc.), I have generated longer distance routes for the affected profiles with different options
    (avoid features, max weight etc.) and compared these with the routes of the same parameters and start/end
    points generated from the current live ORS.
    If there are differences then the reasoning for these MUST be documented in the pull request.
  • 12. I have written in the Pull Request information about the changes made including their intended usage
    and why the change was needed.
  • 13. For changes touching the API documentation, I have tested that the API playground renders correctly.

Fixes #1981.

Information about the changes

  • Key functionality added: Introduce a weight penalty on roads tagged with access = customers in order to avoid them during route calculation.
  • Reason for change: sometimes the route returned by ORS takes "shortcuts" through parking lots, gas stations, or similar instead of following the regular road. This is of an issue because it:
    • might be illegal to do
    • is typically much slower due to the lower speed limit and the presence of pedestrians
    • results in an overall higher number of turns compared to the direct route.

Examples and reasons for differences between live ORS routes, and those generated from this pull request

The following examples from the original issue now yield the desired routes.

image

image

image

image

@aoles aoles changed the title Fix: avoid roads reserved to customers fix: avoid roads reserved to customers May 16, 2025
@github-actions github-actions bot added the fix label May 16, 2025
@github-actions github-actions bot added fix and removed fix labels May 16, 2025
@aoles aoles requested a review from Copilot May 19, 2025 14:52
@github-actions github-actions bot added fix and removed fix labels May 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a weight penalty for roads tagged access=customers so that routes avoid them by default.

  • Defines new customer access factors with bounds checking and integrates them into LimitedAccessWeighting.
  • Applies the customersPenalty in the routing weight calculation.
  • Introduces an API test verifying the distance difference when customer‐reserved roads are penalized and updates the changelog.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/weighting/LimitedAccessWeighting.java Added DEFAULT_CUSTOMERS_FACTOR, VEHICLE_CUSTOMERS_FACTOR, bounds, customersPenalty field and logic in constructor/modifyWeight.
ors-api/src/test/java/org/heigit/ors/apitests/routing/ResultTest.java Added testCustomersAccess to verify routing behavior when customer‐reserved roads are penalized.
CHANGELOG.md Documented the fix for avoiding roads reserved to customers under the “Fixed” section.
Comments suppressed due to low confidence (1)

ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/weighting/LimitedAccessWeighting.java:98

  • Introduce unit tests for modifyWeight covering the RoadAccess.CUSTOMERS branch to ensure customersPenalty is applied as expected in isolation.
else if (access == RoadAccess.CUSTOMERS)

public static final double DEFAULT_DESTINATION_FACTOR = 1;
public static final double VEHICLE_DESTINATION_FACTOR = 10;
public static final double DEFAULT_PRIVATE_FACTOR = 1.2;
public static final double VEHICLE_PRIVATE_FACTOR = 10;
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Add a Javadoc comment explaining the purpose of DEFAULT_CUSTOMERS_FACTOR and the corresponding road_access_customers_factor configuration key to clarify usage.

Suggested change
public static final double VEHICLE_PRIVATE_FACTOR = 10;
public static final double VEHICLE_PRIVATE_FACTOR = 10;
/**
* The default factor applied to roads with "customers" access restrictions.
* This factor is used to penalize such roads during route calculation.
* It can be overridden by specifying the "road_access_customers_factor" configuration key.
*/

Copilot uses AI. Check for mistakes.

@@ -52,7 +58,9 @@ public LimitedAccessWeighting(Weighting superWeighting, PMap map) {
destinationPenalty = checkBounds("road_access_destination_factor", map.getDouble("road_access_destination_factor", defaultDestinationFactor), MIN_DESTINATION_FACTOR, MAX_DESTINATION_FACTOR);
double defaultPrivateFactor = encoder.getTransportationMode().isMotorVehicle() ? VEHICLE_PRIVATE_FACTOR : DEFAULT_PRIVATE_FACTOR;
privatePenalty = checkBounds("road_access_private_factor", map.getDouble("road_access_private_factor", defaultPrivateFactor), MIN_PRIVATE_FACTOR, MAX_PRIVATE_FACTOR);
roadAccessEnc = destinationPenalty > 1 || privatePenalty > 1 ? encoder.getEnumEncodedValue(RoadAccess.KEY, RoadAccess.class) : null;
double defaultCustomersFactor = encoder.getTransportationMode().isMotorVehicle() ? VEHICLE_CUSTOMERS_FACTOR : DEFAULT_CUSTOMERS_FACTOR;
customersPenalty = checkBounds("road_access_customers_factor", map.getDouble("road_access_customers_factor", defaultCustomersFactor), MIN_CUSTOMERS_FACTOR, MAX_CUSTOMERS_FACTOR);
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Update the external configuration documentation (ors-config.json docs) to mention the new road_access_customers_factor parameter, its default, and valid bounds.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Directions API routes through parking lots rather than go through intersections
1 participant