Skip to content

Commit

Permalink
#466 distance weights X/Y centroids v.s. user selected Lat/Lon
Browse files Browse the repository at this point in the history
The user selections have been incorrectly read from memory, especially
when NEW POLYID has been created
  • Loading branch information
lixun910 committed Aug 27, 2016
1 parent fcc114a commit 91a5218
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
17 changes: 12 additions & 5 deletions DialogTools/CreatingWeightDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,16 @@ void CreatingWeightDlg::OnCreateNewIdClick( wxCommandEvent& event )
if (dlg.ShowModal() == wxID_OK) {

// We know that the new id has been added to the the table in memory
m_id_field->Insert(dlg.GetIdVarName(), 0);
//wxString new_id = dlg.GetIdVarName();
//m_id_field->Insert(new_id, 0);
//m_id_field->SetSelection(0);

col_id_map.clear();
table_int->FillColIdMap(col_id_map);

InitFields();
m_id_field->SetSelection(0);

EnableDistanceRadioButtons(m_id_field->GetSelection() != wxNOT_FOUND);
EnableContiguityRadioButtons((m_id_field->GetSelection() != wxNOT_FOUND) && !project->IsTableOnlyProject());
UpdateCreateButtonState();
Expand Down Expand Up @@ -653,8 +661,8 @@ void CreatingWeightDlg::UpdateThresholdValues()
}
if (v1 != wxEmptyString || v2 != wxEmptyString) {
if (v1 != wxEmptyString) {
int x_sel = (project->IsTableOnlyProject() ?
m_X->GetSelection() : m_X->GetSelection()-2);
// minus 2 is for <X-Centroids> and <X-Mean> selection options in Dropdown
int x_sel = (project->IsTableOnlyProject() ? m_X->GetSelection() : m_X->GetSelection()-2);
int col_id = col_id_map[x_sel];
int tm = 0;
dist_tm_1 = -1;
Expand All @@ -666,8 +674,7 @@ void CreatingWeightDlg::UpdateThresholdValues()
table_int->GetColData(col_id, tm, m_XCOO);
}
if (v2 != wxEmptyString) {
int y_sel = (project->IsTableOnlyProject() ?
m_Y->GetSelection() : m_Y->GetSelection()-2);
int y_sel = (project->IsTableOnlyProject() ? m_Y->GetSelection() : m_Y->GetSelection()-2);
int col_id = col_id_map[y_sel];
int tm = 0;
dist_tm_2 = -1;
Expand Down
27 changes: 11 additions & 16 deletions ShapeOperations/WeightUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ wxString WeightUtils::ReadIdField(const wxString& fname)

} else {

ss >> num1 >> num2 >> dbf_name >> t_key_field;
ss.clear();
ss.seekg(0, ios::beg); // reset to beginning
ss >> num1 >> num2 >> dbf_name >> t_key_field;
}


Expand Down Expand Up @@ -145,21 +147,9 @@ GalElement* WeightUtils::ReadGal(const wxString& fname,

} else {

wxString num1_str = header.BeforeFirst(' ');

header = header.AfterFirst(' ');

wxString num2_str = header.BeforeFirst(' ');

header = header.AfterFirst(' ');

dbf_name = header.BeforeFirst(' ');

t_key_field = header.AfterFirst(' ');


num1_str.ToLongLong(&num1);
num2_str.ToLongLong(&num2);
ss.clear();
ss.seekg(0, ios::beg); // reset to beginning
ss >> num1 >> num2 >> dbf_name >> t_key_field;
}


Expand Down Expand Up @@ -430,8 +420,11 @@ GalElement* WeightUtils::ReadGwtAsGal(const wxString& fname,

} else {

ss.clear();
ss.seekg(0, ios::beg); // reset to beginning
ss >> num1 >> num2 >> dbf_name >> t_key_field;
}

wxString key_field(t_key_field);
if (num2 == 0) {
use_rec_order = true;
Expand Down Expand Up @@ -682,6 +675,8 @@ GwtElement* WeightUtils::ReadGwt(const wxString& fname,

} else {

ss.clear();
ss.seekg(0, ios::beg); // reset to beginning
ss >> num1 >> num2 >> dbf_name >> t_key_field;
}

Expand Down

0 comments on commit 91a5218

Please sign in to comment.