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
2 changes: 1 addition & 1 deletion src/Model/gwmlayerbasicgwritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GwmLayerBasicGWRItem::GwmLayerBasicGWRItem(GwmLayerItem* parent, QgsVectorLayer*
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(taskThread->spatialWeight().weight<gwm::BandwidthWeight>());
mDiagnostic = taskThread->diagnostic();
mDiagnostic0 = taskThread->diagnostic0();
mBetas = mat(taskThread->betas());
Expand Down
2 changes: 1 addition & 1 deletion src/Model/gwmlayercollinearitygwritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GwmLayerCollinearityGWRItem::GwmLayerCollinearityGWRItem(GwmLayerItem* parent, Q
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(taskThread->spatialWeight().weight<gwm::BandwidthWeight>());
mDiagnostic = taskThread->dialnostic();
mDiagnostic0 = taskThread->diagnostic0();
mBetas = mat(taskThread->betas());
Expand Down
2 changes: 1 addition & 1 deletion src/Model/gwmlayerggwritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GwmLayerGGWRItem::GwmLayerGGWRItem(GwmLayerItem* parent, QgsVectorLayer* vector,
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(taskThread->spatialWeight().weight<gwm::BandwidthWeight>());
mBetas = mat(taskThread->betas());
isBandwidthOptimized = taskThread->autoselectBandwidth();
mBandwidthSelScores = taskThread->bandwidthSelectorCriterions();
Expand Down
22 changes: 12 additions & 10 deletions src/Model/gwmlayergtdritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ GwmLayerGTDRItem::GwmLayerGTDRItem(GwmLayerItem* parentItem, QgsVectorLayer* vec
// update mBandwidth
if (!sws.empty())
{
auto* optimizedBw = sws[0].weight<gwm::BandwidthWeight>();
if (optimizedBw)
const auto& coreW = sws[0].weight();
if (coreW)
{
auto& optimizedBw = sws[0].weight<gwm::BandwidthWeight>();
// 更新为优化后的带宽值
mBandwidth->setBandwidth(optimizedBw->bandwidth());
mBandwidth->setAdaptive(optimizedBw->adaptive());
mBandwidth->setKernel(static_cast<GwmBandwidthWeight::KernelFunctionType>(optimizedBw->kernel()));
mBandwidth->setBandwidth(optimizedBw.bandwidth());
mBandwidth->setAdaptive(optimizedBw.adaptive());
mBandwidth->setKernel(static_cast<GwmBandwidthWeight::KernelFunctionType>(optimizedBw.kernel()));
isBandwidthOptimized = true;
}
}
Expand All @@ -57,14 +58,15 @@ GwmLayerGTDRItem::GwmLayerGTDRItem(GwmLayerItem* parentItem, QgsVectorLayer* vec
mBandwidths.reserve(sws.size());
for(int i = 0; i < sws.size(); ++i){
// 从 taskMeta 获取初始值,或从优化后的 spatialWeight 获取
auto* libBw = sws[i].weight<gwm::BandwidthWeight>();
if (libBw)
const auto& coreW = sws[i].weight();
if (coreW)
{
auto& libBw = sws[i].weight<gwm::BandwidthWeight>();
// 创建应用层的带宽权重对象
auto* appBw = new GwmBandwidthWeight(
libBw->bandwidth(),
libBw->adaptive(),
static_cast<GwmBandwidthWeight::KernelFunctionType>(libBw->kernel())
libBw.bandwidth(),
libBw.adaptive(),
static_cast<GwmBandwidthWeight::KernelFunctionType>(libBw.kernel())
);
mBandwidths.append(appBw);
}
Expand Down
11 changes: 6 additions & 5 deletions src/Model/gwmlayergwpcaitem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gwmlayergwpcaitem.h"
#include "gwmlayergwpcaitem.h"
#include "gwmlayergroupitem.h"

#include <QDir>
Expand All @@ -16,14 +16,15 @@ GwmLayerGWPCAItem::GwmLayerGWPCAItem(GwmLayerItem* parent, QgsVectorLayer* vecto
mK = taskThread->k();

gwm::SpatialWeight sw = taskThread->spatialWeight();
gwm::BandwidthWeight* gwmBw = sw.weight<gwm::BandwidthWeight>();
if (gwmBw)
const auto& coreW = sw.weight();
if (coreW)
{
if(gwmBw->bandwidth() == 0)
gwm::BandwidthWeight& gwmBw = sw.weight<gwm::BandwidthWeight>();
if(gwmBw.bandwidth() == 0)
{
qDebug() << "[GwmLayerGWPCAItem] WARNING: Bandwidth is 0! This will cause display issues in property panel.";
}
mWeight = gwm::BandwidthWeight(*gwmBw);
mWeight = gwm::BandwidthWeight(gwmBw);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Model/gwmlayerscalablegwritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GwmLayerScalableGWRItem::GwmLayerScalableGWRItem(GwmLayerItem* parent, QgsVector
mDataPointsSize = taskThread->dataLayer()->featureCount();
mDepVar = taskThread->dependentVariable();
mIndepVars = taskThread->independentVariables();
mWeight = gwm::BandwidthWeight(*static_cast<gwm::BandwidthWeight*>(taskThread->spatialWeight().weight()));
mWeight = gwm::BandwidthWeight(taskThread->spatialWeight().weight<gwm::BandwidthWeight>());
mDistanceType = taskThread->spatialWeight().distance()->type();
mDiagnostic = taskThread->diagnostic();
mDiagnostic0 = taskThread->diagnostic0();
Expand Down
Loading