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