Skip to content

Commit

Permalink
Adds support for routing cars in pedestrian streets that allows for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkrog committed Feb 12, 2024
1 parent 373b233 commit e8a137b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ graphhopper:
# motorized vehicles. This leads to a smaller and less dense graph, because there are fewer ways (obviously),
# but also because there are fewer crossings between highways (=junctions).
# Another typical example is excluding 'motorway', 'trunk' and maybe 'primary' highways for bicycle or pedestrian routing.
import.osm.ignored_highways: footway,cycleway,path,pedestrian,steps # typically useful for motorized-only routing
import.osm.ignored_highways: footway,cycleway,path,steps # typically useful for motorized-only routing
# import.osm.ignored_highways: motorway,trunk # typically useful for non-motorized routing

# configure the memory access, use RAM_STORE for well equipped servers (default and recommended)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.graphhopper.routing.util.countryrules.CountryRule;

/**
* Defines the default rules for Polish roads
* Defines the default rules for Danish roads
*
* @author Thomas Butz
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class CarAccessParser extends AbstractAccessParser implements TagParser {

protected final Set<String> trackTypeValues = new HashSet<>();
protected final Set<String> highwayValues = new HashSet<>();
protected final Set<String> pedestrianAccessValues = new HashSet<>();
protected final BooleanEncodedValue roundaboutEnc;

public CarAccessParser(EncodedValueLookup lookup, PMap properties) {
Expand Down Expand Up @@ -71,7 +72,9 @@ public CarAccessParser(BooleanEncodedValue accessEnc,

highwayValues.addAll(Arrays.asList("motorway", "motorway_link", "trunk", "trunk_link",
"primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link",
"unclassified", "residential", "living_street", "service", "road", "track"));
"unclassified", "residential", "living_street", "service", "road", "track", "pedestrian"));

pedestrianAccessValues.addAll(Arrays.asList("destination", "yes", "customers"));

trackTypeValues.addAll(Arrays.asList("grade1", "grade2", "grade3", null));
}
Expand Down Expand Up @@ -155,6 +158,20 @@ public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way
List<Map<String, Object>> nodeTags = way.getTag("node_tags", Collections.emptyList());
handleBarrierEdge(edgeId, edgeIntAccess, nodeTags.get(0));
}

if("pedestrian".equals(way.getTag("highway"))) {
boolean allowed = way.hasTag("motor_vehicle", pedestrianAccessValues) ||
way.hasTag("vehicle", pedestrianAccessValues);
if (isOneway(way)) {
if (isForwardOneway(way))
accessEnc.setBool(false, edgeId, edgeIntAccess, allowed);
if (isBackwardOneway(way))
accessEnc.setBool(true, edgeId, edgeIntAccess, allowed);
} else {
accessEnc.setBool(false, edgeId, edgeIntAccess, allowed);
accessEnc.setBool(true, edgeId, edgeIntAccess, allowed);
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3149,6 +3149,11 @@
],
"DK": [
{
"name": "pedestrian",
"tags": {
"maxspeed": "walk"
}
},{
"name": "living street",
"tags": {
"maxspeed": "15"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ public void testAccess() {
way.setTag("highway", "service");
way.setTag("service", "emergency_access");
assertTrue(parser.getAccess(way).canSkip());

way.clearTags();
way.setTag("highway", "pedestrian");
way.setTag("motor_vehicle", "yes");
assertTrue(parser.getAccess(way).isWay());

way.clearTags();
way.setTag("highway", "pedestrian");
way.setTag("motor_vehicle", "destination");
assertTrue(parser.getAccess(way).isWay());

way.clearTags();
way.setTag("highway", "pedestrian");
way.setTag("motor_vehicle", "customer");
assertTrue(parser.getAccess(way).isWay());
}

@Test
Expand Down Expand Up @@ -701,7 +716,7 @@ public void testIssue_1256() {
@ValueSource(strings = {"mofa", "moped", "motorcar", "motor_vehicle", "motorcycle"})
void footway_etc_not_allowed_despite_vehicle_yes(String vehicle) {
// these highways are blocked, even when we set one of the vehicles to yes
for (String highway : Arrays.asList("footway", "cycleway", "steps", "pedestrian")) {
for (String highway : Arrays.asList("footway", "cycleway", "steps")) {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", highway);
way.setTag(vehicle, "yes");
Expand Down

0 comments on commit e8a137b

Please sign in to comment.