From b8069479ba26c3c702f6542561aeb7e65f03ee8c Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Mon, 14 Apr 2025 09:52:56 +0200 Subject: [PATCH] reverse point order of polygon to counter-clockwise --- pycsw/core/util.py | 2 +- tests/unittests/test_metadata.py | 2 +- tests/unittests/test_util.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pycsw/core/util.py b/pycsw/core/util.py index 80c2b56fa..4eae12bff 100644 --- a/pycsw/core/util.py +++ b/pycsw/core/util.py @@ -239,7 +239,7 @@ def bbox2wktpolygon(bbox): bbox = wktenvelope2bbox(bbox) minx, miny, maxx, maxy = [f"{float(coord):.{precision}f}" for coord in bbox.split(",")] wktGeometry = 'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' \ - % (minx, miny, minx, maxy, maxx, maxy, maxx, miny, minx, miny) + % (minx, miny, maxx, miny, maxx, maxy, minx, maxy, minx, miny) return wktGeometry diff --git a/tests/unittests/test_metadata.py b/tests/unittests/test_metadata.py index 20a25a8eb..a49a05e9b 100644 --- a/tests/unittests/test_metadata.py +++ b/tests/unittests/test_metadata.py @@ -41,7 +41,7 @@ "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))", "POLYGON ((2 2, 2 3, 3 3, 3 2, 2 2))", ], - "POLYGON((0.00 0.00, 0.00 3.00, 3.00 3.00, 3.00 0.00, 0.00 0.00))" + "POLYGON((0.00 0.00, 3.00 0.00, 3.00 3.00, 0.00 3.00, 0.00 0.00))" ), ]) def test_bbox_from_polygons(bboxes, expected): diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 42b2fb421..a9319d146 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -144,13 +144,13 @@ def test_wkt2geom(wkt, bounds, expected): @pytest.mark.parametrize("bbox, expected", [ ( "0.0, 10.0, 30.0, 15.0", - "POLYGON((0.00 10.00, 0.00 15.00, 30.00 15.00, " - "30.00 10.00, 0.00 10.00))" + "POLYGON((0.00 10.00, 30.00 10.00, 30.00 15.00, " + "0.00 15.00, 0.00 10.00))" ), ( "-10.0, 10.0, 30.0, 15.0", - "POLYGON((-10.00 10.00, -10.00 15.00, 30.00 15.00, " - "30.00 10.00, -10.00 10.00))" + "POLYGON((-10.00 10.00, 30.00 10.00, 30.00 15.00, " + "-10.00 15.00, -10.00 10.00))" ) ]) def test_bbox2wktpolygon(bbox, expected):