[geos-commits] [SCM] GEOS branch master updated. ea5689eb7b308c0b743d86e6c98882bb6d8f1450

git at osgeo.org git at osgeo.org
Sun Sep 15 12:47:59 PDT 2019


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, master has been updated
       via  ea5689eb7b308c0b743d86e6c98882bb6d8f1450 (commit)
      from  23a581b295756c030ba5de3f8168663aff20759f (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 ea5689eb7b308c0b743d86e6c98882bb6d8f1450
Author: Daniel Baston <dbaston at gmail.com>
Date:   Sun Sep 15 15:47:48 2019 -0400

    Manage some prepared geometry members with unique_ptr

diff --git a/include/geos/geom/prep/PreparedLineString.h b/include/geos/geom/prep/PreparedLineString.h
index bf5789e..7d70d2f 100644
--- a/include/geos/geom/prep/PreparedLineString.h
+++ b/include/geos/geom/prep/PreparedLineString.h
@@ -22,12 +22,9 @@
 
 #include <geos/geom/prep/BasicPreparedGeometry.h> // for inheritance
 #include <geos/noding/SegmentString.h>
+#include <geos/noding/FastSegmentSetIntersectionFinder.h>
 
-namespace geos {
-namespace noding {
-class FastSegmentSetIntersectionFinder;
-}
-}
+#include <memory>
 
 namespace geos {
 namespace geom { // geos::geom
@@ -42,7 +39,7 @@ namespace prep { // geos::geom::prep
  */
 class PreparedLineString : public BasicPreparedGeometry {
 private:
-    noding::FastSegmentSetIntersectionFinder* segIntFinder;
+    std::unique_ptr<noding::FastSegmentSetIntersectionFinder> segIntFinder;
     mutable noding::SegmentString::ConstVect segStrings;
 
 protected:
diff --git a/include/geos/geom/prep/PreparedPolygon.h b/include/geos/geom/prep/PreparedPolygon.h
index 295397d..04b8ca7 100644
--- a/include/geos/geom/prep/PreparedPolygon.h
+++ b/include/geos/geom/prep/PreparedPolygon.h
@@ -23,6 +23,8 @@
 #include <geos/geom/prep/BasicPreparedGeometry.h> // for inheritance
 #include <geos/noding/SegmentString.h>
 
+#include <memory>
+
 namespace geos {
 namespace noding {
 class FastSegmentSetIntersectionFinder;
@@ -48,8 +50,8 @@ namespace prep { // geos::geom::prep
 class PreparedPolygon : public BasicPreparedGeometry {
 private:
     bool isRectangle;
-    mutable noding::FastSegmentSetIntersectionFinder* segIntFinder;
-    mutable algorithm::locate::PointOnGeometryLocator* ptOnGeomLoc;
+    mutable std::unique_ptr<noding::FastSegmentSetIntersectionFinder> segIntFinder;
+    mutable std::unique_ptr<algorithm::locate::PointOnGeometryLocator> ptOnGeomLoc;
     mutable noding::SegmentString::ConstVect segStrings;
 
 protected:
diff --git a/include/geos/noding/FastSegmentSetIntersectionFinder.h b/include/geos/noding/FastSegmentSetIntersectionFinder.h
index 91bbb42..ee1e23f 100644
--- a/include/geos/noding/FastSegmentSetIntersectionFinder.h
+++ b/include/geos/noding/FastSegmentSetIntersectionFinder.h
@@ -20,6 +20,7 @@
 #ifndef GEOS_NODING_FASTSEGMENTSETINTERSECTIONFINDER_H
 #define GEOS_NODING_FASTSEGMENTSETINTERSECTIONFINDER_H
 
+#include <geos/algorithm/LineIntersector.h>
 #include <geos/noding/SegmentString.h>
 #include <geos/noding/MCIndexSegmentSetMutualIntersector.h>
 
diff --git a/src/geom/prep/PreparedLineString.cpp b/src/geom/prep/PreparedLineString.cpp
index 90cd075..09ca4ea 100644
--- a/src/geom/prep/PreparedLineString.cpp
+++ b/src/geom/prep/PreparedLineString.cpp
@@ -32,7 +32,6 @@ namespace prep { // geos.geom.prep
 
 PreparedLineString::~PreparedLineString()
 {
-    delete segIntFinder;
     for(noding::SegmentString::ConstVect::size_type i = 0,
             ni = segStrings.size(); i < ni; ++i) {
         delete segStrings[ i ];
@@ -44,10 +43,10 @@ PreparedLineString::getIntersectionFinder()
 {
     if(! segIntFinder) {
         noding::SegmentStringUtil::extractSegmentStrings(&getGeometry(), segStrings);
-        segIntFinder = new noding::FastSegmentSetIntersectionFinder(&segStrings);
+        segIntFinder.reset(new noding::FastSegmentSetIntersectionFinder(&segStrings));
     }
 
-    return segIntFinder;
+    return segIntFinder.get();
 }
 
 bool
diff --git a/src/geom/prep/PreparedPolygon.cpp b/src/geom/prep/PreparedPolygon.cpp
index 69d672a..130562d 100644
--- a/src/geom/prep/PreparedPolygon.cpp
+++ b/src/geom/prep/PreparedPolygon.cpp
@@ -46,9 +46,6 @@ PreparedPolygon::PreparedPolygon(const geom::Geometry* geom)
 
 PreparedPolygon::~PreparedPolygon()
 {
-    delete segIntFinder;
-    delete ptOnGeomLoc;
-
     for(std::size_t i = 0, ni = segStrings.size(); i < ni; i++) {
         delete segStrings[ i ];
     }
@@ -61,9 +58,9 @@ getIntersectionFinder() const
 {
     if(! segIntFinder) {
         noding::SegmentStringUtil::extractSegmentStrings(&getGeometry(), segStrings);
-        segIntFinder = new noding::FastSegmentSetIntersectionFinder(&segStrings);
+        segIntFinder.reset(new noding::FastSegmentSetIntersectionFinder(&segStrings));
     }
-    return segIntFinder;
+    return segIntFinder.get();
 }
 
 algorithm::locate::PointOnGeometryLocator*
@@ -71,10 +68,10 @@ PreparedPolygon::
 getPointLocator() const
 {
     if(! ptOnGeomLoc) {
-        ptOnGeomLoc = new algorithm::locate::IndexedPointInAreaLocator(getGeometry());
+        ptOnGeomLoc.reset(new algorithm::locate::IndexedPointInAreaLocator(getGeometry()));
     }
 
-    return ptOnGeomLoc;
+    return ptOnGeomLoc.get();
 }
 
 bool

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

Summary of changes:
 include/geos/geom/prep/PreparedLineString.h            |  9 +++------
 include/geos/geom/prep/PreparedPolygon.h               |  6 ++++--
 include/geos/noding/FastSegmentSetIntersectionFinder.h |  1 +
 src/geom/prep/PreparedLineString.cpp                   |  5 ++---
 src/geom/prep/PreparedPolygon.cpp                      | 11 ++++-------
 5 files changed, 14 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list