Skip to content

Commit 3c765d6

Browse files
committed
Merge remote-tracking branch 'origin/main' into merge-upstream
2 parents 9e179f8 + 2f227b7 commit 3c765d6

File tree

5 files changed

+329
-69
lines changed

5 files changed

+329
-69
lines changed

plugin/teksi_wastewater/interlis/interlis_importer_exporter.py

+52-15
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def interlis_export(
197197
export_orientation=export_orientation,
198198
selected_labels_scales_indices=selected_labels_scales_indices,
199199
labels_file_path=labels_file_path,
200+
export_model=export_models[0]
200201
)
201202

202203
# Export to the temporary ili2pg model
@@ -324,9 +325,8 @@ def _export_labels_file(
324325
export_orientation,
325326
selected_labels_scales_indices,
326327
labels_file_path,
327-
):
328-
self._progress_done(self.current_progress, "Extracting labels...")
329-
328+
export_model
329+
):
330330
try:
331331
# We only import now to avoid useless exception if dependencies aren't met
332332
from qgis import processing
@@ -347,19 +347,56 @@ def _export_labels_file(
347347
"Make sure your TEKSI Wastewater project is open.",
348348
None,
349349
)
350-
350+
351351
self._progress_done(self.current_progress + 5)
352-
processing.run(
353-
"tww:extractlabels_interlis",
354-
{
355-
"OUTPUT": labels_file_path,
356-
"RESTRICT_TO_SELECTION": limit_to_selection,
357-
"EXPORT_ORIENTATION": export_orientation,
358-
"STRUCTURE_VIEW_LAYER": structures_lyr,
359-
"REACH_VIEW_LAYER": reaches_lyr,
360-
"SCALES": selected_labels_scales_indices,
361-
},
362-
)
352+
if export_model == config.MODEL_NAME_AG96:
353+
catch_lyr = TwwLayerManager.layer("catchment_area")
354+
meas_pt_lyr = TwwLayerManager.layer("measure_point")
355+
meas_lin_lyr = TwwLayerManager.layer("measure_line")
356+
meas_ply_lyr = TwwLayerManager.layer("measure_polygon")
357+
building_group_lyr = TwwLayerManager.layer("building_group")
358+
359+
processing.run(
360+
"tww:extractlabels_interlis",
361+
{
362+
"OUTPUT": labels_file_path,
363+
"RESTRICT_TO_SELECTION": limit_to_selection,
364+
"STRUCTURE_VIEW_LAYER": structures_lyr,
365+
"REACH_VIEW_LAYER": reaches_lyr,
366+
"CATCHMENT_LAYER": catch_lyr,
367+
"MEASURE_POINT_LAYER": meas_pt_lyr,
368+
"MEASURE_LINE_LAYER": meas_lin_lyr,
369+
"MEASURE_POLYGON_LAYER": meas_ply_lyr,
370+
"BUILDING_GROUP_LAYER": building_group_lyr,
371+
"SCALES": selected_labels_scales_indices,
372+
"REPLACE_WS_WITH_WN":True,
373+
},
374+
)
375+
376+
elif export_model == config.MODEL_NAME_AG64:
377+
processing.run(
378+
"tww:extractlabels_interlis",
379+
{
380+
"OUTPUT": labels_file_path,
381+
"RESTRICT_TO_SELECTION": limit_to_selection,
382+
"STRUCTURE_VIEW_LAYER": structures_lyr,
383+
"REACH_VIEW_LAYER": reaches_lyr,
384+
"SCALES": selected_labels_scales_indices,
385+
"REPLACE_WS_WITH_WN": True,
386+
},
387+
)
388+
else:
389+
processing.run(
390+
"tww:extractlabels_interlis",
391+
{
392+
"OUTPUT": labels_file_path,
393+
"RESTRICT_TO_SELECTION": limit_to_selection,
394+
"EXPORT_ORIENTATION": export_orientation,
395+
"STRUCTURE_VIEW_LAYER": structures_lyr,
396+
"REACH_VIEW_LAYER": reaches_lyr,
397+
"SCALES": selected_labels_scales_indices,
398+
},
399+
)
363400

