Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 31, 2024
1 parent 52bfd49 commit 86f305d
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ def get_pk(self, relation):
return relation.t_ili_tid

# new 30.10.2024
def geometry3D_convert(self, geometryattribute, levelattribute, obj_id, classname_attributename):
def geometry3D_convert(
self, geometryattribute, levelattribute, obj_id, classname_attributename
):
"""
Checks if levelattribute or geometryattribut is Null or empty and calls ST_Force3D accordingly as else 3D geometry will be set to NULL if levelattribute is missing - see https://github.com/teksi/wastewater/issues/475#issuecomment-2441032526 and https://trac.osgeo.org/postgis/ticket/5804#comment:1
"""
Expand All @@ -434,12 +436,12 @@ def geometry3D_convert(self, geometryattribute, levelattribute, obj_id, classnam
f"No {classname_attributename} and geometry (Lage) provided for object {obj_id} - situation3d_geometry cannot be defined! Object cannot be displayed in TEKSI TWW!"
)
return None

else:
# geometry attribute but no levelattribute provided
geom = self.session_tww.scalar(ST_Force3D(geometryattribute))
logger.info(
f'No {classname_attributename} provided for object {obj_id}- situation3d_geometry with no z-value created: {geom}.'
f"No {classname_attributename} provided for object {obj_id}- situation3d_geometry with no z-value created: {geom}."
)
return geom
else:
Expand All @@ -453,7 +455,9 @@ def geometry3D_convert(self, geometryattribute, levelattribute, obj_id, classnam
# situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.kote)),
# Levelattribute and geometry attribute provided - 3D coordinate can be created as expected
geom = self.session_tww.scalar(ST_Force3D(geometryattribute, levelattribute))
logger.debug(f" debug: situation3d_geometry created with geometry (x,y) and level (z): {geom}.")
logger.debug(
f" debug: situation3d_geometry created with geometry (x,y) and level (z): {geom}."
)
return geom

def create_or_update(self, cls, **kwargs):
Expand Down Expand Up @@ -1973,7 +1977,9 @@ def _import_haltungspunkt(self):
remark=row.bemerkung,
# 30.10.2024 patching
# situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.kote)),
situation3d_geometry=self.geometry3D_convert(row.lage, row.kote, row.t_ili_tid, 'reach_point.cote (Haltungpunkt.Kote)'),
situation3d_geometry=self.geometry3D_convert(
row.lage, row.kote, row.t_ili_tid, "reach_point.cote (Haltungpunkt.Kote)"
),
)
self.session_tww.add(reach_point)
print(".", end="")
Expand Down Expand Up @@ -2008,7 +2014,12 @@ def _import_abwasserknoten(self):
# situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.sohlenkote)),
# 30.10.2024 patching
# situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.sohlenkote)),
situation3d_geometry=self.geometry3D_convert(row.lage, row.sohlenkote, row.t_ili_tid, 'wastewater_node.bottom_level (Abwasserknoten.Sohlenkote)'),
situation3d_geometry=self.geometry3D_convert(
row.lage,
row.sohlenkote,
row.t_ili_tid,
"wastewater_node.bottom_level (Abwasserknoten.Sohlenkote)",
),
)
self.session_tww.add(wastewater_node)
print(".", end="")
Expand Down Expand Up @@ -2119,10 +2130,12 @@ def _import_deckel(self):
self.model_classes_tww_od.cover_positional_accuracy, row.lagegenauigkeit
),
# patching 31.10.2024
#situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.kote)),
# situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.kote)),
# 30.10.2024 patching
# situation3d_geometry=self.session_tww.scalar(ST_Force3D(row.lage, row.kote)),
situation3d_geometry=self.geometry3D_convert(row.lage, row.kote, row.t_ili_tid, 'cover.level (Deckel.Deckelkote)'),
situation3d_geometry=self.geometry3D_convert(
row.lage, row.kote, row.t_ili_tid, "cover.level (Deckel.Deckelkote)"
),
sludge_bucket=self.get_vl_code(
self.model_classes_tww_od.cover_sludge_bucket, row.schlammeimer
),
Expand Down

0 comments on commit 86f305d

Please sign in to comment.