Skip to content
Permalink
Browse files

harmonize join type value (0=one-to-many, 1=one-to-one)

  • Loading branch information
nirvn committed Mar 2, 2018
1 parent 1542b48 commit 2073562fa5d2200d7d2f08d6e6a870e291ac8b8b
@@ -2774,7 +2774,6 @@ tests:
- algorithm: native:joinattributestable
name: join the attribute table by common field (one-to-one)
params:
METHOD: 0
INPUT:
name: points.gml
type: vector
@@ -2791,7 +2790,7 @@ tests:
- algorithm: native:joinattributestable
name: join the attribute table by common field, discard non matching (one-to-one)
params:
METHOD: 0
METHOD: 1
INPUT:
name: points.gml
type: vector
@@ -2809,7 +2808,7 @@ tests:
- algorithm: native:joinattributestable
name: join the attribute table by common field (one-to-many)
params:
METHOD: 1
METHOD: 0
INPUT:
name: points.gml
type: vector
@@ -2826,7 +2825,6 @@ tests:
- algorithm: native:joinattributestable
name: Join attributes table with subset of fields
params:
METHOD: 0
FIELD: id
FIELDS_TO_COPY:
- NUM_A
@@ -47,8 +47,8 @@ QString QgsJoinByAttributeAlgorithm::groupId() const
void QgsJoinByAttributeAlgorithm::initAlgorithm( const QVariantMap & )
{
QStringList methods;
methods << QObject::tr( "Take attributes of the first matching feature only (one-to-one)" )
<< QObject::tr( "Create separate feature for each matching feature (one-to-many)" );
methods << QObject::tr( "Create separate feature for each matching feature (one-to-many)" )
<< QObject::tr( "Take attributes of the first matching feature only (one-to-one)" );

addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ),
QObject::tr( "Input layer" ), QList< int>() << QgsProcessing::TypeVector ) );
@@ -67,7 +67,7 @@ void QgsJoinByAttributeAlgorithm::initAlgorithm( const QVariantMap & )

addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ),
QObject::tr( "Join type" ),
methods, false, 0 ) );
methods, false, 1 ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "DISCARD_NONMATCHING" ),
QObject::tr( "Discard records which could not be joined" ),
false ) );
@@ -158,7 +158,7 @@ QVariantMap QgsJoinByAttributeAlgorithm::processAlgorithm( const QVariantMap &pa

feedback->setProgress( i * step );

if ( joinMethod == 0 && input2AttributeCache.contains( feat.attribute( joinField2Index ) ) )
if ( joinMethod == 1 && input2AttributeCache.contains( feat.attribute( joinField2Index ) ) )
continue;

// only keep selected attributes

0 comments on commit 2073562

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