[geos-commits] [SCM] GEOS branch master updated. 4b2f28c250cbb734605e13de3b3ceba289a438c9

git at osgeo.org git at osgeo.org
Tue Aug 20 15:52:39 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  4b2f28c250cbb734605e13de3b3ceba289a438c9 (commit)
      from  4c70abae2c76eacd6d30d0c503066556a5067b42 (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 4b2f28c250cbb734605e13de3b3ceba289a438c9
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 20 15:52:11 2019 -0700

    Port JTS PR 462
    https://github.com/locationtech/jts/pull/462/

diff --git a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
index f66b9a4..10541a1 100644
--- a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
+++ b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
@@ -54,6 +54,7 @@ private:
     class IntervalIndexedGeometry {
     private:
         index::intervalrtree::SortedPackedIntervalRTree index;
+        bool isEmpty;
 
         void init(const geom::Geometry& g);
         void addLine(const geom::CoordinateSequence* pts);
diff --git a/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h b/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
index 2aab524..e12442a 100644
--- a/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
+++ b/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
@@ -52,6 +52,13 @@ class SortedPackedIntervalRTree {
 private:
     std::vector<IntervalRTreeLeafNode> leaves;
     std::vector<IntervalRTreeBranchNode> branches;
+
+    /**
+    * If root is null that indicates
+    * that the tree has not yet been built,
+    * OR nothing has been added to the tree.
+    * In both cases, the tree is still open for insertions.
+    */
     const IntervalRTreeNode* root = nullptr;
     int level = 0;
 
diff --git a/src/algorithm/locate/IndexedPointInAreaLocator.cpp b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
index 410fa36..181ecf5 100644
--- a/src/algorithm/locate/IndexedPointInAreaLocator.cpp
+++ b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
@@ -38,8 +38,12 @@ namespace locate {
 // private:
 //
 IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry(const geom::Geometry& g)
+    : isEmpty(0)
 {
-    init(g);
+    if (g.isEmpty())
+        isEmpty = true;
+    else
+        init(g);
 }
 
 void
@@ -119,6 +123,8 @@ IndexedPointInAreaLocator::SegmentVisitor::visitItem(void* item)
 void
 IndexedPointInAreaLocator::IntervalIndexedGeometry::query(double min, double max, index::ItemVisitor* visitor)
 {
+    if (isEmpty)
+        return;
     index.query(min, max, visitor);
 }
 
diff --git a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
index b2b8b86..a01ab37 100644
--- a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
+++ b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
@@ -34,9 +34,15 @@ namespace intervalrtree {
 void
 SortedPackedIntervalRTree::init()
 {
-    if(root != nullptr) {
+    // Already built
+    if(root != nullptr)
         return;
-    }
+
+    /**
+    * if leaves is empty then nothing has been inserted.
+    * In this case it is safe to leave the tree in an open state
+    */
+    if (leaves.size() == 0) return;
 
     root = buildTree();
 }
@@ -112,6 +118,10 @@ SortedPackedIntervalRTree::query(double min, double max, index::ItemVisitor* vis
 {
     init();
 
+    // if root is null tree must be empty
+    if (root == nullptr)
+      return;
+
     root->query(min, max, visitor);
 }
 

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

Summary of changes:
 include/geos/algorithm/locate/IndexedPointInAreaLocator.h  |  1 +
 .../geos/index/intervalrtree/SortedPackedIntervalRTree.h   |  7 +++++++
 src/algorithm/locate/IndexedPointInAreaLocator.cpp         |  8 +++++++-
 src/index/intervalrtree/SortedPackedIntervalRTree.cpp      | 14 ++++++++++++--
 4 files changed, 27 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list