Skip to content
Permalink
Browse files
QgsVectorFileWriter is a QgsFeatureSink
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 8d0a9d6 commit 8d598337f3ffe6b7d050d3e5efe7a290fa5cc443
Showing with 26 additions and 4 deletions.
  1. +5 −2 python/core/qgsvectorfilewriter.sip
  2. +16 −0 src/core/qgsvectorfilewriter.cpp
  3. +5 −2 src/core/qgsvectorfilewriter.h
@@ -4,7 +4,7 @@
1. static call to QgsVectorFileWriter::writeAsVectorFormat(...) which saves the whole vector layer
2. create an instance of the class and issue calls to addFeature(...)
*/
class QgsVectorFileWriter
class QgsVectorFileWriter : QgsFeatureSink
{
%TypeHeaderCode
#include <qgsvectorfilewriter.h>
@@ -380,8 +380,11 @@ class QgsVectorFileWriter
/** Retrieves error message */
QString errorMessage();

bool addFeature( QgsFeature &feature /In,Out/ );
bool addFeatures( QgsFeatureList &features /In,Out/ );

/** Add feature to the currently opened data source */
bool addFeature( QgsFeature& feature, QgsFeatureRenderer* renderer = 0, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );
bool addFeature( QgsFeature& feature, QgsFeatureRenderer* renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );

//! @note not available in python bindings
// QMap<int, int> attrIdxToOgrIdx();
@@ -1818,6 +1818,22 @@ QString QgsVectorFileWriter::errorMessage()
return mErrorMessage;
}

bool QgsVectorFileWriter::addFeature( QgsFeature &feature )
{
return addFeature( feature, nullptr, QgsUnitTypes::DistanceMeters );
}

bool QgsVectorFileWriter::addFeatures( QgsFeatureList &features )
{
QgsFeatureList::iterator fIt = features.begin();
bool result = true;
for ( ; fIt != features.end(); ++fIt )
{
result = result && addFeature( *fIt, nullptr, QgsUnitTypes::DistanceMeters );
}
return result;
}

bool QgsVectorFileWriter::addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit )
{
// create the feature
@@ -40,7 +40,7 @@ class QgsFeatureIterator;
1. static call to QgsVectorFileWriter::writeAsVectorFormat(...) which saves the whole vector layer
2. create an instance of the class and issue calls to addFeature(...)
*/
class CORE_EXPORT QgsVectorFileWriter
class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
{
public:
enum OptionType
@@ -497,8 +497,11 @@ class CORE_EXPORT QgsVectorFileWriter
//! Retrieves error message
QString errorMessage();

bool addFeature( QgsFeature &feature ) override;
bool addFeatures( QgsFeatureList &features ) override;

//! Add feature to the currently opened data source
bool addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer = nullptr, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );
bool addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );

//! \note not available in Python bindings
QMap<int, int> attrIdxToOgrIdx() { return mAttrIdxToOgrIdx; }

0 comments on commit 8d59833

Please sign in to comment.