Skip to content

Commit

Permalink
Merge pull request #470 from lixun910/master
Browse files Browse the repository at this point in the history
GeoDa 1.8.12 pull request
  • Loading branch information
lixun910 committed Sep 2, 2016
2 parents 9400009 + 58b08d5 commit 514595f
Show file tree
Hide file tree
Showing 28 changed files with 684 additions and 132 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ rc/Drop-Files-Here-extra-black.png
*.opensdf
*.exe
BuildTools/windows/logger.txt

BuildTools/.DS_Store

.DS_Store

*.DS_Store
6 changes: 6 additions & 0 deletions BuildTools/macosx/GeoDa.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
A11F1B821850437A006F5F98 /* OGRTableOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A11F1B801850437A006F5F98 /* OGRTableOperation.cpp */; };
A12E0F4F1705087A00B6059C /* OGRDataAdapter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A12E0F4E1705087A00B6059C /* OGRDataAdapter.cpp */; };
A13B6B9418760CF100F93ACF /* SaveAsDlg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A13B6B9318760CF100F93ACF /* SaveAsDlg.cpp */; };
A14C496F1D76174000D9831C /* CsvFieldConfDlg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A14C496D1D76174000D9831C /* CsvFieldConfDlg.cpp */; };
A16BA470183D626200D3B7DA /* DatasourceDlg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A16BA46E183D626200D3B7DA /* DatasourceDlg.cpp */; };
A186F0A11C16508A00AEBA13 /* GdaCartoDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A186F09F1C16508A00AEBA13 /* GdaCartoDB.cpp */; };
A19F51501756A11E006E31B4 /* plugins in Resources */ = {isa = PBXBuildFile; fileRef = A19F514D1756A11E006E31B4 /* plugins */; };
Expand Down Expand Up @@ -233,6 +234,8 @@
A12E0F4E1705087A00B6059C /* OGRDataAdapter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OGRDataAdapter.cpp; sourceTree = "<group>"; };
A13B6B9218760CF100F93ACF /* SaveAsDlg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveAsDlg.h; sourceTree = "<group>"; };
A13B6B9318760CF100F93ACF /* SaveAsDlg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SaveAsDlg.cpp; sourceTree = "<group>"; };
A14C496D1D76174000D9831C /* CsvFieldConfDlg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CsvFieldConfDlg.cpp; sourceTree = "<group>"; };
A14C496E1D76174000D9831C /* CsvFieldConfDlg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CsvFieldConfDlg.h; sourceTree = "<group>"; };
A16BA46E183D626200D3B7DA /* DatasourceDlg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatasourceDlg.cpp; sourceTree = "<group>"; };
A16BA46F183D626200D3B7DA /* DatasourceDlg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatasourceDlg.h; sourceTree = "<group>"; };
A171FBFE1792332A000DD5A0 /* GdaException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GdaException.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -750,6 +753,8 @@
DD7974FE0F1D296F00496A84 /* DialogTools */ = {
isa = PBXGroup;
children = (
A14C496D1D76174000D9831C /* CsvFieldConfDlg.cpp */,
A14C496E1D76174000D9831C /* CsvFieldConfDlg.h */,
A1EBC88D1CD2B2FD001DCFE9 /* AutoUpdateDlg.cpp */,
A1EBC88E1CD2B2FD001DCFE9 /* AutoUpdateDlg.h */,
A1AC05BD1C8645F300B6FE5F /* AdjustYAxisDlg.cpp */,
Expand Down Expand Up @@ -1369,6 +1374,7 @@
DDEA3CBE193CEE5C0028B746 /* GdaLexer.cpp in Sources */,
DDEA3CBF193CEE5C0028B746 /* GdaParser.cpp in Sources */,
DDEA3D01193D17130028B746 /* CalculatorDlg.cpp in Sources */,
A14C496F1D76174000D9831C /* CsvFieldConfDlg.cpp in Sources */,
DDA4F0A4196311A9007645E2 /* WeightsMetaInfo.cpp in Sources */,
DDA4F0AD196315AF007645E2 /* WeightUtils.cpp in Sources */,
DD817EA819676AF100228B0A /* WeightsManState.cpp in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion BuildTools/macosx/auto_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ git pull
cd ~/geoda_trunk/o
rm *
cd ~/geoda_trunk/BuildTools/macosx
./build.sh $CPU $DEBUG
./build.sh $CPU $NODEBUG
cd ~/Dropbox/yoursway-create-dmg
./geoda.sh $VERSION
mv GeoDa$VERSION-Installer.dmg ~/Dropbox
Expand Down
2 changes: 1 addition & 1 deletion BuildTools/ubuntu/build64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ echo "%%%%%%%%%%%%%%%%%%%"
mkdir ../../o
$MAKER
make app
cp plugins/x64/*.so build/plugins/
#cp plugins/x64/*.so build/plugins/
cp ../CommonDistFiles/cache.sqlite build/
cp ../CommonDistFiles/geoda_prefs.sqlite build/
cp ../CommonDistFiles/geoda_prefs.json build/
Expand Down
2 changes: 2 additions & 0 deletions BuildTools/windows/GeoDa.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
<ClCompile Include="..\..\DialogTools\AdjustYAxisDlg.cpp" />
<ClCompile Include="..\..\DialogTools\AutoUpdateDlg.cpp" />
<ClCompile Include="..\..\DialogTools\BasemapConfDlg.cpp" />
<ClCompile Include="..\..\DialogTools\CsvFieldConfDlg.cpp" />
<ClCompile Include="..\..\DialogTools\PublishDlg.cpp" />
<ClCompile Include="..\..\DialogTools\SelectWeightsDlg.cpp" />
<ClCompile Include="..\..\DialogTools\WebViewHelpWin.cpp" />
Expand Down Expand Up @@ -271,6 +272,7 @@
<ClInclude Include="..\..\DialogTools\AutoUpdateDlg.h" />
<ClInclude Include="..\..\DialogTools\BasemapConfDlg.h" />
<ClInclude Include="..\..\DialogTools\CalculatorDlg.h" />
<ClInclude Include="..\..\DialogTools\CsvFieldConfDlg.h" />
<ClInclude Include="..\..\DialogTools\DatasourceDlg.h" />
<ClInclude Include="..\..\DialogTools\ExportDataDlg.h" />
<ClInclude Include="..\..\DialogTools\FieldNameCorrectionDlg.h" />
Expand Down
6 changes: 6 additions & 0 deletions BuildTools/windows/GeoDa.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@
<ClInclude Include="..\..\DialogTools\AutoUpdateDlg.h">
<Filter>DialogTools</Filter>
</ClInclude>
<ClInclude Include="..\..\DialogTools\CsvFieldConfDlg.h">
<Filter>DialogTools</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\rc\GdaAppResources.cpp">
Expand Down Expand Up @@ -1133,5 +1136,8 @@
<ClCompile Include="..\..\DialogTools\AutoUpdateDlg.cpp">
<Filter>DialogTools</Filter>
</ClCompile>
<ClCompile Include="..\..\DialogTools\CsvFieldConfDlg.cpp">
<Filter>DialogTools</Filter>
</ClCompile>
</ItemGroup>
</Project>
32 changes: 18 additions & 14 deletions DialogTools/ConnectDatasourceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <json_spirit/json_spirit.h>
#include <json_spirit/json_spirit_writer.h>

#include "../DialogTools/CsvFieldConfDlg.h"
#include "../DataViewer/DataSource.h"
#include "../ShapeOperations/OGRDataAdapter.h"
#include "../GenUtils.h"
Expand All @@ -58,8 +59,6 @@ class DnDFile : public wxFileDropTarget
bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
{
size_t nFiles = filenames.GetCount();
//wxString str;
//str.Printf( wxT("%d files dropped"), (int)nFiles);

if (m_pOwner != NULL && nFiles > 0)
{
Expand All @@ -83,8 +82,7 @@ END_EVENT_TABLE()

using namespace std;

ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos,
const wxSize& size)
ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos, const wxSize& size)
:datasource(0)
{
// init controls defined in parent class
Expand All @@ -98,8 +96,7 @@ ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos,

m_drag_drop_box->SetDropTarget(new DnDFile(this));

Bind(wxEVT_COMMAND_MENU_SELECTED, &ConnectDatasourceDlg::BrowseDataSource,
this, DatasourceDlg::ID_DS_START, ID_DS_START + ds_names.Count());
Bind(wxEVT_COMMAND_MENU_SELECTED, &ConnectDatasourceDlg::BrowseDataSource, this, DatasourceDlg::ID_DS_START, ID_DS_START + ds_names.Count());
}

ConnectDatasourceDlg::~ConnectDatasourceDlg()
Expand Down Expand Up @@ -194,6 +191,7 @@ void ConnectDatasourceDlg::OnOkClick( wxCommandEvent& event )
{
LOG_MSG("Entering ConnectDatasourceDlg::OnOkClick");
try {
// Open GeoDa project file direclty
if (ds_file_path.GetExt().Lower() == "gda") {
GdaFrame* gda_frame = GdaFrame::GetGdaFrame();
if (gda_frame) {
Expand All @@ -202,8 +200,16 @@ void ConnectDatasourceDlg::OnOkClick( wxCommandEvent& event )
}
return;
}

// For csv file, if no csvt file, pop-up a field definition dialog and create a csvt file
//if (ds_file_path.GetExt().Lower() == "csv") {
// wxString csv_path = ds_file_path.GetFullPath();
// CsvFieldConfDlg csvDlg(this, csv_path);
// csvDlg.ShowModal();
//}

CreateDataSource();

// Check to make sure to get a layer name
wxString layername;
int datasource_type = m_ds_notebook->GetSelection();
Expand Down Expand Up @@ -238,10 +244,12 @@ void ConnectDatasourceDlg::OnOkClick( wxCommandEvent& event )
return;
}

if (layername.IsEmpty()) return;
if (layername.IsEmpty())
return;

// At this point, there is a valid datasource and layername.
if (layer_name.IsEmpty()) layer_name = layername;
if (layer_name.IsEmpty())
layer_name = layername;

EndDialog(wxID_OK);

Expand Down Expand Up @@ -298,8 +306,7 @@ IDataSource* ConnectDatasourceDlg::CreateDataSource()
PromptDSLayers(datasource);
if (layer_name.IsEmpty()) {
throw GdaException(
wxString("Layer/Table name could not be empty. Please select"
" a layer/table.").mb_str());
wxString("Layer/Table name could not be empty. Please select a layer/table.").mb_str());
}
}

Expand All @@ -322,10 +329,7 @@ IDataSource* ConnectDatasourceDlg::CreateDataSource()
else if (cur_sel == DBTYPE_MYSQL) ds_type = GdaConst::ds_mysql;
//else if (cur_sel == 4) ds_type = GdaConst::ds_ms_sql;
else {
wxString msg = "The selected database driver is not supported "
"on this platform. Please check GeoDa website "
"for more information about database support "
" and connection.";
wxString msg = "The selected database driver is not supported on this platform. Please check GeoDa website for more information about database support and connection.";
throw GdaException(msg.mb_str());
}

Expand Down
49 changes: 34 additions & 15 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 @@ -296,17 +304,18 @@ void CreatingWeightDlg::OnCreateClick( wxCommandEvent& event )
{
GwtWeight* Wp = 0;
double t_val = m_threshold_val;
if (t_val <= 0) t_val = std::numeric_limits<float>::min();
wmi.SetToThres(id, dist_metric, dist_units, dist_values,
t_val, dist_var_1, dist_tm_1,
dist_var_2, dist_tm_2);
if (t_val <= 0) {
t_val = std::numeric_limits<float>::min();
}
wmi.SetToThres(id, dist_metric, dist_units, dist_units_str,dist_values, t_val, dist_var_1, dist_tm_1, dist_var_2, dist_tm_2);

if (m_is_arc && m_arc_in_km) {
t_val /= GenGeomAlgs::one_mi_in_km; // convert km to mi
}

if (t_val > 0) {
using namespace SpatialIndAlgs;
Wp = thresh_build(m_XCOO, m_YCOO, t_val * m_thres_delta_factor,
m_is_arc, !m_arc_in_km);
Wp = thresh_build(m_XCOO, m_YCOO, t_val * m_thres_delta_factor, m_is_arc, !m_arc_in_km);
if (!Wp || !Wp->gwt) {
wxString m;
m << "No weights file was created due to all observations ";
Expand All @@ -327,15 +336,20 @@ void CreatingWeightDlg::OnCreateClick( wxCommandEvent& event )

case KNN: // k nn
{
wmi.SetToKnn(id, dist_metric, dist_units, dist_values, m_kNN, dist_var_1, dist_tm_1, dist_var_2, dist_tm_2);
wmi.SetToKnn(id, dist_metric, dist_units, dist_units_str, dist_values, m_kNN, dist_var_1, dist_tm_1, dist_var_2, dist_tm_2);

if (m_kNN > 0 && m_kNN < m_num_obs) {
GwtWeight* Wp = 0;
Wp = SpatialIndAlgs::knn_build(m_XCOO, m_YCOO, m_kNN, dist_metric == WeightsMetaInfo::DM_arc, dist_units == WeightsMetaInfo::DU_mile);
if (!Wp->gwt) return;

if (!Wp->gwt)
return;
Wp->id_field = id;

WriteWeightFile(0, Wp->gwt, project->GetProjectTitle(), outputfile, id, wmi);
if (Wp) delete Wp;
done = true;

} else {
wxString s;
s << "Error: Maximum number of neighbors " << m_num_obs-1;
Expand Down Expand Up @@ -653,8 +667,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 +680,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 Expand Up @@ -914,7 +927,8 @@ void CreatingWeightDlg::InitDlg()
m_thres_val_valid = false;
m_threshold_val = 0.01;
dist_metric = WeightsMetaInfo::DM_euclidean;
dist_units = WeightsMetaInfo::DU_mile;
dist_units = WeightsMetaInfo::DU_unspecified;
dist_units_str = project->project_unit;
dist_values = WeightsMetaInfo::DV_centroids;
dist_var_1 = "";
dist_tm_1 = -1;
Expand Down Expand Up @@ -1055,7 +1069,12 @@ void CreatingWeightDlg::SetDistChoiceEuclid(bool update_sel)
m_arc_in_km = false;

dist_metric = WeightsMetaInfo::DM_euclidean;
dist_units = WeightsMetaInfo::DU_mile;

// note: the projection information can be used (after version 1.8.10)
// to read the UNIT meta data.
dist_units_str = project->project_unit;

dist_units = WeightsMetaInfo::DU_unspecified;
}

void CreatingWeightDlg::SetDistChoiceArcMiles(bool update_sel)
Expand Down
4 changes: 3 additions & 1 deletion DialogTools/CreatingWeightDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public TableStateObserver, public WeightsManStateObserver
WeightsMetaInfo::DistanceMetricEnum dist_metric;
WeightsMetaInfo::DistanceUnitsEnum dist_units;
WeightsMetaInfo::DistanceValuesEnum dist_values;


wxString dist_units_str;

wxString dist_var_1;
long dist_tm_1;
wxString dist_var_2;
Expand Down
Loading

0 comments on commit 514595f

Please sign in to comment.