27 #include "../../common/Logger.h"
28 #include "../../common/progress/ProgressManager.h"
29 #include "../../common/Translator.h"
30 #include "../../common/STLUtils.h"
31 #include "../../dataaccess/dataset/DataSet.h"
32 #include "../../dataaccess/utils/Utils.h"
33 #include "../../geometry/GeometryProperty.h"
34 #include "../core/GeostatisticalFunctions.h"
35 #include "../core/GeostatisticalMethodSemivariogram.h"
36 #include "../core/GeostatisticalModel.h"
37 #include "../core/GeostatisticalModelExponential.h"
38 #include "../core/GeostatisticalModelGaussian.h"
39 #include "../core/GeostatisticalModelSpherical.h"
40 #include "../core/Utils.h"
42 #include "../Exception.h"
44 #include "ui_GeostatisticalMethodsDialogForm.h"
47 #include <QGridLayout>
48 #include <QMessageBox>
52 #include <qwt_legend.h>
54 #include <qwt_symbol.h>
63 m_ui(new Ui::GeostatisticalMethodsDialogForm),
69 m_ui->m_nLagsLineEdit->setValidator(
new QIntValidator(
this));
70 m_ui->m_lagsIncrementLineEdit->setValidator(
new QDoubleValidator(
this));
71 m_ui->m_angleDirLineEdit->setValidator(
new QDoubleValidator(
this));
72 m_ui->m_angleTolLineEdit->setValidator(
new QDoubleValidator(
this));
74 m_ui->m_adjustGroupBox->setEnabled(
false);
75 m_ui->m_changeAttrToolButton->setEnabled(
false);
80 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"sa-measurespatialvar-hint").pixmap(112,48));
81 m_ui->m_changeAttrToolButton->setIcon(QIcon::fromTheme(
"view-refresh"));
87 connect(
m_ui->m_modelComboBox, SIGNAL(activated(
int)),
this, SLOT(
calculate()));
88 connect(
m_ui->m_nuggetHorizontalSlider, SIGNAL(sliderMoved(
int)),
this, SLOT(
calculate()));
89 connect(
m_ui->m_sillHorizontalSlider, SIGNAL(sliderMoved(
int)),
this, SLOT(
calculate()));
90 connect(
m_ui->m_rangeHorizontalSlider, SIGNAL(sliderMoved(
int)),
this, SLOT(
calculate()));
93 QGridLayout* chartLayout =
new QGridLayout(
m_ui->m_chartWidget);
104 m_scatterChartMethod->setSymbol(
new QwtSymbol( QwtSymbol::XCross, QBrush( Qt::red ), QPen( Qt::red, 3 ), QSize( 8, 8 )));
116 m_chartDisplay->insertLegend(
new QwtLegend(), QwtPlot::RightLegend);
119 m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins");
120 m_ui->m_helpPushButton->setPageReference(
"plugins/sa/sa_geostatisticalmethods.html");
127 m_methodMatrix.clear();
129 m_modelMatrix.clear();
134 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
136 while(it != layers.end())
142 std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
144 m_ui->m_inputLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
151 if(m_ui->m_inputLayerComboBox->count() > 0)
152 onInputLayerComboBoxActivated(0);
157 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
161 std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
163 std::vector<te::dt::Property*> propVec = dsType->getProperties();
165 m_ui->m_attributeComboBox->clear();
167 for(std::size_t t = 0; t < propVec.size(); ++t)
169 int dataType = propVec[t]->getType();
176 m_ui->m_attributeComboBox->addItem(propVec[t]->getName().c_str(), dataType);
181 std::auto_ptr<te::da::DataSet> ds = l->getData();
182 double lagIncrement = l->getExtent().getWidth() / ds->size();
184 QString strLagIncrement;
185 strLagIncrement.setNum(lagIncrement);
187 m_ui->m_lagsIncrementLineEdit->setText(strLagIncrement);
193 m_ui->m_adjustGroupBox->setEnabled(
false);
194 m_ui->m_changeAttrToolButton->setEnabled(
false);
197 if(m_ui->m_nLagsLineEdit->text().isEmpty())
199 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Number of lags not defined."));
203 if(m_ui->m_lagsIncrementLineEdit->text().isEmpty())
205 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Lag increment not defined."));
209 if(m_ui->m_angleDirLineEdit->text().isEmpty())
211 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Angular direction not defined."));
215 if(m_ui->m_angleTolLineEdit->text().isEmpty())
217 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Angular tolerance not defined."));
222 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
226 std::auto_ptr<te::da::DataSet> dataSet = l->getData();
227 std::auto_ptr<te::da::DataSetType> dataSetType = l->getSchema();
230 std::string attrName = m_ui->m_attributeComboBox->currentText().toStdString();
239 int typeIdx = m_ui->m_typeComboBox->currentIndex();
253 m_method->setNumberOfLags((std::size_t)m_ui->m_nLagsLineEdit->text().toInt());
254 m_method->setLagIncrement(m_ui->m_lagsIncrementLineEdit->text().toDouble());
255 m_method->setAngleDirection(m_ui->m_angleDirLineEdit->text().toDouble());
256 m_method->setAngleTolerance(m_ui->m_angleTolLineEdit->text().toDouble());
261 double variance = 0.;
266 resetAdjustParameters(mean, variance);
272 m_ui->m_adjustGroupBox->setEnabled(
true);
273 m_ui->m_changeAttrToolButton->setEnabled(
true);
279 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
283 std::auto_ptr<te::da::DataSet> dataSet = l->getData();
286 std::string attrName = m_ui->m_attributeComboBox->currentText().toStdString();
293 double variance = 0.;
298 resetAdjustParameters(mean, variance);
307 int modelIdx = m_ui->m_modelComboBox->currentIndex();
319 model->
setNugget((
double)m_ui->m_nuggetHorizontalSlider->value());
320 model->
setSill((
double)m_ui->m_sillHorizontalSlider->value());
321 model->
setRange((
double)m_ui->m_rangeHorizontalSlider->value());
324 m_methodMatrix = m_method->calculate();
325 m_modelMatrix = model->
calculate(m_methodMatrix);
336 m_ui->m_typeComboBox->clear();
341 m_ui->m_modelComboBox->clear();
352 double max = variance;
353 double nuggetVar = (max - min)/mean;
355 m_ui->m_nuggetHorizontalSlider->setRange(min - nuggetVar, max + nuggetVar);
356 m_ui->m_nuggetHorizontalSlider->setValue(min);
357 m_ui->m_nuggetLabel->setNum(min);
361 max = max + variance;
362 double sillVar = (max - min)/mean;
364 m_ui->m_sillHorizontalSlider->setRange(min - sillVar, max + sillVar);
365 m_ui->m_sillHorizontalSlider->setValue(min);
366 m_ui->m_sillLabel->setNum(min);
369 double rangeVar = m_ui->m_nLagsLineEdit->text().toDouble();
370 min = m_ui->m_lagsIncrementLineEdit->text().toDouble();
371 max = min * rangeVar;
373 m_ui->m_rangeHorizontalSlider->setRange(min - rangeVar, max + rangeVar);
374 m_ui->m_rangeHorizontalSlider->setValue(min);
375 m_ui->m_rangeLabel->setNum(min);
380 m_chartDisplay->setTitle(m_ui->m_typeComboBox->currentText());
383 std::vector<double> methodh;
384 std::vector<double> methodyh;
386 for(std::size_t t = 1; t < m_methodMatrix.size1(); ++t)
388 methodh.push_back(m_methodMatrix(t, 0));
389 methodyh.push_back(m_methodMatrix(t, 1));
392 m_scatterMethod->setXValues(methodh);
393 m_scatterMethod->setYValues(methodyh);
394 m_scatterMethod->calculateMinMaxValues();
395 m_scatterChartMethod->setData();
398 std::vector<double> modelh;
399 std::vector<double> modelyh;
401 for(std::size_t t = 0; t < m_modelMatrix.size1(); ++t)
403 modelh.push_back(m_modelMatrix(t, 0));
404 modelyh.push_back(m_modelMatrix(t, 1));
407 m_scatterModel->setXValues(modelh);
408 m_scatterModel->setYValues(modelyh);
409 m_scatterModel->calculateMinMaxValues();
410 m_scatterChartModel->setData();
413 m_chartDisplay->replot();
void setSill(double value)
Function to set the sill value.
Class that represents the geostatistical exponential model.
te::qt::widgets::ScatterChart * m_scatterChartModel
void onApplyPushButtonClicked()
Class that represents the geostatistical spherical model.
The empirical variogram cannot be computed at every lag distance h and due to variation in the estima...
te::qt::widgets::Scatter * m_scatterMethod
void onInputLayerComboBoxActivated(int index)
te::qt::widgets::Scatter * m_scatterModel
te::qt::widgets::ChartDisplay * m_chartDisplay
TESAEXPORT void SetMainDiagonal(boost::numeric::ublas::matrix< double > &matrix, te::da::DataSet *dataSet, int attrIdx)
Function used to set new values in the matrix main diagonal.
TEDATAACCESSEXPORT int GetPropertyIndex(te::da::DataSet *dataSet, const std::string propName)
std::auto_ptr< Ui::GeostatisticalMethodsDialogForm > m_ui
TESAEXPORT boost::numeric::ublas::matrix< double > CreateMatrixFromDataSet(te::da::DataSet *dataSet, int attrIdx, int geomIdx)
Function used to create a matrix with values, distance and angle for each element from dataset...
Class that represents the geostatistical gaussian model.
TESAEXPORT void CalculateMoments(const boost::numeric::ublas::matrix< double > &matrix, double &mean, double &variance)
Function used to calculate mean and variance from a matrix.
void onChangeAttrToolButtonClicked()
Semivariogram is a function describing the degree of spatial dependence of a spatial random field...
A dialog with geostatistical methods to measure the spatial variability of attribute of a dataset...
virtual boost::numeric::ublas::matrix< double > calculate(boost::numeric::ublas::matrix< double > matrix)=0
Function to calculate the geostatistical information from model.
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
GeostatisticalModelType
Geostatistical models for measure of Spatial Variability.
~GeostatisticalMethodsDialog()
GeostatisticalMethodType
Geostatistical methods for measure of Spatial Variability.
GeostatisticalMethodsDialog(QWidget *parent=0, Qt::WindowFlags f=0)
void resetAdjustParameters(double mean, double variance)
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void setNugget(double value)
Function to set the nugget value.
void setRange(double value)
Function to set the range value.
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
te::qt::widgets::ScatterChart * m_scatterChartMethod