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::unique_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::unique_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();
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  bool isPositionValid() const;
94 
95  char getChar(std::size_t /*i*/) const { return '\0'; }
96  char getChar(const std::string& /*name*/) const { return '\0'; }
97 
98  unsigned char getUChar(std::size_t /*i*/) const { return 0; }
99  unsigned char getUChar(const std::string& /*name*/) const { return 0; }
100 
101  boost::int16_t getInt16(std::size_t /*i*/) const { return 0; }
102  boost::int16_t getInt16(const std::string& /*name*/) const { return 0; }
103 
104  boost::int32_t getInt32(std::size_t /*i*/) const { return 0; }
105  boost::int32_t getInt32(const std::string& /*name*/) const { return 0; }
106 
107  boost::int64_t getInt64(std::size_t /*i*/) const { return 0; }
108  boost::int64_t getInt64(const std::string& /*name*/) const { return 0; }
109 
110  bool getBool(std::size_t /*i*/) const { return false; }
111  bool getBool(const std::string& /*name*/) const { return false; }
112 
113  float getFloat(std::size_t /*i*/) const { return 0.0; }
114  float getFloat(const std::string& /*name*/) const {return 0.0; }
115 
116  double getDouble(std::size_t /*i*/) const { return 0.0; }
117  double getDouble(const std::string& /*name*/) const { return 0.0; }
118 
119  std::string getNumeric(std::size_t /*i*/) const { return ""; }
120  std::string getNumeric(const std::string& /*name*/) const { return ""; }
121 
122  std::string getString(std::size_t /*i*/) const { return ""; }
123  std::string getString(const std::string& /*name*/) const { return ""; }
124 
125  std::unique_ptr<te::dt::ByteArray> getByteArray(std::size_t /*i*/) const
126  { return std::unique_ptr<te::dt::ByteArray>(); }
127 
128  std::unique_ptr<te::dt::ByteArray> getByteArray(const std::string& /*name*/) const
129  { return std::unique_ptr<te::dt::ByteArray>(); }
130 
131  std::unique_ptr<te::gm::Geometry> getGeometry(std::size_t /*i*/) const
132  { return std::unique_ptr<te::gm::Geometry>(); }
133 
134  std::unique_ptr<te::gm::Geometry> getGeometry(const std::string& /*name*/) const
135  { return std::unique_ptr<te::gm::Geometry>(); }
136 
137  std::unique_ptr<te::rst::Raster> getRaster(std::size_t i) const;
138 
139  std::unique_ptr<te::rst::Raster> getRaster(const std::string& name) const;
140 
141  std::unique_ptr<te::dt::DateTime> getDateTime(std::size_t /*i*/) const
142  { return std::unique_ptr<te::dt::DateTime>(); }
143 
144  std::unique_ptr<te::dt::DateTime> getDateTime(const std::string& /*name*/) const
145  { return std::unique_ptr<te::dt::DateTime>(); }
146 
147  std::unique_ptr<te::dt::Array> getArray(std::size_t /*i*/) const
148  { return std::unique_ptr<te::dt::Array>(); }
149 
150  std::unique_ptr<te::dt::Array> getArray(const std::string& /*name*/) const
151  { return std::unique_ptr<te::dt::Array>(); }
152 
153  bool isNull(std::size_t i) const { return i != 0; }
154 
155  bool isNull(const std::string& /*name*/) const { return true; }
156 
157  void setURI(const std::string& uri);
158 
159  bool isConnected() const { return false; }
160 
161  private:
162 
163  void loadTypeInfo();
164 
165  private:
166 
167  std::unique_ptr<te::da::DataSetType> m_dsType; //!< It describes the dataset.
168  std::string m_uri;
170  int m_size; //!< For GDAL driver this will be constant: 1.
171  int m_i; //!< Just to indicate the internal pointer movement.
172  };
173 
174  typedef boost::shared_ptr<DataSet> DataSetPtr;
175  } // end namespace gdal
176 } // end namespace te
177 
178 #endif // __TERRALIB_GDAL_INTERNAL_DATASET_H
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
A GDAL data set gives access to a raster file.
Definition: DataSet.h:51
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
std::string getDatasetNameOfProperty(std::size_t pos) const
It returns the underlying dataset name of the property at position pos.
bool isBeforeBegin() const
It tells if the dataset internal pointer is in a position before the first element of the collection ...
float getFloat(std::size_t) const
Method for retrieving a float attribute value.
Definition: DataSet.h:113
bool move(std::size_t i)
It moves the dataset internal pointer to a given position.
bool isPositionValid() const
It tells if the dataset internal pointer is on a valid position.
double getDouble(const std::string &) const
Method for retrieving a double attribute value.
Definition: DataSet.h:117
te::common::AccessPolicy m_rwRole
Access role.
Definition: DataSet.h:169
boost::int64_t getInt64(const std::string &) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:108
std::unique_ptr< te::dt::DateTime > getDateTime(std::size_t) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:141
int getPropertyDataType(std::size_t pos) const
It returns the underlying data type of the property at position pos.
std::unique_ptr< te::dt::ByteArray > getByteArray(std::size_t) const
Method for retrieving a byte array.
Definition: DataSet.h:125
std::string getNumeric(const std::string &) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:120
std::unique_ptr< te::dt::Array > getArray(std::size_t) const
Method for retrieving an array.
Definition: DataSet.h:147
boost::int64_t getInt64(std::size_t) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
Definition: DataSet.h:107
double getDouble(std::size_t) const
Method for retrieving a double attribute value.
Definition: DataSet.h:116
bool movePrevious()
It moves the internal pointer to the previous item of the collection.
bool moveNext()
It moves the internal pointer to the next item of the collection.
bool isAtBegin() const
It tells if the dataset internal pointer is on the first element of the collection or not.
std::unique_ptr< te::rst::Raster > getRaster(std::size_t i) const
Method for retrieving a raster attribute value.
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
Definition: DataSet.h:153
void setURI(const std::string &uri)
std::string getPropertyName(std::size_t pos) const
It returns the property name at position pos.
bool isAfterEnd() const
It tells if the dataset internal pointer is on the sentinel position after the last element of the co...
std::unique_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
boost::int32_t getInt32(const std::string &) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:105
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.
int m_i
Just to indicate the internal pointer movement.
Definition: DataSet.h:171
boost::int16_t getInt16(std::size_t) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Definition: DataSet.h:101
boost::int16_t getInt16(const std::string &) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Definition: DataSet.h:102
unsigned char getUChar(const std::string &) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:99
std::unique_ptr< te::da::DataSetType > m_dsType
It describes the dataset.
Definition: DataSet.h:167
bool isNull(const std::string &) const
It checks if the attribute value is NULL.
Definition: DataSet.h:155
virtual ~DataSet()
Destructor.
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
Definition: DataSet.h:66
boost::int32_t getInt32(std::size_t) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
Definition: DataSet.h:104
bool moveLast()
It sets the dataset internal pointer to the last item in the collection.
bool getBool(const std::string &) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:111
std::string getNumeric(std::size_t) const
Method for retrieving a numeric attribute value.
Definition: DataSet.h:119
bool isEmpty() const
It returns true if the collection is empty.
Definition: DataSet.h:78
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:159
char getChar(const std::string &) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:96
std::unique_ptr< te::gm::Geometry > getGeometry(const std::string &) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:134
std::unique_ptr< te::rst::Raster > getRaster(const std::string &name) const
Method for retrieving a raster attribute value.
bool moveFirst()
It moves the internal pointer to the first item in the collection.
bool isAtEnd() const
It tells if the dataset internal pointer is on the last element of the collection.
std::unique_ptr< te::dt::Array > getArray(const std::string &) const
Method for retrieving an array.
Definition: DataSet.h:150
float getFloat(const std::string &) const
Method for retrieving a float attribute value.
Definition: DataSet.h:114
std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t) const
Method for retrieving a geometric attribute value.
Definition: DataSet.h:131
unsigned char getUChar(std::size_t) const
Method for retrieving an unsigned character attribute value (1 byte long).
Definition: DataSet.h:98
std::unique_ptr< te::dt::ByteArray > getByteArray(const std::string &) const
Method for retrieving a byte array.
Definition: DataSet.h:128
std::string getString(std::size_t) const
Method for retrieving a string value attribute.
Definition: DataSet.h:122
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
Definition: DataSet.h:64
std::string m_uri
Definition: DataSet.h:168
std::unique_ptr< te::dt::DateTime > getDateTime(const std::string &) const
Method for retrieving a date and time attribute value.
Definition: DataSet.h:144
int m_size
For GDAL driver this will be constant: 1.
Definition: DataSet.h:170
char getChar(std::size_t) const
Method for retrieving a signed character attribute value (1 byte long).
Definition: DataSet.h:95
std::string getString(const std::string &) const
Method for retrieving a string attribute value.
Definition: DataSet.h:123
DataSet(std::unique_ptr< te::da::DataSetType > dt, te::common::AccessPolicy rwRole, std::string uri="")
Constructor.
bool getBool(std::size_t) const
Method for retrieving a boolean attribute value.
Definition: DataSet.h:110
std::size_t size() const
It returns the collection size, if it is known.
Definition: DataSet.h:80
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:54
@ FORWARDONLY
Definition: Enums.h:55
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
boost::shared_ptr< DataSet > DataSetPtr
Definition: DataSet.h:174
TerraLib.
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
Proxy configuration file for TerraView (see terraview_config.h).