Skip to content
Permalink
Browse files
Fixed a crash occuring with identify tool which was caused by GEOS th…
…rowing TopologyException.

This exception might be thrown when GEOS has problems with calculating intersection.


git-svn-id: http://svn.osgeo.org/qgis/trunk@6071 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 10, 2006
1 parent da8d308 commit 60f7822
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
@@ -2076,9 +2076,17 @@ bool QgsGeometry::intersects(QgsRect* r) const
rectwkt+="))";

geos::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
if(geosGeom->intersects(geosRect))
try // geos might throw exception on error
{
returnval=true;
if(geosGeom->intersects(geosRect))
{
returnval=true;
}
}
catch (geos::TopologyException* e)
{
QString error = e->toString().c_str();
QgsLogger::warning("GEOS: " + error);
}

delete geosGeom;
@@ -2121,9 +2129,17 @@ bool QgsGeometry::fast_intersects(const QgsRect* r) const
geos::WKTReader *wktReader = new geos::WKTReader(gf);
geos::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );

if(geosGeom->intersects(geosRect))
try // geos might throw exception on error
{
if(geosGeom->intersects(geosRect))
{
returnval=true;
}
}
catch (geos::TopologyException* e)
{
returnval=true;
QString error = e->toString().c_str();
QgsLogger::warning("GEOS: " + error);
}

delete geosGeom;
@@ -423,7 +423,20 @@ QgsFeature *QgsOgrProvider::getNextFeature(bool fetchAttributes)
mSelectionRectangle->exportToWkt(&sWkt);
geos::Geometry *geosRect = wktReader->read(sWkt);
assert(geosRect != 0);
if(geosGeom->intersects(geosRect))
bool intersection = false;

try // geos might throw exception on error
{
if(geosGeom->intersects(geosRect))
intersection = true;
}
catch (geos::TopologyException* e)
{
QString error = e->toString().c_str();
QgsLogger::warning("GEOS: " + error);
}

if (intersection)
{
QgsDebugMsg("intersection found");
delete[] sWkt;

0 comments on commit 60f7822

Please sign in to comment.