All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Transactor.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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/gdal/Transactor.cpp
22 */
23 
24 
25 // Boost
26 #include <boost/algorithm/string.hpp>
27 #include <boost/format.hpp>
28 #include <boost/filesystem.hpp>
29 
30 // TerraLib
31 #include "../common/StringUtils.h"
32 #include "../common/Translator.h"
33 #include "../dataaccess/dataset/DataSetType.h"
34 #include "../dataaccess/query/DataSetName.h"
35 #include "../dataaccess/query/Select.h"
36 #include "../dataaccess/query/From.h"
37 #include "../dataaccess/query/FromItem.h"
38 #include "../geometry/Envelope.h"
39 #include "../raster/Grid.h"
40 #include "../raster/Raster.h"
41 #include "../raster/RasterProperty.h"
42 #include "DataSet.h"
43 #include "DataSource.h"
44 #include "Exception.h"
45 #include "Transactor.h"
46 #include "Utils.h"
47 #include "DataSetUseCounter.h"
48 
49 // GDAL
50 #include <gdal_priv.h>
51 
52 // STL
53 #include <algorithm>
54 
55 std::auto_ptr<te::da::DataSetType> te::gdal::Transactor::getType(const std::string& dsfullname)
56 {
58 
59  GDALDataset* ds = static_cast<GDALDataset*>(GDALOpen(dsfullname.c_str(), GA_ReadOnly));
60  if (!ds)
61  {
62  return std::auto_ptr<te::da::DataSetType>();
63  }
64 
65  te::da::DataSetType* ptr = new te::da::DataSetType("", 0);
66  ptr->setTitle("raster");
67 
68  te::rst::Grid* grid = GetGrid(ds);
69 
70  std::vector<te::rst::BandProperty*> bprops;
71 
72  GetBandProperties(ds, bprops);
73 
75  rp->set(grid);
76  for (size_t i=0; i<bprops.size(); ++i)
77  rp->add(bprops[i]);
78 
79  ptr->add(rp);
80 
81  GDALClose(ds);
82 
83  return std::auto_ptr<te::da::DataSetType>(ptr);
84 }
85 
86 te::gdal::Transactor::Transactor(const std::string& accessInfo):
87  m_path (boost::filesystem::path(accessInfo))
88 {
89 }
90 
92 {
93 }
94 
96 {
97  return 0;
98 }
99 
100 bool te::gdal::Transactor::isDataSetNameValid(const std::string& datasetName)
101 {
102  return true;
103 }
104 
105 bool te::gdal::Transactor::isPropertyNameValid(const std::string& propertyName)
106 {
107  return true;
108 }
109 
110 void te::gdal::Transactor::getDataSetNames(const boost::filesystem::path& path, std::vector<std::string>& dsnames)
111 {
112  if (boost::filesystem::is_regular_file(path))
113  {
114  DataSetUseCounter dsUseCounter( path.string(), DataSetsManager::MultipleAccessType );
115 
116  GDALDataset* gds = static_cast<GDALDataset*>(GDALOpen(path.string().c_str(), GA_ReadOnly));
117  if (!gds)
118  return;
119 
120  char** subdatasets = gds->GetMetadata("SUBDATASETS");
121  if(subdatasets == 0)
122  {
123  dsnames.push_back(path.leaf().string());
124  GDALClose(gds);
125  return;
126  }
127 
128  for(char** i = subdatasets; *i != 0; ++i)
129  {
130  std::map<std::string, std::string> sdsmap;
131 
132  te::common::ExtractKVP(std::string(*i), sdsmap);
133 
134  if(sdsmap.begin()->first.find("_NAME") != std::string::npos)
135  {
136  std::string fullName = sdsmap.begin()->second;
137  std::string subdsname = GetSubDataSetName(fullName, te::gdal::GetDriverName(path.string()));
138  dsnames.push_back(subdsname);
139  }
140  }
141  GDALClose(gds);
142  }
143  else
144  {
145  for (boost::filesystem::directory_iterator it(path), itEnd; it !=itEnd; ++it)
146  getDataSetNames(*it,dsnames);
147  }
148  return;
149 }
150 
151 std::vector<std::string> te::gdal::Transactor::getDataSetNames()
152 {
153  std::vector<std::string> dsnames;
154 
155  getDataSetNames(m_path,dsnames);
156 
157  return dsnames;
158 }
159 
160 bool te::gdal::Transactor::hasDataSets(const boost::filesystem::path& path)
161 {
162  if (boost::filesystem::is_regular_file(path))
163  {
164  DataSetUseCounter dsUseCounter( path.string(), DataSetsManager::MultipleAccessType );
165 
166  GDALDataset* gds = static_cast<GDALDataset*>(GDALOpen(path.string().c_str(), GA_ReadOnly));
167  if (!gds)
168  return false;
169  GDALClose(gds);
170  return true;
171  }
172  else
173  {
174  for (boost::filesystem::directory_iterator it(path), itEnd; it != itEnd; ++it)
175  if (hasDataSets(*it))
176  return true;
177  }
178  return false;
179 }
180 
182 {
183  return hasDataSets(m_path);
184 }
185 
186 size_t te::gdal::Transactor::getNumberOfDataSets(const boost::filesystem::path& path)
187 {
188  size_t nds = 0;
189  if (boost::filesystem::is_regular_file(path))
190  {
191  DataSetUseCounter dsUseCounter( path.string(), DataSetsManager::MultipleAccessType );
192 
193  GDALDataset* gds = static_cast<GDALDataset*>(GDALOpen(path.string().c_str(), GA_ReadOnly));
194  if (!gds)
195  return 0;
196  char** subdatasets = gds->GetMetadata("SUBDATASETS");
197  if(subdatasets == 0)
198  {
199  GDALClose(gds);
200  return 1;
201  }
202  for(char** i = subdatasets; *i != 0; ++i, ++nds);
203 
204  GDALClose(gds);
205  return nds;
206  }
207  else
208  {
209  for (boost::filesystem::directory_iterator it(path), itEnd; it != itEnd; ++it)
210  nds+= getNumberOfDataSets(*it);
211  }
212  return nds;
213 }
214 
216 {
217  return getNumberOfDataSets(m_path);
218 }
219 
220 std::auto_ptr<te::da::DataSetType> te::gdal::Transactor::getDataSetType(const std::string& name)
221 {
222  std::string uri;
223  return getDataSetType(m_path,name,uri);
224 }
225 
226 std::auto_ptr<te::da::DataSetType> te::gdal::Transactor::getDataSetType(const boost::filesystem::path& path, const std::string& name, std::string& uri)
227 {
228  if (boost::filesystem::is_regular_file(path))
229  {
230  if (path.leaf() == name)
231  {
232  // it is a regular file and the dataset we expect
233  std::auto_ptr<te::da::DataSetType> dsty = getType(path.string());
234  dsty->setName(name);
235  dsty->setTitle(name);
236  uri=path.string();
237  return dsty;
238  }
239  else
240  {
242 
243  // it might be one of its sub datasets
244  GDALDataset* gds = static_cast<GDALDataset*>(GDALOpen(path.string().c_str(), GA_ReadOnly));
245  if (!gds)
246  return std::auto_ptr<te::da::DataSetType>();
247 
248  char** subdatasets = gds->GetMetadata("SUBDATASETS");
249  if(subdatasets == 0)
250  return std::auto_ptr<te::da::DataSetType>(); // it has no subdatasets
251 
252  for(char** i = subdatasets; *i != 0; i=i+2)
253  {
254  std::string sds_name = std::string(*i);
255  std::string sds_desc = std::string(*(i+1));
256 
257  unsigned pos = sds_name.find("=");
258  std::string val = sds_name.substr(++pos);
259  if(GetSubDataSetName(val, te::gdal::GetDriverName(path.string())) == name)
260  {
261  GDALClose(gds);
262 
263  uri = val;
264  std::auto_ptr<te::da::DataSetType> dsty = getType(val);
265  dsty->setName(name);
266 
267  pos = sds_desc.find("=");
268  val = sds_desc.substr(++pos);
269  dsty->setTitle(val);
270 
271  return dsty;
272  }
273  }
274  GDALClose(gds);
275  }
276  }
277  else
278  {
279  for (boost::filesystem::directory_iterator it(path), itEnd; it != itEnd; ++it)
280  {
281  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(*it,name,uri);
282  if (dsty.get())
283  return dsty;
284  }
285  }
286  return std::auto_ptr<te::da::DataSetType>();
287 }
288 
289 
290 std::auto_ptr<te::da::DataSet> te::gdal::Transactor::getDataSet(const std::string& name,
291  te::common::TraverseType travType,
292  bool /*connected*/,
293  const te::common::AccessPolicy accessPolicy)
294 {
295  std::string uri;
296  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(m_path,name,uri);
297  if (!dsty.get())
298  return std::auto_ptr<te::da::DataSet>();
299 
300  return std::auto_ptr<te::da::DataSet>(new DataSet(dsty,accessPolicy, uri));
301 }
302 
303 std::auto_ptr<te::da::DataSet> te::gdal::Transactor::getDataSet(const std::string& name,
304  const std::string& /*propertyName*/,
305  const te::gm::Envelope* /*e*/,
307  te::common::TraverseType travType,
308  bool connected,
309  const te::common::AccessPolicy accessPolicy)
310 {
311  return getDataSet(name, travType, connected, accessPolicy);
312 }
313 
314 std::auto_ptr<te::da::DataSet> te::gdal::Transactor::getDataSet(const std::string& name,
315  const std::string& /*propertyName*/,
316  const te::gm::Geometry* /*g*/,
318  te::common::TraverseType travType,
319  bool connected,
320  const te::common::AccessPolicy accessPolicy)
321 {
322  return getDataSet(name, travType, connected, accessPolicy);
323 }
324 
325 std::auto_ptr<te::da::DataSet> te::gdal::Transactor::getDataSet(const std::string& name,
326  const te::da::ObjectIdSet* /*oids*/,
327  te::common::TraverseType travType,
328  bool connected,
329  const te::common::AccessPolicy accessPolicy)
330 {
331  return getDataSet(name, travType, connected, accessPolicy);
332 }
333 
334 
335 boost::ptr_vector<te::dt::Property> te::gdal::Transactor::getProperties(const std::string& datasetName)
336 {
337  boost::ptr_vector<te::dt::Property> properties;
338 
339  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
340  if (!dsty.get())
341  return boost::ptr_vector<te::dt::Property>();
342 
343  const std::vector<te::dt::Property*>& props = dsty->getProperties();
344  for(std::size_t i = 0; i < props.size(); ++i)
345  properties.push_back(props[i]->clone());
346 
347  return properties;
348 }
349 
350 std::auto_ptr<te::dt::Property> te::gdal::Transactor::getProperty(const std::string& datasetName, const std::string& name)
351 {
352  boost::ptr_vector<te::dt::Property> properties;
353 
354  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
355  if (!dsty.get())
356  return std::auto_ptr<te::dt::Property>();
357 
358  const std::vector<te::dt::Property*>& props = dsty->getProperties();
359  for(std::size_t i = 0; i < props.size(); ++i)
360  {
361  if (props[i]->getName() == name)
362  return std::auto_ptr<te::dt::Property>(props[i]->clone());
363  }
364 
365  return std::auto_ptr<te::dt::Property>();
366 }
367 
368 std::auto_ptr<te::dt::Property> te::gdal::Transactor::getProperty(const std::string& datasetName, std::size_t propertyPos)
369 {
370  boost::ptr_vector<te::dt::Property> properties;
371 
372  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
373  if (!dsty.get())
374  return std::auto_ptr<te::dt::Property>();
375 
376  const std::vector<te::dt::Property*>& props = dsty->getProperties();
377  if (propertyPos<props.size() && propertyPos>0)
378  return std::auto_ptr<te::dt::Property>(props[propertyPos]->clone());
379 
380  return std::auto_ptr<te::dt::Property>();
381 }
382 
383 std::vector<std::string> te::gdal::Transactor::getPropertyNames(const std::string& datasetName)
384 {
385  std::vector<std::string> pNames;
386 
387  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
388  if (dsty.get())
389  {
390  const std::vector<te::dt::Property*>& props = dsty->getProperties();
391  for(std::size_t i = 0; i < props.size(); ++i)
392  pNames.push_back(props[i]->getName());
393  }
394  return pNames;
395 }
396 
397 std::size_t te::gdal::Transactor::getNumberOfProperties(const std::string& datasetName)
398 {
399  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
400  if (dsty.get())
401  return dsty->getProperties().size();
402 
403  return 0;
404 }
405 
406 bool te::gdal::Transactor::propertyExists(const std::string& datasetName, const std::string& name)
407 {
408  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
409  if (dsty.get())
410  {
411  const std::vector<te::dt::Property*>& props = dsty->getProperties();
412  for(std::size_t i = 0; i < props.size(); ++i)
413  if(props[i]->getName()==name)
414  return true;
415  }
416  return false;
417 }
418 
419 bool te::gdal::Transactor::propertyExists(const std::string& datasetName, size_t propertyPos)
420 {
421  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(datasetName);
422  if (dsty.get())
423  return (propertyPos < dsty->getProperties().size() && propertyPos>0);
424 
425  return false;
426 }
427 
428 std::auto_ptr<te::da::DataSet> te::gdal::Transactor::query(const te::da::Select& q,
430  bool,
431  const te::common::AccessPolicy accessPolicy)
432 {
433  const te::da::From& from = q.from();
434 
435  if (from.empty())
436  throw Exception(TR_GDAL("Can not process the Select object."));
437 
438  te::da::DataSetName* dsname = static_cast<te::da::DataSetName*>(from[0].clone());
439 
440  if (!dsname)
441  throw Exception(TR_GDAL("Can not process the Select object."));
442 
443  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(dsname->getName());
444 
445  delete dsname;
446 
447  if (!dsty.get())
448  throw Exception(TR_GDAL("Can not process the Select object: dataset not found."));
449 
450  std::string uri = dsty->getTitle();
451  return std::auto_ptr<te::da::DataSet>(new DataSet(dsty,accessPolicy,uri));
452 }
453 
454 std::auto_ptr<te::da::DataSet> te::gdal::Transactor::query(const std::string& query,
456  bool,
457  const te::common::AccessPolicy accessPolicy)
458 {
459  std::vector<std::string> words;
460  std::string s;
461  boost::split(words, s, boost::is_any_of(", "), boost::token_compress_on);
462 
463  std::vector<std::string>::const_iterator it = std::find(words.begin(), words.end(), "FROM");
464  if (it== words.end())
465  it = std::find(words.begin(), words.end(), "from");
466 
467  if (it== words.end())
468  throw Exception(TR_GDAL("Can not process the query expression."));
469 
470  ++it;
471  if (it== words.end())
472  throw Exception(TR_GDAL("Can not process the query expression."));
473 
474  std::string dsname = *it;
475 
476  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(dsname);
477  if (!dsty.get())
478  throw Exception(TR_GDAL("Can not process the Select object: dataset not found."));
479 
480  std::string uri = dsty->getTitle();
481  return std::auto_ptr<te::da::DataSet>(new DataSet(dsty,accessPolicy,uri));
482 }
483 
484 bool te::gdal::Transactor::dataSetExists(const std::string& name)
485 {
486  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(name);
487 
488  return (dsty.get() != 0);
489 }
490 
491 std::auto_ptr<te::gm::Envelope> te::gdal::Transactor::getExtent(const std::string& datasetName, std::size_t propertyPos)
492 {
493  std::auto_ptr<te::dt::Property> pp = getProperty(datasetName,propertyPos);
494 
495  if (pp.get())
496  {
497  te::rst::RasterProperty* rp = static_cast<te::rst::RasterProperty*>(pp.get());
498  te::gm::Envelope* env = rp->getGrid()->getExtent();
499  return std::auto_ptr<te::gm::Envelope>(new te::gm::Envelope(env->getLowerLeftX(), env->getLowerLeftY(),
500  env->getUpperRightX(), env->getUpperRightY()));
501  }
502  return std::auto_ptr<te::gm::Envelope>();
503 }
504 
505 std::auto_ptr<te::gm::Envelope> te::gdal::Transactor::getExtent(const std::string& datasetName, const std::string& propertyName)
506 {
507  std::auto_ptr<te::dt::Property> pp = getProperty(datasetName,propertyName);
508 
509  if (pp.get())
510  {
511  te::rst::RasterProperty* rp = static_cast<te::rst::RasterProperty*>(pp.get());
512  te::gm::Envelope* env = rp->getGrid()->getExtent();
513  return std::auto_ptr<te::gm::Envelope>(new te::gm::Envelope(env->getLowerLeftX(), env->getLowerLeftY(),
514  env->getUpperRightX(), env->getUpperRightY()));
515  }
516  return std::auto_ptr<te::gm::Envelope>();
517 }
518 
520  const std::map<std::string, std::string>& options)
521 {
522  if (!boost::filesystem::is_directory(m_path))
523  throw Exception(TR_GDAL("Create operation supported just on directory data sources."));
524 
525  te::rst::RasterProperty* rstp = static_cast<te::rst::RasterProperty*>(dt->getProperty(0));
526 
527  boost::filesystem::path paux(m_path);
528  paux /= dt->getName();
529 
530  if (boost::filesystem::exists(paux))
531  throw Exception((boost::format(TR_GDAL("The datasource already has a dataset with this name (\"%1%\")!")) % dt->getName()).str());
532 
533  DataSetUseCounter dsUseCounter( paux.string(), DataSetsManager::SingleAccessType );
534 
535  GDALDataset* gds = te::gdal::CreateRaster(paux.string(), rstp->getGrid(), rstp->getBandProperties(),options);
536 
537  if (!gds)
538  throw Exception(TR_GDAL("GDAL driver couldn't persist the raster file."));
539 
540  GDALClose(gds);
541 }
542 
543 void te::gdal::Transactor::cloneDataSet(const std::string& name,
544  const std::string& cloneName,
545  const std::map<std::string, std::string>& options)
546 {
547  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(name);
548 
549  if (!dsty.get())
550  throw Exception(TR_GDAL("Dataset does not exist."));
551 
552  boost::filesystem::path mpath(dsty->getTitle());
553 
554  if (!boost::filesystem::is_regular_file(mpath))
555  throw Exception(TR_GDAL("Can not clone a dataset that it is not a raster file."));
556 
557  boost::filesystem::path newpath(mpath.parent_path() /= cloneName);
558  boost::filesystem::copy_file(mpath, newpath);
559 
560 }
561 
562 void te::gdal::Transactor::dropDataSet(const std::string& name)
563 {
564  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(name);
565 
566  if (!dsty.get())
567  throw Exception(TR_GDAL("Dataset does not exist."));
568 
569  boost::filesystem::path mpath(dsty->getTitle());
570  if (!boost::filesystem::is_regular_file(mpath))
571  throw Exception(TR_GDAL("Can not drop a dataset that it is not a raster file."));
572 
573  boost::filesystem::remove(mpath.string());
574 }
575 
576 void te::gdal::Transactor::renameDataSet(const std::string& name, const std::string& newName)
577 {
578  std::auto_ptr<te::da::DataSetType> dsty = getDataSetType(name);
579 
580  if (!dsty.get())
581  throw Exception(TR_GDAL("Dataset does not exist."));
582 
583  boost::filesystem::path mpath(dsty->getTitle());
584  if (!boost::filesystem::is_regular_file(mpath))
585  throw Exception(TR_GDAL("Can not rename a dataset that it is not a raster file."));
586 
587  boost::filesystem::path newpath(mpath.parent_path() /= newName);
588  boost::filesystem::rename(mpath, newpath);
589 }
590 
std::vector< te::rst::BandProperty * > & getBandProperties()
Returns a reference to the list of bands definitions.
std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. A dataset can be connected or disconnected. A connected dataset, after its creation through the data source transactor, continues to depend on the connection given by its associated data source. Differently, a disconnected dataset, after its creation, no more depends of the connection given by the data source, and it continues to live after the connection has been released to the data source.
Definition: Transactor.cpp:290
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
Property * getProperty(std::size_t i) const
It returns the i-th property.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
Definition: Transactor.cpp:406
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
Definition: Envelope.h:400
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
Definition: Transactor.cpp:105
GDALDataset * CreateRaster(te::rst::Grid *g, const std::vector< te::rst::BandProperty * > &bands, const std::map< std::string, std::string > &optParams)
Creates a raster data using GDAL.
Definition: Utils.cpp:496
const std::string & getName() const
It returns the dataset name.
Definition: DataSetName.cpp:57
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
std::string GetParentDataSetName(const std::string &subDataSetName)
It returns the parent dataset name from a Sub DataSet name.
Definition: Utils.cpp:749
Select & from(const FromItem &item)
Definition: Select.cpp:487
const std::string & getName() const
It returns the property name.
Definition: Property.h:126
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
Definition: Transactor.cpp:151
void add(Constraint *c)
It adds a new constraint.
bool hasDataSets()
It checks if the data source has any dataset.
Definition: Transactor.cpp:181
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
Definition: Transactor.cpp:100
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:122
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
Definition: Transactor.cpp:220
GDAL data set use counter.
std::auto_ptr< te::da::DataSetType > getType(const std::string &dsfullname)
Definition: Transactor.cpp:55
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
Definition: Envelope.h:390
void ExtractKVP(const std::string &kvpStr, std::map< std::string, std::string > &kvp, const std::string &kvpDelimiter="&", const std::string &kvDelimiter="=", bool toUpper=false)
It extracts a key-value map from a string.
Definition: StringUtils.h:251
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
std::auto_ptr< te::da::DataSet > query(const te::da::Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. A dataset can be connected or di...
Definition: Transactor.cpp:428
void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)
It clones the dataset in the data source.
Definition: Transactor.cpp:543
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
Definition: Transactor.cpp:95
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
Definition: Grid.cpp:276
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
Definition: Transactor.cpp:383
A GDAL data set gives access to a raster file.
Definition: DataSet.h:50
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
Definition: Transactor.cpp:335
te::rst::Grid * getGrid()
Returns the definition of the raster grid support.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
Definition: Transactor.cpp:215
te::rst::Grid * GetGrid(GDALDataset *gds)
Gets the grid definition from a GDAL dataset.
Definition: Utils.cpp:102
An exception class for the GDAL module.
void GetBandProperties(GDALDataset *gds, std::vector< te::rst::BandProperty * > &bprops)
Gets the list of bands definition from a GDAL dataset.
Definition: Utils.cpp:137
void set(te::rst::Grid *grid)
Sets the definition of the raster grid support.
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
std::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
Definition: Transactor.cpp:350
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:116
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
Definition: Transactor.cpp:576
void add(te::rst::BandProperty *b)
It adds a new band information to the property.
A class that models the description of a dataset.
Definition: DataSetType.h:72
Transactor(const std::string &accessInfo)
Definition: Transactor.cpp:86
Utilitary functions to access GDAL and match some of its concepts to TerraLib concepts.
Raster property.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:410
std::string GetSubDataSetName(const std::string &name, const std::string &driverName)
It returns the Sub DataSet name from the given name or the same name.
Definition: Utils.cpp:61
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
Definition: Transactor.cpp:397
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:420
std::auto_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)
It retrieves the bounding rectangle of the spatial property for the given dataset.
Definition: Transactor.cpp:505
std::string GetDriverName(const std::string &dsName)
It returns the GDAL driver name associated to a data source name.
Definition: Utils.cpp:633
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType.
Definition: DataSetType.h:137
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
Definition: Transactor.cpp:562
void createDataSet(te::da::DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
Definition: Transactor.cpp:519
The implementation of a DataSource that consists of datasets that can be decoded by the GDAL Library...
#define TR_GDAL(message)
It marks a string in order to get translated. This is a special mark used in the Vector Geometry modu...
Definition: Config.h:64
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
Definition: Transactor.cpp:484