@@ -2125,6 +2125,8 @@ void TestQgsProcessing::parameterCrs()
2125
2125
QVERIFY ( def->checkValueIsAcceptable ( " EPSG:12003" ) );
2126
2126
QVERIFY ( def->checkValueIsAcceptable ( " EPSG:3111" ) );
2127
2127
QVERIFY ( def->checkValueIsAcceptable ( QVariant::fromValue ( r1 ) ) );
2128
+ QVERIFY ( def->checkValueIsAcceptable ( QgsCoordinateReferenceSystem () ) );
2129
+ QVERIFY ( def->checkValueIsAcceptable ( QgsCoordinateReferenceSystem ( QStringLiteral ( " EPSG:3111" ) ) ) );
2128
2130
QVERIFY ( !def->checkValueIsAcceptable ( " " ) );
2129
2131
QVERIFY ( !def->checkValueIsAcceptable ( QVariant () ) );
2130
2132
QVERIFY ( def->checkValueIsAcceptable ( QgsProcessingFeatureSourceDefinition ( r1->id () ) ) );
@@ -2139,6 +2141,12 @@ void TestQgsProcessing::parameterCrs()
2139
2141
params.insert ( " non_optional" , QVariant::fromValue ( v1 ) );
2140
2142
QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:3111" ) );
2141
2143
2144
+ // using QgsCoordinateReferenceSystem
2145
+ params.insert ( " non_optional" , QgsCoordinateReferenceSystem ( " EPSG:28356" ) );
2146
+ QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:28356" ) );
2147
+ params.insert ( " non_optional" , QgsCoordinateReferenceSystem () );
2148
+ QVERIFY ( !QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).isValid () );
2149
+
2142
2150
// special ProjectCrs string
2143
2151
params.insert ( " non_optional" , QStringLiteral ( " ProjectCrs" ) );
2144
2152
QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:28353" ) );
@@ -2172,6 +2180,8 @@ void TestQgsProcessing::parameterCrs()
2172
2180
QCOMPARE ( QgsProcessingParameters::parameterAsCrs ( def.get (), params, context ).authid (), QString ( " EPSG:3111" ) );
2173
2181
2174
2182
QCOMPARE ( def->valueAsPythonString ( QVariant (), context ), QStringLiteral ( " None" ) );
2183
+ QCOMPARE ( def->valueAsPythonString ( QgsCoordinateReferenceSystem ( " EPSG:3111" ), context ), QStringLiteral ( " QgsCoordinateReferenceSystem('EPSG:3111')" ) );
2184
+ QCOMPARE ( def->valueAsPythonString ( QgsCoordinateReferenceSystem (), context ), QStringLiteral ( " QgsCoordinateReferenceSystem()" ) );
2175
2185
QCOMPARE ( def->valueAsPythonString ( " EPSG:12003" , context ), QStringLiteral ( " 'EPSG:12003'" ) );
2176
2186
QCOMPARE ( def->valueAsPythonString ( " ProjectCrs" , context ), QStringLiteral ( " 'ProjectCrs'" ) );
2177
2187
QCOMPARE ( def->valueAsPythonString ( QStringLiteral ( " c:\\ test\\ new data\\ test.dat" ), context ), QStringLiteral ( " 'c:\\\\ test\\\\ new data\\\\ test.dat'" ) );
0 commit comments