Skip to content

Commit

Permalink
Code refactor and small fix (in mode replacement)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksander1234519 committed Nov 5, 2024
1 parent 9c10275 commit 651be8c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/main/java/org/matsim/prepare/pt/CreateBlankSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

Expand All @@ -30,21 +29,15 @@ public class CreateBlankSchedule implements MATSimAppCommand {
@CommandLine.Option(names = "--osm", description = "Path to the .osm-file", required = true)
private Path osmPath;

@CommandLine.Option(names = "--network", description = "Path to the matsim-network to use", required = true)
private Path networkPath;

@CommandLine.Option(names = "--config", description = "Path to the mapper-config.xml Can be created using the pt2matsim " +
"CreateDefaultPTMapperConfig.java. If no config is given, this code will automatically use the default-config for the kyoto-scenario.")
private Path configPath;

@CommandLine.Option(names = "--outSchedule", description = "Path, where to output the blank schedule file.", required = true)
private Path scheduleOutPath;

@CommandLine.Option(names = "--outNetwork", description = "Path, where to output the blank schedule file.", required = true)
@CommandLine.Option(names = "--outNetwork", description = "Path, where to output the network file with pt.", required = true)
private Path networkOutPath;

@CommandLine.Option(names = "--outCRS", description = "CRS in which to output the blank schedule file (default=EPSG:32653).", defaultValue = OpenKyotoScenario.CRS)
private String CRSOut;
private String CRS;


public static void main(String[] args) {
Expand All @@ -66,7 +59,7 @@ public Integer call() throws Exception {

// Start with the transitScheduleGeneration
log.info("Starting with osm2transitSchedule transformation...");
Osm2TransitSchedule.run(osmPath.toString(), "./schedule.tmp", CRSOut);
Osm2TransitSchedule.run(osmPath.toString(), "./schedule.tmp", CRS);
log.info("Finished osm2transitSchedule transformation!");

// Continue by mapping the schedule
Expand All @@ -79,15 +72,15 @@ public Integer call() throws Exception {
Network network = NetworkUtils.readNetwork(config.getOutputNetworkFile());

//TODO Add missing modes here (if there are any)
for(Link l : network.getLinks().values()){
for (Link l : network.getLinks().values()){
if (l.getAllowedModes().contains("bus")||
l.getAllowedModes().contains("tram")||
l.getAllowedModes().contains("train")||
l.getAllowedModes().contains("light_train")||
l.getAllowedModes().contains("subway")||
l.getAllowedModes().contains("artificial")){
HashSet<String> allowedModes = new HashSet<>(l.getAllowedModes());
List.of("bus", "tram", "rail", "light_rail", "subway").forEach(allowedModes::remove);
List.of("bus", "tram", "train", "light_train", "subway", "artificial").forEach(allowedModes::remove);
allowedModes.add("pt");
l.setAllowedModes(allowedModes);
}
Expand Down

0 comments on commit 651be8c

Please sign in to comment.