[geos-commits] [SCM] GEOS branch main updated. 24ec89dc300e1f403dfb234506bb54a8c9f3e68c
git at osgeo.org
git at osgeo.org
Wed May 20 05:29:16 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 24ec89dc300e1f403dfb234506bb54a8c9f3e68c (commit)
via 354774939da50aedc2680583ab217212d8ef537a (commit)
via 588ab2b922181b44caad62cb7e27830ba2f91682 (commit)
via 532837e2edcc8678b32c50a96925a8f6ce248402 (commit)
via 10a6af8a82e4ebd59004f817d21f4945001cca10 (commit)
via faf653775e13a87622f9b1052ffcb844df11f7ba (commit)
from 87af72224bf9f066353d2215e2e3dea50fba8cb1 (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 24ec89dc300e1f403dfb234506bb54a8c9f3e68c
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue May 19 22:35:59 2026 -0400
planargraph::Edge: use std::array
diff --git a/include/geos/planargraph/Edge.h b/include/geos/planargraph/Edge.h
index 85dc26f7f..b177fc479 100644
--- a/include/geos/planargraph/Edge.h
+++ b/include/geos/planargraph/Edge.h
@@ -19,6 +19,7 @@
#include <geos/planargraph/GraphComponent.h> // for inheritance
+#include <array>
#include <vector> // for typedefs
#include <set> // for typedefs
#include <iosfwd> // ostream
@@ -72,7 +73,7 @@ public:
protected:
/** \brief The two DirectedEdges associated with this Edge */
- std::vector<DirectedEdge*> dirEdge;
+ std::array<DirectedEdge*, 2> dirEdge;
public:
diff --git a/src/planargraph/Edge.cpp b/src/planargraph/Edge.cpp
index 1b0a271d8..a9352ae6d 100644
--- a/src/planargraph/Edge.cpp
+++ b/src/planargraph/Edge.cpp
@@ -31,8 +31,8 @@ namespace planargraph {
void
Edge::setDirectedEdges(DirectedEdge* de0, DirectedEdge* de1)
{
- dirEdge.push_back(de0);
- dirEdge.push_back(de1);
+ dirEdge[0] = de0;
+ dirEdge[1] = de1;
de0->setEdge(this);
de1->setEdge(this);
de0->setSym(de1);
commit 354774939da50aedc2680583ab217212d8ef537a
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue May 19 22:29:41 2026 -0400
PlanarGraph: add const qualifiers
diff --git a/include/geos/planargraph/DirectedEdge.h b/include/geos/planargraph/DirectedEdge.h
index e80f9c187..e2395328f 100644
--- a/include/geos/planargraph/DirectedEdge.h
+++ b/include/geos/planargraph/DirectedEdge.h
@@ -54,11 +54,11 @@ public:
protected:
Edge* parentEdge;
- Node* from;
- Node* to;
- geom::Coordinate p0, p1;
+ Node* const from;
+ Node* const to;
+ const geom::CoordinateXY p0, p1;
DirectedEdge* sym; // optional
- bool edgeDirection;
+ const bool edgeDirection;
int quadrant;
double angle;
public:
@@ -129,7 +129,7 @@ public:
* \brief Returns a point to which an imaginary line is drawn
* from the from-node to specify this DirectedEdge's orientation.
*/
- const geom::Coordinate& getDirectionPt() const;
+ const geom::CoordinateXY& getDirectionPt() const;
/**
* \brief Returns whether the direction of the parent Edge (if any)
@@ -140,18 +140,20 @@ public:
/**
* \brief Returns the node from which this DirectedEdge leaves.
*/
- Node* getFromNode() const;
+ const Node* getFromNode() const;
+ Node* getFromNode();
/**
* \brief Returns the node to which this DirectedEdge goes.
*/
- Node* getToNode() const;
+ const Node* getToNode() const;
+ Node* getToNode();
/**
* \brief
* Returns the coordinate of the from-node.
*/
- geom::CoordinateXY& getCoordinate() const;
+ const geom::CoordinateXY& getCoordinate() const;
/**
* \brief
@@ -185,7 +187,7 @@ public:
* A robust algorithm is:
*
* - first compare the quadrants.
- * If the quadrants are different, it it
+ * If the quadrants are different, it is
* trivial to determine which std::vector is "greater".
* - if the vectors lie in the same quadrant, the robust
* Orientation::index(Coordinate, Coordinate, Coordinate)
@@ -206,7 +208,7 @@ public:
* A robust algorithm is:
*
* - first compare the quadrants.
- * If the quadrants are different, it it trivial to determine
+ * If the quadrants are different, it is trivial to determine
* which std::vector is "greater".
* - if the vectors lie in the same quadrant, the robust
* Orientation::index(Coordinate, Coordinate, Coordinate)
diff --git a/include/geos/planargraph/DirectedEdgeStar.h b/include/geos/planargraph/DirectedEdgeStar.h
index 27591124c..9c02a7fc6 100644
--- a/include/geos/planargraph/DirectedEdgeStar.h
+++ b/include/geos/planargraph/DirectedEdgeStar.h
@@ -104,7 +104,7 @@ public:
* \brief Returns the coordinate for the node at which this
* star is based
*/
- geom::CoordinateXY& getCoordinate() const;
+ const geom::CoordinateXY& getCoordinate() const;
/**
* \brief Returns the DirectedEdges, in ascending order
diff --git a/include/geos/planargraph/Node.h b/include/geos/planargraph/Node.h
index 24176200d..83b62683a 100644
--- a/include/geos/planargraph/Node.h
+++ b/include/geos/planargraph/Node.h
@@ -72,8 +72,8 @@ public:
/**
* \brief Returns the location of this Node.
*/
- geom::CoordinateXY&
- getCoordinate()
+ const geom::CoordinateXY&
+ getCoordinate() const
{
return pt;
}
diff --git a/include/geos/planargraph/NodeMap.h b/include/geos/planargraph/NodeMap.h
index 3e4cc1ea8..67947c0c3 100644
--- a/include/geos/planargraph/NodeMap.h
+++ b/include/geos/planargraph/NodeMap.h
@@ -72,7 +72,7 @@ public:
* Removes the Node at the given location, and returns it
* (or null if no Node was there).
*/
- Node* remove(geom::CoordinateXY& pt);
+ Node* remove(const geom::CoordinateXY& pt);
/**
* \brief
diff --git a/src/operation/linemerge/LineSequencer.cpp b/src/operation/linemerge/LineSequencer.cpp
index 12b826695..a8ffa894f 100644
--- a/src/operation/linemerge/LineSequencer.cpp
+++ b/src/operation/linemerge/LineSequencer.cpp
@@ -291,9 +291,9 @@ LineSequencer::addReverseSubpath(const planargraph::DirectedEdge* de,
using planargraph::DirectedEdge;
// trace an unvisited path *backwards* from this de
- Node* endNode = de->getToNode();
+ const Node* endNode = de->getToNode();
- Node* fromNode = nullptr;
+ const Node* fromNode = nullptr;
while(true) {
deList.insert(lit, de->getSym());
de->getEdge()->setVisited(true);
@@ -365,8 +365,8 @@ LineSequencer::orient(planargraph::DirectedEdge::NonConstList* seq)
const DirectedEdge* startEdge = seq->front();
const DirectedEdge* endEdge = seq->back();
- Node* startNode = startEdge->getFromNode();
- Node* endNode = endEdge->getToNode();
+ const Node* startNode = startEdge->getFromNode();
+ const Node* endNode = endEdge->getToNode();
bool flipSeq = false;
bool hasDegree1Node = \
diff --git a/src/planargraph/DirectedEdge.cpp b/src/planargraph/DirectedEdge.cpp
index a6a591624..727ab8981 100644
--- a/src/planargraph/DirectedEdge.cpp
+++ b/src/planargraph/DirectedEdge.cpp
@@ -48,13 +48,13 @@ DirectedEdge::toEdges(std::vector<DirectedEdge*>& dirEdges)
/*public*/
DirectedEdge::DirectedEdge(Node* newFrom, Node* newTo,
- const CoordinateXY& directionPt, bool newEdgeDirection)
+ const CoordinateXY& directionPt, bool newEdgeDirection) :
+ from(newFrom),
+ to(newTo),
+ p0(from->getCoordinate()),
+ p1(directionPt),
+ edgeDirection(newEdgeDirection)
{
- from = newFrom;
- to = newTo;
- edgeDirection = newEdgeDirection;
- p0 = from->getCoordinate();
- p1 = directionPt;
double dx = p1.x - p0.x;
double dy = p1.y - p0.y;
quadrant = geom::Quadrant::quadrant(dx, dy);
@@ -84,7 +84,7 @@ DirectedEdge::getQuadrant() const
}
/*public*/
-const Coordinate&
+const CoordinateXY&
DirectedEdge::getDirectionPt() const
{
return p1;
@@ -98,21 +98,33 @@ DirectedEdge::getEdgeDirection() const
}
/*public*/
-Node*
+const Node*
DirectedEdge::getFromNode() const
{
return from;
}
-/*public*/
Node*
+DirectedEdge::getFromNode()
+{
+ return from;
+}
+
+/*public*/
+const Node*
DirectedEdge::getToNode() const
{
return to;
}
+Node*
+DirectedEdge::getToNode()
+{
+ return to;
+}
+
/*public*/
-CoordinateXY&
+const CoordinateXY&
DirectedEdge::getCoordinate() const
{
return from->getCoordinate();
diff --git a/src/planargraph/DirectedEdgeStar.cpp b/src/planargraph/DirectedEdgeStar.cpp
index 1db36c5fa..7d11dde18 100644
--- a/src/planargraph/DirectedEdgeStar.cpp
+++ b/src/planargraph/DirectedEdgeStar.cpp
@@ -81,7 +81,7 @@ DirectedEdgeStar::end() const
/*
* Returns the coordinate for the node at which this star is based
*/
-CoordinateXY&
+const CoordinateXY&
DirectedEdgeStar::getCoordinate() const
{
if(outEdges.empty()) {
diff --git a/src/planargraph/NodeMap.cpp b/src/planargraph/NodeMap.cpp
index 6729a22f4..1d38973e2 100644
--- a/src/planargraph/NodeMap.cpp
+++ b/src/planargraph/NodeMap.cpp
@@ -52,7 +52,7 @@ NodeMap::add(Node* n)
* (or null if no Node was there).
*/
Node*
-NodeMap::remove(geom::CoordinateXY& pt)
+NodeMap::remove(const geom::CoordinateXY& pt)
{
Node* n = find(pt);
nodeMap.erase(pt);
commit 588ab2b922181b44caad62cb7e27830ba2f91682
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue May 19 22:21:55 2026 -0400
PlanarGraph: apply some cleanups
diff --git a/include/geos/planargraph/DirectedEdgeStar.h b/include/geos/planargraph/DirectedEdgeStar.h
index e58daa810..27591124c 100644
--- a/include/geos/planargraph/DirectedEdgeStar.h
+++ b/include/geos/planargraph/DirectedEdgeStar.h
@@ -110,21 +110,21 @@ public:
* \brief Returns the DirectedEdges, in ascending order
* by angle with the positive x-axis.
*/
- std::vector<DirectedEdge*>& getEdges();
+ std::vector<DirectedEdge*>& getEdges() const;
/**
* \brief Returns the zero-based index of the given Edge,
* after sorting in ascending order by angle with the
* positive x-axis.
*/
- int getIndex(const Edge* edge);
+ int getIndex(const Edge* edge) const;
/**
* \brief Returns the zero-based index of the given DirectedEdge,
* after sorting in ascending order
* by angle with the positive x-axis.
*/
- int getIndex(const DirectedEdge* dirEdge);
+ int getIndex(const DirectedEdge* dirEdge) const;
/**
* \brief Returns the remainder when i is divided by the number of
@@ -137,7 +137,7 @@ public:
* of the given DirectedEdge (which must be a member of this
* DirectedEdgeStar).
*/
- DirectedEdge* getNextEdge(DirectedEdge* dirEdge);
+ DirectedEdge* getNextEdge(DirectedEdge* dirEdge) const;
};
} // namespace geos::planargraph
diff --git a/include/geos/planargraph/Node.h b/include/geos/planargraph/Node.h
index e1a030e26..24176200d 100644
--- a/include/geos/planargraph/Node.h
+++ b/include/geos/planargraph/Node.h
@@ -57,21 +57,17 @@ public:
/** \brief
* Returns all Edges that connect the two nodes (which are
* assumed to be different).
- *
- * Note: returned vector is newly allocated, ownership to
- * the caller.
*/
- static std::vector<Edge*>* getEdgesBetween(Node* node0,
- Node* node1);
+ static std::vector<Edge*> getEdgesBetween(const Node* node0,
+ const Node* node1);
/// Constructs a Node with the given location.
- Node(const geom::CoordinateXY& newPt)
+ explicit Node(const geom::CoordinateXY& newPt)
:
pt(newPt)
{}
- ~Node() override
- {}
+ ~Node() override = default;
/**
* \brief Returns the location of this Node.
diff --git a/src/planargraph/DirectedEdgeStar.cpp b/src/planargraph/DirectedEdgeStar.cpp
index 6dfc5ebab..1db36c5fa 100644
--- a/src/planargraph/DirectedEdgeStar.cpp
+++ b/src/planargraph/DirectedEdgeStar.cpp
@@ -97,7 +97,7 @@ DirectedEdgeStar::getCoordinate() const
* the positive x-axis.
*/
std::vector<DirectedEdge*>&
-DirectedEdgeStar::getEdges()
+DirectedEdgeStar::getEdges() const
{
sortEdges();
return outEdges;
@@ -129,7 +129,7 @@ DirectedEdgeStar::sortEdges() const
* ascending order by angle with the positive x-axis.
*/
int
-DirectedEdgeStar::getIndex(const Edge* edge)
+DirectedEdgeStar::getIndex(const Edge* edge) const
{
sortEdges();
for(unsigned int i = 0; i < outEdges.size(); ++i) {
@@ -146,7 +146,7 @@ DirectedEdgeStar::getIndex(const Edge* edge)
* in ascending order by angle with the positive x-axis.
*/
int
-DirectedEdgeStar::getIndex(const DirectedEdge* dirEdge)
+DirectedEdgeStar::getIndex(const DirectedEdge* dirEdge) const
{
sortEdges();
for(unsigned int i = 0; i < outEdges.size(); ++i) {
@@ -178,7 +178,7 @@ DirectedEdgeStar::getIndex(int i) const
* DirectedEdge (which must be a member of this DirectedEdgeStar).
*/
DirectedEdge*
-DirectedEdgeStar::getNextEdge(DirectedEdge* dirEdge)
+DirectedEdgeStar::getNextEdge(DirectedEdge* dirEdge) const
{
int i = getIndex(dirEdge);
return outEdges[getIndex(i + 1)];
diff --git a/src/planargraph/Node.cpp b/src/planargraph/Node.cpp
index 9a5f8e97e..48a459256 100644
--- a/src/planargraph/Node.cpp
+++ b/src/planargraph/Node.cpp
@@ -26,8 +26,8 @@ namespace planargraph {
/* static public */
/* UNUSED */
-std::vector<Edge*>*
-Node::getEdgesBetween(Node* node0, Node* node1)
+std::vector<Edge*>
+Node::getEdgesBetween(const Node* node0, const Node* node1)
{
std::vector<Edge*> edges0;
DirectedEdge::toEdges(node0->getOutEdges()->getEdges(), edges0);
@@ -39,13 +39,13 @@ Node::getEdgesBetween(Node* node0, Node* node1)
std::sort(edges0.begin(), edges0.end());
std::sort(edges1.begin(), edges1.end());
- std::vector<Edge*>* commonEdges = new std::vector<Edge*>();
+ std::vector<Edge*> commonEdges;
// Intersect the two sets
std::set_intersection(
edges0.begin(), edges0.end(),
edges1.begin(), edges1.end(),
- commonEdges->end()
+ std::back_inserter(commonEdges)
);
return commonEdges;
commit 532837e2edcc8678b32c50a96925a8f6ce248402
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue May 19 22:14:59 2026 -0400
planargraph::Node: avoid heap-allocating DirectedEdgeStar
diff --git a/include/geos/planargraph/Node.h b/include/geos/planargraph/Node.h
index 48f3751ba..e1a030e26 100644
--- a/include/geos/planargraph/Node.h
+++ b/include/geos/planargraph/Node.h
@@ -48,7 +48,7 @@ protected:
geom::CoordinateXY pt;
/// The collection of DirectedEdges that leave this Node
- DirectedEdgeStar* deStar;
+ DirectedEdgeStar deStar;
public:
@@ -68,25 +68,9 @@ public:
Node(const geom::CoordinateXY& newPt)
:
pt(newPt)
- {
- deStar = new DirectedEdgeStar();
- }
+ {}
~Node() override
- {
- delete deStar;
- }
-
- /**
- * \brief
- * Constructs a Node with the given location and
- * collection of outgoing DirectedEdges.
- * Takes ownership of the given DirectedEdgeStar!!
- */
- Node(geom::Coordinate& newPt, DirectedEdgeStar* newDeStar)
- :
- pt(newPt),
- deStar(newDeStar)
{}
/**
@@ -104,7 +88,7 @@ public:
void
addOutEdge(DirectedEdge* de)
{
- deStar->add(de);
+ deStar.add(de);
}
/**
@@ -114,12 +98,13 @@ public:
DirectedEdgeStar*
getOutEdges()
{
- return deStar;
+ return &deStar;
}
+
const DirectedEdgeStar*
getOutEdges() const
{
- return deStar;
+ return &deStar;
}
/**
@@ -128,7 +113,7 @@ public:
size_t
getDegree() const
{
- return deStar->getDegree();
+ return deStar.getDegree();
}
/**
@@ -139,7 +124,7 @@ public:
int
getIndex(Edge* edge)
{
- return deStar->getIndex(edge);
+ return deStar.getIndex(edge);
}
private:
commit 10a6af8a82e4ebd59004f817d21f4945001cca10
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue May 19 22:12:05 2026 -0400
LineMergeGraph: Apply some cleanups
diff --git a/include/geos/operation/linemerge/LineMergeDirectedEdge.h b/include/geos/operation/linemerge/LineMergeDirectedEdge.h
index 4da09e0b8..01303ab34 100644
--- a/include/geos/operation/linemerge/LineMergeDirectedEdge.h
+++ b/include/geos/operation/linemerge/LineMergeDirectedEdge.h
@@ -59,7 +59,7 @@ public:
*/
LineMergeDirectedEdge(planargraph::Node* from,
planargraph::Node* to,
- const geom::Coordinate& directionPt,
+ const geom::CoordinateXY& directionPt,
bool edgeDirection);
/** \brief
diff --git a/include/geos/operation/linemerge/LineMergeGraph.h b/include/geos/operation/linemerge/LineMergeGraph.h
index c711248f4..bf5c1f315 100644
--- a/include/geos/operation/linemerge/LineMergeGraph.h
+++ b/include/geos/operation/linemerge/LineMergeGraph.h
@@ -23,6 +23,7 @@
#include <geos/export.h>
#include <geos/planargraph/PlanarGraph.h> // for inheritance
+#include <memory>
#include <vector>
#ifdef _MSC_VER
@@ -59,16 +60,18 @@ class GEOS_DLL LineMergeGraph: public planargraph::PlanarGraph {
private:
- planargraph::Node* getNode(const geom::Coordinate& coordinate);
+ planargraph::Node* getNode(const geom::CoordinateXY& coordinate);
- std::vector<planargraph::Node*> newNodes;
+ std::vector<std::unique_ptr<planargraph::Node>> newNodes;
- std::vector<planargraph::Edge*> newEdges;
+ std::vector<std::unique_ptr<planargraph::Edge>> newEdges;
- std::vector<planargraph::DirectedEdge*> newDirEdges;
+ std::vector<std::unique_ptr<planargraph::DirectedEdge>> newDirEdges;
public:
+ LineMergeGraph();
+
/** \brief
* Adds an Edge, DirectedEdges, and Nodes for the given
* LineString representation of an edge.
@@ -80,6 +83,12 @@ public:
void addEdge(const geom::LineString* lineString);
~LineMergeGraph() override;
+
+private:
+ // Declared as non-copyable
+ LineMergeGraph(const LineMergeGraph& other) = delete;
+ LineMergeGraph& operator=(const LineMergeGraph& rhs) = delete;
+
};
} // namespace geos::operation::linemerge
} // namespace geos::operation
diff --git a/src/operation/linemerge/LineMergeDirectedEdge.cpp b/src/operation/linemerge/LineMergeDirectedEdge.cpp
index f1a15f5dd..1428b22a5 100644
--- a/src/operation/linemerge/LineMergeDirectedEdge.cpp
+++ b/src/operation/linemerge/LineMergeDirectedEdge.cpp
@@ -33,7 +33,7 @@ namespace linemerge { // geos.operation.linemerge
LineMergeDirectedEdge::LineMergeDirectedEdge(
planargraph::Node* newFrom,
planargraph::Node* newTo,
- const Coordinate& newDirectionPt,
+ const CoordinateXY& newDirectionPt,
bool nEdgeDirection)
:
planargraph::DirectedEdge(newFrom, newTo,
diff --git a/src/operation/linemerge/LineMergeGraph.cpp b/src/operation/linemerge/LineMergeGraph.cpp
index f021dc4f4..f464ce435 100644
--- a/src/operation/linemerge/LineMergeGraph.cpp
+++ b/src/operation/linemerge/LineMergeGraph.cpp
@@ -46,6 +46,8 @@ namespace geos {
namespace operation { // geos.operation
namespace linemerge { // geos.operation.linemerge
+LineMergeGraph::LineMergeGraph() = default;
+
void
LineMergeGraph::addEdge(const LineString* lineString)
{
@@ -66,8 +68,8 @@ LineMergeGraph::addEdge(const LineString* lineString)
return;
}
- const Coordinate& startCoordinate = coordinates->getAt(0);
- const Coordinate& endCoordinate = coordinates->getAt(nCoords - 1);
+ const CoordinateXY& startCoordinate = coordinates->getAt<CoordinateXY>(0);
+ const CoordinateXY& endCoordinate = coordinates->getAt<CoordinateXY>(nCoords - 1);
planargraph::Node* startNode = getNode(startCoordinate);
planargraph::Node* endNode = getNode(endCoordinate);
@@ -76,18 +78,16 @@ LineMergeGraph::addEdge(const LineString* lineString)
std::cerr << " endNode: " << *endNode << std::endl;
#endif
- planargraph::DirectedEdge* directedEdge0 = new LineMergeDirectedEdge(startNode,
- endNode, coordinates->getAt(1),
- true);
- newDirEdges.push_back(directedEdge0);
+ const CoordinateXY& dirPt0 = coordinates->getAt<CoordinateXY>(1);
+ newDirEdges.push_back(std::make_unique<LineMergeDirectedEdge>(startNode, endNode, dirPt0, true));
+ auto* directedEdge0 = newDirEdges.back().get();
- planargraph::DirectedEdge* directedEdge1 = new LineMergeDirectedEdge(endNode,
- startNode, coordinates->getAt(nCoords - 2),
- false);
- newDirEdges.push_back(directedEdge1);
+ const CoordinateXY& dirPt1 = coordinates->getAt<CoordinateXY>(nCoords - 2);
+ newDirEdges.push_back(std::make_unique<LineMergeDirectedEdge>(endNode, startNode, dirPt1, false));
+ auto* directedEdge1 = newDirEdges.back().get();
- planargraph::Edge* edge = new LineMergeEdge(lineString);
- newEdges.push_back(edge);
+ newEdges.push_back(std::make_unique<LineMergeEdge>(lineString));
+ planargraph::Edge* edge = newEdges.back().get();
edge->setDirectedEdges(directedEdge0, directedEdge1);
#if GEOS_DEBUG
@@ -105,30 +105,18 @@ LineMergeGraph::addEdge(const LineString* lineString)
}
planargraph::Node*
-LineMergeGraph::getNode(const Coordinate& coordinate)
+LineMergeGraph::getNode(const CoordinateXY& coordinate)
{
planargraph::Node* node = findNode(coordinate);
if(node == nullptr) {
- node = new planargraph::Node(coordinate);
- newNodes.push_back(node);
+ newNodes.push_back(std::make_unique<planargraph::Node>(coordinate));
+ node = newNodes.back().get();
add(node);
}
return node;
}
-LineMergeGraph::~LineMergeGraph()
-{
- unsigned int i;
- for(i = 0; i < newNodes.size(); i++) {
- delete newNodes[i];
- }
- for(i = 0; i < newEdges.size(); i++) {
- delete newEdges[i];
- }
- for(i = 0; i < newDirEdges.size(); i++) {
- delete newDirEdges[i];
- }
-}
+LineMergeGraph::~LineMergeGraph() = default;
} // namespace geos.operation.linemerge
} // namespace geos.operation
commit faf653775e13a87622f9b1052ffcb844df11f7ba
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue May 19 21:54:50 2026 -0400
LineMerger: apply some cleanups
diff --git a/include/geos/operation/linemerge/LineMerger.h b/include/geos/operation/linemerge/LineMerger.h
index 041ac3943..a641838e4 100644
--- a/include/geos/operation/linemerge/LineMerger.h
+++ b/include/geos/operation/linemerge/LineMerger.h
@@ -82,7 +82,7 @@ private:
std::vector<std::unique_ptr<geom::LineString>> mergedLineStrings;
- std::vector<EdgeString*> edgeStrings;
+ std::vector<std::unique_ptr<EdgeString>> edgeStrings;
const geom::GeometryFactory* factory;
@@ -98,7 +98,7 @@ private:
void buildEdgeStringsStartingAt(planargraph::Node* node);
- EdgeString* buildEdgeStringStartingWith(LineMergeDirectedEdge* start);
+ std::unique_ptr<EdgeString> buildEdgeStringStartingWith(LineMergeDirectedEdge* start) const;
public:
LineMerger(bool directed = false);
diff --git a/src/operation/linemerge/LineMerger.cpp b/src/operation/linemerge/LineMerger.cpp
index e26aab299..23d79fcdf 100644
--- a/src/operation/linemerge/LineMerger.cpp
+++ b/src/operation/linemerge/LineMerger.cpp
@@ -23,7 +23,6 @@
#include <geos/planargraph/DirectedEdge.h>
#include <geos/planargraph/Edge.h>
#include <geos/planargraph/Node.h>
-//#include <geos/planargraph/GraphComponent.h>
#include <geos/geom/GeometryComponentFilter.h>
#include <geos/geom/LineString.h>
#include <geos/util.h>
@@ -62,18 +61,12 @@ LineMerger::LineMerger(bool directed):
{
}
-LineMerger::~LineMerger()
-{
- for(std::size_t i = 0, n = edgeStrings.size(); i < n; ++i) {
- delete edgeStrings[i];
- }
-}
-
+LineMerger::~LineMerger() = default;
struct LMGeometryComponentFilter: public GeometryComponentFilter {
LineMerger* lm;
- LMGeometryComponentFilter(LineMerger* newLm): lm(newLm) {}
+ explicit LMGeometryComponentFilter(LineMerger* newLm): lm(newLm) {}
void
filter_ro(const Geometry* geom) override
@@ -122,9 +115,6 @@ LineMerger::merge()
GraphComponent::setMarked(graph.edgeIterator(), graph.edgeEnd(),
false);
- for(std::size_t i = 0, n = edgeStrings.size(); i < n; ++i) {
- delete edgeStrings[i];
- }
edgeStrings.clear();
buildEdgeStringsForObviousStartNodes();
@@ -132,8 +122,8 @@ LineMerger::merge()
auto numEdgeStrings = edgeStrings.size();
mergedLineStrings.reserve(numEdgeStrings);
- for(std::size_t i = 0; i < numEdgeStrings; ++i) {
- EdgeString* edgeString = edgeStrings[i];
+
+ for(const auto& edgeString : edgeStrings) {
mergedLineStrings.emplace_back(edgeString->toLineString());
}
}
@@ -156,12 +146,9 @@ LineMerger::buildEdgeStringsForUnprocessedNodes()
#if GEOS_DEBUG
std::cerr << __FUNCTION__ << std::endl;
#endif
- typedef std::vector<Node*> Nodes;
-
- Nodes nodes;
+ std::vector<Node*> nodes;
graph.getNodes(nodes);
- for(Nodes::size_type i = 0, in = nodes.size(); i < in; ++i) {
- Node* node = nodes[i];
+ for(Node* node : nodes) {
#if GEOS_DEBUG
std::cerr << "Node " << i << ": " << *node << std::endl;
#endif
@@ -182,12 +169,9 @@ LineMerger::buildEdgeStringsForNonDegree2Nodes()
#if GEOS_DEBUG
std::cerr << __FUNCTION__ << std::endl;
#endif
- typedef std::vector<Node*> Nodes;
-
- Nodes nodes;
+ std::vector<Node*> nodes;
graph.getNodes(nodes);
- for(Nodes::size_type i = 0, in = nodes.size(); i < in; ++i) {
- Node* node = nodes[i];
+ for(Node* node : nodes) {
#if GEOS_DEBUG
std::cerr << "Node " << i << ": " << *node << std::endl;
#endif
@@ -215,10 +199,10 @@ void
LineMerger::buildEdgeStringsStartingAt(Node* node)
{
std::vector<planargraph::DirectedEdge*>& edges = node->getOutEdges()->getEdges();
- std::size_t size = edges.size();
- for(std::size_t i = 0; i < size; i++) {
+
+ for(auto* edge : edges) {
LineMergeDirectedEdge* directedEdge =
- detail::down_cast<LineMergeDirectedEdge*>(edges[i]);
+ detail::down_cast<LineMergeDirectedEdge*>(edge);
if(isDirected && !directedEdge->getEdgeDirection()) {
continue;
}
@@ -229,10 +213,10 @@ LineMerger::buildEdgeStringsStartingAt(Node* node)
}
}
-EdgeString*
-LineMerger::buildEdgeStringStartingWith(LineMergeDirectedEdge* start)
+std::unique_ptr<EdgeString>
+LineMerger::buildEdgeStringStartingWith(LineMergeDirectedEdge* start) const
{
- EdgeString* edgeString = new EdgeString(factory);
+ auto edgeString = std::make_unique<EdgeString>(factory);
LineMergeDirectedEdge* current = start;
do {
edgeString->add(current);
-----------------------------------------------------------------------
Summary of changes:
.../operation/linemerge/LineMergeDirectedEdge.h | 2 +-
include/geos/operation/linemerge/LineMergeGraph.h | 17 ++++++--
include/geos/operation/linemerge/LineMerger.h | 4 +-
include/geos/planargraph/DirectedEdge.h | 22 +++++-----
include/geos/planargraph/DirectedEdgeStar.h | 10 ++---
include/geos/planargraph/Edge.h | 3 +-
include/geos/planargraph/Node.h | 47 +++++++---------------
include/geos/planargraph/NodeMap.h | 2 +-
src/operation/linemerge/LineMergeDirectedEdge.cpp | 2 +-
src/operation/linemerge/LineMergeGraph.cpp | 44 ++++++++------------
src/operation/linemerge/LineMerger.cpp | 44 +++++++-------------
src/operation/linemerge/LineSequencer.cpp | 8 ++--
src/planargraph/DirectedEdge.cpp | 32 ++++++++++-----
src/planargraph/DirectedEdgeStar.cpp | 10 ++---
src/planargraph/Edge.cpp | 4 +-
src/planargraph/Node.cpp | 8 ++--
src/planargraph/NodeMap.cpp | 2 +-
17 files changed, 119 insertions(+), 142 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list