Skip to content

Commit

Permalink
Merge branch 'master' into margriet_399_support_implicit_crs
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm authored Jan 16, 2025
2 parents d7433ec + ebb8e16 commit c026033
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion threedigrid_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from .exceptions import * # NOQA

# fmt: off
__version__ = '1.22.1.dev0'
__version__ = '1.22.2.dev0'
# fmt: on
2 changes: 2 additions & 0 deletions threedigrid_builder/grid/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions threedigrid_builder/interface/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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})

Expand All @@ -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)
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand All @@ -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})

Expand Down
10 changes: 10 additions & 0 deletions threedigrid_builder/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c026033

Please sign in to comment.