Skip to content

Commit

Permalink
Rename addFeature member in QgsVectorFileWriter to avoid clash
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 15, 2017
1 parent 30d35c1 commit 2640626
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions python/core/qgsvectorfilewriter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,10 @@ Retrieves error message
virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );


bool addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );
bool addFeatureWithStyle( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );
%Docstring
Add feature to the currently opened data source
Adds a ``feature`` to the currently opened data source, using the style from a specified ``renderer``.
.. versionadded:: 3.0
:rtype: bool
%End

Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1836,23 +1836,23 @@ QString QgsVectorFileWriter::errorMessage()
return mErrorMessage;
}

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

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

bool QgsVectorFileWriter::addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit )
bool QgsVectorFileWriter::addFeatureWithStyle( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit )
{
// create the feature
OGRFeatureH poFeature = createFeature( feature );
Expand Down Expand Up @@ -2561,7 +2561,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer,
fet.initAttributes( 0 );
}

if ( !writer->addFeature( fet, layer->renderer(), mapUnits ) )
if ( !writer->addFeatureWithStyle( fet, layer->renderer(), mapUnits ) )
{
WriterError err = writer->hasError();
if ( err != NoError && errorMessage )
Expand Down
7 changes: 5 additions & 2 deletions src/core/qgsvectorfilewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,11 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 ) override;
bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 ) override;

//! Add feature to the currently opened data source
bool addFeature( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );
/**
* Adds a \a feature to the currently opened data source, using the style from a specified \a renderer.
* \since QGIS 3.0
*/
bool addFeatureWithStyle( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );

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

0 comments on commit 2640626

Please sign in to comment.