[geos-commits] r3318 - in trunk: include/geos/operation/relate
src/operation/relate
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Apr 28 11:08:56 EDT 2011
Author: strk
Date: 2011-04-28 08:08:56 -0700 (Thu, 28 Apr 2011)
New Revision: 3318
Modified:
trunk/include/geos/operation/relate/RelateComputer.h
trunk/src/operation/relate/RelateComputer.cpp
Log:
Plug leak on exception in RelateComputer (exposed by running doc/example)
Modified: trunk/include/geos/operation/relate/RelateComputer.h
===================================================================
--- trunk/include/geos/operation/relate/RelateComputer.h 2011-04-28 15:08:47 UTC (rev 3317)
+++ trunk/include/geos/operation/relate/RelateComputer.h 2011-04-28 15:08:56 UTC (rev 3318)
@@ -1,10 +1,11 @@
/**********************************************************************
- * $Id$
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
+ * Copyright (C) 2011 Sandro Santilli <strk at keybit.net>
* Copyright (C) 2006 Refractions Research Inc.
+ * Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
@@ -28,6 +29,7 @@
#include <geos/geom/Coordinate.h> // for RelateComputer composition
#include <vector>
+#include <memory>
#ifdef _MSC_VER
#pragma warning(push)
@@ -72,8 +74,6 @@
*/
class GEOS_DLL RelateComputer {
public:
- //RelateComputer();
- virtual ~RelateComputer();
RelateComputer(std::vector<geomgraph::GeometryGraph*> *newArg);
geom::IntersectionMatrix* computeIM();
private:
@@ -88,7 +88,7 @@
geomgraph::NodeMap nodes;
/// this intersection matrix will hold the results compute for the relate
- geom::IntersectionMatrix *im;
+ std::auto_ptr<geom::IntersectionMatrix> im;
std::vector<geomgraph::Edge*> isolatedEdges;
@@ -97,18 +97,61 @@
void insertEdgeEnds(std::vector<geomgraph::EdgeEnd*> *ee);
- void computeProperIntersectionIM(geomgraph::index::SegmentIntersector *intersector,
- geom::IntersectionMatrix *imX);
+ void computeProperIntersectionIM(
+ geomgraph::index::SegmentIntersector *intersector,
+ geom::IntersectionMatrix *imX);
void copyNodesAndLabels(int argIndex);
void computeIntersectionNodes(int argIndex);
void labelIntersectionNodes(int argIndex);
+
+ /**
+ * If the Geometries are disjoint, we need to enter their dimension and
+ * boundary dimension in the Ext rows in the IM
+ */
void computeDisjointIM(geom::IntersectionMatrix *imX);
+
void labelNodeEdges();
+
+ /**
+ * update the IM with the sum of the IMs for each component
+ */
void updateIM(geom::IntersectionMatrix *imX);
+
+ /**
+ * Processes isolated edges by computing their labelling and adding them
+ * to the isolated edges list.
+ * Isolated edges are guaranteed not to touch the boundary of the target
+ * (since if they
+ * did, they would have caused an intersection to be computed and hence would
+ * not be isolated)
+ */
void labelIsolatedEdges(int thisIndex,int targetIndex);
- void labelIsolatedEdge(geomgraph::Edge *e,int targetIndex, const geom::Geometry *target);
+
+ /**
+ * Label an isolated edge of a graph with its relationship to the target
+ * geometry.
+ * If the target has dim 2 or 1, the edge can either be in the interior
+ * or the exterior.
+ * If the target has dim 0, the edge must be in the exterior
+ */
+ void labelIsolatedEdge(geomgraph::Edge *e,int targetIndex,
+ const geom::Geometry *target);
+
+ /**
+ * Isolated nodes are nodes whose labels are incomplete
+ * (e.g. the location for one Geometry is null).
+ * This is the case because nodes in one graph which don't intersect
+ * nodes in the other are not completely labelled by the initial process
+ * of adding nodes to the nodeList.
+ * To complete the labelling we need to check for nodes that lie in the
+ * interior of edges, and in the interior of areas.
+ */
void labelIsolatedNodes();
+
+ /**
+ * Label an isolated node with its relationship to the target geometry.
+ */
void labelIsolatedNode(geomgraph::Node *n,int targetIndex);
};
Modified: trunk/src/operation/relate/RelateComputer.cpp
===================================================================
--- trunk/src/operation/relate/RelateComputer.cpp 2011-04-28 15:08:47 UTC (rev 3317)
+++ trunk/src/operation/relate/RelateComputer.cpp 2011-04-28 15:08:56 UTC (rev 3318)
@@ -1,11 +1,11 @@
/**********************************************************************
- * $Id$
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
- * Copyright (C) 2001-2002 Vivid Solutions Inc.
+ * Copyright (C) 2011 Sandro Santilli <strk at keybit.net>
* Copyright (C) 2005 Refractions Research Inc.
+ * Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
@@ -55,10 +55,6 @@
{
}
-RelateComputer::~RelateComputer()
-{
-}
-
IntersectionMatrix*
RelateComputer::computeIM()
{
@@ -68,17 +64,21 @@
const Envelope *e1=(*arg)[0]->getGeometry()->getEnvelopeInternal();
const Envelope *e2=(*arg)[1]->getGeometry()->getEnvelopeInternal();
if (!e1->intersects(e2)) {
- computeDisjointIM(im);
- //delete e1;
- //delete e2;
- return im;
+ computeDisjointIM(im.get());
+ return im.release();
}
- SegmentIntersector *si1=(*arg)[0]->computeSelfNodes(&li,false);
- SegmentIntersector *si2=(*arg)[1]->computeSelfNodes(&li,false);
+ std::auto_ptr<SegmentIntersector> si1 (
+ (*arg)[0]->computeSelfNodes(&li,false)
+ );
+ std::auto_ptr<SegmentIntersector> si2 (
+ (*arg)[1]->computeSelfNodes(&li,false)
+ );
// compute intersections between edges of the two input geometries
- SegmentIntersector *intersector=(*arg)[0]->computeEdgeIntersections((*arg)[1], &li,false);
+ std::auto_ptr< SegmentIntersector> intersector (
+ (*arg)[0]->computeEdgeIntersections((*arg)[1], &li,false)
+ );
computeIntersectionNodes(0);
computeIntersectionNodes(1);
@@ -103,7 +103,7 @@
* If a proper intersection was found, we can set a lower bound
* on the IM.
*/
- computeProperIntersectionIM(intersector, im);
+ computeProperIntersectionIM(intersector.get(), im.get());
/*
* Now process improper intersections
@@ -114,10 +114,14 @@
*/
// build EdgeEnds for all intersections
EdgeEndBuilder eeBuilder;
- std::vector<EdgeEnd*> *ee0=eeBuilder.computeEdgeEnds((*arg)[0]->getEdges());
- insertEdgeEnds(ee0);
- std::vector<EdgeEnd*> *ee1=eeBuilder.computeEdgeEnds((*arg)[1]->getEdges());
- insertEdgeEnds(ee1);
+ std::auto_ptr< std::vector<EdgeEnd*> > ee0 (
+ eeBuilder.computeEdgeEnds((*arg)[0]->getEdges())
+ );
+ insertEdgeEnds(ee0.get());
+ std::auto_ptr< std::vector<EdgeEnd*> > ee1 (
+ eeBuilder.computeEdgeEnds((*arg)[1]->getEdges())
+ );
+ insertEdgeEnds(ee1.get());
//Debug.println("==== NodeList ===");
//Debug.print(nodes);
labelNodeEdges();
@@ -138,13 +142,8 @@
//debugPrintln("Graph B isolated edges - ");
labelIsolatedEdges(1,0);
// update the IM from all components
- updateIM(im);
- delete si1;
- delete si2;
- delete intersector;
- delete ee0;
- delete ee1;
- return im;
+ updateIM(im.get());
+ return im.release();
}
void
@@ -295,10 +294,7 @@
}
}
-/**
- * If the Geometries are disjoint, we need to enter their dimension and
- * boundary dimension in the Ext rows in the IM
- */
+/* private */
void
RelateComputer::computeDisjointIM(IntersectionMatrix *imX)
{
@@ -330,9 +326,7 @@
}
}
-/**
- * update the IM with the sum of the IMs for each component
- */
+/*private*/
void
RelateComputer::updateIM(IntersectionMatrix *imX)
{
@@ -356,14 +350,10 @@
}
}
-/**
-* Processes isolated edges by computing their labelling and adding them
-* to the isolated edges list.
-* Isolated edges are guaranteed not to touch the boundary of the target (since if they
-* did, they would have caused an intersection to be computed and hence would
-* not be isolated)
-*/
-void RelateComputer::labelIsolatedEdges(int thisIndex,int targetIndex) {
+/*private*/
+void
+RelateComputer::labelIsolatedEdges(int thisIndex,int targetIndex)
+{
std::vector<Edge*> *edges=(*arg)[thisIndex]->getEdges();
for(std::vector<Edge*>::iterator i=edges->begin();i<edges->end();i++) {
Edge *e=*i;
@@ -374,11 +364,7 @@
}
}
-/**
- * Label an isolated edge of a graph with its relationship to the target geometry.
- * If the target has dim 2 or 1, the edge can either be in the interior or the exterior.
- * If the target has dim 0, the edge must be in the exterior
- */
+/* private */
void
RelateComputer::labelIsolatedEdge(Edge *e, int targetIndex, const Geometry *target)
{
@@ -395,15 +381,7 @@
//System.out.println(e.getLabel());
}
-/**
- * Isolated nodes are nodes whose labels are incomplete
- * (e.g. the location for one Geometry is null).
- * This is the case because nodes in one graph which don't intersect
- * nodes in the other are not completely labelled by the initial process
- * of adding nodes to the nodeList.
- * To complete the labelling we need to check for nodes that lie in the
- * interior of edges, and in the interior of areas.
- */
+/*private*/
void
RelateComputer::labelIsolatedNodes()
{
@@ -423,9 +401,7 @@
}
}
-/**
- * Label an isolated node with its relationship to the target geometry.
- */
+/* private */
void
RelateComputer::labelIsolatedNode(Node *n,int targetIndex)
{
@@ -439,24 +415,3 @@
} // namespace geos.operation
} // namespace geos
-/**********************************************************************
- * $Log$
- * Revision 1.32 2006/03/21 13:11:29 strk
- * opRelate.h header split
- *
- * Revision 1.31 2006/03/20 16:57:44 strk
- * spatialindex.h and opValid.h headers split
- *
- * Revision 1.30 2006/03/17 16:48:55 strk
- * LineIntersector and PointLocator made complete components of RelateComputer
- * (were statics const pointers before). Reduced inclusions from opRelate.h
- * and opValid.h, updated .cpp files to allow build.
- *
- * Revision 1.29 2006/03/09 16:46:49 strk
- * geos::geom namespace definition, first pass at headers split
- *
- * Revision 1.28 2006/03/06 19:40:47 strk
- * geos::util namespace. New GeometryCollection::iterator interface, many cleanups.
- *
- **********************************************************************/
-
More information about the geos-commits
mailing list