27 #include "../../common/Logger.h" 
   28 #include "../../common/progress/ProgressManager.h" 
   29 #include "../../common/Translator.h" 
   30 #include "../../common/STLUtils.h" 
   31 #include "../../dataaccess/datasource/DataSource.h" 
   32 #include "../../dataaccess/utils/Utils.h" 
   33 #include "../../maptools/DataSetLayer.h" 
   34 #include "../../qt/widgets/progress/ProgressViewerDialog.h" 
   35 #include "../core/KernelMapOperation.h" 
   36 #include "../Exception.h" 
   39 #include "ui_KernelMapDialogForm.h" 
   42 #include <QFileDialog> 
   44 #include <QMessageBox> 
   51 #include <boost/algorithm/string.hpp> 
   52 #include <boost/filesystem.hpp> 
   53 #include <boost/uuid/random_generator.hpp> 
   54 #include <boost/uuid/uuid_io.hpp> 
   60     m_ui(new Ui::KernelMapDialogForm)
 
   65   m_ui->m_nColsLineEdit->setValidator(
new QIntValidator(
this));
 
   70   m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"sa-kernelmap-hint").pixmap(112,48));
 
   78   m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins"); 
 
   79   m_ui->m_helpPushButton->setPageReference(
"plugins/sa/sa_kernelmap.html");
 
   88   std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
 
   90   while(it != layers.end())
 
   96       std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  100       if(dsLayer && dsType->hasGeom())
 
  101         m_ui->m_inputLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
 
  108   if(m_ui->m_inputLayerComboBox->count() > 0)
 
  109     onInputLayerComboBoxActivated(0);
 
  114   return m_outputLayer;
 
  120   m_ui->m_functionComboBox->clear();
 
  122   m_ui->m_functionComboBox->addItem(
"Quartic", QVariant(
te::sa::Quartic));
 
  123   m_ui->m_functionComboBox->addItem(
"Normal", QVariant(
te::sa::Normal));
 
  125   m_ui->m_functionComboBox->addItem(
"Uniform", QVariant(
te::sa::Uniform));
 
  129   m_ui->m_estimationComboBox->clear();
 
  131   m_ui->m_estimationComboBox->addItem(
"Density", QVariant(
te::sa::Density));
 
  138   QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
 
  142   std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  144   std::vector<te::dt::Property*> propVec = dsType->getProperties();
 
  146   m_ui->m_attrLayerComboBox->clear();
 
  148   for(std::size_t t = 0; t < propVec.size(); ++t)
 
  150     int dataType = propVec[t]->getType();
 
  157       m_ui->m_attrLayerComboBox->addItem(propVec[t]->getName().c_str(), dataType);
 
  166   if(m_ui->m_repositoryLineEdit->text().isEmpty())
 
  168     QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a repository for the result."));
 
  172   if(m_ui->m_newLayerNameLineEdit->text().isEmpty())
 
  174     QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a name for the resulting layer."));
 
  179   QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
 
  185   kInParams->m_functionType = (
te::sa::KernelFunctionType) m_ui->m_functionComboBox->itemData(m_ui->m_functionComboBox->currentIndex()).toInt();
 
  186   kInParams->m_estimationType = (
te::sa::KernelEstimationType) m_ui->m_estimationComboBox->itemData(m_ui->m_estimationComboBox->currentIndex()).toInt();
 
  188   kInParams->m_useAdaptativeRadius = m_ui->m_useAdaptRadiusCheckBox->isChecked();
 
  190   if(!m_ui->m_useAdaptRadiusCheckBox->isChecked())
 
  192     kInParams->m_radiusPercentValue = m_ui->m_radiusSpinBox->value();
 
  195   if(m_ui->m_useAttrLayerCheckBox->isChecked())
 
  197     kInParams->m_intensityAttrName = m_ui->m_attrLayerComboBox->currentText().toStdString();
 
  200   kInParams->m_ds = l->getData();
 
  201   kInParams->m_dsType = l->getSchema();
 
  206   kOutParams->
m_outputPath = m_ui->m_repositoryLineEdit->text().toStdString();
 
  209   if(m_ui->m_gridRadioButton->isChecked())
 
  211     if(m_ui->m_nColsLineEdit->text().isEmpty())
 
  213       QMessageBox::information(
this, tr(
"Warning"), tr(
"Define the number of columns to the output grid."));
 
  218     kOutParams->
