From 0b10118f80dbb9ced3035e5e0c1ffcd48e8808af Mon Sep 17 00:00:00 2001 From: rakow Date: Thu, 8 Aug 2024 22:12:28 +0200 Subject: [PATCH] configurable crs for filter agent class --- .../matsim/prepare/FilterRelevantAgents.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/matsim/prepare/FilterRelevantAgents.java b/src/main/java/org/matsim/prepare/FilterRelevantAgents.java index 455bf3f1..42de3fb0 100644 --- a/src/main/java/org/matsim/prepare/FilterRelevantAgents.java +++ b/src/main/java/org/matsim/prepare/FilterRelevantAgents.java @@ -14,6 +14,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; import org.matsim.application.MATSimAppCommand; +import org.matsim.application.options.CrsOptions; import org.matsim.application.options.ShpOptions; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; @@ -41,8 +42,8 @@ @CommandLine.Command( - name = "filter-relevant-agents", - description = "Filter agents that have any activities or routes within the shp file." + name = "filter-relevant-agents", + description = "Filter agents that have any activities or routes within the shp file." ) public class FilterRelevantAgents implements MATSimAppCommand, PersonAlgorithm { @@ -63,6 +64,9 @@ public class FilterRelevantAgents implements MATSimAppCommand, PersonAlgorithm { @CommandLine.Mixin private ShpOptions shp; + @CommandLine.Mixin + private CrsOptions crs = new CrsOptions(OpenBerlinScenario.CRS); + private ActivityFacilities facilities; private Network network; private CoordinateTransformation ct; @@ -75,6 +79,16 @@ public static void main(String[] args) { new FilterRelevantAgents().execute(args); } + private static LeastCostPathCalculator createRouter(Network network) { + + FreeSpeedTravelTime travelTime = new FreeSpeedTravelTime(); + LeastCostPathCalculatorFactory factory = new SpeedyALTFactory(); + + OnlyTimeDependentTravelDisutility travelDisutility = new OnlyTimeDependentTravelDisutility(travelTime); + + return factory.createPathCalculator(network, travelDisutility, travelTime); + } + @Override public Integer call() throws Exception { @@ -89,11 +103,10 @@ public Integer call() throws Exception { filter.filter(network, Set.of(TransportMode.car)); geometry = shp.getGeometry(); - ct = shp.createTransformation(OpenBerlinScenario.CRS); + ct = shp.createTransformation(crs.getInputCRS()); facilities = FacilitiesUtils.createActivityFacilities(); - new MatsimFacilitiesReader(OpenBerlinScenario.CRS, OpenBerlinScenario.CRS, facilities) - .readFile(facilityPath.toString()); + new MatsimFacilitiesReader(crs.getInputCRS(), crs.getInputCRS(), facilities).readFile(facilityPath.toString()); ctxs = ThreadLocal.withInitial(() -> this.createRouter(network)); toRemove = ConcurrentHashMap.newKeySet(); @@ -174,14 +187,4 @@ private Coord getCoordinate(Activity act) { return coord; } - - private static LeastCostPathCalculator createRouter(Network network) { - - FreeSpeedTravelTime travelTime = new FreeSpeedTravelTime(); - LeastCostPathCalculatorFactory factory = new SpeedyALTFactory(); - - OnlyTimeDependentTravelDisutility travelDisutility = new OnlyTimeDependentTravelDisutility(travelTime); - - return factory.createPathCalculator(network, travelDisutility, travelTime); - } }