Skip to content

Commit

Permalink
Merge pull request #355 from cymed/import-wastewater-structure-symbols
Browse files Browse the repository at this point in the history
Import/export wastewater structure symbols
  • Loading branch information
ponceta authored Aug 8, 2024
2 parents e0159e9 + c9aceff commit 6f6a21b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 3 deletions.
4 changes: 2 additions & 2 deletions datamodel/changelogs/0001/03_tww_db_dss.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4895,8 +4895,8 @@ COMMENT ON COLUMN tww_od.wastewater_structure_symbol.obj_id IS 'INTERLIS STANDAR
COMMENT ON COLUMN tww_od.wastewater_structure_symbol.classname IS 'Name of class that symbol class is related to / Name der Klasse zu der die Symbolklasse gehört / nom de la classe à laquelle appartient la classe de symbole';
ALTER TABLE tww_od.wastewater_structure_symbol ADD COLUMN plantype integer ;
COMMENT ON COLUMN tww_od.wastewater_structure_symbol.plantype IS '';
ALTER TABLE tww_od.wastewater_structure_symbol ADD COLUMN symbol_scaling_heigth decimal(2,1) ;
COMMENT ON COLUMN tww_od.wastewater_structure_symbol.symbol_scaling_heigth IS '';
ALTER TABLE tww_od.wastewater_structure_symbol ADD COLUMN symbol_scaling_height decimal(2,1) ;
COMMENT ON COLUMN tww_od.wastewater_structure_symbol.symbol_scaling_height IS '';
ALTER TABLE tww_od.wastewater_structure_symbol ADD COLUMN symbol_scaling_width decimal(2,1) ;
COMMENT ON COLUMN tww_od.wastewater_structure_symbol.symbol_scaling_width IS '';
ALTER TABLE tww_od.wastewater_structure_symbol ADD COLUMN symbolori decimal(4,1) ;
Expand Down
2 changes: 1 addition & 1 deletion datamodel/changelogs/0001/09_tww_dictionaries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ orientiert. Ein Einzugsgebiet setzt sich aus einer oder mehreren Gemeindefläche
INSERT INTO tww_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (99700,7864,'wastewater_structure_symbol','symbolori','symbolori','SymbolOri','SYMBOLEORI','simboloori','simbolori','Default: 90 Degree','Default: 90 Grad','Default: 90 degree','Default: 90 Grad','Default: 90 Grad',ARRAY['kein_Plantyp_definiert']::tww_od.plantype[],'true','decimal(4,1)','[degrees]','Degree','[Altgrad]','[Altgrad]','[degres]','degrées [degres]','[vecchi gradi]','vecchi gradi','rrr_[Altgrad]','rrr_Altgrad',0,359.9);
INSERT INTO tww_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (99700,7867,'wastewater_structure_symbol','plantype','plantype','Plantyp','TYPE_DE_PLAN','tipo_di_pianta','tipul_planului','NULL','NULL','NULL','NULL','Default: 90 Grad',ARRAY['kein_Plantyp_definiert']::tww_od.plantype[],'true','integer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO tww_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (99700,7888,'wastewater_structure_symbol','symbol_scaling_width','symbol_scaling_width','SymbolskalierungLaengs','MISE_A_L_ECHELLE_EN_LONGUEUR','ridimensionamento_lunghezza','latimea_de_scalare_a_simbolului','NULL','NULL','NULL','NULL','NULL',ARRAY['kein_Plantyp_definiert']::tww_od.plantype[],'true','decimal(2,1)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,9.9);
INSERT INTO tww_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (99700,7889,'wastewater_structure_symbol','symbol_scaling_heigth','symbol_scaling_heigth','SymbolskalierungHoch','MISE_A_L_ECHELLE_EN_HAUTEUR','ridimensionamento_altezza','inaltimea_de_scalare_a_simbolului','NULL','NULL','NULL','NULL','NULL',ARRAY['kein_Plantyp_definiert']::tww_od.plantype[],'true','decimal(2,1)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,9.9);
INSERT INTO tww_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (99700,7889,'wastewater_structure_symbol','symbol_scaling_height','symbol_scaling_height','SymbolskalierungHoch','MISE_A_L_ECHELLE_EN_HAUTEUR','ridimensionamento_altezza','inaltimea_de_scalare_a_simbolului','NULL','NULL','NULL','NULL','NULL',ARRAY['kein_Plantyp_definiert']::tww_od.plantype[],'true','decimal(2,1)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,9.9);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def _export_sia405_abwasser(self):
self._export_benching()
self._check_for_stop()

logger.info("Exporting TWW.wastewater_structure_symbol -> ABWASSER.abwasserbauwerk_symbol")
self._export_wastewater_structure_symbol()
self._check_for_stop()

logger.info("Exporting TWW.flushing_nozzle -> ABWASSER.spuelstutzen")
self._export_flushing_nozzle()
self._check_for_stop()
Expand Down Expand Up @@ -1025,6 +1029,35 @@ def _export_benching(self):
logger.info("done")
self.abwasser_session.flush()

def _export_wastewater_structure_symbol(self):
query = self.tww_session.query(self.model_classes_tww_od.wastewater_structure_symbol)
if self.filtered:
query = query.join(
self.model_classes_tww_od.wastewater_structure,
self.model_classes_tww_od.wastewater_networkelement,
).filter(
self.model_classes_tww_od.wastewater_networkelement.obj_id.in_(self.subset_ids)
)
# add sql statement to logger
statement = query.statement
logger.info(f" selection query = {statement}")
for row in query:
abwasserbauwerk_symbol = self.model_classes_interlis.abwasserbauwerk_symbol(
# FIELDS TO MAP TO ABWASSER.abwasserbauwerk_symbol
# --- abwasserbauwerk_symbol ---
t_ili_tid=row.obj_id,
plantyp=self.get_vl(row.plantype__REL),
symbolskalierunghoch=row.symbol_scaling_height,
symbolskalierunglaengs=row.symbol_scaling_width,
symbolori=row.symbolori,
symbolpos=row.symbolpos_geometry,
abwasserbauwerkref=self.get_tid(row.fk_wastewater_structure__REL),
)
self.abwasser_session.add(abwasserbauwerk_symbol)
print(".", end="")
logger.info("done")
self.abwasser_session.flush()

def _export_flushing_nozzle(self):
query = self.tww_session.query(self.model_classes_tww_od.flushing_nozzle)
if self.filtered:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def _import_sia405_abwasser(self):
self._import_spuelstutzen()
self._check_for_stop()

logger.info(
"\nImporting ABWASSER.abwasserbauwerk_symbol -> TWW.wastewater_structure_symbol"
)
self._import_abwasserbauwerk_symbol()
self._check_for_stop()

def _import_dss(self):
logger.info(
"\nImporting ABWASSER.abwasserreinigungsanlage -> TWW.waste_water_treatment_plant"
Expand Down Expand Up @@ -2055,6 +2061,24 @@ def _import_spuelstutzen(self):
self.session_tww.add(flushing_nozzle)
print(".", end="")

def _import_abwasserbauwerk_symbol(self):
for row in self.session_interlis.query(self.model_classes_interlis.abwasserbauwerk_symbol):
wastewater_structure_symbol = self.create_or_update(
self.model_classes_tww_od.wastewater_structure_symbol,
# --- wastewater_structure_symbol ---
obj_id=row.t_ili_tid,
plantype=self.get_vl_code(
self.model_classes_tww_vl.wastewater_structure_symbol_plantype, row.plantyp
),
symbol_scaling_height=row.symbolskalierunghoch,
symbol_scaling_width=row.symbolskalierunglaengs,
symbolori=row.symbolori,
symbolpos_geometry=row.symbolpos,
fk_wastewater_structure=self.get_pk(row.abwasserbauwerkref__REL),
)
self.session_tww.add(wastewater_structure_symbol)
print(".", end="")

def _import_untersuchung(self):
for row in self.session_interlis.query(self.model_classes_interlis.untersuchung):
examination = self.create_or_update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,23 @@ class abwasserbauwerk_text(sia405_textpos):
__table_args__ = {"schema": config.ABWASSER_SCHEMA}

ModelInterlisSia405Abwasser.abwasserbauwerk_text = abwasserbauwerk_text

# SymbolPos

class symbolpos(baseclass):
__tablename__ = "symbolpos"
__table_args__ = {"schema": config.ABWASSER_SCHEMA}

ModelInterlisSia405Abwasser.symbolpos = symbolpos

class sia405_symbolpos(symbolpos):
__tablename__ = "sia405_symbolpos"
__table_args__ = {"schema": config.ABWASSER_SCHEMA}

ModelInterlisSia405Abwasser.sia405_symbolpos = sia405_symbolpos

class abwasserbauwerk_symbol(sia405_symbolpos):
__tablename__ = "abwasserbauwerk_symbol"
__table_args__ = {"schema": config.ABWASSER_SCHEMA}

ModelInterlisSia405Abwasser.abwasserbauwerk_symbol = abwasserbauwerk_symbol

0 comments on commit 6f6a21b

Please sign in to comment.