Skip to content

Commit

Permalink
fix #29630 spatialindex for NaN points
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik authored and nyalldawson committed May 30, 2019
1 parent 66815c1 commit e87ac63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/core/qgspointlocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,17 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
}
}

SpatialIndex::Region r( rect2region( f.geometry().boundingBox() ) );
dataList << new RTree::Data( 0, nullptr, r, f.id() );
const QgsRectangle bbox = f.geometry().boundingBox();
if ( bbox.isFinite() )
{
SpatialIndex::Region r( rect2region( bbox ) );
dataList << new RTree::Data( 0, nullptr, r, f.id() );

if ( mGeoms.contains( f.id() ) )
delete mGeoms.take( f.id() );
mGeoms[f.id()] = new QgsGeometry( f.geometry() );
++indexedCount;
if ( mGeoms.contains( f.id() ) )
delete mGeoms.take( f.id() );
mGeoms[f.id()] = new QgsGeometry( f.geometry() );
++indexedCount;
}

if ( maxFeaturesToIndex != -1 && indexedCount > maxFeaturesToIndex )
{
Expand Down Expand Up @@ -776,8 +780,8 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
}
}

QgsRectangle bbox = f.geometry().boundingBox();
if ( !bbox.isNull() )
const QgsRectangle bbox = f.geometry().boundingBox();
if ( bbox.isFinite() )
{
SpatialIndex::Region r( rect2region( bbox ) );
mRTree->insertData( 0, nullptr, r, f.id() );
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsspatialindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ bool QgsSpatialIndex::featureInfo( const QgsFeature &f, QgsRectangle &rect, QgsF

id = f.id();
rect = f.geometry().boundingBox();

if ( !rect.isFinite() )
return false;

return true;
}

Expand Down

0 comments on commit e87ac63

Please sign in to comment.