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  virtual ~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  bool isNull(std::size_t i) const { return i != 0; }
153 
154  bool isNull(const std::string& /*name*/) const { return true; }
155 
156  void setURI(const std::string& uri);
157 
158  bool isConnected() const { return false; }
159 
160  private:
161 
162  void loadTypeInfo();
163 
164  private:
165 
166  std::auto_ptr<te::da::DataSetType> m_dsType; //!< It describes the dataset.
167  std::string m_uri;
169  int m_size; //!< For GDAL driver this will be constant: 1.
170  int m_i; //!< Just to indicate the internal pointer movement.
171  };
172 
173  typedef boost::shared_ptr<DataSet> DataSetPtr;
174  } // end namespace gdal
175 } // end namespace te
176 
177 #endif // __TERRALIB_GDAL_INTERNAL_DATASET_H
std::size_t size() const
It returns the collection size, if it is known.
Definition: DataSet.h:80
char getChar(std::size_t) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:94
boost::shared_ptr< DataSet > DataSetPtr
Definition: DataSet.h:173
unsigned char getUChar(const std::string &) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:98
std::auto_ptr< te::da::DataSetType > m_dsType
It describes the dataset.
Definition: DataSet.h:166
int m_size
For GDAL driver this will be constant: 1.
Definition: DataSet.h:169
std::string getNumeric(std::size_t) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:118
#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:158
double getDouble(const std::string &) const
Method for retrieving a double attribute value.
Definition: DataSet.h:116
std::string getString(std::size_t) const
Method for retrieving a string value attribute.
Definition: DataSet.h:121
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
Definition: DataSet.h:152
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:122
bool getBool(std::size_t) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:109
std::string m_uri
Definition: DataSet.h:167
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:101
double getDouble(std::size_t) const
Method for retrieving a double attribute value.
Definition: DataSet.h:115
boost::int32_t getInt32(const std::string &) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:104
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:107
std::auto_ptr< te::dt::DateTime > getDateTime(const std::string &) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:143
bool isNull(const std::string &) const
It checks if the attribute value is NULL.
Definition: DataSet.h:154
char getChar(const std::string &) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:95
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:130
int m_i
Just to indicate the internal pointer movement.
Definition: DataSet.h:170
boost::int32_t getInt32(std::size_t) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:103
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::ByteArray > getByteArray(std::size_t) const
Method for retrieving a byte array.
Definition: DataSet.h:124
unsigned char getUChar(std::size_t) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:97
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:100
boost::int64_t getInt64(std::size_t) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:106
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:119
float getFloat(const std::string &) const
Method for retrieving a float attribute value.
Definition: DataSet.h:113
bool getBool(const std::string &) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:110
float getFloat(std::size_t) const
Method for retrieving a float attribute value.
Definition: DataSet.h:112
std::auto_ptr< te::dt::ByteArray > getByteArray(const std::string &) const
Method for retrieving a byte array.
Definition: DataSet.h:127
std::auto_ptr< te::gm::Geometry > getGeometry(const std::string &) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:133
bool isEmpty() const
It returns true if the collection is empty.
Definition: DataSet.h:78
std::auto_ptr< te::dt::Array > getArray(const std::string &) const
Method for retrieving an array.
Definition: DataSet.h:149
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:140
Configuration flags for the GDAL Driver of TerraLib.
te::common::AccessPolicy m_rwRole
Access role.
Definition: DataSet.h:168