Utils.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/statistics/core/Utils.h
22 
23  \brief Utility functions for Statistics.
24 */
25 
26 #ifndef __TERRALIB_ATTRIBUTEFILL_CORE_INTERNAL_UTILS_H
27 #define __TERRALIB_ATTRIBUTEFILL_CORE_INTERNAL_UTILS_H
28 
29 // Terralib
30 #include "Config.h"
31 #include "Enums.h"
32 
33 #include "../geometry/Coord2D.h"
34 #include "../geometry/Geometry.h"
35 #include "../geometry/Polygon.h"
36 #include "../raster/Grid.h"
37 #include "../raster/Raster.h"
38 
39 // STL
40 #include <map>
41 #include <string>
42 
43 namespace te
44 {
45  namespace attributefill
46  {
47  /*!
48  \brief Gets the full name of the operation as string.
49 
50  \param e The enumerator.
51 
52  \return The full name for the operation.
53  */
54  TEATTRIBUTEFILLEXPORT std::string GetOperationFullName(const int& e);
55 
56  /*!
57  \brief Convert the coordinate to the grid col/row postion of the pixel .
58 
59  If the coordinate is outside the grid extent the function will
60  return std::numeric_limits<uint32_t>::max for col and/or row the is outside.
61  The other value is valid.
62 
63  \return Pair of <col, row> of the pixel at the coord.
64  */
65  TEATTRIBUTEFILLEXPORT std::pair<uint32_t, uint32_t> GeoToGrid(const te::gm::Coord2D& coord,
66  const rst::Grid &grid);
67 
68  /*!
69  \brief Gets the minimum and maximum row and column values of the raster based on polygon.
70 
71  \param raster The raster.
72  \param polygon The polygon.
73  \param minimumRow Minimum value for row
74  \param minimumColumn Minimum value for column
75  \param maximumRow Maximum value for row
76  \param maximumColumn Maximum value for column
77 
78  \return Fills the minimum and maximum values.
79  */
81  const te::gm::Polygon &polygon,
82  uint32_t &minimumRow, uint32_t &minimumColumn,
83  uint32_t &maximumRow, uint32_t &maximumColumn);
84 
85  /*!
86  \brief Gets the pixel values for a specific band that intersects the polygon.
87 
88  The computation is based on the intersection of the pixel resolution and the polygon.
89 
90  \param raster The raster.
91  \param band The band.
92  \param polygon The polygon.
93  \param minimumRow Minimum value for row
94  \param minimumColumn Minimum value for column
95  \param maximumRow Maximum value for row
96  \param maximumColumn Maximum value for column
97  \param values A map<key, value> where the key will be filled with the pixel and the value with the number of occurrence.
98 
99  \return A map<key, value> of values that the key is the pixel and the value is the number of occurrence.
100  */
102  const unsigned int &band,
103  const gm::Polygon &polygon,
104  const uint32_t &minimumRow,
105  const uint32_t &minimumColumn,
106  const uint32_t &maximumRow,
107  const uint32_t &maximumColumn,
108  std::map<double, int>& values);
109 
110  /*!
111  \brief Gets the pixel percentage for a specific band that intersects the polygon.
112 
113  The computation is based on the intersection of the pixel resolution and the polygon.
114 
115  \param raster The raster.
116  \param band The band.
117  \param polygon The polygon.
118  \param minimumRow Minimum value for row
119  \param minimumColumn Minimum value for column
120  \param maximumRow Maximum value for row
121  \param maximumColumn Maximum value for column
122  \param percentOfEachClassByArea A map<key, value> where the key will be filled with the pixel and the value with the percentage of occurence.
123 
124  \return A map<key, value> of values that the key is the pixel and the value is the percentage of occurrence.
125  */
127  const unsigned int &band,
128  const gm::Polygon &polygon,
129  const uint32_t &minimumRow,
130  const uint32_t &minimumColumn,
131  const uint32_t &maximumRow,
132  const uint32_t &maximumColumn,
133  std::map<double, double> &percentOfEachClassByArea);
134 
135  } // end namespace attributefill
136 } // end namespace te
137 
138 #endif // __TERRALIB_ATTRIBUTEFILL_CORE_INTERNAL_UTILS_H
TEATTRIBUTEFILLEXPORT void GetPercentOfEachClassByArea(const te::rst::Raster &raster, const unsigned int &band, const gm::Polygon &polygon, const uint32_t &minimumRow, const uint32_t &minimumColumn, const uint32_t &maximumRow, const uint32_t &maximumColumn, std::map< double, double > &percentOfEachClassByArea)
Gets the pixel percentage for a specific band that intersects the polygon.
Configuration flags for the Attribute Fill module of TerraLib.
TEATTRIBUTEFILLEXPORT void GetValuesFromBand(const te::rst::Raster &raster, const unsigned int &band, const gm::Polygon &polygon, const uint32_t &minimumRow, const uint32_t &minimumColumn, const uint32_t &maximumRow, const uint32_t &maximumColumn, std::map< double, int > &values)
Gets the pixel values for a specific band that intersects the polygon.
TEATTRIBUTEFILLEXPORT void GetMinMaxLineAndColumn(const te::rst::Raster &raster, const te::gm::Polygon &polygon, uint32_t &minimumRow, uint32_t &minimumColumn, uint32_t &maximumRow, uint32_t &maximumColumn)
Gets the minimum and maximum row and column values of the raster based on polygon.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
#define TEATTRIBUTEFILLEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
TEATTRIBUTEFILLEXPORT std::pair< uint32_t, uint32_t > GeoToGrid(const te::gm::Coord2D &coord, const rst::Grid &grid)
Convert the coordinate to the grid col/row postion of the pixel .
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
TEATTRIBUTEFILLEXPORT std::string GetOperationFullName(const int &e)
Gets the full name of the operation as string.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50