Skip to content

Commit

Permalink
Fixed a crash occuring with identify tool which was caused by GEOS th…
Browse files Browse the repository at this point in the history
…rowing TopologyException.

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


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6071 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 10, 2006
1 parent d1d3a1e commit dccc1c3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/core/qgsgeometry.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit dccc1c3

Please sign in to comment.