Skip to content

Commit

Permalink
Make ways with motorroad=yes car-only
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 28, 2024
1 parent 2cc3ce4 commit e1d3a22
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ else if (speedLimit <= 16.65f) {
// Don't recommend walking in trunk road tunnels
props.setProperties("highway=trunk;tunnel=yes", withModes(CAR).bicycleSafety(7.47));

// Do not walk on "moottoriliikennetie"
props.setProperties("motorroad=yes", withModes(CAR).bicycleSafety(7.47));

// Remove informal and private roads
props.setProperties("highway=*;informal=yes", withModes(NONE));
props.setProperties("highway=service;access=private", withModes(NONE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.opentripplanner.osm.wayproperty.WayProperties;
import org.opentripplanner.osm.wayproperty.WayPropertySet;
import org.opentripplanner.osm.wayproperty.specifier.BestMatchSpecifier;
import org.opentripplanner.osm.wayproperty.specifier.Condition;
import org.opentripplanner.osm.wayproperty.specifier.ExactMatchSpecifier;
import org.opentripplanner.osm.wayproperty.specifier.LogicalOrSpecifier;
import org.opentripplanner.routing.services.notes.StreetNotesService;
Expand Down Expand Up @@ -104,6 +103,9 @@ public void populateProperties(WayPropertySet props) {
props.setProperties("highway=trunk", withModes(CAR).bicycleSafety(7.47));
props.setProperties("highway=motorway", withModes(CAR).bicycleSafety(8));

// Do not walk on "moottoriliikennetie"/"Kraftfahrstrasse"
props.setProperties(new ExactMatchSpecifier("motorroad=yes"), withModes(CAR));

/* cycleway=lane */
props.setProperties(
"highway=*;cycleway=lane",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.street.model.StreetTraversalPermission.ALL;
import static org.opentripplanner.street.model.StreetTraversalPermission.CAR;

import org.junit.jupiter.api.Test;
import org.opentripplanner.osm.model.OsmWithTags;
import org.opentripplanner.osm.wayproperty.WayPropertySet;
import org.opentripplanner.osm.wayproperty.specifier.WayTestData;

public class OsmTagMapperTest {
class OsmTagMapperTest {

@Test
public void isMotorThroughTrafficExplicitlyDisallowed() {
void isMotorThroughTrafficExplicitlyDisallowed() {
OsmWithTags o = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -34,7 +37,7 @@ public void isMotorThroughTrafficExplicitlyDisallowed() {
}

@Test
public void isBicycleThroughTrafficExplicitlyDisallowed() {
void isBicycleThroughTrafficExplicitlyDisallowed() {
OsmTagMapper osmTagMapper = new OsmTagMapper();
assertTrue(
osmTagMapper.isBicycleThroughTrafficExplicitlyDisallowed(way("bicycle", "destination"))
Expand All @@ -45,14 +48,14 @@ public void isBicycleThroughTrafficExplicitlyDisallowed() {
}

@Test
public void isWalkThroughTrafficExplicitlyDisallowed() {
void isWalkThroughTrafficExplicitlyDisallowed() {
OsmTagMapper osmTagMapper = new OsmTagMapper();
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(way("foot", "destination")));
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(way("access", "destination")));
}

@Test
public void testAccessNo() {
void testAccessNo() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -64,7 +67,7 @@ public void testAccessNo() {
}

@Test
public void testAccessPrivate() {
void testAccessPrivate() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -76,7 +79,7 @@ public void testAccessPrivate() {
}

@Test
public void testFootModifier() {
void testFootModifier() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -89,7 +92,7 @@ public void testFootModifier() {
}

@Test
public void testVehicleDenied() {
void testVehicleDenied() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -101,7 +104,7 @@ public void testVehicleDenied() {
}

@Test
public void testVehicleDeniedMotorVehiclePermissive() {
void testVehicleDeniedMotorVehiclePermissive() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -114,7 +117,7 @@ public void testVehicleDeniedMotorVehiclePermissive() {
}

@Test
public void testVehicleDeniedBicyclePermissive() {
void testVehicleDeniedBicyclePermissive() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -127,7 +130,7 @@ public void testVehicleDeniedBicyclePermissive() {
}

@Test
public void testMotorcycleModifier() {
void testMotorcycleModifier() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -140,7 +143,7 @@ public void testMotorcycleModifier() {
}

@Test
public void testBicycleModifier() {
void testBicycleModifier() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -153,7 +156,7 @@ public void testBicycleModifier() {
}

@Test
public void testBicyclePermissive() {
void testBicyclePermissive() {
OsmWithTags tags = new OsmWithTags();
OsmTagMapper osmTagMapper = new OsmTagMapper();

Expand All @@ -165,6 +168,19 @@ public void testBicyclePermissive() {
assertTrue(osmTagMapper.isWalkThroughTrafficExplicitlyDisallowed(tags));
}

@Test
void motorroad() {
OsmTagMapper osmTagMapper = new OsmTagMapper();
WayPropertySet wps = new WayPropertySet();
osmTagMapper.populateProperties(wps);

var way = WayTestData.carTunnel();
assertEquals(ALL, wps.getDataForWay(way).getPermission());

way.addTag("motorroad","yes");
assertEquals(CAR, wps.getDataForWay(way).getPermission());
}

public OsmWithTags way(String key, String value) {
var way = new OsmWithTags();
way.addTag(key, value);
Expand Down
2 changes: 1 addition & 1 deletion doc/user/osm/Finland.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Lower safety values make an OSM way more desirable and higher values less desira
| `highway=trunk_link` | `ALL` | 2.06 | |
| `highway=trunk` | `ALL` | 7.47 | |
| `highway=trunk; tunnel=yes` | `CAR` | 7.47 | |
| `motorroad=yes` | `CAR` | 7.47 | |
| `present(highway); informal=yes` | `NONE` | | |
| `highway=service; access=private` | `NONE` | | |
| `highway=trail` | `NONE` | | |
Expand Down Expand Up @@ -105,6 +104,7 @@ Lower safety values make an OSM way more desirable and higher values less desira
| `highway=motorway_link` | `CAR` | 2.06 | |
| `highway=trunk` | `CAR` | 7.47 | |
| `highway=motorway` | `CAR` | 8.0 | |
| `motorroad=yes` | `CAR` | | |
| `present(highway); cycleway=lane` | `PEDESTRIAN_AND_BICYCLE` | 0.87 | |
| `highway=service; cycleway=lane` | `ALL` | 0.77 | |
| `highway=residential; cycleway=lane` | `ALL` | 0.77 | |
Expand Down
1 change: 1 addition & 0 deletions doc/user/osm/Germany.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Lower safety values make an OSM way more desirable and higher values less desira
| `highway=motorway_link` | `CAR` | 2.06 | |
| `highway=trunk` | `CAR` | 7.47 | |
| `highway=motorway` | `CAR` | 8.0 | |
| `motorroad=yes` | `CAR` | | |
| `present(highway); cycleway=lane` | `PEDESTRIAN_AND_BICYCLE` | 0.87 | |
| `highway=service; cycleway=lane` | `ALL` | 0.77 | |
| `highway=residential; cycleway=lane` | `ALL` | 0.77 | |
Expand Down
1 change: 1 addition & 0 deletions doc/user/osm/OsmTag.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Lower safety values make an OSM way more desirable and higher values less desira
| `highway=motorway_link` | `CAR` | 2.06 | |
| `highway=trunk` | `CAR` | 7.47 | |
| `highway=motorway` | `CAR` | 8.0 | |
| `motorroad=yes` | `CAR` | | |
| `present(highway); cycleway=lane` | `PEDESTRIAN_AND_BICYCLE` | 0.87 | |
| `highway=service; cycleway=lane` | `ALL` | 0.77 | |
| `highway=residential; cycleway=lane` | `ALL` | 0.77 | |
Expand Down
1 change: 1 addition & 0 deletions doc/user/osm/UK.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Lower safety values make an OSM way more desirable and higher values less desira
| `highway=motorway_link` | `CAR` | 2.06 | |
| `highway=trunk` | `CAR` | 7.47 | |
| `highway=motorway` | `CAR` | 8.0 | |
| `motorroad=yes` | `CAR` | | |
| `present(highway); cycleway=lane` | `PEDESTRIAN_AND_BICYCLE` | 0.87 | |
| `highway=service; cycleway=lane` | `ALL` | 0.77 | |
| `highway=residential; cycleway=lane` | `ALL` | 0.77 | |
Expand Down

0 comments on commit e1d3a22

Please sign in to comment.