All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Utils.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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/raster/Utils.h
22 
23  \brief Utility functions for the raster module.
24 */
25 
26 #ifndef __TERRALIB_RASTER_INTERNAL_UTILS_H
27 #define __TERRALIB_RASTER_INTERNAL_UTILS_H
28 
29 // TerraLib
30 #include "Band.h"
31 #include "BandProperty.h"
32 #include "Config.h"
33 #include "Grid.h"
34 #include "Raster.h"
35 
36 // STL
37 #include <map>
38 #include <vector>
39 
40 namespace te
41 {
42  namespace rst
43  {
44  /*! \brief Returns the byte size of a given datatype. */
45  TERASTEREXPORT int GetPixelSize(int datatype);
46 
47  /*!
48  \brief Returns a vector of band properties, based on a given raster info.
49 
50  \param rinfo The map of raster informations.
51 
52  \return A vector of band properties.
53 
54  \note The caller will take the ownership of the returned pointer.
55 
56  \warning The variable rinfo must have the properties NBANDS and BANDSTYPE defined.
57  */
58  TERASTEREXPORT std::vector<BandProperty*> GetBandProperties(const std::map<std::string, std::string>& rinfo);
59 
60  /*!
61  \brief Returns a grid based on a given raster info.
62 
63  \param rinfo The map of raster informations.
64 
65  \return A grid info.
66 
67  \note The caller will take the ownership of the returned pointer.
68 
69  \warning The parameter rinfo must have the properties NCOLS and NROWS defined.
70  \warning Optional properties in parameter rinfo are RESX, RESY, SRID, ULX and ULY.
71  */
72  TERASTEREXPORT Grid* GetGrid(const std::map<std::string, std::string>& rinfo);
73 
74  /*!
75  \brief Copies the pixel values from one raster to another.
76 
77  \param rin The input raster.
78  \param rout The output raster.
79 
80  \warning Both rasters must have the same properties of grid and number/type of bands.
81  */
82  TERASTEREXPORT void Copy(const Raster& rin, Raster& rout);
83 
84  /*!
85  \brief Copies the pixel values from one band to another.
86 
87  \param bin The input band.
88  \param bout The output band.
89 
90  \warning Both bands must have the same properties of type and grid.
91  */
92  TERASTEREXPORT void Copy(const Band& bin, Band& bout);
93 
94  /*!
95  \brief Copy a subset of the raster, given a box.
96 
97  \param method The method of interpolation. \sa te::rst::Interpolator
98  \param drow The starting row to make a subset of the image.
99  \param dcolumn The starting column to make a subset of the image.
100  \param height The height of the subset.
101  \param width The width of the subset.
102  \param rin Pointer to valid output raster.
103  \param rout Pointer to valid output raster.
104  */
105  TERASTEREXPORT void Copy(unsigned int drow, unsigned int dcolumn, unsigned int height, unsigned int width, const Raster& rin, Raster& rout);
106 
107  /*!
108  \brief Round a double value to a integer value.
109 
110  \param val The double value.
111 
112  \return A integer value.
113  */
114 
115  TERASTEREXPORT int Round(double val);
116 
117  /*!
118  \brief Create a new raster from existing one.
119 
120  \param rin The input raster.
121  \param uri The output raster URI.
122 
123  \param rType The name of the specific driver to create the raster.
124 
125  \return a valid pointer to the created raster or a null (invalid) pointer if an error ocurred.
126  */
127  TERASTEREXPORT te::rst::RasterPtr CreateCopy(const te::rst::Raster& rin, const std::string& uri,
128  const std::string& rType = std::string("GDAL"));
129 
130  /*!
131  \brief Return the values range of a given data type.
132 
133  \param dataType The given data type.
134  \param min The mininmum value allowed for the given data type.
135  \param min The maximum value allowed for the given data type.
136  */
137  TERASTEREXPORT void GetDataTypeRanges(const int& dataType, double& min, double& max);
138 
139  /*!
140  \brief Fill a Raster with provided value (all bands).
141 
142  \param rin The input raster.
143  \param value The value to fill all the bands of the Raster.
144  */
145  TERASTEREXPORT void FillRaster(te::rst::Raster* rin, const std::complex<double>& value);
146 
147  /*!
148  \brief Fill a Raster Band with provided value.
149 
150  \param bin The input band.
151  \param value The value to fill all the bands of the Raster.
152  */
153  TERASTEREXPORT void FillBand(te::rst::Band* bin, const std::complex<double>& value);
154  } // end namespace rst
155 } // end namespace te
156 
157 #endif // __TERRALIB_RASTER_INTERNAL_UTILS_H
It gives access to values in one band (dimension) of a raster.
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
Definition: Utils.cpp:295
TERASTEREXPORT int GetPixelSize(int datatype)
Returns the byte size of a given datatype.
Definition: Utils.cpp:77
TERASTEREXPORT void FillRaster(te::rst::Raster *rin, const std::complex< double > &value)
Fill a Raster with provided value (all bands).
Definition: Utils.cpp:415
It describes one band (or dimension) of a raster.
TERASTEREXPORT std::vector< BandProperty * > GetBandProperties(const std::map< std::string, std::string > &rinfo)
Returns a vector of band properties, based on a given raster info.
Definition: Utils.cpp:82
A rectified grid is the spatial support for raster data.
A raster band description.
Definition: Band.h:63
TERASTEREXPORT Grid * GetGrid(const std::map< std::string, std::string > &rinfo)
Returns a grid based on a given raster info.
Definition: Utils.cpp:108
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:93
TERASTEREXPORT te::rst::RasterPtr CreateCopy(const te::rst::Raster &rin, const std::string &uri, const std::string &rType=std::string("GDAL"))
Create a new raster from existing one.
Definition: Utils.cpp:303
An abstract class for raster data strucutures.
Definition: Raster.h:70
TERASTEREXPORT void Copy(const Raster &rin, Raster &rout)
Copies the pixel values from one raster to another.
Definition: Utils.cpp:154
TERASTEREXPORT void FillBand(te::rst::Band *bin, const std::complex< double > &value)
Fill a Raster Band with provided value.
Definition: Utils.cpp:421
Configuration flags for the Raster module of TerraLib.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
Definition: Utils.cpp:331
boost::shared_ptr< Raster > RasterPtr
Definition: Raster.h:599
An abstract class for raster data strucutures.