Skip to content
Permalink
Browse files

[processing] Fix hasGeometry() method when output is a geometry-less …

…vector table

From the dox for QgsProcessing.TypeVector: "When used for a sink this indicates
the sink has no geometry.". If an algorithm is using this value to indicate
"maybe has geometry" for an output, then that algorithm is incorrect and
should be using TypeVectorAnyGeometry instead.
  • Loading branch information
nyalldawson committed Dec 3, 2018
1 parent e1b3524 commit 583b602e76d013d764541d44cb269e331d4a353c
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/core/processing/qgsprocessingparameters.cpp
  2. +2 −2 tests/src/analysis/testqgsprocessing.cpp
@@ -3754,11 +3754,11 @@ bool QgsProcessingParameterFeatureSink::hasGeometry() const
case QgsProcessing::TypeVectorPoint:
case QgsProcessing::TypeVectorLine:
case QgsProcessing::TypeVectorPolygon:
case QgsProcessing::TypeVector:
return true;

case QgsProcessing::TypeRaster:
case QgsProcessing::TypeFile:
case QgsProcessing::TypeVector:
return false;
}
return true;
@@ -4314,11 +4314,11 @@ bool QgsProcessingParameterVectorDestination::hasGeometry() const
case QgsProcessing::TypeVectorPoint:
case QgsProcessing::TypeVectorLine:
case QgsProcessing::TypeVectorPolygon:
case QgsProcessing::TypeVector:
return true;

case QgsProcessing::TypeRaster:
case QgsProcessing::TypeFile:
case QgsProcessing::TypeVector:
return false;
}
return true;
@@ -4665,7 +4665,7 @@ void TestQgsProcessing::parameterFeatureSink()
QVERIFY( QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeVectorPolygon ).hasGeometry() );
QVERIFY( !QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeRaster ).hasGeometry() );
QVERIFY( !QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeFile ).hasGeometry() );
QVERIFY( QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeVector ).hasGeometry() );
QVERIFY( !QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeVector ).hasGeometry() );

// invalidSinkError
QVariantMap params;
@@ -4783,7 +4783,7 @@ void TestQgsProcessing::parameterVectorOut()
QVERIFY( QgsProcessingParameterVectorDestination( "test", QString(), QgsProcessing::TypeVectorPolygon ).hasGeometry() );
QVERIFY( !QgsProcessingParameterVectorDestination( "test", QString(), QgsProcessing::TypeRaster ).hasGeometry() );
QVERIFY( !QgsProcessingParameterVectorDestination( "test", QString(), QgsProcessing::TypeFile ).hasGeometry() );
QVERIFY( QgsProcessingParameterVectorDestination( "test", QString(), QgsProcessing::TypeVector ).hasGeometry() );
QVERIFY( !QgsProcessingParameterVectorDestination( "test", QString(), QgsProcessing::TypeVector ).hasGeometry() );

// test layers to load on completion
def.reset( new QgsProcessingParameterVectorDestination( "x", QStringLiteral( "desc" ), QgsProcessing::TypeVectorAnyGeometry, QString(), true ) );

0 comments on commit 583b602

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