@@ -1853,6 +1853,7 @@ void TestQgsProcessing::parameterCrs()
1853
1853
QVERIFY ( !def->checkValueIsAcceptable ( 5 ) );
1854
1854
QVERIFY ( def->checkValueIsAcceptable ( " EPSG:12003" ) );
1855
1855
QVERIFY ( def->checkValueIsAcceptable ( " EPSG:3111" ) );
1856
+ QVERIFY ( def->checkValueIsAcceptable ( QVariant::fromValue ( r1 ) ) );
1856
1857
QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
1857
1858
QVERIFY ( !def->checkValueIsAcceptable ( QVariant () ) );
1858
1859
@@ -1861,6 +1862,8 @@ void TestQgsProcessing::parameterCrs()
1861
1862
params.insert ( " non_optional" , v1->id () );
1862
1863
QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:3111" ) );
1863
1864
QVERIFY ( def->checkValueIsAcceptable ( v1->id () ) );
1865
+ params.insert ( " non_optional" , QVariant::fromValue ( v1 ) );
1866
+ QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:3111" ) );
1864
1867
1865
1868
// special ProjectCrs string
1866
1869
params.insert ( " non_optional" , QStringLiteral ( " ProjectCrs" ) );
@@ -2112,6 +2115,24 @@ void TestQgsProcessing::parameterExtent()
2112
2115
QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2113
2116
QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2114
2117
2118
+ // layer as parameter
2119
+ params.insert ( " non_optional" , QVariant::fromValue ( r1 ) );
2120
+ QVERIFY ( def->checkValueIsAcceptable ( QVariant::fromValue ( r1 ) ) );
2121
+ QCOMPARE ( QgsProcessingParameters::parameterAsExtent ( def.get (), params, context ), r1->extent () );
2122
+ QCOMPARE ( QgsProcessingParameters::parameterAsExtentCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
2123
+ ext = QgsProcessingParameters::parameterAsExtent ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2124
+ QGSCOMPARENEAR ( ext.xMinimum (), 1535375 , 100 );
2125
+ QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 100 );
2126
+ QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2127
+ QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2128
+ QgsGeometry gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2129
+ QCOMPARE ( gExt .constGet ()->vertexCount (), 5 );
2130
+ ext = gExt .boundingBox ();
2131
+ QGSCOMPARENEAR ( ext.xMinimum (), 1535375 , 100 );
2132
+ QGSCOMPARENEAR ( ext.xMaximum (), 1535475 , 100 );
2133
+ QGSCOMPARENEAR ( ext.yMinimum (), 5083255 , 100 );
2134
+ QGSCOMPARENEAR ( ext.yMaximum (), 5083355 , 100 );
2135
+
2115
2136
// string representing a non-project layer source
2116
2137
params.insert ( " non_optional" , raster2 );
2117
2138
QVERIFY ( def->checkValueIsAcceptable ( raster2 ) );
@@ -2126,7 +2147,7 @@ void TestQgsProcessing::parameterExtent()
2126
2147
QGSCOMPARENEAR ( ext.xMaximum (), 18.045658 , 0.01 );
2127
2148
QGSCOMPARENEAR ( ext.yMinimum (), 30.151856 , 0.01 );
2128
2149
QGSCOMPARENEAR ( ext.yMaximum (), 30.257289 , 0.01 );
2129
- QgsGeometry gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2150
+ gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:4326" ) );
2130
2151
QCOMPARE ( gExt .constGet ()->vertexCount (), 85 );
2131
2152
ext = gExt .boundingBox ();
2132
2153
QGSCOMPARENEAR ( ext.xMinimum (), 17.924273 , 0.01 );
0 commit comments