[geos-commits] r2366 - in trunk/source: geomgraph
headers/geos/geomgraph headers/geos/operation/overlay
operation/overlay
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Apr 15 05:25:28 EDT 2009
Author: strk
Date: 2009-04-15 05:25:28 -0400 (Wed, 15 Apr 2009)
New Revision: 2366
Modified:
trunk/source/geomgraph/EdgeRing.cpp
trunk/source/headers/geos/geomgraph/EdgeRing.h
trunk/source/headers/geos/operation/overlay/MaximalEdgeRing.h
trunk/source/headers/geos/operation/overlay/PolygonBuilder.h
trunk/source/operation/overlay/MaximalEdgeRing.cpp
trunk/source/operation/overlay/PolygonBuilder.cpp
Log:
Fix leak in PolygonBuilder (overlay operation). The leak was exposed by the stmlf-cases-20061020.xml testcase. This commit also adds some doc-only throw specs related to the bug.
Modified: trunk/source/geomgraph/EdgeRing.cpp
===================================================================
--- trunk/source/geomgraph/EdgeRing.cpp 2009-04-15 07:52:11 UTC (rev 2365)
+++ trunk/source/geomgraph/EdgeRing.cpp 2009-04-15 09:25:28 UTC (rev 2366)
@@ -222,6 +222,7 @@
/*protected*/
void
EdgeRing::computePoints(DirectedEdge *newStart)
+ // throw(const TopologyException &)
{
startDe=newStart;
DirectedEdge *de=newStart;
Modified: trunk/source/headers/geos/geomgraph/EdgeRing.h
===================================================================
--- trunk/source/headers/geos/geomgraph/EdgeRing.h 2009-04-15 07:52:11 UTC (rev 2365)
+++ trunk/source/headers/geos/geomgraph/EdgeRing.h 2009-04-15 09:25:28 UTC (rev 2366)
@@ -144,6 +144,7 @@
const geom::GeometryFactory *geometryFactory;
+ /// throw(const TopologyException &)
void computePoints(DirectedEdge *newStart);
void mergeLabel(Label& deLabel);
Modified: trunk/source/headers/geos/operation/overlay/MaximalEdgeRing.h
===================================================================
--- trunk/source/headers/geos/operation/overlay/MaximalEdgeRing.h 2009-04-15 07:52:11 UTC (rev 2365)
+++ trunk/source/headers/geos/operation/overlay/MaximalEdgeRing.h 2009-04-15 09:25:28 UTC (rev 2366)
@@ -62,9 +62,9 @@
public:
- // CGAlgorithms arg is obsoleted
MaximalEdgeRing(geomgraph::DirectedEdge *start,
const geom::GeometryFactory *geometryFactory);
+ // throw(const TopologyException &)
virtual ~MaximalEdgeRing();
Modified: trunk/source/headers/geos/operation/overlay/PolygonBuilder.h
===================================================================
--- trunk/source/headers/geos/operation/overlay/PolygonBuilder.h 2009-04-15 07:52:11 UTC (rev 2365)
+++ trunk/source/headers/geos/operation/overlay/PolygonBuilder.h 2009-04-15 09:25:28 UTC (rev 2366)
@@ -61,7 +61,8 @@
* The graph is assumed to contain one or more polygons,
* possibly with holes.
*/
- void add(geomgraph::PlanarGraph *graph); // throw(TopologyException *);
+ void add(geomgraph::PlanarGraph *graph);
+ // throw(const TopologyException &)
/**
* Add a set of edges and nodes, which form a graph.
@@ -70,7 +71,7 @@
*/
void add(const std::vector<geomgraph::DirectedEdge*> *dirEdges,
const std::vector<geomgraph::Node*> *nodes);
- // throw(TopologyException *);
+ // throw(const TopologyException &)
std::vector<geom::Geometry*>* getPolygons();
@@ -87,10 +88,14 @@
std::vector<geomgraph::EdgeRing*> shellList;
/**
- * for all DirectedEdges in result, form them into MaximalEdgeRings
+ * For all DirectedEdges in result, form them into MaximalEdgeRings
+ *
+ * Ownership of the returned vector *and* it's elements is
+ * transferred to caller.
*/
std::vector<MaximalEdgeRing*>* buildMaximalEdgeRings(
const std::vector<geomgraph::DirectedEdge*> *dirEdges);
+ // throw(const TopologyException &)
std::vector<MaximalEdgeRing*>* buildMinimalEdgeRings(
std::vector<MaximalEdgeRing*> *maxEdgeRings,
@@ -148,6 +153,7 @@
*/
void placeFreeHoles(std::vector<geomgraph::EdgeRing*>& newShellList,
std::vector<geomgraph::EdgeRing*>& freeHoleList);
+ // throw(const TopologyException&)
/** \brief
* Find the innermost enclosing shell geomgraph::EdgeRing containing the
Modified: trunk/source/operation/overlay/MaximalEdgeRing.cpp
===================================================================
--- trunk/source/operation/overlay/MaximalEdgeRing.cpp 2009-04-15 07:52:11 UTC (rev 2365)
+++ trunk/source/operation/overlay/MaximalEdgeRing.cpp 2009-04-15 09:25:28 UTC (rev 2366)
@@ -49,6 +49,7 @@
// CGAlgorithms obsoleted
MaximalEdgeRing::MaximalEdgeRing(DirectedEdge *start,
const GeometryFactory *geometryFactory)
+ // throw(const TopologyException &)
:
EdgeRing(start, geometryFactory)
{
Modified: trunk/source/operation/overlay/PolygonBuilder.cpp
===================================================================
--- trunk/source/operation/overlay/PolygonBuilder.cpp 2009-04-15 07:52:11 UTC (rev 2365)
+++ trunk/source/operation/overlay/PolygonBuilder.cpp 2009-04-15 09:25:28 UTC (rev 2366)
@@ -30,6 +30,7 @@
#include <geos/geom/Polygon.h>
#include <geos/algorithm/CGAlgorithms.h>
#include <geos/util/TopologyException.h>
+#include <geos/util/GEOSException.h>
#include <vector>
#include <cassert>
@@ -144,10 +145,11 @@
#endif
vector<EdgeRing*> freeHoleList;
- vector<MaximalEdgeRing*> *edgeRings=
- buildMinimalEdgeRings(maxEdgeRings,&shellList,&freeHoleList);
+ vector<MaximalEdgeRing*> *edgeRings;
+ edgeRings= buildMinimalEdgeRings(maxEdgeRings,&shellList,&freeHoleList);
sortShellsAndHoles(edgeRings,&shellList,&freeHoleList);
+
placeFreeHoles(shellList, freeHoleList);
delete maxEdgeRings;
delete edgeRings;
@@ -166,6 +168,7 @@
/*private*/
vector<MaximalEdgeRing*> *
PolygonBuilder::buildMaximalEdgeRings(const vector<DirectedEdge*> *dirEdges)
+ // throw(const TopologyException &)
{
#if GEOS_DEBUG
cerr<<"PolygonBuilder::buildMaximalEdgeRings got "<<dirEdges->size()<<" dirEdges"<<endl;
@@ -180,10 +183,24 @@
<< " inResult:" << de->isInResult() << endl
<< " isArea:" << de->getLabel()->isArea() << endl;
#endif
- if (de->isInResult() && de->getLabel()->isArea()) {
+ if (de->isInResult() && de->getLabel()->isArea())
+ {
// if this edge has not yet been processed
- if (de->getEdgeRing()==NULL) {
- MaximalEdgeRing *er=new MaximalEdgeRing(de,geometryFactory);
+ if (de->getEdgeRing() == NULL)
+ {
+ MaximalEdgeRing *er;
+ try
+ { // MaximalEdgeRing constructor may throw
+ er=new MaximalEdgeRing(de,geometryFactory);
+ }
+ catch (util::GEOSException& e)
+ { // cleanup if that happens (see stmlf-cases-20061020.xml)
+ for(size_t i=0, n=maxEdgeRings->size(); i<n; i++)
+ delete (*maxEdgeRings)[i];
+ delete maxEdgeRings;
+ //cerr << "Exception! " << e.what() << endl;
+ throw;
+ }
maxEdgeRings->push_back(er);
er->setInResult();
//System.out.println("max node degree=" + er.getMaxDegree());
More information about the geos-commits
mailing list