Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,6 @@ void testWheelchairKerbRestriction() {
.assertThat()
.body("any { it.key == 'routes' }", is(true))
.body("routes[0].summary.distance", is(74.1f))
.body("routes[0].summary.duration", is(49.2f))
.statusCode(200);

restrictions = new JSONObject();
Expand All @@ -2333,6 +2332,19 @@ void testWheelchairKerbRestriction() {
.assertThat()
.body("any { it.key == 'routes' }", is(true))
.body("routes[0].summary.distance", is(105.8f))
.statusCode(200);

body.put("preference", "fastest");

given()
.headers(CommonHeaders.jsonContent)
.pathParam("profile", "wheelchair")
.body(body.toString())
.when()
.post(getEndPointPath() + "/{profile}")
.then()
.assertThat()
.body("any { it.key == 'routes' }", is(true))
.body("routes[0].summary.duration", is(90.7f))
.statusCode(200);
}
Expand Down
2 changes: 1 addition & 1 deletion ors-api/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,4 @@ ors:
- time_after: 2020-01-01T00:00:00Z
- time_before: 2050-06-01T00:00:00Z
- active: true
text: This message would be sent with every request
text: This message would be sent with every request
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.graphhopper.routing.ev;

/**
* EncodedValue for wheelchair incline attribute.
* Stores incline percentage as a signed integer value (range: -50 to +50).
*/
public class WheelchairIncline {
public static final String KEY = "wheelchair_incline";

private WheelchairIncline() {
// Private constructor to prevent instantiation
}

public static IntEncodedValue create() {
// 6 bits signed to store 0% to +50% incline
return new UnsignedIntEncodedValue(KEY, 6, false) {
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.graphhopper.routing.ev;

/**
* EncodedValue for wheelchair kerb/curb height attribute.
* Stores kerb height in centimeters as an unsigned integer value (range: 0-30cm).
*/
public class WheelchairKerb {
public static final String KEY = "wheelchair_kerb";

private WheelchairKerb() {
// Private constructor to prevent instantiation
}

public static IntEncodedValue create() {
// 6 bits unsigned to store 0-30cm kerb height
return new UnsignedIntEncodedValue(KEY, 6, false);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.graphhopper.routing.ev;

import org.heigit.ors.routing.graphhopper.extensions.WheelchairAttributes;

// Side of the sidewalk, if attached.
public class WheelchairSide {

Check warning on line 6 in ors-engine/src/main/java/com/graphhopper/routing/ev/WheelchairSide.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a private constructor to hide the implicit public one.

See more on https://sonarcloud.io/project/issues?id=GIScience_openrouteservice&issues=AZ5j0ibNiwcqmXarFp69&open=AZ5j0ibNiwcqmXarFp69&pullRequest=2284
public static final String KEY = "wheelchair_side";

public static EnumEncodedValue<WheelchairAttributes.Side> create() {
return new EnumEncodedValue<>(KEY, WheelchairAttributes.Side.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.graphhopper.routing.ev;

public class WheelchairSmoothness {

Check warning on line 3 in ors-engine/src/main/java/com/graphhopper/routing/ev/WheelchairSmoothness.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a private constructor to hide the implicit public one.

See more on https://sonarcloud.io/project/issues?id=GIScience_openrouteservice&issues=AZ5j0ibFiwcqmXarFp68&open=AZ5j0ibFiwcqmXarFp68&pullRequest=2284
public static final String KEY = "wheelchair_smoothness";

public static IntEncodedValue create() {
return new UnsignedIntEncodedValue(KEY, 4, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.graphhopper.routing.ev;

/**
* EncodedValue for wheelchair suitable attribute.
*/
public class WheelchairSuitable {
public static final String KEY = "wheelchair_suitable";

private WheelchairSuitable() {
// Private constructor to prevent instantiation
}

public static SimpleBooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.graphhopper.routing.ev;

public class WheelchairSurface {

Check warning on line 3 in ors-engine/src/main/java/com/graphhopper/routing/ev/WheelchairSurface.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a private constructor to hide the implicit public one.

See more on https://sonarcloud.io/project/issues?id=GIScience_openrouteservice&issues=AZ5j0ia-iwcqmXarFp67&open=AZ5j0ia-iwcqmXarFp67&pullRequest=2284
public static final String KEY = "wheelchair_surface";

public static IntEncodedValue create() {
return new UnsignedIntEncodedValue(KEY, 5, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class WheelchairSurfaceQualityKnown {
public static final String KEY = "wheelchair_surface_quality_known";

private WheelchairSurfaceQualityKnown() {
// Private constructor to prevent instantiation
}

public static SimpleBooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.graphhopper.routing.ev;

public class WheelchairTrackType {

Check warning on line 3 in ors-engine/src/main/java/com/graphhopper/routing/ev/WheelchairTrackType.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a private constructor to hide the implicit public one.

See more on https://sonarcloud.io/project/issues?id=GIScience_openrouteservice&issues=AZ5j0ia3iwcqmXarFp66&open=AZ5j0ia3iwcqmXarFp66&pullRequest=2284
public static final String KEY = "wheelchair_track_type";

public static IntEncodedValue create() {
return new UnsignedIntEncodedValue(KEY, 3, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.graphhopper.routing.ev;

/**
* EncodedValue for wheelchair width attribute.
* Stores width in centimeters as an unsigned integer value (range: 0-500cm).
*/
public class WheelchairWidth {
public static final String KEY = "wheelchair_width";

private WheelchairWidth() {
// Private constructor to prevent instantiation
}

public static IntEncodedValue create() {
// 9 bits unsigned to store 0-500cm (0-5 meters)
return new UnsignedIntEncodedValue(KEY, 9, false);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void initExtStorages() {
continue;
}
ExtendedStorageName extendedStorageName = ExtendedStorageName.getEnum(key);

switch (extendedStorageName) {
case HEAVY_VEHICLE -> handleHeavyVehicle(storage);
case OSM_ID -> handleOsmId();
Expand All @@ -111,6 +112,7 @@ public void initExtStorages() {
case TOLLWAYS -> handleTollways();
case HILL_INDEX -> handleHillIndex();
case TRAIL_DIFFICULTY -> handleTrailDifficulty();
case WHEELCHAIR -> handleWheelchair();
default -> {
storage.initialize(extendedStorageName);
this.extStorages.put(key, storage);
Expand Down Expand Up @@ -226,6 +228,36 @@ private void handleTrailDifficulty() {
}
}

private void handleWheelchair() {
if (encodedValues.getWheelchairSurface() == null) {
encodedValues.setWheelchairSurface(true);
}
if (encodedValues.getWheelchairSmoothness() == null) {
encodedValues.setWheelchairSmoothness(true);
}
if (encodedValues.getWheelchairTrackType() == null) {
encodedValues.setWheelchairTrackType(true);
}
if (encodedValues.getWheelchairIncline() == null) {
encodedValues.setWheelchairIncline(true);
}
if (encodedValues.getWheelchairWidth() == null) {
encodedValues.setWheelchairWidth(true);
}
if (encodedValues.getWheelchairKerb() == null) {
encodedValues.setWheelchairKerb(true);
}
if(encodedValues.getWheelchairSuitable() == null) {
encodedValues.setWheelchairSuitable(true);
}
if (encodedValues.getWheelchairSide() == null) {
encodedValues.setWheelchairSide(true);
}
if(encodedValues.getWheelchairSurfaceQualityKnown() == null) {
encodedValues.setWheelchairSurfaceQualityKnown(true);
}
}

@JsonIgnore
public String getEncoderOptionsString() {
if (encoderOptions == null) return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ public class EncodedValuesProperties {
private Boolean maxWeight;
@JsonProperty(MaxWidth.KEY)
private Boolean maxWidth;
@JsonProperty(WheelchairSurface.KEY)
private Boolean wheelchairSurface;
@JsonProperty(WheelchairSmoothness.KEY)
private Boolean wheelchairSmoothness;
@JsonProperty(WheelchairTrackType.KEY)
private Boolean wheelchairTrackType;
@JsonProperty(WheelchairSurfaceQualityKnown.KEY)
private Boolean wheelchairSurfaceQualityKnown;
@JsonProperty(WheelchairIncline.KEY)
private Boolean wheelchairIncline;
@JsonProperty(WheelchairWidth.KEY)
private Boolean wheelchairWidth;
@JsonProperty(WheelchairKerb.KEY)
private Boolean wheelchairKerb;
@JsonProperty(WheelchairSuitable.KEY)
private Boolean wheelchairSuitable;
@JsonProperty(WheelchairSide.KEY)
private Boolean wheelchairSide;
@JsonProperty(AccessRestriction.KEY)
private Boolean accessRestriction;
@JsonProperty(Toll.KEY)
Expand Down Expand Up @@ -97,6 +115,15 @@ private Map<String, Boolean> getProperties() {
properties.put(MaxLength.KEY, maxLength);
properties.put(MaxWeight.KEY, maxWeight);
properties.put(MaxWidth.KEY, maxWidth);
properties.put(WheelchairSurface.KEY, wheelchairSurface);
properties.put(WheelchairSmoothness.KEY, wheelchairSmoothness);
properties.put(WheelchairTrackType.KEY, wheelchairTrackType);
properties.put(WheelchairSurfaceQualityKnown.KEY, wheelchairSurfaceQualityKnown);
properties.put(WheelchairIncline.KEY, wheelchairIncline);
properties.put(WheelchairWidth.KEY, wheelchairWidth);
properties.put(WheelchairKerb.KEY, wheelchairKerb);
properties.put(WheelchairSuitable.KEY, wheelchairSuitable);
properties.put(WheelchairSide.KEY, wheelchairSide);
properties.put(AccessRestriction.KEY, accessRestriction);
properties.put(Toll.KEY, toll);
properties.put(HillIndex.KEY, hillIndex);
Expand Down Expand Up @@ -139,6 +166,15 @@ public void merge(EncodedValuesProperties other) {
maxLength = ofNullable(this.maxLength).orElse(other.maxLength);
maxWeight = ofNullable(this.maxWeight).orElse(other.maxWeight);
maxWidth = ofNullable(this.maxWidth).orElse(other.maxWidth);
wheelchairSurface = ofNullable(this.wheelchairSurface).orElse(other.wheelchairSurface);
wheelchairSmoothness = ofNullable(this.wheelchairSmoothness).orElse(other.wheelchairSmoothness);
wheelchairTrackType = ofNullable(this.wheelchairTrackType).orElse(other.wheelchairTrackType);
wheelchairSurfaceQualityKnown = ofNullable(this.wheelchairSurfaceQualityKnown).orElse(other.wheelchairSurfaceQualityKnown);
wheelchairIncline = ofNullable(this.wheelchairIncline).orElse(other.wheelchairIncline);
wheelchairWidth = ofNullable(this.wheelchairWidth).orElse(other.wheelchairWidth);
wheelchairKerb = ofNullable(this.wheelchairKerb).orElse(other.wheelchairKerb);
wheelchairSuitable = ofNullable(this.wheelchairSuitable).orElse(other.wheelchairSuitable);
wheelchairSide = ofNullable(this.wheelchairSide).orElse(other.wheelchairSide);
accessRestriction = ofNullable(this.accessRestriction).orElse(other.accessRestriction);
toll = ofNullable(this.toll).orElse(other.toll);
hillIndex = ofNullable(this.hillIndex).orElse(other.hillIndex);
Expand All @@ -147,3 +183,5 @@ public void merge(EncodedValuesProperties other) {
mtbScaleUphill = ofNullable(this.mtbScaleUphill).orElse(other.mtbScaleUphill);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.heigit.ors.routing.RoutingProfileType;
import org.heigit.ors.routing.WeightingMethod;
import org.heigit.ors.routing.graphhopper.extensions.WheelchairAttributes;
import org.heigit.ors.routing.graphhopper.extensions.storages.GraphStorageUtils;

Check warning on line 22 in ors-engine/src/main/java/org/heigit/ors/export/ExportRequest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'org.heigit.ors.routing.graphhopper.extensions.storages.GraphStorageUtils'.

See more on https://sonarcloud.io/project/issues?id=GIScience_openrouteservice&issues=AZ5j0iZriwcqmXarFp63&open=AZ5j0iZriwcqmXarFp63&pullRequest=2284
import org.heigit.ors.routing.graphhopper.extensions.storages.WheelchairAttributesGraphStorage;
import org.heigit.ors.routing.graphhopper.extensions.util.WheelchairAttributesEncodedValues;
import org.heigit.ors.util.ProfileTools;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
Expand Down Expand Up @@ -49,7 +49,7 @@

private static final int NO_TIME = -1;
private IntEncodedValue osmWayIdEnc;
private WheelchairAttributesGraphStorage wheelchairAttributesGraphStorage;
private WheelchairAttributesEncodedValues wheelchairAttributesEnc;
private Weighting weighting;

public void setBoundingBox(BBox bbox) {
Expand Down Expand Up @@ -89,7 +89,9 @@
// Ignore osm_way_id if not available
osmWayIdEnc = null;
}
wheelchairAttributesGraphStorage = GraphStorageUtils.getGraphExtension(gh.getGraphHopperStorage(), WheelchairAttributesGraphStorage.class);

if(gh.getEncodingManager().hasEncoder("wheelchair"))
wheelchairAttributesEnc = new WheelchairAttributesEncodedValues(gh.getEncodingManager());

// filter graph for nodes in Bounding Box
Set<Integer> nodesInBBox = nodesInBBox(gh.getLocationIndex(), nodeAccess, graph);
Expand Down Expand Up @@ -171,10 +173,9 @@
extra.put("osm_id", osmWayIdEnc.getInt(false, iter.getFlags()));
}
extra.put("ors_id", iter.getEdge());
if (wheelchairAttributesGraphStorage != null) {
WheelchairAttributes attributes = new WheelchairAttributes();
byte[] buffer = new byte[WheelchairAttributesGraphStorage.BYTE_COUNT];
wheelchairAttributesGraphStorage.getEdgeValues(iter.getEdge(), attributes, buffer);
if (wheelchairAttributesEnc != null) {
WheelchairAttributes attributes = wheelchairAttributesEnc.getAttributes(iter.getFlags());

if (attributes.hasValues()) {
extra.put("incline", attributes.getIncline());
extra.put("surface_quality_known", attributes.isSurfaceQualityKnown());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@
nodeTagsToStore = new HashSet<>(Arrays.asList("maxheight", "maxweight", "maxweight:hgv", "maxwidth", "maxlength", "maxlength:hgv", "maxaxleload"));
osmNodeTagValues = new GHLongObjectHashMap<>(200, .5f);

if(super.encodingManager.hasEncoder("wheelchair")) {
this.processNodeTags = true;
this.processSimpleGeom = true;
extraTagKeys.add("kerb");
extraTagKeys.add("kerb:both");
extraTagKeys.add("kerb:left");
extraTagKeys.add("kerb:right");
extraTagKeys.add("kerb:height");
extraTagKeys.add("kerb:both:height");
extraTagKeys.add("kerb:left:height");
extraTagKeys.add("kerb:right:height");
}

// Look if we should do border processing - if so then we have to process the geometry
for (GraphStorageBuilder b : this.procCntx.getStorageBuilders()) {
if (b instanceof BordersGraphStorageBuilder) {
Expand All @@ -90,19 +103,6 @@
this.processGeom = true;
this.processWholeGeom = true;
}

if (b instanceof WheelchairGraphStorageBuilder) {
this.processNodeTags = true;
this.processSimpleGeom = true;
extraTagKeys.add("kerb");
extraTagKeys.add("kerb:both");
extraTagKeys.add("kerb:left");
extraTagKeys.add("kerb:right");
extraTagKeys.add("kerb:height");
extraTagKeys.add("kerb:both:height");
extraTagKeys.add("kerb:left:height");
extraTagKeys.add("kerb:right:height");
}
}

if (procCntx.isUseSidewalks()) {
Expand Down Expand Up @@ -251,7 +251,7 @@
*
* @param way The way object read from the OSM data (not including geometry)
*/
private void onProcessWay(ReaderWay way) {

Check warning on line 254 in ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/ORSOSMReader.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 70 to 64, Complexity from 22 to 14, Nesting Level from 5 to 2, Number of Variables from 21 to 6.

See more on https://sonarcloud.io/project/issues?id=GIScience_openrouteservice&issues=AZ5j0iZOiwcqmXarFp62&open=AZ5j0iZOiwcqmXarFp62&pullRequest=2284
Map<Integer, Map<String, String>> tags = new HashMap<>();
ArrayList<Coordinate> coords = new ArrayList<>();
ArrayList<Coordinate> allCoordinates = new ArrayList<>();
Expand Down Expand Up @@ -281,6 +281,10 @@
tags.put(internalId, tagsForNode);
}
}

if (!tags.isEmpty()) {
way.setTag("ors:node_tags", nodeTags);
}
}

if (processGeom || processSimpleGeom) {
Expand Down Expand Up @@ -385,6 +389,7 @@
}
}


private void storeConditionalAccess(AcceptWay acceptWay, EdgeIteratorState edge) {
for (FlagEncoder encoder : encodingManager.fetchEdgeEncoders()) {
String encoderName = encoder.toString();
Expand Down
Loading
Loading