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

git at osgeo.org git at osgeo.org
Sat Nov 28 13:23:21 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  ad0122541f85886cf9eb9dd65d8246e0144f7ffa (commit)
      from  b3043f9c2ec08074c433d80798551e9790cf1fd0 (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 ad0122541f85886cf9eb9dd65d8246e0144f7ffa
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Sat Nov 28 13:23:17 2020 -0800

    Allow nullptr to be a valid item in the tree

diff --git a/include/geos/index/strtree/SimpleSTRnode.h b/include/geos/index/strtree/SimpleSTRnode.h
index 426f787..1782189 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 item != nullptr;
+        return childNodes.size() == 0;
     }
 
     bool isComposite() const
diff --git a/tests/unit/capi/GEOSSTRtreeTest.cpp b/tests/unit/capi/GEOSSTRtreeTest.cpp
index 5e69671..c46d39a 100644
--- a/tests/unit/capi/GEOSSTRtreeTest.cpp
+++ b/tests/unit/capi/GEOSSTRtreeTest.cpp
@@ -258,7 +258,6 @@ void object::test<7>
     GEOSSTRtree_destroy(tree);
 }
 
-
 // querying tree with box
 template<>
 template<>
@@ -266,30 +265,28 @@ void object::test<8>
 ()
 {
     GEOSSTRtree* tree = GEOSSTRtree_create(10);
+
     GEOSGeometry* g = GEOSGeomFromWKT("POINT (2 3)");
-    GEOSSTRtree_insert(tree, g, g);
+    int payload = 876;
+    GEOSSTRtree_insert(tree, g, &payload);
+
     GEOSGeometry* q = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))");
 
-    typedef std::vector<GEOSGeometry*> GList;
-    GList geoms;
-    ensure_equals(geoms.size(), 0);
+    typedef std::vector<int*> IList;
+    IList items;
+    ensure_equals(items.size(), 0);
     GEOSSTRtree_query(
         tree,
         q,
         [](void* item, void* userdata) {
-            GList* gl = (GList*)userdata;
-            gl->push_back((GEOSGeometry*)item);
+            IList* il = (IList*)userdata;
+            il->push_back((int*)item);
         },
-        &geoms);
+        &items);
 
-    ensure_equals(geoms.size(), 1);
-    const GEOSCoordSequence* seq = GEOSGeom_getCoordSeq(geoms[0]);
+    ensure_equals(items.size(), 1);
 
-    double x = -1;
-    double y = -1;
-    GEOSCoordSeq_getXY(seq,  0, &x, &y);
-    ensure_equals(x, 2.0);
-    ensure_equals(y, 3.0);
+    ensure_equals(*(items[0]), payload);
 
     GEOSGeom_destroy(q);
     GEOSGeom_destroy(g);
@@ -297,7 +294,7 @@ void object::test<8>
 }
 
 
-// querying tree with box
+// Index a null pointer
 template<>
 template<>
 void object::test<9>
@@ -306,8 +303,7 @@ void object::test<9>
     GEOSSTRtree* tree = GEOSSTRtree_create(10);
 
     GEOSGeometry* g = GEOSGeomFromWKT("POINT (2 3)");
-    int payload = 876;
-    GEOSSTRtree_insert(tree, g, &payload);
+    GEOSSTRtree_insert(tree, g, (void*)0);
 
     GEOSGeometry* q = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))");
 
@@ -325,7 +321,7 @@ void object::test<9>
 
     ensure_equals(items.size(), 1);
 
-    ensure_equals(*(items[0]), payload);
+    ensure_equals(items[0], (void*)0);
 
     GEOSGeom_destroy(q);
     GEOSGeom_destroy(g);
@@ -333,13 +329,6 @@ void object::test<9>
 }
 
 
-// >>> import pygeos
-// >>> pygeos.geos_version
-// (3, 9, 0)
-// >>> point = pygeos.Geometry("POINT (2 3)")
-// >>> tree = pygeos.STRtree([point])
-// >>> tree.query(pygeos.box(0, 0, 10, 10))
-// array([], dtype=int64)
 
 
 } // namespace tut

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

Summary of changes:
 include/geos/index/strtree/SimpleSTRnode.h |  2 +-
 tests/unit/capi/GEOSSTRtreeTest.cpp        | 41 +++++++++++-------------------
 2 files changed, 16 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list