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