27 #include "../../core/logger/Logger.h" 28 #include "../../common/progress/ProgressManager.h" 29 #include "../../core/translator/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> 61 te::sa::GeostatisticalMethodsDialog::GeostatisticalMethodsDialog(
QWidget* parent, Qt::WindowFlags f)
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"));
84 connect(m_ui->m_inputLayerComboBox, SIGNAL(activated(
int)),
this, SLOT(onInputLayerComboBoxActivated(
int)));
85 connect(m_ui->m_changeAttrToolButton, SIGNAL(clicked()),
this, SLOT(onChangeAttrToolButtonClicked()));
86 connect(m_ui->m_applyPushButton, SIGNAL(clicked()),
this, SLOT(onApplyPushButtonClicked()));
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);
95 chartLayout->addWidget(m_chartDisplay);
98 m_chartDisplay->setAxisTitle(QwtPlot::xBottom, tr(
"h"));
99 m_chartDisplay->setAxisTitle(QwtPlot::yLeft, tr(
"Y(h)"));
104 m_scatterChartMethod->setSymbol(
new QwtSymbol( QwtSymbol::XCross, QBrush( Qt::red ), QPen( Qt::red, 3 ), QSize( 8, 8 )));
105 m_scatterChartMethod->attach(m_chartDisplay);
106 m_scatterChartMethod->setTitle(tr(
"Data"));
110 m_scatterChartModel->setPen(Qt::blue);
111 m_scatterChartModel->setSymbol(
nullptr);
112 m_scatterChartModel->setStyle(QwtPlotCurve::Lines);
113 m_scatterChartModel->attach(m_chartDisplay);
114 m_scatterChartModel->setTitle(tr(
"Model"));
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");
134 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
136 while(it != layers.end())
142 std::unique_ptr<te::da::DataSetType> dsType = l->getSchema();
144 if (dsType->hasGeom())
145 m_ui->m_inputLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
152 if(
m_ui->m_inputLayerComboBox->count() > 0)
158 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
162 std::unique_ptr<te::da::DataSetType> dsType = l->getSchema();
164 std::vector<te::dt::Property*> propVec = dsType->getProperties();
166 m_ui->m_attributeComboBox->clear();
168 for(std::size_t t = 0; t < propVec.size(); ++t)
170 int dataType = propVec[t]->getType();
177 m_ui->m_attributeComboBox->addItem(propVec[t]->getName().c_str(), dataType);
182 std::unique_ptr<te::da::DataSet>
ds = l->getData();
183 double lagIncrement = l->getExtent().getWidth() / ds->size();
185 QString strLagIncrement;
186 strLagIncrement.setNum(lagIncrement);
188 m_ui->m_lagsIncrementLineEdit->setText(strLagIncrement);
194 m_ui->m_adjustGroupBox->setEnabled(
false);
195 m_ui->m_changeAttrToolButton->setEnabled(
false);
198 if(
m_ui->m_nLagsLineEdit->text().isEmpty())
200 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Number of lags not defined."));
204 if(
m_ui->m_lagsIncrementLineEdit->text().isEmpty())
206 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Lag increment not defined."));
210 if(
m_ui->m_angleDirLineEdit->text().isEmpty())
212 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Angular direction not defined."));
216 if(
m_ui->m_angleTolLineEdit->text().isEmpty())
218 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Angular tolerance not defined."));
223 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(
m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
227 std::unique_ptr<te::da::DataSet> dataSet = l->getData();
228 std::unique_ptr<te::da::DataSetType> dataSetType = l->getSchema();
231 std::string attrName =
m_ui->m_attributeComboBox->currentText().toUtf8().data();
240 int typeIdx =
m_ui->m_typeComboBox->currentIndex();
254 m_method->setNumberOfLags((std::size_t)
m_ui->m_nLagsLineEdit->text().toInt());
255 m_method->setLagIncrement(
m_ui->m_lagsIncrementLineEdit->text().toDouble());
256 m_method->setAngleDirection(
m_ui->m_angleDirLineEdit->text().toDouble());
257 m_method->setAngleTolerance(
m_ui->m_angleTolLineEdit->text().toDouble());
262 double variance = 0.;
273 m_ui->m_adjustGroupBox->setEnabled(
true);
274 m_ui->m_changeAttrToolButton->setEnabled(
true);
280 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(
m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
284 std::unique_ptr<te::da::DataSet> dataSet = l->getData();
287 std::string attrName =
m_ui->m_attributeComboBox->currentText().toUtf8().data();
294 double variance = 0.;
308 int modelIdx =
m_ui->m_modelComboBox->currentIndex();
320 model->
setNugget((
double)
m_ui->m_nuggetHorizontalSlider->value());
321 model->
setSill((
double)
m_ui->m_sillHorizontalSlider->value());
322 model->
setRange((
double)
m_ui->m_rangeHorizontalSlider->value());
337 m_ui->m_typeComboBox->clear();
342 m_ui->m_modelComboBox->clear();
353 double max = variance;
354 double nuggetVar = (max - min)/mean;
356 m_ui->m_nuggetHorizontalSlider->setRange(min - nuggetVar, max + nuggetVar);
357 m_ui->m_nuggetHorizontalSlider->setValue(min);
358 m_ui->m_nuggetLabel->setNum(min);
362 max = max + variance;
363 double sillVar = (max - min)/mean;
365 m_ui->m_sillHorizontalSlider->setRange(min - sillVar, max + sillVar);
366 m_ui->m_sillHorizontalSlider->setValue(min);
367 m_ui->m_sillLabel->setNum(min);
370 double rangeVar =
m_ui->m_nLagsLineEdit->text().toDouble();
371 min =
m_ui->m_lagsIncrementLineEdit->text().toDouble();
372 max = min * rangeVar;
374 m_ui->m_rangeHorizontalSlider->setRange(min - rangeVar, max + rangeVar);
375 m_ui->m_rangeHorizontalSlider->setValue(min);
376 m_ui->m_rangeLabel->setNum(min);
384 std::vector<double> methodh;
385 std::vector<double> methodyh;
399 std::vector<double> modelh;
400 std::vector<double> modelyh;
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)
static te::dt::Date ds(2010, 01, 01)
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)
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.
boost::numeric::ublas::matrix< double > m_modelMatrix
void onChangeAttrToolButtonClicked()
te::sa::GeostatisticalMethod * m_method
boost::numeric::ublas::matrix< double > m_methodMatrix
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.
virtual boost::numeric::ublas::matrix< double > calculate()=0
Function to calculate the geostatistical information.
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
boost::numeric::ublas::matrix< double > & getMatrix()
Function to get the input matrix with data information.
GeostatisticalModelType
Geostatistical models for measure of Spatial Variability.
~GeostatisticalMethodsDialog()
std::unique_ptr< Ui::GeostatisticalMethodsDialogForm > m_ui
GeostatisticalMethodType
Geostatistical methods for measure of Spatial Variability.
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
te::qt::widgets::ScatterChart * m_scatterChartMethod