Machines added into City class

This commit is contained in:
atiya 2022-02-22 16:24:12 -05:00
parent 651151c6ac
commit a40c1a0154
3 changed files with 20 additions and 6 deletions

View File

@ -20,6 +20,7 @@ from city_model_structure.buildings_cluster import BuildingsCluster
from city_model_structure.parts_consisting_building import PartsConsistingBuilding from city_model_structure.parts_consisting_building import PartsConsistingBuilding
from city_model_structure.subway_entrance import SubwayEntrance from city_model_structure.subway_entrance import SubwayEntrance
from city_model_structure.fuel import Fuel from city_model_structure.fuel import Fuel
from city_model_structure.machine import Machine
from helpers.geometry_helper import GeometryHelper from helpers.geometry_helper import GeometryHelper
from helpers.location import Location from helpers.location import Location
from city_model_structure.energy_system import EnergySystem from city_model_structure.energy_system import EnergySystem
@ -52,6 +53,7 @@ class City:
self._city_objects = None self._city_objects = None
self._energy_systems = None self._energy_systems = None
self._fuels = None self._fuels = None
self._machines = None
self._stations = [] self._stations = []
@property @property
@ -62,6 +64,14 @@ class City:
def fuels(self, value): def fuels(self, value):
self._fuels = value self._fuels = value
@property
def machines(self) -> [Machine]:
return self._machines
@machines.setter
def machines(self, value):
self._machines = value
def _get_location(self) -> Location: def _get_location(self) -> Location:
if self._location is None: if self._location is None:
gps = pyproj.CRS('EPSG:4326') # LatLon with WGS84 datum used by GPS units and Google Earth gps = pyproj.CRS('EPSG:4326') # LatLon with WGS84 datum used by GPS units and Google Earth

View File

@ -14,7 +14,7 @@ from city_model_structure.attributes.polygon import Polygon
from city_model_structure.building import Building from city_model_structure.building import Building
from city_model_structure.city import City from city_model_structure.city import City
from city_model_structure.building_demand.surface import Surface as LibsSurface from city_model_structure.building_demand.surface import Surface as LibsSurface
from helpers.constants import EPSILON # from helpers.constants import EPSILON
from imports.geometry.helpers.geometry_helper import GeometryHelper from imports.geometry.helpers.geometry_helper import GeometryHelper

View File

@ -16,12 +16,16 @@ class LcaMachine:
def enrich(self): def enrich(self):
self._city.machines = [] self._city.machines = []
# print(self._base_path)
path = Path(self._base_path / 'lca_data.xml').resolve() path = Path(self._base_path / 'lca_data.xml').resolve()
with open(path) as xml: with open(path) as xml:
self._lca = xmltodict.parse(xml.read()) self._lca = xmltodict.parse(xml.read())
for machine in self._lca["library"]["machines"]['machine']: for machine in self._lca["library"]["machines"]['machine']:
self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'], self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'],
machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'], machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'],
machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'], machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'],
machine['carbon_emission_factor']['@unit'])) machine['carbon_emission_factor']['@unit']))