Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove banDiscouragedCycling and banDiscouragedWalking #5341

Merged
Merged
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
2 changes: 0 additions & 2 deletions docs/BuildConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Sections follow that describe particular settings in more depth.
| Config Parameter | Type | Summary | Req./Opt. | Default Value | Since |
|--------------------------------------------------------------------------|:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------:|-----------------------------------|:-----:|
| [areaVisibility](#areaVisibility) | `boolean` | Perform visibility calculations. | *Optional* | `false` | 1.5 |
| banDiscouragedBiking | `boolean` | Should biking be allowed on OSM ways tagged with `bicycle=discouraged` | *Optional* | `false` | 2.0 |
| banDiscouragedWalking | `boolean` | Should walking be allowed on OSM ways tagged with `foot=discouraged` | *Optional* | `false` | 2.0 |
| [buildReportDir](#buildReportDir) | `uri` | URI to the directory where the graph build report should be written to. | *Optional* | | 2.0 |
| [configVersion](#configVersion) | `string` | Deployment version of the *build-config.json*. | *Optional* | | 2.1 |
| [dataImportReport](#dataImportReport) | `boolean` | Generate nice HTML report of Graph errors/warnings | *Optional* | `false` | 2.0 |
Expand Down
2 changes: 0 additions & 2 deletions docs/examples/entur/build-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"islandWithoutStopsMaxSize": 5,
"islandWithStopsMaxSize": 5
},
"banDiscouragedWalking": false,
"banDiscouragedBiking": false,
"maxTransferDuration": "30m",
"distanceBetweenElevationSamples": 25,
"multiThreadElevationCalculations": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ static OsmModule provideOpenStreetMapModule(
.withPlatformEntriesLinking(config.platformEntriesLinking)
.withStaticParkAndRide(config.staticParkAndRide)
.withStaticBikeParkAndRide(config.staticBikeParkAndRide)
.withBanDiscouragedWalking(config.banDiscouragedWalking)
.withBanDiscouragedBiking(config.banDiscouragedBiking)
.withMaxAreaNodes(config.maxAreaNodes)
.withBoardingAreaRefTags(config.boardingLocationTags)
.withIssueStore(issueStore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public static StreetTraversalPermission getPermissionsForEntity(
public static StreetTraversalPermission getPermissionsForWay(
OSMWay way,
StreetTraversalPermission def,
boolean banDiscouragedWalking,
boolean banDiscouragedBiking,
DataImportIssueStore issueStore
) {
StreetTraversalPermission permissions = getPermissionsForEntity(way, def);
Expand Down Expand Up @@ -121,22 +119,14 @@ public static StreetTraversalPermission getPermissionsForWay(
permissions = permissions.remove(StreetTraversalPermission.PEDESTRIAN);
}

// Check for foot=discouraged, if applicable
if (banDiscouragedWalking && way.hasTag("foot") && way.getTag("foot").equals("discouraged")) {
permissions = permissions.remove(StreetTraversalPermission.PEDESTRIAN);
}

// Compute bike permissions, check consistency.
boolean forceBikes = false;
if (way.isBicycleExplicitlyAllowed()) {
permissions = permissions.add(StreetTraversalPermission.BICYCLE);
forceBikes = true;
}

if (
way.isBicycleDismountForced() ||
(banDiscouragedBiking && way.hasTag("bicycle") && way.getTag("bicycle").equals("discouraged"))
) {
if (way.isBicycleDismountForced()) {
permissions = permissions.remove(StreetTraversalPermission.BICYCLE);
if (forceBikes) {
issueStore.add(new ConflictingBikeTags(way));
Expand All @@ -150,7 +140,7 @@ public static StreetTraversalPermission getPermissionsForWay(
OSMWay way,
StreetTraversalPermission def
) {
return getPermissionsForWay(way, def, false, false, DataImportIssueStore.NOOP);
return getPermissionsForWay(way, def, DataImportIssueStore.NOOP);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ private void buildBasicGraph() {
StreetTraversalPermission permissions = OsmFilter.getPermissionsForWay(
way,
wayData.getPermission(),
params.banDiscouragedWalking(),
params.banDiscouragedBiking(),
issueStore
);
if (!OsmFilter.isWayRoutable(way) || permissions.allowsNothing()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class OsmModuleBuilder {
private boolean platformEntriesLinking = false;
private boolean staticParkAndRide = false;
private boolean staticBikeParkAndRide = false;
private boolean banDiscouragedWalking = false;
private boolean banDiscouragedBiking = false;
private int maxAreaNodes;

OsmModuleBuilder(Collection<OsmProvider> providers, Graph graph) {
Expand Down Expand Up @@ -67,16 +65,6 @@ public OsmModuleBuilder withStaticBikeParkAndRide(boolean staticBikeParkAndRide)
return this;
}

public OsmModuleBuilder withBanDiscouragedWalking(boolean banDiscouragedWalking) {
this.banDiscouragedWalking = banDiscouragedWalking;
return this;
}

public OsmModuleBuilder withBanDiscouragedBiking(boolean banDiscouragedBiking) {
this.banDiscouragedBiking = banDiscouragedBiking;
return this;
}

public OsmModuleBuilder withMaxAreaNodes(int maxAreaNodes) {
this.maxAreaNodes = maxAreaNodes;
return this;
Expand All @@ -94,9 +82,7 @@ public OsmModule build() {
areaVisibility,
platformEntriesLinking,
staticParkAndRide,
staticBikeParkAndRide,
banDiscouragedWalking,
banDiscouragedBiking
staticBikeParkAndRide
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
* @param platformEntriesLinking Whether platform entries should be linked
* @param staticParkAndRide Whether we should create car P+R stations from OSM data.
* @param staticBikeParkAndRide Whether we should create bike P+R stations from OSM data.
* @param banDiscouragedWalking Whether ways tagged foot=discouraged should be marked as
* inaccessible.
* @param banDiscouragedBiking Whether ways tagged bicycle=discouraged should be marked as
* inaccessible.
*/
public record OsmProcessingParameters(
Set<String> boardingAreaRefTags,
Expand All @@ -25,9 +21,7 @@ public record OsmProcessingParameters(
boolean areaVisibility,
boolean platformEntriesLinking,
boolean staticParkAndRide,
boolean staticBikeParkAndRide,
boolean banDiscouragedWalking,
boolean banDiscouragedBiking
boolean staticBikeParkAndRide
) {
public OsmProcessingParameters {
boardingAreaRefTags = Set.copyOf(Objects.requireNonNull(boardingAreaRefTags));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.OptionalInt;
Expand Down Expand Up @@ -70,12 +69,17 @@ public void addTag(OSMTag tag) {
/**
* Adds a tag.
*/
public void addTag(String key, String value) {
if (key == null || value == null) return;
public OSMWithTags addTag(String key, String value) {
if (key == null || value == null) {
return this;
}

if (tags == null) tags = new HashMap<>();
if (tags == null) {
tags = new HashMap<>();
}

tags.put(key.toLowerCase(), value);
return this;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.opentripplanner.openstreetmap.tagmapping;

import static org.opentripplanner.openstreetmap.wayproperty.MixinPropertiesBuilder.ofBicycleSafety;
import static org.opentripplanner.openstreetmap.wayproperty.MixinPropertiesBuilder.ofWalkSafety;
import static org.opentripplanner.openstreetmap.wayproperty.WayPropertiesBuilder.withModes;
import static org.opentripplanner.street.model.StreetTraversalPermission.ALL;
import static org.opentripplanner.street.model.StreetTraversalPermission.BICYCLE_AND_CAR;
Expand Down Expand Up @@ -618,6 +619,9 @@ public void populateProperties(WayPropertySet props) {
props.setMixinProperties("CCGIS:bicycle:right=caution_area", ofBicycleSafety(1.45, 1));
props.setMixinProperties("CCGIS:bicycle:left=caution_area", ofBicycleSafety(1, 1.45));

props.setMixinProperties("foot=discouraged", ofWalkSafety(3));
props.setMixinProperties("bicycle=discouraged", ofBicycleSafety(3));
Comment on lines +622 to +623
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked that this wasn't handled in the NorwayMapper either and it doesn't rely on the default mapper. I can ask if the norwegians have interest in this too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, you can ask but I see very, very few instances of this tag in the Nordics: https://taginfo.openstreetmap.org/tags/bicycle=discouraged#map


populateNotesAndNames(props);

// slope overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ public class BuildConfig implements OtpDataStoreConfig {
/** See {@link IslandPruningConfig}. */
public final IslandPruningConfig islandPruning;

public final boolean banDiscouragedWalking;
public final boolean banDiscouragedBiking;
public final Duration maxTransferDuration;
public final NetexFeedParameters netexDefaults;
public final GtfsFeedParameters gtfsDefaults;
Expand Down Expand Up @@ -211,18 +209,6 @@ public BuildConfig(NodeAdapter root, boolean logUnusedParams) {
"""
)
.asBoolean(false);
banDiscouragedWalking =
root
.of("banDiscouragedWalking")
.since(V2_0)
.summary("Should walking be allowed on OSM ways tagged with `foot=discouraged`")
.asBoolean(false);
banDiscouragedBiking =
root
.of("banDiscouragedBiking")
.since(V2_0)
.summary("Should biking be allowed on OSM ways tagged with `bicycle=discouraged`")
.asBoolean(false);
configVersion =
root
.of("configVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.street.model.StreetTraversalPermission.ALL;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opentripplanner.openstreetmap.model.OSMWithTags;
import org.opentripplanner.openstreetmap.wayproperty.SpeedPicker;
Expand All @@ -13,12 +16,15 @@

public class DefaultMapperTest {

static WayPropertySet wps = new WayPropertySet();
private WayPropertySet wps;
float epsilon = 0.01f;

static {
@BeforeEach
public void setup() {
var wps = new WayPropertySet();
DefaultMapper source = new DefaultMapper();
source.populateProperties(wps);
this.wps = wps;
}

/**
Expand Down Expand Up @@ -111,6 +117,32 @@ void stairs() {
assertEquals(PEDESTRIAN, props.getPermission());
}

@Test
void footDiscouraged() {
var regular = WayTestData.pedestrianTunnel();
var props = wps.getDataForWay(regular);
assertEquals(PEDESTRIAN_AND_BICYCLE, props.getPermission());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit surprising that highway=footway gets BICYCLE permission by default, even when bicycle=no is set. Anyway, that issue is out of the scope of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you see bicycle=no?

public static OSMWithTags pedestrianTunnel() {
// https://www.openstreetmap.org/way/127288293
OSMWithTags tunnel = new OSMWithTags();
tunnel.addTag("highway", "footway");
tunnel.addTag("indoor", "yes");
tunnel.addTag("layer", "-1");
tunnel.addTag("lit", "yes");
tunnel.addTag("name", "Lamar Tunnel");
tunnel.addTag("tunnel", "yes");
return tunnel;
}

However, highway=footway should probably not allow bicycles: https://wiki.openstreetmap.org/wiki/Tag:highway=footway?uselang=en

We should indeed change it in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested adding bicycle=no myself, just for curiosity :) It did not change anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that it's this piece of code taking care of it:

StreetTraversalPermission permissions = OsmFilter.getPermissionsForWay(
way,
wayData.getPermission(),
params.banDiscouragedWalking(),
params.banDiscouragedBiking(),
issueStore
);

I would be in favour of moving that somehow together with the other code figuring out the permissions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started working on that, and also fixing some known errors in traversal permission processing.

assertEquals(1, props.getWalkSafetyFeatures().forward());

var discouraged = WayTestData.pedestrianTunnel().addTag("foot", "discouraged");
var discouragedProps = wps.getDataForWay(discouraged);
assertEquals(PEDESTRIAN_AND_BICYCLE, discouragedProps.getPermission());
assertEquals(3, discouragedProps.getWalkSafetyFeatures().forward());
}

@Test
void bicycleDiscouraged() {
var regular = WayTestData.southeastLaBonitaWay();
var props = wps.getDataForWay(regular);
assertEquals(ALL, props.getPermission());
assertEquals(.98, props.getBicycleSafetyFeatures().forward());

var discouraged = WayTestData.southeastLaBonitaWay().addTag("bicycle", "discouraged");
var discouragedProps = wps.getDataForWay(discouraged);
assertEquals(ALL, discouragedProps.getPermission());
assertEquals(2.94, discouragedProps.getBicycleSafetyFeatures().forward(), epsilon);
}

/**
* Test that two values are within epsilon of each other.
*/
Expand Down
2 changes: 0 additions & 2 deletions test/performance/norway/build-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"islandWithoutStopsMaxSize": 5,
"islandWithStopsMaxSize": 5
},
"banDiscouragedWalking": false,
"banDiscouragedBiking": false,
"distanceBetweenElevationSamples": 25,
"multiThreadElevationCalculations": true,
"boardingLocationTags": [],
Expand Down