[geos-commits] [SCM] GEOS branch master updated. 91e9df7650fd56409e383331d4a199996b4944d0

git at osgeo.org git at osgeo.org
Thu Nov 12 17:54:45 PST 2020


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  91e9df7650fd56409e383331d4a199996b4944d0 (commit)
       via  86bd0f0903c9effca511776955541750e08829bb (commit)
       via  cd2431685a813be1aca85fa1e70e1fb59393c16e (commit)
       via  15db8e952edc5b9b75cc556cc7fcd141950dc7ad (commit)
      from  03e8090d9a2019402dbb0d3c2931eac75d11030e (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 91e9df7650fd56409e383331d4a199996b4944d0
Merge: 03e8090 86bd0f0
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Nov 12 20:54:23 2020 -0500

    Merge branch 'segment-node-list'


commit 86bd0f0903c9effca511776955541750e08829bb
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Nov 12 19:56:24 2020 -0500

    Add const to SegmentNodeList methods

diff --git a/include/geos/noding/SegmentNodeList.h b/include/geos/noding/SegmentNodeList.h
index 83b0812..80c46c6 100644
--- a/include/geos/noding/SegmentNodeList.h
+++ b/include/geos/noding/SegmentNodeList.h
@@ -67,7 +67,7 @@ private:
      *
      * @param splitEdges the split edges for this edge (in order)
      */
-    void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
+    void checkSplitEdgesCorrectness(const std::vector<SegmentString*>& splitEdges) const;
 
     /**
      * Create a new "split edge" with the section of points between
@@ -77,7 +77,7 @@ private:
      *
      * ownership of return value is transferred
      */
-    std::unique_ptr<SegmentString> createSplitEdge(SegmentNode* ei0, SegmentNode* ei1);
+    std::unique_ptr<SegmentString> createSplitEdge(const SegmentNode* ei0, const SegmentNode* ei1) const;
 
     /**
     * Extracts the points for a split edge running between two nodes.
@@ -89,7 +89,7 @@ private:
     * @param ei1 the end node of the split edge
     * @return the points for the split edge
     */
-    void createSplitEdgePts(SegmentNode* ei0, SegmentNode* ei1, std::vector<geom::Coordinate>& pts);
+    void createSplitEdgePts(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<geom::Coordinate>& pts) const;
 
     /**
      * Adds nodes for any collapsed edge pairs.
@@ -106,7 +106,7 @@ private:
      * which are pre-existing in the vertex list.
      */
     void findCollapsesFromExistingVertices(
-        std::vector<std::size_t>& collapsedVertexIndexes);
+        std::vector<std::size_t>& collapsedVertexIndexes) const;
 
     /**
      * Adds nodes for any collapsed edge pairs caused by inserted nodes
@@ -116,12 +116,12 @@ private:
      * the vertex must be added as a node as well.
      */
     void findCollapsesFromInsertedNodes(
-        std::vector<std::size_t>& collapsedVertexIndexes);
+        std::vector<std::size_t>& collapsedVertexIndexes) const;
 
-    bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
-                           size_t& collapsedVertexIndex);
+    bool findCollapseIndex(const SegmentNode& ei0, const SegmentNode& ei1,
+                           size_t& collapsedVertexIndex) const;
 
-    void addEdgeCoordinates(SegmentNode* ei0, SegmentNode* ei1, std::vector<geom::Coordinate>& coordList);
+    void addEdgeCoordinates(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<geom::Coordinate>& coordList) const;
 
     // Declare type as noncopyable
     SegmentNodeList(const SegmentNodeList& other) = delete;
