From 0faabcf796b47d63e050e9b107c39d5fc108a27b Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Apr 2026 09:37:21 +0200 Subject: [PATCH 1/6] Add orientation test for ring with collapsed elements References GH-1425 --- .../unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp index 6c0dae2304..0078a4059a 100644 --- a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp +++ b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp @@ -248,6 +248,15 @@ void object::test<16> } +// See https://trac.osgeo.org/postgis/ticket/6065 +template<> +template<> +void object::test<17> +() +{ + const std::string wkt("POLYGON((17.422075702665087 69.11091383235977,17.42207545158684 69.11091383590066,17.42207570266477 69.11091383235974,17.422075702665087 69.11091383235977))"); + checkCCW(false, wkt); +} } // namespace tut From b927eee7feac8c2c8beafd7d94fa315d051ffd3d Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Apr 2026 17:44:48 +0200 Subject: [PATCH 2/6] Fix the WKT of the collapsed topology ring --- tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp index 0078a4059a..c878e809c8 100644 --- a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp +++ b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp @@ -254,7 +254,7 @@ template<> void object::test<17> () { - const std::string wkt("POLYGON((17.422075702665087 69.11091383235977,17.42207545158684 69.11091383590066,17.42207570266477 69.11091383235974,17.422075702665087 69.11091383235977))"); + const std::string wkt("POLYGON((17.42207545158684 69.11091383590066,17.422075702665087 69.11091383235977,17.579930758184094 69.12294910230447,17.622976580401446 69.12848944101118,17.579930758184094 69.12294910230447,17.422075702665087 69.11091383235977,17.42207570266477 69.11091383235974,17.42207545158684 69.11091383590066,17.42207545158653 69.11091383590062,17.42207545158684 69.11091383590066))"); checkCCW(false, wkt); } From 388bfaef9d8370cb3b2ca6b64c25ac0c8ce6140f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Apr 2026 18:51:15 +0200 Subject: [PATCH 3/6] Test also in WKB form --- tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp index c878e809c8..c27b7f3fda 100644 --- a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp +++ b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp @@ -256,6 +256,9 @@ void object::test<17> { const std::string wkt("POLYGON((17.42207545158684 69.11091383590066,17.422075702665087 69.11091383235977,17.579930758184094 69.12294910230447,17.622976580401446 69.12848944101118,17.579930758184094 69.12294910230447,17.422075702665087 69.11091383235977,17.42207570266477 69.11091383235974,17.42207545158684 69.11091383590066,17.42207545158653 69.11091383590062,17.42207545158684 69.11091383590066))"); checkCCW(false, wkt); + + std::istringstream wkb("0103000000010000000A000000890205230D6C31408177583619475140FD613B270D6C314031AA5436194751405D58985776943140195EE965DE47514085FFA6647B9F31408FC1C62B394851405D58985776943140195EE965DE475140FD613B270D6C314031AA543619475140A4613B270D6C31402FAA543619475140890205230D6C31408177583619475140320205230D6C31407E77583619475140890205230D6C31408177583619475140"); + checkHexOrientationCCW(false, wkb); } From 69b9768086511da04dd05af9b30842b18582cb38 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Apr 2026 19:28:53 +0200 Subject: [PATCH 4/6] Add new failing test --- .../algorithm/CGAlgorithms/OrientationIsCCWTest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp index c27b7f3fda..a8691b2598 100644 --- a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp +++ b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp @@ -261,6 +261,16 @@ void object::test<17> checkHexOrientationCCW(false, wkb); } +// See https://trac.osgeo.org/postgis/ticket/6065 +template<> +template<> +void object::test<18> +() +{ + std::istringstream wkb("0103000000010000000A0000007A6873CA73782440DE38B01D9CEE4D40438AD46B73782440FEAF5D499CEE4D40588FC2F528782440106D5B2FB5EE4D4089058AA63E7824401D9FCAB6B0EE4D4084CBFA5C7A7824405CC705259CEE4D4089058AA63E7824401D9FCAB6B0EE4D4040A8CCBF35782440B80E7F8CB2EE4D40588FC2F528782440106D5B2FB5EE4D40438AD46B73782440FEAF5D499CEE4D407A6873CA73782440DE38B01D9CEE4D40"); + checkHexOrientationCCW(false, wkb); +} + } // namespace tut From 65f40100f2f5515333caa275b40b9fead721522f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 16 Apr 2026 10:39:25 +0200 Subject: [PATCH 5/6] Simplify test for ticket GH-1425 --- .../algorithm/CGAlgorithms/OrientationIsCCWTest.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp index a8691b2598..8f8c5ff514 100644 --- a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp +++ b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp @@ -254,21 +254,19 @@ template<> void object::test<17> () { - const std::string wkt("POLYGON((17.42207545158684 69.11091383590066,17.422075702665087 69.11091383235977,17.579930758184094 69.12294910230447,17.622976580401446 69.12848944101118,17.579930758184094 69.12294910230447,17.422075702665087 69.11091383235977,17.42207570266477 69.11091383235974,17.42207545158684 69.11091383590066,17.42207545158653 69.11091383590062,17.42207545158684 69.11091383590066))"); + const std::string wkt("POLYGON ((2 1, 2 0, 0 2, 0 0,0 2, 2 1))"); checkCCW(false, wkt); - - std::istringstream wkb("0103000000010000000A000000890205230D6C31408177583619475140FD613B270D6C314031AA5436194751405D58985776943140195EE965DE47514085FFA6647B9F31408FC1C62B394851405D58985776943140195EE965DE475140FD613B270D6C314031AA543619475140A4613B270D6C31402FAA543619475140890205230D6C31408177583619475140320205230D6C31407E77583619475140890205230D6C31408177583619475140"); - checkHexOrientationCCW(false, wkb); } + // See https://trac.osgeo.org/postgis/ticket/6065 template<> template<> void object::test<18> () { - std::istringstream wkb("0103000000010000000A0000007A6873CA73782440DE38B01D9CEE4D40438AD46B73782440FEAF5D499CEE4D40588FC2F528782440106D5B2FB5EE4D4089058AA63E7824401D9FCAB6B0EE4D4084CBFA5C7A7824405CC705259CEE4D4089058AA63E7824401D9FCAB6B0EE4D4040A8CCBF35782440B80E7F8CB2EE4D40588FC2F528782440106D5B2FB5EE4D40438AD46B73782440FEAF5D499CEE4D407A6873CA73782440DE38B01D9CEE4D40"); - checkHexOrientationCCW(false, wkb); + const std::string wkt("POLYGON ((0 0,0 2, 2 1, 2 0, 0 2, 0 0))"); + checkCCW(false, wkt); } From 031b0c11450f72c11925b22725ce0ac843958a14 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 16 Apr 2026 10:52:10 +0200 Subject: [PATCH 6/6] Another case involving no danglings --- .../algorithm/CGAlgorithms/OrientationIsCCWTest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp index 8f8c5ff514..ec8eaba5c6 100644 --- a/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp +++ b/tests/unit/algorithm/CGAlgorithms/OrientationIsCCWTest.cpp @@ -268,6 +268,16 @@ void object::test<18> const std::string wkt("POLYGON ((0 0,0 2, 2 1, 2 0, 0 2, 0 0))"); checkCCW(false, wkt); } +// +// See https://trac.osgeo.org/postgis/ticket/6065 +template<> +template<> +void object::test<19> +() +{ + const std::string wkt("POLYGON ((-1 0,0 2, 2 1, 2 0, 0 2, 0 0, -1 0))"); + checkCCW(false, wkt); +} } // namespace tut