[geos-commits] [SCM] GEOS branch main updated. fa569a231414a1f73cb6c4f3c31c259700337035
git at osgeo.org
git at osgeo.org
Wed Jun 17 09:45:40 PDT 2026
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, main has been updated
via fa569a231414a1f73cb6c4f3c31c259700337035 (commit)
from 69b6dad8aa171142b2e0d4342b578232f40cd9a4 (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 fa569a231414a1f73cb6c4f3c31c259700337035
Author: Daniel Baston <dbaston at gmail.com>
Date: Wed Jun 17 10:59:48 2026 -0400
KdTree: Resolve various clang-tidy issues
diff --git a/include/geos/index/kdtree/KdNodeVisitor.h b/include/geos/index/kdtree/KdNodeVisitor.h
index 17c9a9cfa..51589e4f5 100644
--- a/include/geos/index/kdtree/KdNodeVisitor.h
+++ b/include/geos/index/kdtree/KdNodeVisitor.h
@@ -35,6 +35,7 @@ public:
KdNodeVisitor() {};
virtual void visit(KdNode *node) = 0;
+ virtual ~KdNodeVisitor() = default;
};
diff --git a/include/geos/index/kdtree/KdTree.h b/include/geos/index/kdtree/KdTree.h
index 144fbc13f..f98f203cc 100644
--- a/include/geos/index/kdtree/KdTree.h
+++ b/include/geos/index/kdtree/KdTree.h
@@ -19,9 +19,7 @@
#include <geos/index/kdtree/KdNodeVisitor.h>
#include <geos/index/kdtree/KdNode.h>
-#include <memory>
#include <vector>
-#include <string>
#include <deque>
#ifdef _MSC_VER
@@ -64,8 +62,8 @@ private:
KdNode* findBestMatchNode(const geom::Coordinate& p);
KdNode* insertExact(const geom::Coordinate& p, void* data);
- void queryNode(KdNode* currentNode, const geom::Envelope& queryEnv, bool odd, KdNodeVisitor& visitor);
- KdNode* queryNodePoint(KdNode* currentNode, const geom::Coordinate& queryPt, bool odd);
+ static void queryNode(KdNode* currentNode, const geom::Envelope& queryEnv, bool odd, KdNodeVisitor& visitor);
+ static KdNode* queryNodePoint(KdNode* currentNode, const geom::Coordinate& queryPt, bool odd);
/**
* Create a node on a locally managed deque to allow easy
@@ -85,15 +83,16 @@ private:
KdNode* getNode();
void visit(KdNode* node) override;
+ // Declare type as noncopyable
+ BestMatchVisitor(const BestMatchVisitor& other) = delete;
+ BestMatchVisitor& operator=(const BestMatchVisitor& rhs) = delete;
+
private:
// Members
double tolerance;
KdNode* matchNode;
double matchDist;
const geom::Coordinate& p;
- // Declare type as noncopyable
- BestMatchVisitor(const BestMatchVisitor& other);
- BestMatchVisitor& operator=(const BestMatchVisitor& rhs);
};
/**
@@ -102,16 +101,17 @@ private:
*/
class AccumulatingVisitor : public KdNodeVisitor {
public:
- AccumulatingVisitor(std::vector<KdNode*>& p_nodeList) :
+ explicit AccumulatingVisitor(std::vector<KdNode*>& p_nodeList) :
nodeList(p_nodeList) {};
void visit(KdNode* node) override { nodeList.push_back(node); }
+ // Declare type as noncopyable
+ AccumulatingVisitor(const AccumulatingVisitor& other) = delete;
+ AccumulatingVisitor& operator=(const AccumulatingVisitor& rhs) = delete;
+
private:
// Members
std::vector<KdNode*>& nodeList;
- // Declare type as noncopyable
- AccumulatingVisitor(const AccumulatingVisitor& other);
- AccumulatingVisitor& operator=(const AccumulatingVisitor& rhs);
};
@@ -121,10 +121,10 @@ public:
/**
* Converts a collection of {@link KdNode}s to an vector of {@link geom::Coordinate}s.
*
- * @param kdnodes a collection of nodes
- * @return an vector of the coordinates represented by the nodes
+ * @param kdNodes a collection of nodes
+ * @return a vector of the coordinates represented by the nodes
*/
- static std::unique_ptr<std::vector<geom::Coordinate>> toCoordinates(std::vector<KdNode*>& kdnodes);
+ static std::vector<geom::Coordinate> toCoordinates(const std::vector<KdNode*>& kdNodes);
/**
* Converts a collection of {@link KdNode}s
@@ -132,12 +132,12 @@ public:
* specifying whether repeated nodes should be represented
* by multiple coordinates.
*
- * @param kdnodes a collection of nodes
+ * @param kdNodes a collection of nodes
* @param includeRepeated true if repeated nodes should
* be included multiple times
- * @return an vector of the coordinates represented by the nodes
+ * @return a vector of the coordinates represented by the nodes
*/
- static std::unique_ptr<std::vector<geom::Coordinate>> toCoordinates(std::vector<KdNode*>& kdnodes, bool includeRepeated);
+ static std::vector<geom::Coordinate> toCoordinates(const std::vector<KdNode*>& kdNodes, bool includeRepeated);
KdTree() :
root(nullptr),
@@ -145,7 +145,7 @@ public:
tolerance(0.0)
{};
- KdTree(double p_tolerance) :
+ explicit KdTree(double p_tolerance) :
root(nullptr),
numberOfNodes(0),
tolerance(p_tolerance)
@@ -167,7 +167,7 @@ public:
/**
* Performs a range search of the points in the index.
*/
- std::unique_ptr<std::vector<KdNode*>> query(const geom::Envelope& queryEnv);
+ std::vector<KdNode*> query(const geom::Envelope& queryEnv);
/**
* Performs a range search of the points in the index.
diff --git a/src/index/kdtree/KdTree.cpp b/src/index/kdtree/KdTree.cpp
index a0c2dfbff..2118165aa 100644
--- a/src/index/kdtree/KdTree.cpp
+++ b/src/index/kdtree/KdTree.cpp
@@ -27,26 +27,26 @@ namespace kdtree { // geos.index.kdtree
/*public static*/
-std::unique_ptr<std::vector<Coordinate>>
-KdTree::toCoordinates(std::vector<KdNode*>& kdnodes)
+std::vector<Coordinate>
+KdTree::toCoordinates(const std::vector<KdNode*>& kdnodes)
{
return toCoordinates(kdnodes, false);
}
/*public static*/
-std::unique_ptr<std::vector<Coordinate>>
-KdTree::toCoordinates(std::vector<KdNode*>& kdnodes, bool includeRepeated)
+std::vector<Coordinate>
+KdTree::toCoordinates(const std::vector<KdNode*>& kdnodes, bool includeRepeated)
{
- std::unique_ptr<std::vector<Coordinate>> coord(new std::vector<Coordinate>);
+ std::vector<Coordinate> coord;
for (auto node: kdnodes) {
std::size_t count = includeRepeated ? node->getCount() : 1;
for (std::size_t i = 0; i < count; i++) {
- coord->emplace_back(node->getCoordinate());
+ coord.emplace_back(node->getCoordinate());
}
}
if (!includeRepeated) {
// Remove duplicate Coordinates from coordList
- coord->erase(std::unique(coord->begin(), coord->end()), coord->end());
+ coord.erase(std::unique(coord.begin(), coord.end()), coord.end());
}
return coord;
}
@@ -153,7 +153,7 @@ KdTree::insertExact(const geom::Coordinate& p, void* data)
void
KdTree::queryNode(KdNode* currentNode, const geom::Envelope& queryEnv, bool odd, KdNodeVisitor& visitor)
{
- // Non recursive formulation of in-order traversal from
+ // Non-recursive formulation of in-order traversal from
// http://web.cs.wpi.edu/~cs2005/common/iterative.inorder
// Otherwise we may blow up the stack
// See https://github.com/qgis/QGIS/issues/45226
@@ -175,7 +175,7 @@ KdTree::queryNode(KdNode* currentNode, const geom::Envelope& queryEnv, bool odd,
}
bool searchLeft = min < discriminant;
- activeNodes.emplace(Pair(currentNode, odd));
+ activeNodes.emplace(currentNode, odd);
// search is computed via in-order traversal
KdNode* leftNode = nullptr;
@@ -267,11 +267,11 @@ KdTree::query(const geom::Envelope& queryEnv, KdNodeVisitor& visitor)
}
/*public*/
-std::unique_ptr<std::vector<KdNode*>>
+std::vector<KdNode*>
KdTree::query(const geom::Envelope& queryEnv)
{
- std::unique_ptr<std::vector<KdNode*>> result(new std::vector<KdNode*>);
- query(queryEnv, *result);
+ std::vector<KdNode*> result;
+ query(queryEnv, result);
return result;
}
diff --git a/tests/unit/index/kdtree/KdTreeTest.cpp b/tests/unit/index/kdtree/KdTreeTest.cpp
index 2de94f162..34ef8d8c6 100644
--- a/tests/unit/index/kdtree/KdTreeTest.cpp
+++ b/tests/unit/index/kdtree/KdTreeTest.cpp
@@ -28,13 +28,13 @@ struct test_kdtree_data {
std::vector<Coordinate> expectedCoord;
csExpected->toVector(expectedCoord);
// Read tree into vector of coordinates
- std::unique_ptr<std::vector<Coordinate>> result = KdTree::toCoordinates(*(index.query(queryEnv)), includeRepeated);
+ auto result = KdTree::toCoordinates(index.query(queryEnv), includeRepeated);
- std::sort(result->begin(), result->end());
+ std::sort(result.begin(), result.end());
std::sort(expectedCoord.begin(), expectedCoord.end());
- ensure("Result count not equal to expected count", result->size() == expectedCoord.size());
- ensure("Expected result coordinates not found", *result == expectedCoord);
+ ensure("Result count not equal to expected count", result.size() == expectedCoord.size());
+ ensure("Expected result coordinates not found", result == expectedCoord);
}
void testQuery(std::string& wktInput, double tolerance, const Envelope& queryEnv, std::string& wktExpected) {
@@ -67,11 +67,11 @@ void object::test<1> ()
ensure("Inserting 2 identical points should create one node", node1 == node2);
Envelope queryEnv(0, 10, 0, 10);
- std::unique_ptr<std::vector<KdNode*>> result = index.query(queryEnv);
+ std::vector<KdNode*> result = index.query(queryEnv);
- ensure("query should return 1 result", result->size() == 1);
+ ensure("query should return 1 result", result.size() == 1);
- KdNode* node = result->at(0);
+ KdNode* node = result.at(0);
ensure("node should have two entries", node->getCount() == 2);
ensure("node should be repeated", node->isRepeated());
}
@@ -180,11 +180,11 @@ void object::test<8> ()
ensure("Inserting 2 identical points should create one node", node1 == node2);
Envelope queryEnv(0, 10, 0, 10);
- std::unique_ptr<std::vector<KdNode*>> result = index.query(queryEnv);
+ std::vector<KdNode*> result = index.query(queryEnv);
- ensure(result->size() == 1);
+ ensure(result.size() == 1);
- KdNode* node = (KdNode*)(*result)[0];
+ KdNode* node = result[0];
ensure(node->getCount() == 2);
ensure(node->isRepeated());
}
-----------------------------------------------------------------------
Summary of changes:
include/geos/index/kdtree/KdNodeVisitor.h | 1 +
include/geos/index/kdtree/KdTree.h | 38 +++++++++++++++----------------
src/index/kdtree/KdTree.cpp | 24 +++++++++----------
tests/unit/index/kdtree/KdTreeTest.cpp | 20 ++++++++--------
4 files changed, 42 insertions(+), 41 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list