364401
def _export_to_intermediate_schema(
365402
self,

plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py

+108-39
Original file line numberDiff line numberDiff line change
@@ -3243,16 +3243,32 @@ def _export_label_positions(self):
32433243
"vw_tww_wastewater_structure": {},
32443244
"catchment_area": {},
32453245
}
3246+
32463247
for row in self.abwasser_session.query(self.model_classes_interlis.haltung):
32473248
tid_for_obj_id["vw_tww_reach"][row.t_ili_tid] = row.t_id
32483249
for row in self.abwasser_session.query(
32493250
self.model_classes_interlis.abwasserbauwerk
32503251
):
32513252
tid_for_obj_id["vw_tww_wastewater_structure"][row.t_ili_tid] = row.t_id
3252-
for row in self.abwasser_session.query(
3253-
self.model_classes_interlis.einzugsgebiet
3254-
):
3255-
tid_for_obj_id["catchment_area"][row.t_ili_tid] = row.t_id
3253+
3254+
if self.model in [config.MODEL_NAME_DSS,config.MODEL_NAME_AG96]:
3255+
for row in self.abwasser_session.query(self.model_classes_interlis.einzugsgebiet):
3256+
tid_for_obj_id["catchment_area"][row.t_ili_tid] = row.t_id
3257+
3258+
if self.is_ag_xx_model:
3259+
tid_for_obj_id.update({
3260+
"building_group": {},
3261+
"measure_line": {},
3262+
"measure_point": {},
3263+
"measure_polygon": {},
3264+
})
3265+
for row in self.abwasser_session.query(self.model_classes_interlis.bautenausserhalbbaugebiet):
3266+
tid_for_obj_id["building_group"][row.t_ili_tid] = row.t_id
3267+
for row in self.abwasser_session.query(self.model_classes_interlis.gepmassnahme):
3268+
tid_for_obj_id["measure_line"][row.t_ili_tid] = row.t_id
3269+
tid_for_obj_id["measure_point"][row.t_ili_tid] = row.t_id
3270+
tid_for_obj_id["measure_polygon"][row.t_ili_tid] = row.t_id
3271+
32563272

32573273
with open(self.labels_file) as labels_file_handle:
32583274
labels = json.load(labels_file_handle)
@@ -3267,7 +3283,7 @@ def _export_label_positions(self):
32673283

32683284
if self.subset_ids and obj_id not in self.subset_ids:
32693285
logger.warning(
3270-
f"Label for {layer_name} `{obj_id}` exists, but that object is not part of the export"
3286+
f"Label for {layer_name} `{obj_id}` exists, but that object is not part of the subset export"
32713287
)
32723288
continue
32733289

@@ -3284,43 +3300,96 @@ def _export_label_positions(self):
32843300
)
32853301
continue
32863302

3287-
if layer_name == "vw_tww_reach":
3288-
ili_label = self.model_classes_interlis.haltung_text(
3289-
**self._textpos_common(
3290-
label, "haltung_text", geojson_crs_def, "RX", self.oid_prefix
3291-
),
3292-
haltungref=t_id,
3293-
)
3294-
3295-
elif layer_name == "vw_tww_wastewater_structure":
3296-
ili_label = self.model_classes_interlis.abwasserbauwerk_text(
3297-
**self._textpos_common(
3298-
label,
3299-
"abwasserbauwerk_text",
3300-
geojson_crs_def,
3301-
"WX",
3302-
self.oid_prefix,
3303-
),
3304-
abwasserbauwerkref=t_id,
3305-
)
3303+
if not self.is_ag_xx_model:
3304+
if layer_name == "vw_tww_reach":
3305+
ili_label = self.model_classes_interlis.haltung_text(
3306+
**self._textpos_common(label, "haltung_text", geojson_crs_def, "RX", self.oid_prefix),
3307+
haltungref=t_id,
3308+
)
33063309

3307-
elif layer_name == "catchment_area":
3308-
ili_label = self.model_classes_interlis.einzugsgebiet_text(
3309-
**self._textpos_common(
3310-
label,
3311-
"einzugsgebiet_text",
3312-
geojson_crs_def,
3313-
"CX",
3314-
self.oid_prefix,
3315-
),
3316-
einzugsgebietref=t_id,
3317-
)
3310+
elif layer_name == "vw_tww_wastewater_structure":
3311+
ili_label = self.model_classes_interlis.abwasserbauwerk_text(
3312+
**self._textpos_common(label, "abwasserbauwerk_text", geojson_crs_def, "WX", self.oid_prefix),
3313+
abwasserbauwerkref=t_id,
3314+
)
33183315

