2023-01-31 13:11:39 -05:00
|
|
|
"""
|
|
|
|
Model representation of a city object
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca
|
|
|
|
"""
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
from sqlalchemy import Column, Integer, String, Sequence, ForeignKey, Float
|
|
|
|
from sqlalchemy import DateTime
|
2023-05-10 17:06:51 -04:00
|
|
|
|
|
|
|
from hub.city_model_structure.building import Building
|
2023-02-02 06:12:24 -05:00
|
|
|
from hub.persistence.configuration import Models
|
2023-01-31 13:11:39 -05:00
|
|
|
|
2023-02-02 06:12:24 -05:00
|
|
|
class CityObject(Models):
|
2023-01-31 13:11:39 -05:00
|
|
|
"""
|
|
|
|
A model representation of an application
|
|
|
|
"""
|
2023-02-02 06:12:24 -05:00
|
|
|
__tablename__ = 'city_object'
|
2023-02-08 13:40:06 -05:00
|
|
|
id = Column(Integer, Sequence('city_object_id_seq'), primary_key=True)
|
2023-01-31 13:11:39 -05:00
|
|
|
city_id = Column(Integer, ForeignKey('city.id'), nullable=False)
|
|
|
|
name = Column(String, nullable=False)
|
|
|
|
alias = Column(String, nullable=True)
|
|
|
|
type = Column(String, nullable=False)
|
|
|
|
year_of_construction = Column(Integer, nullable=True)
|
|
|
|
function = Column(String, nullable=True)
|
|
|
|
usage = Column(String, nullable=True)
|
|
|
|
volume = Column(Float, nullable=False)
|
|
|
|
area = Column(Float, nullable=False)
|
2023-05-10 17:06:51 -04:00
|
|
|
total_heating_area = Column(Float, nullable=False)
|
|
|
|
wall_area = Column(Float, nullable=False)
|
|
|
|
windows_area = Column(Float, nullable=False)
|
|
|
|
system_name = Column(String, nullable=False)
|
2023-01-31 13:11:39 -05:00
|
|
|
created = Column(DateTime, default=datetime.datetime.utcnow)
|
|
|
|
updated = Column(DateTime, default=datetime.datetime.utcnow)
|
|
|
|
|
2023-05-10 17:06:51 -04:00
|
|
|
# def __init__(self, city_id, name, alias, object_type, year_of_construction, function, usage, volume, area):
|
|
|
|
def __init__(self, city_id, building: Building):
|
2023-01-31 13:11:39 -05:00
|
|
|
self.city_id = city_id
|
2023-05-10 17:06:51 -04:00
|
|
|
self.name = building.name
|
|
|
|
self.alias = building.alias
|
|
|
|
self.type = building.type
|
|
|
|
self.year_of_construction = building.year_of_construction
|
|
|
|
self.function = building.function
|
|
|
|
self.usage = building.usages_percentage
|
|
|
|
self.volume = building.volume
|
|
|
|
self.area = building.floor_area
|