MergeDialog.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/vp/MergeDialog.cpp
22 
23  \brief A dialog for merge operation
24 */
25 
26 // TerraLib
27 #include "../../core/logger/Logger.h"
28 #include "../../core/filesystem/FileSystem.h"
29 #include "../../core/translator/Translator.h"
30 #include "../../common/progress/ProgressManager.h"
31 #include "../../common/StringUtils.h"
32 #include "../../common/progress/TaskProgress.h"
33 #include "../../dataaccess/dataset/DataSetAdapter.h"
34 #include "../../dataaccess/dataset/DataSetTypeConverter.h"
35 #include "../../dataaccess/datasource/DataSource.h"
36 #include "../../dataaccess/datasource/DataSourceCapabilities.h"
37 #include "../../dataaccess/datasource/DataSourceInfoManager.h"
38 #include "../../dataaccess/datasource/DataSourceFactory.h"
39 #include "../../dataaccess/datasource/DataSourceManager.h"
40 #include "../../dataaccess/datasource/DataSourceTransactor.h"
41 #include "../../dataaccess/utils/Utils.h"
42 #include "../../maptools/QueryLayer.h"
43 #include "../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h"
44 #include "../../qt/widgets/layer/utils/DataSet2Layer.h"
45 #include "../../qt/widgets/progress/ProgressViewerDialog.h"
46 #include "../../qt/widgets/utils/FileDialog.h"
47 
48 #include "../../vp/Merge.h"
49 
50 #include "MergeDialog.h"
51 #include "ui_MergeDialogForm.h"
52 
53 #include "../../vp/AlgorithmParams.h"
54 #include "../../vp/ComplexData.h"
55 #include "../../vp/InputParams.h"
56 
57 // Qt
58 #include <QComboBox>
59 #include <QFileDialog>
60 #include <QMessageBox>
61 
62 // Boost
63 #include <boost/filesystem.hpp>
64 #include <boost/uuid/random_generator.hpp>
65 #include <boost/uuid/uuid_io.hpp>
66 
68 
69 te::vp::MergeDialog::MergeDialog(QWidget* parent, Qt::WindowFlags f)
70  : QDialog(parent, f),
71  m_ui(new Ui::MergeDialogForm),
72  m_layers(std::list<te::map::AbstractLayerPtr>()),
73  m_toFile(false)
74 {
75 // add controls
76  m_ui->setupUi(this);
77 
78  connect(m_ui->m_targetLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTargetLayerComboBoxChanged(int)));
79  connect(m_ui->m_originLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onOriginLayerComboBoxChanged(int)));
80  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onOkPushButtonClicked()));
81  connect(m_ui->m_targetDatasourceToolButton, SIGNAL(pressed()), this, SLOT(onTargetDatasourceToolButtonPressed()));
82  connect(m_ui->m_targetFileToolButton, SIGNAL(pressed()), this, SLOT(onTargetFileToolButtonPressed()));
83  connect(m_ui->m_outputGroupBox, SIGNAL(toggled(bool)), this, SLOT(onOutputGroupBoxToggled(bool)));
84 
85 // add icons
86  m_ui->m_imgLabel->setPixmap(QIcon::fromTheme("vp-merge-hint").pixmap(112,48));
87  m_ui->m_targetDatasourceToolButton->setIcon(QIcon::fromTheme("datasource"));
88 
89  m_ui->m_helpPushButton->setNameSpace("dpi.inpe.br.plugins");
90  m_ui->m_helpPushButton->setPageReference("plugins/vp/vp_merge.html");
91 
92  m_outputDatasource = te::da::DataSourceInfoPtr();
93  m_ui->m_newLayerNameLineEdit->setEnabled(true);
94 }
95 
97 
98 void te::vp::MergeDialog::setLayers(std::list<te::map::AbstractLayerPtr> layers)
99 {
100  std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
101 
102  while (it != layers.end())
103  {
104  std::unique_ptr<te::da::DataSetType> dsType = it->get()->getSchema();
105  if (dsType->hasGeom())
106  {
107  m_layers.push_back(*it);
108  }
109 
110  ++it;
111  }
112 
114 
116 
118 }
119 
121 {
122  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
123 
124  disconnect(m_ui->m_targetLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTargetLayerComboBoxChanged(int)));
125 
126  while (it != m_layers.end())
127  {
128  m_ui->m_targetLayerComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant::fromValue(*it));
129  ++it;
130  }
131 
132  connect(m_ui->m_targetLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTargetLayerComboBoxChanged(int)));
133 
134  QVariant varLayer = m_ui->m_targetLayerComboBox->itemData(m_ui->m_targetLayerComboBox->currentIndex(), Qt::UserRole);
135  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
136 
137  m_targetSelectedLayer = layer;
138 }
139 
141 {
142  int currIndex = m_ui->m_targetLayerComboBox->currentIndex();
143 
144  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
145 
146  disconnect(m_ui->m_originLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onOriginLayerComboBoxChanged(int)));
147 
148  while (it != m_layers.end())
149  {
150  m_ui->m_originLayerComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant::fromValue(*it));
151  ++it;
152  }
153 
154  m_ui->m_originLayerComboBox->removeItem(currIndex);
155 
156  connect(m_ui->m_originLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onOriginLayerComboBoxChanged(int)));
157 
158  QVariant varLayer = m_ui->m_originLayerComboBox->itemData(m_ui->m_originLayerComboBox->currentIndex(), Qt::UserRole);
159  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
160 
161  m_originSelectedLayer = layer;
162 }
163 
165 {
166  return m_outputLayer;
167 }
168 
170 {
171  m_ui->m_newLayerNameLineEdit->clear();
172  m_ui->m_newLayerNameLineEdit->setEnabled(true);
174  dlg.exec();
175 
176  std::list<te::da::DataSourceInfoPtr> dsPtrList = dlg.getSelecteds();
177 
178  if(dsPtrList.empty())
179  return;
180 
181  std::list<te::da::DataSourceInfoPtr>::iterator it = dsPtrList.begin();
182 
183  m_ui->m_repositoryLineEdit->setText(QString(it->get()->getTitle().c_str()));
184 
185  m_outputDatasource = *it;
186 
187  m_toFile = false;
188 }
189 
191 {
192  m_ui->m_newLayerNameLineEdit->clear();
193  m_ui->m_repositoryLineEdit->clear();
194 
196 
197  try {
198  fileDialog.exec();
199  }
200  catch (te::common::Exception& ex) {
201  QMessageBox::warning(this, tr("File information"), ex.what());
202  return;
203  }
204 
205  m_ui->m_repositoryLineEdit->setText(fileDialog.getPath().c_str());
206  m_ui->m_newLayerNameLineEdit->setText(fileDialog.getFileName().c_str());
207 
208  m_toFile = true;
209  m_ui->m_newLayerNameLineEdit->setEnabled(false);
210 }
211 
213 {
214  TE_LOG_INFO(TE_TR("Merge operation started"));
215 
216  bool isUpdate = !m_ui->m_outputGroupBox->isChecked();
217 
218  if (isUpdate)
219  {
220  int res = QMessageBox::question(this, tr("Merge"), tr("The origin layer information will be inserted into the target layer.\n Do you want to continue the operation?"), QMessageBox::Yes, QMessageBox::Cancel);
221  if(res == QMessageBox::Cancel)
222  return;
223  }
224 
225  if (m_ui->m_targetLayerComboBox->currentText().isEmpty() || m_ui->m_originLayerComboBox->currentText().isEmpty())
226  {
227  QMessageBox::information(this, tr("Merge"), tr("It is necessary at least two layer to operate!"));
228  return;
229  }
230 
231  // Checking consistency of output paramenters
232  if (!isUpdate && m_ui->m_repositoryLineEdit->text().isEmpty())
233  {
234  QMessageBox::information(this, tr("Merge"), tr("Select a repository for the resulting layer!"));
235  return;
236  }
237 
238  if (!isUpdate && m_ui->m_newLayerNameLineEdit->text().isEmpty())
239  {
240  QMessageBox::information(this, tr("Merge"), tr("Define a name for the resulting layer!"));
241  return;
242  }
243 
244  int targetSrid = m_targetSelectedLayer->getSRID();
245  int originSrid = m_originSelectedLayer->getSRID();
246 
247  if (targetSrid <= 0 || originSrid <= 0)
248  {
249  QMessageBox::information(this, tr("Merge"), tr("All layers must have SRID!"));
250  return;
251  }
252 
254 
255  std::string outputdataset = m_ui->m_newLayerNameLineEdit->text().toUtf8().data();
256 
257  std::string targetSourceId = m_targetSelectedLayer->getDataSourceId();
258  std::string originSourceId = m_originSelectedLayer->getDataSourceId();
259 
260  te::da::DataSourcePtr targetSource = te::da::DataSourceManager::getInstance().find(targetSourceId);
261  te::da::DataSourcePtr originSource = te::da::DataSourceManager::getInstance().find(originSourceId);
262 
263  std::unique_ptr<te::da::DataSetTypeConverter> targetConverter(new te::da::DataSetTypeConverter(m_targetSelectedLayer->getSchema().get(), targetSource->getCapabilities(), targetSource->getEncoding()));
264  te::da::AssociateDataSetTypeConverterSRID(targetConverter.get(), m_targetSelectedLayer->getSRID());
265 
266  std::unique_ptr<te::da::DataSetTypeConverter> originConverter(new te::da::DataSetTypeConverter(m_originSelectedLayer->getSchema().get(), originSource->getCapabilities(), originSource->getEncoding()));
267  te::da::AssociateDataSetTypeConverterSRID(originConverter.get(), m_originSelectedLayer->getSRID(), m_targetSelectedLayer->getSRID());
268 
269  te::da::DataSetType* targetDst(targetConverter->getResult());
270  te::da::DataSetType* originDst(originConverter->getResult());
271 
272  std::unique_ptr<te::common::TaskProgress> task(new te::common::TaskProgress(TE_TR("Preparing Merge...")));
273  task->setTotalSteps(2);
274 
275  std::string logMsg = TE_TR("Getting Target Layer Data...");
276  task->setMessage(logMsg);
277  TE_LOG_INFO(logMsg);
278  const te::da::DataSourceCapabilities& targetCap = targetSource->getCapabilities();
279  const te::da::DataSetCapabilities& targetDsCap = targetCap.getDataSetCapabilities();
280  std::unique_ptr<te::da::DataSourceTransactor> targetTransactor = targetSource->getTransactor();
281  std::unique_ptr<te::da::DataSet> targetConnDs = targetTransactor->getDataSet(targetDst->getName(), te::common::FORWARDONLY, targetDsCap.isConnected());
282  TE_LOG_INFO(TE_TR("Target Layer DataSet ") + (targetDsCap.isConnected() ? TE_TR("CONNECTED") : ("NOT CONNECTED")));
283 
284  task->pulse();
285 
286  logMsg = TE_TR("Getting Origin Layer Data...");
287  task->setMessage(logMsg);
288  TE_LOG_INFO(logMsg);
289  const te::da::DataSourceCapabilities& originCap = originSource->getCapabilities();
290  const te::da::DataSetCapabilities& originDsCap = originCap.getDataSetCapabilities();
291  std::unique_ptr<te::da::DataSourceTransactor> originTransactor = originSource->getTransactor();
292 
293  std::unique_ptr<te::da::DataSet> originConnDs;
294 
295  te::map::QueryLayer* queryLayer = dynamic_cast<te::map::QueryLayer*>(m_originSelectedLayer.get());
296 
297  if (queryLayer)
298  {
299  te::da::Select* q = queryLayer->getQuery();
300 
301  originConnDs = originTransactor->query(q);
302  }
303  else
304  {
305  originConnDs = originTransactor->getDataSet(originDst->getName(), te::common::FORWARDONLY, originDsCap.isConnected());
306  TE_LOG_INFO(TE_TR("Origin: Query Layer"));
307  }
308 
309  TE_LOG_INFO(TE_TR("Origin Layer DataSet ") + (originDsCap.isConnected() ? TE_TR("CONNECTED") : ("NOT CONNECTED")));
310 
311  task->pulse();
312 
313  task.reset(nullptr);
314 
315  te::da::DataSetAdapter* targetAdapter = te::da::CreateAdapter(targetConnDs.release(), targetConverter.get());
316  te::da::DataSetAdapter* originAdapter = te::da::CreateAdapter(originConnDs.release(), originConverter.get());
317 
318  std::unique_ptr<te::da::DataSet> targetDs(targetAdapter);
319  std::unique_ptr<te::da::DataSet> originDs(originAdapter);
320 
321  try
322  {
323 
324  te::vp::InputParams inputParam;
325  inputParam.m_inputDataSet = targetDs.get();
326  inputParam.m_inputDataSetType = targetDst;
327  inputParam.m_inputDataSource = targetSource;
328 
329  te::vp::InputParams mergeParam;
330  mergeParam.m_inputDataSet = originDs.get();
331  mergeParam.m_inputDataSetType = originDst;
332  mergeParam.m_inputDataSource = originSource;
333 
334  std::vector<te::vp::InputParams> params;
335  params.push_back(inputParam);
336  params.push_back(mergeParam);
337 
339 
341 
342  std::map<std::string, te::dt::AbstractData*> specificParams;
343  specificParams["ATTRIBUTES"] = attrs;
344  specificParams["ISUPDATE"] = isUp;
345 
347  aParams->setInputParams(params);
348  aParams->setOutputDataSetName(outputdataset);
349  aParams->setSpecificParams(specificParams);
350 
351  te::da::DataSourcePtr auxSource;
352  std::string ogrDsinfo("file://");
353  boost::filesystem::path ogrUri;
354 
355  if (m_toFile)
356  {
357  ogrUri = m_ui->m_repositoryLineEdit->text().toUtf8().data();
358 
359  if (te::core::FileSystem::exists(ogrUri.string()))
360  {
361  QMessageBox::information(this, tr("Merge"), tr("Output file already exists. Remove it or select a new name and try again."));
362  return;
363  }
364 
365  std::size_t idx = outputdataset.find(".");
366  if (idx != std::string::npos)
367  outputdataset = outputdataset.substr(0, idx);
368 
369  ogrDsinfo += ogrUri.string();
370 
371  auxSource.reset(te::da::DataSourceFactory::make("OGR", ogrDsinfo).release());
372  auxSource->open();
373 
374  if (auxSource->dataSetExists(outputdataset))
375  {
376  QMessageBox::information(this, tr("Merge"), tr("There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again."));
377  return;
378  }
379  }
380  else
381  {
382  if (!isUpdate)
383  {
384  auxSource = te::da::GetDataSource(m_outputDatasource->getId());
385  if (!auxSource)
386  {
387  QMessageBox::information(this, tr("Merge"), tr("The selected output datasource can not be accessed."));
388  return;
389  }
390  if (auxSource->dataSetExists(outputdataset))
391  {
392  QMessageBox::information(this, tr("Merge"), tr("Dataset already exists. Remove it or select a new name and try again."));
393  return;
394  }
395  }
396  }
397 
398 
399  if (!isUpdate)
400  {
401  aParams->setOutputDataSource(auxSource);
402  }
403  else
404  {
405  aParams->setOutputDataSource(targetSource);
406  }
407 
408 
409 
410  te::vp::Merge merge;
411  merge.executeMemory(aParams);
412 
413  delete aParams;
414 
415  if (m_toFile)
416  {
417  // let's include the new datasource in the managers
418  boost::uuids::basic_random_generator<boost::mt19937> gen;
419  boost::uuids::uuid u = gen();
420  std::string id = boost::uuids::to_string(u);
421 
423  ds->setConnInfo(ogrDsinfo);
424  ds->setTitle(ogrUri.stem().string());
425  ds->setAccessDriver("OGR");
426  ds->setType("OGR");
427  ds->setDescription(ogrUri.string());
428  ds->setId(id);
429 
430  te::da::DataSourcePtr newds = te::da::DataSourceManager::getInstance().get(id, "OGR", ds->getConnInfo());
431  newds->open();
434  }
435 
436  if (!isUpdate)
437  {
438  // creating a layer for the result
440 
442 
443  te::da::DataSetTypePtr dt(outDataSource->getDataSetType(outputdataset).release());
444  m_outputLayer = converter(dt);
445  }
446  else
447  {
448  te::gm::Envelope env1 = m_targetSelectedLayer->getExtent();
449  te::gm::Envelope env2 = m_originSelectedLayer->getExtent();
450 
451  env1.Union(env2);
452 
453  m_targetSelectedLayer->setExtent(env1);
454 
455  QMessageBox::information(this, tr("Merge"), tr("Successfully Merge!"));
456  }
457  }
458  catch (const te::common::Exception& e)
459  {
460  QMessageBox::warning(this, tr("Merge"), e.what());
461  return;
462  }
463  catch (const std::exception& e)
464  {
465  QMessageBox::warning(this, tr("Merge"), e.what());
466  return;
467  }
468 
469  TE_LOG_INFO(TE_TR("Merge operation finished"));
470  accept();
471 }
472 
474 {
475  reject();
476 }
477 
479 {
480  QVariant varLayer = m_ui->m_targetLayerComboBox->itemData(index, Qt::UserRole);
481  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
482 
483  m_ui->m_originLayerComboBox->clear();
484 
485  m_targetSelectedLayer = layer;
486 
488 
490 
491  // The update only works with datasetlayer
492  if (m_targetSelectedLayer->getType() != "DATASETLAYER")
493  {
494  m_ui->m_outputGroupBox->setChecked(true);
495  }
496 }
497 
499 {
500  QVariant varLayer = m_ui->m_originLayerComboBox->itemData(index, Qt::UserRole);
501  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
502 
503  m_originSelectedLayer = layer;
504 
506 }
507 
509 {
510  m_ui->m_attributeTableWidget->setRowCount(0);
511 
512  std::unique_ptr<te::da::DataSetType> targetSchema;
513  std::unique_ptr<te::da::DataSetType> originSchema;
514 
516  targetSchema = m_targetSelectedLayer->getSchema();
517  else
518  return;
519 
521  originSchema = m_originSelectedLayer->getSchema();
522  else
523  return;
524 
525  std::vector<te::dt::Property*> originProps = originSchema->getProperties();
526 
527  std::vector<te::dt::Property*> targetProps = targetSchema->getProperties();
528 
529  int rowCount = -1;
530  for (std::size_t i = 0; i < targetProps.size(); ++i)
531  {
532  if (targetProps[i]->getType() != te::dt::GEOMETRY_TYPE)
533  {
534  ++rowCount;
535  m_ui->m_attributeTableWidget->insertRow(rowCount);
536 
537  QTableWidgetItem* item = new QTableWidgetItem(targetProps[i]->getName().c_str());
538  item->setFlags(Qt::ItemIsEnabled);
539  m_ui->m_attributeTableWidget->setItem(rowCount, 0, item);
540 
541  QComboBox* cb = getPossibleAttributesComboBox(targetProps[i], originProps);
542  cb->setParent(m_ui->m_attributeTableWidget);
543 
544  m_ui->m_attributeTableWidget->setCellWidget(rowCount, 1, cb);
545  }
546  }
547 
548  std::size_t fSize = targetProps.size();
549  std::size_t sSize = originProps.size();
550  if (targetProps.size() < originProps.size())
551  {
552  int diference = static_cast<int>(sSize - fSize);
553 
554  for (int i = 0; i < diference; ++i)
555  {
556  ++rowCount;
557  m_ui->m_attributeTableWidget->insertRow(rowCount);
558 
559  QTableWidgetItem* item = new QTableWidgetItem();
560  m_ui->m_attributeTableWidget->setItem(rowCount, 0, item);
561 
562  QComboBox* cb = getAllAttributesComboBox(originProps);
563  cb->setParent(m_ui->m_attributeTableWidget);
564 
565  m_ui->m_attributeTableWidget->setCellWidget(rowCount, 1, cb);
566  }
567  }
568 
569 #if (QT_VERSION >= 0x050000)
570  m_ui->m_attributeTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
571 #else
572  m_ui->m_attributeTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
573 #endif
574 }
575 
576 QComboBox* te::vp::MergeDialog::getPossibleAttributesComboBox(te::dt::Property* mainProp, std::vector<te::dt::Property*> props)
577 {
578  QComboBox* result = new QComboBox();
579  result->addItem("");
580 
581  int sameName = -1;
582  int count = 1;
583 
584  for (std::size_t i = 0; i < props.size(); ++i)
585  {
586  if (mainProp->getType() == props[i]->getType())
587  {
588  if (te::common::Convert2LCase(mainProp->getName()) == te::common::Convert2LCase(props[i]->getName()))
589  {
590  sameName = count;
591  }
592 
593  result->addItem(props[i]->getName().c_str());
594  ++count;
595  }
596  }
597 
598  if (sameName > -1)
599  {
600  result->setCurrentIndex(sameName);
601  }
602 
603  return result;
604 }
605 
606 QComboBox* te::vp::MergeDialog::getAllAttributesComboBox(std::vector<te::dt::Property*> props)
607 {
608  QComboBox* result = new QComboBox();
609  result->addItem("");
610 
611  for (std::size_t i = 0; i < props.size(); ++i)
612  {
613  if (props[i]->getType() != te::dt::GEOMETRY_TYPE)
614  {
615  result->addItem(props[i]->getName().c_str());
616  }
617  }
618 
619  return result;
620 }
621 
622 std::vector<std::pair<std::string, std::string> > te::vp::MergeDialog::getTablePropertiesNames()
623 {
624  std::vector<std::pair<std::string, std::string> > result;
625 
626  int rowCount = m_ui->m_attributeTableWidget->rowCount();
627 
628  for (std::size_t i = 0; i < static_cast<std::size_t>(rowCount); ++i)
629  {
630  std::string fp = m_ui->m_attributeTableWidget->item(static_cast<int>(i), 0)->text().toUtf8().data();;
631 
632  QComboBox* cb = dynamic_cast<QComboBox*>(m_ui->m_attributeTableWidget->cellWidget(static_cast<int>(i), 1));
633 
634  std::string sp = cb->currentText().toUtf8().data();
635 
636  result.push_back(std::pair<std::string, std::string>(fp, sp));
637  }
638 
639  return result;
640 }
641 
643 {
644  if (!on)
645  {
646  if (m_targetSelectedLayer->getType() != "DATASETLAYER")
647  {
648  QMessageBox::warning(this, tr("Merge"), tr("To use target layer as output (update), it must be a DataSet Layer!"));
649  m_ui->m_outputGroupBox->setChecked(true);
650  return;
651  }
652  }
653 }
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
A structure to hold the input parameters of vector processing.
Definition: InputParams.h:50
Defines a component for choose a file.
Definition: FileDialog.h:52
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
Definition: FileSystem.cpp:142
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
void updateTargetLayerComboBox()
boost::shared_ptr< DataSource > DataSourcePtr
QComboBox * getAllAttributesComboBox(std::vector< te::dt::Property * > props)
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
Definition: StringUtils.h:202
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
A class that models the description of a dataset.
Definition: DataSetType.h:72
virtual const char * what() const
It outputs the exception message.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
void onTargetFileToolButtonPressed()
void setOutputDataSetName(const std::string &outputDataSetName)
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
A layer resulting from a query.
Definition: QueryLayer.h:50
std::list< te::map::AbstractLayerPtr > m_layers
List of layers.
Definition: MergeDialog.h:115
static te::dt::Date ds(2010, 01, 01)
std::unique_ptr< Ui::MergeDialogForm > m_ui
Definition: MergeDialog.h:112
A class that informs what the dataset implementation of a given data source can perform.
QComboBox * getPossibleAttributesComboBox(te::dt::Property *mainProp, std::vector< te::dt::Property * > props)
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
te::da::DataSourcePtr m_inputDataSource
Is Required.
Definition: InputParams.h:81
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
Definition: MergeDialog.cpp:98
void setOutputDataSource(te::da::DataSourcePtr outputDataSource)
#define TE_LOG_INFO(message)
Use this tag in order to log a message to the TerraLib default logger with the INFO level...
Definition: Logger.h:315
te::map::AbstractLayerPtr m_originSelectedLayer
Second layer selected.
Definition: MergeDialog.h:120
It models a property definition.
Definition: Property.h:59
void Union(const Envelope &rhs)
It updates the envelop with coordinates of another envelope.
An converter for DataSetType.
void onOriginLayerComboBoxChanged(int index)
A template for complex data types.
Definition: ComplexData.h:52
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
void exec()
This method will open the dialog of file selection and populate the class members with the chosen fil...
Definition: FileDialog.cpp:54
URI C++ Library.
Definition: Attributes.h:37
void onTargetDatasourceToolButtonPressed()
static te::dt::TimeDuration dt(20, 30, 50, 11)
void onOutputGroupBoxToggled(bool on)
te::map::AbstractLayerPtr m_outputLayer
Generated Layer.
Definition: MergeDialog.h:116
void onCancelPushButtonClicked()
A dialog merge operation.
te::da::Select * getQuery() const
Definition: QueryLayer.cpp:363
void updateOriginLayerComboBox()
te::da::DataSetType * m_inputDataSetType
Is required.
Definition: InputParams.h:82
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
int getType() const
It returns the property data type.
Definition: Property.h:161
std::string getPath()
This method will return the chosen path.
Definition: FileDialog.cpp:103
te::da::DataSet * m_inputDataSet
Is required for operations in memory.
Definition: InputParams.h:84
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) te
Definition: MergeDialog.cpp:67
std::vector< std::pair< std::string, std::string > > getTablePropertiesNames()
te::map::AbstractLayerPtr m_targetSelectedLayer
Target layer selected.
Definition: MergeDialog.h:119
A dialog for selecting a data source.
A class that represents a data source component.
void setInputParams(const std::vector< te::vp::InputParams > &setInputParams)
std::string getFileName()
This method will return the file name.
Definition: FileDialog.cpp:113
te::map::AbstractLayerPtr getLayer()
Get the generated layer.
bool executeMemory(te::vp::AlgorithmParams *mainParams)
Definition: Merge.cpp:81
te::da::DataSourceInfoPtr m_outputDatasource
DataSource information.
Definition: MergeDialog.h:114
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
const DataSetCapabilities & getDataSetCapabilities() const
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void setSpecificParams(const std::map< std::string, te::dt::AbstractData * > &specificParams)
An adapter for DataSet.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
void onTargetLayerComboBoxChanged(int index)
const std::string & getName() const
It returns the property name.
Definition: Property.h:127