Skip to content
Permalink
Browse files

Some minor changes

- QgsVectorLayer *
- make a const copy of a const container
- typo and comments
  • Loading branch information
elpaso committed Sep 25, 2018
1 parent fb47dd9 commit a8dbb5395cc087f636babec73ff092a9d02f0358
@@ -177,12 +177,13 @@ are padded with NULL values to match the required length).
.. versionadded:: 3.4
%End

static const QgsFeatureList makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer &layer );
static const QgsFeatureList makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer *layer );
%Docstring
Converts input ``feature`` to be compatible with the given ``layer``.

This function returns a new list of transformed features compatible with the input
layer, note that the number of features returned might be greater than one.
layer, note that the number of features returned might be greater than one when
converting a multi part geometry to single part

The following operations will be performed to convert the input features:
- convert single geometries to multi part
@@ -196,13 +197,13 @@ The following operations will be performed to convert the input features:
.. versionadded:: 3.4
%End

static const QgsFeatureList makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer &layer );
static const QgsFeatureList makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer *layer );
%Docstring
Converts input ``features`` to be compatible with the given ``layer``.

This function returns a new list of transformed features compatible with the input
layer, note that the number of features returned might be greater than the number
of input featurers.
of input features.

The following operations will be performed to convert the input features:
- convert single geometries to multi part
@@ -561,13 +561,13 @@ void QgsVectorLayerUtils::matchAttributesToFields( QgsFeature &feature, const Qg
}
}

const QgsFeatureList QgsVectorLayerUtils::makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer &layer )
const QgsFeatureList QgsVectorLayerUtils::makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer *layer )
{
QgsWkbTypes::Type inputWkbType( layer.wkbType( ) );
QgsWkbTypes::Type inputWkbType( layer->wkbType( ) );
QgsFeatureList resultFeatures;
QgsFeature newF( feature );
// Fix attributes
QgsVectorLayerUtils::matchAttributesToFields( newF, layer.fields( ) );
QgsVectorLayerUtils::matchAttributesToFields( newF, layer->fields( ) );
// Does geometry need transformations?
QgsWkbTypes::GeometryType newFGeomType( QgsWkbTypes::geometryType( newF.geometry().wkbType() ) );
bool newFHasGeom = newFGeomType !=
@@ -579,7 +579,7 @@ const QgsFeatureList QgsVectorLayerUtils::makeFeatureCompatible( const QgsFeatur
// Drop geometry if layer is geometry-less
if ( newFHasGeom && ! layerHasGeom )
{
QgsFeature _f = QgsFeature( layer.fields() );
QgsFeature _f = QgsFeature( layer->fields() );
_f.setAttributes( newF.attributes() );
resultFeatures.append( _f );
}
@@ -634,7 +634,7 @@ const QgsFeatureList QgsVectorLayerUtils::makeFeatureCompatible( const QgsFeatur
for ( int i = 0; i < parts->partCount( ); i++ )
{
QgsGeometry g( parts->geometryN( i )->clone() );
QgsFeature _f( createFeature( &layer, g, attrMap ) );
QgsFeature _f( createFeature( layer, g, attrMap ) );
resultFeatures.append( _f );
}
}
@@ -651,12 +651,13 @@ const QgsFeatureList QgsVectorLayerUtils::makeFeatureCompatible( const QgsFeatur
return resultFeatures;
}

const QgsFeatureList QgsVectorLayerUtils::makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer &layer )
const QgsFeatureList QgsVectorLayerUtils::makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer *layer )
{
QgsFeatureList resultFeatures;
for ( const QgsFeature &f : features )
{
for ( const auto &_f : makeFeatureCompatible( f, layer ) )
const QgsFeatureList features( makeFeatureCompatible( f, layer ) );
for ( const auto &_f : features )
{
resultFeatures.append( _f );
}
@@ -192,7 +192,8 @@ class CORE_EXPORT QgsVectorLayerUtils
* Converts input \a feature to be compatible with the given \a layer.
*
* This function returns a new list of transformed features compatible with the input
* layer, note that the number of features returned might be greater than one.
* layer, note that the number of features returned might be greater than one when
* converting a multi part geometry to single part
*
* The following operations will be performed to convert the input features:
* - convert single geometries to multi part
@@ -205,14 +206,14 @@ class CORE_EXPORT QgsVectorLayerUtils
*
* \since QGIS 3.4
*/
static const QgsFeatureList makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer &layer );
static const QgsFeatureList makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer *layer );

/**
* Converts input \a features to be compatible with the given \a layer.
*
* This function returns a new list of transformed features compatible with the input
* layer, note that the number of features returned might be greater than the number
* of input featurers.
* of input features.
*
* The following operations will be performed to convert the input features:
* - convert single geometries to multi part
@@ -225,7 +226,7 @@ class CORE_EXPORT QgsVectorLayerUtils
*
* \since QGIS 3.4
*/
static const QgsFeatureList makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer &layer );
static const QgsFeatureList makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer *layer );

};

0 comments on commit a8dbb53

Please sign in to comment.
You can’t perform that action at this time.