diff --git a/src/main/java/org/matsim/stuttgart/prepare/CreatePt.java b/src/main/java/org/matsim/stuttgart/prepare/CreatePt.java index 49eca4d..11dcfcd 100644 --- a/src/main/java/org/matsim/stuttgart/prepare/CreatePt.java +++ b/src/main/java/org/matsim/stuttgart/prepare/CreatePt.java @@ -58,7 +58,7 @@ public static void create(Path sharedSvn, Network network, ElevationReader eleva GtfsConverter.newBuilder() .setScenario(scenario) .setTransform(Utils.getTransformationWGS84ToUTM32()) - .setDate(LocalDate.now()) + .setDate(LocalDate.of(2021, 4, 29)) .setFeed(sharedSvn.resolve(schedule)) .build() .convert(); diff --git a/src/main/java/org/matsim/stuttgart/run/StuttgartApplication.java b/src/main/java/org/matsim/stuttgart/run/StuttgartApplication.java index 6770323..2c944d0 100644 --- a/src/main/java/org/matsim/stuttgart/run/StuttgartApplication.java +++ b/src/main/java/org/matsim/stuttgart/run/StuttgartApplication.java @@ -5,6 +5,8 @@ import org.locationtech.jts.geom.prep.PreparedGeometryFactory; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; +import org.matsim.api.core.v01.population.Activity; +import org.matsim.api.core.v01.population.Leg; import org.matsim.application.MATSimApplication; import org.matsim.contrib.bicycle.BicycleConfigGroup; import org.matsim.contrib.bicycle.Bicycles; @@ -34,6 +36,9 @@ @CommandLine.Command(header = ":: Open Stuttgart Scenario ::", version = StuttgartApplication.VERSION) public class StuttgartApplication extends MATSimApplication { + @CommandLine.Option(names = "--cleanNetworkRefs", description = "Removes network ids from plans file") + private boolean cleanNetworkReferences = false; + /** * Current version identifier. */ @@ -94,7 +99,24 @@ protected Config prepareConfig(Config config) { @Override protected void prepareScenario(Scenario scenario) { - // don't do anything + if (this.cleanNetworkReferences) { + + // remove references from activities + scenario.getPopulation().getPersons().values().parallelStream() + .flatMap(person -> person.getPlans().stream()) + .flatMap(plan -> plan.getPlanElements().stream()) + .filter(element -> element instanceof Activity) + .map(element -> (Activity)element) + .forEach(activity -> activity.setLinkId(null)); + + // remove references from legs + scenario.getPopulation().getPersons().values().parallelStream() + .flatMap(person -> person.getPlans().stream()) + .flatMap(plan -> plan.getPlanElements().stream()) + .filter(element -> element instanceof Leg) + .map(element -> (Leg)element) + .forEach(leg -> leg.setRoute(null)); + } } @Override