From 2f370f1da4a8a0f41c342a58fa63c63ff1abae1d Mon Sep 17 00:00:00 2001 From: Damiano Lombardi Date: Fri, 12 Apr 2024 08:41:07 +0200 Subject: [PATCH] Fix lenght of labels OID suffix and hardcoded shortcut_en Add a warning when exporting more than 999999 labels --- .../interlis_exporter_to_intermediate_schema.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py b/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py index e1e76843c..bdc0546aa 100644 --- a/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py +++ b/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py @@ -2510,16 +2510,21 @@ def structure_part_common(self, row, type_name): "instandstellung": self.get_vl(row.renovation_demand__REL), } - def _textpos_common(self, row, t_type, geojson_crs_def): + def _textpos_common(self, row, t_type, geojson_crs_def, shortcut_en): """ Returns common attributes for textpos """ t_id = self.tid_maker.next_tid() + if t_id > 999999: + logger.warning( + f"Exporting more than 999999 labels will generate invalid OIDs. Currently exporting {t_id} label of type '{t_type}'." + ) + return { "t_id": t_id, "t_type": t_type, - "t_ili_tid": f"ch080txtPR0000{t_id}", + "t_ili_tid": f"ch080txt{shortcut_en}{t_id:06d}", # --- TextPos --- "textpos": ST_GeomFromGeoJSON( json.dumps( @@ -2587,19 +2592,19 @@ def _export_label_positions(self): if layer_name == "vw_tww_reach": ili_label = self.model_classes_interlis.haltung_text( - **self._textpos_common(label, "haltung_text", geojson_crs_def), + **self._textpos_common(label, "haltung_text", geojson_crs_def, "RX"), haltungref=t_id, ) elif layer_name == "vw_tww_wastewater_structure": ili_label = self.model_classes_interlis.abwasserbauwerk_text( - **self._textpos_common(label, "abwasserbauwerk_text", geojson_crs_def), + **self._textpos_common(label, "abwasserbauwerk_text", geojson_crs_def, "WX"), abwasserbauwerkref=t_id, ) elif layer_name == "catchment_area": ili_label = self.model_classes_interlis.einzugsgebiet_text( - **self._textpos_common(label, "einzugsgebiet_text", geojson_crs_def), + **self._textpos_common(label, "einzugsgebiet_text", geojson_crs_def, "CX"), einzugsgebietref=t_id, )