mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-28 00:04:04 -04:00
vector layer: fix lazy extent calculation (fixes #9608; introduced in 500116bfe)
This commit is contained in:
parent
55cb04c52c
commit
a1ada3c54c
@ -136,6 +136,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
|
||||
, mDiagramRenderer( 0 )
|
||||
, mDiagramLayerSettings( 0 )
|
||||
, mValidExtent( false )
|
||||
, mLazyExtent( true )
|
||||
, mSymbolFeatureCounted( false )
|
||||
, mCurrentRendererContext( 0 )
|
||||
|
||||
@ -1179,15 +1180,30 @@ void QgsVectorLayer::setExtent( const QgsRectangle &r )
|
||||
|
||||
QgsRectangle QgsVectorLayer::extent()
|
||||
{
|
||||
if ( mValidExtent )
|
||||
return QgsMapLayer::extent();
|
||||
|
||||
QgsRectangle rect;
|
||||
rect.setMinimal();
|
||||
|
||||
if ( !hasGeometryType() )
|
||||
return rect;
|
||||
|
||||
if ( !mValidExtent && mLazyExtent && mDataProvider )
|
||||
{
|
||||
// get the extent
|
||||
QgsRectangle mbr = mDataProvider->extent();
|
||||
|
||||
// show the extent
|
||||
QString s = mbr.toString();
|
||||
|
||||
QgsDebugMsg( "Extent of layer: " + s );
|
||||
// store the extent
|
||||
setExtent( mbr );
|
||||
|
||||
mLazyExtent = false;
|
||||
}
|
||||
|
||||
if( mValidExtent )
|
||||
return QgsMapLayer::extent();
|
||||
|
||||
if ( !mDataProvider )
|
||||
{
|
||||
QgsDebugMsg( "invoked with null mDataProvider" );
|
||||
@ -1704,17 +1720,6 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
|
||||
// TODO: Check if the provider has the capability to send fullExtentCalculated
|
||||
connect( mDataProvider, SIGNAL( fullExtentCalculated() ), this, SLOT( updateExtents() ) );
|
||||
|
||||
#if 0 // allow lazy calculation of extents and give the creator of the vector layer a chance to 'manually' setExtent
|
||||
// get the extent
|
||||
QgsRectangle mbr = mDataProvider->extent();
|
||||
|
||||
// show the extent
|
||||
QString s = mbr.toString();
|
||||
QgsDebugMsg( "Extent of layer: " + s );
|
||||
// store the extent
|
||||
setExtent( mbr );
|
||||
#endif
|
||||
|
||||
// get and store the feature type
|
||||
mWkbType = mDataProvider->geometryType();
|
||||
|
||||
|
@ -1756,6 +1756,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
QgsDiagramLayerSettings *mDiagramLayerSettings;
|
||||
|
||||
bool mValidExtent;
|
||||
bool mLazyExtent;
|
||||
|
||||
// Features in renderer classes counted
|
||||
bool mSymbolFeatureCounted;
|
||||
|
Loading…
x
Reference in New Issue
Block a user