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

fix: failing queries that combine departure/arrival parameters with avoid areas #1871

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RELEASING:
## [unreleased]
### Fixed
- do not enforce a time-dependent routing algorithm unless the weighting requires it ([#1865](https://github.com/GIScience/openrouteservice/pull/1865))
- failing queries that combined departure/arrival parameters with avoid areas ([#1870](https://github.com/GIScience/openrouteservice/pull/1870))

## [8.2.0] - 2024-10-09
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,19 @@ public void setSpeedups(GHRequest req, boolean useCH, boolean useCore, boolean u
}
}

boolean requiresTimeDependentWeighting(RouteSearchParameters searchParams, RouteSearchContext searchCntx) {
boolean requiresTimeDependentAlgorithm(RouteSearchParameters searchParams, RouteSearchContext searchCntx) {
if (!searchParams.isTimeDependent())
return false;

FlagEncoder flagEncoder = searchCntx.getEncoder();

return flagEncoder.hasEncodedValue(EncodingManager.getKey(flagEncoder, ConditionalEdges.ACCESS))
|| flagEncoder.hasEncodedValue(EncodingManager.getKey(flagEncoder, ConditionalEdges.SPEED))
if (flagEncoder.hasEncodedValue(EncodingManager.getKey(flagEncoder, ConditionalEdges.ACCESS)))
return true;

if (WeightingMethod.SHORTEST==searchParams.getWeightingMethod())
return false;

return flagEncoder.hasEncodedValue(EncodingManager.getKey(flagEncoder, ConditionalEdges.SPEED))
|| mGraphHopper.isTrafficEnabled();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,8 @@ else if (bearings[1] == null)

if (TemporaryUtilShelter.supportWeightingMethod(profileType)) {
ProfileTools.setWeightingMethod(req.getHints(), weightingMethod, profileType, TemporaryUtilShelter.hasTimeDependentSpeed(searchParams, searchCntx));
if (routingProfile.requiresTimeDependentWeighting(searchParams, searchCntx)) {
req.setAlgorithm(Parameters.Algorithms.TD_ASTAR);
if (routingProfile.requiresTimeDependentAlgorithm(searchParams, searchCntx))
flexibleMode = ProfileTools.KEY_FLEX_PREPROCESSED;
}
flexibleMode = TemporaryUtilShelter.getFlexibilityMode(flexibleMode, searchParams, profileType);
} else
throw new IllegalArgumentException("Unsupported weighting " + weightingMethod + " for profile + " + profileType);
Expand All @@ -413,16 +411,22 @@ else if (bearings[1] == null)

if (searchParams.isTimeDependent()) {
String key;
LocalDateTime time;
LocalDateTime dateTime;
if (searchParams.hasDeparture()) {
key = RouteRequestParameterNames.PARAM_DEPARTURE;
time = searchParams.getDeparture();
dateTime = searchParams.getDeparture();
} else {
key = RouteRequestParameterNames.PARAM_ARRIVAL;
time = searchParams.getArrival();
dateTime = searchParams.getArrival();
}

req.getHints().putObject(key, time.atZone(ZoneId.of("Europe/Berlin")).toInstant());
Instant time = dateTime.atZone(ZoneId.of("Europe/Berlin")).toInstant();
req.getHints().putObject(key, time);

if (routingProfile.requiresTimeDependentAlgorithm(searchParams, searchCntx)) {
req.getHints().putObject("time", time.toEpochMilli());
req.setAlgorithm(Parameters.Algorithms.TD_ASTAR);
}
}

if (routingProfile.getAstarEpsilon() != null)
Expand Down
Loading