00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "qgsruggednessfilter.h"
00019
00020 QgsRuggednessFilter::QgsRuggednessFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat ): QgsNineCellFilter( inputFile, outputFile, outputFormat )
00021 {
00022
00023 }
00024
00025 QgsRuggednessFilter::QgsRuggednessFilter(): QgsNineCellFilter( "", "", "" )
00026 {
00027
00028 }
00029
00030
00031 QgsRuggednessFilter::~QgsRuggednessFilter()
00032 {
00033
00034 }
00035
00036 float QgsRuggednessFilter::processNineCellWindow( float* x11, float* x21, float* x31, \
00037 float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
00038 {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 if ( *x22 == mInputNodataValue )
00054 {
00055 return mOutputNodataValue;
00056 }
00057
00058 double sum = 0;
00059 if ( *x11 != mInputNodataValue )
00060 {
00061 sum += ( *x11 - *x22 ) * ( *x11 - *x22 );
00062 }
00063 if ( *x21 != mInputNodataValue )
00064 {
00065 sum += ( *x21 - *x22 ) * ( *x21 - *x22 );
00066 }
00067 if ( *x31 != mInputNodataValue )
00068 {
00069 sum += ( *x31 - *x22 ) * ( *x31 - *x22 );
00070 }
00071 if ( *x12 != mInputNodataValue )
00072 {
00073 sum += ( *x12 - *x22 ) * ( *x12 - *x22 );
00074 }
00075 if ( *x32 != mInputNodataValue )
00076 {
00077 sum += ( *x32 - *x22 ) * ( *x32 - *x22 );
00078 }
00079 if ( *x13 != mInputNodataValue )
00080 {
00081 sum += ( *x13 - *x22 ) * ( *x13 - *x22 );
00082 }
00083 if ( *x23 != mInputNodataValue )
00084 {
00085 sum += ( *x23 - *x22 ) * ( *x23 - *x22 );
00086 }
00087 if ( *x33 != mInputNodataValue )
00088 {
00089 sum += ( *x33 - *x22 ) * ( *x33 - *x22 );
00090 }
00091
00092 return sqrt( sum );
00093 }
00094