@@ -2362,16 +2362,25 @@ void TestQgsProcessing::parameterPoint()
2362
2362
QVERIFY ( !def->checkValueIsAcceptable ( true ) );
2363
2363
QVERIFY ( !def->checkValueIsAcceptable ( 5 ) );
2364
2364
QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2" ) );
2365
+ QVERIFY ( def->checkValueIsAcceptable ( " (1.1,2)" ) );
2365
2366
QVERIFY ( def->checkValueIsAcceptable ( " 1.1, 2 " ) );
2367
+ QVERIFY ( def->checkValueIsAcceptable ( " ( 1.1, 2 ) " ) );
2366
2368
QVERIFY ( def->checkValueIsAcceptable ( " -1.1,2" ) );
2367
2369
QVERIFY ( def->checkValueIsAcceptable ( " 1.1,-2" ) );
2368
2370
QVERIFY ( def->checkValueIsAcceptable ( " -1.1,-2" ) );
2371
+ QVERIFY ( def->checkValueIsAcceptable ( " (-1.1,-2)" ) );
2369
2372
QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2[EPSG:4326]" ) );
2370
2373
QVERIFY ( def->checkValueIsAcceptable ( " 1.1,2 [EPSG:4326]" ) );
2374
+ QVERIFY ( def->checkValueIsAcceptable ( " (1.1,2 [EPSG:4326] )" ) );
2371
2375
QVERIFY ( def->checkValueIsAcceptable ( " -1.1, -2 [EPSG:4326] " ) );
2376
+ QVERIFY ( def->checkValueIsAcceptable ( " ( -1.1, -2 [EPSG:4326] ) " ) );
2372
2377
QVERIFY ( !def->checkValueIsAcceptable ( " 1.1,a" ) );
2378
+ QVERIFY ( !def->checkValueIsAcceptable ( " (1.1,a)" ) );
2373
2379
QVERIFY ( !def->checkValueIsAcceptable ( " layer12312312" ) );
2380
+ QVERIFY ( !def->checkValueIsAcceptable ( " (layer12312312)" ) );
2374
2381
QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
2382
+ QVERIFY ( !def->checkValueIsAcceptable ( " ()" ) );
2383
+ QVERIFY ( !def->checkValueIsAcceptable ( " ( ) " ) );
2375
2384
QVERIFY ( !def->checkValueIsAcceptable ( QVariant () ) );
2376
2385
QVERIFY ( def->checkValueIsAcceptable ( QgsPointXY ( 1 , 2 ) ) );
2377
2386
QVERIFY ( def->checkValueIsAcceptable ( QgsReferencedPointXY ( QgsPointXY ( 1 , 2 ), QgsCoordinateReferenceSystem ( " EPSG:4326" ) ) ) );
@@ -2389,6 +2398,17 @@ void TestQgsProcessing::parameterPoint()
2389
2398
QGSCOMPARENEAR ( point.x (), 1.1 , 0.001 );
2390
2399
QGSCOMPARENEAR ( point.y (), 2.2 , 0.001 );
2391
2400
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
+
2392
2412
// with CRS as string
2393
2413
params.insert ( " non_optional" , QString ( " 1.1,2.2[EPSG:4326]" ) );
2394
2414
QCOMPARE ( QgsProcessingParameters::parameterAsPointCrs ( def.get (), params, context ).authid (), QStringLiteral ( " EPSG:4326" ) );
@@ -2401,12 +2421,23 @@ void TestQgsProcessing::parameterPoint()
2401
2421
QGSCOMPARENEAR ( point.x (), 122451 , 100 );
2402
2422
QGSCOMPARENEAR ( point.y (), 244963 , 100 );
2403
2423
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
+
2404
2430
// nonsense string
2405
2431
params.insert ( " non_optional" , QString ( " i'm not a crs, and nothing you can do will make me one" ) );
2406
2432
point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
2407
2433
QCOMPARE ( point.x (), 0.0 );
2408
2434
QCOMPARE ( point.y (), 0.0 );
2409
2435
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
+
2410
2441
// QgsPointXY
2411
2442
params.insert ( " non_optional" , QgsPointXY ( 11.1 , 12.2 ) );
2412
2443
point = QgsProcessingParameters::parameterAsPoint ( def.get (), params, context );
0 commit comments