Skip to content

Commit 9cd920d

Browse files
committed
[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)
1 parent 9951619 commit 9cd920d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/core/processing/qgsprocessingparameters.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3755,11 +3755,11 @@ bool QgsProcessingParameterFeatureSink::hasGeometry() const
37553755
case QgsProcessing::TypeVectorPoint:
37563756
case QgsProcessing::TypeVectorLine:
37573757
case QgsProcessing::TypeVectorPolygon:
3758-
case QgsProcessing::TypeVector:
37593758
return true;
37603759

37613760
case QgsProcessing::TypeRaster:
37623761
case QgsProcessing::TypeFile:
3762+
case QgsProcessing::TypeVector:
37633763
return false;
37643764
}
37653765
return true;
@@ -4315,11 +4315,11 @@ bool QgsProcessingParameterVectorDestination::hasGeometry() const
43154315
case QgsProcessing::TypeVectorPoint:
43164316
case QgsProcessing::TypeVectorLine:
43174317
case QgsProcessing::TypeVectorPolygon:
4318-
case QgsProcessing::TypeVector:
43194318
return true;
43204319

43214320
case QgsProcessing::TypeRaster:
43224321
case QgsProcessing::TypeFile:
4322+
case QgsProcessing::TypeVector:
43234323
return false;
43244324
}
43254325
return true;

tests/src/analysis/testqgsprocessing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,7 +4665,7 @@ void TestQgsProcessing::parameterFeatureSink()
46654665
QVERIFY( QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeVectorPolygon ).hasGeometry() );
46664666
QVERIFY( !QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeRaster ).hasGeometry() );
46674667
QVERIFY( !QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeFile ).hasGeometry() );
4668-
QVERIFY( QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeVector ).hasGeometry() );
4668+
QVERIFY( !QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessing::TypeVector ).hasGeometry() );
46694669

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

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

0 commit comments

Comments
 (0)