Fixed a crash occuring with identify tool which was caused by GEOS throwing 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
This commit is contained in:
wonder 2006-11-10 21:36:37 +00:00
parent da8d308b1a
commit 60f7822a6e
2 changed files with 34 additions and 5 deletions

View File

@ -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
{
returnval=true;
if(geosGeom->intersects(geosRect))
{
returnval=true;
}
}
catch (geos::TopologyException* e)
{
QString error = e->toString().c_str();
QgsLogger::warning("GEOS: " + error);
}
delete geosGeom;

View File

@ -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;