Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: optionally add vehicles for cutting
Browse files Browse the repository at this point in the history
sebhoerl committed May 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 18eb5c3 commit 763aff6
Showing 8 changed files with 55 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.eqasim.core.scenario.cutter.transit.TransitVehiclesCutter;
import org.eqasim.core.scenario.routing.PopulationRouter;
import org.eqasim.core.scenario.routing.PopulationRouterModule;
import org.eqasim.core.scenario.routing.RunPopulationRouting;
import org.eqasim.core.scenario.validation.ScenarioValidator;
import org.eqasim.core.simulation.EqasimConfigurator;
import org.eqasim.core.simulation.mode_choice.AbstractEqasimExtension;
@@ -44,13 +45,15 @@ static public void main(String[] args)
throws ConfigurationException, MalformedURLException, IOException, InterruptedException {
CommandLine cmd = new CommandLine.Builder(args) //
.requireOptions("config-path", "output-path", "extent-path") //
.allowOptions("threads", "prefix", "extent-attribute", "extent-value", "plans-path", "events-path") //
.allowOptions("threads", "prefix", "extent-attribute", "extent-value", "plans-path", "events-path",
"insert-vehicles") //
.build();

// Load some configuration
String prefix = cmd.getOption("prefix").orElse("");
int numberOfThreads = cmd.getOption("threads").map(Integer::parseInt)
.orElse(Runtime.getRuntime().availableProcessors());
boolean insertVehicles = cmd.getOption("insert-vehicles").map(Boolean::parseBoolean).orElse(false);

File outputDirectory = new File(cmd.getOptionStrict("output-path")).getAbsoluteFile();
ScenarioWriter.checkOutputDirectory(outputDirectory);
@@ -64,7 +67,7 @@ static public void main(String[] args)
// Load scenario
EqasimConfigurator configurator = new EqasimConfigurator();
configurator.getModules().removeIf(m -> m instanceof EqasimTerminationModule);

Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path"), configurator.getConfigGroups());
cmd.applyConfiguration(config);

@@ -83,6 +86,10 @@ static public void main(String[] args)
Scenario scenario = ScenarioUtils.createScenario(config);
configurator.configureScenario(scenario);
ScenarioUtils.loadScenario(scenario);

if (insertVehicles) {
RunPopulationRouting.insertVehicles(config, scenario);
}

// Check validity before cutting
ScenarioValidator scenarioValidator = new ScenarioValidator();
@@ -101,7 +108,8 @@ static public void main(String[] args)

// Cut population
Injector populationCutterInjector = new InjectorBuilder(scenario) //
.addOverridingModules(configurator.getModules().stream().filter(module -> !(module instanceof AbstractEqasimExtension)).toList()) //
.addOverridingModules(configurator.getModules().stream()
.filter(module -> !(module instanceof AbstractEqasimExtension)).toList()) //
.addOverridingModule(
new PopulationCutterModule(extent, numberOfThreads, 40, cmd.getOption("events-path"))) //
.addOverridingModule(new CutterTravelTimeModule(travelTime)) //
@@ -154,7 +162,8 @@ static public void main(String[] args)

// Final routing
Injector routingInjector = new InjectorBuilder(scenario) //
.addOverridingModules(configurator.getModules().stream().filter(module -> !(module instanceof AbstractEqasimExtension)).toList()) //
.addOverridingModules(configurator.getModules().stream()
.filter(module -> !(module instanceof AbstractEqasimExtension)).toList()) //
.addOverridingModule(new PopulationRouterModule(numberOfThreads, 100, false)) //
.addOverridingModule(new CutterTravelTimeModule(travelTime)) //
.addOverridingModule(new TimeInterpretationModule()) //
1 change: 1 addition & 0 deletions core/src/main/resources/melun/center.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file added core/src/main/resources/melun/center.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions core/src/main/resources/melun/center.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["RGF93_Lambert_93",GEOGCS["GCS_RGF93_geographiques_dms",DATUM["D_RGF_1993",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",700000.0],PARAMETER["False_Northing",6600000.0],PARAMETER["Central_Meridian",3.0],PARAMETER["Standard_Parallel_1",44.0],PARAMETER["Standard_Parallel_2",49.0],PARAMETER["Latitude_Of_Origin",46.5],UNIT["Meter",1.0]]
27 changes: 27 additions & 0 deletions core/src/main/resources/melun/center.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="3.36.1-Maidenhead">
<identifier></identifier>
<parentidentifier></parentidentifier>
<language></language>
<type>dataset</type>
<title></title>
<abstract></abstract>
<links/>
<dates/>
<fees></fees>
<encoding></encoding>
<crs>
<spatialrefsys nativeFormat="Wkt">
<wkt>PROJCRS["RGF93 Lambert 93",BASEGEOGCRS["RGF93 geographiques (dms)",DATUM["Reseau Geodesique Francais 1993 v1",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["IGNF","RGF93G"]],CONVERSION["LAMBERT-93",METHOD["Lambert Conic Conformal (2SP)",ID["EPSG",9802]],PARAMETER["Latitude of false origin",46.5,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8821]],PARAMETER["Longitude of false origin",3,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8822]],PARAMETER["Latitude of 1st standard parallel",44,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Latitude of 2nd standard parallel",49,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8824]],PARAMETER["Easting at false origin",700000,LENGTHUNIT["metre",1],ID["EPSG",8826]],PARAMETER["Northing at false origin",6600000,LENGTHUNIT["metre",1],ID["EPSG",8827]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["NATIONALE A CARACTERE LEGAL"],AREA["FRANCE METROPOLITAINE (CORSE COMPRISE)"],BBOX[41,-5.5,52,10]],ID["IGNF","LAMB93"]]</wkt>
<proj4>+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=44 +lat_2=49 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs</proj4>
<srsid>10089</srsid>
<srid>310024140</srid>
<authid>IGNF:LAMB93</authid>
<description>RGF93 Lambert 93</description>
<projectionacronym>lcc</projectionacronym>
<ellipsoidacronym>EPSG:7019</ellipsoidacronym>
<geographicflag>false</geographicflag>
</spatialrefsys>
</crs>
<extent/>
</qgis>
Binary file added core/src/main/resources/melun/center.shp
Binary file not shown.
Binary file added core/src/main/resources/melun/center.shx
Binary file not shown.
13 changes: 13 additions & 0 deletions core/src/test/java/org/eqasim/TestSimulationPipeline.java
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
import org.eqasim.core.analysis.run.RunLegAnalysis;
import org.eqasim.core.analysis.run.RunPublicTransportLegAnalysis;
import org.eqasim.core.analysis.run.RunTripAnalysis;
import org.eqasim.core.scenario.cutter.RunScenarioCutter;
import org.eqasim.core.scenario.routing.RunPopulationRouting;
import org.eqasim.core.simulation.EqasimConfigurator;
import org.eqasim.core.simulation.analysis.EqasimAnalysisModule;
import org.eqasim.core.simulation.mode_choice.AbstractEqasimExtension;
@@ -193,6 +195,16 @@ private void runExports() throws Exception {
"--output-path", "melun_test/exports/persons.csv"
});
}

private void runCutter() throws Exception {
RunScenarioCutter.main(new String[] {
"--config-path", "melun_test/input/config.xml",
"--events-path", "melun_test/output/output_events.xml.gz",
"--output-path", "melun_test/cutter",
"--prefix", "center_",
"--extent-path", "melun_test/input/center.shp"
});
}

@Test
public void testDrt() throws IOException, CommandLine.ConfigurationException {
@@ -316,6 +328,7 @@ public void testPipeline() throws Exception {
runStandaloneModeChoice();
runAnalyses();
runExports();
runCutter();
}


0 comments on commit 763aff6

Please sign in to comment.