All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RasterProperty.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/raster/RasterProperty.cpp
22 
23  \brief Raster property.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../datatype/Enums.h"
29 #include "BandProperty.h"
30 #include "Grid.h"
31 #include "RasterProperty.h"
32 
33 // STL
34 #include <cassert>
35 
36 // Boost
37 #include <boost/filesystem.hpp>
38 #include <boost/format.hpp>
39 
41  bool isRequired,
42  unsigned int id,
43  te::dt::Property* parent)
44  : te::dt::SimpleProperty(name, te::dt::RASTER_TYPE, isRequired, 0, id, parent),
45  m_grid(0)
46 {
47 }
48 
50  const std::vector<BandProperty*>& bands,
51  const std::map<std::string, std::string>& rinfo,
52  bool isRequired,
53  unsigned int id,
54  te::dt::Property* parent)
55  : te::dt::SimpleProperty("", te::dt::RASTER_TYPE, isRequired, 0, id, parent),
56  m_grid(grid),
57  m_bands(bands),
58  m_rinfo(rinfo)
59 {
60 }
61 
63  : te::dt::SimpleProperty(rhs)
64 {
65  m_grid = rhs.m_grid ? new te::rst::Grid(*rhs.m_grid) : 0;
66 
68 
69  m_rinfo = rhs.m_rinfo;
70 }
71 
73 {
74  delete m_grid;
75 
76  te::common::FreeContents(m_bands);
77 }
78 
80 {
81  if(this != &rhs)
82  {
83  SimpleProperty::operator=(rhs);
84 
85  delete m_grid;
86 
87  m_grid = rhs.m_grid ? new Grid(*rhs.m_grid) : 0;
88 
89  te::common::FreeContents(m_bands);
90 
91  m_bands.clear();
92 
93  te::common::Copy(rhs.m_bands, m_bands);
94 
95  m_rinfo = rhs.m_rinfo;
96  }
97 
98  return *this;
99 }
100 
102 {
103  delete m_grid;
104 
105  m_grid = grid;
106 }
107 
109 {
110  return m_grid;
111 }
112 
114 {
115  return m_grid;
116 }
117 
119 {
120  m_bands.push_back(b);
121 }
122 
124 {
125  assert(i < m_bands.size());
126 
127  delete m_bands[i];
128 
129  m_bands[i] = b;
130 }
131 
132 std::vector<te::rst::BandProperty*>& te::rst::RasterProperty::getBandProperties()
133 {
134  return m_bands;
135 }
136 
137 const std::vector<te::rst::BandProperty*>& te::rst::RasterProperty::getBandProperties() const
138 {
139  return m_bands;
140 }
141 
142 void te::rst::RasterProperty::setInfo(const std::map<std::string, std::string>& rinfo)
143 {
144  m_rinfo = rinfo;
145 }
146 
147 const std::map<std::string, std::string>& te::rst::RasterProperty::getInfo() const
148 {
149  return m_rinfo;
150 }
151 
153 {
154  return new RasterProperty(*this);
155 }
156 
157 //void te::rst::RasterProperty::setName(const std::string& name)
158 //{
159 // m_name = name;
160 //
161 // boost::filesystem::path path(m_rinfo["URI"]);
162 //
163 // if (path.has_filename())
164 // path.remove_filename();
165 //
166 // path /= name;
167 //
168 // m_rinfo["URI"] = path.string();
169 //}
void setInfo(const std::map< std::string, std::string > &rinfo)
Sets the detailed information about the raster data.
void set(te::rst::Grid *grid)
Sets the definition of the raster grid support.
It describes one band (or dimension) of a raster.
std::map< std::string, std::string > m_rinfo
Additional raster information.
A raster band description.
Definition: BandProperty.h:61
Raster property.
void Copy(const std::vector< T * > &src, std::vector< T * > &dst)
This function can be applied to a vector of pointers. It will copy element by element through its cop...
Definition: STLUtils.h:255
It models a property definition.
Definition: Property.h:59
Raster property.
RasterProperty(const std::string &name, bool isRequired=false, unsigned int id=0, te::dt::Property *parent=0)
It constructs a new raster property.
void add(te::rst::BandProperty *b)
It adds a new band information to the property.
te::dt::Property * clone() const
It returns a clone of the object.
std::vector< BandProperty * > m_bands
A vector of bands description.
virtual ~RasterProperty()
Destructor.
RasterProperty & operator=(const RasterProperty &rhs)
Assignment operator.
te::rst::Grid * getGrid()
Returns the definition of the raster grid support.
const std::map< std::string, std::string > & getInfo() const
Returns the detailed information about the raster data.
A rectified grid is the spatial support for raster data.
std::vector< te::rst::BandProperty * > & getBandProperties()
Returns a reference to the list of bands definitions.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
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
Grid * m_grid
Sets the Raster Property name.