Skip to content
Permalink
Browse files
use combineFields to handle conflicts
  • Loading branch information
roya0045 authored and nyalldawson committed Dec 23, 2021
1 parent 96ad33f commit 5ac07f57e6392aed2a2c37a455cd394155ec9d0d
Showing with 9 additions and 6 deletions.
  1. +9 −6 src/analysis/processing/qgsalgorithmjoinbynearest.cpp
@@ -169,12 +169,15 @@ QVariantMap QgsJoinByNearestAlgorithm::processAlgorithm( const QVariantMap &para
const QgsAttributeList fields2Fetch = fields2Indices;

QgsFields outFields = QgsProcessingUtils::combineFields( input->fields(), outFields2 );
outFields.append( QgsField( QStringLiteral( "n" ), QVariant::Int ) );
outFields.append( QgsField( QStringLiteral( "distance" ), QVariant::Double ) );
outFields.append( QgsField( QStringLiteral( "feature_x" ), QVariant::Double ) );
outFields.append( QgsField( QStringLiteral( "feature_y" ), QVariant::Double ) );
outFields.append( QgsField( QStringLiteral( "nearest_x" ), QVariant::Double ) );
outFields.append( QgsField( QStringLiteral( "nearest_y" ), QVariant::Double ) );

QgsFields resultFields;
resultFields.append( QgsField( QStringLiteral( "n" ), QVariant::Int ) );
resultFields.append( QgsField( QStringLiteral( "distance" ), QVariant::Double ) );
resultFields.append( QgsField( QStringLiteral( "feature_x" ), QVariant::Double ) );
resultFields.append( QgsField( QStringLiteral( "feature_y" ), QVariant::Double ) );
resultFields.append( QgsField( QStringLiteral( "nearest_x" ), QVariant::Double ) );
resultFields.append( QgsField( QStringLiteral( "nearest_y" ), QVariant::Double ) );
outFields = QgsProcessingUtils::combineFields( outFields, resultFields );

QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, outFields,

0 comments on commit 5ac07f5

Please sign in to comment.