mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
QgsVectorFileWriter is a QgsFeatureSink
This commit is contained in:
parent
8d0a9d6bce
commit
8d598337f3
@ -4,7 +4,7 @@
|
|||||||
1. static call to QgsVectorFileWriter::writeAsVectorFormat(...) which saves the whole vector layer
|
1. static call to QgsVectorFileWriter::writeAsVectorFormat(...) which saves the whole vector layer
|
||||||
2. create an instance of the class and issue calls to addFeature(...)
|
2. create an instance of the class and issue calls to addFeature(...)
|
||||||
*/
|
*/
|
||||||
class QgsVectorFileWriter
|
class QgsVectorFileWriter : QgsFeatureSink
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgsvectorfilewriter.h>
|
#include <qgsvectorfilewriter.h>
|
||||||
@ -380,8 +380,11 @@ class QgsVectorFileWriter
|
|||||||
/** Retrieves error message */
|
/** Retrieves error message */
|
||||||
QString errorMessage();
|
QString errorMessage();
|
||||||
|
|
||||||
|
bool addFeature( QgsFeature &feature /In,Out/ );
|
||||||
|
bool addFeatures( QgsFeatureList &features /In,Out/ );
|
||||||
|
|
||||||
/** Add feature to the currently opened data source */
|
/** 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
|
//! @note not available in python bindings
|
||||||
// QMap<int, int> attrIdxToOgrIdx();
|
// QMap<int, int> attrIdxToOgrIdx();
|
||||||
|
@ -1818,6 +1818,22 @@ QString QgsVectorFileWriter::errorMessage()
|
|||||||
return mErrorMessage;
|
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 )
|
bool QgsVectorFileWriter::addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit )
|
||||||
{
|
{
|
||||||
// create the feature
|
// create the feature
|
||||||
|
@ -40,7 +40,7 @@ class QgsFeatureIterator;
|
|||||||
1. static call to QgsVectorFileWriter::writeAsVectorFormat(...) which saves the whole vector layer
|
1. static call to QgsVectorFileWriter::writeAsVectorFormat(...) which saves the whole vector layer
|
||||||
2. create an instance of the class and issue calls to addFeature(...)
|
2. create an instance of the class and issue calls to addFeature(...)
|
||||||
*/
|
*/
|
||||||
class CORE_EXPORT QgsVectorFileWriter
|
class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum OptionType
|
enum OptionType
|
||||||
@ -497,8 +497,11 @@ class CORE_EXPORT QgsVectorFileWriter
|
|||||||
//! Retrieves error message
|
//! Retrieves error message
|
||||||
QString errorMessage();
|
QString errorMessage();
|
||||||
|
|
||||||
|
bool addFeature( QgsFeature &feature ) override;
|
||||||
|
bool addFeatures( QgsFeatureList &features ) override;
|
||||||
|
|
||||||
//! Add feature to the currently opened data source
|
//! 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
|
//! \note not available in Python bindings
|
||||||
QMap<int, int> attrIdxToOgrIdx() { return mAttrIdxToOgrIdx; }
|
QMap<int, int> attrIdxToOgrIdx() { return mAttrIdxToOgrIdx; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user