Skip to content

Commit

Permalink
add input directory for freight generated data
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed Jan 30, 2025
1 parent 04e16f0 commit 41b18c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/main/java/org/matsim/prepare/CreateCommercialDemand.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class CreateCommercialDemand implements MATSimAppCommand {
@CommandLine.Option(names = "--sample", description = "Scaling factor of the small scale commercial traffic (0, 1)", required = true, defaultValue = "0.01")
private double sample;

@CommandLine.Option(names = "--generatedInputDataPath", description = "Path to the generated input data", required = true, defaultValue = "scenarios/metropole-ruhr-v2024.0/output/rvr/generatedInputData")
private Path generatedInputDataPath;

@CommandLine.Option(names = "--pathOutputFolder", description = "Path for the output folder", required = true, defaultValue = "scenarios/metropole-ruhr-v2024.0/output/rvr/testing/commercial_0.1pct")
private Path output;

Expand Down Expand Up @@ -125,6 +128,14 @@ public Integer call() {
return 1;
}
}
if (!Files.exists(generatedInputDataPath)) {
try {
Files.createDirectories(generatedInputDataPath);
} catch (Exception e) {
log.error("Could not create output directory", e);
return 1;
}
}

String shapeCRS = "EPSG:25832";
log.info("1st step - create freight data from BUW data");
Expand All @@ -134,13 +145,13 @@ public Integer call() {

String freightDataName = "ruhr_freightData_100pct.xml.gz";

if (Files.exists(output.resolve(freightDataName)) || Files.exists(freightData)) {
if (Files.exists(generatedInputDataPath.resolve(freightDataName)) || Files.exists(freightData)) {
log.warn("Freight data already exists. Skipping generation.");
} else {
new GenerateFreightDataRuhr().execute(
"--data", freightRawData,
"--KEPdata", freightRawDataKEP,
"--pathOutput", output.toString(),
"--pathOutput", generatedInputDataPath.toString(),
"--nameOutputDataFile", freightDataName,
"--shpCells", vpCellsLocation.toString()
);
Expand All @@ -151,7 +162,7 @@ public Integer call() {
log.warn("Freight population already exists. Skipping generation.");
} else {
new GenerateFTLFreightPlansRuhr().execute(
"--data", output.resolve(freightDataName).toString(),
"--data", generatedInputDataPath.resolve(freightDataName).toString(),
"--output", output.toString(),
"--nameOutputPopulation", FTLFreightPopulationName,
"--truck-load", "13.0",
Expand All @@ -166,7 +177,7 @@ public Integer call() {
log.warn("Freight population already exists. Skipping generation.");
} else {
new GenerateLTLFreightPlansRuhr().execute(
"--data", output.resolve(freightDataName).toString(),
"--data", generatedInputDataPath.resolve(freightDataName).toString(),
"--network", configPath.getParent().resolve(networkPath).toString(),
"--output", output.toString(),
"--nameOutputPopulation", LTLFreightPopulationName,
Expand Down Expand Up @@ -216,10 +227,10 @@ public Integer call() {
}
log.info("5rd step - create input data for small scale commercial traffic");

Path pathCommercialFacilities = output.resolve("commercialFacilities.xml.gz");
Path pathCommercialFacilities = generatedInputDataPath.resolve("commercialFacilities.xml.gz");
//here possible to create an implementation for ruhrAGIS data
LanduseDataConnectionCreator landuseDataConnectionCreator = new LanduseDataConnectionCreatorForOSM_Data();
Path pathDataDistributionFile = output.resolve("dataDistributionPerZone.csv");
Path pathDataDistributionFile = generatedInputDataPath.resolve("dataDistributionPerZone.csv");
if (Files.exists(pathCommercialFacilities)) {
log.warn("Commercial facilities for small-scale commercial generation already exists. Skipping generation.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ enum CarrierType {
config.global().setCoordinateSystem("EPSG:25832");
FreightCarriersConfigGroup freightCarriersConfigGroup = ConfigUtils.addOrGetModule(config, FreightCarriersConfigGroup.class);
freightCarriersConfigGroup.setCarriersVehicleTypesFile(vehicleTypesFilePath);
Path outputFolderCarriers = output.resolve("carriersLTL");
Path outputFolderCarriers = Path.of(dataPath).getParent().resolve("carriersLTL");
if (!Files.exists(outputFolderCarriers)) {
Files.createDirectory(outputFolderCarriers);
}
Expand Down

0 comments on commit 41b18c2

Please sign in to comment.