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

git at osgeo.org git at osgeo.org
Wed Sep 18 15:23:16 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  a1710cdc950658e3dcc9cb4d52c352052587ef72 (commit)
      from  f1c5dcecc2daf47b76941919a60e3c06ace8f5a3 (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 a1710cdc950658e3dcc9cb4d52c352052587ef72
Author: Daniel Baston <dbaston at gmail.com>
Date:   Wed Sep 18 18:23:03 2019 -0400

    Simplify FuzzyPointLocator

diff --git a/src/operation/overlay/validate/FuzzyPointLocator.cpp b/src/operation/overlay/validate/FuzzyPointLocator.cpp
index e9cc604..ac2ffdd 100644
--- a/src/operation/overlay/validate/FuzzyPointLocator.cpp
+++ b/src/operation/overlay/validate/FuzzyPointLocator.cpp
@@ -37,7 +37,6 @@
 #define USE_ELEVATION_MATRIX 1
 #define USE_INPUT_AVGZ 0
 
-using namespace std;
 using namespace geos::geom;
 using namespace geos::algorithm;
 
@@ -62,30 +61,17 @@ FuzzyPointLocator::extractLineWork(const geom::Geometry& geom)
 {
     ::geos::ignore_unused_variable_warning(geom);
 
-    vector<Geometry*>* lineGeoms = new vector<Geometry*>();
-    try { // geoms array will leak if an exception is thrown
+    std::vector<std::unique_ptr<Geometry>> lineGeoms;
 
-        for(size_t i = 0, n = g.getNumGeometries(); i < n; ++i) {
-            const Geometry* gComp = g.getGeometryN(i);
-            Geometry* lineGeom = nullptr;
+    for(size_t i = 0, n = g.getNumGeometries(); i < n; ++i) {
+        const Geometry* gComp = g.getGeometryN(i);
 
-            // only get linework for polygonal components
-            if(gComp->getDimension() == 2) {
-                lineGeom = gComp->getBoundary().release();
-                lineGeoms->push_back(lineGeom);
-            }
+        // only get linework for polygonal components
+        if(gComp->getDimension() == Dimension::A) {
+            lineGeoms.push_back(gComp->getBoundary());
         }
-        return std::unique_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
-
-    }
-    catch(...) {    // avoid leaks
-        for(size_t i = 0, n = lineGeoms->size(); i < n; ++i) {
-            delete(*lineGeoms)[i];
-        }
-        delete lineGeoms;
-        throw;
     }
-
+    return g.getFactory()->buildGeometry(std::move(lineGeoms));
 }
 
 /*private*/
@@ -94,39 +80,25 @@ FuzzyPointLocator::getLineWork(const geom::Geometry& geom)
 {
     ::geos::ignore_unused_variable_warning(geom);
 
-    vector<Geometry*>* lineGeoms = new vector<Geometry*>();
-    try { // geoms array will leak if an exception is thrown
-
-        for(size_t i = 0, n = g.getNumGeometries(); i < n; ++i) {
-            const Geometry* gComp = g.getGeometryN(i);
-            Geometry* lineGeom;
-            if(gComp->getDimension() == 2) {
-                lineGeom = gComp->getBoundary().release();
-            }
-            else {
-                lineGeom = gComp->clone().release();
-            }
-            lineGeoms->push_back(lineGeom);
-        }
-        return std::unique_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
-
-    }
-    catch(...) {    // avoid leaks
-        for(size_t i = 0, n = lineGeoms->size(); i < n; ++i) {
+    std::vector<std::unique_ptr<Geometry>> lineGeoms;
+    for(size_t i = 0, n = g.getNumGeometries(); i < n; ++i) {
+        const Geometry* gComp = g.getGeometryN(i);
 
-            delete(*lineGeoms)[i];
+        if(gComp->getDimension() == 2) {
+            lineGeoms.push_back(gComp->getBoundary());
+        } else {
+            lineGeoms.push_back(gComp->clone());
         }
-        delete lineGeoms;
-        throw;
     }
 
+    return g.getFactory()->buildGeometry(std::move(lineGeoms));
 }
 
 /* public */
 Location
 FuzzyPointLocator::getLocation(const Coordinate& pt)
 {
-    unique_ptr<Geometry> point(g.getFactory()->createPoint(pt));
+    std::unique_ptr<Geometry> point(g.getFactory()->createPoint(pt));
 
     double dist = linework->distance(point.get());
 

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

Summary of changes:
 .../overlay/validate/FuzzyPointLocator.cpp         | 60 ++++++----------------
 1 file changed, 16 insertions(+), 44 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list