Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ add_subdirectory("./Validity")
qt5_wrap_ui(FORMS_H ${FORMS})

if(WIN32)
add_executable(GWmodelS WIN32 ${SOURCES} ${HEADERS} ${FORMS_H} ${app_WINRC} ${GWMODEL_ICONS})
add_executable(GWmodelS WIN32 ${SOURCES} ${HEADERS} ${FORMS_H} ${app_WINRC} ${GWMODEL_ICONS}
)
endif(WIN32)

if(UNIX AND NOT CYGWIN)
Expand Down Expand Up @@ -273,4 +274,4 @@ target_link_libraries(GWmodelS
PRIVATE
${GWMODELCUDA_LIBRARIES}
)
endif(ENABLE_CUDA)
endif(ENABLE_CUDA)
32 changes: 24 additions & 8 deletions src/Model/gwmlayerbasicgwritem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gwmlayerbasicgwritem.h"
#include "gwmlayerbasicgwritem.h"
#include "gwmlayergroupitem.h"
#include "TaskThread/gwmbasicgwralgorithm.h"

Expand All @@ -10,8 +10,9 @@ GwmLayerBasicGWRItem::GwmLayerBasicGWRItem(GwmLayerItem* parent, QgsVectorLayer*
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = GwmBandwidthWeight(*static_cast<GwmBandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mDiagnostic = taskThread->diagnostic();
mDiagnostic0 = taskThread->diagnostic0();
mBetas = mat(taskThread->betas());
mModelSelModels = taskThread->indepVarSelectorCriterions();
isBandwidthOptimized = taskThread->autoselectBandwidth();
Expand Down Expand Up @@ -88,8 +89,15 @@ bool GwmLayerBasicGWRItem::readXml(QDomNode &node)
{
double bandwidth = weightNode.attribute("bandwidth").toDouble();
bool adaptive = weightNode.attribute("adaptive").toInt();
GwmBandwidthWeight::KernelFunctionType kernel = GwmBandwidthWeight::KernelFunctionTypeNameMapper.value(weightNode.attribute("kernel"));
mWeight = GwmBandwidthWeight(bandwidth, adaptive, kernel);
auto it = std::find_if(
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.begin(),
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.end(),
[&](const auto& kv){ return kv.second == weightNode.attribute("kernel").toStdString(); }
);
gwm::BandwidthWeight::KernelFunctionType kernel =
it != gwm::BandwidthWeight::KernelFunctionTypeNameMapper.end() ? it->first : gwm::BandwidthWeight::Gaussian;

mWeight = gwm::BandwidthWeight(bandwidth, adaptive, kernel);
}
else return false;

Expand Down Expand Up @@ -214,7 +222,7 @@ bool GwmLayerBasicGWRItem::readXml(QDomNode &node)
{
double size = bandwidthNode.attribute("size").toDouble();
double criterion = bandwidthNode.attribute("criterion").toDouble();
mBandwidthSelScores.append(qMakePair(size, criterion));
mBandwidthSelScores.push_back(std::make_pair(size, criterion));
}
bandwidthNode = bandwidthNode.nextSiblingElement("bandwidth");
}
Expand Down Expand Up @@ -331,7 +339,10 @@ bool GwmLayerBasicGWRItem::writeXml(QDomNode &node, QDomDocument &doc)
nodeAnalyse.appendChild(nodeIndepVarList);

QDomElement nodeBandwidth = doc.createElement("weight");
nodeBandwidth.setAttribute("kernel", GwmBandwidthWeight::KernelFunctionTypeNameMapper.name(mWeight.kernel()));
nodeBandwidth.setAttribute(
"kernel",
QString::fromStdString(gwm::BandwidthWeight::KernelFunctionTypeNameMapper.at(mWeight.kernel()))
);
nodeBandwidth.setAttribute("bandwidth", mWeight.bandwidth());
nodeBandwidth.setAttribute("adaptive", mWeight.adaptive());
nodeAnalyse.appendChild(nodeBandwidth);
Expand Down Expand Up @@ -463,6 +474,11 @@ GwmDiagnostic GwmLayerBasicGWRItem::diagnostic() const
return mDiagnostic;
}

