Skip to content

Commit

Permalink
Make QgsPointLocator discard geometries that cannot be projected
Browse files Browse the repository at this point in the history
Fix #12634 (crash snapping in measure tool)
To be backported to 2.8 branch
  • Loading branch information
Sandro Santilli committed Apr 24, 2015
1 parent 876e54b commit 0480cab
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/core/qgspointlocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
{
QgsRectangle rect = *mExtent;
if ( mTransform )
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
{
try {
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
} catch (const QgsException& e) {
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform bounding box to map, skipping the snap filter (%1)").arg(e.what()) );
}
}
request.setFilterRect( rect );
}
QgsFeatureIterator fi = mLayer->getFeatures( request );
Expand All @@ -644,7 +651,15 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
continue;

if ( mTransform )
f.geometry()->transform( *mTransform );
{
try {
f.geometry()->transform( *mTransform );
} catch (const QgsException& e) {
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
continue;
}
}

SpatialIndex::Region r( rect2region( f.geometry()->boundingBox() ) );
dataList << new RTree::Data( 0, 0, r, f.id() );
Expand Down Expand Up @@ -708,7 +723,15 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
return;

if ( mTransform )
f.geometry()->transform( *mTransform );
{
try {
f.geometry()->transform( *mTransform );
} catch (const QgsException& e) {
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
return;
}
}

SpatialIndex::Region r( rect2region( f.geometry()->boundingBox() ) );
mRTree->insertData( 0, 0, r, f.id() );
Expand Down

0 comments on commit 0480cab

Please sign in to comment.