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/wms/Transactor.cpp
22 
23  \brief Implementation of the transactor for the WMS driver.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "../gdal/DataSet.h"
29 #include "../gdal/Utils.h"
30 #include "../geometry/Envelope.h"
31 #include "../raster/Grid.h"
32 #include "Exception.h"
33 #include "Transactor.h"
34 #include "Utils.h"
35 
36 // GDAL
37 #include <gdal_priv.h>
38 
39 // STL
40 #include <vector>
41 
42 te::wms::Transactor::Transactor(const std::string& uri, const std::map<std::string, WMSLayerInfo>& layersInfo)
43  : m_uri(uri),
44  m_layersInfo(layersInfo)
45 {
46 }
47 
49 {
50 }
51 
53 {
54  return 0;
55 }
56 
57 std::auto_ptr<te::da::DataSet> te::wms::Transactor::getDataSet(const std::string& name,
58  te::common::TraverseType /*travType*/,
59  bool /*connected*/,
60  const te::common::AccessPolicy /*accessPolicy*/)
61 {
62  std::string layer, width, height, format;
63  ExtractRequestValues(name, layer, width, height, format);
64 
65  if(layer.empty())
66  throw Exception(TE_TR("Invalid data set request. Missing the parameter 'LAYER'!"));
67 
68  std::map<std::string, WMSLayerInfo>::const_iterator it = m_layersInfo.find(layer);
69  if(it == m_layersInfo.end())
70  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
71 
72  // Retrieves the data set type
73  std::auto_ptr<te::da::DataSetType> type = getDataSetType(layer);
74 
75  // Build the GetMap request
76  std::string request = BuildGetMapRequest(m_uri, it->second, width, height, format);
77 
78  return std::auto_ptr<te::da::DataSet>(new te::gdal::DataSet(type, te::common::RAccess, request));
79 }
80 
81 std::auto_ptr<te::da::DataSet> te::wms::Transactor::getDataSet(const std::string& name,
82  const std::string& /*propertyName*/,
83  const te::gm::Envelope* e,
85  te::common::TraverseType /*travType*/,
86  bool /*connected*/,
87  const te::common::AccessPolicy /*accessPolicy*/)
88 {
89  std::string layer, width, height, format;
90  ExtractRequestValues(name, layer, width, height, format);
91 
92  if(layer.empty())
93  throw Exception(TE_TR("Invalid data set request. Missing the parameter 'LAYER'!"));
94 
95  std::map<std::string, WMSLayerInfo>::const_iterator it = m_layersInfo.find(layer);
96  if(it == m_layersInfo.end())
97  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
98 
99  // Retrieves the data set type
100  std::auto_ptr<te::da::DataSetType> type = getDataSetType(layer);
101 
102  // Build the GetMap request
103  std::string request = BuildGetMapRequest(m_uri, it->second, width, height, format, GetBBOX(*e));
104 
105  return std::auto_ptr<te::da::DataSet>(new te::gdal::DataSet(type, te::common::RAccess, request));
106 }
107 
108 std::auto_ptr<te::da::DataSet> te::wms::Transactor::getDataSet(const std::string& name,
109  const std::string& propertyName,
110  const te::gm::Geometry* g,
112  te::common::TraverseType travType,
113  bool connected,
114  const te::common::AccessPolicy accessPolicy)
115 {
116  return getDataSet(name, propertyName, g->getMBR(), r, travType, connected, accessPolicy);
117 }
118 
119 std::auto_ptr<te::da::DataSet> te::wms::Transactor::getDataSet(const std::string& name,
120  const te::da::ObjectIdSet* oids,
121  te::common::TraverseType travType,
122  bool connected,
123  const te::common::AccessPolicy accessPolicy)
124 {
125  throw Exception(TE_TR("The ObjectIdSet concept is not supported by the WMS driver!"));
126 }
127 
128 std::auto_ptr<te::da::DataSet> te::wms::Transactor::query(const te::da::Select& q,
129  te::common::TraverseType travType,
130  bool connected,
131  const te::common::AccessPolicy accessPolicy)
132 {
133  // TODO: Review to considet GetFeatureInfo request?
134  throw Exception(TE_TR("Query operations is not supported by the WMS driver!"));
135 }
136 
137 std::auto_ptr<te::da::DataSet> te::wms::Transactor::query(const std::string& query,
138  te::common::TraverseType travType,
139  bool connected,
140  const te::common::AccessPolicy accessPolicy)
141 {
142  // TODO: Review to considet GetFeatureInfo request?
143  throw Exception(TE_TR("Query operations is not supported by the WMS driver!"));
144 }
145 
146 std::vector<std::string> te::wms::Transactor::getDataSetNames()
147 {
148  std::vector<std::string> names;
149 
150  std::map<std::string, WMSLayerInfo>::const_iterator it;
151  for(it = m_layersInfo.begin(); it != m_layersInfo.end(); ++it)
152  names.push_back(it->second.m_name);
153 
154  return names;
155 }
156 
158 {
159  return m_layersInfo.size();
160 }
161 
162 std::auto_ptr<te::da::DataSetType> te::wms::Transactor::getDataSetType(const std::string& name)
163 {
164  std::map<std::string, WMSLayerInfo>::const_iterator it = m_layersInfo.find(name);
165  if(it == m_layersInfo.end())
166  throw Exception(TE_TR("The informed data set could not be found in the data source."));
167 
168  const WMSLayerInfo& info = it->second;
169 
170  GDALDataset* gds = static_cast<GDALDataset*>(GDALOpen(info.m_pseudoGetMapRequest.c_str(), GA_ReadOnly));
171  if(gds == 0)
172  throw Exception(TE_TR("The data set type could not be retrieved from data source."));
173 
174  te::da::DataSetType* type = new te::da::DataSetType(info.m_name, 0);
175  type->setTitle(info.m_title);
176 
177  te::rst::Grid* grid = te::gdal::GetGrid(gds);
178 
179  std::vector<te::rst::BandProperty*> bandProperties;
180  te::gdal::GetBandProperties(gds, bandProperties);
181 
183  rp->set(grid);
184 
185  for(std::size_t i = 0; i < bandProperties.size(); ++i)
186  rp->add(bandProperties[i]);
187 
188  type->add(rp);
189 
190  GDALClose(gds);
191 
192  return std::auto_ptr<te::da::DataSetType>(type);
193 }
194 
195 boost::ptr_vector<te::dt::Property> te::wms::Transactor::getProperties(const std::string& datasetName)
196 {
197  boost::ptr_vector<te::dt::Property> properties;
198 
199  std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
200 
201  const std::vector<te::dt::Property*>& props = type->getProperties();
202  for(std::size_t i = 0; i < props.size(); ++i)
203  properties.push_back(props[i]->clone());
204 
205  return properties;
206 }
207 
208 std::auto_ptr<te::dt::Property> te::wms::Transactor::getProperty(const std::string& datasetName, const std::string& name)
209 {
210  std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
211 
212  const std::vector<te::dt::Property*>& props = type->getProperties();
213  for(std::size_t i = 0; i < props.size(); ++i)
214  {
215  if(props[i]->getName() == name)
216  return std::auto_ptr<te::dt::Property>(props[i]->clone());
217  }
218 
219  throw Exception(TE_TR("The informed property name could not be found in the data set."));
220 }
221 
222 std::auto_ptr<te::dt::Property> te::wms::Transactor::getProperty(const std::string& datasetName, std::size_t propertyPos)
223 {
224  std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
225 
226  const std::vector<te::dt::Property*>& props = type->getProperties();
227 
228  if(propertyPos >= props.size())
229  throw Exception(TE_TR("The informed property position could not be found in the data set."));
230 
231  return std::auto_ptr<te::dt::Property>(props[propertyPos]->clone());
232 }
233 
234 std::vector<std::string> te::wms::Transactor::getPropertyNames(const std::string& datasetName)
235 {
236  std::vector<std::string> propertyNames;
237 
238  std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
239 
240  const std::vector<te::dt::Property*>& props = type->getProperties();
241  for(std::size_t i = 0; i < props.size(); ++i)
242  propertyNames.push_back(props[i]->getName());
243 
244  return propertyNames;
245 }
246 
247 std::size_t te::wms::Transactor::getNumberOfProperties(const std::string& datasetName)
248 {
249  return getPropertyNames(datasetName).size();
250 }
251 
252 bool te::wms::Transactor::propertyExists(const std::string& datasetName, const std::string& name)
253 {
254  std::vector<std::string> propertyNames = getPropertyNames(datasetName);
255 
256  for(std::size_t i = 0; i < propertyNames.size(); ++i)
257  if(propertyNames[i] == name)
258  return true;
259 
260  return false;
261 }
262 
263 std::auto_ptr<te::gm::Envelope> te::wms::Transactor::getExtent(const std::string& datasetName,
264  const std::string& propertyName)
265 {
266  std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
267 
268  std::auto_ptr<te::dt::Property> prop = getProperty(datasetName, propertyName);
269 
270  te::rst::RasterProperty* rasterProperty = static_cast<te::rst::RasterProperty*>(prop.get());
271  te::gm::Envelope* e = rasterProperty->getGrid()->getExtent();
272 
273  return std::auto_ptr<te::gm::Envelope>(new te::gm::Envelope(e->getLowerLeftX(), e->getLowerLeftY(),
274  e->getUpperRightX(), e->getUpperRightY()));
275 }
276 
277 std::auto_ptr<te::gm::Envelope> te::wms::Transactor::getExtent(const std::string& datasetName,
278  std::size_t propertyPos)
279 {
280  std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
281 
282  std::auto_ptr<te::dt::Property> prop = getProperty(datasetName, propertyPos);
283 
284  te::rst::RasterProperty* rasterProperty = static_cast<te::rst::RasterProperty*>(prop.get());
285  te::gm::Envelope* e = rasterProperty->getGrid()->getExtent();
286 
287  return std::auto_ptr<te::gm::Envelope>(new te::gm::Envelope(e->getLowerLeftX(), e->getLowerLeftY(),
288  e->getUpperRightX(), e->getUpperRightY()));
289 }
290 
291 std::size_t te::wms::Transactor::getNumberOfItems(const std::string& datasetName)
292 {
293  return 1;
294 }
295 
297 {
298  return !m_layersInfo.empty();
299 }
300 
301 bool te::wms::Transactor::dataSetExists(const std::string& name)
302 {
303  return m_layersInfo.find(name) != m_layersInfo.end();
304 }
305 
306 /** NOT SUPPORTED METHODS */
307 //@{
308 
310 {
311  throw Exception(TE_TR("The method begin() is not supported by the WMS driver!"));
312 }
313 
315 {
316  throw Exception(TE_TR("The method commit() is not supported by the WMS driver!"));
317 }
318 
320 {
321  throw Exception(TE_TR("The method rollBack() is not supported by the WMS driver!"));
322 }
323 
325 {
326  throw Exception(TE_TR("The method isInTransaction() is not supported by the WMS driver!"));
327 }
328 
330 {
331  throw Exception(TE_TR("The method execute() is not supported by the WMS driver!"));
332 }
333 
334 void te::wms::Transactor::execute(const std::string& /*command*/)
335 {
336  throw Exception(TE_TR("The method execute() is not supported by the WMS driver!"));
337 }
338 
339 std::auto_ptr<te::da::PreparedQuery> te::wms::Transactor::getPrepared(const std::string& /*qName*/)
340 {
341  throw Exception(TE_TR("The method getPrepared() is not supported by the WMS driver!"));
342 }
343 
344 std::auto_ptr<te::da::BatchExecutor> te::wms::Transactor::getBatchExecutor()
345 {
346  throw Exception(TE_TR("The method getBatchExecutor() is not supported by the WMS driver!"));
347 }
348 
350 {
351  throw Exception(TE_TR("The method cancel() is not supported by the WMS driver!"));
352 }
353 
355 {
356  throw Exception(TE_TR("The method getLastGeneratedId() is not supported by the WMS driver!"));
357 }
358 
359 std::string te::wms::Transactor::escape(const std::string& /*value*/)
360 {
361  throw Exception(TE_TR("The method escape() is not supported by the WMS driver!"));
362 }
363 
364 bool te::wms::Transactor::isDataSetNameValid(const std::string& /*datasetName*/)
365 {
366  throw Exception(TE_TR("The method isDataSetNameValid() is not supported by the WMS driver!"));
367 }
368 
369 bool te::wms::Transactor::isPropertyNameValid(const std::string& /*propertyName*/)
370 {
371  throw Exception(TE_TR("The method isPropertyNameValid() is not supported by the WMS driver!"));
372 }
373 
374 void te::wms::Transactor::addProperty(const std::string& /*datasetName*/, te::dt::Property* /*p*/)
375 {
376  throw Exception(TE_TR("The method addProperty() is not supported by the WMS driver!"));
377 }
378 
379 void te::wms::Transactor::dropProperty(const std::string& /*datasetName*/, const std::string& /*name*/)
380 {
381  throw Exception(TE_TR("The method dropProperty() is not supported by the WMS driver!"));
382 }
383 
384 void te::wms::Transactor::renameProperty(const std::string& /*datasetName*/, const std::string& /*propertyName*/, const std::string& /*newPropertyName*/)
385 {
386  throw Exception(TE_TR("The method renameProperty() is not supported by the WMS driver!"));
387 }
388 
389 std::auto_ptr<te::da::PrimaryKey> te::wms::Transactor::getPrimaryKey(const std::string& /*datasetName*/)
390 {
391  throw Exception(TE_TR("The method getPrimaryKey() is not supported by the WMS driver!"));
392 }
393 
394 bool te::wms::Transactor::primaryKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
395 {
396  throw Exception(TE_TR("The method primaryKeyExists() is not supported by the WMS driver!"));
397 }
398 
399 void te::wms::Transactor::addPrimaryKey(const std::string& /*datasetName*/, te::da::PrimaryKey* /*pk*/)
400 {
401  throw Exception(TE_TR("The method addPrimaryKey() is not supported by the WMS driver!"));
402 }
403 
404 void te::wms::Transactor::dropPrimaryKey(const std::string& /*datasetName*/)
405 {
406  throw Exception(TE_TR("The method dropPrimaryKey() is not supported by the WMS driver!"));
407 }
408 
409 std::auto_ptr<te::da::ForeignKey> te::wms::Transactor::getForeignKey(const std::string& /*datasetName*/, const std::string& /*name*/)
410 {
411  throw Exception(TE_TR("The method getForeignKey() is not supported by the WMS driver!"));
412 }
413 
414 std::vector<std::string> te::wms::Transactor::getForeignKeyNames(const std::string& /*datasetName*/)
415 {
416  throw Exception(TE_TR("The method getForeignKeyNames() is not supported by the WMS driver!"));
417 }
418 
419 bool te::wms::Transactor::foreignKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
420 {
421  throw Exception(TE_TR("The method foreignKeyExists() is not supported by the WMS driver!"));
422 }
423 
424 void te::wms::Transactor::addForeignKey(const std::string& /*datasetName*/, te::da::ForeignKey* /*fk*/)
425 {
426  throw Exception(TE_TR("The method addForeignKey() is not supported by the WMS driver!"));
427 }
428 
429 void te::wms::Transactor::dropForeignKey(const std::string& /*datasetName*/, const std::string& /*fkName*/)
430 {
431  throw Exception(TE_TR("The method dropForeignKey() is not supported by the WMS driver!"));
432 }
433 
434 std::auto_ptr<te::da::UniqueKey> te::wms::Transactor::getUniqueKey(const std::string& /*datasetName*/, const std::string& /*name*/)
435 {
436  throw Exception(TE_TR("The method getUniqueKey() is not supported by the WMS driver!"));
437 }
438 
439 std::vector<std::string> te::wms::Transactor::getUniqueKeyNames(const std::string& /*datasetName*/)
440 {
441  throw Exception(TE_TR("The method getUniqueKeyNames() is not supported by the WMS driver!"));
442 }
443 
444 bool te::wms::Transactor::uniqueKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
445 {
446  throw Exception(TE_TR("The method uniqueKeyExists() is not supported by the WMS driver!"));
447 }
448 
449 void te::wms::Transactor::addUniqueKey(const std::string& /*datasetName*/, te::da::UniqueKey* /*uk*/)
450 {
451  throw Exception(TE_TR("The method addUniqueKey() is not supported by the WMS driver!"));
452 }
453 
454 void te::wms::Transactor::dropUniqueKey(const std::string& /*datasetName*/, const std::string& /*name*/)
455 {
456  throw Exception(TE_TR("The method dropUniqueKey() is not supported by the WMS driver!"));
457 }
458 
459 std::auto_ptr<te::da::CheckConstraint> te::wms::Transactor::getCheckConstraint(const std::string& /*datasetName*/, const std::string& /*name*/)
460 {
461  throw Exception(TE_TR("The method getCheckConstraint() is not supported by the WMS driver!"));
462 }
463 
464 std::vector<std::string> te::wms::Transactor::getCheckConstraintNames(const std::string& /*datasetName*/)
465 {
466  throw Exception(TE_TR("The method getCheckConstraintNames() is not supported by the WMS driver!"));
467 }
468 
469 bool te::wms::Transactor::checkConstraintExists(const std::string& /*datasetName*/, const std::string& /*name*/)
470 {
471  throw Exception(TE_TR("The method checkConstraintExists() is not supported by the WMS driver!"));
472 }
473 
474 void te::wms::Transactor::addCheckConstraint(const std::string& /*datasetName*/, te::da::CheckConstraint* /*cc*/)
475 {
476  throw Exception(TE_TR("The method addCheckConstraint() is not supported by the WMS driver!"));
477 }
478 
479 void te::wms::Transactor::dropCheckConstraint(const std::string& /*datasetName*/, const std::string& /*name*/)
480 {
481  throw Exception(TE_TR("The method dropCheckConstraint() is not supported by the WMS driver!"));
482 }
483 
484 std::auto_ptr<te::da::Index> te::wms::Transactor::getIndex(const std::string& /*datasetName*/, const std::string& /*name*/)
485 {
486  throw Exception(TE_TR("The method getIndex() is not supported by the WMS driver!"));
487 }
488 
489 std::vector<std::string> te::wms::Transactor::getIndexNames(const std::string& /*datasetName*/)
490 {
491  throw Exception(TE_TR("The method getIndexNames() is not supported by the WMS driver!"));
492 }
493 
494 bool te::wms::Transactor::indexExists(const std::string& /*datasetName*/, const std::string& /*name*/)
495 {
496  throw Exception(TE_TR("The method indexExists() is not supported by the WMS driver!"));
497 }
498 
499 void te::wms::Transactor::addIndex(const std::string& /*datasetName*/, te::da::Index* /*idx*/, const std::map<std::string, std::string>& /*options*/)
500 {
501  throw Exception(TE_TR("The method addIndex() is not supported by the WMS driver!"));
502 }
503 
504 void te::wms::Transactor::dropIndex(const std::string& /*datasetName*/, const std::string& /*idxName*/)
505 {
506  throw Exception(TE_TR("The method dropIndex() is not supported by the WMS driver!"));
507 }
508 
509 std::auto_ptr<te::da::Sequence> te::wms::Transactor::getSequence(const std::string& /*name*/)
510 {
511  throw Exception(TE_TR("The method getSequence() is not supported by the WMS driver!"));
512 }
513 
514 std::vector<std::string> te::wms::Transactor::getSequenceNames()
515 {
516  throw Exception(TE_TR("The method getSequenceNames() is not supported by the WMS driver!"));
517 }
518 
519 bool te::wms::Transactor::sequenceExists(const std::string& /*name*/)
520 {
521  throw Exception(TE_TR("The method sequenceExists() is not supported by the WMS driver!"));
522 }
523 
525 {
526  throw Exception(TE_TR("The method addSequence() is not supported by the WMS driver!"));
527 }
528 
529 void te::wms::Transactor::dropSequence(const std::string& /*name*/)
530 {
531  throw Exception(TE_TR("The method dropSequence() is not supported by the WMS driver!"));
532 }
533 
535  const std::map<std::string, std::string>& /*options*/)
536 {
537  throw Exception(TE_TR("The method createDataSet() is not supported by the WMS driver!"));
538 }
539 
540 void te::wms::Transactor::cloneDataSet(const std::string& /*name*/,
541  const std::string& /*cloneName*/,
542  const std::map<std::string, std::string>& /*options*/)
543 {
544  throw Exception(TE_TR("The method cloneDataSet() is not supported by the WMS driver!"));
545 }
546 
547 void te::wms::Transactor::dropDataSet(const std::string& /*name*/)
548 {
549  throw Exception(TE_TR("The method dropDataSet() is not supported by the WMS driver!"));
550 }
551 
552 void te::wms::Transactor::renameDataSet(const std::string& /*name*/,
553  const std::string& /*newName*/)
554 {
555  throw Exception(TE_TR("The method renameDataSet() is not supported by the WMS driver!"));
556 }
557 
558 void te::wms::Transactor::add(const std::string& /*datasetName*/,
559  te::da::DataSet* /*d*/,
560  const std::map<std::string, std::string>& /*options*/,
561  std::size_t /*limit*/)
562 {
563  throw Exception(TE_TR("The method add() is not supported by the WMS driver!"));
564 }
565 
566 void te::wms::Transactor::remove(const std::string& /*datasetName*/, const te::da::ObjectIdSet* /*oids*/)
567 {
568  throw Exception(TE_TR("The method remove() is not supported by the WMS driver!"));
569 }
570 
571 void te::wms::Transactor::update(const std::string& /*datasetName*/,
572  te::da::DataSet* /*dataset*/,
573  const std::vector<std::size_t>& /*properties*/,
574  const te::da::ObjectIdSet* /*oids*/,
575  const std::map<std::string, std::string>& /*options*/,
576  std::size_t /*limit*/)
577 {
578  throw Exception(TE_TR("The method update() is not supported by the WMS driver!"));
579 }
580 
581 void te::wms::Transactor::optimize(const std::map<std::string, std::string>& /*opInfo*/)
582 {
583  throw Exception(TE_TR("The method optimize() is not supported by the WMS driver!"));
584 }
585 
587 {
588  return te::common::UTF8;
589 }
590 
591 //@}
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
Definition: Transactor.cpp:504
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
Definition: Transactor.cpp:354
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
Definition: Transactor.cpp:566
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType.
Definition: DataSetType.h:137
void set(te::rst::Grid *grid)
Sets the definition of the raster grid support.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
Definition: Transactor.cpp:444
std::auto_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
Definition: Transactor.cpp:484
void update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
Definition: Transactor.cpp:571
void optimize(const std::map< std::string, std::string > &opInfo)
For some data access drivers, this method will perform some operations to optimize the data storage...
Definition: Transactor.cpp:581
CharEncoding
Supported charsets (character encoding).
Transactor(const std::string &uri, const std::map< std::string, WMSLayerInfo > &layersInfo)
Definition: Transactor.cpp:42
Utilitary functions to access GDAL and match some of its concepts to TerraLib concepts.
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
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
Definition: Transactor.cpp:489
void begin()
NOT SUPPORTED METHODS.
Definition: Transactor.cpp:309
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
Definition: Transactor.cpp:514
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
Definition: Transactor.cpp:404
void cancel()
It requests that the data source stop the processing of the current command.
Definition: Transactor.cpp:349
std::string m_pseudoGetMapRequest
Definition: WMSLayerInfo.h:48
A class that models the description of a dataset.
Definition: DataSetType.h:72
Informations about WMS Layers.
Definition: WMSLayerInfo.h:44
std::auto_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)
It gets the check constraint of the dataset with the given name.
Definition: Transactor.cpp:459
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
Definition: Transactor.cpp:474
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
Definition: Transactor.cpp:424
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:410
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
Definition: Transactor.cpp:399
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::string BuildGetMapRequest(const std::string &serverUrl, const WMSLayerInfo &info, const std::string &width, const std::string &height, const std::string &format, const std::string &bbox="")
Definition: Utils.cpp:140
It describes a sequence (a number generator).
Definition: Sequence.h:56
std::auto_ptr< te::da::PreparedQuery > getPrepared(const std::string &qName=std::string(""))
It creates a prepared query object that may be used for query commands (select, insert, update and delete) that are used repeatedly.
Definition: Transactor.cpp:339
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:420
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
Definition: Transactor.cpp:301
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
Definition: Transactor.cpp:157
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
Definition: Transactor.cpp:52
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
Definition: Transactor.cpp:359
It models a property definition.
Definition: Property.h:59
Raster property.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
Definition: Transactor.cpp:449
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
Definition: Transactor.cpp:454
std::string GetBBOX(const te::gm::Envelope &e)
Definition: Utils.cpp:229
bool hasDataSets()
It checks if the data source has any dataset.
Definition: Transactor.cpp:296
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:128
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
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
Definition: Transactor.cpp:464
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
Definition: Transactor.cpp:369
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
Definition: Transactor.cpp:414
An exception class for the TerraLib WMS module.
void add(te::rst::BandProperty *b)
It adds a new band information to the property.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
Definition: Transactor.cpp:529
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
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::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
Definition: Transactor.cpp:389
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
Definition: Transactor.cpp:374
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
Definition: Transactor.cpp:409
void ExtractRequestValues(const std::string &request, std::string &layer, std::string &width, std::string &height, std::string &format)
Definition: Utils.cpp:97
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
Definition: Transactor.cpp:324
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
Definition: Transactor.cpp:344
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
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
Definition: Transactor.cpp:384
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
Definition: Transactor.cpp:379
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:57
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
Definition: Transactor.cpp:319
void add(Constraint *c)
It adds a new constraint.
te::rst::Grid * getGrid()
Returns the definition of the raster grid support.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
bool foreignKeyExists(const std::string &datasetName, const std::string &name)
It checks if a foreign key with the given name exists in the data source.
Definition: Transactor.cpp:419
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
Definition: Transactor.cpp:162
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
Definition: Transactor.cpp:439
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
Definition: Transactor.cpp:364
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
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:534
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:540
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
Definition: Transactor.cpp:291
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
Definition: Envelope.h:390
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
Definition: Transactor.cpp:329
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
Definition: Grid.cpp:275
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
Definition: Transactor.cpp:394
A GDAL data set gives access to a raster file.
Definition: DataSet.h:50
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
Definition: Transactor.cpp:524
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
Definition: Transactor.cpp:429
te::common::CharEncoding getEncoding()
It return the DataSource current encoding.
Definition: Transactor.cpp:586
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:252
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
Definition: Transactor.cpp:547
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
Definition: Transactor.cpp:146
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
Definition: Transactor.cpp:234
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:208
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
Definition: Transactor.cpp:552
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
Definition: Transactor.cpp:494
bool checkConstraintExists(const std::string &datasetName, const std::string &name)
It checks if a check-constraint with the given name exists in the data source.
Definition: Transactor.cpp:469
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
Definition: Transactor.cpp:519
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
TEGDALEXPORT te::rst::Grid * GetGrid(GDALDataset *gds)
Gets the grid definition from a GDAL dataset.
Definition: Utils.cpp:104
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:263
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
Definition: Transactor.cpp:195
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
Definition: Geometry.cpp:104
A Query is independent from the data source language/dialect.
Definition: Query.h:46
It describes an index associated to a DataSetType.
Definition: Index.h:54
std::auto_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)
It gets the unique key in the dataset with the given name.
Definition: Transactor.cpp:434
void add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0)
It adds data items to the dataset in the data source.
Definition: Transactor.cpp:558
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
Definition: Transactor.cpp:509
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
Definition: Transactor.cpp:247
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
Definition: Transactor.cpp:479
void commit()
It commits the transaction.
Definition: Transactor.cpp:314
Implementation of the transactor for the WMS driver.
void addIndex(const std::string &datasetName, te::da::Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
Definition: Transactor.cpp:499