@@ -2006,6 +2006,13 @@ void TestQgsProcessing::parameterPoint()
2006
2006
QVERIFY ( !def->checkValueIsAcceptable ( true ) );
2007
2007
QVERIFY ( !def->checkValueIsAcceptable ( 5 ) );
2008
2008
QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2" ) );
2009
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1, 2 " ) );
2010
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1,2" ) );
2011
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,-2" ) );
2012
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1,-2" ) );
2013
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2[EPSG:4326]" ) );
2014
+ QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2 [EPSG:4326]" ) );
2015
+ QVERIFY ( def->checkValueIsAcceptable ( " -1.1, -2 [EPSG:4326] " ) );
2009
2016
QVERIFY ( !def->checkValueIsAcceptable ( " 1.1,a" ) );
2010
2017
QVERIFY ( !def->checkValueIsAcceptable ( " layer12312312" ) );
2011
2018
QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
@@ -2026,6 +2033,18 @@ void TestQgsProcessing::parameterPoint()
2026
2033
QGSCOMPARENEAR ( point.x (), 1.1 , 0.001 );
2027
2034
QGSCOMPARENEAR ( point.y (), 2.2 , 0.001 );
2028
2035
2036
+ // with CRS as string
2037
+ params.insert ( " non_optional" , QString ( " 1.1,2.2[EPSG:4326]" ) );
2038
+ QCOMPARE ( QgsProcessingParameters::parameterAsPointCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
2039
+ point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
2040
+ QGSCOMPARENEAR ( point.x (), 122451 , 100 );
2041
+ QGSCOMPARENEAR ( point.y (), 244963 , 100 );
2042
+ params.insert ( " non_optional" , QString ( " 1.1,2.2 [EPSG:4326]" ) );
2043
+ QCOMPARE ( QgsProcessingParameters::parameterAsPointCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
2044
+ point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
2045
+ QGSCOMPARENEAR ( point.x (), 122451 , 100 );
2046
+ QGSCOMPARENEAR ( point.y (), 244963 , 100 );
2047
+
2029
2048
// nonsense string
2030
2049
params.insert ( " non_optional" , QString ( " i'm not a crs, and nothing you can do will make me one" ) );
2031
2050
point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
@@ -2056,8 +2075,9 @@ void TestQgsProcessing::parameterPoint()
2056
2075
QGSCOMPARENEAR ( point.y (), 244963 , 100 );
2057
2076
2058
2077
QCOMPARE ( def->valueAsPythonString ( " 1,2" , context ), QStringLiteral ( " '1,2'" ) );
2059
- QCOMPARE ( def->valueAsPythonString ( QgsPointXY ( 11 , 12 ), context ), QStringLiteral ( " QgsPointXY( 11, 12 )" ) );
2060
- QCOMPARE ( def->valueAsPythonString ( QgsReferencedPointXY ( QgsPointXY ( 11 , 12 ), QgsCoordinateReferenceSystem ( " epsg:4326" ) ), context ), QStringLiteral ( " QgsReferencedPointXY( QgsPointXY( 11, 12 ), QgsCoordinateReferenceSystem( 'EPSG:4326' ) )" ) );
2078
+ QCOMPARE ( def->valueAsPythonString ( " 1,2 [EPSG:4326]" , context ), QStringLiteral ( " '1,2 [EPSG:4326]'" ) );
2079
+ QCOMPARE ( def->valueAsPythonString ( QgsPointXY ( 11 , 12 ), context ), QStringLiteral ( " '11,12'" ) );
2080
+ QCOMPARE ( def->valueAsPythonString ( QgsReferencedPointXY ( QgsPointXY ( 11 , 12 ), QgsCoordinateReferenceSystem ( " epsg:4326" ) ), context ), QStringLiteral ( " '11,12 [EPSG:4326]'" ) );
2061
2081
2062
2082
QString code = def->asScriptCode ();
2063
2083
QCOMPARE ( code, QStringLiteral ( " ##non_optional=point 1,2" ) );
0 commit comments