Skip to content

Commit

Permalink
Handle GEOS exception when parsing WKT
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14904 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Dec 13, 2010
1 parent 1c32d26 commit f1ba5fe
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/core/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,22 @@ static QgsGeometry *fromGeosGeom( GEOSGeometry *geom )

QgsGeometry* QgsGeometry::fromWkt( QString wkt )
{
try
{
#if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR>=3)
GEOSWKTReader *reader = GEOSWKTReader_create();;
QgsGeometry *g = fromGeosGeom( GEOSWKTReader_read( reader, wkt.toLocal8Bit().data() ) );
GEOSWKTReader_destroy( reader );
return g;
GEOSWKTReader *reader = GEOSWKTReader_create();
QgsGeometry *g = fromGeosGeom( GEOSWKTReader_read( reader, wkt.toLocal8Bit().data() ) );
GEOSWKTReader_destroy( reader );
return g;
#else
return fromGeosGeom( GEOSGeomFromWKT( wkt.toLocal8Bit().data() ) );
return fromGeosGeom( GEOSGeomFromWKT( wkt.toLocal8Bit().data() ) );
#endif
}
catch ( GEOSException &e )
{
Q_UNUSED( e );
return 0;
}
}

QgsGeometry* QgsGeometry::fromPoint( const QgsPoint& point )
Expand Down

0 comments on commit f1ba5fe

Please sign in to comment.