Skip to content

Commit 17b73c5

Browse files
committed
very primitive (working) port of the wheelchair attributes to encoded values
1 parent b098003 commit 17b73c5

16 files changed

Lines changed: 926 additions & 34 deletions

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,39 @@ public WheelchairAttributes copy() {
206206
at.suitable = this.suitable;
207207
return at;
208208
}
209+
210+
public String difference(WheelchairAttributes other) {
211+
String diff = "";
212+
if(other.getSlopedKerbHeight() != getSlopedKerbHeight())
213+
diff += "kerbHeight: " + getSlopedKerbHeight() + " vs " + other.getSlopedKerbHeight() + "\n";
214+
215+
if(other.getIncline() != getIncline())
216+
diff += "incline: " + getIncline() + " vs " + other.getIncline() + "\n";
217+
218+
if(other.getWidth() != getWidth())
219+
diff += "width: " + getWidth() + " vs " + other.getWidth() + "\n";
220+
221+
if(other.getTrackType() != getTrackType())
222+
diff += "trackType: " + getTrackType() + " vs " + other.getTrackType() + "\n";
223+
224+
if(other.getSide() != getSide())
225+
diff += "side: " + getSide() + " vs " + other.getSide() + "\n";
226+
227+
if(other.getSmoothnessType() != getSmoothnessType())
228+
diff += "smoothness: " + getSmoothnessType() + " vs " + other.getSmoothnessType() + "\n";
229+
230+
if(other.getSurfaceType() != getSurfaceType())
231+
diff += "surfaceType: " + getSurfaceType() + " vs " + other.getSurfaceType() + "\n";
232+
233+
if(other.isSuitable() != isSuitable())
234+
diff += "suitable: " + isSuitable() + " vs " + other.isSuitable() + "\n";
235+
236+
if(other.isSurfaceQualityKnown() != isSurfaceQualityKnown())
237+
diff += "surfaceQualityKnown: " + isSurfaceQualityKnown() + " vs " + other.isSurfaceQualityKnown() + "\n";
238+
239+
if(other.hasAttributes != hasAttributes)
240+
diff += "hasAttributes: " + hasAttributes + " vs " + other.hasAttributes + "\n";
241+
242+
return diff;
243+
}
209244
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public WheelchairEdgeFilter(WheelchairParameters params, GraphHopperStorage grap
4646
public boolean accept(EdgeIteratorState iter) {
4747
boolean oldValue = oldFilter.accept(iter);
4848
attributes = encodedValues.getAttributes(iter.getFlags());
49-
int num = encodedValues.osmWayIdEnc.getInt(false, iter.getFlags());
50-
if (num == 76911875){
51-
LOGGER.error("stop here");
52-
}
49+
5350
LOGGER.debug("edge: " + iter + (attributes.hasValues() ? " suitable: " + attributes.isSuitable() + " surfaceQualityKnown: " + attributes.isSurfaceQualityKnown() : " no wheelchair attributes"));
5451
boolean newValue = !attributes.hasValues() || !(
5552
checkSurfaceType()
@@ -62,7 +59,7 @@ public boolean accept(EdgeIteratorState iter) {
6259
|| checkUnsuitable()
6360
);
6461
if (oldValue != newValue) {
65-
LOGGER.warn("New wheelchair edge filter value " + newValue + " differs from old filter value " + oldValue + " for edge " + iter.getEdge());
62+
LOGGER.warn(attributes.difference(this.oldFilter.attributes));
6663
}
6764
return newValue;
6865
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class WheelchairEdgeFilterOld implements EdgeFilter {
2626
private static final Logger LOGGER = Logger.getLogger(WheelchairEdgeFilterOld.class.getName());
2727
private final byte[] buffer;
2828
private final WheelchairAttributesGraphStorage storage;
29-
private final WheelchairAttributes attributes;
29+
public final WheelchairAttributes attributes;
3030
private WheelchairParameters params;
3131

3232
public WheelchairEdgeFilterOld(WheelchairParameters params, GraphHopperStorage graphStorage) throws Exception {

ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/util/WheelchairAttributesEncodedValues.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,18 @@ public WheelchairAttributesEncodedValues(EncodingManager encodingManager) {
5151

5252
public WheelchairAttributes getAttributes(IntsRef edgeFlags) {
5353
WheelchairAttributes attrs = new WheelchairAttributes();
54-
attrs.setSurfaceType(surfaceEncoder.getInt(false, edgeFlags));
55-
attrs.setSmoothnessType(smoothnessEncoder.getInt(false, edgeFlags));
56-
attrs.setTrackType(trackTypeEncoder.getInt(false, edgeFlags));
54+
int surface = surfaceEncoder.getInt(false, edgeFlags) - 1;
55+
if(surface > -1)
56+
attrs.setSurfaceType(surface);
57+
58+
int smoothness = smoothnessEncoder.getInt(false, edgeFlags) - 1;
59+
if(smoothness > -1)
60+
attrs.setSmoothnessType(smoothness);
61+
62+
int trackType = trackTypeEncoder.getInt(false, edgeFlags) - 1;
63+
if(trackType > -1)
64+
attrs.setTrackType(trackType);
65+
5766
attrs.setSuitable(suitableEncoder.getBool(false, edgeFlags));
5867
attrs.setSide(sideEncoder.getEnum(false, edgeFlags));
5968
attrs.setSurfaceQualityKnown(surfaceQualityKnownEncoder.getBool(false, edgeFlags));
@@ -63,13 +72,13 @@ public WheelchairAttributes getAttributes(IntsRef edgeFlags) {
6372
attrs.setIncline(incline); // incline is converts to int in WheelchairAttributes, weird that the method takes a double...
6473
}
6574

66-
int width = widthEncoder.getInt(false, edgeFlags);
67-
if (width > 0) {
75+
int width = widthEncoder.getInt(false, edgeFlags) - 1;
76+
if (width > 0) { // no idea why we also exclude 0 here, but this was already the previous behavior and changing it to -1 breaks it
6877
attrs.setWidth(width);
6978
}
7079

71-
int kerb = kerbEncoder.getInt(false, edgeFlags);
72-
if (kerb > 0) {
80+
int kerb = kerbEncoder.getInt(false, edgeFlags) - 1;
81+
if (kerb > -1) {
7382
attrs.setSlopedKerbHeight(kerb);
7483
}
7584

0 commit comments

Comments
 (0)