CreateCellularSpaceDialog.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/qt/widgets/connector/cellspace/CreateCellularSpaceDialog.cpp
22 
23  \brief ....
24 */
25 
26 // TerraLib
27 #include "../../../cellspace/CellSpaceOperations.h"
28 #include "../../../common/Exception.h"
29 #include "../../../common/progress/ProgressManager.h"
30 #include "../../../common/StringUtils.h"
31 #include "../../../common/Translator.h"
32 #include "../../../common/UnitsOfMeasureManager.h"
33 #include "../../../dataaccess/datasource/DataSource.h"
34 #include "../../../dataaccess/datasource/DataSourceFactory.h"
35 #include "../../../dataaccess/datasource/DataSourceInfoManager.h"
36 #include "../../../dataaccess/datasource/DataSourceTransactor.h"
37 #include "../../../dataaccess/datasource/DataSourceManager.h"
38 #include "../../../dataaccess/utils/Utils.h"
39 #include "../../../qt/widgets/layer/utils/DataSet2Layer.h"
40 #include "../../../qt/widgets/help/HelpPushButton.h"
41 #include "../../../qt/widgets/progress/ProgressViewerDialog.h"
42 #include "../../../qt/widgets/srs/SRSManagerDialog.h"
43 #include "../../../qt/widgets/utils/ScopedCursor.h"
44 #include "../../../srs/SpatialReferenceSystemManager.h"
45 #include "../../../srs/Converter.h"
46 #include "../../widgets/datasource/selector/DataSourceSelectorDialog.h"
47 #include "ui_CreateCellularSpaceDialogForm.h"
49 
50 // Qt
51 #include <QFileDialog>
52 #include <QMessageBox>
53 #include <QToolButton>
54 
55 // Boost
56 #include <boost/filesystem.hpp>
57 #include <boost/uuid/random_generator.hpp>
58 #include <boost/uuid/uuid_io.hpp>
59 
62 
64  : QDialog(parent, f),
65  m_bbSRID(4618),
66  m_isFile(false),
67  m_outputDataSetName(""),
68  m_ui(new Ui::CreateCellularSpaceDialogForm)
69 {
70 // add controls
71  m_ui->setupUi(this);
72 
73 // Set icons
74  QSize iconSize(32, 32);
75 
76  m_ui->m_imgLabel->setPixmap(QIcon::fromTheme("cellspace-no-mask-hint").pixmap(48, 48));
77  m_ui->m_maskRadioButton->setIconSize(iconSize);
78  m_ui->m_maskRadioButton->setIcon(QIcon::fromTheme("cellspace-mask-hint"));
79  m_ui->m_noMaskRadioButton->setIconSize(iconSize);
80  m_ui->m_noMaskRadioButton->setIcon(QIcon::fromTheme("cellspace-no-mask-hint"));
81  m_ui->m_polygonsRadioButton->setIconSize(iconSize);
82  m_ui->m_polygonsRadioButton->setIcon(QIcon::fromTheme("cellspace-polygons-hint"));
83  m_ui->m_pointsRadioButton->setIconSize(iconSize);
84  m_ui->m_pointsRadioButton->setIcon(QIcon::fromTheme("cellspace-points-hint"));
85  m_ui->m_targetDatasourceToolButton->setIcon(QIcon::fromTheme("datasource"));
86  m_ui->m_srsToolButton->setIcon(QIcon::fromTheme("srs"));
87 
88 // Set validators
89  m_ui->m_llxLineEdit->setValidator(new QDoubleValidator(this));
90  m_ui->m_llyLineEdit->setValidator(new QDoubleValidator(this));
91  m_ui->m_urxLineEdit->setValidator(new QDoubleValidator(this));
92  m_ui->m_uryLineEdit->setValidator(new QDoubleValidator(this));
93  m_ui->m_resXLineEdit->setValidator(new QDoubleValidator(0, 99999999, 8, this));
94  m_ui->m_resYLineEdit->setValidator(new QDoubleValidator(0, 99999999, 8, this));
95 
97 
98  connect(m_ui->m_layersComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLayersComboBoxChanged(int)));
99  connect(m_ui->m_unitComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onUnitComboBoxChanged(int)));
100 
101  connect(m_ui->m_resXLineEdit, SIGNAL(editingFinished()), this, SLOT(onResXLineEditEditingFinished()));
102  connect(m_ui->m_resYLineEdit, SIGNAL(editingFinished()), this, SLOT(onResYLineEditEditingFinished()));
103  connect(m_ui->m_llxLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onEnvelopeChanged(const QString &)));
104  connect(m_ui->m_llyLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onEnvelopeChanged(const QString &)));
105  connect(m_ui->m_urxLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onEnvelopeChanged(const QString &)));
106  connect(m_ui->m_uryLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onEnvelopeChanged(const QString &)));
107 
108  connect(m_ui->m_targetFileToolButton, SIGNAL(clicked()), this, SLOT(onTargetFileToolButtonClicked()));
109  connect(m_ui->m_targetDatasourceToolButton, SIGNAL(clicked()), this, SLOT(onTargetDatasourceToolButtonClicked()));
110  connect(m_ui->m_createPushButton, SIGNAL(clicked()), this, SLOT(onCreatePushButtonClicked()));
111  connect(m_ui->m_srsToolButton, SIGNAL(clicked()), this, SLOT(onSrsToolButtonClicked()));
112 
113  m_ui->m_helpPushButton->setNameSpace("dpi.inpe.br.plugins");
114  m_ui->m_helpPushButton->setPageReference("plugins/cellspace/cellspace.html");
115 }
116 
118 {
119 }
120 
121 void te::qt::plugins::cellspace::CreateCellularSpaceDialog::setLayers(std::list<te::map::AbstractLayerPtr> layers)
122 {
123  if (layers.empty())
124  {
125  m_ui->m_noMaskRadioButton->setChecked(true);
126  m_ui->m_maskRadioButton->setEnabled(false);
127  m_ui->m_resSRIDLabel->setText("No SRS defined");
128  m_ui->m_layerSRIDLabel->setText("No SRS defined");
129  m_ui->m_unitComboBox->setCurrentIndex(0);
130  m_bbSRID = 0;
131  return;
132  }
133 
134  std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
135  m_bbSRID = it->get()->getSRID();
136  while(it != layers.end())
137  {
138  m_ui->m_layersComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant::fromValue(*it));
139  ++it;
140  }
141  m_ui->m_layersComboBox->setCurrentIndex(0);
142 }
143 
145 {
146  if(m_isFile)
147  {
148  // let's include the new datasource in the managers
149  boost::uuids::basic_random_generator<boost::mt19937> gen;
150  boost::uuids::uuid u = gen();
151  std::string id_ds = boost::uuids::to_string(u);
152 
153  boost::filesystem::path uri(m_outDataSourceInfo->getConnInfo()["URI"]);
154 
156  ds->setConnInfo(m_outDataSourceInfo->getConnInfo());
157  ds->setTitle(uri.stem().string());
158  ds->setAccessDriver("OGR");
159  ds->setType("OGR");
160  ds->setDescription(uri.string());
161  ds->setId(id_ds);
162 
163  te::da::DataSourcePtr newds = te::da::DataSourceManager::getInstance().get(id_ds, "OGR", ds->getConnInfo());
164  newds->open();
166  m_outDataSourceInfo = ds;
167 
168  m_outputDataSetName = uri.stem().string();
169  }
170 
171  te::da::DataSourcePtr outDataSource = te::da::GetDataSource(m_outDataSourceInfo->getId());
172  outDataSource->open();
173 
174  te::qt::widgets::DataSet2Layer converter(m_outDataSourceInfo->getId());
175 
176  te::da::DataSetTypePtr dt(outDataSource->getDataSetType(m_outputDataSetName).release());
177 
178  te::map::AbstractLayerPtr layer = converter(dt);
179 
180  layer->setSRID(m_bbSRID);
181 
182  return layer;
183 }
184 
185 // whenever the reference layer changes the parameters of the new cellular space will bem modified accordingly
187 {
188  te::map::AbstractLayerPtr layer = getReferenceLayer();
189  if(!layer)
190  return;
191 
192  m_bbSRID = layer->getSRID();
193  int precision = 2;
194  if (m_bbSRID>0)
195  {
197  if (unit->getId() == te::common::UOM_Degree ||
198  unit->getId() == te::common::UOM_Radian)
199  precision = 6;
200  m_ui->m_resSRIDLabel->setText(te::srs::SpatialReferenceSystemManager::getInstance().getName(m_bbSRID).c_str());
201  m_ui->m_layerSRIDLabel->setText(te::srs::SpatialReferenceSystemManager::getInstance().getName(m_bbSRID).c_str());
202  setResolutionUnit(unit);
203  }
204  else
205  {
206  m_ui->m_resSRIDLabel->setText("No SRS defined");
207  m_ui->m_layerSRIDLabel->setText("No SRS defined");
208  m_ui->m_unitComboBox->setCurrentIndex(0);
209  precision = 6;
210  }
211  showEnvelope(layer->getExtent(),precision);
212  m_ui->m_maskRadioButton->setChecked(true);
213 }
214 
215 
217 {
218  clearResolution();
219 }
220 
222 {
223  te::qt::widgets::SRSManagerDialog srsDialog(this);
224  srsDialog.setWindowTitle(tr("Choose the SRS"));
225 
226  if(srsDialog.exec() == QDialog::Rejected)
227  return;
228 
229  int newSRID = srsDialog.getSelectedSRS().first;
230 
231  if (m_ui->m_maskRadioButton->isChecked())
232  {
233  te::map::AbstractLayerPtr refLayer = getReferenceLayer();
234  if (refLayer &&
235  ((newSRID <= 0 && refLayer->getSRID() > 0) ||
236  (newSRID > 0 && refLayer->getSRID() <= 0) ))
237  m_ui->m_noMaskRadioButton->setChecked(true);
238  }
239 
240  if (newSRID <= 0)
241  {
242  m_ui->m_unitComboBox->setCurrentIndex(0);
243  m_ui->m_resSRIDLabel->setText("No SRS defined");
244  }
245  else
246  {
247  std::string name = te::srs::SpatialReferenceSystemManager::getInstance().getName(newSRID);
248  m_ui->m_resSRIDLabel->setText(name.c_str());
249  if (m_bbSRID > 0)
250  {
251  te::gm::Envelope env = getEnvelope();
252  clearEnvelope();
253  if (env.isValid())
254  {
255  int precision = 2;
257  if (unit->getId() == te::common::UOM_Degree ||
258  unit->getId() == te::common::UOM_Radian)
259  precision = 6;
260 
261  env.transform(m_bbSRID,newSRID);
262  showEnvelope(env, precision);
263  }
264  }
265  }
266  m_bbSRID = newSRID;
268  setResolutionUnit(unit);
269  clearResolution();
270 }
271 
272 // if user change the unit it will have to re-enter resolution
274 {
275  if (m_bbSRID <= 0 && index != 0)
276  {
277  QMessageBox::warning(this, tr("Cellular Spaces"), tr("There is no no spatial reference defined for the new cellular space. It is not possible to select a unit for the resolution."));
278  m_ui->m_unitComboBox->setCurrentIndex(0);
279  return;
280  }
281 
282  if (index == 0)
283  return;
284 
285  clearResolution();
286 
287  te::common::UnitOfMeasurePtr resUnit = getResolutionUnit();
289 
290  if (!resUnit || !bbUnit)
291  return;
292 
293  if (resUnit == bbUnit)
294  return;
295 
296  if ((te::common::UnitsOfMeasureManager::getInstance().areConvertible(bbUnit->getName(), resUnit->getName()) || // units are convertible
297  // accepting an exception to deal with the most common case: bounding box in geographic coordinates
298  // and resolution in meters, kilometers or foot
299  (te::srs::SpatialReferenceSystemManager::getInstance().isGeographic(m_bbSRID) &&
300  (resUnit->getId() == te::common::UOM_Metre ||
301  resUnit->getId() == te::common::UOM_Foot ||
302  resUnit->getId() == te::common::UOM_Kilometre)) ||
303  (!te::srs::SpatialReferenceSystemManager::getInstance().isGeographic(m_bbSRID) &&
304  (resUnit->getId() == te::common::UOM_Radian ||
305  resUnit->getId() == te::common::UOM_Degree ))))
306  return;
307 
308  QMessageBox::warning(this, tr("Cellular Spaces"), tr("Unable to convert between the selected unit for the resolution and the unit of new cell layer SRS"));
309  m_ui->m_unitComboBox->setCurrentText(bbUnit->getName().c_str());
310 }
311 
313 {
314  te::gm::Envelope env = getEnvelope();
315  if(!env.isValid())
316  {
317  QMessageBox::warning(this, tr("Cellular Spaces"), tr("Invalid bounding box."));
318  return;
319  }
320 
321  double resX = m_ui->m_resXLineEdit->text().toDouble();
322  unitConvertion(resX, getResolutionUnit(), te::srs::SpatialReferenceSystemManager::getInstance().getUnit(m_bbSRID));
323 
324  int maxCols = (int)ceil((env.m_urx - env.m_llx)/resX);
325  m_ui->m_colsLineEdit->setText(QString::number(maxCols));
326 }
327 
329 {
330  te::gm::Envelope env = getEnvelope();
331  if(!env.isValid())
332  {
333  QMessageBox::warning(this, tr("Cellular Spaces"), tr("Invalid bounding box."));
334  return;
335  }
336 
337  double resY = m_ui->m_resXLineEdit->text().toDouble();
338  unitConvertion(resY, getResolutionUnit(), te::srs::SpatialReferenceSystemManager::getInstance().getUnit(m_bbSRID));
339 
340  int maxRows = (int)ceil((env.m_ury - env.m_lly)/resY);
341  m_ui->m_rowsLineEdit->setText(QString::number(maxRows));
342 }
343 
345 {
346  m_ui->m_newLayerNameLineEdit->clear();
347  m_ui->m_repositoryLineEdit->clear();
348 
350  dlg.exec();
351 
352  std::list<te::da::DataSourceInfoPtr> dsPtrList = dlg.getSelecteds();
353 
354  if(dsPtrList.empty())
355  return;
356 
357  std::list<te::da::DataSourceInfoPtr>::iterator it = dsPtrList.begin();
358 
359  m_outDataSourceInfo = *it;
360 
361  m_ui->m_repositoryLineEdit->setText(QString(it->get()->getTitle().c_str()));
362 
363  m_isFile = false;
364 
365  m_ui->m_newLayerNameLineEdit->setEnabled(true);
366 }
367 
369 {
370  m_ui->m_newLayerNameLineEdit->clear();
371  m_ui->m_repositoryLineEdit->clear();
372 
373  if (m_ui->m_colsLineEdit->text().isEmpty())
374  onResXLineEditEditingFinished();
375 
376  if (m_ui->m_rowsLineEdit->text().isEmpty())
377  onResYLineEditEditingFinished();
378 
379  QString extension;
380 
381  std::string accessDriver;
382 
383  extension = tr("Shapefile (*.shp *.SHP);;");
384  accessDriver = "OGR";
385 
386  QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."),
387  QString(), extension, 0, QFileDialog::DontConfirmOverwrite);
388 
389  if (fileName.isEmpty())
390  return;
391 
392  boost::filesystem::path outfile(fileName.toStdString());
393  std::string aux = outfile.leaf().string();
394  m_ui->m_newLayerNameLineEdit->setText(aux.c_str());
395  aux = outfile.string();
396  m_ui->m_repositoryLineEdit->setText(aux.c_str());
397 
398  m_isFile = true;
399 
400  m_ui->m_newLayerNameLineEdit->setEnabled(false);
401 
402  std::map<std::string, std::string> connInfo;
403  connInfo["URI"] = m_ui->m_repositoryLineEdit->text().toStdString();
404 
405  m_outDataSourceInfo.reset(new te::da::DataSourceInfo);
406 
407  m_outDataSourceInfo->setAccessDriver(accessDriver);
408  m_outDataSourceInfo->setConnInfo(connInfo);
409 }
410 
412 {
413  std::string errors;
414  if(!checkList(errors))
415  {
416  QMessageBox::warning(this, tr("Cellular Spaces"), errors.c_str());
417  return;
418  }
419 
420  std::auto_ptr<te::cellspace::CellularSpacesOperations> cellSpaceOp(new te::cellspace::CellularSpacesOperations());
421 
423 
424  if(m_ui->m_polygonsRadioButton->isChecked())
425  {
427  }
428  else
429  {
431  }
432 
433  te::map::AbstractLayerPtr referenceLayer;
434  if (m_ui->m_maskRadioButton->isChecked())
435  referenceLayer = getReferenceLayer();
436 
437  m_outputDataSetName = m_ui->m_newLayerNameLineEdit->text().toStdString();
438 
439 
440  //progress
443 
444  try
445  {
446  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
447  cellSpaceOp->createCellSpace(m_outDataSourceInfo, m_outputDataSetName,
448  getResX(), getResY(), getEnvelope(), m_bbSRID,
449  type,
450  referenceLayer);
451  }
452  catch(te::common::Exception& e)
453  {
455  this->setCursor(Qt::ArrowCursor);
456  QMessageBox::warning(this, tr("Cellular Spaces"), e.what());
457  reject();
458  return;
459  }
460 
462  this->setCursor(Qt::ArrowCursor);
463 
464  accept();
465 }
466 
468 {
469  m_ui->m_unitComboBox->addItem("UNIT");
470 
473  while (it != itend)
474  {
475  te::common::UnitOfMeasurePtr uptr = it->second;
476  if (it->second->getType() == te::common::Length ||
477  it->second->getType() == te::common::Angle)
478  m_ui->m_unitComboBox->addItem(uptr->getName().c_str(), QVariant::fromValue(uptr));
479  ++it;
480  }
481 
482  if(m_bbSRID > 0)
483  {
485  if (unit.get())
486  setResolutionUnit(unit);
487  return;
488  }
489  m_ui->m_unitComboBox->setCurrentIndex(0);
490 }
491 
493 {
494  m_ui->m_llxLineEdit->setText(QString::number(env.m_llx,'f',precision));
495  m_ui->m_llyLineEdit->setText(QString::number(env.m_lly,'f',precision));
496  m_ui->m_urxLineEdit->setText(QString::number(env.m_urx,'f',precision));
497  m_ui->m_uryLineEdit->setText(QString::number(env.m_ury,'f',precision));
498 }
499 
501 {
502  if (!unit)
503  {
504  m_ui->m_unitComboBox->setCurrentIndex(0);
505  return;
506  }
507 
508  for(int i = 0; i < m_ui->m_unitComboBox->count(); ++i)
509  {
510  std::string name = m_ui->m_unitComboBox->itemText(i).toStdString();
511 
512  if(unit->getName() == name)
513  {
514  m_ui->m_unitComboBox->setCurrentIndex(i);
515  break;
516  }
517  }
518 }
519 
521 {
522  QVariant varUnit = m_ui->m_unitComboBox->itemData(m_ui->m_unitComboBox->currentIndex(), Qt::UserRole);
523  return varUnit.value<te::common::UnitOfMeasurePtr>();
524 }
525 
527 {
528  QVariant varLayer = m_ui->m_layersComboBox->itemData(m_ui->m_layersComboBox->currentIndex(), Qt::UserRole);
529  return varLayer.value<te::map::AbstractLayerPtr>();
530 }
531 
533 {
534  te::gm::Envelope env;
535  env.m_llx = m_ui->m_llxLineEdit->text().toDouble();
536  env.m_lly = m_ui->m_llyLineEdit->text().toDouble();
537  env.m_urx = m_ui->m_urxLineEdit->text().toDouble();
538  env.m_ury = m_ui->m_uryLineEdit->text().toDouble();
539 
540  return env;
541 }
542 
544 {
545  m_ui->m_llxLineEdit->clear();
546  m_ui->m_llyLineEdit->clear();
547  m_ui->m_urxLineEdit->clear();
548  m_ui->m_uryLineEdit->clear();
549 }
550 
551 
553 {
554  double resX = m_ui->m_resXLineEdit->text().toDouble();
555  if (m_bbSRID <=0) // if there is no output SRS defined
556  return resX; // no check to be done
557 
558  unitConvertion(resX, getResolutionUnit(), te::srs::SpatialReferenceSystemManager::getInstance().getUnit(m_bbSRID));
559 
560  return resX;
561 }
562 
564 {
565  double resY = m_ui->m_resYLineEdit->text().toDouble();
566  if (m_bbSRID <=0) // if there is no output SRS defined
567  return resY; // no check to be done
568 
569  unitConvertion(resY, getResolutionUnit(), te::srs::SpatialReferenceSystemManager::getInstance().getUnit(m_bbSRID));
570 
571  return resY;
572 }
573 
574 
578 {
579  // no need to convert
580  if(from == to)
581  return true;
582 
583  if (!from || !to)
584  return false;
585 
586  // check to see if conversion is possible
587  if (te::common::UnitsOfMeasureManager::getInstance().areConvertible(from->getName(), to->getName()))
588  {
589  try
590  {
591  double factor = te::common::UnitsOfMeasureManager::getInstance().getConversion(from->getName(),to->getName());
592  res *= factor;
593  return true;
594  }
595  catch(te::common::Exception& /*e*/)
596  {
597  return false;
598  }
599  }
600 
601  // try to handle the most common: degree <-> meters and its variations
602  if (from->getId() == te::common::UOM_Degree)
603  return (convertAngleToPlanar(res, to));
604 
605  if (to->getId() == te::common::UOM_Degree)
606  return (convertPlanarToAngle(res, from));
607 
608  return false;
609 }
610 
612 {
613  switch (planar->getId())
614  {
616  val *= 111000; // 1 degree = 111.000 meters
617  break;
619  val *= 111; // 1 degree = 111 kilometers
620  break;
622  val *= 364173.24; // 1 feet = 3.28084 meters
623  break;
624  default:
625  return false;
626  }
627  return true;
628 }
629 
631 {
632  switch (planar->getId())
633  {
635  val /= 111000; // 1 degree = 111.000 meters
636  break;
638  val /= 111; // 1 degree = 111 kilometers
639  break;
641  val /= 364173.24; // 1 feet = 3.28084 meters
642  break;
643  default:
644  return false;
645  }
646  return true;
647 }
648 
650 {
651  m_ui->m_resXLineEdit->clear();
652  m_ui->m_resYLineEdit->clear();
653  m_ui->m_colsLineEdit->clear();
654  m_ui->m_rowsLineEdit->clear();
655 }
656 
658 {
659  if (m_bbSRID > 0)
660  {
661  std::string name = te::srs::SpatialReferenceSystemManager::getInstance().getName(m_bbSRID);
662  m_ui->m_resSRIDLabel->setText(name.c_str());
663  }
664  else
665  {
666  m_ui->m_resSRIDLabel->setText("No SRS defined");
667  }
668 }
669 
671 {
672  bool noErrors = true;
673  errors = tr("Consistency errors:").toStdString();
674 
675  te::gm::Envelope env = getEnvelope();
676  if(!env.isValid())
677  {
678  errors += "\n - " + tr("Invalid bounding box").toStdString();
679  noErrors = false;
680  }
681 
682  double resX = getResX();
683  if (resX < 0. || resX >= env.getWidth())
684  {
685  char txt[40];
686  sprintf(txt,"%.8g",env.getWidth());
687  errors += "\n - " + tr("X resolution must be greater than 0 and smaller than the bounding box Width ").toStdString() + txt;
688  noErrors = false;
689  }
690 
691  double resY = getResY();
692  if (resY < 0. || resY >= env.getHeight())
693  {
694  char txt[40];
695  sprintf(txt,"%.8g",env.getHeight());
696  errors += "\n - " + tr("Y resolution must be greater than 0 and smaller than the bounding box Height ").toStdString() + txt;
697  noErrors = false;
698  }
699 
700  std::string name = m_ui->m_newLayerNameLineEdit->text().toStdString();
701  if (name.empty())
702  {
703  errors += "\n - " + tr("Output layer name is empty").toStdString();
704  noErrors = false;
705  }
706 
707  if (m_ui->m_maskRadioButton->isChecked())
708  {
709  te::map::AbstractLayerPtr referenceLayer = getReferenceLayer();
710  if (!((referenceLayer->getSRID() > 0 && m_bbSRID > 0) ||
711  (referenceLayer->getSRID() <= 0 && m_bbSRID <= 0)))
712  {
713  errors += "\n - " + tr("Reference layer and output layer have incompatible SRSs. It is not possible to create cells using polygons as masks.").toStdString();
714  noErrors = false;
715  }
716  }
717  return noErrors;
718 }
719 
const_iterator begin() const
It returns an iterator to the beginning of the conteiner.
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
This class provide cellular spaces operations.
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
virtual const char * what() const
It outputs the exception message.
Definition: Exception.cpp:58
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
const_iterator end() const
It returns an iterator to the end of the conteiner.
bool convertPlanarToAngle(double &val, te::common::UnitOfMeasurePtr planar)
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
void removeViewer(int viewerId)
Dettach a progress viewer.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
bool unitConvertion(double &res, te::common::UnitOfMeasurePtr from, te::common::UnitOfMeasurePtr to)
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
std::map< unsigned int, UnitOfMeasurePtr >::const_iterator const_iterator
double getConversion(const std::string &unitFromName, const std::string &unitToName) const
Calculates a multiplicative factor to convert from a given unit to its base unit and vice-versa...
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
void showEnvelope(const te::gm::Envelope &env, int precision)
A dialog for selecting a data source.
A class that represents a data source component.
A dialog used to build a SRSManagerDialog element.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
Definition: Envelope.cpp:92
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
const std::pair< int, std::string > & getSelectedSRS() const
Returns the selected SRS in the window.
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
std::auto_ptr< Ui::CreateCellularSpaceDialogForm > m_ui
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
bool convertAngleToPlanar(double &val, te::common::UnitOfMeasurePtr planar)
CreateCellularSpaceDialog(QWidget *parent=0, Qt::WindowFlags f=0)