mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Add sourceExtent method to QgsFeatureSource
This commit is contained in:
parent
72f95e6f1a
commit
c6c20c6114
@ -78,6 +78,14 @@ class QgsFeatureSource
|
||||
:rtype: set of QVariant
|
||||
%End
|
||||
|
||||
virtual QgsRectangle sourceExtent() const;
|
||||
%Docstring
|
||||
Returns the extent of all geometries from the source.
|
||||
The base class implementation uses a non-optimised approach of looping through
|
||||
all features in the source.
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -126,6 +126,8 @@ Bitmask of all provider's editing capabilities
|
||||
|
||||
virtual QgsCoordinateReferenceSystem sourceCrs() const;
|
||||
|
||||
virtual QgsRectangle sourceExtent() const;
|
||||
|
||||
|
||||
virtual QString dataComment() const;
|
||||
%Docstring
|
||||
|
@ -1103,10 +1103,8 @@ Synchronises with changes in the datasource
|
||||
|
||||
virtual QgsRectangle extent() const;
|
||||
|
||||
%Docstring
|
||||
Return the extent of the layer
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
virtual QgsRectangle sourceExtent() const;
|
||||
|
||||
|
||||
virtual QgsFields fields() const;
|
||||
%Docstring
|
||||
|
@ -40,3 +40,20 @@ QSet<QVariant> QgsFeatureSource::uniqueValues( int fieldIndex, int limit ) const
|
||||
return values;
|
||||
}
|
||||
|
||||
QgsRectangle QgsFeatureSource::sourceExtent() const
|
||||
{
|
||||
QgsRectangle r;
|
||||
|
||||
QgsFeatureRequest req;
|
||||
req.setSubsetOfAttributes( QgsAttributeList() );
|
||||
|
||||
QgsFeatureIterator it = getFeatures( req );
|
||||
QgsFeature f;
|
||||
while ( it.nextFeature( f ) )
|
||||
{
|
||||
if ( f.hasGeometry() )
|
||||
r.combineExtentWith( f.geometry().boundingBox() );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,13 @@ class CORE_EXPORT QgsFeatureSource
|
||||
*/
|
||||
virtual QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const;
|
||||
|
||||
/**
|
||||
* Returns the extent of all geometries from the source.
|
||||
* The base class implementation uses a non-optimised approach of looping through
|
||||
* all features in the source.
|
||||
*/
|
||||
virtual QgsRectangle sourceExtent() const;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( QgsFeatureSource * )
|
||||
|
@ -52,6 +52,11 @@ QgsCoordinateReferenceSystem QgsVectorDataProvider::sourceCrs() const
|
||||
return crs();
|
||||
}
|
||||
|
||||
QgsRectangle QgsVectorDataProvider::sourceExtent() const
|
||||
{
|
||||
return extent();
|
||||
}
|
||||
|
||||
QString QgsVectorDataProvider::dataComment() const
|
||||
{
|
||||
return QString();
|
||||
|
@ -159,6 +159,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
|
||||
virtual QgsFields fields() const override = 0;
|
||||
|
||||
QgsCoordinateReferenceSystem sourceCrs() const override;
|
||||
QgsRectangle sourceExtent() const override;
|
||||
|
||||
/**
|
||||
* Return a short comment for the data that this provider is
|
||||
|
@ -879,6 +879,11 @@ QgsRectangle QgsVectorLayer::extent() const
|
||||
return rect;
|
||||
}
|
||||
|
||||
QgsRectangle QgsVectorLayer::sourceExtent() const
|
||||
{
|
||||
return extent();
|
||||
}
|
||||
|
||||
QString QgsVectorLayer::subsetString() const
|
||||
{
|
||||
if ( !mValid || !mDataProvider )
|
||||
|
@ -1077,8 +1077,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
*/
|
||||
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
|
||||
|
||||
//! Return the extent of the layer
|
||||
QgsRectangle extent() const override;
|
||||
QgsRectangle sourceExtent() const override;
|
||||
|
||||
/**
|
||||
* Returns the list of fields of this layer.
|
||||
|
Loading…
x
Reference in New Issue
Block a user