Skip to content

Commit e87ac63

Browse files
PeterPetriknyalldawson
authored andcommittedMay 30, 2019
fix #29630 spatialindex for NaN points
1 parent 66815c1 commit e87ac63

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed
 

‎src/core/qgspointlocator.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,17 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
667667
}
668668
}
669669

670-
SpatialIndex::Region r( rect2region( f.geometry().boundingBox() ) );
671-
dataList << new RTree::Data( 0, nullptr, r, f.id() );
670+
const QgsRectangle bbox = f.geometry().boundingBox();
671+
if ( bbox.isFinite() )
672+
{
673+
SpatialIndex::Region r( rect2region( bbox ) );
674+
dataList << new RTree::Data( 0, nullptr, r, f.id() );
672675

673-
if ( mGeoms.contains( f.id() ) )
674-
delete mGeoms.take( f.id() );
675-
mGeoms[f.id()] = new QgsGeometry( f.geometry() );
676-
++indexedCount;
676+
if ( mGeoms.contains( f.id() ) )
677+
delete mGeoms.take( f.id() );
678+
mGeoms[f.id()] = new QgsGeometry( f.geometry() );
679+
++indexedCount;
680+
}
677681

678682
if ( maxFeaturesToIndex != -1 && indexedCount > maxFeaturesToIndex )
679683
{
@@ -776,8 +780,8 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
776780
}
777781
}
778782

779-
QgsRectangle bbox = f.geometry().boundingBox();
780-
if ( !bbox.isNull() )
783+
const QgsRectangle bbox = f.geometry().boundingBox();
784+
if ( bbox.isFinite() )
781785
{
782786
SpatialIndex::Region r( rect2region( bbox ) );
783787
mRTree->insertData( 0, nullptr, r, f.id() );

‎src/core/qgsspatialindex.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ bool QgsSpatialIndex::featureInfo( const QgsFeature &f, QgsRectangle &rect, QgsF
296296

297297
id = f.id();
298298
rect = f.geometry().boundingBox();
299+
300+
if ( !rect.isFinite() )
301+
return false;
302+
299303
return true;
300304
}
301305

0 commit comments

Comments
 (0)
Please sign in to comment.