diff --git a/__pycache__/matsim.cpython-39.pyc b/__pycache__/matsim.cpython-39.pyc index 0c7f12c..9f23944 100644 Binary files a/__pycache__/matsim.cpython-39.pyc and b/__pycache__/matsim.cpython-39.pyc differ diff --git a/__pycache__/matsim_visualizer.cpython-39.pyc b/__pycache__/matsim_visualizer.cpython-39.pyc index d0798ab..683f809 100644 Binary files a/__pycache__/matsim_visualizer.cpython-39.pyc and b/__pycache__/matsim_visualizer.cpython-39.pyc differ diff --git a/main.py b/main.py index c145760..9bfffad 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,7 @@ +import gzip + import json +import shutil from pathlib import Path from hub.imports.geometry_factory import GeometryFactory @@ -32,7 +35,7 @@ try: visualizer = MatsimVisualizer( 'output_files/Montreal', 'output_files', - (3854635.608067, 6040255.047194, 3855550.392442, 6039416.667303), + (3853903.627142, 6041373.293774, 3856702.336973, 6038057.730141), True ) visualizer.visualize() diff --git a/matsim-network-from-osm.jar b/matsim-network-from-osm.jar index e1e4302..841637f 100644 Binary files a/matsim-network-from-osm.jar and b/matsim-network-from-osm.jar differ diff --git a/matsim.py b/matsim.py index b11eede..99f2bed 100644 --- a/matsim.py +++ b/matsim.py @@ -27,7 +27,7 @@ MONTREAL_RIGHT = 3863759.595656 class Matsim: - def __init__(self, city, output_file_path): + def __init__(self, city, output_file_path, crs="EPSG:26911"): """ Constructs a Matsim exporter instance with a city object and an output file path. @@ -36,7 +36,7 @@ class Matsim: """ self._city = city self._output_file_path = output_file_path - + self._crs = crs self._facilities = { 'name': self._city.name + ' Facilities', 'facility': [] @@ -133,7 +133,8 @@ class Matsim: "-jar", jar_path, "input_files/merged-network.osm.pbf", f"{self._output_file_path}/buildings_shapefile.shp", - f"{self._output_file_path}/{self._city.name}_network.xml.gz" + f"{self._output_file_path}/{self._city.name}_network.xml.gz", + self._crs ] subprocess.run(command) @@ -141,11 +142,10 @@ class Matsim: """ Generates and exports the city's population data to an XML file. """ + population = etree.Element("population") + id = 0 + try: - - population = etree.Element("population") - id = 0 - # Generate work facilities work = [] for facility in self._facilities['facility']: @@ -325,34 +325,22 @@ class Matsim: ('typicalDuration', '13:00:00'), ('minimalDuration', '01:00:00'), ]), - ('medium office',[ - ('priority', '1'), - ('typicalDuration', '09:00:00'), - ('minimalDuration', '08:00:00'), - ('openingTime', '08:00:00'), - ('earliestEndTime', '17:00:00'), - ('latestStartTime', '09:00:00'), - ('closingTime', '18:00:00'), - ]), - ('warehouse',[ - ('priority', '1'), - ('typicalDuration', '09:00:00'), - ('minimalDuration', '08:00:00'), - ('openingTime', '08:00:00'), - ('earliestEndTime', '17:00:00'), - ('latestStartTime', '09:00:00'), - ('closingTime', '18:00:00'), - ]), - ('stand alone retail',[ - ('priority', '1'), - ('typicalDuration', '09:00:00'), - ('minimalDuration', '08:00:00'), - ('openingTime', '08:00:00'), - ('earliestEndTime', '17:00:00'), - ('latestStartTime', '09:00:00'), - ('closingTime', '18:00:00'), - ]), ] + + for facility in self._facilities['facility']: + if not any(activity[0] == facility['activity'][0]['type'] for activity in activity_paramsets): + activity_paramsets.append( + (facility['activity'][0]['type'], [ + ('priority', '1'), + ('typicalDuration', '09:00:00'), + ('minimalDuration', '08:00:00'), + ('openingTime', '08:00:00'), + ('earliestEndTime', '17:00:00'), + ('latestStartTime', '09:00:00'), + ('closingTime', '18:00:00'), + ]) + ) + for activity_type, parameters in activity_paramsets: _add_parameterset(scoring_paramset, "activityParams", [("activityType", activity_type)] + parameters)