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

git at osgeo.org git at osgeo.org
Sat Nov 28 16:32:00 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  e26560f7000baf5715ac3905f9395a5a5f2fa2c4 (commit)
      from  ad0122541f85886cf9eb9dd65d8246e0144f7ffa (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 e26560f7000baf5715ac3905f9395a5a5f2fa2c4
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Sat Nov 28 16:31:50 2020 -0800

    Clean-ups that hopefully will make python downstream happier

diff --git a/include/geos/index/strtree/SimpleSTRnode.h b/include/geos/index/strtree/SimpleSTRnode.h
index 1782189..9d24e25 100644
--- a/include/geos/index/strtree/SimpleSTRnode.h
+++ b/include/geos/index/strtree/SimpleSTRnode.h
@@ -114,7 +114,7 @@ public:
 
     bool isLeaf() const override
     {
-        return childNodes.size() == 0;
+        return level == 0;
     }
 
     bool isComposite() const
diff --git a/include/geos/index/strtree/SimpleSTRtree.h b/include/geos/index/strtree/SimpleSTRtree.h
index c01bd5e..5cd41b1 100644
--- a/include/geos/index/strtree/SimpleSTRtree.h
+++ b/include/geos/index/strtree/SimpleSTRtree.h
@@ -71,7 +71,6 @@ private:
     std::deque<SimpleSTRnode> nodesQue;
     std::vector<SimpleSTRnode*> nodes;
     std::size_t nodeCapacity;
-    SimpleSTRnode* root;
     bool built;
 
     /*
@@ -111,6 +110,9 @@ private:
 
 public:
 
+    /* Member */
+    SimpleSTRnode* root;
+
     /**
      * Constructs an STRtree with the given maximum number of child nodes that
      * a node may have
@@ -126,7 +128,10 @@ public:
     }
 
     std::size_t getNumLeafNodes() const {
-        return root->getNumLeafNodes();
+        if (!root)
+            return 0;
+        else
+            return root->getNumLeafNodes();
     }
 
 
diff --git a/src/index/strtree/SimpleSTRnode.cpp b/src/index/strtree/SimpleSTRnode.cpp
index 36299f7..ae09494 100644
--- a/src/index/strtree/SimpleSTRnode.cpp
+++ b/src/index/strtree/SimpleSTRnode.cpp
@@ -31,7 +31,7 @@ SimpleSTRnode::toString(std::ostream& os, int indentLevel) const
     for (int i = 0; i < indentLevel; i++) {
         os << "  ";
     }
-    os << bounds << std::endl;
+    os << bounds << " [" << level << "]" << std::endl;
     for (auto* node: childNodes) {
         node->toString(os, indentLevel+1);
     }
diff --git a/src/index/strtree/SimpleSTRtree.cpp b/src/index/strtree/SimpleSTRtree.cpp
index 9d60adc..ca63b2d 100644
--- a/src/index/strtree/SimpleSTRtree.cpp
+++ b/src/index/strtree/SimpleSTRtree.cpp
@@ -181,7 +181,7 @@ SimpleSTRtree::build()
         root = nullptr;
     }
     else {
-        std::vector<SimpleSTRnode*> nodeTree = createHigherLevels(nodes, -1);
+        std::vector<SimpleSTRnode*> nodeTree = createHigherLevels(nodes, 0);
         assert(nodeTree.size()==1);
         root = nodeTree[0];
     }
@@ -309,20 +309,18 @@ SimpleSTRtree::remove(const geom::Envelope* searchBounds,
     return found;
 }
 
-
 /*public static*/
 std::ostream&
-operator<<(std::ostream& os, SimpleSTRtree& tree)
+operator<<(std::ostream& os, const SimpleSTRtree& tree)
 {
 
     os << "nodeCapacity: " << tree.getNodeCapacity() << std::endl;
     os << "nodes.size(): " << tree.getNumLeafNodes() << std::endl;
     os << "built: " << tree.getBuilt() << std::endl;
 
-
-    if (tree.getRoot()) {
+    if (tree.root) {
         os << "tree: " << std::endl;
-        tree.getRoot()->toString(os, 1);
+        tree.root->toString(os, 1);
     }
     else {
         os << "tree: empty" << std::endl;
diff --git a/tests/unit/index/strtree/SimpleSTRtreeTest.cpp b/tests/unit/index/strtree/SimpleSTRtreeTest.cpp
index 5c7d239..67735d6 100644
--- a/tests/unit/index/strtree/SimpleSTRtreeTest.cpp
+++ b/tests/unit/index/strtree/SimpleSTRtreeTest.cpp
@@ -8,6 +8,7 @@
 #include <geos/index/ItemVisitor.h>
 #include <geos/io/WKTReader.h>
 
+#include <iostream>
 
 using namespace geos;
 
@@ -42,14 +43,14 @@ void object::test<1>
         }
     }
 
-    // std::cout << t << std::endl;
-
     geom::Envelope qe(-0.5, 1.5, -0.5, 1.5);
     std::vector<void*> matches;
     t.query(&qe, matches);
     // std::cout << matches.size() << std::endl;
     ensure(matches.size() == 4);
 
+    // std::cout << t << std::endl;
+
     class SimpleTestVisitor: public index::ItemVisitor {
         public:
             std::size_t count;
@@ -140,6 +141,8 @@ void object::test<3>
     ensure(leaf_before = 4u);
     ensure(all_before  = 5u);
 
+    // std::cout << t << std::endl;
+
     t.remove(geoms[3]->getEnvelopeInternal(), geoms[3].get());
 
     std::size_t leaf_after = t.getRoot()->getNumLeafNodes();

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

Summary of changes:
 include/geos/index/strtree/SimpleSTRnode.h     |  2 +-
 include/geos/index/strtree/SimpleSTRtree.h     |  9 +++++++--
 src/index/strtree/SimpleSTRnode.cpp            |  2 +-
 src/index/strtree/SimpleSTRtree.cpp            | 10 ++++------
 tests/unit/index/strtree/SimpleSTRtreeTest.cpp |  7 +++++--
 5 files changed, 18 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list