Skip to content

Commit c2042a2

Browse files
committedMay 30, 2019
fix #29630 spatialindex for NaN points
1 parent 789a758 commit c2042a2

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
@@ -668,13 +668,17 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
668668
}
669669
}
670670

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

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

679683
if ( maxFeaturesToIndex != -1 && indexedCount > maxFeaturesToIndex )
680684
{
@@ -777,8 +781,8 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
777781
}
778782
}
779783

780-
QgsRectangle bbox = f.geometry().boundingBox();
781-
if ( !bbox.isNull() )
784+
const QgsRectangle bbox = f.geometry().boundingBox();
785+
if ( bbox.isFinite() )
782786
{
783787
SpatialIndex::Region r( rect2region( bbox ) );
784788
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
@@ -379,6 +379,10 @@ bool QgsSpatialIndex::featureInfo( const QgsFeature &f, QgsRectangle &rect, QgsF
379379

380380
id = f.id();
381381
rect = f.geometry().boundingBox();
382+
383+
if ( !rect.isFinite() )
384+
return false;
385+
382386
return true;
383387
}
384388

0 commit comments

Comments
 (0)
Please sign in to comment.