All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataSet.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 
76  std::string getDatasetNameOfProperty(std::size_t pos) const;
77 
78  bool isEmpty() const { return false; }
79 
80  std::size_t size() const { return 1; }
81 
82  bool moveNext();
83  bool movePrevious();
84  bool moveBeforeFirst();
85  bool moveFirst();
86  bool moveLast();
87  bool move(std::size_t i);
88 
89  bool isAtBegin() const;
90  bool isBeforeBegin() const;
91  bool isAtEnd() const;
92  bool isAfterEnd() const;
93 
94  char getChar(std::size_t /*i*/) const { return '\0'; }
95  char getChar(const std::string& /*name*/) const { return '\0'; }
96 
97  unsigned char getUChar(std::size_t /*i*/) const { return 0; }
98  unsigned char getUChar(const std::string& /*name*/) const { return 0; }
99 
100  boost::int16_t getInt16(std::size_t /*i*/) const { return 0; }
101  boost::int16_t getInt16(const std::string& /*name*/) const { return 0; }
102 
103  boost::int32_t getInt32(std::size_t /*i*/) const { return 0; }
104  boost::int32_t getInt32(const std::string& /*name*/) const { return 0; }
105 
106  boost::int64_t getInt64(std::size_t /*i*/) const { return 0; }
107  boost::int64_t getInt64(const std::string& /*name*/) const { return 0; }
108 
109  bool getBool(std::size_t /*i*/) const { return false; }
110  bool getBool(const std::string& /*name*/) const { return false; }
111 
112  float getFloat(std::size_t /*i*/) const { return 0.0; }
113  float getFloat(const std::string& /*name*/) const {return 0.0; }
114 
115  double getDouble(std::size_t /*i*/) const { return 0.0; }
116  double getDouble(const std::string& /*name*/) const { return 0.0; }
117 
118  std::string getNumeric(std::size_t /*i*/) const { return ""; }
119  std::string getNumeric(const std::string& /*name*/) const { return ""; }
120 
121  std::string getString(std::size_t /*i*/) const { return ""; }
122  std::string getString(const std::string& /*name*/) const { return ""; }
123 
124  std::auto_ptr<te::dt::ByteArray> getByteArray(std::size_t /*i*/) const
125  { return std::auto_ptr<te::dt::ByteArray>(0); }
126 
127  std::auto_ptr<te::dt::ByteArray> getByteArray(const std::string& /*name*/) const
128  { return std::auto_ptr<te::dt::ByteArray>(0); }
129 
130  std::auto_ptr<te::gm::Geometry> getGeometry(std::size_t /*i*/) const
131  { return std::auto_ptr<te::gm::Geometry>(0); }
132 
133  std::auto_ptr<te::gm::Geometry> getGeometry(const std::string& /*name*/) const
134  { return std::auto_ptr<te::gm::Geometry>(0); }
135 
136  std::auto_ptr<te::rst::Raster> getRaster(std::size_t i) const;
137 
138  std::auto_ptr<te::rst::Raster> getRaster(const std::string& name) const;
139 
140  std::auto_ptr<te::dt::DateTime> getDateTime(std::size_t /*i*/) const
141  { return std::auto_ptr<te::dt::DateTime>(0); }
142 
143  std::auto_ptr<te::dt::DateTime> getDateTime(const std::string& /*name*/) const
144  { return std::auto_ptr<te::dt::DateTime>(0); }
145 
146  std::auto_ptr<te::dt::Array> getArray(std::size_t /*i*/) const
147  { return std::auto_ptr<te::dt::Array>(0); }
148 
149  std::auto_ptr<te::dt::Array> getArray(const std::string& /*name*/) const
150  { return std::auto_ptr<te::dt::Array>(0); }
151 
152  std::auto_ptr<te::dt::AbstractData> getValue(std::size_t /*i*/) const
153  { return std::auto_ptr<te::dt::AbstractData>(0); }
154 
155  std::auto_ptr<te::dt::AbstractData> getValue(const std::string& /*name*/) const
156  {return std::auto_ptr<te::dt::AbstractData>(0); }
157 
158  bool isNull(std::size_t i) const { return i != 0; }
159 
160  bool isNull(const std::string& /*name*/) const { return true; }
161 
162  void setURI(const std::string& uri);
163 
164  bool isConnected() const { return false; }
165 
166  private:
167 
168  void loadTypeInfo();
169 
170  private:
171 
172  std::auto_ptr<te::da::DataSetType> m_dsType; //!< It describes the dataset.
173  std::string m_uri;
175  int m_size; //!< For GDAL driver this will be constant: 1.
176  int m_i; //!< Just to indicate the internal pointer movement.
177  };
178 
179  typedef boost::shared_ptr<DataSet> DataSetPtr;
180  } // end namespace gdal
181 } // end namespace te
182 
183 #endif // __TERRALIB_GDAL_INTERNAL_DATASET_H
Configuration flags for the GDAL Driver of TerraLib.
boost::int16_t getInt16(const std::string &) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Definition: DataSet.h:101
char getChar(std::size_t) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:94
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:140
std::auto_ptr< te::dt::ByteArray > getByteArray(const std::string &) const
Method for retrieving a byte array.
Definition: DataSet.h:127
bool getBool(std::size_t) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:109
bool isEmpty() const
It returns true if the collection is empty.
Definition: DataSet.h:78
std::string getNumeric(std::size_t) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:118
std::auto_ptr< te::dt::Array > getArray(const std::string &) const
Method for retrieving an array.
Definition: DataSet.h:149
std::auto_ptr< te::da::DataSetType > m_dsType
It describes the dataset.
Definition: DataSet.h:172
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:152
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
Definition: DataSet.h:64
float getFloat(const std::string &) const
Method for retrieving a float attribute value.
Definition: DataSet.h:113
double getDouble(const std::string &) const
Method for retrieving a double attribute value.
Definition: DataSet.h:116
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:164
te::common::AccessPolicy m_rwRole
Access role.
Definition: DataSet.h:174
boost::int32_t getInt32(const std::string &) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:104
boost::int32_t getInt32(std::size_t) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:103
char getChar(const std::string &) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:95
int m_i
Just to indicate the internal pointer movement.
Definition: DataSet.h:176
unsigned char getUChar(std::size_t) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:97
A GDAL data set gives access to a raster file.
Definition: DataSet.h:50
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
Definition: DataSet.h:158
int m_size
For GDAL driver this will be constant: 1.
Definition: DataSet.h:175
std::auto_ptr< te::dt::DateTime > getDateTime(const std::string &) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:143
boost::int64_t getInt64(const std::string &) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:107
boost::int64_t getInt64(std::size_t) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:106
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:113
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
double getDouble(std::size_t) const
Method for retrieving a double attribute value.
Definition: DataSet.h:115
bool getBool(const std::string &) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:110
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
Definition: DataSet.h:66
boost::shared_ptr< DataSet > DataSetPtr
Definition: DataSet.h:179
std::auto_ptr< te::gm::Geometry > getGeometry(const std::string &) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:133
std::auto_ptr< te::dt::Array > getArray(std::size_t) const
Method for retrieving an array.
Definition: DataSet.h:146
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:155
unsigned char getUChar(const std::string &) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:98
std::string getNumeric(const std::string &) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:119
std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t) const
Method for retrieving a byte array.
Definition: DataSet.h:124
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:130
boost::int16_t getInt16(std::size_t) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Definition: DataSet.h:100
std::size_t size() const
It returns the collection size, if it is known.
Definition: DataSet.h:80
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111
float getFloat(std::size_t) const
Method for retrieving a float attribute value.
Definition: DataSet.h:112
std::string m_uri
Definition: DataSet.h:173
bool isNull(const std::string &) const
It checks if the attribute value is NULL.
Definition: DataSet.h:160
std::string getString(const std::string &) const
Method for retrieving a string attribute value.
Definition: DataSet.h:122
std::string getString(std::size_t) const
Method for retrieving a string value attribute.
Definition: DataSet.h:121