mirror of
				https://github.com/Ahp06/SUMO_Emissions.git
				synced 2025-10-31 02:19:18 +00:00 
			
		
		
		
	Add sumoconfig template
This commit is contained in:
		| @@ -45,6 +45,7 @@ def load_sumoconfig_template(simulation_name): | ||||
| def generate_scenario(osm_file, out_path, scenario_name): | ||||
|     net_template = load_netconvert_template(osm_file, scenario_name) | ||||
|     poly_template = load_polyconvert_template(osm_file, 'typemap/osmPolyconvert.typ.xml', scenario_name) | ||||
|  | ||||
|     with tempfile.TemporaryDirectory() as tmpdirname: | ||||
|         netconfig = os.path.join(tmpdirname, f'{scenario_name}.netcfg') | ||||
|         polyconfig = os.path.join(tmpdirname, f'{scenario_name}.polycfg') | ||||
| @@ -86,12 +87,27 @@ def generate_mobility(path, name): | ||||
|     randomTrips.main(randomTrips.get_options(options)) | ||||
|  | ||||
|  | ||||
| def generate_all(osm_file, output_path): | ||||
|     output_dir = os.path.dirname(output_path) | ||||
|     simulation_name = os.path.basename(output_path) | ||||
|     generate_scenario(osm_file, output_dir, simulation_name) | ||||
|     generate_mobility(output_dir, simulation_name) | ||||
| def generate_sumo_configuration(path, scenario_name): | ||||
|     sumo_template = load_sumoconfig_template(scenario_name) | ||||
|     sumo_template.write(os.path.join(path, f'{scenario_name}.sumocfg')) | ||||
|  | ||||
|  | ||||
| def generate_all(osm_file, output_path, simulation_name): | ||||
|     simulation_dir = os.path.join(output_path, simulation_name) | ||||
|     logs_dir = os.path.join(simulation_dir, 'log') | ||||
|     if not os.path.exists(simulation_dir): | ||||
|         os.mkdir(simulation_dir) | ||||
|         os.mkdir(logs_dir) | ||||
|     generate_scenario(osm_file, simulation_dir, simulation_name) | ||||
|     generate_mobility(simulation_dir, simulation_name) | ||||
|     generate_sumo_configuration(simulation_dir, simulation_name) | ||||
|     # Move all logs to logdir | ||||
|     for f in os.listdir(simulation_dir): | ||||
|         if os.path.splitext(f)[1] == '.log': | ||||
|             shutil.move(os.path.join(simulation_dir, f), logs_dir) | ||||
|  | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     pass | ||||
|     path = '/tmp/scenario/' | ||||
|     osm = '/tmp/scenario/map.osm' | ||||
|     generate_all(osm, path, 'foo') | ||||
|   | ||||
| @@ -8,13 +8,14 @@ | ||||
|     </input> | ||||
|  | ||||
|     <output> | ||||
|         <output-prefix value="simul." /> | ||||
|         <output-file value="net.xml"/> | ||||
|         <!--<output-prefix value="simul." />--> | ||||
|         <output-file value="simul.net.xml"/> | ||||
|     </output> | ||||
|  | ||||
|     <tls_building> | ||||
|         <tls.join value="true"/> | ||||
|         <tls.guess-signals value="true"/> | ||||
|         <tls.discard-simple value="true" /> | ||||
|         <tls.default-type value="actuated"/> | ||||
|         <tls.min-dur value="5"/> | ||||
|         <tls.max-dur value="30"/> | ||||
| @@ -24,10 +25,15 @@ | ||||
|         <ramps.guess value="true"/> | ||||
|     </ramp_guessing> | ||||
|  | ||||
|     <junctions> | ||||
|          <junctions.join value="true"/> | ||||
|     </junctions> | ||||
|  | ||||
|     <processing> | ||||
|         <geometry.remove value="true"/> | ||||
|         <roundabouts.guess value="true"/> | ||||
|         <junctions.join value="true"/> | ||||
|  | ||||
|         <!-- | ||||
|         <junctions.limit-turn-speed value="1"/> | ||||
|         <crossings.guess value="true"/> | ||||
|         <walkingareas value="false"/> | ||||
| @@ -38,7 +44,7 @@ | ||||
|         <no-internal-links value="false"/> | ||||
|         <ignore-errors value="false"/> | ||||
|         <ignore-errors.connections value="false"/> | ||||
|         <show-errors.connections-first-try value="true"/> | ||||
|         <show-errors.connections-first-try value="true"/>--> | ||||
|     </processing> | ||||
|  | ||||
|     <building_defaults> | ||||
|   | ||||
| @@ -1,30 +1,11 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
|  | ||||
| <!-- | ||||
|     Monaco SUMO Traffic (MoST) Scenario | ||||
|     Copyright (C) 2018 | ||||
|     Lara CODECA | ||||
|  | ||||
|     This program is free software: you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation, either version 3 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed static the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License | ||||
|     along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| --> | ||||
|  | ||||
| <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/polyconvertConfiguration.xsd"> | ||||
|  | ||||
|     <input> | ||||
|         <net-file value="simul.net.xml"/> | ||||
|         <osm-files value="simul.raw.osm"/> | ||||
|         <osm.keep-full-type value="true"/> | ||||
|         <!--<osm.keep-full-type value="true"/>--> | ||||
|         <type-file value="typemap/osmPolyconvert.typ.xml"/> | ||||
|     </input> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user