Skip to content

Commit

Permalink
GeoDaCenter#1751 weights enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Nov 16, 2018
1 parent 00b9280 commit 1329ae7
Show file tree
Hide file tree
Showing 8 changed files with 964 additions and 630 deletions.
59 changes: 57 additions & 2 deletions DialogTools/CreatingWeightDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ EVT_CHECKBOX( XRCID("IDC_CHK_INVERSE_DISTANCE"), CreatingWeightDlg::OnInverseDis
EVT_CHECKBOX( XRCID("IDC_CHK_INVERSE_DISTANCE_KNN"), CreatingWeightDlg::OnInverseKNNCheck)
EVT_SPIN( XRCID("IDC_SPIN_POWER"), CreatingWeightDlg::OnCSpinPowerInverseDistUpdated )
EVT_SPIN( XRCID("IDC_SPIN_POWER_KNN"), CreatingWeightDlg::OnCSpinPowerInverseKNNUpdated )
EVT_NOTEBOOK_PAGE_CHANGED( XRCID("IDC_WEIGHTS_DIST_VARS_LIST"), CreatingWeightDlg::OnDistanceWeightsInputUpdate )
END_EVENT_TABLE()


Expand Down Expand Up @@ -178,6 +179,8 @@ void CreatingWeightDlg::CreateControls()
m_X_time = XRCCTRL(*this, "IDC_XCOORD_TIME", wxChoice);
m_Y = XRCCTRL(*this, "IDC_YCOORDINATES", wxChoice);
m_Y_time = XRCCTRL(*this, "IDC_YCOORD_TIME", wxChoice);
m_Vars = XRCCTRL(*this, "IDC_WEIGHTS_DIST_VARS_LIST", wxListBox);
m_nb_distance_variables = XRCCTRL(*this, "IDC_NB_DISTANCE_VARIABLES", wxNotebook);
m_nb_distance_methods = XRCCTRL(*this, "IDC_NB_DISTANCE_WEIGHTS", wxNotebook);
m_threshold = XRCCTRL(*this, "IDC_THRESHOLD_EDIT", wxTextCtrl);
m_sliderdistance = XRCCTRL(*this, "IDC_THRESHOLD_SLIDER", wxSlider);
Expand Down Expand Up @@ -209,9 +212,48 @@ void CreatingWeightDlg::CreateControls()
m_power->Enable(false);
m_power_knn->Enable(false);

m_nb_distance_variables->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &CreatingWeightDlg::OnDistanceWeightsInputUpdate, this);
m_Vars->Bind(wxEVT_LISTBOX, &CreatingWeightDlg::OnDistanceWeightsVarsSel, this);

InitDlg();
}

void CreatingWeightDlg::OnDistanceWeightsVarsSel( wxCommandEvent& event )
{
// update Threshold values for distance weight
wxArrayInt selections;
m_Vars->GetSelections(selections);
int num_var = selections.size();
if (num_var <= 0) {
return;
}
for (int i=0; i<num_var; i++) {
int idx = selections[i];
wxString sel_str = m_Vars->GetString(idx);

// get data []
//int col = table_int->FindColId(nm);
}
}

void CreatingWeightDlg::OnDistanceWeightsInputUpdate( wxBookCtrlEvent& event )
{
int sel = event.GetSelection();
if (sel == 0) {
UpdateThresholdValues();
} else {
wxArrayInt selections;
m_Vars->GetSelections(selections);
int n_sel = selections.GetCount();
if (n_sel <= 0) {
m_thres_val_valid = false;
m_threshold->ChangeValue("0");
m_bandwidth_thres_val_valid = false;
m_manu_bandwidth->ChangeValue("0");
}
}
}

