Skip to content

Commit

Permalink
feat(OsmModule): Add build option to prevent ped routing on roads.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Aug 16, 2024
1 parent d1496be commit 371ee42
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docs/BuildConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Sections follow that describe particular settings in more depth.
| [osmCacheDataInMem](#osmCacheDataInMem) | `boolean` | If OSM data should be cached in memory during processing. | *Optional* | `false` | 2.0 |
| [osmNaming](#osmNaming) | `enum` | A custom OSM namer to use. | *Optional* | `"default"` | 1.5 |
| platformEntriesLinking | `boolean` | Link unconnected entries to public transport platforms. | *Optional* | `false` | 2.0 |
| [preventWalkingOnRoads](#preventWalkingOnRoads) | `boolean` | Determines whether to prevent pedestrian routing on roads or not. | *Optional* | `false` | 2.5 |
| [readCachedElevations](#readCachedElevations) | `boolean` | Whether to read cached elevation data. | *Optional* | `true` | 2.0 |
| staticBikeParkAndRide | `boolean` | Whether we should create bike P+R stations from OSM data. | *Optional* | `false` | 1.5 |
| staticParkAndRide | `boolean` | Whether we should create car P+R stations from OSM data. | *Optional* | `true` | 1.5 |
Expand Down Expand Up @@ -528,6 +529,15 @@ data, and to `false` to read the stream from the source each time.

A custom OSM namer to use.

<h3 id="preventWalkingOnRoads">preventWalkingOnRoads</h3>

**Since version:** `2.5`**Type:** `boolean`**Cardinality:** `Optional`**Default value:** `false`
**Path:** /

Determines whether to prevent pedestrian routing on roads or not.

True to prevent pedestrian routing on roads.

<h3 id="readCachedElevations">readCachedElevations</h3>

**Since version:** `2.0`**Type:** `boolean`**Cardinality:** `Optional`**Default value:** `true`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static OsmModule provideOpenStreetMapModule(
.withBoardingAreaRefTags(config.boardingLocationTags)
.withIssueStore(issueStore)
.withStreetLimitationParameters(streetLimitationParameters)
.withPreventWalkingOnRoads(config.preventWalkingOnRoads)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.ext.mobilityprofile.MobilityProfileParser;
import org.opentripplanner.ext.mobilityprofile.MobilityProfileRouting;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.framework.geometry.SphericalDistanceLibrary;
import org.opentripplanner.framework.i18n.I18NString;
Expand Down Expand Up @@ -569,13 +570,17 @@ private StreetEdge getEdgeForStreet(
LOG.warn("Unable to extract OSM nodes for way {} {}, {}=>{}", name, wayId, startId, endId);
}

StreetTraversalPermission perms = params.preventWalkingOnRoads()
? MobilityProfileRouting.adjustPedestrianPermissions(way, permissions)
: permissions;

StreetEdgeBuilder<?> seb = new StreetEdgeBuilder<>()
.withFromVertex(startEndpoint)
.withToVertex(endEndpoint)
.withGeometry(geometry)
.withName(name)
.withMeterLength(length)
.withPermission(permissions)
.withPermission(perms)
.withBack(back)
.withCarSpeed(carSpeed)
.withLink(way.isLink())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class OsmModuleBuilder {
private boolean staticBikeParkAndRide = false;
private int maxAreaNodes;
private StreetLimitationParameters streetLimitationParameters = new StreetLimitationParameters();
private boolean preventWalkingOnRoads;

OsmModuleBuilder(Collection<OsmProvider> providers, Graph graph) {
this.providers = providers;
Expand Down Expand Up @@ -77,6 +78,11 @@ public OsmModuleBuilder withStreetLimitationParameters(StreetLimitationParameter
return this;
}

public OsmModuleBuilder withPreventWalkingOnRoads(boolean value) {
this.preventWalkingOnRoads = value;
return this;
}

public OsmModule build() {
return new OsmModule(
providers,
Expand All @@ -90,7 +96,8 @@ public OsmModule build() {
areaVisibility,
platformEntriesLinking,
staticParkAndRide,
staticBikeParkAndRide
staticBikeParkAndRide,
preventWalkingOnRoads
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public record OsmProcessingParameters(
boolean areaVisibility,
boolean platformEntriesLinking,
boolean staticParkAndRide,
boolean staticBikeParkAndRide
boolean staticBikeParkAndRide,
boolean preventWalkingOnRoads
) {
public OsmProcessingParameters {
boardingAreaRefTags = Set.copyOf(Objects.requireNonNull(boardingAreaRefTags));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ public class BuildConfig implements OtpDataStoreConfig {

public final URI stopConsolidation;

public final boolean preventWalkingOnRoads;

/**
* Set all parameters from the given Jackson JSON tree, applying defaults. Supplying
* MissingNode.getInstance() will cause all the defaults to be applied. This could be done
Expand Down Expand Up @@ -612,6 +614,14 @@ that we support remote input files (cloud storage or arbitrary URLs) not all dat
)
.asUri(null);

preventWalkingOnRoads =
root
.of("preventWalkingOnRoads")
.since(V2_5)
.summary("Determines whether to prevent pedestrian routing on roads or not.")
.description("True to prevent pedestrian routing on roads.")
.asBoolean(false);

osmDefaults = OsmConfig.mapOsmDefaults(root, "osmDefaults");
osm = OsmConfig.mapOsmConfig(root, "osm", osmDefaults);
demDefaults = DemConfig.mapDemDefaultsConfig(root, "demDefaults");
Expand Down

0 comments on commit 371ee42

Please sign in to comment.