-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from Deltares/fix/83-removal-of-outside-grass-…
…and-clay-layers-with-outside-reinforcement Fix/83 removal of outside grass and clay layers with outside reinforcement
- Loading branch information
Showing
40 changed files
with
281 additions
and
240 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
docs/reference/koswat_docstrings/calculations/reinforcement_layers.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Reinforcement Layers Wrapper | ||
|
||
::: koswat.calculations.reinforcement_layers.reinforcement_layer_protocol | ||
::: koswat.calculations.reinforcement_layers.reinforcement_base_layer | ||
::: koswat.calculations.reinforcement_layers.reinforcement_coating_layer | ||
::: koswat.calculations.reinforcement_layers.reinforcement_layers_wrapper | ||
|
||
# Reinforcement Layers Wrapper builders | ||
|
||
::: koswat.calculations.reinforcement_layers.outside_slope_reinforcement_layers_wrapper_builder | ||
::: koswat.calculations.reinforcement_layers.standard_reinforcement_layers_wrapper_builder |
2 changes: 0 additions & 2 deletions
2
docs/reference/koswat_docstrings/calculations/reinforcement_layers_wrapper.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from koswat.calculations.reinforcement_layers_wrapper import ReinforcementLayersWrapper | ||
from koswat.calculations.reinforcement_layers.reinforcement_layers_wrapper import ( | ||
ReinforcementLayersWrapper, | ||
) | ||
from koswat.calculations.reinforcement_profile_builder_factory import ( | ||
ReinforcementProfileBuilderFactory, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# Calculations protocols | ||
The following protocols can be found here: | ||
The following protocols __regarding creation of input profiles__ can be found here: | ||
|
||
- `ReinforcementInputProfileProtocol`: An extension of `KoswatInputProfileProtocol`. | ||
- `ReinforcementProfileCalculationProtocol`: Extension of the `BuilderProtocol` to define the required calculations that will return the input data required to create a `ReinforcementInputProfileProtocol`. | ||
- `ReinforcementLayerProtocol`: An extension of the `KoswatLayerProtocol` which contains information regarding the new layer geometry, surface as well as the preivous layer geometry. | ||
|
||
- `ReinforcementProfileProtocol`: An extension of `KoswatProfileProtocol` which uses `ReinforcementLayersWrapper` instead. | ||
- `ReinforcementProfileBuilderProtocol`: Extension of the `BuilderProtocol` to specify the required data needed to generate a `ReinforcementProfileProtocol`. | ||
|
||
How to define "layers" is specified in the `koswat.calculations.reinforcement_layers` module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
11 changes: 8 additions & 3 deletions
11
...e_reinforcement_layers_wrapper_builder.py → ...e_reinforcement_layers_wrapper_builder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
koswat/calculations/reinforcement_layers/reinforcement_base_layer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from __future__ import annotations | ||
|
||
|
||
from shapely.geometry import LineString, Polygon, MultiPolygon | ||
from koswat.calculations.reinforcement_layers.reinforcement_layer_protocol import ( | ||
ReinforcementLayerProtocol, | ||
) | ||
from koswat.core.geometries.calc_library import get_polygon_coordinates | ||
from koswat.dike.layers.base_layer import KoswatBaseLayer | ||
|
||
from koswat.dike.material.koswat_material_type import KoswatMaterialType | ||
|
||
|
||
class ReinforcementBaseLayer(ReinforcementLayerProtocol): | ||
material_type: KoswatMaterialType | ||
outer_geometry: Polygon | ||
material_geometry: Polygon | ||
upper_points: LineString | ||
new_layer_geometry: Polygon | MultiPolygon | ||
new_layer_surface: LineString | ||
old_layer_geometry: Polygon | ||
|
||
def __init__(self) -> None: | ||
self.material_type = None | ||
self.outer_geometry = None | ||
self.material_geometry = None | ||
self.upper_points = None | ||
self.new_layer_geometry = None | ||
|
||
def as_data_dict(self) -> dict: | ||
_geometry = [] | ||
if self.outer_geometry: | ||
_geometry = list(get_polygon_coordinates(self.outer_geometry).coords) | ||
return dict( | ||
material=self.material_type.name, | ||
geometry=_geometry, | ||
) | ||
|
||
@classmethod | ||
def from_koswat_base_layer( | ||
cls, base_layer: KoswatBaseLayer | ||
) -> ReinforcementBaseLayer: | ||
_reinforced_base_layer = cls() | ||
_reinforced_base_layer.__dict__ = base_layer.__dict__ | ||
return _reinforced_base_layer |
71 changes: 71 additions & 0 deletions
71
koswat/calculations/reinforcement_layers/reinforcement_coating_layer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from __future__ import annotations | ||
|
||
|
||
from shapely.geometry import LineString, Polygon, MultiPolygon | ||
from koswat.calculations.reinforcement_layers.reinforcement_layer_protocol import ( | ||
ReinforcementLayerProtocol, | ||
) | ||
|
||
from koswat.core.geometries.calc_library import get_polygon_coordinates | ||
from koswat.dike.layers.coating_layer import KoswatCoatingLayer | ||
from koswat.dike.material.koswat_material_type import KoswatMaterialType | ||
|
||
|
||
class ReinforcementCoatingLayer(ReinforcementLayerProtocol): | ||
material_type: KoswatMaterialType | ||
outer_geometry: Polygon | ||
material_geometry: Polygon | ||
upper_points: LineString | ||
old_layer_geometry: Polygon | ||
new_layer_geometry: Polygon | MultiPolygon | ||
new_layer_surface: LineString | ||
removal_layer_geometry: Polygon | ||
|
||
def __init__(self) -> None: | ||
self.material_type = None | ||
self.outer_geometry = None | ||
self.material_geometry = None | ||
self.upper_points = None | ||
self.new_layer_geometry = None | ||
self.removal_layer_geometry = None | ||
|
||
def as_data_dict(self) -> dict: | ||
_geometry = [] | ||
if self.outer_geometry: | ||
_geometry = list(get_polygon_coordinates(self.outer_geometry).coords) | ||
return dict( | ||
material=self.material_type.name, | ||
depth=self.depth, | ||
geometry=_geometry, | ||
) | ||
|
||
@classmethod | ||
def from_koswat_coating_layer( | ||
cls, coating_layer: KoswatCoatingLayer | ||
) -> ReinforcementCoatingLayer: | ||
_reinforced_coating_layer = cls() | ||
_reinforced_coating_layer.__dict__ = coating_layer.__dict__ | ||
return _reinforced_coating_layer | ||
|
||
@classmethod | ||
def with_same_outer_geometry( | ||
cls, coating_layer: KoswatCoatingLayer | ||
) -> ReinforcementCoatingLayer: | ||
""" | ||
Creates a new reinforcement coating layer which does not differ | ||
in geometry from the provided coating layer. This was found to | ||
be needed in KOSWAT_82. | ||
Args: | ||
coating_layer (KoswatCoatingLayer): Base coating layer. | ||
Returns: | ||
ReinforcementCoatingLayer: Resulting coating layer with "empty" | ||
polygons for added / removed (layer) geometries. | ||
""" | ||
_reinforced_coating_layer = cls.from_koswat_coating_layer(coating_layer) | ||
_reinforced_coating_layer.old_layer_geometry = coating_layer.outer_geometry | ||
_reinforced_coating_layer.removal_layer_geometry = Polygon() | ||
_reinforced_coating_layer.new_layer_geometry = Polygon() | ||
_reinforced_coating_layer.new_layer_surface = LineString() | ||
return _reinforced_coating_layer |
10 changes: 10 additions & 0 deletions
10
koswat/calculations/reinforcement_layers/reinforcement_layer_protocol.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Protocol, runtime_checkable | ||
from koswat.dike.layers import KoswatLayerProtocol | ||
from shapely.geometry import LineString, Polygon, MultiPolygon | ||
|
||
|
||
@runtime_checkable | ||
class ReinforcementLayerProtocol(KoswatLayerProtocol, Protocol): | ||
new_layer_geometry: Polygon | MultiPolygon | ||
new_layer_surface: LineString | ||
old_layer_geometry: Polygon |
55 changes: 55 additions & 0 deletions
55
koswat/calculations/reinforcement_layers/reinforcement_layers_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from koswat.calculations.reinforcement_layers.reinforcement_layer_protocol import ( | ||
ReinforcementLayerProtocol, | ||
) | ||
from koswat.calculations.reinforcement_layers.reinforcement_base_layer import ( | ||
ReinforcementBaseLayer, | ||
) | ||
from koswat.calculations.reinforcement_layers.reinforcement_coating_layer import ( | ||
ReinforcementCoatingLayer, | ||
) | ||
from koswat.dike.layers.layers_wrapper import KoswatLayersWrapperProtocol | ||
from koswat.dike.material.koswat_material_type import KoswatMaterialType | ||
|
||
|
||
class ReinforcementLayersWrapper(KoswatLayersWrapperProtocol): | ||
base_layer: ReinforcementBaseLayer | ||
coating_layers: list[ReinforcementCoatingLayer] | ||
|
||
def __init__(self) -> None: | ||
self.base_layer = None | ||
self.coating_layers = [] | ||
|
||
def as_data_dict(self) -> dict: | ||
return dict( | ||
base_layer=self.base_layer.as_data_dict(), | ||
coating_layers=[c_l.as_data_dict() for c_l in self.coating_layers], | ||
) | ||
|
||
def get_layer(self, material_type: KoswatMaterialType) -> ReinforcementCoatingLayer: | ||
_found_layer = next( | ||
( | ||
_layer | ||
for _layer in self.coating_layers | ||
if _layer.material_type == material_type | ||
), | ||
None, | ||
) | ||
if not _found_layer: | ||
raise ValueError( | ||
"Material {} not present in the layers.".format(material_type.name) | ||
) | ||
return _found_layer | ||
|
||
@property | ||
def layers(self) -> list[ReinforcementLayerProtocol]: | ||
""" | ||
All the stored layers being the `KoswatBaseLayer` the latest one in the collection. | ||
Returns: | ||
List[KoswatLayerProtocol]: Ordered list of `KoswatLayerProtocol`. | ||
""" | ||
_layers = [] | ||
_layers.extend(self.coating_layers) | ||
if self.base_layer: | ||
_layers.append(self.base_layer) | ||
return _layers |
2 changes: 1 addition & 1 deletion
2
...d_reinforcement_layers_wrapper_builder.py → ...d_reinforcement_layers_wrapper_builder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.