void CreatingWeightDlg::OnCreateNewIdClick( wxCommandEvent& event )
{
wxLogMessage("Click CreatingWeightDlg::OnCreateNewIdClick");
Expand Down Expand Up @@ -571,14 +613,27 @@ void CreatingWeightDlg::InitFields()
m_id_field->Clear();
m_X_time->Clear();
m_Y_time->Clear();
m_Vars->Clear();

ResetThresXandYCombo();

for (int i=0, iend=col_id_map.size(); i<iend; i++) {
int col = col_id_map[i];

m_X->Append(table_int->GetColName(col));
m_Y->Append(table_int->GetColName(col));
wxString name = table_int->GetColName(col);
m_X->Append(name);
m_Y->Append(name);

if (table_int->IsColTimeVariant(col)) {
for (int t=0; t<table_int->GetColTimeSteps(col); t++) {
wxString nm = name;
nm << " (" << table_int->GetTimeString(t) << ")";
m_Vars->Append(nm);
}
} else {
m_Vars->Append(name);
}

if (table_int->GetColType(col) == GdaConst::long64_type ||
table_int->GetColType(col) == GdaConst::string_type) {
if (!table_int->IsColTimeVariant(col)) {
Expand Down
7 changes: 5 additions & 2 deletions DialogTools/CreatingWeightDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public TableStateObserver, public WeightsManStateObserver
void OnCThresholdSliderUpdated( wxCommandEvent& event );
void OnCSpinPowerInverseDistUpdated( wxSpinEvent& event );
void OnCSpinPowerInverseKNNUpdated( wxSpinEvent& event );

void OnDistanceWeightsInputUpdate( wxBookCtrlEvent& event );
void OnDistanceWeightsVarsSel( wxCommandEvent& event );
/** Implementation of FramesManagerObserver interface */
virtual void update(FramesManager* o);

Expand Down Expand Up @@ -129,7 +130,9 @@ public TableStateObserver, public WeightsManStateObserver
wxChoice* m_X_time;
wxChoice* m_Y;
wxChoice* m_Y_time;
wxNotebook* m_nb_distance_methods;
wxListBox* m_Vars;
wxNotebook* m_nb_distance_variables;
wxNotebook* m_nb_distance_methods;
wxTextCtrl* m_threshold;
wxSlider* m_sliderdistance;
wxCheckBox* m_use_inverse;
Expand Down
7 changes: 7 additions & 0 deletions DialogTools/ProjectInfoDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ ProjectInfoDlg::ProjectInfoDlg(Project* project)

key.push_back("Number Table Groups");
val.push_back(wxString::Format("%d", grp_cnt));

if (project->IsTableOnlyProject() == false) {
key.push_back("Map boundary");
double minx = 0, miny = 0, maxx = 0, maxy = 0;
project->GetMapExtent(minx, miny, maxx, maxy);
val.push_back(wxString::Format("Lower left: %f, %f Upper right: %f, %f", minx, miny, maxx, maxy));
}

const int left_offset = 0;
const int top_offset = 0;
Expand Down
2 changes: 1 addition & 1 deletion PointSetAlgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void PointSetAlgs::GetMinMax(const std::vector<wxRealPoint>& pts,
double PointSetAlgs::EstDiameter(const std::vector<double>& x,
const std::vector<double>& y,
bool is_arc,
wxRealPoint& pt1, wxRealPoint& pt2)
wxRealPoint& pt1, wxRealPoint& pt2)
{
LOG_MSG("Entering PointSetAlgs::EstDiameter");
using namespace GenGeomAlgs;
Expand Down
9 changes: 9 additions & 0 deletions Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,15 @@ GdaPolygon* Project::GetMapBoundary()
}
}

void Project::GetMapExtent(double& minx, double& miny, double& maxx, double& maxy)
{
wxLogMessage("Project::GetMapExtent()");

if (layer_proxy) {
layer_proxy->GetExtent(minx, miny, maxx, maxy);
}
}

void Project::GetCentroids(std::vector<double>& x, std::vector<double>& y)
{
wxLogMessage("Project::GetCentroids(std::vector<double>& x, std::vector<double>& y)");
Expand Down
3 changes: 2 additions & 1 deletion Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ class Project {
void GetCentroids(std::vector<wxRealPoint>& pts);
const std::vector<GdaShape*>& GetVoronoiPolygons();
GdaPolygon* GetMapBoundary();

void GetMapExtent(double& minx, double& miny, double& maxx, double& maxy);

double GetMin1nnDistEuc();
double GetMax1nnDistEuc();
double GetMaxDistEuc(); // diameter of convex hull
Expand Down
Loading

0 comments on commit 1329ae7

Please sign in to comment.