Skip to content

Commit

Permalink
Merge pull request #6 from lixun910/dev1.9
Browse files Browse the repository at this point in the history
1.8.6 GeoDa patch (TestMode)
  • Loading branch information
lixun910 committed May 6, 2016
2 parents c06bf8e + 982c16a commit 31edd93
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 23 deletions.
Binary file modified BuildTools/CommonDistFiles/cache.sqlite
Binary file not shown.
12 changes: 12 additions & 0 deletions DialogTools/AutoUpdateDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ wxString AutoUpdate::CheckUpdate()

// could be a testing version
if (isTestMode
&& update_build >= Gda::version_build // e.g. 1.8.5 vs 1.8.4
&& update_build % 2 == 1 // e.g. 1.8.5
&& update_subbuild >= 0 ) { // 1.8.5.1
return version;
Expand Down Expand Up @@ -216,7 +217,18 @@ wxString AutoUpdate::GetUpdateUrl(wxString checklist)

wxString AutoUpdate::GetCheckList()
{
bool isTestMode = false;
std::vector<std::string> test_mode = OGRDataAdapter::GetInstance().GetHistory("test_mode");
if (!test_mode.empty() && test_mode[0] == "yes") {
isTestMode = true;
}

wxString checklistUrl = "http://geodacenter.github.io/updates/checklist";

if (isTestMode) {
checklistUrl = "http://geodacenter.github.io/updates/test.checklist";
}

// download checklist.txt
if ( GeneralWxUtils::isWindows()) {
if (GeneralWxUtils::isX86()) {
Expand Down
2 changes: 1 addition & 1 deletion Explore/LineChartStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void LineChartStats::UpdateTtest()
fisher_f dist(df_treat, df_res);
double q = cdf(complement(dist, fabs(f_val)));

deg_free = (obs_sz_i-1);
deg_free = obs_sz_i-1;
test_stat = f_val;
p_val = q;

Expand Down
10 changes: 7 additions & 3 deletions Explore/LineChartView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,11 @@ void LineChartFrame::UpdateStatsWinContent(int var)
s<< "<tr>";
s<< "<td bgcolor=\"#CCCCCC\" align=\"center\">D.F.&nbsp;</td>";
stringstream _s;
_s << (int)lcs.deg_free;
if (choice_groups->GetSelection() == 0)
_s << (int)lcs.deg_free;
else
_s << (int)(lcs.deg_free * 2);

_s << std::fixed << std::setprecision(2);
s<< "<td align=\"center\">" << _s.str() << "</td>";
s<< "</tr>";
Expand All @@ -2189,9 +2193,9 @@ void LineChartFrame::UpdateStatsWinContent(int var)
s<< "<td bgcolor=\"#CCCCCC\" align=\"center\">D.F.&nbsp;</td>";
stringstream _s;
if (choice_group1->GetSelection() == 0) {
_s << (int)lcs.deg_free_c[1];
_s << (int)lcs.deg_free_c[1] * 2;
} else {
_s << (int)lcs.deg_free_c[4];
_s << (int)lcs.deg_free_c[4] * 2;
}
_s << std::fixed << std::setprecision(2);
s<< "<td align=\"center\">" << _s.str() << "</td>";
Expand Down
4 changes: 2 additions & 2 deletions GeoDa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5680,11 +5680,11 @@ void GdaFrame::OnCheckUpdates(wxCommandEvent& WXUNUSED(event) )

void GdaFrame::OnCheckTestMode(wxCommandEvent& event)
{
wxString checked = "no";
std::string checked = "no";
if (event.IsChecked()) {
checked = "yes";
}
OGRDataAdapter::GetInstance().AddEntry("test_mode", std::string(checked.mb_str()));
OGRDataAdapter::GetInstance().AddEntry("test_mode", checked);
}

void GdaFrame::OnHelpAbout(wxCommandEvent& WXUNUSED(event) )
Expand Down
2 changes: 1 addition & 1 deletion ShapeOperations/GalWeight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool GalWeight::SaveDIDWeights(Project* project, int num_obs, std::vector<wxInt6

for (int cp=gal[orig_id].Size(); --cp >= 0;) {
int n_id = gal[orig_id][cp];
out << n_id + offset;
out << n_id + offset + 1; // n_id starts from 0, so add 1
if (cp > 0) out << " ";
}
out << endl;
Expand Down
6 changes: 5 additions & 1 deletion ShapeOperations/GdaCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ GdaCache::GdaCache()

GdaCache::~GdaCache()
{
history_table->Save();

delete history_table;
history_table = NULL;
delete cach_ds_proxy;
Expand Down Expand Up @@ -115,7 +117,9 @@ void GdaCache::AddEntry(std::string param_key, std::string param_val)
history_vals.push_back( param_val );
// add to spatialite table
std::string sql = "INSERT INTO history VALUES('" + param_key +"','"+param_val + "')";
cach_ds_proxy->ExecuteSQL(sql);
//cach_ds_proxy->ExecuteSQL(sql);
OGRLayer* tmp_layer = cach_ds_proxy->ds->ExecuteSQL(sql.c_str(), 0, "SQLITE");
cach_ds_proxy->ds->ReleaseResultSet(tmp_layer);
}

void GdaCache::CleanHistory()
Expand Down
2 changes: 1 addition & 1 deletion ShapeOperations/GwtWeight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool GwtWeight::SaveDIDWeights(Project* project, int num_obs, std::vector<wxInt6
for (long nbr=0; nbr<gwt[orig_id].Size(); ++nbr) {
const GwtNeighbor& current = gwt[orig_id].elt(nbr);

int n_id = current.nbx + offset;
int n_id = current.nbx + offset + 1; // current.nbx starts from 0, so add 1

out << newids[i] << ' ' << n_id << ' ' << setprecision(9) << setw(18) << current.weight << endl;
}
Expand Down
21 changes: 13 additions & 8 deletions ShapeOperations/OGRDatasourceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,22 @@ OGRDatasourceProxy::OGRDatasourceProxy(wxString _ds_name, GdaConst::DataSourceTy
if (!ds) {
// try without UPDATE
ds = (GDALDataset*) GDALOpenEx(pszDsPath, GDAL_OF_VECTOR, NULL, NULL, NULL);
wxString drv_name(ds->GetDriverName());
if (!ds || (drv_name == "OpenFileGDB")) {

if (ds==0) {
//wxString drv_name(ds->GetDriverName());
//if (drv_name == "OpenFileGDB") {
// raise open fialed
// we don't use OpenFileGDB since it has some bugs
string error_detail = CPLGetLastErrorMsg();
ostringstream msg;
if ( error_detail.length() == 0 || error_detail == "Unknown") {
msg << "Failed to open data source. Please check the data and check if the data type/format is supported by GeoDa.\n\nTip: you can set up the necessary GeoDa driver by following the instructions at:\n http://geodacenter.github.io/formats.html";
} else {
msg << error_detail;
}
msg << "Failed to open data source. Please check the data/datasource and check if the data type/format is supported by GeoDa.\n\nTip: you can set up the necessary GeoDa driver by following the instructions at:\n http://geodacenter.github.io/formats.html";
//if ( error_detail.length() == 0 || error_detail == "Unknown") {
//} else {
// msg << error_detail;
//}

throw GdaException(msg.str().c_str());
//}
}
is_writable = false;
}
Expand Down Expand Up @@ -216,7 +219,9 @@ vector<string> OGRDatasourceProxy::GetLayerNames()

OGRLayerProxy* OGRDatasourceProxy::ExecuteSQL(string sql)
{
ds->ExecuteSQL(sql.c_str(), 0, 0);
OGRLayer* tmp_layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
//tmp_layer->SyncToDisk();
ds->ReleaseResultSet(tmp_layer);
return NULL;
}

Expand Down
10 changes: 5 additions & 5 deletions ShapeOperations/WeightUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ GalElement* WeightUtils::ReadGal(const wxString& fname,
msg << "range of 1 through " << num_obs << ".";
} else {
msg << " encountered which does not exist in field \"";
msg << key_field << " of the Table.";
msg << key_field << "\" of the Table.";
}
LOG_MSG(msg);
wxMessageDialog dlg(NULL, msg, "Error", wxOK | wxICON_ERROR);
Expand Down Expand Up @@ -288,15 +288,15 @@ GalElement* WeightUtils::ReadGal(const wxString& fname,
if (it == id_map.end()) {
wxString msg = "On line ";
msg << line_cnt << " of weights file, observation id ";
msg << obs;
msg << neigh;
if (use_rec_order) {
msg << " encountered which is out of allowed ";
msg << "observation ";
msg << "range of 1 through " << num_obs << ".";
} else {
msg << " encountered which does not exist ";
msg << "in field \"" << key_field;
msg << " of the Table.";
msg << "\" of the Table.";
}
LOG_MSG(msg);
wxMessageDialog dlg(NULL, msg, "Error",
Expand Down Expand Up @@ -521,7 +521,7 @@ GalElement* WeightUtils::ReadGwtAsGal(const wxString& fname,
msg << "range of 1 through " << num_obs << ".";
} else {
msg << " encountered which does not exist in field \"";
msg << key_field << " of the Table.";
msg << key_field << "\" of the Table.";
}
LOG_MSG(msg);
wxMessageDialog dlg(NULL, msg, "Error", wxOK | wxICON_ERROR);
Expand Down Expand Up @@ -728,7 +728,7 @@ GwtElement* WeightUtils::ReadGwt(const wxString& fname,
msg << "range of 1 through " << num_obs << ".";
} else {
msg << " encountered which does not exist in field \"";
msg << key_field << " of the Table.";
msg << key_field << "\" of the Table.";
}
LOG_MSG(msg);
wxMessageDialog dlg(NULL, msg, "Error", wxOK | wxICON_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Gda {
const int version_subbuild = 0;
const int version_year = 2016;
const int version_month = 5;
const int version_day = 5;
const int version_day = 6;
const int version_night = 0;
const int version_type = 1; // 0: alpha, 1: beta, 2: release
}

0 comments on commit 31edd93

Please sign in to comment.