DataSet.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/dataaccess/gdal/DataSet.h
22 
23  \brief Implementation of a DataSet for GDAL data provider.
24  */
25 
26 #ifndef __TERRALIB_DATAACCES_GDAL_INTERNAL_DATASET_H
27 #define __TERRALIB_DATAACCES_GDAL_INTERNAL_DATASET_H
28 
29 // TerraLib
30 #include "../dataaccess/dataset/DataSet.h"
31 #include "../dataaccess/dataset/DataSetType.h"
32 #include "Config.h"
33 
34 
35 // STL
36 #include <map>
37 #include <memory>
38 #include <string>
39 #include <vector>
40 
41 namespace te
42 {
43  namespace gdal
44  {
45  /*!
46  \class DataSet
47 
48  \brief A GDAL data set gives access to a raster file.
49  */
51  {
52  public:
53 
54  /*!
55  \brief Constructor.
56  \param dt The dataset type. DataSet will take its ownership.
57  \param rwRole The access policy of the dataset.
58  */
59  DataSet(std::auto_ptr<te::da::DataSetType> dt, te::common::AccessPolicy rwRole, std::string uri="");
60 
61  /*! \brief Destructor. */
62  ~DataSet();
63 
65 
66  te::common::AccessPolicy getAccessPolicy() const { return m_rwRole; }
67 
68  std::auto_ptr<te::gm::Envelope> getExtent(std::size_t i);
69 
70  std::size_t getNumProperties() const;
71 
72  int getPropertyDataType(std::size_t pos) const;
73 
74  std::string getPropertyName(std::size_t pos) const;
75 
77 
78  std::string getDatasetNameOfProperty(std::size_t pos) const;
79 
80  bool isEmpty() const { return false; }
81 
82  std::size_t size() const { return 1; }
83 
84  bool moveNext();
85  bool movePrevious();
86  bool moveBeforeFirst();
87  bool moveFirst();
88  bool moveLast();
89  bool move(std::size_t i);
90 
91  bool isAtBegin() const;
92  bool isBeforeBegin() const;
93  bool isAtEnd() const;
94  bool isAfterEnd() const;
95 
96  char getChar(std::size_t /*i*/) const { return '\0'; }
97  char getChar(const std::string& /*name*/) const { return '\0'; }
98 
99  unsigned char getUChar(std::size_t /*i*/) const { return 0; }
100  unsigned char getUChar(const std::string& /*name*/) const { return 0; }
101 
102  boost::int16_t getInt16(std::size_t /*i*/) const { return 0; }
103  boost::int16_t getInt16(const std::string& /*name*/) const { return 0; }
104 
105  boost::int32_t getInt32(std::size_t /*i*/) const { return 0; }
106  boost::int32_t getInt32(const std::string& /*name*/) const { return 0; }
107 
108  boost::int64_t getInt64(std::size_t /*i*/) const { return 0; }
109  boost::int64_t getInt64(const std::string& /*name*/) const { return 0; }
110 
111  bool getBool(std::size_t /*i*/) const { return false; }
112  bool getBool(const std::string& /*name*/) const { return false; }
113 
114  float getFloat(std::size_t /*i*/) const { return 0.0; }
115  float getFloat(const std::string& /*name*/) const {return 0.0; }
116 
117  double getDouble(std::size_t /*i*/) const { return 0.0; }
118  double getDouble(const std::string& /*name*/) const { return 0.0; }
119 
120  std::string getNumeric(std::size_t /*i*/) const { return ""; }
121  std::string getNumeric(const std::string& /*name*/) const { return ""; }
122 
123  std::string getString(std::size_t /*i*/) const { return ""; }
124  std::string getString(const std::string& /*name*/) const { return ""; }
125 
126  std::auto_ptr<te::dt::ByteArray> getByteArray(std::size_t /*i*/) const
127  { return std::auto_ptr<te::dt::ByteArray>(0); }
128 
129  std::auto_ptr<te::dt::ByteArray> getByteArray(const std::string& /*name*/) const
130  { return std::auto_ptr<te::dt::ByteArray>(0); }
131 
132  std::auto_ptr<te::gm::Geometry> getGeometry(std::size_t /*i*/) const
133  { return std::auto_ptr<te::gm::Geometry>(0); }
134 
135  std::auto_ptr<te::gm::Geometry> getGeometry(const std::string& /*name*/) const
136  { return std::auto_ptr<te::gm::Geometry>(0); }
137 
138  std::auto_ptr<te::rst::Raster> getRaster(std::size_t i) const;
139 
140  std::auto_ptr<te::rst::Raster> getRaster(const std::string& name) const;
141 
142  std::auto_ptr<te::dt::DateTime> getDateTime(std::size_t /*i*/) const
143  { return std::auto_ptr<te::dt::DateTime>(0); }
144 
145  std::auto_ptr<te::dt::DateTime> getDateTime(const std::string& /*name*/) const
146  { return std::auto_ptr<te::dt::DateTime>(0); }
147 
148  std::auto_ptr<te::dt::Array> getArray(std::size_t /*i*/) const
149  { return std::auto_ptr<te::dt::Array>(0); }
150 
151  std::auto_ptr<te::dt::Array> getArray(const std::string& /*name*/) const
152  { return std::auto_ptr<te::dt::Array>(0); }
153 
154  std::auto_ptr<te::dt::AbstractData> getValue(std::size_t /*i*/) const
155  { return std::auto_ptr<te::dt::AbstractData>(0); }
156 
157  std::auto_ptr<te::dt::AbstractData> getValue(const std::string& /*name*/) const
158  {return std::auto_ptr<te::dt::AbstractData>(0); }
159 
160  bool isNull(std::size_t i) const { return i != 0; }
161 
162  bool isNull(const std::string& /*name*/) const { return true; }
163 
164  void setURI(const std::string& uri);
165 
166  bool isConnected() const { return false; }
167 
168  private:
169 
170  void loadTypeInfo();
171 
172  private:
173 
174  std::auto_ptr<te::da::DataSetType> m_dsType; //!< It describes the dataset.
175  std::string m_uri;
177  int m_size; //!< For GDAL driver this will be constant: 1.
178  int m_i; //!< Just to indicate the internal pointer movement.
179  };
180 
181  typedef boost::shared_ptr<DataSet> DataSetPtr;
182  } // end namespace gdal
183 } // end namespace te
184 
185 #endif // __TERRALIB_GDAL_INTERNAL_DATASET_H
std::size_t size() const
It returns the collection size, if it is known.
Definition: DataSet.h:82
char getChar(std::size_t) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:96
CharEncoding
Supported charsets (character encoding).
boost::shared_ptr< DataSet > DataSetPtr
Definition: DataSet.h:181
unsigned char getUChar(const std::string &) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:100
std::auto_ptr< te::dt::AbstractData > getValue(std::size_t) const
Method for retrieving any other type of data value stored in the data source.
Definition: DataSet.h:154
std::auto_ptr< te::da::DataSetType > m_dsType
It describes the dataset.
Definition: DataSet.h:174
int m_size
For GDAL driver this will be constant: 1.
Definition: DataSet.h:177
std::string getNumeric(std::size_t) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:120
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
bool isConnected() const
It returns true if the dataset is connected and false if it is disconnected. A dataset can be connect...
Definition: DataSet.h:166
double getDouble(const std::string &) const
Method for retrieving a double attribute value.
Definition: DataSet.h:118
std::string getString(std::size_t) const
Method for retrieving a string value attribute.
Definition: DataSet.h:123
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
Definition: DataSet.h:160
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
Definition: DataSet.h:66
std::string getString(const std::string &) const
Method for retrieving a string attribute value.
Definition: DataSet.h:124
bool getBool(std::size_t) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:111
std::string m_uri
Definition: DataSet.h:175
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
boost::int16_t getInt16(const std::string &) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Definition: DataSet.h:103
double getDouble(std::size_t) const
Method for retrieving a double attribute value.
Definition: DataSet.h:117
boost::int32_t getInt32(const std::string &) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:106
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
Definition: DataSet.h:64
URI C++ Library.
boost::int64_t getInt64(const std::string &) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:109
std::auto_ptr< te::dt::DateTime > getDateTime(const std::string &) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:145
bool isNull(const std::string &) const
It checks if the attribute value is NULL.
Definition: DataSet.h:162
char getChar(const std::string &) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:97
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:132
int m_i
Just to indicate the internal pointer movement.
Definition: DataSet.h:178
boost::int32_t getInt32(std::size_t) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:105
std::auto_ptr< te::dt::Array > getArray(std::size_t) const
Method for retrieving an array.
Definition: DataSet.h:148
std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t) const
Method for retrieving a byte array.
Definition: DataSet.h:126
unsigned char getUChar(std::size_t) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:99
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
boost::int16_t getInt16(std::size_t) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Definition: DataSet.h:102
boost::int64_t getInt64(std::size_t) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:108
A GDAL data set gives access to a raster file.
Definition: DataSet.h:50
std::string getNumeric(const std::string &) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:121
float getFloat(const std::string &) const
Method for retrieving a float attribute value.
Definition: DataSet.h:115
bool getBool(const std::string &) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:112
float getFloat(std::size_t) const
Method for retrieving a float attribute value.
Definition: DataSet.h:114
std::auto_ptr< te::dt::ByteArray > getByteArray(const std::string &) const
Method for retrieving a byte array.
Definition: DataSet.h:129
te::common::CharEncoding getPropertyCharEncoding(std::size_t i) const
It returns the property character encoding at position pos.
Definition: DataSet.h:76
std::auto_ptr< te::gm::Geometry > getGeometry(const std::string &) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:135
bool isEmpty() const
It returns true if the collection is empty.
Definition: DataSet.h:80
std::auto_ptr< te::dt::AbstractData > getValue(const std::string &) const
Method for retrieving any other type of data value stored in the data source.
Definition: DataSet.h:157
std::auto_ptr< te::dt::Array > getArray(const std::string &) const
Method for retrieving an array.
Definition: DataSet.h:151
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:142
Configuration flags for the GDAL Driver of TerraLib.
te::common::AccessPolicy m_rwRole
Access role.
Definition: DataSet.h:176