-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4416 from nyalldawson/feature_sink
Add a QgsFeatureSink interface
- Loading branch information
Showing
30 changed files
with
414 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsfeaturesink.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsFeatureSink | ||
{ | ||
%Docstring | ||
An interface for objects which accept features via addFeature(s) methods. | ||
|
||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsfeaturesink.h" | ||
%End | ||
public: | ||
|
||
virtual ~QgsFeatureSink(); | ||
|
||
virtual bool addFeature( QgsFeature &feature ); | ||
%Docstring | ||
Adds a single ``feature`` to the sink. | ||
\see addFeatures() | ||
:return: true in case of success and false in case of failure | ||
:rtype: bool | ||
%End | ||
|
||
virtual bool addFeatures( QgsFeatureList &features ) = 0; | ||
%Docstring | ||
Adds a list of ``features`` to the sink. | ||
\see addFeature() | ||
:return: true in case of success and false in case of failure | ||
:rtype: bool | ||
%End | ||
|
||
virtual bool addFeatures( QgsFeatureIterator &iterator ); | ||
%Docstring | ||
Adds all features from the specified ``iterator`` to the sink. | ||
:return: true if all features were added successfully, or false if any feature could not be added | ||
:rtype: bool | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsfeaturesink.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,92 @@ | ||
class QgsFeatureStore | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsfeaturestore.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
class QgsFeatureStore : QgsFeatureSink | ||
{ | ||
%Docstring | ||
A container for features with the same fields and crs. | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include <qgsfeaturestore.h> | ||
#include "qgsfeaturestore.h" | ||
%End | ||
public: | ||
//! Constructor | ||
QgsFeatureStore(); | ||
%Docstring | ||
Constructor | ||
%End | ||
|
||
//! Constructor | ||
QgsFeatureStore( const QgsFields& fields, const QgsCoordinateReferenceSystem& crs ); | ||
QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs ); | ||
%Docstring | ||
Constructor | ||
%End | ||
|
||
/** Get fields list */ | ||
QgsFields& fields(); | ||
QgsFields fields() const; | ||
%Docstring | ||
Returns the store's field list. | ||
\see setFields() | ||
:rtype: QgsFields | ||
%End | ||
|
||
/** Set fields. Resets feature's fields to pointer to new internal fields. */ | ||
void setFields( const QgsFields & fields ); | ||
void setFields( const QgsFields &fields ); | ||
%Docstring | ||
Sets the store's ``fields``. Every contained feature's fields will be reset to match ``fields``. | ||
\see fields() | ||
%End | ||
|
||
/** Get crs */ | ||
QgsCoordinateReferenceSystem crs() const; | ||
%Docstring | ||
Returns the store's coordinate reference system. | ||
\see setCrs() | ||
:rtype: QgsCoordinateReferenceSystem | ||
%End | ||
|
||
void setCrs( const QgsCoordinateReferenceSystem &crs ); | ||
%Docstring | ||
Sets the store's ``crs``. | ||
\see crs() | ||
%End | ||
|
||
/** Set crs */ | ||
void setCrs( const QgsCoordinateReferenceSystem& crs ); | ||
virtual bool addFeature( QgsFeature &feature ); | ||
|
||
/** Add feature. Feature's fields will be set to pointer to the store fields. | ||
* @param feature | ||
* @note added in 2.1 | ||
*/ | ||
void addFeature( const QgsFeature& feature ); | ||
virtual bool addFeatures( QgsFeatureList &features ); | ||
|
||
/** Get features list reference */ | ||
QgsFeatureList& features(); | ||
|
||
/** Set map of optional parameters */ | ||
void setParams( const QMap<QString, QVariant> ¶ms ); | ||
QgsFeatureList features() const; | ||
%Docstring | ||
Returns the list of features contained in the store. | ||
:rtype: QgsFeatureList | ||
%End | ||
|
||
void setParams( const QMap<QString, QVariant> ¶meters ); | ||
%Docstring | ||
Sets a map of optional ``parameters`` for the store. | ||
\see params() | ||
%End | ||
|
||
/** Get map of optional parameters */ | ||
QMap<QString, QVariant> params() const; | ||
%Docstring | ||
Returns the map of optional parameters. | ||
\see setParams() | ||
:rtype: QMap<str, QVariant> | ||
%End | ||
|
||
}; | ||
|
||
typedef QList<QgsFeatureStore> QgsFeatureStoreList; | ||
|
||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsfeaturestore.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*************************************************************************** | ||
qgsfeaturesink.cpp | ||
------------------ | ||
begin : April 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsfeaturestore.h" | ||
|
||
bool QgsFeatureSink::addFeature( QgsFeature &feature ) | ||
{ | ||
QgsFeatureList features; | ||
features << feature; | ||
bool result = addFeatures( features ); | ||
|
||
// need to update the passed feature reference to the updated copy from the features list | ||
feature = features.at( 0 ); | ||
return result; | ||
} | ||
|
||
bool QgsFeatureSink::addFeatures( QgsFeatureIterator &iterator ) | ||
{ | ||
QgsFeature f; | ||
bool result = true; | ||
while ( iterator.nextFeature( f ) ) | ||
{ | ||
result = result && addFeature( f ); | ||
} | ||
return result; | ||
} | ||
|
Oops, something went wrong.