From 311afd3bd92f06dd31eef82a07f4d015333ee93c Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Tue, 3 Mar 2026 16:10:12 +0100 Subject: [PATCH 1/8] GRIDEDIT-2223 Added getting of netlink contour polygons --- meshkernel/meshkernel.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/meshkernel/meshkernel.py b/meshkernel/meshkernel.py index acfc8e62..90405f93 100644 --- a/meshkernel/meshkernel.py +++ b/meshkernel/meshkernel.py @@ -1757,6 +1757,39 @@ def mesh2d_casulli_refinement_on_polygon( byref(c_polygon), ) + def mesh2d_compute_netlink_contour_polygons(self) -> GeometryList: + """Gets the netlink contour polygons from the MeshKernel. + + Returns: + Mesh2d: A copy of the netlink contour polygons. + """ + + c_geometry_list_dimension = c_int() + + self._execute_function( + self.lib.mkernel_mesh2d_compute_netlink_contour_polygons_dimension, + self._meshkernelid, + byref(c_geometry_list_dimension), + ) + + n_coordinates = c_geometry_list_dimension.value + x_coordinates = np.empty(n_coordinates, dtype=np.double) + y_coordinates = np.empty(n_coordinates, dtype=np.double) + + edge_polygons = GeometryList( + x_coordinates=x_coordinates, y_coordinates=y_coordinates + ) + + c_edge_polygons = CGeometryList.from_geometrylist(edge_polygons) + + self._execute_function( + self.lib.mkernel_mesh2d_compute_netlink_contour_polygons, + self._meshkernelid, + byref(c_edge_polygons), + ) + + return edge_polygons + def mesh2d_compute_orthogonalization( self, project_to_land_boundary_option: ProjectToLandBoundaryOption, From b0f6f6fe052e7ac97baa2c1c4884e4ee53be5987 Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Tue, 3 Mar 2026 16:30:36 +0100 Subject: [PATCH 2/8] GRIDEDIT-2223 Added unit test for netlink contours --- tests/test_mesh2d_basics.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index ea48b41d..f3b79c96 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -2568,3 +2568,15 @@ def test_mesh2d_casulli_refinement_based_on_depths(): # new mesh has more nodes and edges than the starting mesh, it has been refined assert len(mesh2d_not_refined.node_x) == 121 assert len(mesh2d_refined.node_x) == 253 + + +def test_mesh2d_netlink_contour_polygons(): + """Test test_mesh2d_netlink_contour_polygons """ + + mk = meshkernel_with_mesh2d(2, 2) + + netlink_polygons = mk.mesh2d_compute_netlink_contour_polygons() + + assert len(netlink_polygons.num_coordinates) == 48 + assert len(netlink_polygons.x_coordinates) == 48 + assert len(netlink_polygons.y_coordinates) == 48 From 365133f882ecc9f122fe0edb4d319be278ff8d7d Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Wed, 4 Mar 2026 10:39:01 +0100 Subject: [PATCH 3/8] GRIDEDIT-1699 Fixed a formatting warning --- tests/test_mesh2d_basics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index f3b79c96..421768ca 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -2571,7 +2571,7 @@ def test_mesh2d_casulli_refinement_based_on_depths(): def test_mesh2d_netlink_contour_polygons(): - """Test test_mesh2d_netlink_contour_polygons """ + """Test test_mesh2d_netlink_contour_polygons""" mk = meshkernel_with_mesh2d(2, 2) From fa873bac9efb5c6e8e848d9bb7ec8167d7450da9 Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Wed, 4 Mar 2026 10:43:35 +0100 Subject: [PATCH 4/8] GRIDEDIT-2223 Added missing parameter --- tests/test_mesh2d_basics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index 421768ca..d64ff01e 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -2570,7 +2570,7 @@ def test_mesh2d_casulli_refinement_based_on_depths(): assert len(mesh2d_refined.node_x) == 253 -def test_mesh2d_netlink_contour_polygons(): +def test_mesh2d_netlink_contour_polygons(meshkernel_with_mesh2d: MeshKernel): """Test test_mesh2d_netlink_contour_polygons""" mk = meshkernel_with_mesh2d(2, 2) From d3d4129cf4cd79310b3e36c31dc349238bd148f4 Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Wed, 4 Mar 2026 11:20:55 +0100 Subject: [PATCH 5/8] GRIDEDIT-2223 Removed incorrect check --- tests/test_mesh2d_basics.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index d64ff01e..fc7515eb 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -2577,6 +2577,5 @@ def test_mesh2d_netlink_contour_polygons(meshkernel_with_mesh2d: MeshKernel): netlink_polygons = mk.mesh2d_compute_netlink_contour_polygons() - assert len(netlink_polygons.num_coordinates) == 48 assert len(netlink_polygons.x_coordinates) == 48 assert len(netlink_polygons.y_coordinates) == 48 From d9f85edb48dc8e0fae8090b17440b4f554684156 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 9 Mar 2026 15:24:00 +0100 Subject: [PATCH 6/8] GRIDEDIT-2223 Added location id when getting property --- meshkernel/meshkernel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meshkernel/meshkernel.py b/meshkernel/meshkernel.py index 90405f93..1217592b 100644 --- a/meshkernel/meshkernel.py +++ b/meshkernel/meshkernel.py @@ -1868,6 +1868,7 @@ def mesh2d_get_property( self.lib.mkernel_mesh2d_get_property_dimension, self._meshkernelid, c_int(property), + c_int(mesh2d_location.value), byref(c_geometry_list_dimension), ) n_coordinates = c_geometry_list_dimension.value From 39224b77a88a261f36da2de89ef2d302ae875f42 Mon Sep 17 00:00:00 2001 From: veenstrajelmer <60435591+veenstrajelmer@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:18:46 +0200 Subject: [PATCH 7/8] kick off tests --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aa7e7666..7d7fa516 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.isort] profile = "black" -multi_line_output = 3 +multi_line_output = 3 From 2573642e461bd1b8b00fc8e182d5b950cd8fc393 Mon Sep 17 00:00:00 2001 From: veenstrajelmer <60435591+veenstrajelmer@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:18:52 +0200 Subject: [PATCH 8/8] kick off tests --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7d7fa516..aa7e7666 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.isort] profile = "black" -multi_line_output = 3 +multi_line_output = 3