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

git at osgeo.org git at osgeo.org
Fri Nov 8 06:16:07 PST 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  c96422005f1bd2bff98e74f201e4a3a4328c85f2 (commit)
       via  698c97f490a1786994b1606f37a606818757582f (commit)
       via  7be06d1dac9113b06d48edfad6752446d00546eb (commit)
       via  962089ed871d3032e164fea4b42adc2d49e84143 (commit)
      from  18be6c2dae08059ed901252d48ceefa1283b0c59 (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 c96422005f1bd2bff98e74f201e4a3a4328c85f2
Author: Daniel Baston <dbaston at gmail.com>
Date:   Tue Nov 5 21:51:10 2019 -0500

    Speed up sort in SortedPackedIntervalRTree construction

diff --git a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
index 1025eca..bb5604e 100644
--- a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
+++ b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
@@ -51,6 +51,15 @@ SortedPackedIntervalRTree::buildTree()
 {
     branches.reserve(leaves.size() - 1);
 
+    // sort the leaf nodes
+    std::sort(leaves.begin(), leaves.end(),
+            [](const IntervalRTreeLeafNode & n1, const IntervalRTreeLeafNode & n2) {
+                double mid1 = n1.getMin() + n1.getMax();
+                double mid2 = n2.getMin() + n2.getMax();
+
+                return mid1 > mid2;
+            });
+
     // now group nodes into blocks of two and build tree up recursively
     std::vector<const IntervalRTreeNode*> src{leaves.size()};
     std::vector<const IntervalRTreeNode*> dest;
@@ -58,9 +67,6 @@ SortedPackedIntervalRTree::buildTree()
         return &n;
     });
 
-    // sort the leaf nodes
-    std::sort(src.begin(), src.end(), IntervalRTreeNode::compare);
-
     while(true) {
         buildLevel(src, dest);
 

commit 698c97f490a1786994b1606f37a606818757582f
Author: Daniel Baston <dbaston at gmail.com>
Date:   Tue Nov 5 21:28:50 2019 -0500

    Presize segment vector in IntervalIndexedGeometry

diff --git a/src/algorithm/locate/IndexedPointInAreaLocator.cpp b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
index 96899a4..bbe6890 100644
--- a/src/algorithm/locate/IndexedPointInAreaLocator.cpp
+++ b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
@@ -52,6 +52,13 @@ IndexedPointInAreaLocator::IntervalIndexedGeometry::init(const geom::Geometry& g
     geom::LineString::ConstVect lines;
     geom::util::LinearComponentExtracter::getLines(g, lines);
 
+    // pre-compute size of segment vector
+    size_t nsegs = 0;
+    for(const geom::LineString* line : lines) {
+        nsegs += line->getCoordinatesRO()->size() - 1;
+    }
+    segments.reserve(nsegs);
+
     for(const geom::LineString* line : lines) {
         addLine(line->getCoordinatesRO());
     }

commit 7be06d1dac9113b06d48edfad6752446d00546eb
Author: Daniel Baston <dbaston at gmail.com>
Date:   Tue Nov 5 21:19:15 2019 -0500

    Inline SortedPackedIntervalRTree::insert

diff --git a/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h b/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
index e12442a..0bab17e 100644
--- a/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
+++ b/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
@@ -19,6 +19,7 @@
 #include <geos/index/intervalrtree/IntervalRTreeNode.h>
 #include <geos/index/intervalrtree/IntervalRTreeBranchNode.h>
 #include <geos/index/intervalrtree/IntervalRTreeLeafNode.h>
+#include <geos/util/UnsupportedOperationException.h>
 
 // forward declarations
 namespace geos {
@@ -84,7 +85,13 @@ public:
      *
      * @throw IllegalStateException if the index has already been queried
      */
-    void insert(double min, double max, void* item);
+    void insert(double min, double max, void* item) {
+        if(root != nullptr) {
+            throw util::UnsupportedOperationException("Index cannot be added to once it has been queried");
+        }
+
+        leaves.emplace_back(min, max, item);
+    }
 
     /**
      * Search for intervals in the index which intersect the given closed interval
diff --git a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
index 83b4829..1025eca 100644
--- a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
+++ b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
@@ -17,7 +17,6 @@
 #include <geos/index/intervalrtree/IntervalRTreeLeafNode.h>
 #include <geos/index/intervalrtree/IntervalRTreeBranchNode.h>
 #include <geos/index/ItemVisitor.h>
-#include <geos/util/UnsupportedOperationException.h>
 
 #include <algorithm>
 
@@ -103,15 +102,6 @@ SortedPackedIntervalRTree::buildLevel(IntervalRTreeNode::ConstVect& src, Interva
 // public:
 //
 
-void
-SortedPackedIntervalRTree::insert(double min, double max, void* item)
-{
-    if(root != nullptr) {
-        throw util::UnsupportedOperationException("Index cannot be added to once it has been queried");
-    }
-
-    leaves.emplace_back(min, max, item);
-}
 
 void
 SortedPackedIntervalRTree::query(double min, double max, index::ItemVisitor* visitor)

commit 962089ed871d3032e164fea4b42adc2d49e84143
Author: Daniel Baston <dbaston at gmail.com>
Date:   Tue Nov 5 21:18:05 2019 -0500

    Initialize interval tree with known number of segments

diff --git a/src/algorithm/locate/IndexedPointInAreaLocator.cpp b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
index 181ecf5..96899a4 100644
--- a/src/algorithm/locate/IndexedPointInAreaLocator.cpp
+++ b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
@@ -56,6 +56,8 @@ IndexedPointInAreaLocator::IntervalIndexedGeometry::init(const geom::Geometry& g
         addLine(line->getCoordinatesRO());
     }
 
+    index = index::intervalrtree::SortedPackedIntervalRTree(segments.size());
+
     for(geom::LineSegment& seg : segments) {
         index.insert(
             std::min(seg.p0.y, seg.p1.y),

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

Summary of changes:
 .../intervalrtree/SortedPackedIntervalRTree.h      |  9 ++++++++-
 src/algorithm/locate/IndexedPointInAreaLocator.cpp |  9 +++++++++
 .../intervalrtree/SortedPackedIntervalRTree.cpp    | 22 +++++++++-------------
 3 files changed, 26 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list