Skip to content

Commit dccc1c3

Browse files
author
wonder
committedNov 10, 2006
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/qgis@6071 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed
 

‎src/core/qgsgeometry.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,9 +2076,17 @@ bool QgsGeometry::intersects(QgsRect* r) const
20762076
rectwkt+="))";
20772077

20782078
geos::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
2079-
if(geosGeom->intersects(geosRect))
2079+
try // geos might throw exception on error
20802080
{
2081-
returnval=true;
2081+
if(geosGeom->intersects(geosRect))
2082+
{
2083+
returnval=true;
2084+
}
2085+
}
2086+
catch (geos::TopologyException* e)
2087+
{
2088+
QString error = e->toString().c_str();
2089+
QgsLogger::warning("GEOS: " + error);
20822090
}
20832091

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

2124-
if(geosGeom->intersects(geosRect))
2132+
try // geos might throw exception on error
2133+
{
2134+
if(geosGeom->intersects(geosRect))
2135+
{
2136+
returnval=true;
2137+
}
2138+
}
2139+
catch (geos::TopologyException* e)
21252140
{
2126-
returnval=true;
2141+
QString error = e->toString().c_str();
2142+
QgsLogger::warning("GEOS: " + error);
21272143
}
21282144

21292145
delete geosGeom;

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,20 @@ QgsFeature *QgsOgrProvider::getNextFeature(bool fetchAttributes)
423423
mSelectionRectangle->exportToWkt(&sWkt);
424424
geos::Geometry *geosRect = wktReader->read(sWkt);
425425
assert(geosRect != 0);
426-
if(geosGeom->intersects(geosRect))
426+
bool intersection = false;
427+
428+
try // geos might throw exception on error
429+
{
430+
if(geosGeom->intersects(geosRect))
431+
intersection = true;
432+
}
433+
catch (geos::TopologyException* e)
434+
{
435+
QString error = e->toString().c_str();
436+
QgsLogger::warning("GEOS: " + error);
437+
}
438+
439+
if (intersection)
427440
{
428441
QgsDebugMsg("intersection found");
429442
delete[] sWkt;

0 commit comments

Comments
 (0)
Please sign in to comment.