gwm::RegressionDiagnostic GwmLayerBasicGWRItem::diagnostic0() const
{
return mDiagnostic0;
}

arma::mat GwmLayerBasicGWRItem::betas() const
{
return mBetas;
Expand Down Expand Up @@ -523,12 +539,12 @@ QList<QPair<QList<GwmVariable>, double> > GwmLayerBasicGWRItem::modelSelModels()
return mModelSelModels;
}

QList<QPair<double, double> > GwmLayerBasicGWRItem::bandwidthSelScores() const
gwm::BandwidthCriterionList GwmLayerBasicGWRItem::bandwidthSelScores() const
{
return mBandwidthSelScores;
}

GwmBandwidthWeight GwmLayerBasicGWRItem::weight() const
gwm::BandwidthWeight GwmLayerBasicGWRItem::weight() const
{
return mWeight;
}
13 changes: 8 additions & 5 deletions src/Model/gwmlayerbasicgwritem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef GWMLAYERBASICGWRITEM_H
#ifndef GWMLAYERBASICGWRITEM_H
#define GWMLAYERBASICGWRITEM_H

#include "prefix.h"
Expand Down Expand Up @@ -27,6 +27,8 @@ class GwmLayerBasicGWRItem : public GwmLayerVectorItem

GwmDiagnostic diagnostic() const;

gwm::RegressionDiagnostic diagnostic0() const;

arma::mat betas() const;

bool modelOptimized() const;
Expand All @@ -49,21 +51,22 @@ class GwmLayerBasicGWRItem : public GwmLayerVectorItem

QList<QPair<QList<GwmVariable>, double> > modelSelModels() const;

QList<QPair<double, double> > bandwidthSelScores() const;
gwm::BandwidthCriterionList bandwidthSelScores() const;

GwmBandwidthWeight weight() const;
gwm::BandwidthWeight weight() const;

GwmBasicGWRAlgorithm::OLSVar OLSResults() const;

protected:
int mDataPointsSize;
GwmVariable mDepVar;
QList<GwmVariable> mIndepVars;
GwmBandwidthWeight mWeight;
gwm::BandwidthWeight mWeight;
GwmDiagnostic mDiagnostic;
gwm::RegressionDiagnostic mDiagnostic0;
arma::mat mBetas;
QList<QPair<QList<GwmVariable>, double> > mModelSelModels;
QList<QPair<double, double> > mBandwidthSelScores;
BandwidthCriterionList mBandwidthSelScores;
GwmBasicGWRAlgorithm::FTestResultPack mFTestResults;
GwmBasicGWRAlgorithm::OLSVar mOLSVar;
bool isRegressionPointGiven;
Expand Down
25 changes: 17 additions & 8 deletions src/Model/gwmlayercollinearitygwritem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gwmlayercollinearitygwritem.h"
#include "gwmlayercollinearitygwritem.h"
#include "gwmlayergroupitem.h"

