17
17
18
18
#include " qgsaspectfilter.h"
19
19
20
- QgsAspectFilter::QgsAspectFilter ( const QString& inputFile, const QString& outputFile, const QString& outputFormat ): \
20
+ QgsAspectFilter::QgsAspectFilter ( const QString& inputFile, const QString& outputFile, const QString& outputFormat ) :
21
21
QgsDerivativeFilter( inputFile, outputFile, outputFormat )
22
22
{
23
23
@@ -28,40 +28,23 @@ QgsAspectFilter::~QgsAspectFilter()
28
28
29
29
}
30
30
31
- float QgsAspectFilter::processNineCellWindow ( float * x11, float * x21, float * x31, float * x12, float * x22, \
32
- float * x32, float * x13, float * x23, float * x33 )
31
+ float QgsAspectFilter::processNineCellWindow (
32
+ float * x11, float * x21, float * x31,
33
+ float * x12, float * x22, float * x32,
34
+ float * x13, float * x23, float * x33 )
33
35
{
34
36
float derX = calcFirstDerX ( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
35
37
float derY = calcFirstDerY ( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
36
38
37
- if ( derX == mOutputNodataValue || derY == mOutputNodataValue )
39
+ if ( derX == mOutputNodataValue ||
40
+ derY == mOutputNodataValue ||
41
+ (derX == 0.0 && derY == 0.0 ) )
38
42
{
39
43
return mOutputNodataValue ;
40
44
}
41
-
42
- if ( derY < 0 && derX > 0 )
43
- {
44
- return 360 + ( atan ( derX / derY ) * 180 / M_PI );
45
- }
46
- else if ( derY < 0 && derX < 0 )
47
- {
48
- return atan ( derX / derY ) * 180 / M_PI;
49
- }
50
- else if ( derY > 0 )
51
- {
52
- return ( atan ( derX / derY ) * 180 / M_PI ) + 180 ;
53
- }
54
- else if ( derX < 0 && derY == 0 )
55
- {
56
- return 90 ;
57
- }
58
- else if ( derX > 0 && derY == 0 )
45
+ else
59
46
{
60
- return 270 ;
61
- }
62
- else if ( derX == 0 && derY == 0 )
63
- {
64
- return mOutputNodataValue ;
47
+ return 180.0 + atan2 (derX, derY) * 180.0 / M_PI;
65
48
}
66
49
}
67
50
0 commit comments