Skip to content

Commit

Permalink
Merge pull request #202 from teksi/labelsOIDSuffix
Browse files Browse the repository at this point in the history
Fix lenght of labels OID suffix and hardcoded shortcut_en
  • Loading branch information
ponceta authored Apr 12, 2024
2 parents b2525ff + 2f370f1 commit c49a468
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)

Expand Down

0 comments on commit c49a468

Please sign in to comment.