m_nCols = m_ui->m_nColsLineEdit->text().toInt();
 
  220   else if(m_ui->m_attrRadioButton->isChecked())
 
  222     if(m_ui->m_attrNameLineEdit->text().isEmpty())
 
  224       QMessageBox::information(
this, tr(
"Warning"), tr(
"Define the attribute name to the output data."));
 
  229     kOutParams->
m_outputAttrName = m_ui->m_attrNameLineEdit->text().toStdString();
 
  236   QApplication::setOverrideCursor(Qt::WaitCursor);
 
  248   catch(
const std::exception& e)
 
  250     QMessageBox::warning(
this, tr(
"Warning"), e.what());
 
  252     QApplication::restoreOverrideCursor();
 
  260     QMessageBox::warning(
this, tr(
"Warning"), tr(
"Kernel Map internal error."));
 
  262     QApplication::restoreOverrideCursor();
 
  269   QApplication::restoreOverrideCursor();
 
  276   std::string dataSetName = 
"";
 
  278   if(m_ui->m_gridRadioButton->isChecked())
 
  280     outputDataSource = 
te::sa::CreateGDALDataSource(m_ui->m_repositoryLineEdit->text().toStdString(), m_ui->m_newLayerNameLineEdit->text().toStdString());
 
  282     dataSetName = m_ui->m_newLayerNameLineEdit->text().toStdString() + 
".tif";
 
  284   else if(m_ui->m_attrRadioButton->isChecked())
 
  286     outputDataSource = 
te::sa::CreateOGRDataSource(m_ui->m_repositoryLineEdit->text().toStdString(), m_ui->m_newLayerNameLineEdit->text().toStdString());
 
  288     dataSetName = m_ui->m_newLayerNameLineEdit->text().toStdString();
 
  295   if(m_ui->m_gridRadioButton->isChecked())
 
  299   else if(m_ui->m_attrRadioButton->isChecked())
 
  309   m_ui->m_newLayerNameLineEdit->clear();
 
  310   m_ui->m_repositoryLineEdit->clear();
 
  312   QString fileName = QFileDialog::getExistingDirectory(
this, tr(
"Set output location..."));
 
  314   if (fileName.isEmpty())
 
  317   m_ui->m_repositoryLineEdit->setText(fileName);
 
Utility functions for the data access module. 
 
TESAEXPORT void CreateKernelColorMaping(te::map::AbstractLayerPtr layer)
 
boost::shared_ptr< DataSource > DataSourcePtr
 
TESAEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
 
std::auto_ptr< Ui::KernelMapDialogForm > m_ui
 
te::sa::KernelOutputType m_storageType
Kernel storage type. 
 
Class used to calculate the kernel map of a dataset. 
 
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used. 
 
KernelMapDialog(QWidget *parent=0, Qt::WindowFlags f=0)
 
TESAEXPORT te::da::DataSourcePtr CreateGDALDataSource(std::string path, std::string dataSetName)
 
Class that represents the kernel output parameters. 
 
void onOkPushButtonClicked()
 
void setOutputParameters(te::sa::KernelOutputParams *outParams)
 
void onInputLayerComboBoxActivated(int index)
 
te::map::AbstractLayerPtr getOutputLayer()
 
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
 
void removeViewer(int viewerId)
Dettach a progress viewer. 
 
static ProgressManager & getInstance()
It returns a reference to the singleton instance. 
 
std::string m_outputAttrName
Attribute with the new attr name (if KernelOutputType is Attribute) 
 
void fillKernelParameters()
 
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer. 
 
std::string m_outputPath
Attribute with URI of the output file. 
 
virtual void execute()
Function to execute the kernel operation. 
 
TESAEXPORT te::map::AbstractLayerPtr CreateLayer(te::da::DataSourcePtr ds, std::string dataSetName)
 
std::string m_outputDataSetName
Attribute that defines the output dataset name. 
 
void onTargetFileToolButtonPressed()
 
A layer with reference to a dataset. 
 
TESAEXPORT void CreateKernelGrouping(te::map::AbstractLayerPtr layer, std::string kernelAttr)
 
A dialog to calculate the kernel map of a dataset. 
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
int m_nCols
Attribute with number of columns to create the grid (if KernelOutputType is Grid) ...
 
void setInputParameters(te::sa::KernelInputParams *inParams)