Loading...
Searching...
No Matches
Raster.h
Go to the documentation of this file.
1/* Copyright (C) 2008 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#include "ScopedDataSetHandle.h"
35
36#include <string>
37#include <memory>
38
39#include <gdal_priv.h>
40
41// Forward declaration
42class GDALDataset;
43class GDALRasterBand;
44
45namespace te
46{
47 namespace gdal
48 {
49 // Forward declaration
50 class Band;
51
52 /*!
53 \class Raster
54
55 \brief This class represents Raster data.
56
57 This class is a concrete implementation of a Raster using the GDAL library to access
58 the data.
59
60 \sa te::rst::Raster
61 */
63 {
64 public:
65
67
69
70 /*!
71 \brief Constructor.
72
73 \param rinfo The information needed to open the raster.
74 \param p Access Policy.
75 */
76 Raster(const std::string& rinfo,
78
79 /*!
80 \brief Constructor.
81
82 \param grid The grid definition. The Raster will take its ownership.
83 \param bprops A vector of band properties, one for each band. The Raster will take its ownership.
84 \param metadata Raster metadata in a form [metadata name, value].
85 \param optparams Extra information to create the raster. See GDAL documentation for more information.
86 Parameters include NBANDS, BANDSTYPE, NCOLS, NROWS, RESX, RESY, SRID, ULX, ULY.
87 \param p Access Policy.
88 */
90 const std::vector<te::rst::BandProperty*>& bprops,
91 const std::map<std::string, std::string>& optParams,
92 const std::map<std::string, std::string>& metadata,
94
95 /*!
96 \brief Constructor.
97
98 \param gdataset A GDAL dataset handler.
99 \param p Access Policy.
100 */
101 //Raster(GDALDataset* gdataset, te::common::AccessPolicy p = te::common::RAccess);
102
103 Raster(const Raster& rhs);
104
106
107 void open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p = te::common::RAccess);
108
109 std::map<std::string, std::string> getInfo() const;
110
111 std::size_t getNumberOfBands() const;
112
113 int getBandDataType(std::size_t i) const;
114
115 const te::rst::Band* getBand(std::size_t i) const;
116
117 te::rst::Band* getBand(std::size_t i);
118
119 const te::rst::Band& operator[](std::size_t i) const;
120
121 te::rst::Band& operator[](std::size_t i);
122
123 /*! \brief Returns the raster GDAL handler. */
124 GDALDataset* getGDALDataset() const;
125
127
128 Raster& operator=(const Raster& rhs);
129
130 te::rst::Raster* resample(int method, int scale, const std::map<std::string, std::string>& rinfo) const;
131
132 /*!
133 \note When the parameter USE_TERRALIB_REPROJECTION = TRUE in rinfo, the default terralib internal reprojection will be called.
134 Otherwise this method will may call the GDAL reprojection method (only for recognized spatial reference systems). The rinfo must define a GDAL compatible raster.
135 The parameter m (interpolation method) is not used in GDAL implementation.
136 */
137 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;
138
139 void transform(te::rst::Raster* outRaster);
140
141 /*!
142 \note GDAL driver extended method.
143 */
145 const std::vector<te::rst::BandProperty*> bands,
146 const std::map<std::string, std::string>& rinfo,
147 const std::map<std::string, std::string>& metadata,
148 void* h, void (*deleter)(void*));
149
150 bool createMultiResolution( const unsigned int levels, const te::rst::InterpolationMethod interpMethod );
151
153
154 unsigned int getMultiResLevelsCount() const;
155
156 te::rst::Raster* getMultiResLevel( const unsigned int level ) const;
157
158 protected :
159
160 /*!
161 \brief Constructor.
162
163 \param multiResolutionLevel Level of a multi-resolution pyramid.
164 \param uRI The raster URI.
165 \param policy The raster access policy.
166 */
167 Raster( const unsigned int multiResolutionLevel, const std::string& uRI,
168 const te::common::AccessPolicy& policy );
169
170 private:
171
172 ScopedDataSetHandlePtr m_gdatasetHandle; //!< Gdal data set handler.
173 std::vector<Band*> m_bands; //!< The vector of available bands in the raster.
174 void (*m_deleter)(void*); //!< A pointer to a deleter function, if the buffer needs to be deleted by this object.
175 std::string m_myURI; //!< This instance URI;
176 std::unique_ptr<DataSetUseCounter> m_dsUseCounterPtr; //!< Dataset use counter pointer.
177 };
178 } // end namespace gdal
179} // end namespace te
180
181#endif // __TERRALIB_GDAL_INTERNAL_RASTER_H
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
This class represents Raster data.
Definition: Raster.h:63
te::dt::AbstractData * clone() const
It returns a clone of this object.
te::rst::Band * getBand(std::size_t i)
Returns the raster i-th band.
ScopedDataSetHandlePtr m_gdatasetHandle
Gdal data set handler.
Definition: Raster.h:172
std::unique_ptr< DataSetUseCounter > m_dsUseCounterPtr
Dataset use counter pointer.
Definition: Raster.h:176
bool removeMultiResolution()
Remove/Destroy a sub-sampled multi-resolution pyramid, if there is one.
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
std::vector< Band * > m_bands
The vector of available bands in the raster.
Definition: Raster.h:173
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
Raster & operator=(const Raster &rhs)
GDALDataset * getGDALDataset() const
Returns the raster GDAL handler.
Raster(const std::string &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Constructor.
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
te::rst::Raster * getMultiResLevel(const unsigned int level) const
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists.
te::rst::Band & operator[](std::size_t i)
Access band in i position.
void create(te::rst::Grid *g, const std::vector< te::rst::BandProperty * > bands, const std::map< std::string, std::string > &rinfo, const std::map< std::string, std::string > &metadata, void *h, void(*deleter)(void *))
void transform(te::rst::Raster *outRaster)
Raster(te::rst::Grid *grid, const std::vector< te::rst::BandProperty * > &bprops, const std::map< std::string, std::string > &optParams, const std::map< std::string, std::string > &metadata, te::common::AccessPolicy p=te::common::RAccess)
Constructor.
te::rst::Raster * resample(int method, int scale, const std::map< std::string, std::string > &rinfo) const
Resample raster.
~Raster()
Virtual destructor.
Raster(const unsigned int multiResolutionLevel, const std::string &uRI, const te::common::AccessPolicy &policy)
Constructor.
std::string m_myURI
This instance URI;.
Definition: Raster.h:175
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
Raster(const Raster &rhs)
Constructor.
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
bool createMultiResolution(const unsigned int levels, const te::rst::InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
A raster band description.
Definition: Band.h:64
A rectified grid is the spatial support for raster data.
Definition: Grid.h:69
An abstract class for raster data strucutures.
Definition: Raster.h:72
virtual Raster * transform(int srid, const std::map< std::string, std::string > &rinfo, int m=1) const
Reprojects this raster to a distinct SRS. This method reprojects this raster to a distinct SRS....
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
@ RAccess
Definition: Enums.h:43
std::unique_ptr< ScopedDataSetHandle > ScopedDataSetHandlePtr
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
TerraLib.
Band implementation for TerraLib 4.x.
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
Proxy configuration file for TerraView (see terraview_config.h).