mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-08 00:05:32 -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 )
|
, mDiagramRenderer( 0 )
|
||||||
, mDiagramLayerSettings( 0 )
|
, mDiagramLayerSettings( 0 )
|
||||||
, mValidExtent( false )
|
, mValidExtent( false )
|
||||||
|
, mLazyExtent( true )
|
||||||
, mSymbolFeatureCounted( false )
|
, mSymbolFeatureCounted( false )
|
||||||
, mCurrentRendererContext( 0 )
|
, mCurrentRendererContext( 0 )
|
||||||
|
|
||||||
@ -1179,15 +1180,30 @@ void QgsVectorLayer::setExtent( const QgsRectangle &r )
|
|||||||
|
|
||||||
QgsRectangle QgsVectorLayer::extent()
|
QgsRectangle QgsVectorLayer::extent()
|
||||||
{
|
{
|
||||||
if ( mValidExtent )
|
|
||||||
return QgsMapLayer::extent();
|
|
||||||
|
|
||||||
QgsRectangle rect;
|
QgsRectangle rect;
|
||||||
rect.setMinimal();
|
rect.setMinimal();
|
||||||
|
|
||||||
if ( !hasGeometryType() )
|
if ( !hasGeometryType() )
|
||||||
return rect;
|
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 )
|
if ( !mDataProvider )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( "invoked with null 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
|
// TODO: Check if the provider has the capability to send fullExtentCalculated
|
||||||
connect( mDataProvider, SIGNAL( fullExtentCalculated() ), this, SLOT( updateExtents() ) );
|
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
|
// get and store the feature type
|
||||||
mWkbType = mDataProvider->geometryType();
|
mWkbType = mDataProvider->geometryType();
|
||||||
|
|
||||||
|
@ -1756,6 +1756,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
|||||||
QgsDiagramLayerSettings *mDiagramLayerSettings;
|
QgsDiagramLayerSettings *mDiagramLayerSettings;
|
||||||
|
|
||||||
bool mValidExtent;
|
bool mValidExtent;
|
||||||
|
bool mLazyExtent;
|
||||||
|
|
||||||
// Features in renderer classes counted
|
// Features in renderer classes counted
|
||||||
bool mSymbolFeatureCounted;
|
bool mSymbolFeatureCounted;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user