Skip to content
Permalink
Browse files
use combineFields to handle conflicts
  • Loading branch information
roya0045 authored and github-actions committed Dec 22, 2021
1 parent 4437bcd commit f729798d4f1e26c68fc5acd1b65716ec4f63b59b
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 f729798

Please sign in to comment.