24
24
#include " qgsprocessingmodelalgorithm.h"
25
25
#include " qgsnativealgorithms.h"
26
26
#include " qgsalgorithmimportphotos.h"
27
+ #include " qgsalgorithmtransform.h"
27
28
28
29
class TestQgsProcessingAlgs : public QObject
29
30
{
@@ -39,6 +40,7 @@ class TestQgsProcessingAlgs: public QObject
39
40
void loadLayerAlg ();
40
41
void parseGeoTags ();
41
42
void featureFilterAlg ();
43
+ void transformAlg ();
42
44
43
45
private:
44
46
@@ -404,6 +406,35 @@ void TestQgsProcessingAlgs::featureFilterAlg()
404
406
Q_ASSERT ( outputParamDef2->flags () & QgsProcessingParameterDefinition::FlagHidden );
405
407
}
406
408
409
+ void TestQgsProcessingAlgs::transformAlg ()
410
+ {
411
+ std::unique_ptr< QgsProcessingAlgorithm > alg ( QgsApplication::processingRegistry ()->createAlgorithmById ( QStringLiteral ( " native:reprojectlayer" ) ) );
412
+ QVERIFY ( alg );
413
+
414
+ std::unique_ptr< QgsProcessingContext > context = qgis::make_unique< QgsProcessingContext >();
415
+ QgsProject p;
416
+ context->setProject ( &p );
417
+
418
+ QgsProcessingFeedback feedback;
419
+
420
+ QgsVectorLayer *layer = new QgsVectorLayer ( QStringLiteral ( " Point?crs=EPSG:4326field=col1:integer" ), QStringLiteral ( " test" ), QStringLiteral ( " memory" ) );
421
+ QVERIFY ( layer->isValid () );
422
+ QgsFeature f;
423
+ // add a point with a bad geometry - this should result in a transform exception!
424
+ f.setGeometry ( QgsGeometry::fromPointXY ( QgsPointXY ( -96215069 , 41.673559 ) ) );
425
+ QVERIFY ( layer->dataProvider ()->addFeature ( f ) );
426
+ p.addMapLayer ( layer );
427
+
428
+ QVariantMap parameters;
429
+ parameters.insert ( QStringLiteral ( " INPUT" ), QStringLiteral ( " test" ) );
430
+ parameters.insert ( QStringLiteral ( " OUTPUT" ), QStringLiteral ( " memory:" ) );
431
+ parameters.insert ( QStringLiteral ( " TARGET_CRS" ), QStringLiteral ( " EPSG:2163" ) );
432
+ bool ok = false ;
433
+ QVariantMap results = alg->run ( parameters, *context, &feedback, &ok );
434
+ Q_UNUSED ( results );
435
+ QVERIFY ( ok );
436
+ }
437
+
407
438
408
439
QGSTEST_MAIN ( TestQgsProcessingAlgs )
409
440
#include " testqgsprocessingalgs.moc"
0 commit comments