GwmLayerCollinearityGWRItem::GwmLayerCollinearityGWRItem(GwmLayerItem* parent, QgsVectorLayer* vector, const GwmLocalCollinearityGWRAlgorithm* taskThread)
Expand All @@ -9,7 +9,7 @@ GwmLayerCollinearityGWRItem::GwmLayerCollinearityGWRItem(GwmLayerItem* parent, Q
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = GwmBandwidthWeight(*static_cast<GwmBandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mDiagnostic = taskThread->dialnostic();
mBetas = mat(taskThread->betas());
//mModelSelModels = taskThread->indepVarSelectorCriterions();
Expand Down Expand Up @@ -88,8 +88,14 @@ bool GwmLayerCollinearityGWRItem::readXml(QDomNode &node)
{
double bandwidth = weightNode.attribute("bandwidth").toDouble();
bool adaptive = weightNode.attribute("adaptive").toInt();
GwmBandwidthWeight::KernelFunctionType kernel = GwmBandwidthWeight::KernelFunctionTypeNameMapper.value(weightNode.attribute("kernel"));
mWeight = GwmBandwidthWeight(bandwidth, adaptive, kernel);
auto it = std::find_if(
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.begin(),
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.end(),
[&](const auto& kv){ return kv.second == weightNode.attribute("kernel").toStdString(); }
);
gwm::BandwidthWeight::KernelFunctionType kernel =
it != gwm::BandwidthWeight::KernelFunctionTypeNameMapper.end() ? it->first : gwm::BandwidthWeight::Gaussian;
mWeight = gwm::BandwidthWeight(bandwidth, adaptive, kernel);
}
else return false;

Expand Down Expand Up @@ -142,7 +148,7 @@ bool GwmLayerCollinearityGWRItem::readXml(QDomNode &node)
{
double size = bandwidthNode.attribute("size").toDouble();
double criterion = bandwidthNode.attribute("criterion").toDouble();
mBandwidthSelScores.append(qMakePair(size, criterion));
mBandwidthSelScores.push_back(std::make_pair(size, criterion));
}
bandwidthNode = bandwidthNode.nextSiblingElement("bandwidth");
}
Expand Down Expand Up @@ -190,7 +196,10 @@ bool GwmLayerCollinearityGWRItem::writeXml(QDomNode &node, QDomDocument &doc)
nodeAnalyse.appendChild(nodeIndepVarList);

QDomElement nodeBandwidth = doc.createElement("weight");
nodeBandwidth.setAttribute("kernel", GwmBandwidthWeight::KernelFunctionTypeNameMapper.name(mWeight.kernel()));
nodeBandwidth.setAttribute(
"kernel",
QString::fromStdString(gwm::BandwidthWeight::KernelFunctionTypeNameMapper.at(mWeight.kernel()))
);
nodeBandwidth.setAttribute("bandwidth", mWeight.bandwidth());
nodeBandwidth.setAttribute("adaptive", mWeight.adaptive());
nodeAnalyse.appendChild(nodeBandwidth);
Expand Down Expand Up @@ -241,7 +250,7 @@ QList<GwmVariable> GwmLayerCollinearityGWRItem::indepVars() const
return mIndepVars;
}

GwmBandwidthWeight GwmLayerCollinearityGWRItem::weight() const
gwm::BandwidthWeight GwmLayerCollinearityGWRItem::weight() const
{
return mWeight;
}
Expand All @@ -256,7 +265,7 @@ arma::mat GwmLayerCollinearityGWRItem::betas() const
return mBetas;
}

