Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #29630 spatialindex for NaN points
  • Loading branch information
PeterPetrik committed May 30, 2019
1 parent 789a758 commit c2042a2
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
Expand Up @@ -668,13 +668,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 @@ -777,8 +781,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
Expand Up @@ -379,6 +379,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 c2042a2

Please sign in to comment.