All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MainWindowDialog.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/addressgeocoding/MainWindowDialog.cpp
22 
23  \brief A dialog for Address Geocoding operation
24 */
25 
26 // TerraLib
27 #include "../../common/CharEncodingConv.h"
28 #include "../../common/Logger.h"
29 #include "../../common/progress/ProgressManager.h"
30 #include "../../common/Translator.h"
31 #include "../../common/STLUtils.h"
32 #include "../../dataaccess/dataset/DataSetType.h"
33 #include "../../dataaccess/dataset/ObjectIdSet.h"
34 #include "../../dataaccess/datasource/DataSourceCapabilities.h"
35 #include "../../dataaccess/datasource/DataSourceInfo.h"
36 #include "../../dataaccess/datasource/DataSourceInfoManager.h"
37 #include "../../dataaccess/datasource/DataSourceFactory.h"
38 #include "../../dataaccess/datasource/DataSourceManager.h"
39 #include "../../dataaccess/utils/Utils.h"
40 #include "../../datatype/Enums.h"
41 #include "../../datatype/Property.h"
42 #include "../../maptools/AbstractLayer.h"
43 #include "../../qt/af/Utils.h"
44 #include "../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h"
45 #include "../../qt/widgets/layer/utils/DataSet2Layer.h"
46 #include "../../qt/widgets/progress/ProgressViewerDialog.h"
47 #include "../../qt/widgets/Utils.h"
48 #include "../AddressGeocodingOp.h"
49 #include "../Config.h"
50 #include "../Exception.h"
51 #include "MainWindowDialog.h"
53 #include "ConfigInputLayerDialog.h"
54 #include "ui_MainWindowDialogForm.h"
55 
56 // Qt
57 #include <QFileDialog>
58 #include <QMessageBox>
59 #include <QSettings>
60 
61 // Boost
62 #include <boost/algorithm/string.hpp>
63 #include <boost/filesystem.hpp>
64 #include <boost/uuid/random_generator.hpp>
65 #include <boost/uuid/uuid_io.hpp>
66 
68  : QDialog(parent, f),
69  m_ui(new Ui::MainWindowDialogForm),
70  m_layers(std::list<te::map::AbstractLayerPtr>()),
71  m_newColumnLayer(0)
72 {
73 // add controls
74  m_ui->setupUi(this);
75 
76 // add icons
77  m_ui->m_imgLabel->setPixmap(QIcon::fromTheme("addressgeocoding-hint").pixmap(112,48));
78  m_ui->m_targetDatasourceToolButton->setIcon(QIcon::fromTheme("datasource"));
79  m_ui->m_targetDataSourceAddressToolButton->setIcon(QIcon::fromTheme("datasource"));
80  m_ui->m_editAddressFileToolButton->setIcon(QIcon::fromTheme("preferences-system"));
81  m_ui->m_removeAddressFileToolButton->setIcon(QIcon::fromTheme("delete"));
82 
83  connect(m_ui->m_inputLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLayerComboBoxChanged(int)));
84  connect(m_ui->m_iLeftComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onInitialLeftComboBoxChanged(int)));
85  connect(m_ui->m_fLeftComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onFinalLeftComboBoxChanged(int)));
86  connect(m_ui->m_iRightComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onInitialRightComboBoxChanged(int)));
87  connect(m_ui->m_fRightComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onFinalRightComboBoxChanged(int)));
88  connect(m_ui->m_inputAddressComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onAddressComboBoxChanged(int)));
89 
90  connect(m_ui->m_targetFileToolButton, SIGNAL(pressed()), this, SLOT(onTargetFileToolButtonPressed()));
91  connect(m_ui->m_targetDatasourceToolButton, SIGNAL(pressed()), this, SLOT(onTargetDatasourceToolButtonPressed()));
92 
93  connect(m_ui->m_configureLayerPushButton, SIGNAL(clicked()), this, SLOT(onConfigureLayerClicked()));
94  connect(m_ui->m_targetFileAddressToolButton, SIGNAL(clicked()), this, SLOT(onTargetFileAddressToolButtonPressed()));
95 
96  connect(m_ui->m_removeAddressFileToolButton, SIGNAL(clicked()), this, SLOT(onRemoveAddressToolButtonPressed()));
97  connect(m_ui->m_editAddressFileToolButton, SIGNAL(clicked()), this, SLOT(onEditAddressToolButtonPressed()));
98 
99  connect(m_ui->m_helpPushButton, SIGNAL(clicked()), this, SLOT(onHelpPushButtonClicked()));
100  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onOkPushButtonClicked()));
101  connect(m_ui->m_cancelPushButton, SIGNAL(clicked()), this, SLOT(onCancelPushButtonClicked()));
102 
103 // Load the Address file Name.
105  std::map<std::string, std::vector<std::string> >::iterator it = m_mapFields.begin();
106 
107  while(it != m_mapFields.end())
108  {
109  m_ui->m_inputAddressComboBox->addItem(QString(it->first.c_str()));
110  ++it;
111  }
112 }
113 
115 {
116 }
117 
118 void te::addressgeocoding::MainWindowDialog::setLayers(std::list<te::map::AbstractLayerPtr> layers)
119 {
120  m_layers = layers;
121 
122  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
123 
124  while(it != m_layers.end())
125  {
126  std::auto_ptr<te::da::DataSetType> dsType = it->get()->getSchema();
127  std::vector<te::dt::Property*> properties = dsType->getProperties();
128  for(std::size_t i = 0; i < properties.size(); ++i)
129  {
130  std::string name = properties[i]->getName();
131  if(name == "tsvector")
132  m_ui->m_inputLayerComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant(it->get()->getId().c_str()));
133  }
134 
135  ++it;
136  }
137 }
138 
140 {
141  return m_resultLayer;
142 }
143 
145 {
146  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
147 
148  std::string layerID = m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole).toString().toStdString();
149 
150  while(it != m_layers.end())
151  {
152  if(layerID == it->get()->getId().c_str())
153  {
154  te::map::AbstractLayerPtr selectedLayer = it->get();
155  m_selectedLayer = selectedLayer;
156 
157  std::auto_ptr<te::da::DataSetType> dsType = m_selectedLayer->getSchema();
158  std::vector<te::dt::Property*> propVec = dsType->getProperties();
159 
160  m_ui->m_iLeftComboBox->clear();
161  m_ui->m_fLeftComboBox->clear();
162  m_ui->m_iRightComboBox->clear();
163  m_ui->m_fRightComboBox->clear();
164 
165  m_ui->m_iLeftComboBox->addItem("");
166  m_ui->m_fLeftComboBox->addItem("");
167  m_ui->m_iRightComboBox->addItem("");
168  m_ui->m_fRightComboBox->addItem("");
169 
170  int type;
171 
172  for(std::size_t i = 0; i < propVec.size(); ++i)
173  {
174  type = propVec[i]->getType();
175  if(type == te::dt::INT16_TYPE ||
176  type == te::dt::INT32_TYPE ||
177  type == te::dt::INT64_TYPE ||
178  type == te::dt::DOUBLE_TYPE ||
179  type == te::dt::NUMERIC_TYPE)
180  {
181  m_ui->m_iLeftComboBox->addItem(QString(propVec[i]->getName().c_str()));
182  m_ui->m_fLeftComboBox->addItem(QString(propVec[i]->getName().c_str()));
183  m_ui->m_iRightComboBox->addItem(QString(propVec[i]->getName().c_str()));
184  m_ui->m_fRightComboBox->addItem(QString(propVec[i]->getName().c_str()));
185  }
186  }
187 
188  return;
189  }
190  ++it;
191  }
192 }
193 
195 {
196  m_initialLeft = m_ui->m_iLeftComboBox->itemText(index).toStdString();
197 }
198 
200 {
201  m_finalLeft = m_ui->m_fLeftComboBox->itemText(index).toStdString();
202 }
203 
205 {
206  m_initialRight = m_ui->m_iRightComboBox->itemText(index).toStdString();
207 }
208 
210 {
211  m_finalRight = m_ui->m_fRightComboBox->itemText(index).toStdString();
212 }
213 
215 {
217  dlg.setLayers(m_layers);
218 
219  if(dlg.exec() == QDialog::Accepted)
220  {
221  m_newColumnLayer = dlg.getLayer();
222  m_layerDataSource = dlg.getDataSource();
223  m_ui->m_inputLayerComboBox->clear();
224  setLayers(m_layers);
225  }
226  return;
227 }
228 
230 {
231  // Load the Address file Name.
232 
233  if(index == -1)
234  {
235  m_ui->m_editAddressFileToolButton->setEnabled(false);
236  m_ui->m_removeAddressFileToolButton->setEnabled(false);
237  return;
238  }
239 
240  GetAddressFilePathToSettings(m_mapFields);
241 
242  std::map<std::string, std::vector<std::string> >::iterator it;
243 
244  std::string value = m_ui->m_inputAddressComboBox->itemText(index).toStdString();
245 
246  it = m_mapFields.find(value);
247  m_addressFile = it->first;
248  std::vector<std::string> vecFields = it->second;
249 
250  m_associatedProps.clear();
251 
252  for(std::size_t i = 0; i < vecFields.size(); ++i)
253  {
254  if(i != 0 && i != 2 && vecFields[i] != "")
255  m_associatedProps.push_back(vecFields[i]);
256  if(i == 0)
257  GetAddressDataSource(vecFields[i]);
258  if(i == 2)
259  m_streetNumber = m_mapFields.begin()->second[i];
260  }
261 
262  m_ui->m_editAddressFileToolButton->setEnabled(true);
263  m_ui->m_removeAddressFileToolButton->setEnabled(true);
264 }
265 
267 {
268  try
269  {
270  QString fileName = QFileDialog::getOpenFileName(this, tr("Open Textual File"), te::qt::widgets::GetFilePathFromSettings("tabular"), tr("dBASE (*.dbf *.DBF);; Comma Separated Value (*.csv *.CSV)"),
271  0, QFileDialog::ReadOnly);
272 
273  GetAddressDataSource(fileName.toStdString());
274 
275  if (fileName.isEmpty())
276  return;
277 
279 
280  if(m_addressDataSource)
281  dlg.setDataSource(m_addressDataSource);
282 
283  if(dlg.exec() == QDialog::Accepted)
284  {
285  m_addressDataSource = dlg.getDataSource();
286  m_addressFile = dlg.getAddressFileName();
287 
288  if(dlg.getStreetType() != "")
289  m_associatedProps.push_back(dlg.getStreetType());
290 
291  if(dlg.getStreetTitle() != "")
292  m_associatedProps.push_back(dlg.getStreetTitle());
293 
294  if(dlg.getStreetName() != "")
295  m_associatedProps.push_back(dlg.getStreetName());
296 
297  if(dlg.getStreetNeighborhood() != "")
298  m_associatedProps.push_back(dlg.getStreetNeighborhood());
299 
300  if(dlg.getStreetPostalCode() != "")
301  m_associatedProps.push_back(dlg.getStreetPostalCode());
302 
303  m_streetNumber = dlg.getStreetNumber();
304 
305  m_ui->m_inputAddressComboBox->addItem(QString(m_addressFile.c_str()));
306  }
307 
308  return;
309  }
310  catch(const std::exception& e)
311  {
312  QMessageBox::warning(this, tr("Address Geocoding"), e.what());
313  }
314 }
315 
317 {
319 
320  if(m_addressDataSource)
321  dlg.setDataSource(m_addressDataSource);
322 
323  std::map<std::string, std::vector<std::string> > mapFields;
324  GetAddressFilePathToSettings(mapFields);
325  std::map<std::string, std::vector<std::string> >::iterator it;
326 
327  std::string value = m_ui->m_inputAddressComboBox->currentText().toStdString();
328 
329  it = mapFields.find(value);
330  m_addressFile = it->first;
331  std::vector<std::string> vecFields = it->second;
332 
333  dlg.setStreetNeighborhood(vecFields[1]);
334  dlg.setStreetNumber(vecFields[2]);
335  dlg.setStreetPostalCode(vecFields[3]);
336  dlg.setStreetName(vecFields[4]);
337  dlg.setStreetTitle(vecFields[5]);
338  dlg.setStreetType(vecFields[6]);
339 
340  if(dlg.exec() == QDialog::Accepted)
341  {
342  m_addressDataSource = dlg.getDataSource();
343  m_addressFile = dlg.getAddressFileName();
344 
345  if(dlg.getStreetType() != "")
346  m_associatedProps.push_back(dlg.getStreetType());
347 
348  if(dlg.getStreetTitle() != "")
349  m_associatedProps.push_back(dlg.getStreetTitle());
350 
351  if(dlg.getStreetName() != "")
352  m_associatedProps.push_back(dlg.getStreetName());
353 
354  if(dlg.getStreetNeighborhood() != "")
355  m_associatedProps.push_back(dlg.getStreetNeighborhood());
356 
357  if(dlg.getStreetPostalCode() != "")
358  m_associatedProps.push_back(dlg.getStreetPostalCode());
359 
360  m_streetNumber = dlg.getStreetNumber();
361 
362  m_ui->m_inputAddressComboBox->addItem(QString(m_addressFile.c_str()));
363  }
364 
365  return;
366 }
367 
369 {
370  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
371 
372  sett.beginGroup("Address Geocoding");
373 
374  sett.remove(m_ui->m_inputAddressComboBox->currentText());
375  m_ui->m_inputAddressComboBox->removeItem(m_ui->m_inputAddressComboBox->currentIndex());
376 
377  sett.endGroup();
378 }
379 
381 {
382  m_ui->m_newLayerNameLineEdit->clear();
383  m_ui->m_newLayerNameLineEdit->setEnabled(true);
385  dlg.exec();
386 
387  std::list<te::da::DataSourceInfoPtr> dsPtrList = dlg.getSelecteds();
388 
389  if(dsPtrList.size() <= 0)
390  return;
391 
392  std::list<te::da::DataSourceInfoPtr>::iterator it = dsPtrList.begin();
393 
394  m_ui->m_repositoryLineEdit->setText(QString(it->get()->getTitle().c_str()));
395 
396  m_outputDatasource = *it;
397 
398  m_toFile = false;
399 }
400 
402 {
403  m_ui->m_newLayerNameLineEdit->clear();
404  m_ui->m_repositoryLineEdit->clear();
405 
406  QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."),
407  QString(), tr("Shapefile (*.shp *.SHP);;"),0, QFileDialog::DontConfirmOverwrite);
408 
409  if (fileName.isEmpty())
410  return;
411 
412  boost::filesystem::path outfile(fileName.toStdString());
413  std::string aux = outfile.leaf().string();
414  m_ui->m_newLayerNameLineEdit->setText(aux.c_str());
415  aux = outfile.string();
416  m_ui->m_repositoryLineEdit->setText(aux.c_str());
417 
418  m_toFile = true;
419  m_ui->m_newLayerNameLineEdit->setEnabled(false);
420 }
421 
423 {
424  QMessageBox::information(this, "Help", "Under development");
425 }
426 
428 {
429  if(!m_selectedLayer)
430  {
431  QMessageBox::information(this, "Address Geocoding", "Configure an input layer.");
432  return;
433  }
434 
435  if((m_initialLeft == "" || m_finalLeft == "")&&(m_initialRight == "" || m_finalRight == ""))
436  {
437  QMessageBox::information(this, "Address Geocoding", "Associates the number fields with attributes of input layer.");
438  return;
439  }
440 
441  if(m_addressFile == "")
442  {
443  QMessageBox::information(this, "Address Geocoding", "Configure an input address.");
444  return;
445  }
446 
447  if(!m_layerDataSource)
448  {
449  te::map::DataSetLayer* dsLayer = dynamic_cast<te::map::DataSetLayer*>(m_selectedLayer.get());
450  m_layerDataSource = te::da::GetDataSource(dsLayer->getDataSourceId());
451  }
452 
454 
455  addGeoOp->setInput( m_layerDataSource,
456  m_selectedLayer->getTitle(),
457  m_selectedLayer->getSRID(),
458  m_addressDataSource,
459  m_addressFile);
460 
461  addGeoOp->setParams(m_associatedProps,
462  m_streetNumber);
463 
464  addGeoOp->setNumAttributes( m_initialLeft,
465  m_finalLeft,
466  m_initialRight,
467  m_finalRight);
468 
469  std::string outputdataset = m_ui->m_newLayerNameLineEdit->text().toStdString();
470 
471  te::da::DataSourcePtr outputDataSource;
472  bool res;
473 
474  try
475  {
476  if(m_toFile)
477  {
478  boost::filesystem::path uri(m_ui->m_repositoryLineEdit->text().toStdString());
479 
480  if (boost::filesystem::exists(uri))
481  {
482  QMessageBox::information(this, "Address Geocoding", "Output file already exists. Remove it or select a new name and try again.");
483  return;
484  }
485 
486  std::size_t idx = outputdataset.find(".");
487  if (idx != std::string::npos)
488  outputdataset=outputdataset.substr(0,idx);
489 
490  std::map<std::string, std::string> dsinfo;
491  dsinfo["URI"] = uri.string();
492 
493  outputDataSource.reset(te::da::DataSourceFactory::make("OGR").release());
494  outputDataSource->setConnectionInfo(dsinfo);
495  outputDataSource->open();
496  if (outputDataSource->dataSetExists(outputdataset))
497  {
498  QMessageBox::information(this, "Address Geocoding", "There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again.");
499  return;
500  }
501 
502  this->setCursor(Qt::WaitCursor);
503 
504  addGeoOp->setOutput(outputDataSource,
505  outputdataset);
506 
507  if (!addGeoOp->paramsAreValid())
508  res = false;
509  else
510  res = addGeoOp->run();
511 
512  if (!res)
513  {
514  this->setCursor(Qt::ArrowCursor);
515  outputDataSource->close();
516  QMessageBox::information(this, "Address Geocoding", "Error: could not generate the address geocoding.");
517  reject();
518  }
519  outputDataSource->close();
520 
521  delete addGeoOp;
522 
523 // let's include the new datasource in the managers
524  boost::uuids::basic_random_generator<boost::mt19937> gen;
525  boost::uuids::uuid u = gen();
526  std::string id_ds = boost::uuids::to_string(u);
527 
529  ds->setConnInfo(dsinfo);
530  ds->setTitle(uri.stem().string());
531  ds->setAccessDriver("OGR");
532  ds->setType("OGR");
533  ds->setDescription(uri.string());
534  ds->setId(id_ds);
535 
536  te::da::DataSourcePtr newds = te::da::DataSourceManager::getInstance().get(id_ds, "OGR", ds->getConnInfo());
537  newds->open();
539  m_outputDatasource = ds;
540 
541  }
542  else
543  {
544  outputDataSource = te::da::GetDataSource(m_outputDatasource->getId());
545  if (!outputDataSource)
546  {
547  QMessageBox::information(this, "Address Geocoding", "The selected output datasource can not be accessed.");
548  return;
549  }
550 
551  if (outputDataSource->dataSetExists(outputdataset))
552  {
553  QMessageBox::information(this, "Address Geocoding", "Dataset already exists. Remove it or select a new name and try again.");
554  return;
555  }
556  this->setCursor(Qt::WaitCursor);
557 
558  addGeoOp->setOutput(outputDataSource,
559  outputdataset);
560 
561  if (!addGeoOp->paramsAreValid())
562  res = false;
563  else
564  res = addGeoOp->run();
565 
566  delete addGeoOp;
567 
568  if (!res)
569  {
570  this->setCursor(Qt::ArrowCursor);
571  outputDataSource->close();
572  QMessageBox::information(this, "Address Geocoding", "Error: could not generate the address geocoding.");
573  reject();
574  }
575  outputDataSource->close();
576 
577  }
578 
579 // creating a layer for the result
580  te::da::DataSourcePtr outDataSource = te::da::GetDataSource(m_outputDatasource->getId());
581 
582  te::qt::widgets::DataSet2Layer converter(m_outputDatasource->getId());
583 
584  te::da::DataSetTypePtr dt(outDataSource->getDataSetType(outputdataset).release());
585  m_resultLayer = converter(dt);
586 
587  }
588  catch(const std::exception& e)
589  {
590  this->setCursor(Qt::ArrowCursor);
591 
592  QMessageBox::information(this, "Address Geocoding", e.what());
593 
594  //te::common::Logger::logDebug("addressgeocoding", e.what());
595  //te::common::ProgressManager::getInstance().removeViewer(id);
596  return;
597  }
598 
599  this->setCursor(Qt::ArrowCursor);
600 
601  accept();
602 }
603 
605 {
606  reject();
607 }
608 
609 void te::addressgeocoding::MainWindowDialog::GetAddressFilePathToSettings(std::map<std::string, std::vector<std::string> >& mapFields)
610 {
611  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
612 
613  sett.beginGroup("Address Geocoding");
614  QStringList lst = sett.childGroups();
615 
616  QStringList::iterator it;
617 
618  for(it=lst.begin(); it != lst.end(); ++it)
619  {
620  QString gr = *it;
621 
622  sett.beginGroup(gr);
623 
624  std::vector<std::string> vecFields;
625 
626  std::string fileName = sett.value("fileName").toString().toStdString();
627  vecFields.push_back(sett.value("filePath").toString().toStdString());
628  vecFields.push_back(sett.value("neighborhood").toString().toStdString());
629  vecFields.push_back(sett.value("number").toString().toStdString());
630  vecFields.push_back(sett.value("postalCode").toString().toStdString());
631  vecFields.push_back(sett.value("streetName").toString().toStdString());
632  vecFields.push_back(sett.value("streetTitle").toString().toStdString());
633  vecFields.push_back(sett.value("streetType").toString().toStdString());
634 
635  mapFields.insert(std::pair<std::string, std::vector<std::string> >(fileName, vecFields));
636 
637  sett.endGroup();
638  }
639  sett.endGroup();
640 }
641 
643 {
644  if(QString(filePath.c_str()).isEmpty())
645  return;
646 
647  QFileInfo info(QString(filePath.c_str()));
648  te::qt::widgets::AddFilePathToSettings(info.absolutePath(), "tabular");
649 
650  //Getting the connection info
651  std::string ogrInfo("connection_string=" + filePath);
652  std::map<std::string, std::string> connInfo;
653  connInfo["URI"] = filePath;
654 
655  boost::filesystem::path uri(filePath);
656  std::string file = uri.stem().string();
657 
658  //Creating a DataSource
659  static boost::uuids::basic_random_generator<boost::mt19937> gen;
660  boost::uuids::uuid u = gen();
661 
663  dsInfo->setConnInfo(connInfo);
664  dsInfo->setId(boost::uuids::to_string(u));
665  dsInfo->setTitle(filePath);
666  dsInfo->setDescription("");
667  dsInfo->setAccessDriver("OGR");
668  dsInfo->setType("OGR");
669 
671 
672  m_addressDataSource = te::da::DataSourceFactory::make(dsInfo->getAccessDriver());
673  m_addressDataSource->setConnectionInfo(dsInfo->getConnInfo());
674 
675  m_addressDataSource->setId(boost::uuids::to_string(u));
676  m_addressDataSource->open();
677 }
void setParams(std::vector< std::string > associatedProps, std::string streetNumber)
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
Definition: Utils.cpp:262
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, int inSRID, te::da::DataSourcePtr inAddressDsrc, std::string inAddressDsetName)
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
void setDataSource(te::da::DataSourcePtr dataSource)
TEQTWIDGETSEXPORT void AddFilePathToSettings(const QString &path, const QString &typeFile)
Save last used path in QSettings.
Definition: Utils.cpp:367
void setNumAttributes(std::string initialLeft, std::string finalLeft, std::string initialRight, std::string finalRight)
void setStreetPostalCode(std::string streetPostalCode)
void setStreetNeighborhood(std::string streetNeighborhood)
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
A dialog configure the input layer to address geocoding operation.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
A dialog to import table with address to geocoding operation.
const std::string & getDataSourceId() const
static std::auto_ptr< DataSource > make(const std::string &dsType)
void setOutput(te::da::DataSourcePtr outDsrc, std::string m_outDsetName)
MainWindowDialog(QWidget *parent=0, Qt::WindowFlags f=0)
void GetAddressFilePathToSettings(std::map< std::string, std::vector< std::string > > &mapFields)
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
void GetAddressDataSource(std::string fileName)
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
A dialog for selecting a data source.
A class that represents a data source component.
te::map::AbstractLayerPtr getLayer()
Get the generated layer.
std::auto_ptr< Ui::MainWindowDialogForm > m_ui
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
TEQTWIDGETSEXPORT QString GetFilePathFromSettings(const QString &typeFile)
Returns the value of the last saved file path for the typeFile required.
Definition: Utils.cpp:376
std::map< std::string, std::vector< std::string > > m_mapFields
A main window to address geocoding operation.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr