Skip to content
Draft
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
17 changes: 16 additions & 1 deletion java-r5rcore/src/org/ipea/r5r/Network/NetworkBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.conveyal.gtfs.validator.PostLoadValidator;
import com.conveyal.gtfs.validator.model.Priority;
import com.conveyal.osmlib.OSM;
import com.conveyal.r5.analyst.cluster.TransportNetworkConfig;
import com.conveyal.r5.analyst.scenario.RasterCost;
import com.conveyal.r5.kryo.KryoNetworkSerializer;
import com.conveyal.r5.streets.StreetLayer;
Expand All @@ -31,6 +32,7 @@
import java.nio.file.Path;

public class NetworkBuilder {
public static final String JSON_CONFIG_FILE = "config.json";

public boolean useNativeElevation = false;
public String elevationCostFunction = "NONE";
Expand All @@ -41,6 +43,7 @@ public class NetworkBuilder {
private OSM osmFile;
private Stream<GTFSFeed> gtfsFeeds;
private String tiffFile = "";
private static TransportNetworkConfig transportNetworkConfig = null;

public RDataFrame gtfsErrors = null;

Expand Down Expand Up @@ -121,20 +124,23 @@ private Map<String, String> buildNetworkConfig() {
networkConfig.put("elevation_cost_function", elevationCostFunction);
networkConfig.put("tiff_file_name", tiffFile);

networkConfig.put("transportNetworkConfig", transportNetworkConfig != null ? JSON_CONFIG_FILE : null);

return networkConfig;
}

private TransportNetwork createNetwork() {
TransportNetwork network = new TransportNetwork();

network.scenarioId = "r5r";
network.streetLayer = new StreetLayer();
network.streetLayer = new StreetLayer(transportNetworkConfig);
network.streetLayer.loadFromOsm(osmFile);
osmFile.close();

network.streetLayer.parentNetwork = network;
network.streetLayer.indexStreets();

// currently the TransitLayer has no config, so we do not pass in networkConfig
network.transitLayer = new TransitLayer();
// this replaces the old r5r TransitLayerWithShapes class; saving shapes now built in to r5.
network.transitLayer.saveShapes = true;
Expand Down Expand Up @@ -220,6 +226,15 @@ public void loadDirectory(File directory) {
}
if (name.endsWith(".zip")) gtfsFiles.add(file.getAbsolutePath());
if (name.endsWith(".tif") | name.endsWith(".tiff")) tiffFile = file.getAbsolutePath();
if (name.equals(JSON_CONFIG_FILE)) {
try {
// Use the R5 object mapper to make sure R5 config files are compatible (e.g. same case conventions)
transportNetworkConfig = com.conveyal.analysis.util.JsonUtil.objectMapper.readValue(file, TransportNetworkConfig.class);
} catch (Exception e) {
// re-throw, don't silently ignore a config file
throw new RuntimeException(e);
}
}
}

initializeGtfsErrors();
Expand Down
Binary file modified r-package/inst/jar/r5r.jar
Binary file not shown.