Quantum GIS API Documentation  1.8
src/analysis/raster/qgsrelief.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsrelief.h  -  description
00003                           ---------------------------
00004     begin                : November 2011
00005     copyright            : (C) 2011 by Marco Hugentobler
00006     email                : marco dot hugentobler at sourcepole dot ch
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QGSRELIEF_H
00019 #define QGSRELIEF_H
00020 
00021 #include <QColor>
00022 #include <QMap>
00023 #include <QPair>
00024 #include <QString>
00025 #include "gdal.h"
00026 
00027 class QgsAspectFilter;
00028 class QgsSlopeFilter;
00029 class QgsHillshadeFilter;
00030 class QProgressDialog;
00031 
00033 class ANALYSIS_EXPORT QgsRelief
00034 {
00035   public:
00036     struct ReliefColor
00037     {
00038       ReliefColor( const QColor& c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
00039       QColor color;
00040       double minElevation;
00041       double maxElevation;
00042     };
00043 
00044     QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
00045     ~QgsRelief();
00046 
00050     int processRaster( QProgressDialog* p );
00051 
00052     double zFactor() const { return mZFactor; }
00053     void setZFactor( double factor ) { mZFactor = factor; }
00054 
00055     void clearReliefColors();
00056     void addReliefColorClass( const ReliefColor& color );
00057     const QList< ReliefColor >& reliefColors() const { return mReliefColors; }
00058     void setReliefColors( const QList< ReliefColor >& c ) { mReliefColors = c; }
00059 
00062     QList< ReliefColor > calculateOptimizedReliefClasses();
00063 
00065     bool exportFrequencyDistributionToCsv( const QString& file );
00066 
00067   private:
00068 
00069     QString mInputFile;
00070     QString mOutputFile;
00071     QString mOutputFormat;
00072 
00073     double mCellSizeX;
00074     double mCellSizeY;
00076     float mInputNodataValue;
00078     float mOutputNodataValue;
00079 
00080     double mZFactor;
00081 
00082     QgsSlopeFilter* mSlopeFilter;
00083     QgsAspectFilter* mAspectFilter;
00084     QgsHillshadeFilter* mHillshadeFilter285;
00085     QgsHillshadeFilter* mHillshadeFilter300;
00086     QgsHillshadeFilter* mHillshadeFilter315;
00087 
00088     //relief colors and corresponding elevations
00089     QList< ReliefColor > mReliefColors;
00090 
00091     bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
00092                                 unsigned char* red, unsigned char* green, unsigned char* blue );
00093 
00095     GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
00098     GDALDriverH openOutputDriver();
00101     GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
00102 
00104     bool setElevationColor( double elevation, int* red, int* green, int* blue );
00105 
00107     void setDefaultReliefColors();
00110     int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
00112     void optimiseClassBreaks( QList<int>& breaks, double* frequencies );
00118     bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );
00119 };
00120 
00121 #endif // QGSRELIEF_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines