Skip to content

Commit b098003

Browse files
aolesjarinox
authored andcommitted
feat: compare new edge filter against original storage-based one
1 parent 23bf199 commit b098003

3 files changed

Lines changed: 114 additions & 3 deletions

File tree

ors-engine/src/main/java/org/heigit/ors/config/profile/BuildProperties.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public void initExtStorages() {
102102
continue;
103103
}
104104
ExtendedStorageName extendedStorageName = ExtendedStorageName.getEnum(key);
105+
106+
// FIXME: debug code
107+
if (extendedStorageName == ExtendedStorageName.WHEELCHAIR) {
108+
handleWheelchair();
109+
}
110+
105111
switch (extendedStorageName) {
106112
case HEAVY_VEHICLE -> handleHeavyVehicle(storage);
107113
case OSM_ID -> handleOsmId();
@@ -111,7 +117,7 @@ public void initExtStorages() {
111117
case TOLLWAYS -> handleTollways();
112118
case HILL_INDEX -> handleHillIndex();
113119
case TRAIL_DIFFICULTY -> handleTrailDifficulty();
114-
case WHEELCHAIR -> handleWheelchair();
120+
//case WHEELCHAIR -> handleWheelchair();
115121
default -> {
116122
storage.initialize(extendedStorageName);
117123
this.extStorages.put(key, storage);

ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/edgefilters/WheelchairEdgeFilter.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ public class WheelchairEdgeFilter implements EdgeFilter {
3030
private final WheelchairAttributesEncodedValues encodedValues;
3131
private WheelchairAttributes attributes;
3232
private WheelchairParameters params;
33+
private WheelchairEdgeFilterOld oldFilter;
3334

34-
public WheelchairEdgeFilter(WheelchairParameters params, GraphHopperStorage graphStorage) {
35+
public WheelchairEdgeFilter(WheelchairParameters params, GraphHopperStorage graphStorage) throws Exception {
36+
oldFilter = new WheelchairEdgeFilterOld(params, graphStorage);
3537
encodedValues = new WheelchairAttributesEncodedValues(graphStorage.getEncodingManager());
3638
this.params = params;
3739
if (this.params == null) {
@@ -42,13 +44,14 @@ public WheelchairEdgeFilter(WheelchairParameters params, GraphHopperStorage grap
4244

4345
@Override
4446
public boolean accept(EdgeIteratorState iter) {
47+
boolean oldValue = oldFilter.accept(iter);
4548
attributes = encodedValues.getAttributes(iter.getFlags());
4649
int num = encodedValues.osmWayIdEnc.getInt(false, iter.getFlags());
4750
if (num == 76911875){
4851
LOGGER.error("stop here");
4952
}
5053
LOGGER.debug("edge: " + iter + (attributes.hasValues() ? " suitable: " + attributes.isSuitable() + " surfaceQualityKnown: " + attributes.isSurfaceQualityKnown() : " no wheelchair attributes"));
51-
return !attributes.hasValues() || !(
54+
boolean newValue = !attributes.hasValues() || !(
5255
checkSurfaceType()
5356
|| checkSmoothnessType()
5457
|| checkTrackType()
@@ -58,6 +61,10 @@ public boolean accept(EdgeIteratorState iter) {
5861
|| checkSurfaceQualityKnown()
5962
|| checkUnsuitable()
6063
);
64+
if (oldValue != newValue) {
65+
LOGGER.warn("New wheelchair edge filter value " + newValue + " differs from old filter value " + oldValue + " for edge " + iter.getEdge());
66+
}
67+
return newValue;
6168
}
6269

6370
private boolean checkSurfaceType() {
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* This file is part of Openrouteservice.
2+
*
3+
* Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the
4+
* GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1
5+
* of the License, or (at your option) any later version.
6+
7+
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9+
* See the GNU Lesser General Public License for more details.
10+
11+
* You should have received a copy of the GNU Lesser General Public License along with this library;
12+
* if not, see <https://www.gnu.org/licenses/>.
13+
*/
14+
package org.heigit.ors.routing.graphhopper.extensions.edgefilters;
15+
16+
import com.graphhopper.routing.util.EdgeFilter;
17+
import com.graphhopper.storage.GraphHopperStorage;
18+
import com.graphhopper.util.EdgeIteratorState;
19+
import org.apache.log4j.Logger;
20+
import org.heigit.ors.routing.graphhopper.extensions.WheelchairAttributes;
21+
import org.heigit.ors.routing.graphhopper.extensions.storages.GraphStorageUtils;
22+
import org.heigit.ors.routing.graphhopper.extensions.storages.WheelchairAttributesGraphStorage;
23+
import org.heigit.ors.routing.parameters.WheelchairParameters;
24+
25+
public class WheelchairEdgeFilterOld implements EdgeFilter {
26+
private static final Logger LOGGER = Logger.getLogger(WheelchairEdgeFilterOld.class.getName());
27+
private final byte[] buffer;
28+
private final WheelchairAttributesGraphStorage storage;
29+
private final WheelchairAttributes attributes;
30+
private WheelchairParameters params;
31+
32+
public WheelchairEdgeFilterOld(WheelchairParameters params, GraphHopperStorage graphStorage) throws Exception {
33+
storage = GraphStorageUtils.getGraphExtension(graphStorage, WheelchairAttributesGraphStorage.class);
34+
if (storage == null)
35+
throw new Exception("ExtendedGraphStorage for wheelchair attributes was not found.");
36+
this.params = params;
37+
if (this.params == null) {
38+
this.params = new WheelchairParameters();
39+
}
40+
attributes = new WheelchairAttributes();
41+
buffer = new byte[WheelchairAttributesGraphStorage.BYTE_COUNT];
42+
}
43+
44+
@Override
45+
public boolean accept(EdgeIteratorState iter) {
46+
storage.getEdgeValues(iter.getEdge(), attributes, buffer);
47+
LOGGER.debug("edge: " + iter + (attributes.hasValues() ? " suitable: " + attributes.isSuitable() + " surfaceQualityKnown: " + attributes.isSurfaceQualityKnown() : " no wheelchair attributes"));
48+
return !attributes.hasValues() || !(
49+
checkSurfaceType()
50+
|| checkSmoothnessType()
51+
|| checkTrackType()
52+
|| checkMaximumIncline()
53+
|| checkMaximumSlopedKerb()
54+
|| checkMinimumWidth()
55+
|| checkSurfaceQualityKnown()
56+
|| checkUnsuitable()
57+
);
58+
}
59+
60+
private boolean checkSurfaceType() {
61+
return params.getSurfaceType() > 0
62+
&& params.getSurfaceType() < attributes.getSurfaceType();
63+
}
64+
65+
private boolean checkSmoothnessType() {
66+
return params.getSmoothnessType() > 0
67+
&& params.getSmoothnessType() < attributes.getSmoothnessType();
68+
}
69+
70+
private boolean checkTrackType() {
71+
return params.getTrackType() > 0 && attributes.getTrackType() != 0
72+
&& params.getTrackType() <= attributes.getTrackType();
73+
}
74+
75+
private boolean checkMaximumIncline() {
76+
return params.getMaximumIncline() > (Float.MAX_VALUE * -1.0f)
77+
&& params.getMaximumIncline() < attributes.getIncline();
78+
}
79+
80+
private boolean checkMaximumSlopedKerb() {
81+
return params.getMaximumSlopedKerb() >= 0.0
82+
&& params.getMaximumSlopedKerb() * 100.0 < attributes.getSlopedKerbHeight();// Stored in storage in cm
83+
}
84+
85+
private boolean checkMinimumWidth() {
86+
return params.getMinimumWidth() > 0.0
87+
&& attributes.getWidth() > 0.0 // if the attribute value is 0, this signifies that no data is available
88+
&& params.getMinimumWidth() * 100.0 > attributes.getWidth(); // stored in storage in cm
89+
}
90+
91+
private boolean checkSurfaceQualityKnown() {
92+
return params.isRequireSurfaceQualityKnown() && !attributes.isSurfaceQualityKnown();
93+
}
94+
95+
private boolean checkUnsuitable() {
96+
return !params.allowUnsuitable() && !attributes.isSuitable();
97+
}
98+
}

0 commit comments

Comments
 (0)