Vectorizer.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
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/Vectorizer.h
22
23  \brief It implements the vectorizer, based on TerraLib 4 algorithm.
24 */
25
26 #ifndef __TERRALIB_RASTER_INTERNAL_VECTORIZER_H
27 #define __TERRALIB_RASTER_INTERNAL_VECTORIZER_H
28
29
30
31 // TerraLib
32 #include "../geometry/Coord2D.h"
33 #include "../geometry/LineString.h"
34 #include "../sam/rtree.h"
35 #include "Enums.h"
36 #include "Raster.h"
38
39 // STL
40 #include <vector>
41
42 namespace te
43 {
44  namespace rst
45  {
46 // Forward declaration.
47  class Raster;
48
49  /*!
50  \class Vectorizer
51
52  \brief It implements the vectorizer, based on TerraLib 4 algorithm.
53
54  This algorithm implements a vectorizer, which is an algorithm to convert an
55  image with pixel-labels into a set of polygons. All connected pixels in the
56  image with the same label will define an individual polygon. This algorithm
57  is based on the implementation of the previous version of this library, the
58  TerraLib 4.
59
60  \ingroup rst
61
62  \sa Raster, Geometry
63  */
65  {
66  public:
67
68  /*!
69  \brief Constructor.
70
71  \param r The input raster.
72  \param b The selected band of the raster to be vectorized.
73  \param mp The maximum allowed number of polygons to be created (default = 0, unlimited).
74  \param noDataExclusion If true, regions with no-data pixels will not generate geometries.
75  */
76  Vectorizer(Raster* r, std::size_t b, unsigned int mp = 0, const bool noDataExclusion = true );
77
78  /*!
79  \brief Copy constructor.
80
81  \param rhs The right-hand-side copy that would be used to copy from.
82  */
83  Vectorizer(const Vectorizer& rhs);
84
85  /*! \brief Destructor. */
86  ~Vectorizer();
87
88  /*!
89  \brief Assignment operator.
90
91  \param rhs The right-hand-side copy that would be used to copy from.
92
93  \return A reference to this object.
94  */
95  Vectorizer& operator=(const Vectorizer& rhs);
96
97  /*!
98  \brief Returns true if current algorithm implementation runs ok, false otherwise.
99
100  \param polygons The vector of polygons (will be cleared) to get the result of the vectorization.
101
102  \param polygonsValues A pointer to a valid vector where the raster pixel values related to each polygon will be stored, or a NULL pointer.
103
104  \note The caller of this method must take the ownership of the returned geometries and must delete them when necessary.
105  */
106  bool run(std::vector<te::gm::Geometry*>& polygons, std::vector< double > * const polygonsValues = 0 );
107
108  protected :
109
110  /*!
111  \brief Tests if the current point is a edge start.
112
113  \param x X coord.
114  \param y Y coord.
115
116  \return true if the current point is a edge start, false if not.
117  */
118  bool startingEdgeTest(const int& x, const int& y);
119
120  /*!
121  \brief Detects an edge of a cell in Raster.
122
123  \param segmentInitialCol abscissa (column) of the upper-left point of the shape
124  \param segmentInitialRow ordinate (line) of the upper-left point of the shape
125  \param line 2D Line.
126
127  \return true if ok, otherwise false
128  */
129  bool detectEdge(long segmentInitialCol, long segmentInitialRow, te::gm::LinearRing& outputLine);
130
131
132
133  /*! \brief Clear all internally allocated resources. */
134  void clear();
135
136  protected:
137
138  double m_noDataValue; //!< The used dummy value.
139  Raster* m_rasterPtr; //!< A pointer to the input image.
140  te::gm::Coord2D m_directions[8]; //!< Directions vector.
141  double m_resX; //!< Resolution X.
142  double m_resY; //!< Resolution Y.
143  unsigned long m_nLines; //!< The number of lines.
144  unsigned long m_nColumns; //!< The number of columns.
145  unsigned int m_rasterBand; //!< The raster band to be used.
146  unsigned int m_maxPolygons; //!< The maximum allowed number of polygons to be created.
147  };
148  } // end namespace rst
149 } // end namespace te
150
151 #endif // __TERRALIB_RASTER_INTERNAL_VECTORIZER_H
#define TERASTEREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:62
unsigned long m_nColumns
The number of columns.
Definition: Vectorizer.h:144
Raster * m_rasterPtr
A pointer to the input image.
Definition: Vectorizer.h:139
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
unsigned long m_nLines
The number of lines.
Definition: Vectorizer.h:143
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
double m_resX
Resolution X.
Definition: Vectorizer.h:141
Enumerations for the Raster module.
An abstract class for raster data strucutures.
unsigned int m_rasterBand
The raster band to be used.
Definition: Vectorizer.h:145
An abstract class for raster data strucutures.
Definition: Raster.h:71
unsigned int m_maxPolygons
The maximum allowed number of polygons to be created.
Definition: Vectorizer.h:146
URI C++ Library.
double m_resY
Resolution Y.
Definition: Vectorizer.h:142
It implements the vectorizer, based on TerraLib 4 algorithm.
Definition: Vectorizer.h:64
double m_noDataValue
The used dummy value.
Definition: Vectorizer.h:138
A polygon container node class.