QList<QPair<double, double> > GwmLayerCollinearityGWRItem::bandwidthSelScores() const
BandwidthCriterionList GwmLayerCollinearityGWRItem::bandwidthSelScores() const
{
return mBandwidthSelScores;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Model/gwmlayercollinearitygwritem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef GWMLAYERCOLLINEARUTYGWRITEM_H
#ifndef GWMLAYERCOLLINEARUTYGWRITEM_H
#define GWMLAYERCOLLINEARUTYGWRITEM_H

#include "prefix.h"
Expand Down Expand Up @@ -30,13 +30,13 @@ class GwmLayerCollinearityGWRItem : public GwmLayerVectorItem

QList<GwmVariable> indepVars() const;

GwmBandwidthWeight weight() const;
gwm::BandwidthWeight weight() const;

GwmDiagnostic diagnostic() const;

arma::mat betas() const;

QList<QPair<double, double> > bandwidthSelScores() const;
BandwidthCriterionList bandwidthSelScores() const;

bool getIsRegressionPointGiven() const;

Expand All @@ -54,11 +54,11 @@ class GwmLayerCollinearityGWRItem : public GwmLayerVectorItem
int mDataPointsSize;
GwmVariable mDepVar;
QList<GwmVariable> mIndepVars;
GwmBandwidthWeight mWeight;
gwm::BandwidthWeight mWeight;
GwmDiagnostic mDiagnostic;
arma::mat mBetas;
//QList<QPair<QList<GwmVariable>, double> > mModelSelModels;
QList<QPair<double, double> > mBandwidthSelScores;
BandwidthCriterionList mBandwidthSelScores;
//GwmBasicGWRAlgorithm::FTestResultPack mFTestResults;

bool isRegressionPointGiven;
Expand Down
4 changes: 2 additions & 2 deletions src/Model/gwmlayerggwritem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gwmlayerggwritem.h"
#include "gwmlayerggwritem.h"

GwmLayerGGWRItem::GwmLayerGGWRItem(GwmLayerItem* parent, QgsVectorLayer* vector, const GwmGeneralizedGWRAlgorithm* taskThread)
:GwmLayerBasicGWRItem(parent,vector)
Expand All @@ -8,7 +8,7 @@ GwmLayerGGWRItem::GwmLayerGGWRItem(GwmLayerItem* parent, QgsVectorLayer* vector,
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = GwmBandwidthWeight(*static_cast<GwmBandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mBetas = mat(taskThread->betas());
isBandwidthOptimized = taskThread->autoselectBandwidth();
mBandwidthSelScores = taskThread->bandwidthSelectorCriterions();
Expand Down
6 changes: 3 additions & 3 deletions src/Model/gwmlayergtwritem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gwmlayergtwritem.h"
#include "gwmlayergtwritem.h"
#include "gwmlayergroupitem.h"

GwmLayerGTWRItem::GwmLayerGTWRItem(GwmLayerItem* parent, QgsVectorLayer* vector, const GwmGTWRAlgorithm *taskThread)
Expand Down Expand Up @@ -129,7 +129,7 @@ bool GwmLayerGTWRItem::readXml(QDomNode &node)
{
double size = bandwidthNode.attribute("size").toDouble();
double criterion = bandwidthNode.attribute("criterion").toDouble();
mBandwidthSelScores.append(qMakePair(size, criterion));
mBandwidthSelScores.push_back(std::make_pair(size, criterion));
}
bandwidthNode = bandwidthNode.nextSiblingElement("bandwidth");
}
Expand Down Expand Up @@ -251,7 +251,7 @@ QList<GwmVariable> GwmLayerGTWRItem::indepVars() const
return mIndepVars;
}

QList<QPair<double, double> > GwmLayerGTWRItem::bandwidthSelScores() const
BandwidthCriterionList GwmLayerGTWRItem::bandwidthSelScores() const
{
return mBandwidthSelScores;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Model/gwmlayergtwritem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef GWMLAYERGTWRITEM_H
#ifndef GWMLAYERGTWRITEM_H
#define GWMLAYERGTWRITEM_H

#include "prefix.h"
Expand Down Expand Up @@ -39,7 +39,7 @@ class GwmLayerGTWRItem : public GwmLayerVectorItem

QList<GwmVariable> indepVars() const;

QList<QPair<double, double> > bandwidthSelScores() const;
BandwidthCriterionList bandwidthSelScores() const;

GwmBandwidthWeight weight() const;

Expand All @@ -50,7 +50,7 @@ class GwmLayerGTWRItem : public GwmLayerVectorItem
GwmBandwidthWeight mWeight;
GwmDiagnostic mDiagnostic;
arma::mat mBetas;
QList<QPair<double, double> > mBandwidthSelScores;
BandwidthCriterionList mBandwidthSelScores;

bool isRegressionPointGiven;
bool isBandwidthOptimized;
Expand Down
21 changes: 16 additions & 5 deletions src/Model/gwmlayergwaverageitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GwmLayerGWAverageItem::GwmLayerGWAverageItem(GwmLayerItem* parentItem, QgsVector
auto taskMeta = taskThread->meta();
mDataPointsSize = taskMeta.layer->featureCount();
mVariables = taskMeta.variables;
mBandwidth = new GwmBandwidthWeight(taskMeta.weightBandwidthSize, taskMeta.weightBandwidthAdaptive, GwmBandwidthWeight::KernelFunctionType(taskMeta.weightBandwidthKernel));
mBandwidth = new gwm::BandwidthWeight(taskMeta.weightBandwidthSize, taskMeta.weightBandwidthAdaptive, gwm::BandwidthWeight::KernelFunctionType(taskMeta.weightBandwidthKernel));
mQuantile = taskThread->quantile();
mResultList = taskThread->resultlist();

Expand All @@ -27,7 +27,7 @@ GwmLayerGWAverageItem::GwmLayerGWAverageItem(GwmLayerItem* parentItem, QgsVector
}
else
{
mBandwidth = new GwmBandwidthWeight();
mBandwidth = new gwm::BandwidthWeight();
}
}

Expand Down Expand Up @@ -81,8 +81,14 @@ bool GwmLayerGWAverageItem::readXml(QDomNode &node)
{
double bandwidth = weightNode.attribute("bandwidth").toDouble();
bool adaptive = weightNode.attribute("adaptive").toInt();
GwmBandwidthWeight::KernelFunctionType kernel = GwmBandwidthWeight::KernelFunctionTypeNameMapper.value(weightNode.attribute("kernel"));
mBandwidth = new GwmBandwidthWeight(bandwidth, adaptive, kernel);
auto it = std::find_if(
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.begin(),
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.end(),
[&](const auto& kv){ return kv.second == weightNode.attribute("kernel").toStdString(); }
);
gwm::BandwidthWeight::KernelFunctionType kernel =
it != gwm::BandwidthWeight::KernelFunctionTypeNameMapper.end() ? it->first : gwm::BandwidthWeight::Gaussian;
mBandwidth = new gwm::BandwidthWeight(bandwidth, adaptive, kernel);
}
else return false;

Expand Down Expand Up @@ -197,7 +203,12 @@ bool GwmLayerGWAverageItem::writeXml(QDomNode &node, QDomDocument &doc)
nodeAnalyse.appendChild(nodeVariableList);

QDomElement nodeBandwidth = doc.createElement("weight");
nodeBandwidth.setAttribute("kernel", GwmBandwidthWeight::KernelFunctionTypeNameMapper.name(mBandwidth->kernel()));
nodeBandwidth.setAttribute(
"kernel",
QString::fromStdString(
gwm::BandwidthWeight::KernelFunctionTypeNameMapper.at(mBandwidth->kernel())
)
);
nodeBandwidth.setAttribute("bandwidth", mBandwidth->bandwidth());
nodeBandwidth.setAttribute("adaptive", mBandwidth->adaptive());
nodeAnalyse.appendChild(nodeBandwidth);
Expand Down
4 changes: 2 additions & 2 deletions src/Model/gwmlayergwaverageitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GwmLayerGWAverageItem : public GwmLayerVectorItem
return mVariablesY;
}

GwmBandwidthWeight* bandwidth() const
gwm::BandwidthWeight* bandwidth() const
{
return mBandwidth;
}
Expand All @@ -76,7 +76,7 @@ class GwmLayerGWAverageItem : public GwmLayerVectorItem
int mDataPointsSize;
QList<GwmVariable> mVariables;
QList<GwmVariable> mVariablesY;
GwmBandwidthWeight* mBandwidth;
gwm::BandwidthWeight* mBandwidth;
bool mQuantile;
// correlation带宽信息
QList<GwmBandwidthWeight> mBandwidthWeights;
Expand Down
Loading