Skip to content
Permalink
Browse files
Add crs, fields, wkbType and featureCount to QgsFeatureSource
  • Loading branch information
nyalldawson committed May 25, 2017
1 parent 8bfeb8f commit 4647662664f00a61afbae9283faa5c127cf69746
@@ -9,6 +9,7 @@




class QgsFeatureSource
{
%Docstring
@@ -32,8 +33,45 @@ class QgsFeatureSource
:rtype: QgsFeatureIterator
%End

virtual QgsCoordinateReferenceSystem sourceCrs() const = 0;
%Docstring
Returns the coordinate reference system for features in the source.
:rtype: QgsCoordinateReferenceSystem
%End

virtual QgsFields fields() const = 0;
%Docstring
Returns the fields associated with features in the source.
:rtype: QgsFields
%End

virtual QgsWkbTypes::Type wkbType() const = 0;
%Docstring
Returns the geometry type for features returned by this source.
:rtype: QgsWkbTypes.Type
%End


int __len__() const;
%Docstring
Returns the number of features contained in the source, or -1
if the feature count is unknown.
:rtype: int
%End
%MethodCode
sipRes = sipCpp->featureCount();
%End

virtual long featureCount() const = 0;
%Docstring
Returns the number of features contained in the source, or -1
if the feature count is unknown.
:rtype: long
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -124,6 +124,9 @@ Bitmask of all provider's editing capabilities
:rtype: QgsFields
%End

virtual QgsCoordinateReferenceSystem sourceCrs() const;


virtual QString dataComment() const;
%Docstring
Return a short comment for the data that this provider is
@@ -685,7 +685,8 @@ Returns true if this is a geometry layer and false in case of NoGeometry (table
:rtype: bool
%End

QgsWkbTypes::Type wkbType() const;
virtual QgsWkbTypes::Type wkbType() const;

%Docstring
Returns the WKBType or WKBUnknown in case of error
:rtype: QgsWkbTypes.Type
@@ -697,6 +698,9 @@ Return the provider type for this layer
:rtype: str
%End

virtual QgsCoordinateReferenceSystem sourceCrs() const;


virtual bool readXml( const QDomNode &layer_node, const QgsReadWriteContext &context );
%Docstring
Reads vector layer specific state from project file Dom node.
@@ -1104,7 +1108,7 @@ Return the extent of the layer
:rtype: QgsRectangle
%End

QgsFields fields() const;
virtual QgsFields fields() const;
%Docstring
Returns the list of fields of this layer.
This also includes fields which have not yet been saved to the provider.
@@ -1157,7 +1161,8 @@ Returns list of attributes making up the primary key
:rtype: long
%End

long featureCount() const;
virtual long featureCount() const;

%Docstring
Returns feature count including changes which have not yet been committed
If you need only the count of committed features call this method on this layer's provider.
@@ -20,8 +20,11 @@

#include "qgis_core.h"
#include "qgis.h"
#include "qgsfeature.h"
#include "qgsfeatureiterator.h"

class QgsFeatureIterator;
class QgsFeatureRequest;
class QgsCoordinateReferenceSystem;
class QgsFields;

/**
* \class QgsFeatureSource
@@ -43,6 +46,39 @@ class CORE_EXPORT QgsFeatureSource
*/
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const = 0;

/**
* Returns the coordinate reference system for features in the source.
*/
virtual QgsCoordinateReferenceSystem sourceCrs() const = 0;

/**
* Returns the fields associated with features in the source.
*/
virtual QgsFields fields() const = 0;

/**
* Returns the geometry type for features returned by this source.
*/
virtual QgsWkbTypes::Type wkbType() const = 0;

#ifdef SIP_RUN

/**
* Returns the number of features contained in the source, or -1
* if the feature count is unknown.
*/
int __len__() const;
% MethodCode
sipRes = sipCpp->featureCount();
% End
#endif

/**
* Returns the number of features contained in the source, or -1
* if the feature count is unknown.
*/
virtual long featureCount() const = 0;

};

#endif // QGSFEATURESOURCE_H
@@ -47,6 +47,11 @@ QString QgsVectorDataProvider::storageType() const
return QStringLiteral( "Generic vector file" );
}

QgsCoordinateReferenceSystem QgsVectorDataProvider::sourceCrs() const
{
return crs();
}

QString QgsVectorDataProvider::dataComment() const
{
return QString();
@@ -158,6 +158,8 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
*/
virtual QgsFields fields() const = 0;

QgsCoordinateReferenceSystem sourceCrs() const override;

/**
* Return a short comment for the data that this provider is
* providing access to (e.g. the comment for postgres table).
@@ -309,6 +309,11 @@ QString QgsVectorLayer::providerType() const
return mProviderKey;
}

QgsCoordinateReferenceSystem QgsVectorLayer::sourceCrs() const
{
return crs();
}

void QgsVectorLayer::reload()
{
if ( mDataProvider )
@@ -691,11 +691,13 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
bool hasGeometryType() const;

//! Returns the WKBType or WKBUnknown in case of error
QgsWkbTypes::Type wkbType() const;
QgsWkbTypes::Type wkbType() const override;

//! Return the provider type for this layer
QString providerType() const;

QgsCoordinateReferenceSystem sourceCrs() const override;

/** Reads vector layer specific state from project file Dom node.
* \note Called by QgsMapLayer::readXml().
*/
@@ -1083,7 +1085,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*
* \returns A list of fields
*/
inline QgsFields fields() const { return mFields; }
inline QgsFields fields() const override { return mFields; }

/**
* Returns the list of fields of this layer.
@@ -1125,7 +1127,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* Returns feature count including changes which have not yet been committed
* If you need only the count of committed features call this method on this layer's provider.
*/
long featureCount() const;
long featureCount() const override;

/** Make layer read-only (editing disabled) or not
* \returns false if the layer is in editing yet

0 comments on commit 4647662

Please sign in to comment.