All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RasterDataSet.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/terralib4/RasterDataSet.cpp
22 
23  \brief Implementation of a dataset for the TerraLib 4 driver.
24 */
25 
26 // TerraLib
27 #include "../common/ByteSwapUtils.h"
28 #include "../common/Globals.h"
29 #include "../common/StringUtils.h"
30 #include "../common/Translator.h"
31 #include "../dataaccess/dataset/DataSetType.h"
32 #include "../datatype/Array.h"
33 #include "../datatype/ByteArray.h"
34 #include "../datatype/DateTimeProperty.h"
35 #include "../datatype/SimpleData.h"
36 #include "../datatype/TimeInstant.h"
37 #include "../geometry/Envelope.h"
38 #include "../geometry/Geometry.h"
39 #include "../geometry/WKBReader.h"
40 #include "../raster/Raster.h"
41 #include "RasterDataSet.h"
42 #include "DataSource.h"
43 #include "Exception.h"
44 #include "Raster.h"
45 #include "Utils.h"
46 
47 // Terralib 4.x
48 #include <terralib4/kernel/TeAttribute.h>
49 #include <terralib4/kernel/TeDatabase.h>
50 #include <terralib4/kernel/TeLayer.h>
51 #include <terralib4/kernel/TeQuerierParams.h>
52 
53 // STL
54 #include <memory>
55 
56 // Boost
57 #include <boost/dynamic_bitset.hpp>
58 #include <boost/lexical_cast.hpp>
59 
61  : m_raster(raster), m_i(-1)
62 {
63 }
64 
66 {
67 }
68 
70 {
72 }
73 
75 {
76  return te::common::RAccess;
77 }
78 
79 std::auto_ptr<te::gm::Envelope> terralib4::RasterDataSet::getExtent(std::size_t /*i*/)
80 {
81  return Convert2T5(m_raster->box());
82 }
83 
85 {
86  return 1;
87 }
88 
90 {
91  return te::dt::RASTER_TYPE;
92 }
93 
94 std::string terralib4::RasterDataSet::getPropertyName(std::size_t /*i*/) const
95 {
96  return "raster";
97 }
98 
100 {
102 }
103 
104 std::string terralib4::RasterDataSet::getDatasetNameOfProperty(std::size_t /*i*/) const
105 {
106  return "raster";
107 }
108 
110 {
111  return false;
112 }
113 
115 {
116  return true;
117 }
118 
120 {
121  return 1;
122 }
123 
125 {
126  return (++m_i) == 0;
127 }
128 
130 {
131  return false;
132 }
133 
135 {
136  m_i = -1;
137  return true;
138 }
139 
141 {
142  m_i = 0;
143  return true;
144 }
145 
147 {
148  m_i = 0;
149  return true;
150 }
151 
152 bool terralib4::RasterDataSet::move(std::size_t /*i*/)
153 {
154  return false;
155 }
156 
158 {
159  return m_i == 0;
160 }
161 
163 {
164  return m_i == -1;
165 }
166 
168 {
169  return m_i == 0;
170 }
171 
173 {
174  return m_i > 0;
175 }
176 
177 char terralib4::RasterDataSet::getChar(std::size_t /*i*/) const
178 {
179  throw Exception(TE_TR("Not supported by this type of dataset!"));
180 }
181 
182 unsigned char terralib4::RasterDataSet::getUChar(std::size_t /*i*/) const
183 {
184  throw Exception(TE_TR("Not supported by this type of dataset!"));
185 }
186 
187 boost::int16_t terralib4::RasterDataSet::getInt16(std::size_t /*i*/) const
188 {
189  throw Exception(TE_TR("Not supported by this type of dataset!"));
190 }
191 
192 boost::int32_t terralib4::RasterDataSet::getInt32(std::size_t i) const
193 {
194  throw Exception(TE_TR("Not supported by this type of dataset!"));
195 }
196 
197 boost::int64_t terralib4::RasterDataSet::getInt64(std::size_t i) const
198 {
199  throw Exception(TE_TR("Not supported by this type of dataset!"));
200 }
201 
202 bool terralib4::RasterDataSet::getBool(std::size_t /*i*/) const
203 {
204  throw Exception(TE_TR("Not supported by this type of dataset!"));
205 }
206 
207 float terralib4::RasterDataSet::getFloat(std::size_t /*i*/) const
208 {
209  throw Exception(TE_TR("Not supported by this type of dataset!"));
210 }
211 
212 double terralib4::RasterDataSet::getDouble(std::size_t /*i*/) const
213 {
214  throw Exception(TE_TR("Not supported by this type of dataset!"));
215 }
216 
217 std::string terralib4::RasterDataSet::getNumeric(std::size_t /*i*/) const
218 {
219  throw Exception(TE_TR("Not supported by this type of dataset!"));
220 }
221 
222 std::string terralib4::RasterDataSet::getString(std::size_t /*i*/) const
223 {
224  throw Exception(TE_TR("Not supported by this type of dataset!"));
225 }
226 
227 std::auto_ptr<te::dt::ByteArray> terralib4::RasterDataSet::getByteArray(std::size_t /*i*/) const
228 {
229  throw Exception(TE_TR("Not supported by this type of dataset!"));
230 }
231 
232 std::auto_ptr<te::gm::Geometry> terralib4::RasterDataSet::getGeometry(std::size_t /*i*/) const
233 {
234  throw Exception(TE_TR("Not supported by this type of dataset!"));
235 }
236 
237 std::auto_ptr<te::rst::Raster> terralib4::RasterDataSet::getRaster(std::size_t i) const
238 {
239  return std::auto_ptr<te::rst::Raster>(new Raster(m_raster));
240 }
241 
242 std::auto_ptr<te::dt::DateTime> terralib4::RasterDataSet::getDateTime(std::size_t /*i*/) const
243 {
244  throw Exception(TE_TR("Not supported by this type of dataset!"));
245 }
246 
247 std::auto_ptr<te::dt::Array> terralib4::RasterDataSet::getArray(std::size_t i) const
248 {
249  throw Exception(TE_TR("Not supported by this type of dataset!"));
250 }
251 
252 bool terralib4::RasterDataSet::isNull(std::size_t /*i*/) const
253 {
254  return false;
255 }
256 
std::string getPropertyName(std::size_t i) const
It returns the property name at position pos.
bool isConnected() const
It returns true if the dataset is connected and false if it is disconnected. A dataset can be connect...
CharEncoding
Supported charsets (character encoding).
boost::int64_t getInt64(std::size_t i) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
std::auto_ptr< te::dt::Array > getArray(std::size_t i) const
Method for retrieving an array.
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
bool moveFirst()
It moves the internal pointer to the first item in the collection.
bool isAfterEnd() const
It tells if the dataset internal pointer is on the sentinel position after the last element of the co...
std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const
Method for retrieving a byte array.
Implements the DataSource class for the TerraLib 4.x Data Access Driver.
bool movePrevious()
It moves the internal pointer to the previous item of the collection.
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const
Method for retrieving a date and time attribute value.
int getPropertyDataType(std::size_t i) const
It returns the underlying data type of the property at position pos.
bool isAtBegin() const
It tells if the dataset internal pointer is on the first element of the collection or not...
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
bool isBeforeBegin() const
It tells if the dataset internal pointer is in a position before the first element of the collection ...
char getChar(std::size_t i) const
Method for retrieving a signed character attribute value (1 byte long).
bool getBool(std::size_t i) const
Method for retrieving a boolean attribute value.
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
std::string getString(std::size_t i) const
Method for retrieving a string value attribute.
std::auto_ptr< te::dt::Property > Convert2T5(const TeAttributeRep &attRep)
It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
Definition: Utils.cpp:53
te::common::CharEncoding getPropertyCharEncoding(std::size_t i) const
It returns the property character encoding at position pos.
RasterDataSet(TeRaster *raster)
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
std::string getNumeric(std::size_t i) const
Method for retrieving a numeric attribute value.
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
unsigned char getUChar(std::size_t i) const
Method for retrieving an unsigned character attribute value (1 byte long).
An abstract class for raster data strucutures.
std::string getDatasetNameOfProperty(std::size_t i) const
It returns the underlying dataset name of the property at position pos.
bool moveNext()
It moves the internal pointer to the next item of the collection.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const
Method for retrieving a raster attribute value.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
bool moveLast()
It sets the dataset internal pointer to the last item in the collection.
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
bool isEmpty() const
It returns true if the collection is empty.
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.
bool move(std::size_t i)
It moves the dataset internal pointer to a given position.
std::size_t size() const
It returns the collection size, if it is known.
bool isAtEnd() const
It tells if the dataset internal pointer is on the last element of the collection.
boost::int16_t getInt16(std::size_t i) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Utilitary functions for dealing with TerraLib 5 and 4.x conversion.
float getFloat(std::size_t i) const
Method for retrieving a float attribute value.
boost::int32_t getInt32(std::size_t i) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).