All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Raster.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/gdal/Raster.h
22 
23  \brief This is a class that represents a GDAL Raster.
24  */
25 
26 #ifndef __TERRALIB_GDAL_INTERNAL_RASTER_H
27 #define __TERRALIB_GDAL_INTERNAL_RASTER_H
28 
29 //TerraLib
30 #include "../raster/Raster.h"
31 #include "Band.h"
32 #include "Config.h"
33 #include "DataSetUseCounter.h"
34 
35 #include <string>
36 #include <memory>
37 
38 // Forward declaration
39 class GDALDataset;
40 class GDALRasterBand;
41 
42 namespace te
43 {
44  namespace gdal
45  {
46  // Forward declaration
47  class Band;
48 
49  /*!
50  \class Raster
51 
52  \brief This class represents Raster data.
53 
54  This class is a concrete implementation of a Raster using the GDAL library to access
55  the data.
56 
57  \sa te::rst::Raster
58  */
60  {
61  public:
62 
63  Raster();
64 
65  /*!
66  \brief Constructor.
67 
68  \param rinfo The information needed to open the raster.
69  \param p Access Policy.
70  */
71  Raster(const std::string& rinfo, te::common::AccessPolicy p = te::common::RAccess);
72 
73  /*!
74  \brief Constructor.
75 
76  \param grid The grid definition. The Raster will take its ownership.
77  \param bprops A vector of band properties, one for each band. The Raster will take its ownership.
78  \param optparams Extra information to create the raster. See GDAL documentation for more information.
79  Parameters include NBANDS, BANDSTYPE, NCOLS, NROWS, RESX, RESY, SRID, ULX, ULY.
80  \param p Access Policy.
81  */
82  Raster(te::rst::Grid* grid, const std::vector<te::rst::BandProperty*>& bprops, const std::map<std::string, std::string>& optParams, te::common::AccessPolicy p = te::common::RAccess);
83 
84  /*!
85  \brief Constructor.
86 
87  \param gdataset A GDAL dataset handler.
88  \param p Access Policy.
89  */
90  //Raster(GDALDataset* gdataset, te::common::AccessPolicy p = te::common::RAccess);
91 
92  Raster(const Raster& rhs);
93 
94  ~Raster();
95 
96  void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
97 
98  std::map<std::string, std::string> getInfo() const;
99 
100  std::size_t getNumberOfBands() const;
101 
102  int getBandDataType(std::size_t i) const;
103 
104  const te::rst::Band* getBand(std::size_t i) const;
105 
106  te::rst::Band* getBand(std::size_t i);
107 
108  const te::rst::Band& operator[](std::size_t i) const;
109 
110  te::rst::Band& operator[](std::size_t i);
111 
112  /*! \brief Returns the raster GDAL handler. */
113  GDALDataset* getGDALDataset() const;
114 
115  te::dt::AbstractData* clone() const;
116 
117  Raster& operator=(const Raster& rhs);
118 
119  te::rst::Raster* resample(int method, int scale, const std::map<std::string, std::string>& rinfo);
120 
121  /*!
122  \note When the parameter USE_TERRALIB_REPROJECTION = TRUE in rinfo, the default reprojection will be called.
123  Otherwise this method will call the GDAL reprojection method. The rinfo must define a GDAL compatible raster.
124  The parameter m (interpolation method) is not used in GDAL implementation.
125  */
126  te::rst::Raster* transform(int srid, double llx, double lly, double urx, double ury, double resx, double resy, const std::map<std::string, std::string>& rinfo, int m = 0) const;
127 
128  void transform(te::rst::Raster* outRaster);
129 
130  /*!
131  \note GDAL driver extended method.
132  */
133  void create(te::rst::Grid* g,
134  const std::vector<te::rst::BandProperty*> bands,
135  const std::map<std::string, std::string>& rinfo,
136  void* h, void (*deleter)(void*));
137 
138 
139  private:
140 
141  GDALDataset* m_gdataset; //!< Gdal data set handler.
142  std::vector<Band*> m_bands; //!< The vector of available bands in the raster.
143  void (*m_deleter)(void*); //!< A pointer to a deleter function, if the buffer needs to be deleted by this object.
144  std::string m_myURI; //!< This instance URI;
145  std::auto_ptr< DataSetUseCounter > m_dsUseCounterPtr; //!< Dataset use counter pointer.
146  };
147  } // end namespace gdal
148 } // end namespace te
149 
150 #endif // __TERRALIB_GDAL_INTERNAL_RASTER_H
Configuration flags for the GDAL Driver of TerraLib.
This class represents Raster data.
Definition: Raster.h:59
It gives access to values in one band (dimension) of a raster.
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
std::string m_myURI
This instance URI;.
Definition: Raster.h:144
A raster band description.
Definition: Band.h:63
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
std::auto_ptr< DataSetUseCounter > m_dsUseCounterPtr
Dataset use counter pointer.
Definition: Raster.h:145
std::vector< Band * > m_bands
The vector of available bands in the raster.
Definition: Raster.h:142
GDALDataset * m_gdataset
Gdal data set handler.
Definition: Raster.h:141
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:113
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
An abstract class for raster data strucutures.
Definition: Raster.h:70