[geos-commits] [SCM] GEOS branch 3.12 updated. 010e3f977adadd3390d5e4aaa02720848a4fd98b

git at osgeo.org git at osgeo.org
Tue Jan 7 17:03: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.12 has been updated
       via  010e3f977adadd3390d5e4aaa02720848a4fd98b (commit)
       via  dc944e738afec9abaa8252f95f3c9222157eea63 (commit)
      from  42fe6b778e80621d035ae75d6b15a1734d96c768 (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 010e3f977adadd3390d5e4aaa02720848a4fd98b
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Tue Jan 7 17:03:30 2025 -0800

    Update NEWS

diff --git a/NEWS.md b/NEWS.md
index f35c7710e..5bcb22618 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,6 +15,7 @@
   - Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
   - Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis)
   - Fix BufferOp to increase length of segments removed by heuristic (GH-1200, Martin Davis)
+  - Improve OffsetCurve to handle mitre joins for polygons (Martin Davis)
 
 ## Changes in 3.12.2
 2024-06-05

commit dc944e738afec9abaa8252f95f3c9222157eea63
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 d68c0545f..87aa461f8 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                                         |  1 +
 include/geos/operation/buffer/OffsetCurve.h     |  3 +++
 src/operation/buffer/OffsetCurve.cpp            | 26 ++++++++++++++++---------
 tests/unit/operation/buffer/OffsetCurveTest.cpp | 19 +++++++++++++++++-
 4 files changed, 39 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list