| 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/TeCoverageDecoder.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 *************************************************************************************/
    00029 #ifndef  __TERRALIB_INTERNAL_COVERAGEDECODER_H
    00030 #define  __TERRALIB_INTERNAL_COVERAGEDECODER_H
    00031
    00032 #include "TeCoord2D.h"
    00033 #include "TeException.h"
    00034 #include "TeBlockLoader.h"
    00035 #include "TeCoverageParams.h"
    00036 #include "TeCoverageUtils.h"
    00037 #include "TeSpatialOperations.h"
    00038 #include <map>
    00039 #include <vector>
    00040
    00045 #define READ(data, t) *(t*)data; data += sizeof(t)
    00046
    00051 template <class T>
    00052 struct TeGeomValuePair
    00053 {
    00054     T geom;
    00055     std::vector<double> value;
    00056
    00058     TeGeomValuePair(){}
    00059
    00061     TeGeomValuePair(const T& geom,
    00062                      const std::vector<double>& value):
    00063             geom(geom),
    00064             value(value){}
    00065 };
    00066
    00067
    00068
    00077 template <class T>
    00078 struct TeCoverageBlock
    00079 {
    00080     int id;
    00081     TeBox box;
    00082     std::vector<TeGeomValuePair<T> > pairs;
    00083 };
    00084
    00093 template <class T>
    00094 class TeCoverageDecoder
    00095 {
    00096 public:
    00097
    00099     TeCoverageDecoder(TeCoverageParams& params) :
    00100         params_(params)
    00101     {
    00102     }
    00103
    00105     virtual ~TeCoverageDecoder()
    00106     {
    00107         clear();
    00108     }
    00109
    00111     virtual TeCoverageParams& getParameters()
    00112     {
    00113         return params_;
    00114     }
    00115
    00117
    00121     virtual void init()
    00122     {
    00123     }
    00124
    00126
    00130     virtual void clear()
    00131     {
    00132     }
    00133
    00135
    00145     virtual void selectGeomValuePairs(const TePolygon& poly, const TeSpatialRelation relation, std::vector<TeGeomValuePair<T> >& selected)
    00146     {
    00147         // Select blocks which contain geometries that might respect the
    00148         // spatial relation with the polygon
    00149         std::vector<TeCoverageBlock<T> >& blocks = std::vector<TeCoverageBlock<T> >();
    00150         selectBlocks(poly, TeINTERSECTS, blocks);
    00151
    00152         for (std::vector<TeCoverageBlock<T> >::iterator itBlocks = blocks.begin(); itBlocks != blocks.end(); ++itBlocks)
    00153         {
    00154             // Look at all geometry-value pairs of selected blocks
    00155             std::vector<TeGeomValuePair<T> >& pairs = itBlocks->pairs;
    00156             for (std::vector<TeGeomValuePair<T> >::iterator it = pairs.begin(); it != pairs.end(); ++it)
    00157             {
    00158                 // If the spatial relation holds, add geom-value pair to the result
    00159                 if (TeTopologicalRelation(&poly, &it->geom, relation))
    00160                 {
    00161                     selected.push_back(*it);
    00162                 }
    00163             }
    00164         }
    00165     }
    00166
    00168
    00179     virtual void selectBlocks(const TePolygon& poly, const TeSpatialRelation relation, std::vector<TeCoverageBlock<T> >& selected, std::set<int>& dontSelect = std::set<int>()) = 0;
    00180
    00181 protected:
    00182
    00183     TeCoverageParams& params_;
    00184 };
    00185
    00186 #endif // __TERRALIB_INTERNAL_COVERAGEDECODER_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines