| 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/TeDecoderDatabase.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 *************************************************************************************/
    00027 #ifndef  __TERRALIB_INTERNAL_DECODERDATADASE_H
    00028 #define  __TERRALIB_INTERNAL_DECODERDATABASE_H
    00029
    00030 #include "TeDefines.h"
    00031 #include "TeDecoderVirtualMemory.h"
    00032 #include "TeDatabase.h"
    00033
    00035 /*
    00036            TeDecoderDatabase uses a virtual memory, to handle the raster blocks
    00037            (as proposed by the TerraLib data model to store raster data) traffic from
    00038            memory to database and vice versa.
    00039
    00040            \sa TeDatabase TeDecoderVirtualMemory
    00041 */
    00042 class TL_DLL TeDecoderDatabase: public TeDecoderVirtualMemory
    00043 {
    00044 public:
    00046            TeDecoderDatabase() :
    00047                       db_(0),
    00048                       blockPortal_(0),
    00049                       memAux_(0),
    00050                       nSelectedBlocks_(0)
    00051            {          params_.decoderIdentifier_ = "DB"; }
    00052
    00054            TeDecoderDatabase( const TeRasterParams& par );
    00055
    00057            ~TeDecoderDatabase();
    00058
    00060            void setDB (TeDatabase* db)
    00061            { db_ = db; }
    00062
    00064            virtual void init();
    00065
    00067            virtual bool create();
    00068
    00070            virtual bool clear();
    00071
    00073
    00077            bool getRasterBlock(const string& index, void *buf);
    00078
    00080
    00085            bool putRasterBlock(const string& index, void *buf, long bsize);
    00086
    00088            string codifyId(int col, int lin, int band, int res, int subb);
    00089
    00091            void decodifyId(const string& id, int& col,int& lin, int& band, int& res, int& subb);
    00092
    00093
    00095            bool saveLUTTable();
    00096
    00098            /*
    00099                       \param bb bounding box that should be filled
    00100                       \param resFac resolution factor that identify a level of resolution
    00101                       \param parBlock returns the basic parameters  of the selected tiles
    00102                       \note Resolution factor in decoder database is a multiplier of the original resolution
    00103                       and assume integer multiples of two. Smaller resolution has resolution factor
    00104                       of 1 and the higher resolution have multiple of two values (2,4,8, 16...)
    00105            */
    00106            int bestResolution(TeBox& bb, int ncols, int nlines, TeProjection* proj);
    00107
    00109            /*
    00110                       \param bb bounding box that should be filled
    00111                       \param the resolution factor desired
    00112                       \param parBlock common parameters of the blocks selected
    00113                       \returns TRUE if could select at least one block and FALSE otherwise
    00114            */
    00115            bool selectBlocks(TeBox& bb, int resFac, TeRasterParams& parBlock);
    00116
    00118            /*
    00119                       \param bb bounding box that should be filled
    00120                       \param the resolution factor desired
    00121                       \param parBlock common parameters of the blocks selected
    00122                       \param blockId to select a just one block in database
    00123                       \returns TRUE if could select at least one block and FALSE otherwise
    00124            */
    00125            bool selectBlocks(TeBox& bb, int resFac, TeRasterParams& parBlock, const std::string& blockId);
    00126
    00128            bool getSelectedRasterBlock(TeDecoderMemory* memDec);
    00129
    00131            void clearBlockSelection();
    00132
    00134            int numberOfSelectedBlocks()
    00135            {          return nSelectedBlocks_; }
    00136
    00138            virtual void blockIndexPos( const TeBlockIndex& index, int& ulCol, int& ulLin, int& band);
    00139
    00140 protected:
    00141
    00142            virtual TeBlockIndex blockIndex(int col, int lin, int band);
    00143            virtual string codifyId(const TeBlockIndex& idx, int res = 1, int subb = 0);
    00144
    00145            bool getRasterBlock(const TeBlockIndex& index, void *buf);
    00146            bool putRasterBlock(const TeBlockIndex& index, void *buf, long bsize);
    00147
    00148 private:
    00149            TeDatabase                       *db_;
    00150            TeDatabasePortal      *blockPortal_;
    00151            unsigned char                    *memAux_;
    00152            int                                                    nSelectedBlocks_;
    00153 };
    00154
    00156 class TL_DLL TeDecoderDatabaseFactory : public TeDecoderFactory
    00157 {
    00158 public:
    00159
    00161            TeDecoderDatabaseFactory(const string& name) : TeDecoderFactory(name) {}
    00162
    00164            virtual TeDecoder* build (const TeRasterParams& arg)
    00165            {  return new TeDecoderDatabase(arg); }
    00166 };
    00167 #endif
    00168

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines