@@ -1844,6 +1844,21 @@ void TestQgsProcessing::parameterExtent()
1844
1844
QVERIFY ( !def->checkValueIsAcceptable ( true ) );
1845
1845
QVERIFY ( !def->checkValueIsAcceptable ( 5 ) );
1846
1846
QVERIFY ( def->checkValueIsAcceptable ( " 1,2,3,4" ) );
1847
+ QVERIFY ( def->checkValueIsAcceptable ( " 1, 2 ,3 , 4 " ) );
1848
+ QVERIFY ( def->checkValueIsAcceptable ( " 1, 2 ,3 , 4 " , &context ) );
1849
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1,2,-3,-4" ) );
1850
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1,2,-3,-4" , &context ) );
1851
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1,-2.2,-3.3,-4.4" ) );
1852
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1,-2.2,-3.3,-4.4" , &context ) );
1853
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2,3,4.4[EPSG:4326]" ) );
1854
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2,3,4.4[EPSG:4326]" , &context ) );
1855
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2,3,4.4 [EPSG:4326]" ) );
1856
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2,3,4.4 [EPSG:4326]" , &context ) );
1857
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1, -2, -3, -4.4 [EPSG:4326] " ) );
1858
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1, -2, -3, -4.4 [EPSG:4326] " , &context ) );
1859
+ QVERIFY ( def->checkValueIsAcceptable ( " 121774.38859446358,948723.6921024882,-264546.200347173,492749.6672022904 [EPSG:3785]" ) );
1860
+ QVERIFY ( def->checkValueIsAcceptable ( " 121774.38859446358,948723.6921024882,-264546.200347173,492749.6672022904 [EPSG:3785]" , &context ) );
1861
+
1847
1862
QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
1848
1863
QVERIFY ( !def->checkValueIsAcceptable ( QVariant () ) );
1849
1864
QVERIFY ( def->checkValueIsAcceptable ( QgsRectangle ( 1 , 2 , 3 , 4 ) ) );
@@ -1894,6 +1909,27 @@ void TestQgsProcessing::parameterExtent()
1894
1909
QGSCOMPARENEAR ( ext.yMinimum (), 3.3 , 0.001 );
1895
1910
QGSCOMPARENEAR ( ext.yMaximum (), 4.4 , 0.001 );
1896
1911
1912
+ // with crs in string
1913
+ params.insert ( " non_optional" , QString ( " 1.1,3.3,2.2,4.4 [EPSG:4326]" ) );
1914
+ QCOMPARE ( QgsProcessingParameters::parameterAsExtentCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
1915
+ ext = QgsProcessingParameters::parameterAsExtent ( def.get (), params, context );
1916
+ QGSCOMPARENEAR ( ext.xMinimum (), 1.1 , 0.001 );
1917
+ QGSCOMPARENEAR ( ext.xMaximum (), 3.3 , 0.001 );
1918
+ QGSCOMPARENEAR ( ext.yMinimum (), 2.2 , 0.001 );
1919
+ QGSCOMPARENEAR ( ext.yMaximum (), 4.4 , 0.001 );
1920
+ ext = QgsProcessingParameters::parameterAsExtent ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
1921
+ QGSCOMPARENEAR ( ext.xMinimum (), 122451 , 100 );
1922
+ QGSCOMPARENEAR ( ext.xMaximum (), 367354 , 100 );
1923
+ QGSCOMPARENEAR ( ext.yMinimum (), 244963 , 100 );
1924
+ QGSCOMPARENEAR ( ext.yMaximum (), 490287 , 100 );
1925
+ QgsGeometry gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
1926
+ QCOMPARE ( gExt .geometry ()->vertexCount (), 85 );
1927
+ ext = gExt .boundingBox ();
1928
+ QGSCOMPARENEAR ( ext.xMinimum (), 122451 , 100 );
1929
+ QGSCOMPARENEAR ( ext.xMaximum (), 367354 , 100 );
1930
+ QGSCOMPARENEAR ( ext.yMinimum (), 244963 , 100 );
1931
+ QGSCOMPARENEAR ( ext.yMaximum (), 490287 , 100 );
1932
+
1897
1933
// nonsense string
1898
1934
params.insert ( " non_optional" , QString ( " i'm not a crs, and nothing you can do will make me one" ) );
1899
1935
QVERIFY ( QgsProcessingParameters::parameterAsExtent ( def.get (), params, context ).isNull () );
@@ -1913,7 +1949,7 @@ void TestQgsProcessing::parameterExtent()
1913
1949
QGSCOMPARENEAR ( ext.yMinimum (), 12.2 , 0.001 );
1914
1950
QGSCOMPARENEAR ( ext.yMaximum (), 14.4 , 0.001 );
1915
1951
1916
- QgsGeometry gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
1952
+ gExt = QgsProcessingParameters::parameterAsExtentGeometry ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
1917
1953
QCOMPARE ( gExt .exportToWkt ( 1 ), QStringLiteral ( " Polygon ((11.1 12.2, 13.3 12.2, 13.3 14.4, 11.1 14.4, 11.1 12.2))" ) );
1918
1954
1919
1955
p.setCrs ( QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
@@ -1949,8 +1985,9 @@ void TestQgsProcessing::parameterExtent()
1949
1985
QCOMPARE ( def->valueAsPythonString ( QVariant::fromValue ( r1 ), context ), QString ( " '" ) + testDataDir + QStringLiteral ( " tenbytenraster.asc'" ) );
1950
1986
QCOMPARE ( def->valueAsPythonString ( raster2, context ), QString ( " '" ) + testDataDir + QStringLiteral ( " landsat.tif'" ) );
1951
1987
QCOMPARE ( def->valueAsPythonString ( QVariant::fromValue ( QgsProperty::fromExpression ( " \" a\" =1" ) ), context ), QStringLiteral ( " QgsProperty.fromExpression('\" a\" =1')" ) );
1952
- QCOMPARE ( def->valueAsPythonString ( QgsRectangle ( 11 , 12 , 13 , 14 ), context ), QStringLiteral ( " QgsRectangle( 11, 12, 13, 14 )" ) );
1953
- QCOMPARE ( def->valueAsPythonString ( QgsReferencedRectangle ( QgsRectangle ( 11 , 12 , 13 , 14 ), QgsCoordinateReferenceSystem ( " epsg:4326" ) ), context ), QStringLiteral ( " QgsReferencedRectangle( QgsRectangle( 11, 12, 13, 14 ), QgsCoordinateReferenceSystem( 'EPSG:4326' ) )" ) );
1988
+ QCOMPARE ( def->valueAsPythonString ( QgsRectangle ( 11 , 12 , 13 , 14 ), context ), QStringLiteral ( " '11, 13, 12, 14'" ) );
1989
+ QCOMPARE ( def->valueAsPythonString ( QgsReferencedRectangle ( QgsRectangle ( 11 , 12 , 13 , 14 ), QgsCoordinateReferenceSystem ( " epsg:4326" ) ), context ), QStringLiteral ( " '11, 13, 12, 14 [EPSG:4326]'" ) );
1990
+ QCOMPARE ( def->valueAsPythonString ( " 1,2,3,4 [EPSG:4326]" , context ), QStringLiteral ( " '1,2,3,4 [EPSG:4326]'" ) );
1954
1991
1955
1992
QString code = def->asScriptCode ();
1956
1993
QCOMPARE ( code, QStringLiteral ( " ##non_optional=extent 1,2,3,4" ) );
0 commit comments