3316+
elif layer_name == "catchment_area":
3317+
ili_label = self.model_classes_interlis.einzugsgebiet_text(
3318+
**self._textpos_common(label, "einzugsgebiet_text", geojson_crs_def, "CX", self.oid_prefix),
3319+
einzugsgebietref=t_id,
3320+
)
3321+
else:
3322+
logger.warning(
3323+
f"Unknown layer `{layer_name}` for label with id '{obj_id}'. Label will be ignored",
3324+
)
3325+
continue
33193326
else:
3320-
logger.warning(
3321-
f"Unknown layer `{layer_name}` for label with id '{obj_id}'. Label will be ignored",
3322-
)
3323-
continue
3327+
if self.model == config.MODEL_NAME_AG64:
3328+
if layer_name == "vw_tww_reach":
3329+
ili_label = self.model_classes_interlis.haltung_text(
3330+
**self._textpos_common(label, "infrastrukturhaltung_text", geojson_crs_def, "RX", self.oid_prefix),
3331+
infrastrukturhaltung=t_id,
3332+
)
3333+
3334+
elif layer_name == "vw_tww_wastewater_structure":
3335+
ili_label = self.model_classes_interlis.abwasserbauwerk_text(
3336+
**self._textpos_common(label, "infrastrukturknoten_text", geojson_crs_def, "WX", self.oid_prefix),
3337+
infrastrukturknotenref=t_id,
3338+
)
3339+
3340+
else:
3341+
logger.warning(
3342+
f"Unknown layer `{layer_name}` for label with id '{obj_id}'. Label will be ignored",
3343+
)
3344+
continue
3345+
else: # AG-96
3346+
if layer_name == "vw_tww_reach":
3347+
ili_label = self.model_classes_interlis.haltung_text(
3348+
**self._textpos_common(label, "gephaltung_text", geojson_crs_def, "RX", self.oid_prefix),
3349+
gephaltungref=t_id,
3350+
)
3351+
3352+
elif layer_name == "vw_tww_wastewater_structure":
3353+
ili_label = self.model_classes_interlis.abwasserbauwerk_text(
3354+
**self._textpos_common(label, "gepknoten_text", geojson_crs_def, "WX", self.oid_prefix),
3355+
gepknotenref=t_id,
3356+
)
3357+
3358+
elif layer_name == "catchment_area":
3359+
ili_label = self.model_classes_interlis.einzugsgebiet_text(
3360+
**self._textpos_common(label, "einzugsgebiet_text", geojson_crs_def, "CX", self.oid_prefix),
3361+
einzugsgebietref=t_id,
3362+
)
3363+
3364+
elif layer_name == "building_group":
3365+
ili_label = self.model_classes_interlis.bautenausserhalbbaugebiet_text(
3366+
**self._textpos_common(label, "bautenausserhalbbaugebiet_text", geojson_crs_def, "BX", self.oid_prefix),
3367+
bautenausserhalbbaugebietref=t_id,
3368+
)
3369+
3370+
elif layer_name == "measure_line":
3371+
ili_label = self.model_classes_interlis.gepmassnahme_text(
3372+
**self._textpos_common(label, "gepmassnahme_text", geojson_crs_def, "MX", self.oid_prefix),
3373+
gepmassnahmeref=t_id,
3374+
)
3375+
3376+
elif layer_name == "measure_point":
3377+
ili_label = self.model_classes_interlis.gepmassnahme_text(
3378+
**self._textpos_common(label, "gepmassnahme_text", geojson_crs_def, "MX", self.oid_prefix),
3379+
gepmassnahmeref=t_id,
3380+
)
3381+
3382+
elif layer_name == "measure_polygon":
3383+
ili_label = self.model_classes_interlis.gepmassnahme_text(
3384+
**self._textpos_common(label, "gepmassnahme_text", geojson_crs_def, "MX", self.oid_prefix),
3385+
gepmassnahmeref=t_id,
3386+
)
3387+
3388+
else:
3389+
logger.warning(
3390+
f"Unknown layer {layer_name} for label with id '{obj_id}'. Label will be ignored",
3391+
)
3392+
continue
33243393

33253394
self.abwasser_session.add(ili_label)
33263395
print(".", end="")

plugin/teksi_wastewater/interlis/interlis_model_mapping/model_interlis_ag64.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ class sia405_textpos(textpos):
4949

5050
ModelInterlisAG64.sia405_textpos = sia405_textpos
5151

52-
class infrastrukturhaltung_text(sia405_textpos):
52+
class haltung_text(sia405_textpos):
5353
__tablename__ = "infrastrukturhaltung_text"
5454
__table_args__ = {"schema":config.ABWASSER_SCHEMA}
5555

56-
ModelInterlisAG64.infrastrukturhaltung_text = infrastrukturhaltung_text
56+
ModelInterlisAG64.haltung_text = haltung_text
5757

58-
class infrastrukturknoten_text(sia405_textpos):
58+
class abwasserbauwerk_text(sia405_textpos):
5959
__tablename__ = "infrastrukturknoten_text"
6060
__table_args__ = {"schema":config.ABWASSER_SCHEMA}
6161

62-
ModelInterlisAG64.infrastrukturknoten_text = infrastrukturknoten_text
62+
ModelInterlisAG64.abwasserbauwerk_text = abwasserbauwerk_text
6363

plugin/teksi_wastewater/interlis/interlis_model_mapping/model_interlis_ag96.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ class sia405_textpos(textpos):
8383

8484
ModelInterlisAG96.sia405_textpos = sia405_textpos
8585

86-
class gephaltung_text(sia405_textpos):
86+
class haltung_text(sia405_textpos):
8787
__tablename__ = "gephaltung_text"
8888
__table_args__ = {"schema":config.ABWASSER_SCHEMA}
8989

90-
ModelInterlisAG96.gephaltung_text = gephaltung_text
90+
ModelInterlisAG96.haltung_text = haltung_text
9191

92-
class gepknoten_text(sia405_textpos):
92+
class abwasserbauwerk_text(sia405_textpos):
9393
__tablename__ = "gepknoten_text"
9494
__table_args__ = {"schema":config.ABWASSER_SCHEMA}
9595

96-
ModelInterlisAG96.gepknoten_text = gepknoten_text
96+
ModelInterlisAG96.abwasserbauwerk_text = abwasserbauwerk_text
9797

9898
class bautenausserhalbbaugebiet_text(sia405_textpos):
9999
__tablename__ = "bautenausserhalbbaugebiet_text"

0 commit comments

Comments
 (0)