@@ -2362,16 +2362,25 @@ void TestQgsProcessing::parameterPoint()
23622362 QVERIFY ( !def->checkValueIsAcceptable ( true ) );
23632363 QVERIFY ( !def->checkValueIsAcceptable ( 5 ) );
23642364 QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2" ) );
2365+ QVERIFY ( def->checkValueIsAcceptable ( " (1.1,2)" ) );
23652366 QVERIFY ( def->checkValueIsAcceptable ( " 1.1, 2 " ) );
2367+ QVERIFY ( def->checkValueIsAcceptable ( " ( 1.1, 2 ) " ) );
23662368 QVERIFY ( def->checkValueIsAcceptable ( " -1.1,2" ) );
23672369 QVERIFY ( def->checkValueIsAcceptable ( " 1.1,-2" ) );
23682370 QVERIFY ( def->checkValueIsAcceptable ( " -1.1,-2" ) );
2371+ QVERIFY ( def->checkValueIsAcceptable ( " (-1.1,-2)" ) );
23692372 QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2[EPSG:4326]" ) );
23702373 QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2 [EPSG:4326]" ) );
2374+ QVERIFY ( def->checkValueIsAcceptable ( " (1.1,2 [EPSG:4326] )" ) );
23712375 QVERIFY ( def->checkValueIsAcceptable ( " -1.1, -2 [EPSG:4326] " ) );
2376+ QVERIFY ( def->checkValueIsAcceptable ( " ( -1.1, -2 [EPSG:4326] ) " ) );
23722377 QVERIFY ( !def->checkValueIsAcceptable ( " 1.1,a" ) );
2378+ QVERIFY ( !def->checkValueIsAcceptable ( " (1.1,a)" ) );
23732379 QVERIFY ( !def->checkValueIsAcceptable ( " layer12312312" ) );
2380+ QVERIFY ( !def->checkValueIsAcceptable ( " (layer12312312)" ) );
23742381 QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
2382+ QVERIFY ( !def->checkValueIsAcceptable ( " ()" ) );
2383+ QVERIFY ( !def->checkValueIsAcceptable ( " ( ) " ) );
23752384 QVERIFY ( !def->checkValueIsAcceptable ( QVariant () ) );
23762385 QVERIFY ( def->checkValueIsAcceptable ( QgsPointXY ( 1 , 2 ) ) );
23772386 QVERIFY ( def->checkValueIsAcceptable ( QgsReferencedPointXY ( QgsPointXY ( 1 , 2 ), QgsCoordinateReferenceSystem ( " EPSG:4326" ) ) ) );
@@ -2389,6 +2398,17 @@ void TestQgsProcessing::parameterPoint()
23892398 QGSCOMPARENEAR ( point.x (), 1.1 , 0.001 );
23902399 QGSCOMPARENEAR ( point.y (), 2.2 , 0.001 );
23912400
2401+ // with optional brackets
2402+ params.insert ( " non_optional" , QString ( " (1.1,2.2)" ) );
2403+ point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
2404+ QGSCOMPARENEAR ( point.x (), 1.1 , 0.001 );
2405+ QGSCOMPARENEAR ( point.y (), 2.2 , 0.001 );
2406+
2407+ params.insert ( " non_optional" , QString ( " ( -1.1 ,-2.2 ) " ) );
2408+ point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
2409+ QGSCOMPARENEAR ( point.x (), -1.1 , 0.001 );
2410+ QGSCOMPARENEAR ( point.y (), -2.2 , 0.001 );
2411+
23922412 // with CRS as string
23932413 params.insert ( " non_optional" , QString ( " 1.1,2.2[EPSG:4326]" ) );
23942414 QCOMPARE ( QgsProcessingParameters::parameterAsPointCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
@@ -2401,12 +2421,23 @@ void TestQgsProcessing::parameterPoint()
24012421 QGSCOMPARENEAR ( point.x (), 122451 , 100 );
24022422 QGSCOMPARENEAR ( point.y (), 244963 , 100 );
24032423
2424+ params.insert ( " non_optional" , QString ( " ( 1.1,2.2 [EPSG:4326] ) " ) );
2425+ QCOMPARE ( QgsProcessingParameters::parameterAsPointCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
2426+ point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context, QgsCoordinateReferenceSystem ( " EPSG:3785" ) );
2427+ QGSCOMPARENEAR ( point.x (), 122451 , 100 );
2428+ QGSCOMPARENEAR ( point.y (), 244963 , 100 );
2429+
24042430 // nonsense string
24052431 params.insert ( " non_optional" , QString ( " i'm not a crs, and nothing you can do will make me one" ) );
24062432 point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
24072433 QCOMPARE ( point.x (), 0.0 );
24082434 QCOMPARE ( point.y (), 0.0 );
24092435
2436+ params.insert ( " non_optional" , QString ( " ( ) " ) );
2437+ point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
2438+ QCOMPARE ( point.x (), 0.0 );
2439+ QCOMPARE ( point.y (), 0.0 );
2440+
24102441 // QgsPointXY
24112442 params.insert ( " non_optional" , QgsPointXY ( 11.1 , 12.2 ) );
24122443 point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
0 commit comments