21
21
#include " qgsruggednessfilter.h"
22
22
#include " qgstotalcurvaturefilter.h"
23
23
#include " qgsapplication.h"
24
+ #include " qgssettings.h"
25
+
26
+ #ifdef HAVE_OPENCL
27
+ #include " qgsopenclutils.h"
28
+ #endif
24
29
25
30
#include < QDir>
26
31
@@ -38,10 +43,14 @@ class TestNineCellFilters : public QObject
38
43
void testHillshade ();
39
44
void testRuggedness ();
40
45
void testTotalCurvature ();
46
+ #ifdef HAVE_OPENCL
47
+ void testSlopeCl ();
48
+ void testAspectCl ();
49
+ #endif
41
50
42
51
private:
43
52
44
- template <class T > void _testAlg ( const QString &name );
53
+ template <class T > void _testAlg ( const QString &name, bool useOpenCl = false );
45
54
46
55
static QString referenceFile ( const QString &name )
47
56
{
@@ -65,16 +74,21 @@ void TestNineCellFilters::initTestCase()
65
74
}
66
75
67
76
template <class T >
68
- void TestNineCellFilters::_testAlg ( const QString &name )
77
+ void TestNineCellFilters::_testAlg ( const QString &name, bool useOpenCl )
69
78
{
79
+ #ifdef HAVE_OPENCL
80
+ QgsSettings ().setValue ( QStringLiteral ( " useOpenCl" ), true , QgsSettings::Section::Core );
81
+ QString tmpFile ( tempFile ( name + ( useOpenCl ? " _opencl" : " " ) ) );
82
+ #else
83
+ Q_UNUSED ( useOpenCl );
70
84
QString tmpFile ( tempFile ( name ) );
85
+ #endif
71
86
QString refFile ( referenceFile ( name ) );
72
-
73
87
QgsAlignRaster::RasterInfo in ( SRC_FILE );
74
88
QSize inSize ( in.rasterSize () );
75
89
QSizeF inCellSize ( in.cellSize ( ) );
76
- T slopefilter ( SRC_FILE, tmpFile, " GTiff" );
77
- int res = slopefilter .processRaster ();
90
+ T ninecellsfilter ( SRC_FILE, tmpFile, " GTiff" );
91
+ int res = ninecellsfilter .processRaster ();
78
92
QVERIFY ( res == 0 );
79
93
80
94
// Produced file
@@ -93,8 +107,8 @@ void TestNineCellFilters::_testAlg( const QString &name )
93
107
94
108
double refId1 ( ref.identify ( 4081812 , 2431750 ) );
95
109
double refId2 ( ref.identify ( 4081312 , 2431350 ) );
96
- QCOMPARE ( out.identify ( 4081812 , 2431750 ), refId1 );
97
- QCOMPARE ( out.identify ( 4081312 , 2431350 ), refId2 );
110
+ QVERIFY ( qAbs ( out.identify ( 4081812 , 2431750 ) - refId1 ) < 0 . 0001f );
111
+ QVERIFY ( qAbs ( out.identify ( 4081312 , 2431350 ) - refId2 ) < 0 . 0001f );
98
112
99
113
}
100
114
@@ -110,6 +124,18 @@ void TestNineCellFilters::testAspect()
110
124
_testAlg<QgsAspectFilter>( QStringLiteral ( " aspect" ) );
111
125
}
112
126
127
+ #ifdef HAVE_OPENCL
128
+ void TestNineCellFilters::testSlopeCl ()
129
+ {
130
+ _testAlg<QgsSlopeFilter>( QStringLiteral ( " slope" ), true );
131
+ }
132
+
133
+
134
+ void TestNineCellFilters::testAspectCl ()
135
+ {
136
+ _testAlg<QgsAspectFilter>( QStringLiteral ( " aspect" ), true );
137
+ }
138
+ #endif
113
139
114
140
void TestNineCellFilters::testHillshade ()
115
141
{
@@ -128,6 +154,7 @@ void TestNineCellFilters::testTotalCurvature()
128
154
_testAlg<QgsTotalCurvatureFilter>( QStringLiteral ( " totalcurvature" ) );
129
155
}
130
156
157
+
131
158
QGSTEST_MAIN ( TestNineCellFilters )
132
159
133
160
#include " testqgsninecellfilters.moc"
0 commit comments