| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeRasterParams.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_RASTERPARAMS_H
    00027 #define  __TERRALIB_INTERNAL_RASTERPARAMS_H
    00028
    00029 #include "TeProjection.h"
    00030 #include "TeBox.h"
    00031 #include "TeDataTypes.h"
    00032 #include "TeTime.h"
    00033
    00034 #include <string>
    00035 #include <list>
    00036 #include <vector>
    00037
    00038 using namespace std;
    00039
    00040 class TeDatabase;
    00041
    00043
    00051 class TL_DLL TeRasterParams
    00052 {
    00053 public:
    00054
    00056   typedef std::pair< std::string, std::string > DecoderParamT;
    00057
    00059            enum TeRasterInterLeavingMode
    00060            {
    00061                       TePerPixel, // BIP - Band Interleaved by Pixel
    00062                       TePerLine, // BIL - Band Interleaved by Line
    00063                       TePerBand  // BSQ - Band Sequential
    00064            };
    00065
    00067            enum TeRasterPhotometricInterpretation
    00068            { TeUnknown, TePallete, TeMultiBand, TeRGB };
    00069
    00071            enum TeRasterStatus
    00072            { TeNotReady, TeReadyToRead, TeReadyToWrite };
    00073
    00075            enum TeRasterCompressionMode
    00076            { TeNoCompression, TeZLib, TeJpeg, TeTiffCompression };
    00077
    00079            enum TeRasterTilingType
    00080            {  TeExpansible=1, TeNoExpansible=2 };
    00081
    00082
    00084            TeRasterParams () :
    00085                       nlines_(0),
    00086                       ncols_(0),
    00087                       resx_(1),
    00088                       resy_(1),
    00089                       swap_(false),
    00090                       useDummy_(false),
    00091                       mode_('r'),
    00092                       status_(TeRasterParams::TeNotReady),
    00093                       resolution_(1),
    00094                       subBand_(0),
    00095                       offset_(0),
    00096                       tiling_type_(TeRasterParams::TeExpansible),
    00097                       blockHeight_(0),
    00098                       blockWidth_(0),
    00099                       nTilesInMemory_(0),
    00100                       blockId_(""),
    00101                       decoderIdentifier_(""),
    00102                       database_ (0),
    00103                       layerId_(-1),
    00104                       objectId_(""),
    00105                       interleaving_(TeRasterParams::TePerPixel),
    00106                       lutName_(""),
    00107                       dxJ_(0.0),
    00108                       dxI_(0.0),
    00109                       dyJ_(0.0),
    00110                       dyI_(0.0),
    00111                       x0_(0.0),
    00112                       y0_(0.0),
    00113                       box_(TeBox()),
    00114                       projection_(0)
    00115            {
    00116                       nbands_= 1;
    00117                       nbitsperPixel_.resize(nbands_);
    00118                       vmin_.resize(nbands_);
    00119                       vmax_.resize(nbands_);
    00120                       bands_.resize(nbands_);
    00121                       bandName_.resize(nbands_);
    00122                       photometric_.resize(nbands_);
    00123                       dataType_.resize(nbands_);
    00124                       dummy_.resize(nbands_);
    00125                       compression_.resize(nbands_);
    00126                       for (int i=0; i<nbands_; i++)
    00127                       {
    00128                                  bands_[i] = i;
    00129                                  vmin_[i] = TeMAXFLOAT;
    00130                                  vmax_[i] = -TeMAXFLOAT;
    00131                                  dataType_[i] = TeUNSIGNEDCHAR;
    00132                                  photometric_[i] = TeRasterParams::TeMultiBand;
    00133                                  dummy_[i] = 255;
    00134                       }
    00135                       hasSetDummy_ = false;
    00136            }
    00137
    00139            TeRasterParams(const TeRasterParams& other);
    00140
    00142            TeRasterParams& operator=(const TeRasterParams& rhs);
    00143
    00145            virtual ~TeRasterParams()
    00146            {
    00147                       bands_.clear();
    00148                       bandName_.clear();
    00149                       vmin_.clear();
    00150                       vmax_.clear();
    00151                       if (!lutr_.empty())
    00152                       {
    00153                                  lutr_.clear();
    00154                                  lutg_.clear();
    00155                                  lutb_.clear();
    00156                                  lutClassName_.clear();
    00157                       }
    00158                       photometric_.clear();
    00159                       dataType_.clear();
    00160                       dummy_.clear();
    00161                       compression_.clear();
    00162                       if (projection_)
    00163                                  delete projection_;
    00164                       hasSetDummy_ = false;
    00165            }
    00166
    00171
    00172            const TeBox& box() const
    00173            { return box_; }
    00174
    00176            TeBox boundingBox() const;
    00177
    00179            /*
    00180                       This methods recalculates the number of lines and columns and box accordingly to
    00181                       an input bounding box and X and Y resolutions
    00182                       \param x1 bounding box lower left point X coordinate
    00183                       \param y1 bounding box lower left point Y coordinate
    00184                       \param x2 bounding box upper right point X coordinate
    00185                       \param y2 bounding box upper right point Y coordinate
    00186                       \param resx X resolution
    00187                       \param resy Y resolution
    00188                       \param lock corner of the bounding box that should be preserved
    00189            */
    00190            void boundingBoxResolution (double x1, double y1, double x2, double y2,
    00191                                             double resx, double resy, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
    00192
    00194            /*
    00195                       This methods recalculates the resolutions and box accordingly to
    00196                       a given bounding box and number of lines and columns
    00197                       \param x1 bounding box lower left point X coordinate
    00198                       \param y1 bounding box lower left point Y coordinate
    00199                       \param x2 bounding box upper right point X coordinate
    00200                       \param y2 bounding box upper right point Y coordinate
    00201                       \param nlines  number of lines
    00202                       \param ncols number of columns
    00203                       \param lock corner of the bounding box that should be preserved
    00204            */
    00205            void boundingBoxLinesColumns (double x1, double y1, double x2, double y2,
    00206                                                 int nlines, int ncols, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
    00207
    00209            /*
    00210                       This methods recalculates the number of lines and columns and box accordingly to
    00211                       a given box and X and Y resolutions
    00212                       \param x1 box lower left point X coordinate
    00213                       \param y1 box lower left point Y coordinate
    00214                       \param x2 box upper right point X coordinate
    00215                       \param y2 box upper right point Y coordinate
    00216                       \param resx X resolution
    00217                       \param resy Y resolution
    00218                       \param lock corner of the bounding box that should be preserved
    00219            */
    00220            void boxResolution (double x1, double y1, double x2, double y2,
    00221                                       double resx, double resy, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
    00222
    00224            /*
    00225                       This methods recalculates the resolutions and box accordingly to
    00226                       a given box and number of lines and columns
    00227                       \param x1 box lower left point X coordinate
    00228                       \param y1 box lower left point Y coordinate
    00229                       \param x2 box upper right point X coordinate
    00230                       \param y2 box upper right point Y coordinate
    00231                       \param nlines  number of lines
    00232                       \param ncols number of columns
    00233                       \par Calculates X resolution and Y resolution
    00234                       \param lock corner of the bounding box that should be preserved
    00235            */
    00236            void boxLinesColumns (double x1, double y1, double x2, double y2,
    00237                                         int nlines, int ncols, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
    00238
    00240            /*
    00241                       \param left lower left point X coordinate
    00242                       \param top  upper right point Y coordinate
    00243                       \param resx X resolution
    00244                       \param resy Y resolution
    00245                       \param nlines  number of lines
    00246                       \param ncols number of columns
    00247                       \param coordIsCentrePixel flag to indicate that top left coordinate is centre of pixel
    00248            */
    00249            void topLeftResolutionSize (double left, double top, double resx, double resy, int ncol, int nlin, bool coordIsCentrePixel=true);
    00250
    00252            /*
    00253                       \param left lower left point X coordinate
    00254                       \param lower lower left point Y coordinate
    00255                       \param resx X resolution
    00256                       \param resy Y resolution
    00257                       \param nlines  number of lines
    00258                       \param ncols number of columns
    00259                       \param coordIsCentrePixel flag to indicate that top left coordinate is centre of pixel
    00260            */
    00261            void lowerLeftResolutionSize (double left, double lower, double resx, double resy, int ncol, int nlin, bool coordIsCentrePixel=true);
    00262
    00264            /*
    00265                       Sets a valid bouding box, considering a resolution of 1x1 and
    00266                       that the coordinate of the center of lower-left element is (0.5,0.5)
    00267                       \param nlines  number of lines
    00268                       \param ncols number of columns
    00269            */
    00270            void setNLinesNColumns(int nlines, int ncolumns);
    00271
    00273
    00279            void resizeToTiling(TeBox& bb, int bWidth, int bHeight);
    00281
    00283            /*
    00284                       \param n number of bands
    00285                       \note If the required number of bands is greater than the
    00286                       current number of bands, the last band characteristics
    00287                       will be copied to the new defined bands.
    00288            */
    00289            void nBands(int n);
    00290
    00292            /*
    00293                       \param proj a pointer to a terralib projection instance
    00294                       A new instance of projection is created according to the parameters described by proj.
    00295            */
    00296            void projection(TeProjection* proj);
    00297
    00299            TeProjection* projection()
    00300            {          return projection_; }
    00301
    00302
    00304            TeCoord2D coord2Index (const TeCoord2D& pt) const;
    00305
    00307            TeCoord2D index2Coord (const TeCoord2D& pt) const;
    00308
    00309
    00310            int nlines_;
    00311            int ncols_;
    00312
    00313            double     resx_,
    00314                       resy_;
    00315
    00316            bool swap_;
    00317            bool useDummy_;
    00318            char       mode_;
    00319            TeRasterStatus        status_;
    00320            TeTime                           date_;
    00321            std::vector< DecoderParamT > decoderParams_;
    00322
    00326            vector<int>           nbitsperPixel_;
    00327            vector<double>        vmin_;
    00328            vector<double>        vmax_;
    00329            vector<int>           bands_;
    00330            vector<double>        dummy_;
    00331            vector<string> bandName_;
    00332            vector<TeRasterPhotometricInterpretation>   photometric_;
    00333            vector<TeRasterCompressionMode>  compression_;
    00334            vector<TeDataType>               dataType_;
    00335
    00337            /*
    00338                       \param type the computational data type
    00339                       \param band number of the band. Default: all bands
    00340            */
    00341            void setDataType(TeDataType type, int band=-1);
    00342
    00344            int elementSize(int band=0);
    00345
    00347            /*
    00348                       \param photom the photometric interpretation
    00349                       \param band number of the band. Default: all bands
    00350            */
    00351            void setPhotometric(TeRasterPhotometricInterpretation photom, int band=-1);
    00352
    00354            /*
    00355                       \param cmode the compression mode
    00356                       \param band number of the band. Default: all bands
    00357            */
    00358            void setCompressionMode(TeRasterCompressionMode cmode, int band=-1);
    00359
    00361            /*
    00362                       \param dummy dummy value
    00363                       \param band number of the band. Default: all bands
    00364            */
    00365            void setDummy(double dummy, int band=-1);
    00366
    00368            /*
    00369                       \param name band name
    00370                       \param band number of the band. No default value
    00371            */
    00372            void setBandName(string name, int band);
    00374
    00379            int resolution_;
    00380            int subBand_;
    00381
    00382
    00387            string     fileName_;
    00388            int offset_;
    00389
    00390
    00394            TeRasterTilingType    tiling_type_;
    00395            int blockHeight_;
    00396            int blockWidth_;
    00397            int nTilesInMemory_;
    00398            string blockId_;
    00399
    00400
    00401            string     decoderIdentifier_;
    00402
    00404            const string& decName() const
    00405            { return decoderIdentifier_; }
    00406
    00410            TeDatabase*           database_;
    00411            int                   layerId_;
    00412            string                objectId_;
    00413
    00414
    00415            TeRasterInterLeavingMode interleaving_;
    00416
    00421            string     lutName_;
    00422            vector<unsigned short> lutr_;
    00423            vector<unsigned short> lutg_;
    00424            vector<unsigned short> lutb_;
    00425            vector<string> lutClassName_;
    00426
    00428            const string& lutName()
    00429            { return lutName_; }
    00431
    00436            double dxJ_;
    00437            double dxI_;
    00438            double dyJ_;
    00439            double dyI_;
    00440            double x0_;
    00441            double y0_;
    00442
    00467            void setNavigationParameters(const vector<double>& nwf);
    00468
    00491            void getNavigationParameters(vector<double>& nwf);
    00493
    00495            int nBands() const
    00496            { return nbands_; }
    00497
    00499            void writeParametersFile();
    00500
    00502            void readParametersFile();
    00503
    00505            string errorMessage_;
    00506
    00507 private:
    00508            int        nbands_;
    00509            TeBox      box_;
    00510            TeProjection* projection_;
    00511            bool hasSetDummy_;
    00512 };
    00513
    00514 #endif
    00515
    00516
    00517

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines