All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ROI.cpp
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/classification/ROI.cpp
22 
23  \brief A region of interest (often abbreviated ROI), is a selected subset of
24  samples within a dataset identified for a particular purpose.
25 */
26 
27 // TerraLib
28 #include "../common/STLUtils.h"
29 #include "../geometry/Polygon.h"
30 #include "ROI.h"
31 
32 te::cl::ROI::ROI(std::string label): m_label(label), m_color("#ffffff")
33 {
34 }
35 
37 {
38  te::common::FreeContents(m_roiMap);
39  m_roiMap.clear();
40 }
41 
42 void te::cl::ROI::setLabel(std::string label)
43 {
44  m_label = label;
45 }
46 
47 std::string te::cl::ROI::getLabel()
48 {
49  return m_label;
50 }
51 
52 void te::cl::ROI::setColor(std::string color)
53 {
54  m_color = color;
55 }
56 
57 std::string te::cl::ROI::getColor()
58 {
59  return m_color;
60 }
61 
62 std::map<std::string, te::gm::Polygon*>& te::cl::ROI::getPolygons()
63 {
64  return m_roiMap;
65 }
66 
67 void te::cl::ROI::addPolygon(te::gm::Polygon* p, std::string id)
68 {
69  m_roiMap[id] = p;
70 }
71 
72 void te::cl::ROI::removePolygon(std::string id)
73 {
74  std::map<std::string, te::gm::Polygon*>::iterator it = m_roiMap.find(id);
75 
76  if(it != m_roiMap.end())
77  m_roiMap.erase(it);
78 }
void setLabel(std::string label)
Set the ROI label.
Definition: ROI.cpp:42
void addPolygon(te::gm::Polygon *p, std::string id)
Add a new region into this ROI.
Definition: ROI.cpp:67
ROI(std::string label)
Default constructor.
Definition: ROI.cpp:32
virtual ~ROI()
Virtual destructor.
Definition: ROI.cpp:36
void setColor(std::string color)
Set the ROI color using the hexadecimal color name.
Definition: ROI.cpp:52
void removePolygon(std::string id)
Removes a region from this ROI.
Definition: ROI.cpp:72
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
std::string getLabel()
Get the ROI label.
Definition: ROI.cpp:47
A region of interest (often abbreviated ROI), is a selected subset of samples within a dataset identi...
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
std::map< std::string, te::gm::Polygon * > & getPolygons()
Get all polygons belongs to this roi.
Definition: ROI.cpp:62
std::string getColor()
Get the ROI color defined by a hexadecimal color name.
Definition: ROI.cpp:57