All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TL4ConverterWizard.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/qt/plugins/terralib4/TL4ConverterWizard.cpp
22 
23  \brief A wizard for guiding the conversion of a TerraLib 4.x database to a OGC SFS compliant format or any other format known by OGR and GDAL.
24 */
25 
26 // TerraLib
27 #include "../../../../common/Exception.h"
28 #include "../../../../common/Translator.h"
29 #include "../../../../dataaccess.h"
30 #include "../../../../qt/widgets/datasource/selector/DataSourceSelectorWidget.h"
31 #include "../../../../qt/widgets/datasource/selector/DataSourceSelectorWizardPage.h"
32 #include "../../../../qt/widgets/layer/utils/DataSet2Layer.h"
33 #include "../../../../qt/widgets/help/HelpPushButton.h"
34 #include "../../../../qt/widgets/rp/Utils.h"
35 #include "../../../../qt/widgets/utils/ScopedCursor.h"
36 #include "../../../../qt/af/ApplicationController.h"
37 #include "../../../../qt/af/Project.h"
38 #include "../../../../qt/af/events/LayerEvents.h"
39 #include "../../../../raster/Utils.h"
40 #include "TL4ConverterWizard.h"
41 #include "TL4ConnectorWizardPage.h"
44 #include "TL4FinalPageWizardPage.h"
45 #include "ui_TL4ConverterWizardForm.h"
46 #include "ui_TL4ConnectorWizardPageForm.h"
47 #include "ui_TL4LayerSelectionWizardPageForm.h"
48 #include "ui_TL4RasterFolderSelectionWizardPageForm.h"
49 #include "ui_TL4FinalPageWizardPageForm.h"
50 
51 // STL
52 #include <cassert>
53 
54 // Boost
55 #include <boost/filesystem.hpp>
56 #include <boost/lexical_cast.hpp>
57 
58 // Qt
59 #include <QtGui/QIcon>
60 #include <QtGui/QMessageBox>
61 #include <QtGui/QTableWidgetItem>
62 #include <QtGui/QGridLayout>
63 
65  : QWizard(parent, f),
66  m_hasNonRaster(false),
67  m_hasRaster(false),
68  m_rollback(false),
69  m_ui(new Ui::TL4ConverterWizardForm)
70 {
71 // setup controls
72  m_ui->setupUi(this);
73 
74 // add pages
75  m_connectorPage.reset(new TL4ConnectorWizardPage(this));
76  m_connectorPage->setTitle(tr("TerraLib 4.x Database"));
77  m_connectorPage->setSubTitle(tr("Connect to a TerraLib 4.x database."));
78 
80  m_layerSelectionPage->setTitle(tr("Layer Selection"));
81  m_layerSelectionPage->setSubTitle(tr("Select the layers to be added to the project"));
82 
84  m_datasourceSelectorPage->setTitle(tr("Target Data Source"));
85  m_datasourceSelectorPage->setSubTitle(tr("Select a data source to store the converted data"));
86  m_datasourceSelectorPage->getSelectorWidget()->setSelectionMode(QAbstractItemView::SingleSelection);
87  m_datasourceSelectorPage->getSelectorWidget()->showDataSourceWithRasterSupport(false);
88 
90  m_rasterFolderSelectionPage->setTitle(tr("Raster Folder"));
91  m_rasterFolderSelectionPage->setSubTitle(tr("Select folder to store raster data"));
92 
93  m_resolveNamePage.reset(new QWizardPage(this));
94  m_resolveNamePage->setTitle(tr("Resolve Name Conflicts"));
95  m_resolveNamePage->setSubTitle(tr("Some layer names clashes with target data source names. Please, give a new name for the layers showed below"));
96  m_resolveNamePage->setCommitPage(true);
97 
98  QGridLayout* displayLayout = new QGridLayout(m_resolveNamePage.get());
99  m_resolveNameTableWidget.reset(new QTableWidget(m_resolveNamePage.get()));
100  displayLayout->addWidget(m_resolveNameTableWidget.get());
101  displayLayout->setContentsMargins(0,0,0,0);
102  m_resolveNameTableWidget->setColumnCount(3);
103  QStringList labels;
104  labels << "" << tr("Source Names") << tr("Target Names");
105  m_resolveNameTableWidget->setHorizontalHeaderLabels(labels);
106 
107  m_finalPage.reset(new TL4FinalPageWizardPage(this));
108  m_finalPage->setTitle(tr("Layer Creation"));
109  m_finalPage->setSubTitle(tr("Select the layers that you want to create a Project Layer"));
110  m_finalPage->setFinalPage(true);
111 
117  setPage(PAGE_FINALPAGE, m_finalPage.get());
118 
119  connect(this->button(QWizard::NextButton), SIGNAL(pressed()), this, SLOT(next()));
120  connect(this->button(QWizard::BackButton), SIGNAL(pressed()), this, SLOT(back()));
121  connect(this->button(QWizard::FinishButton), SIGNAL(pressed()), this, SLOT(finish()));
122  connect(this->button(QWizard::CommitButton), SIGNAL(pressed()), this, SLOT(commit()));
123 
125 
126  this->setButton(QWizard::HelpButton, helpButton);
127 
128  helpButton->setPageReference("plugins/terralib4/Terralib4Converter.html");
129 }
130 
132 {
133 }
134 
136 {
137  if(currentId() == PAGE_TERRALIB4_CONNECTOR)
138  return PAGE_LAYER_SELECTION;
139 
140  if(currentId() == PAGE_LAYER_SELECTION)
141  {
142  if(m_hasNonRaster)
143  return PAGE_DATASOURCE_SELECTOR;
144 
145  if(m_hasRaster)
146  return PAGE_RASTERFOLDER_SELECTOR;
147 
148  return PAGE_LAYER_SELECTION;
149  }
150 
151  if(currentId() == PAGE_DATASOURCE_SELECTOR)
152  {
153  if(m_hasRaster)
154  return PAGE_RASTERFOLDER_SELECTOR;
155 
156  return PAGE_NAME_RESOLVE_SELECTOR;
157  }
158 
159  if(currentId() == PAGE_RASTERFOLDER_SELECTOR)
160  return PAGE_NAME_RESOLVE_SELECTOR;
161 
162  if(currentId() == PAGE_NAME_RESOLVE_SELECTOR)
163  return PAGE_FINALPAGE;
164 
165  return -1;
166 }
167 
169 {
170  int current_page_id = currentId();
171 
172  if(current_page_id == PAGE_TERRALIB4_CONNECTOR)
173  {
174  if(!validTerraLib4Connection())
175  return false;
176 
177  std::vector<std::string> datasets = m_tl4Database->getDataSetNames();
178 
179  m_layerSelectionPage->setDatasets(datasets);
180  }
181  else if(current_page_id == PAGE_LAYER_SELECTION)
182  {
183  if(!validLayerSelection())
184  return false;
185  }
186  else if(current_page_id == PAGE_DATASOURCE_SELECTOR)
187  {
188  m_targetDataSource = *m_datasourceSelectorPage->getSelectorWidget()->getSelecteds().begin();
189  }
190  else if(current_page_id == PAGE_RASTERFOLDER_SELECTOR)
191  {
192  m_rasterFolderPath = m_rasterFolderSelectionPage->getPath();
193  }
194  else if(current_page_id == PAGE_NAME_RESOLVE_SELECTOR)
195  {
196  return !m_rollback;
197  }
198 
199  try
200  {
201  if(nextId() == PAGE_NAME_RESOLVE_SELECTOR)
202  {
203  te::qt::widgets::ScopedCursor sc(Qt::WaitCursor);
204 
205  std::vector<std::string> selectedLayer = m_layerSelectionPage->getChecked();
206 
207  m_resolveNameTableWidget->clearContents();
208  m_resolveNameTableWidget->setRowCount(selectedLayer.size());
209 
210  te::da::DataSourcePtr tl5ds;
211 
212  if(m_hasNonRaster)
213  tl5ds = te::da::DataSourceManager::getInstance().get(m_targetDataSource->getId(), m_targetDataSource->getType(), m_targetDataSource->getConnInfo());
214 
215  bool hasConflicts = false;
216 
217  for(std::size_t i = 0; i < selectedLayer.size(); ++i)
218  {
219  std::string targetDatasetName = selectedLayer[i];
220 
221  // is it a raster?
222  std::auto_ptr<te::da::DataSetType> input_dataset_type(m_tl4Database->getDataSetType(selectedLayer[i]));
223 
224  if(input_dataset_type->hasRaster())
225  {
226  QTableWidgetItem *conflictItem = 0;
227 
228  if(boost::filesystem::exists(m_rasterFolderPath + "/" + targetDatasetName + ".tif"))
229  {
230  hasConflicts = true;
231 
232  conflictItem = new QTableWidgetItem(QIcon::fromTheme("delete"), "");
233  }
234  else
235  {
236  conflictItem = new QTableWidgetItem(QIcon::fromTheme("check"), "");
237  }
238 
239  conflictItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
240  m_resolveNameTableWidget->setItem(i, 0, conflictItem);
241  }
242  else
243  {
244  // non-raster
245  QTableWidgetItem *conflictItem = 0;
246 
247  if(tl5ds->dataSetExists(targetDatasetName))
248  {
249  hasConflicts = true;
250 
251  conflictItem = new QTableWidgetItem(QIcon::fromTheme("delete"), "");
252  }
253  else
254  {
255  conflictItem = new QTableWidgetItem(QIcon::fromTheme("check"), "");
256  }
257 
258  conflictItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
259  m_resolveNameTableWidget->setItem(i, 0, conflictItem);
260  }
261 
262  QTableWidgetItem *oldNameItem = new QTableWidgetItem(selectedLayer[i].c_str());
263  oldNameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
264  m_resolveNameTableWidget->setItem(i, 1, oldNameItem);
265 
266  QTableWidgetItem *newNameItem = new QTableWidgetItem(targetDatasetName.c_str());
267  m_resolveNameTableWidget->setItem(i, 2, newNameItem);
268  }
269 
270  m_resolveNameTableWidget->resizeColumnsToContents();
271  m_resolveNameTableWidget->sortByColumn(1, Qt::AscendingOrder);
272 
273  if(hasConflicts)
274  {
275  m_resolveNamePage->setTitle(tr("Resolve Name Conflicts"));
276  m_resolveNamePage->setSubTitle(tr("Some layer names clash with target data source dataset names. Please, give a new name for the layers showed below"));
277  }
278  else
279  {
280  m_resolveNamePage->setTitle(tr("No Name Conflicts"));
281  m_resolveNamePage->setSubTitle(tr("You can change the layer names in the target data source"));
282  }
283  }
284  }
285  catch(const te::da::Exception& e)
286  {
287  QMessageBox::warning(this, tr("Warning"), e.what());
288  return false;
289  }
290  catch(...)
291  {
292  QMessageBox::warning(this, tr("Warning"), tr("Could not valid this page!"));
293  return false;
294  }
295 
296  return true;
297 }
298 
300 {
301  std::map<std::string, std::string> connInfo = m_connectorPage->getConnInfo();
302 
303  try
304  {
305  te::qt::widgets::ScopedCursor sc(Qt::WaitCursor);
306  m_tl4Database = te::da::DataSourceFactory::make("TERRALIB4");
307  m_tl4Database->setConnectionInfo(connInfo);
308  m_tl4Database->open();
309  }
310  catch(const te::da::Exception& e)
311  {
312  QMessageBox::warning(this, tr("Warning"), e.what());
313  return false;
314  }
315  catch(...)
316  {
317  QMessageBox::warning(this, tr("Warning"), tr("A connection to the informed Terralib 4.x database could not be established. Please, verify the informed parameters."));
318  return false;
319  }
320 
321  return true;
322 }
323 
325 {
326  if(!m_layerSelectionPage->hasChecked())
327  {
328  // TODO: ao inves de dar esta mensagem deve-se desabilitar o botao next quando nenhum item esta selecionado!
329  QMessageBox::warning(this,
330  tr("Warning"),
331  tr("Please, select at least one layer for conversion!"));
332  return false;
333  }
334 
335  std::vector<std::string> layersNames = m_layerSelectionPage->getChecked();
336 
337 // do we have vector or raster layers?
338  m_hasNonRaster = false;
339  m_hasRaster = false;
340 
341  try
342  {
343  te::qt::widgets::ScopedCursor sc(Qt::WaitCursor);
344 
345  for(std::size_t i = 0; i < layersNames.size(); ++i)
346  {
347  std::auto_ptr<te::da::DataSetType> dst(m_tl4Database->getDataSetType(layersNames[i]));
348 
349  if(dst->hasRaster())
350  m_hasRaster = true;
351  else
352  m_hasNonRaster = true;
353  }
354  }
355  catch(const te::da::Exception& e)
356  {
357  QMessageBox::warning(this, tr("Warning"), e.what());
358  return false;
359  }
360  catch(...)
361  {
362  QMessageBox::warning(this, tr("Warning"), tr("Could not valid layer selection!"));
363  return false;
364  }
365 
366  return true;
367 }
368 
370 {
371  bool hasConflict = false;
372 
373 // TODO: acrescentar try e catch para evitar problemas
374  te::da::DataSourcePtr tl5ds;
375 
376  try
377  {
378  if(m_hasNonRaster)
379  tl5ds = te::da::DataSourceManager::getInstance().get(m_targetDataSource->getId(), m_targetDataSource->getType(), m_targetDataSource->getConnInfo());
380  }
381  catch(const te::da::Exception& e)
382  {
383  QMessageBox::warning(this, tr("Warning"), e.what());
384  return false;
385  }
386  catch(...)
387  {
388  QMessageBox::warning(this, tr("Warning"), tr("Could not connect to TerraLib 5 data source!"));
389  return false;
390  }
391 
392  int nrows = m_resolveNameTableWidget->rowCount();
393 
394  for(int i = 0; i != nrows; ++i)
395  {
396 // get original dataset name
397  QTableWidgetItem* item_source = m_resolveNameTableWidget->item(i, 1);
398 
399  if(item_source == 0)
400  throw te::common::Exception(TE_QT_PLUGIN_TERRALIB4("Invalid source table item!"));
401 
402  std::string sourceName = item_source->text().toStdString();
403 
404 // get target dataset name
405  QTableWidgetItem* item_target = m_resolveNameTableWidget->item(i, 2);
406 
407  if(item_target == 0)
408  throw te::common::Exception(TE_QT_PLUGIN_TERRALIB4("Invalid target table item!"));
409 
410  std::string targetName = item_target->text().toStdString();
411 
412 // ask if the dataset is a raster
413  try
414  {
415  te::qt::widgets::ScopedCursor sc(Qt::WaitCursor);
416 
417  std::auto_ptr<te::da::DataSetType> input_dataset_type(m_tl4Database->getDataSetType(sourceName));
418 
419  if(input_dataset_type->hasRaster())
420  {
421 // yes!
422  if(boost::filesystem::exists(m_rasterFolderPath + "/" + targetName + ".tif"))
423  {
424  hasConflict = true;
425  }
426  else
427  {
428  QTableWidgetItem *nonconflictItem = new QTableWidgetItem(QIcon::fromTheme("check"), "");
429 
430  m_resolveNameTableWidget->setItem(i, 0, nonconflictItem);
431  }
432  }
433  else
434  {
435 // no!
436  if(tl5ds->dataSetExists(targetName))
437  {
438  hasConflict = true;
439  }
440  else
441  {
442  QTableWidgetItem *nonconflictItem = new QTableWidgetItem(QIcon::fromTheme("check"), "");
443 
444  m_resolveNameTableWidget->setItem(i, 0, nonconflictItem);
445  }
446  }
447  }
448  catch(const te::da::Exception& e)
449  {
450  QMessageBox::warning(this, tr("Warning"), e.what());
451  return false;
452  }
453  catch(...)
454  {
455  QMessageBox::warning(this, tr("Warning"), tr("Could not valid layer names in target data source!"));
456  return false;
457  }
458  }
459 
460  if(hasConflict)
461  {
462  QString errMsg(tr("There still have name conflicts. Please, resolve the indicated conflicts before continue!"));
463 
464  QMessageBox::warning(this, tr("TerraLib 4.x Converter"), errMsg);
465 
466  return false;
467  }
468 
469  return true;
470 }
471 
472 std::string te::qt::plugins::terralib4::TL4ConverterWizard::getOriginalName(const std::string& targetName)
473 {
474  int rowCount = m_resolveNameTableWidget->rowCount();
475 
476  for(int i = 0; i < rowCount; ++i)
477  {
478  QString targetNameInTable = m_resolveNameTableWidget->item(i, 2)->text();
479 
480  if(targetName.c_str() == targetNameInTable)
481  return m_resolveNameTableWidget->item(i, 1)->text().toStdString();
482 
483  }
484 
485  return "";
486 }
487 
489 {
490  QWizard::back();
491 }
492 
494 {
495  QWizard::next();
496 }
497 
499 {
500  if(!validLayerNames())
501  {
502  m_rollback = true;
503  return;
504  }
505 
506 // validation successful => convert the source layers!
507  std::vector<std::pair<std::string, std::string> > problematicDatasets;
508  std::vector<std::string> successfulDatasets;
509 
510  te::da::DataSourcePtr tl5ds;
511 
512  try
513  {
514  if(m_hasNonRaster)
515  tl5ds = te::da::DataSourceManager::getInstance().get(m_targetDataSource->getId(), m_targetDataSource->getType(), m_targetDataSource->getConnInfo());
516  }
517  catch(const te::da::Exception& e)
518  {
519  m_rollback = true;
520  QMessageBox::warning(this, tr("Warning"), e.what());
521  return;
522  }
523  catch(...)
524  {
525  m_rollback = true;
526  QMessageBox::warning(this, tr("Warning"), tr("Could not connect to TerraLib 5 data source!"));
527  return;
528  }
529 
530  int nrows = m_resolveNameTableWidget->rowCount();
531 
532  for(int i = 0; i != nrows; ++i)
533  {
534 // get original dataset name
535  QTableWidgetItem* item_source = m_resolveNameTableWidget->item(i, 1);
536 
537  if(item_source == 0)
538  throw te::common::Exception(TE_QT_PLUGIN_TERRALIB4("Invalid source table item!"));
539 
540  std::string sourceName = item_source->text().toStdString();
541 
542 // get target dataset name
543  QTableWidgetItem* item_target = m_resolveNameTableWidget->item(i, 2);
544 
545  if(item_target == 0)
546  throw te::common::Exception(TE_QT_PLUGIN_TERRALIB4("Invalid target table item!"));
547 
548  std::string targetName = item_target->text().toStdString();
549 
550 // ask if the dataset is a raster
551  try
552  {
553  te::qt::widgets::ScopedCursor sc(Qt::WaitCursor);
554 
555  std::auto_ptr<te::da::DataSetType> input_dataset_type(m_tl4Database->getDataSetType(sourceName));
556 
557  if(input_dataset_type->hasRaster())
558  {
559 // yes!
560  std::auto_ptr<te::da::DataSet> ds = m_tl4Database->getDataSet(sourceName);
561 
562  std::auto_ptr<te::rst::Raster> raster = ds->getRaster("Raster");
563 
564  std::string newName = m_rasterFolderPath + "/" + targetName + ".tif";
565 
566  te::rst::CreateCopy(*raster.release(), newName);
567 
568  successfulDatasets.push_back(targetName);
569  }
570  else
571  {
572 // no!
573  input_dataset_type->setName(targetName);
574 
575  std::auto_ptr<te::da::DataSetTypeConverter> dt_adapter(new te::da::DataSetTypeConverter(input_dataset_type.get(), tl5ds->getCapabilities()));
576 
577  std::auto_ptr<te::da::DataSet> ds(m_tl4Database->getDataSet(sourceName));
578 
579  std::auto_ptr<te::da::DataSetAdapter> ds_adapter(te::da::CreateAdapter(ds.get(), dt_adapter.get()));
580 
581  std::map<std::string, std::string> opt;
582 
583  te::da::Create(tl5ds.get(), dt_adapter->getResult(), ds_adapter.get(), opt);
584 
585  successfulDatasets.push_back(targetName);
586  }
587  }
588  catch(const te::common::Exception& e)
589  {
590  std::pair<std::string, std::string> dproblem;
591  dproblem.first = sourceName;
592  dproblem.second = e.what();
593 
594  problematicDatasets.push_back(dproblem);
595  }
596  catch(...)
597  {
598  std::pair<std::string, std::string> dproblem;
599  dproblem.first = sourceName;
600  dproblem.second = TE_QT_PLUGIN_TERRALIB4("unknown problem in conversion!");
601 
602  problematicDatasets.push_back(dproblem);
603  }
604  }
605 
606 // give a warning
607  if(!problematicDatasets.empty())
608  {
609  QString error(tr("Some TerraLib 4.x Layers could not be converted: \n\n"));
610  QString details;
611 
612  for(std::size_t i = 0; i < problematicDatasets.size(); ++i)
613  {
614  error.append(QString(" - ") + problematicDatasets[i].first.c_str() + QString(""));
615  details.append(problematicDatasets[i].first.c_str() + QString(":\n"));
616  details.append(problematicDatasets[i].second.c_str() + QString("\n\n"));
617  }
618 
619  QMessageBox message(QMessageBox::Warning, tr("TerraLib 4.x Converter"), error, QMessageBox::Ok, this);
620  message.setDetailedText(details);
621 
622  message.exec();
623  }
624 
625 // fill next page!
626  m_finalPage->setDataSets(successfulDatasets);
627 
628  m_rollback = false;
629 }
630 
632 {
633  std::vector<std::string> selected = m_finalPage->getSelected();
634 
635  te::da::DataSourcePtr outDataSource;
636 
637  try
638  {
639  if(m_hasNonRaster)
640  outDataSource = te::da::DataSourceManager::getInstance().find(m_targetDataSource->getId());
641  }
642  catch(const te::da::Exception& e)
643  {
644  m_rollback = true;
645  QMessageBox::warning(this, tr("Warning"), e.what());
646  return;
647  }
648  catch(...)
649  {
650  m_rollback = true;
651  QMessageBox::warning(this, tr("Warning"), tr("Could not connect to TerraLib 5 data source!"));
652  return;
653  }
654 
655  try
656  {
657  te::qt::widgets::ScopedCursor sc(Qt::WaitCursor);
658 
659  for(std::size_t i = 0; i < selected.size(); ++i)
660  {
661  te::map::AbstractLayerPtr layer = 0;
662 
663  std::auto_ptr<te::da::DataSetType> sourceDt = m_tl4Database->getDataSetType(getOriginalName(selected[i]));
664 
665  if(sourceDt->hasRaster())
666  {
667  std::map<std::string, std::string> connInfo;
668  connInfo["URI"] = m_rasterFolderPath + "/" + selected[i] + ".tif";
669 
670  layer = te::qt::widgets::createLayer("GDAL", connInfo);
671  }
672  else
673  {
674  te::qt::widgets::DataSet2Layer converter(m_targetDataSource->getId());
675 
676  std::auto_ptr<te::da::DataSetType> dsType = outDataSource->getDataSetType(selected[i]);
677 
678  te::da::DataSetTypePtr dt(dsType.release());
679 
680  layer = converter(dt);
681  }
682 
683  te::qt::af::evt::LayerAdded evt(layer);
684 
686  }
687  }
688  catch(const te::da::Exception& e)
689  {
690  m_rollback = true;
691  QMessageBox::warning(this, tr("Warning"), e.what());
692  return;
693  }
694  catch(...)
695  {
696  m_rollback = true;
697  QMessageBox::warning(this, tr("Warning"), tr("Automatic layer creation failed!"));
698  return;
699  }
700 
701 
702  // std::string originalName = "";
703  // std::map<std::string, std::string>::iterator it = m_datasetFinalNames.begin();
704  // while(it != m_datasetFinalNames.end())
705  // {
706  // if(it->second == selected[i])
707  // {
708  // originalName = it->first;
709  // break;
710  // }
711  //
712  // ++it;
713  // }
714 
715  // std::auto_ptr<te::da::DataSetType> dt = m_tl4Database->getDataSetType(originalName);
716 
717  // if(dt->hasRaster())
718  // {
719  // std::map<std::string, std::string> connInfo;
720  // connInfo["URI"] = m_rasterFolderPath + "/" + selected[i] + ".tif";
721 
722  // lay = te::qt::widgets::createLayer("GDAL", connInfo);
723  // }
724  // else
725  // {
726  // te::da::DataSourcePtr outDataSource = te::da::DataSourceManager::getInstance().find(m_targetDataSource->getId());
727 
728  // te::qt::widgets::DataSet2Layer converter(m_targetDataSource->getId());
729 
730  // std::auto_ptr<te::da::DataSetType> dsType = outDataSource->getDataSetType(selected[i]);
731 
732  // te::da::DataSetTypePtr dt(dsType.release());
733 
734  // lay = converter(dt);
735  // }
736 
737  // te::qt::af::evt::LayerAdded evt(lay);
738 
739  // te::qt::af::ApplicationController::getInstance().broadcast(&evt);
740  //}
741 }
742 
744 {
745  QMessageBox::warning(this,
746  tr("TerraLib 4.x Converter"),
747  tr("This option is not implemented yet!\nWe will provide it soon!"));
748 }
749 
750 
751 
752 
753 
754 
755 
std::auto_ptr< te::qt::widgets::DataSourceSelectorWizardPage > m_datasourceSelectorPage
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
std::auto_ptr< TL4LayerSelectionWizardPage > m_layerSelectionPage
An converter for DataSetType.
static std::auto_ptr< DataSource > make(const std::string &dsType)
std::auto_ptr< TL4RasterFolderSelectionWizardPage > m_rasterFolderSelectionPage
virtual const char * what() const
It outputs the exception message.
Definition: Exception.cpp:58
static ApplicationController & getInstance()
It gives access to the controller singleton.
Push button that uses te::qt::widgets::HelpManager on its mouse pressed implementation.
This event signals that a new layer was created.
Definition: LayerEvents.h:61
TEQTWIDGETSEXPORT te::map::AbstractLayerPtr createLayer(const std::string &driverName, const std::map< std::string, std::string > &connInfo)
Definition: Utils.cpp:40
void setPageReference(const QString &ref)
Sets the documentation page reference.
std::auto_ptr< QTableWidget > m_resolveNameTableWidget
TERASTEREXPORT te::rst::RasterPtr CreateCopy(const te::rst::Raster &rin, const std::string &uri, const std::string &rType=std::string("GDAL"))
Create a new raster from existing one.
Definition: Utils.cpp:303
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1395
std::auto_ptr< Ui::TL4ConverterWizardForm > m_ui
std::auto_ptr< TL4FinalPageWizardPage > m_finalPage
TEDATAACCESSEXPORT void Create(DataSource *ds, DataSetType *dt, DataSet *d, std::size_t limit=0)
It creates the dataset definition in a data source and then fill it with data from the input dataset...
Definition: Utils.cpp:573
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
#define TE_QT_PLUGIN_TERRALIB4(message)
It marks a string in order to get translated. This is a special mark used in the TERRALIB4 QtPlugin o...
Definition: Config.h:58
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
std::string getOriginalName(const std::string &targetName)
TL4ConverterWizard(QWidget *parent=0, Qt::WindowFlags f=0)
std::auto_ptr< TL4ConnectorWizardPage > m_connectorPage
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
Definition: Utils.cpp:591
A wizard page that provides the capability of connecting to a TerraLib 4.x database.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48