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.

(cherry picked from commit 583b602)
  • Loading branch information
nyalldawson committed Dec 4, 2018
1 parent 9951619 commit 9cd920d05ebf9127a7c027ebbbe9a82dbf1c7f27
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/core/processing/qgsprocessingparameters.cpp
  2. +2 −2 tests/src/analysis/testqgsprocessing.cpp
@@ -3755,11 +3755,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;
@@ -4315,11 +4315,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 9cd920d

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