diff --git a/src/noding/SegmentNodeList.cpp b/src/noding/SegmentNodeList.cpp
index c3a7c74..12d8ad4 100644
--- a/src/noding/SegmentNodeList.cpp
+++ b/src/noding/SegmentNodeList.cpp
@@ -104,7 +104,7 @@ SegmentNodeList::addCollapsedNodes()
 /* private */
 void
 SegmentNodeList::findCollapsesFromExistingVertices(
-    std::vector<size_t>& collapsedVertexIndexes)
+    std::vector<size_t>& collapsedVertexIndexes) const
 {
     if(edge.size() < 2) {
         return;    // or we'll never exit the loop below
@@ -123,7 +123,7 @@ SegmentNodeList::findCollapsesFromExistingVertices(
 /* private */
 void
 SegmentNodeList::findCollapsesFromInsertedNodes(
-    std::vector<size_t>& collapsedVertexIndexes)
+    std::vector<size_t>& collapsedVertexIndexes) const
 {
     size_t collapsedVertexIndex;
 
@@ -146,8 +146,8 @@ SegmentNodeList::findCollapsesFromInsertedNodes(
 
 /* private */
 bool
-SegmentNodeList::findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
-                                   size_t& collapsedVertexIndex)
+SegmentNodeList::findCollapseIndex(const SegmentNode& ei0, const SegmentNode& ei1,
+                                   size_t& collapsedVertexIndex) const
 {
     assert(ei1.segmentIndex >= ei0.segmentIndex);
     // only looking for equal nodes
@@ -215,7 +215,7 @@ SegmentNodeList::addSplitEdges(std::vector<SegmentString*>& edgeList)
 
 /*private*/
 void
-SegmentNodeList::checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges)
+SegmentNodeList::checkSplitEdgesCorrectness(const std::vector<SegmentString*>& splitEdges) const
 {
     const CoordinateSequence* edgePts = edge.getCoordinates();
     assert(edgePts);
@@ -244,7 +244,7 @@ SegmentNodeList::checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEd
 
 /*private*/
 std::unique_ptr<SegmentString>
-SegmentNodeList::createSplitEdge(SegmentNode* ei0, SegmentNode* ei1)
+SegmentNodeList::createSplitEdge(const SegmentNode* ei0, const SegmentNode* ei1) const
 {
     std::vector<Coordinate> pts;
     createSplitEdgePts(ei0, ei1, pts);
@@ -254,7 +254,7 @@ SegmentNodeList::createSplitEdge(SegmentNode* ei0, SegmentNode* ei1)
 
 /*private*/
 void
-SegmentNodeList::createSplitEdgePts(SegmentNode* ei0, SegmentNode* ei1, std::vector<Coordinate>& pts)
+SegmentNodeList::createSplitEdgePts(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<Coordinate>& pts) const
 {
     //int npts = ei1->segmentIndex - (ei0->segmentIndex + 2);
     bool twoPoints = (ei1->segmentIndex == ei0->segmentIndex);
@@ -311,8 +311,7 @@ SegmentNodeList::getSplitCoordinates()
 
 /*private*/
 void
-SegmentNodeList::addEdgeCoordinates(SegmentNode* ei0, SegmentNode* ei1, std::vector<Coordinate>& coordList)
-{
+SegmentNodeList::addEdgeCoordinates(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<Coordinate>& coordList) const {
     std::vector<Coordinate> pts;
     createSplitEdgePts(ei0, ei1, pts);
     // Append pts to coordList

commit cd2431685a813be1aca85fa1e70e1fb59393c16e
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Nov 12 19:49:59 2020 -0500

    Return SegmentString by unique_ptr

diff --git a/include/geos/noding/SegmentNodeList.h b/include/geos/noding/SegmentNodeList.h
index 4b93e6c..83b0812 100644
--- a/include/geos/noding/SegmentNodeList.h
+++ b/include/geos/noding/SegmentNodeList.h
@@ -77,7 +77,7 @@ private:
      *
      * ownership of return value is transferred
      */
-    SegmentString* createSplitEdge(SegmentNode* ei0, SegmentNode* ei1);
+    std::unique_ptr<SegmentString> createSplitEdge(SegmentNode* ei0, SegmentNode* ei1);
 
     /**
     * Extracts the points for a split edge running between two nodes.
diff --git a/src/noding/SegmentNodeList.cpp b/src/noding/SegmentNodeList.cpp
index 1a3a727..c3a7c74 100644
--- a/src/noding/SegmentNodeList.cpp
+++ b/src/noding/SegmentNodeList.cpp
@@ -22,6 +22,7 @@
 #include <algorithm>
 
 #include <geos/profiler.h>
+#include <geos/util.h>
 #include <geos/util/GEOSException.h>
 #include <geos/noding/SegmentNodeList.h>
 #include <geos/noding/NodedSegmentString.h>
@@ -199,8 +200,8 @@ SegmentNodeList::addSplitEdges(std::vector<SegmentString*>& edgeList)
             continue;
         }
 
-        SegmentString* newEdge = createSplitEdge(eiPrev, ei);
-        edgeList.push_back(newEdge);
+        std::unique_ptr<SegmentString> newEdge = createSplitEdge(eiPrev, ei);
+        edgeList.push_back(newEdge.release());
 #if GEOS_DEBUG
         testingSplitEdges.push_back(newEdge);
 #endif
@@ -242,12 +243,12 @@ SegmentNodeList::checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEd
 }
 
 /*private*/
-SegmentString*
+std::unique_ptr<SegmentString>
 SegmentNodeList::createSplitEdge(SegmentNode* ei0, SegmentNode* ei1)
 {
     std::vector<Coordinate> pts;
     createSplitEdgePts(ei0, ei1, pts);
-    return new NodedSegmentString(new CoordinateArraySequence(std::move(pts)), edge.getData());
+    return detail::make_unique<NodedSegmentString>(new CoordinateArraySequence(std::move(pts)), edge.getData());
 }
 
 

commit 15db8e952edc5b9b75cc556cc7fcd141950dc7ad
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Nov 12 19:44:45 2020 -0500

    Remove heap alloc in SegmentNodeList

diff --git a/src/noding/SegmentNodeList.cpp b/src/noding/SegmentNodeList.cpp
index 9ebb740..1a3a727 100644
--- a/src/noding/SegmentNodeList.cpp
+++ b/src/noding/SegmentNodeList.cpp
@@ -245,9 +245,9 @@ SegmentNodeList::checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEd
 SegmentString*
 SegmentNodeList::createSplitEdge(SegmentNode* ei0, SegmentNode* ei1)
 {
-    std::unique_ptr<std::vector<Coordinate>> pts(new std::vector<Coordinate>);
-    createSplitEdgePts(ei0, ei1, *pts);
-    return new NodedSegmentString(new CoordinateArraySequence(pts.release()), edge.getData());
+    std::vector<Coordinate> pts;
+    createSplitEdgePts(ei0, ei1, pts);
+    return new NodedSegmentString(new CoordinateArraySequence(std::move(pts)), edge.getData());
 }
 
 

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

Summary of changes:
 include/geos/noding/SegmentNodeList.h | 16 ++++++++--------
 src/noding/SegmentNodeList.cpp        | 30 +++++++++++++++---------------
 2 files changed, 23 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list