[geos-commits] [SCM] GEOS branch 3.13 updated. 5af0c221ed9b61a2e21a7d121716c9e3aa6acd39

git at osgeo.org git at osgeo.org
Tue Jan 7 17:01:51 PST 2025


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, 3.13 has been updated
       via  5af0c221ed9b61a2e21a7d121716c9e3aa6acd39 (commit)
       via  87a824c022ab7644313a7a9b704ab808696a192b (commit)
      from  4f293e17469fe4abf6a5dcf398713c9d914377f2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5af0c221ed9b61a2e21a7d121716c9e3aa6acd39
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Tue Jan 7 17:01:28 2025 -0800

    Update NEWS

diff --git a/NEWS.md b/NEWS.md
index ee8ab3733..ae2ecbb85 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -9,7 +9,8 @@
   - Fix WKTWriter for small precisions and with trim enabled (GH-1199, Mike Taves)
   - Fix BufferOp to increase length of segments removed by heuristic (GH-1200, Martin Davis)
   - Improve RelateNG performance for A/L cases in prepared predicates (GH-1201, Martin Davis)
-
+  - Improve OffsetCurve to handle mitre joins for polygons (Martin Davis)
+  
 ## Changes in 3.13.0
 2024-09-06
 

commit 87a824c022ab7644313a7a9b704ab808696a192b
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Tue Jan 7 15:03:43 2025 -0800

    Improve OffsetCurve to handle mitre joins for polygons

diff --git a/include/geos/operation/buffer/OffsetCurve.h b/include/geos/operation/buffer/OffsetCurve.h
index 403ca98b7..cff62f76b 100644
--- a/include/geos/operation/buffer/OffsetCurve.h
+++ b/include/geos/operation/buffer/OffsetCurve.h
@@ -103,6 +103,9 @@ private:
 
     // Methods
 
+    std::unique_ptr<Geometry> computePolygonCurve(
+        const Polygon& polyGeom, double distance);
+
     std::unique_ptr<Geometry> computeCurve(
         const LineString& lineGeom, double distance);
 
diff --git a/src/operation/buffer/OffsetCurve.cpp b/src/operation/buffer/OffsetCurve.cpp
index f524ccdc1..09fc7d074 100644
--- a/src/operation/buffer/OffsetCurve.cpp
+++ b/src/operation/buffer/OffsetCurve.cpp
@@ -66,15 +66,7 @@ OffsetCurve::getCurve()
 
         if (geom.getGeometryTypeId() == GEOS_POINT) return nullptr;
         if (geom.getGeometryTypeId() == GEOS_POLYGON) {
-            auto boundary = geom.buffer(distance)->getBoundary();
-
-            if (boundary->getGeometryTypeId() == GEOS_LINEARRING) {
-                const LinearRing& ring = static_cast<const LinearRing&>(geom);
-                auto ringCs = ring.getCoordinatesRO();
-                std::unique_ptr<Geometry> ls(geom.getFactory()->createLineString(*ringCs));
-                return ls;
-            }
-            return boundary;
+            return computePolygonCurve(static_cast<const Polygon&>(geom), distance);
         }
         return computeCurve(static_cast<const LineString&>(geom), distance);
     };
@@ -141,6 +133,22 @@ OffsetCurve::rawOffset(const LineString& line, double dist)
     return rawOffsetCurve(line, dist, bufParams);
 }
 
+/* private */
+std::unique_ptr<Geometry>
+OffsetCurve::computePolygonCurve(const Polygon& polyGeom, double dist)
+{
+    auto buffer = BufferOp::bufferOp(&polyGeom, dist, bufferParams);
+    std::unique_ptr<Geometry> boundary = buffer->getBoundary();
+    //-- convert LinearRing to LineString if needed
+    if (boundary->getGeometryTypeId() == GEOS_LINEARRING) {
+        const LinearRing& ring = static_cast<LinearRing&>(*boundary);
+        auto ringCs = ring.getCoordinatesRO();
+        std::unique_ptr<Geometry> ls(polyGeom.getFactory()->createLineString(*ringCs));
+        return ls;
+    }
+    return boundary;
+}
+
 /* private */
 std::unique_ptr<Geometry>
 OffsetCurve::computeCurve(const LineString& lineGeom, double dist)
diff --git a/tests/unit/operation/buffer/OffsetCurveTest.cpp b/tests/unit/operation/buffer/OffsetCurveTest.cpp
index 76b01c4df..e845a51f4 100644
--- a/tests/unit/operation/buffer/OffsetCurveTest.cpp
+++ b/tests/unit/operation/buffer/OffsetCurveTest.cpp
@@ -588,6 +588,23 @@ void object::test<43> ()
     );
 }
 
-
+// testPolygonJoinMitre
+template<>
+template<>
+void object::test<44> ()
+{
+    checkOffsetCurve(
+        "POLYGON ((1 1, 1 7, 5 4, 8 8, 8 1, 1 1))",
+        1, 0, BufferParameters::JOIN_MITRE, 5,
+        "LINESTRING (0 0, 0 9, 4.8 5.4, 9 11, 9 0, 0 0)",
+        0.0001
+    );
+    checkOffsetCurve(
+        "POLYGON ((1 1, 1 7, 5 4, 8 8, 8 1, 1 1))",
+        -1, 0, BufferParameters::JOIN_MITRE, 5,
+        "LINESTRING (2 2, 2 5, 5.2 2.6, 7 5, 7 2, 2 2)",
+        0.0001
+    );
+}
 
 } // namespace tut2

-----------------------------------------------------------------------

Summary of changes:
 NEWS.md                                         |  3 ++-
 include/geos/operation/buffer/OffsetCurve.h     |  3 +++
 src/operation/buffer/OffsetCurve.cpp            | 26 ++++++++++++++++---------
 tests/unit/operation/buffer/OffsetCurveTest.cpp | 19 +++++++++++++++++-
 4 files changed, 40 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list