-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isochrones): use correct edge filter for snapping (#1568)
- Loading branch information
Showing
4 changed files
with
116 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
58 changes: 0 additions & 58 deletions
58
.../main/java/org/heigit/ors/routing/graphhopper/extensions/weighting/DistanceWeighting.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +0,0 @@ | ||
/* This file is part of Openrouteservice. | ||
* | ||
* Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the | ||
* GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License along with this library; | ||
* if not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package org.heigit.ors.routing.graphhopper.extensions.weighting; | ||
|
||
import com.graphhopper.routing.util.FlagEncoder; | ||
import com.graphhopper.routing.weighting.AbstractWeighting; | ||
import com.graphhopper.util.EdgeIteratorState; | ||
|
||
public class DistanceWeighting extends AbstractWeighting { | ||
public DistanceWeighting(FlagEncoder encoder) { | ||
super(encoder); | ||
} | ||
|
||
@Override | ||
public double calcEdgeWeight(EdgeIteratorState edge, boolean reverse) { | ||
double speed = flagEncoder.getAverageSpeedEnc().getDecimal(reverse, edge.getFlags()); | ||
if (speed == 0) | ||
return Double.POSITIVE_INFINITY; | ||
|
||
return edge.getDistance(); | ||
} | ||
|
||
@Override | ||
public double getMinWeight(double distance) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "distance"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final DistanceWeighting other = (DistanceWeighting) obj; | ||
return toString().equals(other.toString()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ("DistanceWeighting" + this).hashCode(); | ||
} | ||
} | ||
103 changes: 103 additions & 0 deletions
103
ors-engine/src/main/java/org/heigit/ors/util/ProfileTools.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package org.heigit.ors.util; | ||
|
||
import com.graphhopper.util.PMap; | ||
import org.heigit.ors.routing.RoutingProfileType; | ||
import org.heigit.ors.routing.WeightingMethod; | ||
import org.heigit.ors.routing.graphhopper.extensions.util.ORSParameters; | ||
|
||
public class ProfileTools { | ||
public static final String VAL_RECOMMENDED = "recommended"; | ||
private static final String KEY_WEIGHTING = "weighting"; | ||
private static final String KEY_WEIGHTING_METHOD = "weighting_method"; | ||
public static final String KEY_CH_DISABLE = "ch.disable"; | ||
public static final String KEY_LM_DISABLE = "lm.disable"; | ||
public static final String KEY_CORE_DISABLE = "core.disable"; | ||
public static final String KEY_PREPARE_CORE_WEIGHTINGS = "prepare.core.weightings"; | ||
public static final String KEY_PREPARE_FASTISOCHRONE_WEIGHTINGS = "prepare.fastisochrone.weightings"; | ||
public static final String KEY_METHODS_CH = "methods.ch"; | ||
public static final String KEY_ENABLED = "enabled"; | ||
public static final String KEY_THREADS = "threads"; | ||
public static final String KEY_WEIGHTINGS = "weightings"; | ||
public static final String KEY_LMSETS = "lmsets"; | ||
public static final String KEY_MAXCELLNODES = "maxcellnodes"; | ||
public static final String KEY_METHODS_LM = "methods.lm"; | ||
public static final String KEY_LANDMARKS = "landmarks"; | ||
public static final String KEY_METHODS_CORE = "methods.core"; | ||
public static final String KEY_DISABLING_ALLOWED = "disabling_allowed"; | ||
public static final String KEY_ACTIVE_LANDMARKS = "active_landmarks"; | ||
public static final String KEY_TOTAL_POP = "total_pop"; | ||
public static final String KEY_TOTAL_AREA_KM = "total_area_km"; | ||
public static final int KEY_FLEX_STATIC = 0; | ||
public static final int KEY_FLEX_PREPROCESSED = 1; | ||
public static final int KEY_FLEX_FULLY = 2; | ||
public static final String KEY_CUSTOM_WEIGHTINGS = "custom_weightings"; | ||
public static final String VAL_SHORTEST = "shortest"; | ||
public static final String VAL_FASTEST = "fastest"; | ||
|
||
public static String makeProfileName(String vehicleName, String weightingName, boolean hasTurnCosts) { | ||
String profileName = vehicleName + "_" + weightingName; | ||
if (hasTurnCosts) | ||
profileName += "_with_turn_costs"; | ||
return profileName; | ||
} | ||
|
||
/** | ||
* Set the weightingMethod for the request based on input weighting. | ||
* | ||
* @param map Hints map for setting up the request | ||
* @param requestWeighting Originally requested weighting | ||
* @param profileType Necessary for HGV | ||
*/ | ||
public static void setWeightingMethod(PMap map, int requestWeighting, int profileType, boolean hasTimeDependentSpeed) { | ||
//Defaults | ||
String weightingMethod = VAL_RECOMMENDED; | ||
|
||
if (requestWeighting == WeightingMethod.SHORTEST) | ||
weightingMethod = VAL_SHORTEST; | ||
|
||
//For a requested recommended weighting, use recommended for bike, walking and hgv. Use fastest for car. | ||
if (requestWeighting == WeightingMethod.RECOMMENDED || requestWeighting == WeightingMethod.FASTEST) { | ||
if (profileType == RoutingProfileType.DRIVING_CAR) { | ||
weightingMethod = VAL_FASTEST; | ||
} | ||
if (RoutingProfileType.isHeavyVehicle(profileType) || RoutingProfileType.isCycling(profileType) || RoutingProfileType.isWalking(profileType)) { | ||
weightingMethod = VAL_RECOMMENDED; | ||
} | ||
} | ||
|
||
map.putObject(KEY_WEIGHTING_METHOD, weightingMethod); | ||
|
||
if (hasTimeDependentSpeed) | ||
map.putObject(ORSParameters.Weighting.TIME_DEPENDENT_SPEED_OR_ACCESS, true); | ||
} | ||
|
||
/** | ||
* Set the weighting for the request based on input weighting. | ||
* | ||
* @param map Hints map for setting up the request | ||
* @param requestWeighting Originally requested weighting | ||
* @param profileType Necessary for HGV | ||
*/ | ||
public static void setWeighting(PMap map, int requestWeighting, int profileType, boolean hasTimeDependentSpeed) { | ||
//Defaults | ||
String weighting = VAL_RECOMMENDED; | ||
|
||
if (requestWeighting == WeightingMethod.SHORTEST) | ||
weighting = VAL_SHORTEST; | ||
|
||
//For a requested recommended weighting, use recommended for bike, walking and hgv. Use fastest for car. | ||
if (requestWeighting == WeightingMethod.RECOMMENDED || requestWeighting == WeightingMethod.FASTEST) { | ||
if (profileType == RoutingProfileType.DRIVING_CAR) { | ||
weighting = VAL_FASTEST; | ||
} | ||
if (RoutingProfileType.isHeavyVehicle(profileType) || RoutingProfileType.isCycling(profileType) || RoutingProfileType.isWalking(profileType)) { | ||
weighting = VAL_RECOMMENDED; | ||
} | ||
} | ||
|
||
map.putObject(KEY_WEIGHTING, weighting); | ||
|
||
if (hasTimeDependentSpeed) | ||
map.putObject(ORSParameters.Weighting.TIME_DEPENDENT_SPEED_OR_ACCESS, true); | ||
} | ||
} |