diff --git a/CHANGES.rst b/CHANGES.rst index 46f1e016..138344eb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,12 +1,19 @@ Changelog of threedigrid-builder ================================ + 1.23.0 (unreleased) ------------------- - Remove transformations of geometries from schematisation +1.22.1 (2025-01-16) +------------------- + +- Use pipe.geom, weir.geom and orifice.weir to build gridadmin + + 1.22.0 (2025-01-08) ------------------- diff --git a/threedigrid_builder/__init__.py b/threedigrid_builder/__init__.py index b5e8d1ff..6b3f23fd 100644 --- a/threedigrid_builder/__init__.py +++ b/threedigrid_builder/__init__.py @@ -2,5 +2,5 @@ from .exceptions import * # NOQA # fmt: off -__version__ = '1.22.1.dev0' +__version__ = '1.22.2.dev0' # fmt: on diff --git a/threedigrid_builder/grid/structures.py b/threedigrid_builder/grid/structures.py index fb695d64..b08222a0 100644 --- a/threedigrid_builder/grid/structures.py +++ b/threedigrid_builder/grid/structures.py @@ -75,6 +75,7 @@ class WeirOrifice: # NL: stuw / doorlaat zoom_category: int display_name: str sewerage: int + the_geom: shapely.Geometry class WeirOrifices(Array[WeirOrifice]): @@ -114,6 +115,7 @@ def get_lines(self, connection_nodes, line_id_counter, connection_node_offset=0) return Lines( id=itertools.islice(line_id_counter, len(self)), line=line, + line_geometries=self.the_geom, content_type=self.content_type, content_pk=self.id, kcu=self.crest_type, # implicitly converts CalculationType -> LineType diff --git a/threedigrid_builder/interface/db.py b/threedigrid_builder/interface/db.py index 343434b1..e6df7a7f 100644 --- a/threedigrid_builder/interface/db.py +++ b/threedigrid_builder/interface/db.py @@ -688,6 +688,7 @@ def get_orifices(self) -> Orifices: models.Orifice.discharge_coefficient_positive, models.Orifice.display_name, models.Orifice.sewerage, + models.Orifice.geom.label("the_geom"), case( { models.Orifice.friction_value.isnot(None) @@ -718,6 +719,7 @@ def get_orifices(self) -> Orifices: ) # map friction_type 4 to friction_type 2 to match crosssectionlocation enum arr["friction_type"][arr["friction_type"] == 4] = 2 + arr["the_geom"] = self.reproject(arr["the_geom"]) return Orifices(**{name: arr[name] for name in arr.dtype.names}) @@ -738,6 +740,7 @@ def get_pipes(self) -> Pipes: models.Pipe.hydraulic_conductivity_out, models.Pipe.hydraulic_conductivity_in, models.Pipe.material_id.label("material"), + models.Pipe.geom.label("the_geom"), case( { models.Pipe.friction_value.isnot(None) @@ -767,6 +770,7 @@ def get_pipes(self) -> Pipes: arr["friction_type"][arr["friction_type"] == 4] = 2 arr["hydraulic_conductivity_out"] /= DAY_IN_SECONDS arr["hydraulic_conductivity_in"] /= DAY_IN_SECONDS + arr["the_geom"] = self.reproject(arr["the_geom"]) # transform to a Pipes object return Pipes(**{name: arr[name] for name in arr.dtype.names}) @@ -812,6 +816,7 @@ def get_weirs(self) -> Weirs: models.Weir.discharge_coefficient_positive, models.Weir.display_name, models.Weir.sewerage, + models.Weir.geom.label("the_geom"), case( { models.Weir.friction_value.isnot(None) @@ -838,6 +843,7 @@ def get_weirs(self) -> Weirs: ) # map friction_type 4 to friction_type 2 to match crosssectionlocation enum arr["friction_type"][arr["friction_type"] == 4] = 2 + arr["the_geom"] = self.reproject(arr["the_geom"]) return Weirs(**{name: arr[name] for name in arr.dtype.names}) diff --git a/threedigrid_builder/tests/test_db.py b/threedigrid_builder/tests/test_db.py index 26698ea0..66b17b4b 100644 --- a/threedigrid_builder/tests/test_db.py +++ b/threedigrid_builder/tests/test_db.py @@ -234,6 +234,11 @@ def test_get_pipes(db): assert pipes.friction_type[28] == FrictionType.MANNING assert pipes.friction_value[36] == 0.0145 assert pipes.display_name[33] == "71518_71517" + assert_geometries_equal( + pipes.the_geom[0], + shapely.from_wkt("LINESTRING (110267.3 517868.8, 110264.3 517863.5)"), + tolerance=1, + ) def test_get_settings(db): @@ -378,6 +383,11 @@ def test_get_weirs(db): assert weirs.friction_value[36] == 0.03 assert weirs.display_name[33] == "KST-JL-76" assert weirs.sewerage[0] == 1 + assert_geometries_equal( + weirs.the_geom[0], + shapely.from_wkt("LINESTRING (110278.3 517669.1, 110276.3 517669.8)"), + tolerance=1, + ) def test_get_dem_average(db):