@@ -2052,6 +2052,8 @@ void TestQgsProcessing::parameterCrs()
20522052 QVERIFY ( def->checkValueIsAcceptable ( QVariant::fromValue ( r1 ) ) );
20532053 QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
20542054 QVERIFY ( !def->checkValueIsAcceptable ( QVariant () ) );
2055+ QVERIFY ( def->checkValueIsAcceptable ( QgsProcessingFeatureSourceDefinition ( r1->id () ) ) );
2056+ QVERIFY ( def->checkValueIsAcceptable ( QgsProcessingFeatureSourceDefinition ( QgsProperty::fromValue ( QVariant::fromValue ( r1 ) ) ) ) );
20552057
20562058 // using map layer
20572059 QVariantMap params;
@@ -2085,6 +2087,12 @@ void TestQgsProcessing::parameterCrs()
20852087 params.insert ( " non_optional" , QString ( " i'm not a crs, and nothing you can do will make me one" ) );
20862088 QVERIFY ( !QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).isValid () );
20872089
2090+ // using feature source definition
2091+ params.insert ( " non_optional" , QgsProcessingFeatureSourceDefinition ( v1->id () ) );
2092+ QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:3111" ) );
2093+ params.insert ( " non_optional" , QgsProcessingFeatureSourceDefinition ( QgsProperty::fromValue ( QVariant::fromValue ( v1 ) ) ) );
2094+ QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:3111" ) );
2095+
20882096 QCOMPARE ( def->valueAsPythonString ( QVariant (), context ), QStringLiteral ( " None" ) );
20892097 QCOMPARE ( def->valueAsPythonString ( " EPSG:12003" , context ), QStringLiteral ( " 'EPSG:12003'" ) );
20902098 QCOMPARE ( def->valueAsPythonString ( " ProjectCrs" , context ), QStringLiteral ( " 'ProjectCrs'" ) );
@@ -2331,6 +2339,36 @@ void TestQgsProcessing::parameterExtent()
23312339 QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
23322340 QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
23332341
2342+ // using feature source definition
2343+ params.insert ( " non_optional" , QgsProcessingFeatureSourceDefinition ( r1->id () ) );
2344+ QCOMPARE ( QgsProcessingParameters::parameterAsExtentCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
2345+ ext = QgsProcessingParameters::parameterAsExtent ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2346+ QGSCOMPARENEAR ( ext.xMinimum (), 1535375 , 100 );
2347+ QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 100 );
2348+ QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2349+ QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2350+ gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2351+ QCOMPARE ( gExt .constGet ()->vertexCount (), 5 );
2352+ ext = gExt .boundingBox ();
2353+ QGSCOMPARENEAR ( ext.xMinimum (), 1535375 , 100 );
2354+ QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 100 );
2355+ QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2356+ QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2357+ params.insert ( " non_optional" , QgsProcessingFeatureSourceDefinition ( QgsProperty::fromValue ( QVariant::fromValue ( r1 ) ) ) );
2358+ QCOMPARE ( QgsProcessingParameters::parameterAsExtentCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
2359+ ext = QgsProcessingParameters::parameterAsExtent ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2360+ QGSCOMPARENEAR ( ext.xMinimum (), 1535375 , 100 );
2361+ QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 100 );
2362+ QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2363+ QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2364+ gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2365+ QCOMPARE ( gExt .constGet ()->vertexCount (), 5 );
2366+ ext = gExt .boundingBox ();
2367+ QGSCOMPARENEAR ( ext.xMinimum (), 1535375 , 100 );
2368+ QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 100 );
2369+ QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2370+ QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2371+
23342372 // string representing a non-project layer source
23352373 params.insert ( " non_optional" , raster2 );
23362374 QVERIFY ( def->checkValueIsAcceptable ( raster2 ) );
0 commit comments