diff --git a/koswat/core/geometries/calc_library.py b/koswat/core/geometries/calc_library.py index 9a38676e..5bcd5553 100644 --- a/koswat/core/geometries/calc_library.py +++ b/koswat/core/geometries/calc_library.py @@ -1,3 +1,4 @@ +import logging from typing import List, Union from shapely import affinity, geometry, ops @@ -14,6 +15,11 @@ def order_geometry_points(dike_polygon: geometry.Polygon) -> geometry.Polygon: Returns: geometry.Polygon: Normalized polygon. """ + if isinstance(dike_polygon.boundary, geometry.MultiLineString): + logging.warning( + "Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this." + ) + return dike_polygon _x, _y = tuple(map(list, dike_polygon.boundary.coords.xy)) # remove last point as it's repeated. _x.pop(-1) diff --git a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py index dc705c8d..1ea4e950 100644 --- a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py +++ b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py @@ -62,7 +62,7 @@ def dict_to_csv_row(key, placeholders: int) -> List[str]: ] _cost_rows.insert(0, dict_to_csv_row(_cost_per_km_key, _required_placeholders)) _csv_fom.headers = _headers - _csv_fom.entries = _location_rows + _cost_rows + _csv_fom.entries = _cost_rows + _location_rows return _csv_fom def _get_locations_matrix( diff --git a/tests/cost_report/io/csv/test_summary_matrix_csv_exporter.py b/tests/cost_report/io/csv/test_summary_matrix_csv_exporter.py index 15dd12c5..befe0410 100644 --- a/tests/cost_report/io/csv/test_summary_matrix_csv_exporter.py +++ b/tests/cost_report/io/csv/test_summary_matrix_csv_exporter.py @@ -37,9 +37,6 @@ def test_summary_matrix_csv_exporter_export(self, request: pytest.FixtureRequest assert _export_path.exists() _read_text = _export_path.read_text() _expected_text = """;;Profile type;Kistdam;Kwelscherm;Grondmaatregel profiel;Stabiliteitswand -A;0.24;0.42;0;1;1;1 -A;2.4;0.42;0;0;1;1 -A;0.24;2.4;0;0;0;1 ;;Cost per km (€);0.0;8144.4;16288.8;24433.2 ;;Reused grass volume (volume / surface):;nan;nan;nan;nan ;;Reused grass volume (cost):;nan;nan;nan;nan @@ -60,5 +57,8 @@ def test_summary_matrix_csv_exporter_export(self, request: pytest.FixtureRequest ;;New core layer surface (volume / surface):;nan;nan;nan;nan ;;New core layer surface (cost):;nan;nan;nan;nan ;;New maaiveld surface (volume / surface):;nan;nan;nan;nan -;;New maaiveld surface (cost):;nan;nan;nan;nan""" +;;New maaiveld surface (cost):;nan;nan;nan;nan +A;0.24;0.42;0;1;1;1 +A;2.4;0.42;0;0;1;1 +A;0.24;2.4;0;0;0;1""" assert _expected_text == _read_text