From 1f68767398670dbc9361bc4dd3ba50b36ea39016 Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 15:24:06 -0400 Subject: [PATCH 01/11] Add SidewalkTraversalPermissionLabeler activated via TransportNetworkConfig when building a network from a config JSON --- .../cluster/TransportNetworkConfig.java | 7 +++++++ .../SidewalkTraversalPermissionLabeler.java | 18 ++++++++++++++++++ .../com/conveyal/r5/streets/StreetLayer.java | 16 ++++++++++++++-- .../r5/transit/TransportNetworkCache.java | 3 ++- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java diff --git a/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java b/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java index 012e3204a..e75373146 100644 --- a/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java +++ b/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java @@ -54,4 +54,11 @@ public class TransportNetworkConfig { */ public Set buildGridsForModes; + /** + * Specifies which "labeler" to use when setting traversal mode permissions from OSM tags. For now, only + * implemented with "sidewalk" to use the SidewalkTraversalPermissionLayer. This should eventually be cleaned up + * (specifying different labelers, using enums). + */ + public String traversalPermissionLabeler; + } diff --git a/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java b/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java new file mode 100644 index 000000000..dd8c53e23 --- /dev/null +++ b/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java @@ -0,0 +1,18 @@ +package com.conveyal.r5.labeling; + + +/** + * Traversal permission labeler that restricts walking on most driving ways (useful for networks with complete + * sidewalks). Also includes permissions for the United States (see USTraversalPermissionLabeler). + */ +public class SidewalkTraversalPermissionLabeler extends TraversalPermissionLabeler { + static { + addPermissions("pedestrian", "bicycle=yes"); + addPermissions("bridleway", "bicycle=yes;foot=yes"); //horse=yes but we don't support horse + addPermissions("cycleway", "bicycle=yes;foot=yes"); + addPermissions("trunk|primary|secondary|tertiary|unclassified|residential|living_street|road|service|track", + "access=yes;foot=no"); // Note foot=no + + } + +} diff --git a/src/main/java/com/conveyal/r5/streets/StreetLayer.java b/src/main/java/com/conveyal/r5/streets/StreetLayer.java index 3d781b41b..2fbc3c709 100644 --- a/src/main/java/com/conveyal/r5/streets/StreetLayer.java +++ b/src/main/java/com/conveyal/r5/streets/StreetLayer.java @@ -6,12 +6,14 @@ import com.conveyal.osmlib.OSMEntity; import com.conveyal.osmlib.Relation; import com.conveyal.osmlib.Way; +import com.conveyal.r5.analyst.cluster.TransportNetworkConfig; import com.conveyal.r5.analyst.scenario.PickupWaitTimes; import com.conveyal.r5.api.util.BikeRentalStation; import com.conveyal.r5.api.util.ParkRideParking; import com.conveyal.r5.common.GeometryUtils; import com.conveyal.r5.labeling.LevelOfTrafficStressLabeler; import com.conveyal.r5.labeling.RoadPermission; +import com.conveyal.r5.labeling.SidewalkTraversalPermissionLabeler; import com.conveyal.r5.labeling.SpeedLabeler; import com.conveyal.r5.labeling.StreetClass; import com.conveyal.r5.labeling.TraversalPermissionLabeler; @@ -132,8 +134,8 @@ public class StreetLayer implements Serializable, Cloneable { public TIntObjectMap parkRideLocationsMap; // TODO these are only needed when building the network, should we really be keeping them here in the layer? - // We should instead have a network builder that holds references to this transient state. - // TODO don't hardwire to US + // We should instead have a network builder that holds references to this transient state. Note initial + // approach of specifying a TraversalPermissionLabeler in TransportNetworkConfig. private transient TraversalPermissionLabeler permissionLabeler = new USTraversalPermissionLabeler(); private transient LevelOfTrafficStressLabeler stressLabeler = new LevelOfTrafficStressLabeler(); private transient TypeOfEdgeLabeler typeOfEdgeLabeler = new TypeOfEdgeLabeler(); @@ -209,6 +211,16 @@ public StreetLayer() { speedLabeler = new SpeedLabeler(SpeedConfig.defaultConfig()); } + public StreetLayer(TransportNetworkConfig config) { + this(); + if (config != null && config.traversalPermissionLabeler != null) { + // TODO cleaner mapping + if ("sidewalk".equals(config.traversalPermissionLabeler)) { + permissionLabeler = new SidewalkTraversalPermissionLabeler(); + } + } + } + /** Load street layer from an OSM-lib OSM DB */ public void loadFromOsm(OSM osm) { loadFromOsm(osm, true, false); diff --git a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java index b7f1f1d8f..b1a018cc8 100644 --- a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java +++ b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java @@ -281,7 +281,8 @@ private TransportNetwork buildNetworkFromConfig (TransportNetworkConfig config) TransportNetwork network = new TransportNetwork(); - network.streetLayer = new StreetLayer(); + network.streetLayer = new StreetLayer(config); + network.streetLayer.loadFromOsm(osmCache.get(config.osmId)); network.streetLayer.parentNetwork = network; From cf73c5572c7b1cd1be85da75211ab5f95fefbaf8 Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 15:41:32 -0400 Subject: [PATCH 02/11] Remove deprecated buildNetworkFromBundleZip Building from .zip files on S3 has not been supported since 2016. --- .../r5/transit/TransportNetworkCache.java | 61 ++----------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java index b1a018cc8..e2043e593 100644 --- a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java +++ b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java @@ -183,9 +183,8 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) { TransportNetworkConfig networkConfig = loadNetworkConfig(networkId); if (networkConfig == null) { // The switch to use JSON manifests instead of zips occurred in 32a1aebe in July 2016. - // Over six years have passed, buildNetworkFromBundleZip is deprecated and could probably be removed. - LOG.warn("No network config (aka manifest) found. Assuming old-format network inputs bundle stored as a single ZIP file."); - network = buildNetworkFromBundleZip(networkId); + // buildNetworkFromBundleZip was deprecated for years then removed in 2024. + throw new RuntimeException("No network config (aka manifest) found."); } else { network = buildNetworkFromConfig(networkConfig); } @@ -218,66 +217,14 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) { return network; } - /** Build a transport network given a network ID, using a zip of all bundle files in S3. */ - @Deprecated - private TransportNetwork buildNetworkFromBundleZip (String networkId) { - // The location of the inputs that will be used to build this graph - File dataDirectory = FileUtils.createScratchDirectory(); - FileStorageKey zipKey = new FileStorageKey(BUNDLES, networkId + ".zip"); - File zipFile = fileStorage.getFile(zipKey); - - try { - ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile)); - ZipEntry entry; - while ((entry = zis.getNextEntry()) != null) { - File entryDestination = new File(dataDirectory, entry.getName()); - if (!entryDestination.toPath().normalize().startsWith(dataDirectory.toPath())) { - throw new Exception("Bad zip entry"); - } - - // Are both these mkdirs calls necessary? - entryDestination.getParentFile().mkdirs(); - if (entry.isDirectory()) - entryDestination.mkdirs(); - else { - OutputStream entryFileOut = new FileOutputStream(entryDestination); - zis.transferTo(entryFileOut); - entryFileOut.close(); - } - } - zis.close(); - } catch (Exception e) { - // TODO delete cache dir which is probably corrupted. - LOG.warn("Error retrieving transportation network input files", e); - return null; - } - - // Now we have a local copy of these graph inputs. Make a graph out of them. - TransportNetwork network; - try { - network = TransportNetwork.fromDirectory(dataDirectory); - } catch (DuplicateFeedException e) { - LOG.error("Duplicate feeds in transport network {}", networkId, e); - throw new RuntimeException(e); - } - - // Set the ID on the network and its layers to allow caching linkages and analysis results. - network.scenarioId = networkId; - - return network; - } - /** * Build a network from a JSON TransportNetworkConfig in file storage. * This describes the locations of files used to create a bundle, as well as options applied at network build time. * It contains the unique IDs of the GTFS feeds and OSM extract. */ private TransportNetwork buildNetworkFromConfig (TransportNetworkConfig config) { - // FIXME duplicate code. All internal building logic should be encapsulated in a method like - // TransportNetwork.build(osm, gtfs1, gtfs2...) - // We currently have multiple copies of it, in buildNetworkFromConfig and buildNetworkFromBundleZip so you've - // got to remember to do certain things like set the network ID of the network in multiple places in the code. - // Maybe we should just completely deprecate bundle ZIPs and remove those code paths. + // FIXME All internal building logic should be encapsulated in a method like TransportNetwork.build(osm, + // gtfs1, gtfs2...) (see various methods in TransportNetwork). TransportNetwork network = new TransportNetwork(); From 68e4e87f36bc5920bfc16e691c0717600a2c7c64 Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 15:42:48 -0400 Subject: [PATCH 03/11] Enable TransportNetworkConfig in non-cluster use such as PointToPointRouterServer --- .../conveyal/r5/transit/TransportNetwork.java | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/conveyal/r5/transit/TransportNetwork.java b/src/main/java/com/conveyal/r5/transit/TransportNetwork.java index 3e3cb3720..a1be48560 100644 --- a/src/main/java/com/conveyal/r5/transit/TransportNetwork.java +++ b/src/main/java/com/conveyal/r5/transit/TransportNetwork.java @@ -4,9 +4,11 @@ import com.conveyal.osmlib.OSM; import com.conveyal.r5.analyst.LinkageCache; import com.conveyal.r5.analyst.WebMercatorGridPointSet; +import com.conveyal.r5.analyst.cluster.TransportNetworkConfig; import com.conveyal.r5.analyst.error.TaskError; import com.conveyal.r5.analyst.fare.InRoutingFareCalculator; import com.conveyal.r5.analyst.scenario.Scenario; +import com.conveyal.r5.common.JsonUtilities; import com.conveyal.r5.kryo.KryoNetworkSerializer; import com.conveyal.r5.profile.StreetMode; import com.conveyal.r5.streets.StreetLayer; @@ -81,8 +83,6 @@ public class TransportNetwork implements Serializable { */ public String scenarioId = null; - public static final String BUILDER_CONFIG_FILENAME = "build-config.json"; - public InRoutingFareCalculator fareCalculator; /** Non-fatal warnings encountered when applying the scenario, null on a base network */ @@ -100,7 +100,9 @@ public void rebuildTransientIndexes() { streetLayer.indexStreets(); transitLayer.rebuildTransientIndexes(); } - + public static TransportNetwork fromFiles (String osmSourceFile, List gtfsSourceFiles) { + return fromFiles(osmSourceFile, gtfsSourceFiles, null); + } /** * OSM PBF files are fragments of a single global database with a single namespace. Therefore it is valid to load * more than one PBF file into a single OSM storage object. However they might be from different points in time, so @@ -114,9 +116,11 @@ public void rebuildTransientIndexes() { * NOTE the feedId of the gtfs feeds loaded here will be the ones declared by the feeds or based on their filenames. * This method makes no effort to impose the more unique feed IDs created by the Analysis backend. */ + public static TransportNetwork fromFiles ( String osmSourceFile, - List gtfsSourceFiles + List gtfsSourceFiles, + String configFile ) throws DuplicateFeedException { // Load OSM data into MapDB to pass into network builder. OSM osm = new OSM(osmSourceFile + ".mapdb"); @@ -124,21 +128,37 @@ public static TransportNetwork fromFiles ( osm.readFromFile(osmSourceFile); // Supply feeds with a stream so they do not sit open in memory while other feeds are being processed. Stream feeds = gtfsSourceFiles.stream().map(GTFSFeed::readOnlyTempFileFromGtfs); - return fromInputs(osm, feeds); + if (configFile == null) { + return fromInputs(osm, feeds); + } else { + try { + // Use lenient mapper to mimic behavior in objectFromRequestBody. + TransportNetworkConfig config = JsonUtilities.lenientObjectMapper.readValue(configFile, + TransportNetworkConfig.class); + return fromInputs(osm, feeds, config); + } catch (IOException e) { + throw new RuntimeException("Error reading TransportNetworkConfig. Does it contain new unrecognized fields?", e); + } + } + } + + public static TransportNetwork fromInputs (OSM osm, Stream gtfsFeeds) { + return fromInputs(osm, gtfsFeeds, null); } /** - * This is the core method for building a street and transit network. It takes osm-lib and gtfs-lib objects as - * parameters. It is wrapped in various other methods that create those OSM and GTFS objects from filenames, input - * directories etc. The supplied OSM object must have intersections already detected. - * The GTFS feeds are supplied as a stream so that they can be loaded one by one on demand. + * This is the method for building a street and transit network locally (as opposed to + * TransportNetworkCache#buildNetworkfromConfig, which is used in cluster builds). This method takes osm-lib, + * gtfs-lib, and config objects as parameters. It is wrapped in various other methods that create those OSM and + * GTFS objects from filenames, input directories etc. The supplied OSM object must have intersections already + * detected. The GTFS feeds are supplied as a stream so that they can be loaded one by one on demand. */ - public static TransportNetwork fromInputs (OSM osm, Stream gtfsFeeds) { + public static TransportNetwork fromInputs (OSM osm, Stream gtfsFeeds, TransportNetworkConfig config) { // Create a transport network to hold the street and transit layers TransportNetwork transportNetwork = new TransportNetwork(); // Make street layer from OSM data in MapDB - StreetLayer streetLayer = new StreetLayer(); + StreetLayer streetLayer = new StreetLayer(config); transportNetwork.streetLayer = streetLayer; streetLayer.parentNetwork = transportNetwork; streetLayer.loadFromOsm(osm); @@ -180,14 +200,16 @@ public static TransportNetwork fromInputs (OSM osm, Stream gtfsFeeds) } /** - * Scan a directory detecting all the files that are network inputs, then build a network from those files. + * Scan a directory detecting all the files that are network inputs, then build a network from those files. This + * method is used in the PointToPointRouterServer, not the cluster-based analysis backend. * - * NOTE the feedId of the gtfs feeds laoded here will be the ones declared by the feeds or based on their filenames. + * NOTE the feedId of the gtfs feeds loaded here will be the ones declared by the feeds or based on their filenames. * This method makes no effort to impose the more unique feed IDs created by the Analysis backend. */ public static TransportNetwork fromDirectory (File directory) throws DuplicateFeedException { File osmFile = null; List gtfsFiles = new ArrayList<>(); + File configFile = null; for (File file : directory.listFiles()) { switch (InputFileType.forFile(file)) { case GTFS: @@ -202,6 +224,9 @@ public static TransportNetwork fromDirectory (File directory) throws DuplicateFe LOG.warn("Can only load one OSM file at a time."); } break; + case CONFIG: + LOG.info("Found config file {}", file); + configFile = file; case DEM: LOG.warn("DEM file '{}' not yet supported.", file); break; @@ -213,7 +238,11 @@ public static TransportNetwork fromDirectory (File directory) throws DuplicateFe LOG.error("An OSM PBF file is required to build a network."); return null; } else { - return fromFiles(osmFile.getAbsolutePath(), gtfsFiles); + if (configFile == null) { + return fromFiles(osmFile.getAbsolutePath(), gtfsFiles); + } else { + return fromFiles(osmFile.getAbsolutePath(), gtfsFiles, configFile.getAbsolutePath()); + } } } @@ -259,6 +288,7 @@ public static InputFileType forFile(File file) { if (name.endsWith(".pbf") || name.endsWith(".vex")) return OSM; if (name.endsWith(".tif") || name.endsWith(".tiff")) return DEM; // Digital elevation model (elevation raster) if (name.endsWith("network.dat")) return OUTPUT; + if (name.endsWith(".json")) return CONFIG; return OTHER; } } From 1355d0d20ef97db37f6a0fb5f362376af984f75d Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 16:23:45 -0400 Subject: [PATCH 04/11] Force use of SidewalkTraversalPermissionLabeler --- src/main/java/com/conveyal/r5/streets/StreetLayer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/conveyal/r5/streets/StreetLayer.java b/src/main/java/com/conveyal/r5/streets/StreetLayer.java index 2fbc3c709..a4597794d 100644 --- a/src/main/java/com/conveyal/r5/streets/StreetLayer.java +++ b/src/main/java/com/conveyal/r5/streets/StreetLayer.java @@ -213,11 +213,11 @@ public StreetLayer() { public StreetLayer(TransportNetworkConfig config) { this(); - if (config != null && config.traversalPermissionLabeler != null) { - // TODO cleaner mapping - if ("sidewalk".equals(config.traversalPermissionLabeler)) { + if (config != null) { + // FIXME hack to force use of SIdewalkTraversalPermissionLabeler in cluster use + // if ("sidewalk".equals(config.traversalPermissionLabeler)) { permissionLabeler = new SidewalkTraversalPermissionLabeler(); - } + // } } } From 1fe1c83ea905a4b0b4619da53f2ed109b3b66360 Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 16:23:27 -0400 Subject: [PATCH 05/11] Make sidewalk PermissionLabeler more restrictive Disallow walking anywhere driving is allowed --- .../SidewalkTraversalPermissionLabeler.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java b/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java index dd8c53e23..34d2c8465 100644 --- a/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java +++ b/src/main/java/com/conveyal/r5/labeling/SidewalkTraversalPermissionLabeler.java @@ -1,5 +1,7 @@ package com.conveyal.r5.labeling; +import com.conveyal.osmlib.Way; +import com.conveyal.r5.streets.EdgeStore; /** * Traversal permission labeler that restricts walking on most driving ways (useful for networks with complete @@ -11,8 +13,23 @@ public class SidewalkTraversalPermissionLabeler extends TraversalPermissionLabel addPermissions("bridleway", "bicycle=yes;foot=yes"); //horse=yes but we don't support horse addPermissions("cycleway", "bicycle=yes;foot=yes"); addPermissions("trunk|primary|secondary|tertiary|unclassified|residential|living_street|road|service|track", - "access=yes;foot=no"); // Note foot=no + "access=yes"); + } + @Override + public RoadPermission getPermissions(Way way) { + RoadPermission rp = super.getPermissions(way); + if (rp.forward.contains(EdgeStore.EdgeFlag.ALLOWS_CAR) || + rp.forward.contains(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_CAR) || + rp.backward.contains(EdgeStore.EdgeFlag.ALLOWS_CAR) || + rp.backward.contains(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_CAR) + ) { + rp.forward.remove(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN); + rp.forward.remove(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_PEDESTRIAN); + rp.backward.remove(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN); + rp.backward.remove(EdgeStore.EdgeFlag.NO_THRU_TRAFFIC_PEDESTRIAN); + } + return rp; } } From d6bfa168c759ce7816928e6839e6557f2b63b2ed Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 21:29:21 -0400 Subject: [PATCH 06/11] Set NETWORK_FORMAT_VERSION to prev commit hash --- src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java b/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java index 7180074f4..dbd8dbdcd 100644 --- a/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java +++ b/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java @@ -53,7 +53,7 @@ public abstract class KryoNetworkSerializer { * When prototyping new features, use a unique identifier such as the branch or a commit ID, not sequential nvX ones. * This avoids conflicts when multiple changes are combined in a single production release, or some are abandoned. */ - public static final String NETWORK_FORMAT_VERSION = "nv3"; + public static final String NETWORK_FORMAT_VERSION = "1fe1c83e"; public static final byte[] HEADER = "R5NETWORK".getBytes(); From 182a2943947739040729aa06541e75c9c22131f8 Mon Sep 17 00:00:00 2001 From: ansons Date: Fri, 9 Aug 2024 21:29:45 -0400 Subject: [PATCH 07/11] Remove unused imports --- .../java/com/conveyal/r5/transit/TransportNetworkCache.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java index e2043e593..d2d5b8799 100644 --- a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java +++ b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java @@ -25,17 +25,12 @@ import javax.annotation.Nonnull; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; import static com.conveyal.file.FileCategory.BUNDLES; import static com.conveyal.file.FileCategory.DATASOURCES; From 1a1e5ea6fc52aa8d4d18a6933f3cd67daf4e4d85 Mon Sep 17 00:00:00 2001 From: ansons Date: Wed, 2 Oct 2024 16:03:06 -0400 Subject: [PATCH 08/11] Revert "Force use of SidewalkTraversalPermissionLabeler" This reverts commit 1355d0d20ef97db37f6a0fb5f362376af984f75d. --- src/main/java/com/conveyal/r5/streets/StreetLayer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/conveyal/r5/streets/StreetLayer.java b/src/main/java/com/conveyal/r5/streets/StreetLayer.java index a4597794d..2fbc3c709 100644 --- a/src/main/java/com/conveyal/r5/streets/StreetLayer.java +++ b/src/main/java/com/conveyal/r5/streets/StreetLayer.java @@ -213,11 +213,11 @@ public StreetLayer() { public StreetLayer(TransportNetworkConfig config) { this(); - if (config != null) { - // FIXME hack to force use of SIdewalkTraversalPermissionLabeler in cluster use - // if ("sidewalk".equals(config.traversalPermissionLabeler)) { + if (config != null && config.traversalPermissionLabeler != null) { + // TODO cleaner mapping + if ("sidewalk".equals(config.traversalPermissionLabeler)) { permissionLabeler = new SidewalkTraversalPermissionLabeler(); - // } + } } } From bc5dfea97220cb80625b67c28afc4ca969b2540b Mon Sep 17 00:00:00 2001 From: ansons Date: Wed, 2 Oct 2024 16:07:28 -0400 Subject: [PATCH 09/11] Remove unused imports --- .../conveyal/r5/analyst/cluster/TransportNetworkConfig.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java b/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java index e75373146..387742634 100644 --- a/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java +++ b/src/main/java/com/conveyal/r5/analyst/cluster/TransportNetworkConfig.java @@ -2,12 +2,8 @@ import com.conveyal.r5.analyst.fare.InRoutingFareCalculator; import com.conveyal.r5.analyst.scenario.Modification; -import com.conveyal.r5.analyst.scenario.RasterCost; -import com.conveyal.r5.analyst.scenario.ShapefileLts; import com.conveyal.r5.profile.StreetMode; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.util.List; import java.util.Set; From 171010702420d7004abe85cc032cb3cfb4848c71 Mon Sep 17 00:00:00 2001 From: ansons Date: Wed, 2 Oct 2024 16:09:05 -0400 Subject: [PATCH 10/11] Revert "Set NETWORK_FORMAT_VERSION to prev commit hash" This reverts commit d6bfa168c759ce7816928e6839e6557f2b63b2ed. --- src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java b/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java index dbd8dbdcd..7180074f4 100644 --- a/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java +++ b/src/main/java/com/conveyal/r5/kryo/KryoNetworkSerializer.java @@ -53,7 +53,7 @@ public abstract class KryoNetworkSerializer { * When prototyping new features, use a unique identifier such as the branch or a commit ID, not sequential nvX ones. * This avoids conflicts when multiple changes are combined in a single production release, or some are abandoned. */ - public static final String NETWORK_FORMAT_VERSION = "1fe1c83e"; + public static final String NETWORK_FORMAT_VERSION = "nv3"; public static final byte[] HEADER = "R5NETWORK".getBytes(); From 8c4b2d9e5d13bbfc8924d4fc0465405ac8417ed9 Mon Sep 17 00:00:00 2001 From: ansons Date: Thu, 3 Oct 2024 21:56:57 -0400 Subject: [PATCH 11/11] Set permissionLabeler more cleanly --- .../com/conveyal/r5/streets/StreetLayer.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/conveyal/r5/streets/StreetLayer.java b/src/main/java/com/conveyal/r5/streets/StreetLayer.java index 2fbc3c709..4e31481ee 100644 --- a/src/main/java/com/conveyal/r5/streets/StreetLayer.java +++ b/src/main/java/com/conveyal/r5/streets/StreetLayer.java @@ -136,7 +136,7 @@ public class StreetLayer implements Serializable, Cloneable { // TODO these are only needed when building the network, should we really be keeping them here in the layer? // We should instead have a network builder that holds references to this transient state. Note initial // approach of specifying a TraversalPermissionLabeler in TransportNetworkConfig. - private transient TraversalPermissionLabeler permissionLabeler = new USTraversalPermissionLabeler(); + private transient TraversalPermissionLabeler permissionLabeler; private transient LevelOfTrafficStressLabeler stressLabeler = new LevelOfTrafficStressLabeler(); private transient TypeOfEdgeLabeler typeOfEdgeLabeler = new TypeOfEdgeLabeler(); private transient SpeedLabeler speedLabeler; @@ -209,15 +209,21 @@ public class StreetLayer implements Serializable, Cloneable { public StreetLayer() { speedLabeler = new SpeedLabeler(SpeedConfig.defaultConfig()); + permissionLabeler = new USTraversalPermissionLabeler(); } public StreetLayer(TransportNetworkConfig config) { this(); - if (config != null && config.traversalPermissionLabeler != null) { - // TODO cleaner mapping - if ("sidewalk".equals(config.traversalPermissionLabeler)) { - permissionLabeler = new SidewalkTraversalPermissionLabeler(); - } + if (config != null) { + permissionLabeler = switch (config.traversalPermissionLabeler) { + case "sidewalk" -> new SidewalkTraversalPermissionLabeler(); + case null -> new USTraversalPermissionLabeler(); + default -> throw new IllegalArgumentException( + "Unknown traversal permission labeler: " + config.traversalPermissionLabeler + ); + }; + } else { + permissionLabeler = new USTraversalPermissionLabeler(); } }