New jar to account for crs

This commit is contained in:
Ruben1729 2024-03-28 15:23:50 -04:00
parent 47b26c4882
commit e81a4bf8d6
5 changed files with 26 additions and 35 deletions

Binary file not shown.

View File

@ -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()

Binary file not shown.

View File

@ -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)