Skip to content

Commit

Permalink
Merge pull request #1 from Apaq/2888-allow-routing-pedestrian-streets
Browse files Browse the repository at this point in the history
Allow routing cars in pedestrian streets
  • Loading branch information
michaelkrog authored Feb 12, 2024
2 parents 8996c25 + 045e791 commit 55f2df3
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ jobs:
${{ runner.os}}-node_modules-
- name: Build ${{ matrix.java-version }}
run: mvn -B clean test

6 changes: 3 additions & 3 deletions .github/workflows/remove-old-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:
jobs:
remove-old-artifacts:
if: github.repository_owner == 'graphhopper'
if: github.repository_owner == 'Apaq'
name: Remove old artifacts
runs-on: ubuntu-latest
timeout-minutes: 10 # stop the task if it takes longer
Expand All @@ -19,7 +19,7 @@ jobs:
skip-recent: 300

remove-old-artifacts-2:
if: github.repository_owner == 'graphhopper'
if: github.repository_owner == 'Apaq'
name: Remove old artifacts
runs-on: ubuntu-latest
timeout-minutes: 10 # stop the task if it takes longer
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
min-versions-to-keep: 300

remove-old-artifacts-3:
if: github.repository_owner == 'graphhopper'
if: github.repository_owner == 'Apaq'
name: Remove old artifacts 3
runs-on: ubuntu-latest
timeout-minutes: 10 # stop the task if it takes longer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Trigger Benchmarks
on: push
jobs:
trigger_measurement:
if: github.repository_owner == 'graphhopper'
if: github.repository_owner == 'Apaq'
runs-on: ubuntu-22.04
environment: benchmarks
steps:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Here is an overview:
* matkoniecz, tweaking documentation
* manueltimita, fixes like #1651
* mathstpierre, fixes like #1753
* michaelkrog, Pedestrian street improvements
* michalmac, fixes like #1467
* michaz, one of the core developers
* mprins, improvements for travis CI and regarding JDK9 #806
Expand Down
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 @@ -702,7 +717,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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
<repository>
<id>github</id>
<name>GitHub GraphHopper Apache Maven Packages</name>
<url>https://maven.pkg.github.com/graphhopper/graphhopper</url>
<url>https://maven.pkg.github.com/apaq/graphhopper</url>
</repository>
</distributionManagement>

Expand Down

0 comments on commit 55f2df3

Please sign in to comment.