diff --git a/.gitignore b/.gitignore index 2c4269fe0..1f0a95b2e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ *.gal *.pyc +deps/ + swig/*.gwt swig/_geoda.so swig/geoda.pyc @@ -98,3 +100,4 @@ BuildTools/macosx/temp1/boost_1_57_0/b2 *.plist .vs/slnx.sqlite BuildTools/temp/CLAPACK-3.1.1-VisualStudio/BLAS/blas.vcproj +*.sqlite-journal diff --git a/Algorithms/DataUtils.h b/Algorithms/DataUtils.h index 994810c77..33cc50ffd 100644 --- a/Algorithms/DataUtils.h +++ b/Algorithms/DataUtils.h @@ -30,8 +30,8 @@ class DataUtils { { double d =0,tmp=0; for (size_t i =0; i& _undefs - //,GalElement* w, double* _controls, double _control_thres - ) + +vector HDBScan::ComputeCoreDistance(double** input_data, int n_pts, + int n_dim, int min_samples, + char dist) { - int cluster_selection_method = _cluster_selection_method; - bool allow_single_cluster = _allow_single_cluster; - bool match_reference_implementation = false; - - // Core distances - core_dist.resize(rows); - - int k = min_samples; - int dim = cols; + vector core_d; + core_d.resize(n_pts); + double eps = 0; // error bound - int nPts = rows; - - ANNkd_tree* kdTree = new ANNkd_tree(_data, nPts, dim); + if (dist == 'e') ANN_DIST_TYPE = 2; // euclidean + else if (dist == 'b') ANN_DIST_TYPE = 1; // manhattan + + // since KNN search will always return the query point itself, so add 1 + // to make sure returning min_samples number of results + //min_samples = min_samples + 1; - ANNidxArray nnIdx = new ANNidx[k]; - ANNdistArray dists = new ANNdist[k]; - for (int i=0; iannkSearch(_data[i], k, nnIdx, dists, eps); - core_dist[i] = sqrt(dists[k-1]); + ANNkd_tree* kdTree = new ANNkd_tree(input_data, n_pts, n_dim); + ANNidxArray nnIdx = new ANNidx[min_samples]; + ANNdistArray dists = new ANNdist[min_samples]; + for (size_t i=0; iannkSearch(input_data[i], min_samples, nnIdx, dists, eps); + core_d[i] = sqrt(dists[min_samples-1]); } delete[] nnIdx; delete[] dists; delete kdTree; + + return core_d; +} + +HDBScan::HDBScan(int min_cluster_size, int min_samples, double alpha, + int _cluster_selection_method, bool _allow_single_cluster, + int rows, int cols, double** _distances, + vector _core_dist, + const vector& _undefs) +{ + int cluster_selection_method = _cluster_selection_method; + bool allow_single_cluster = _allow_single_cluster; + bool match_reference_implementation = false; + + // Core distances + core_dist = _core_dist; // MST - mst_linkage_core_vector(dim, core_dist, _distances, alpha); + mst_linkage_core_vector(cols, core_dist, _distances, alpha); std::sort(mst_edges.begin(), mst_edges.end(), EdgeLess1); // Extract the HDBSCAN hierarchy as a dendrogram from mst @@ -741,7 +756,10 @@ vector HDBScan::recurse_leaf_dfs(vector& cluster_tree, int } } -void HDBScan::mst_linkage_core_vector(int num_features, vector& core_distances, double** dist_metric, double alpha) +void HDBScan::mst_linkage_core_vector(int num_features, + vector& core_distances, + double** dist_metric, + double alpha) { int dim = core_distances.size(); diff --git a/Algorithms/hdbscan.h b/Algorithms/hdbscan.h index f3cd67839..5bbf37a30 100644 --- a/Algorithms/hdbscan.h +++ b/Algorithms/hdbscan.h @@ -212,36 +212,43 @@ namespace GeoDaClustering { bool allow_single_cluster, int rows, int cols, double** _distances, - double** data, + vector _core_dist, const vector& undefs //GalElement * w, //double* controls, //double control_thres ); virtual ~HDBScan(); - + + static vector ComputeCoreDistance(double** input_data, int n_pts, + int n_dim, int min_samples, + char dist); + vector > GetRegions(); vector outlier_scores(vector& tree); - boost::unordered_map compute_stability(vector& condensed_tree); + boost::unordered_map compute_stability( + vector& condensed_tree); void condense_tree(double** hierarchy, int N, int min_cluster_size=10); vector max_lambdas(vector& tree); - vector do_labelling(vector& tree, set& clusters, - boost::unordered_map& cluster_label_map, - bool allow_single_cluster = false, - bool match_reference_implementation = false); + vector do_labelling(vector& tree, + set& clusters, + boost::unordered_map& cluster_label_map, + bool allow_single_cluster = false, + bool match_reference_implementation = false); vector get_probabilities(vector& tree, - boost::unordered_map& reverse_cluster_map, - vector& labels); + boost::unordered_map& reverse_cluster_map, + vector& labels); - vector get_stability_scores(vector& labels, set& clusters, - boost::unordered_map& stability, - double max_lambda); + vector get_stability_scores(vector& labels, + set& clusters, + boost::unordered_map& stability, + double max_lambda); void get_clusters(vector& tree, boost::unordered_map& stability, @@ -253,12 +260,13 @@ namespace GeoDaClustering { bool match_reference_implementation=false); void mst_linkage_core_vector(int num_features, - vector& core_distances, - double** dist_metric, double alpha); + vector& core_distances, + double** dist_metric, double alpha); vector get_cluster_tree_leaves(vector& cluster_tree); - vector recurse_leaf_dfs(vector& cluster_tree, int current_node); + vector recurse_leaf_dfs(vector& cluster_tree, + int current_node); vector bfs_from_hierarchy(double** hierarchy, int dim, int bfs_root) { diff --git a/Algorithms/spectral.cpp b/Algorithms/spectral.cpp index 6ba268d30..4ac08c9e6 100644 --- a/Algorithms/spectral.cpp +++ b/Algorithms/spectral.cpp @@ -72,9 +72,13 @@ void Spectral::affinity_matrix() void Spectral::generate_kernel_matrix() { - //If you have an affinity matrix, such as a distance matrix, for which 0 means identical elements, and high values means very dissimilar elements, it can be transformed in a similarity matrix that is well suited for the algorithm by applying the Gaussian (RBF, heat) kernel: - //np.exp(- X ** 2 / (2. * delta ** 2)) - //delta = X.maxCoeff() - X.minCoeff(); + // If you have an affinity matrix, such as a distance matrix, + // for which 0 means identical elements, and high values means very + // dissimilar elements, it can be transformed in a similarity matrix + // that is well suited for the algorithm by applying + // the Gaussian (RBF, heat) kernel: + // np.exp(- X ** 2 / (2. * delta ** 2)) + // delta = X.maxCoeff() - X.minCoeff(); // Fill kernel matrix K.resize(X.rows(),X.rows()); @@ -200,7 +204,8 @@ void Spectral::fast_eigendecomposition() } } -void Spectral::eigendecomposition(){ +void Spectral::eigendecomposition() +{ //Eigen::SelfAdjointEigenSolver edecomp(K, true); @@ -260,8 +265,12 @@ void Spectral::cluster(int affinity_type) generate_knn_matrix(); } - if (power_iter>0) fast_eigendecomposition(); - else eigendecomposition(); + if (power_iter>0) { + fast_eigendecomposition(); + } else { + // try other method than eigen3, e.g. Intel MLK + eigendecomposition(); + } kmeans(); } @@ -273,7 +282,7 @@ void Spectral::kmeans() int transpose = 0; // row wise int* clusterid = new int[rows]; double* weight = new double[columns]; - for (int j=0; j &get_assignments() const {return assignments;}; diff --git a/BuildTools/macosx/GeoDa.xcodeproj/project.pbxproj b/BuildTools/macosx/GeoDa.xcodeproj/project.pbxproj index cb830c503..b4b4024fa 100644 --- a/BuildTools/macosx/GeoDa.xcodeproj/project.pbxproj +++ b/BuildTools/macosx/GeoDa.xcodeproj/project.pbxproj @@ -830,7 +830,7 @@ DDD593C612E9F90000F7A7C4 /* GalWeight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GalWeight.cpp; sourceTree = ""; }; DDD593C812E9F90C00F7A7C4 /* GwtWeight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GwtWeight.h; sourceTree = ""; }; DDD593C912E9F90C00F7A7C4 /* GwtWeight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GwtWeight.cpp; sourceTree = ""; }; - DDDBF284163AD1D50070610C /* ConditionalMapView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConditionalMapView.cpp; sourceTree = ""; }; + DDDBF284163AD1D50070610C /* ConditionalMapView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConditionalMapView.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; DDDBF285163AD1D50070610C /* ConditionalMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConditionalMapView.h; sourceTree = ""; }; DDDBF299163AD2BF0070610C /* ConditionalScatterPlotView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConditionalScatterPlotView.h; sourceTree = ""; }; DDDBF29A163AD2BF0070610C /* ConditionalScatterPlotView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConditionalScatterPlotView.cpp; sourceTree = ""; }; diff --git a/BuildTools/windows/GeoDa.vcxproj b/BuildTools/windows/GeoDa.vcxproj index 254e974dc..bc3cc7278 100644 --- a/BuildTools/windows/GeoDa.vcxproj +++ b/BuildTools/windows/GeoDa.vcxproj @@ -100,6 +100,9 @@ true true + + true + Disabled @@ -189,7 +192,7 @@ temp\wxWidgets-3.1.0\include;%(AdditionalIncludeDirectories) - opencl.lib;zlibstat.lib;gdal_i.lib;libcurl.lib;libboost_date_time-vc100-mt-gd-1_57.lib;libboost_thread-vc100-mt-gd-1_57.lib;BLAS.lib;clapack.lib;libf2c.lib;json_spirit_lib.lib;sqlite3_i.lib;GlU32.lib;OpenGL32.lib;wxmsw31ud.lib;wxmsw31ud_gl.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;wsock32.lib;comctl32.lib;winmm.lib;rpcrt4.lib;%(AdditionalDependencies) + opencl.lib;zlibstat.lib;gdal_i.lib;libcurl.lib;libboost_date_time-vc100-mt-gd-1_57.lib;libboost_thread-vc100-mt-gd-1_57.lib;BLAS.lib;clapack.lib;libf2c.lib;json_spirit_lib.lib;GlU32.lib;OpenGL32.lib;wxmsw31ud.lib;wxmsw31ud_gl.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;wsock32.lib;comctl32.lib;winmm.lib;rpcrt4.lib;%(AdditionalDependencies) C:\Intel\OpenCL\sdk\lib\x64;dep\zlib\lib;C:\OSGeo4W\lib;temp\wxWidgets-3.1.0\lib\vc_x64_dll;temp\CLAPACK-3.1.1-VisualStudio\LIB\x64;temp\boost_1_57_0\stage\lib;temp\json_spirit_v4.08\Debug;%(AdditionalLibraryDirectories) @@ -205,8 +208,8 @@ Disabled - C:\OSGeo4W\include;temp\boost_1_57_0;temp\wxWidgets-3.1.0\include;temp\wxWidgets-3.1.0\lib\vc_x64_dll\mswud;temp\json_spirit_v4.08;temp\eigen3;%(AdditionalIncludeDirectories) - WIN32;DEBUG;_DEBUG;_WINDOWS;__WXMSW__;__WXDEBUG__;WXUSINGDLL;UNICODE;%(PreprocessorDefinitions) + ..\..\deps\OpenCL\include;..\..\deps\zlib\include;..\..\deps\boost_1_57_0\include;..\..\deps\wxWidgets-3.1.0\include;..\..\deps\wxWidgets-3.1.0\lib\vc_x64_dll\mswud;..\..\deps\json_spirit_v4.08\include;..\..\deps\eigen3;..\..\deps\gdal-1.9.0\include;..\..\deps\curl-7.46.0\include;%(AdditionalIncludeDirectories) + WIN32;DEBUG;_WINDOWS;__WXMSW__;__WXDEBUG__;WXUSINGDLL;UNICODE;_UNICODE;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -222,11 +225,11 @@ __WXMSW__;_UNICODE;_WINDOWS;NOPCH;WXUSINGDLL;%(PreprocessorDefinitions) 0x0409 - temp\wxWidgets-3.1.0\include;%(AdditionalIncludeDirectories) + ..\..\deps\wxWidgets-3.1.0\include;%(AdditionalIncludeDirectories) - opencl.lib;zlibstat.lib;gdal_i.lib;libcurl.lib;libboost_date_time-vc140-mt-gd-1_57.lib;libboost_thread-vc140-mt-gd-1_57.lib;BLAS.lib;clapack.lib;libf2c.lib;json_spirit_lib.lib;sqlite3_i.lib;GlU32.lib;OpenGL32.lib;wxmsw31ud.lib;wxmsw31ud_gl.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;wsock32.lib;comctl32.lib;winmm.lib;rpcrt4.lib;%(AdditionalDependencies) - C:\Intel\OpenCL\sdk\lib\x64;dep\zlib\lib;C:\OSGeo4W\lib;temp\wxWidgets-3.1.0\lib\vc_x64_dll;temp\CLAPACK-3.1.1-VisualStudio\LIB\x64;temp\boost_1_57_0\stage\lib;temp\json_spirit_v4.08\Debug;%(AdditionalLibraryDirectories) + opencl.lib;zlibstat.lib;gdal_i.lib;libcurl.lib;libboost_date_time-vc140-mt-gd-1_57.lib;libboost_thread-vc140-mt-gd-1_57.lib;libboost_system-vc140-mt-gd-1_57.lib;BLAS.lib;clapack.lib;libf2c.lib;json_spirit_libd.lib;wxmsw31ud.lib;wxmsw31ud_gl.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;wxscintillad.lib;wsock32.lib;comctl32.lib;winmm.lib;rpcrt4.lib;GlU32.lib;OpenGL32.lib;%(AdditionalDependencies) + ..\..\deps\zlib\lib;..\..\deps\boost_1_57_0\lib\x64;..\..\deps\wxWidgets-3.1.0\lib\vc_x64_dll;..\..\deps\OpenCL\lib\x64;..\..\deps\CLAPACK-3.1.1\lib\x64;..\..\deps\gdal-1.9.0\lib\x64;..\..\deps\json_spirit_v4.08\lib\x64;..\..\deps\curl-7.46.0\lib\x64;%(AdditionalLibraryDirectories) %(IgnoreSpecificDefaultLibraries) diff --git a/BuildTools/windows/GeoDa.vs2017.sln b/BuildTools/windows/GeoDa.vs2017.sln index 648a24173..670512cbd 100644 --- a/BuildTools/windows/GeoDa.vs2017.sln +++ b/BuildTools/windows/GeoDa.vs2017.sln @@ -1,12 +1,16 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26401.1 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GeoDa", "GeoDa.vcxproj", "{B3CB134F-61C6-48C7-B6E4-353AC473A467}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 + Debug2017|Win32 = Debug2017|Win32 + Debug2017|x64 = Debug2017|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection @@ -15,6 +19,10 @@ Global {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug|Win32.Build.0 = Debug|Win32 {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug|x64.ActiveCfg = Debug|x64 {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug|x64.Build.0 = Debug|x64 + {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug2017|Win32.ActiveCfg = Debug2017|Win32 + {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug2017|Win32.Build.0 = Debug2017|Win32 + {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug2017|x64.ActiveCfg = Debug2017|x64 + {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Debug2017|x64.Build.0 = Debug2017|x64 {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Release|Win32.ActiveCfg = Release|Win32 {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Release|Win32.Build.0 = Release|Win32 {B3CB134F-61C6-48C7-B6E4-353AC473A467}.Release|x64.ActiveCfg = Release|x64 diff --git a/BuildTools/windows/build.bat b/BuildTools/windows/build.bat index 59a774b3b..f5fae8db6 100644 --- a/BuildTools/windows/build.bat +++ b/BuildTools/windows/build.bat @@ -1,18 +1,42 @@ @echo OFF +REM MSVC++ 14.15 _MSC_VER == 1915 (Visual Studio 2017 version 15.8) +REM MSVC++ 14.14 _MSC_VER == 1914 (Visual Studio 2017 version 15.7) +REM MSVC++ 14.13 _MSC_VER == 1913 (Visual Studio 2017 version 15.6) +REM MSVC++ 14.12 _MSC_VER == 1912 (Visual Studio 2017 version 15.5) +REM MSVC++ 14.11 _MSC_VER == 1911 (Visual Studio 2017 version 15.3) +REM MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017 version 15.0) +REM MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015 version 14.0) +REM MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013 version 12.0) +REM MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012 version 11.0) +REM MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010 version 10.0) + +set VS_VER=2010 +set MSC_VER=1600 +set MSVC++=10.0 + REM call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" REM call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" REM call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" if %PROCESSOR_ARCHITECTURE% == x86 ( call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" REM call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" + ) else if %PROCESSOR_ARCHITECTURE% == AMD64 ( - if NOT EXIST "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Microsoft Visual C++ 2010 Express - ENU\License.txt" ( + if EXIST "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" ( call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 echo Looks like you are using Visual Studio 2010 Pro - ) else ( - call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 - echo Looks like you are using Visual Studio 2010 Express + ) + if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Auxiliary\Build\vcvarsall.bat" ( + call "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64 + echo Looks like you are using Visual Studio 2017 Professional Preview + set VS_VER=2017 + set MSC_VER=1911 + set MSVC++=14.1 + ) + if EXIST "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" ( + call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 + echo Looks like you are using Visual Studio 2010 Express ) REM Windows SDK for Windows 7 must be installed before the above command will work REM Please follow steps here to fully patch SDK 7.1 for 64-bit machines: @@ -22,6 +46,7 @@ if %PROCESSOR_ARCHITECTURE% == x86 ( REM The above amd64 environment option does not work with the default VS 2010 Express installation. ) + for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_major" ..\..\version.h') do set VER_MAJOR=%%P for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_minor" ..\..\version.h') do set VER_MINOR=%%P for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_build" ..\..\version.h') do set VER_BUILD=%%P @@ -32,7 +57,7 @@ set GDA_VERSION=%VER_MAJOR%.%VER_MINOR%.%VER_BUILD%.%VER_SUBBUILD% echo. echo ##################################################### echo # -echo # Build script for Windows 7, 32-bit and 64-bit +echo # Build script for Windows 32-bit and 64-bit echo # echo # PROCESSOR_ARCHITECTURE: %PROCESSOR_ARCHITECTURE% @@ -292,7 +317,7 @@ call autogen.bat REM patch nmake.opt to support nmake with version string 10.00.40219.01 copy /Y %BUILD_HOME%\dep\%LIB_NAME%\nmake.opt %DOWNLOAD_HOME%\%LIB_NAME%\nmake.opt -nmake -f makefile.vc MSVC_VER=1600 BUILD_DEBUG=NO +nmake -f makefile.vc MSVC_VER=%MSC_VER% BUILD_DEBUG=NO copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\capi\*.h %LIBRARY_HOME%\include copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\include\*.h %LIBRARY_HOME%\include @@ -693,8 +718,8 @@ echo ##################################################### echo # build wxWidgets echo ##################################################### echo. -set LIB_NAME=wxWidgets-3.1.1 -set LIB_URL="https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.7z" +set LIB_NAME=wxWidgets-3.1.0 +set LIB_URL="https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.0/wxWidgets-3.1.0.7z" REM # We are only checking for a small subset of wxWidgets libraries set ALL_EXIST=true @@ -716,7 +741,7 @@ if %ALL_EXIST% == true ( cd %DOWNLOAD_HOME% IF NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME% ( - IF NOT EXIST %LIB_NAME%.7z %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.7z + IF NOT EXIST %LIB_NAME%.7z %CURL_EXE% -L %LIB_URL% > %LIB_NAME%.7z %UNZIP_EXE% %LIB_NAME%.7z -o%DOWNLOAD_HOME%\%LIB_NAME% ) @@ -826,8 +851,8 @@ if %GDA_BUILD% == BUILD_32 ( ) copy /Y %BUILD_HOME%\dep\gdal-1.9.2\port\cpl_config.h port\cpl_config.h -nmake -f makefile.vc MSVC_VER=1600 -REM nmake -f makefile.vc MSVC_VER=1600 DEBUG=1 +nmake -f makefile.vc MSVC_VER=%MSC_VER% +REM nmake -f makefile.vc MSVC_VER=%MSC_VER% DEBUG=1 copy /Y %DOWNLOAD_HOME%\gdal\gcore\*.h %LIBRARY_HOME%\include copy /Y %DOWNLOAD_HOME%\gdal\port\*.h %LIBRARY_HOME%\include @@ -860,11 +885,21 @@ set LIB_NAME=boost_1_57_0 set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/boost_1_57_0.zip" set ALL_EXIST=true -if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-1_57.lib set ALL_EXIST=false -if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-gd-1_57.lib set ALL_EXIST=false -if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_chrono-vc100-mt-1_57.dll set ALL_EXIST=false -if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_thread-vc100-mt-1_57.dll set ALL_EXIST=false -if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_system-vc100-mt-1_57.dll set ALL_EXIST=false +if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Auxiliary\Build\vcvarsall.bat" ( + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc140-mt-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc140-mt-gd-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_chrono-vc140-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_thread-vc140-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_system-vc140-mt-1_57.dll set ALL_EXIST=false + +) else ( + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-gd-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_chrono-vc100-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_thread-vc100-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_system-vc100-mt-1_57.dll set ALL_EXIST=false +) + if %ALL_EXIST% == true ( echo All %LIB_NAME% library targets exist, skipping build goto SKIP_BOOST_BUILD @@ -882,6 +917,15 @@ cd %BOOST_HOME% call bootstrap.bat +if %GDA_BUILD% == BUILD_32 ( + call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=%MSVC++% --build-type=complete stage + call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=%MSVC++% --build-type=complete --debug-symbols=on stage +) else ( + call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=%MSVC++% --build-type=complete architecture=x86 address-model=64 stage +) +cd %BUILD_HOME% + + echo ############################################### echo # for visual studio 2017 echo edit project-config.jam @@ -890,16 +934,8 @@ echo import option; echo using msvc : 14.0 "c:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe"; echo option.set keep-going : false ; echo -echo Then, run b2 with --toolset=msvc-14.0 +echo Then, run again echo ############################################### -if %GDA_BUILD% == BUILD_32 ( - call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=msvc-10.0 --build-type=complete stage - call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=msvc-10.0 --build-type=complete --debug-symbols=on stage -) else ( - call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage - call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=msvc-10.0 --build-type=complete --debug-symbols=on architecture=x86 address-model=64 stage -) -cd %BUILD_HOME% set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-1_57.lib IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END @@ -1069,8 +1105,13 @@ if %GDA_BUILD% == BUILD_32 ( %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Release" /p:Platform="Win32" %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Debug" /p:Platform="Win32" ) else ( - %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Release" /p:Platform="x64" - %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Debug" /p:Platform="x64" + if %VS_VER% == 2017 ( + REM %MSBUILD_EXE% GeoDa.vs2017.sln /t:GeoDa /property:Configuration="Release" /p:Platform="x64" + %MSBUILD_EXE% GeoDa.vs2017.sln /t:GeoDa /property:Configuration="Debug2017" /p:Platform="x64" + ) else ( + %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Release" /p:Platform="x64" + %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Debug" /p:Platform="x64" + ) ) set CHK_LIB=%BUILD_HOME%\Release\GeoDa.lib REM IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END @@ -1087,6 +1128,9 @@ IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END :SKIP_GEODA_BUILD +if %VS_VER% == 2017 ( + goto REAL_END +) :TO_PACKAGE_BUILD echo. diff --git a/BuildTools/windows/build_vs2017.bat b/BuildTools/windows/build_vs2017.bat new file mode 100644 index 000000000..0b748fb6e --- /dev/null +++ b/BuildTools/windows/build_vs2017.bat @@ -0,0 +1,1238 @@ +@echo OFF + +REM MSVC++ 14.15 _MSC_VER == 1915 (Visual Studio 2017 version 15.8) +REM MSVC++ 14.14 _MSC_VER == 1914 (Visual Studio 2017 version 15.7) +REM MSVC++ 14.13 _MSC_VER == 1913 (Visual Studio 2017 version 15.6) +REM MSVC++ 14.12 _MSC_VER == 1912 (Visual Studio 2017 version 15.5) +REM MSVC++ 14.11 _MSC_VER == 1911 (Visual Studio 2017 version 15.3) +REM MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017 version 15.0) +REM MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015 version 14.0) +REM MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013 version 12.0) +REM MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012 version 11.0) +REM MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010 version 10.0) + +set VS_VER=2010 +set MSC_VER=1600 +set MSVC++=10.0 + +REM call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" +REM call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" +REM call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" +if %PROCESSOR_ARCHITECTURE% == x86 ( + call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" + REM call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" + +) else if %PROCESSOR_ARCHITECTURE% == AMD64 ( + if EXIST "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" ( + call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 + echo Looks like you are using Visual Studio 2010 Pro + ) + if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Auxiliary\Build\vcvarsall.bat" ( + call "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64 + echo Looks like you are using Visual Studio 2017 Professional Preview + set VS_VER=2017 + set MSC_VER=1911 + set MSVC++=14.1 + ) + if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" ( + call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 + echo Looks like you are using Visual Studio 2017 Professional Preview + set VS_VER=2017 + set MSC_VER=1911 + set MSVC++=14.1 + ) + if EXIST "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" ( + call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 + echo Looks like you are using Visual Studio 2010 Express + ) + REM Windows SDK for Windows 7 must be installed before the above command will work + REM Please follow steps here to fully patch SDK 7.1 for 64-bit machines: + REM http://forum.celestialmatters.org/viewtopic.php?t=404 + REM + REM call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64 + REM The above amd64 environment option does not work with the default VS 2010 Express installation. +) + + +for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_major" ..\..\version.h') do set VER_MAJOR=%%P +for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_minor" ..\..\version.h') do set VER_MINOR=%%P +for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_build" ..\..\version.h') do set VER_BUILD=%%P +for /f "tokens=4 delims=;= " %%P in ('findstr /c:"version_subbuild" ..\..\version.h') do set VER_SUBBUILD=%%P + +set GDA_VERSION=%VER_MAJOR%.%VER_MINOR%.%VER_BUILD%.%VER_SUBBUILD% + +echo. +echo ##################################################### +echo # +echo # Build script for Windows 32-bit and 64-bit +echo # +echo # PROCESSOR_ARCHITECTURE: %PROCESSOR_ARCHITECTURE% + +set GDA_BUILD=unknown +if %PROCESSOR_ARCHITECTURE% == x86 ( + echo # 32-bit Windows detected + set GDA_BUILD=BUILD_32 +) else if %PROCESSOR_ARCHITECTURE% == AMD64 ( + echo # 64-bit Windows detected + set GDA_BUILD=BUILD_64 +) else ( + echo # Could not determine processor architecture. + echo # Exiting... +) +echo # +echo # GeoDa version %GDA_VERSION% +echo # +echo ##################################################### +echo. + +set CL=/MP + +set BUILD_HOME=%CD% +echo BUILD_HOME: %BUILD_HOME% +set GEODA_HOME=%BUILD_HOME%\..\.. +echo GEODA_HOME: %GEODA_HOME% +set DOWNLOAD_HOME=%BUILD_HOME%\temp +echo DOWNLOAD_HOME: %DOWNLOAD_HOME% +set BUILD_DEP=%BUILD_HOME%\dep +echo BUILD_DEP: %BUILD_DEP% +set UNZIP_EXE=%BUILD_DEP%\7za.exe x +echo UNZIP_EXE: %UNZIP_EXE% +set CURL_EXE=%BUILD_DEP%\curl.exe -k +echo CURL_EXE: %CURL_EXE% +set MSBUILD_EXE= msbuild +echo MSBUILD_EXE: %MSBUILD_EXE% +if %GDA_BUILD% == BUILD_32 ( + set LIBRARY_HOME=C:\OSGeo4W + set LIB_HM_LIB=lib +) +if %GDA_BUILD% == BUILD_64 ( + set LIBRARY_HOME=C:\OSGeo4W + set LIB_HM_LIB=lib +) +echo LIBRARY_HOME: %LIBRARY_HOME% +echo LIB_HM_LIB: %LIB_HM_LIB% + +REM rmdir %LIBRARY_HOME% /s /q + +IF NOT EXIST %LIBRARY_HOME% md %LIBRARY_HOME% +IF NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB% md %LIBRARY_HOME%\%LIB_HM_LIB% +IF NOT EXIST %LIBRARY_HOME%\include md %LIBRARY_HOME%\include +IF NOT EXIST %LIBRARY_HOME%\plugins md %LIBRARY_HOME%\plugins + +IF NOT EXIST %DOWNLOAD_HOME% md %DOWNLOAD_HOME% + +:TO_WXWIDGETS_BUILD +echo. +echo ##################################################### +echo # build wxWidgets +echo ##################################################### +echo. +set LIB_NAME=wxWidgets-3.1.0 +set LIB_URL="https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.0/wxWidgets-3.1.0.7z" + +REM # We are only checking for a small subset of wxWidgets libraries +set ALL_EXIST=true +set WX_DLL_PATH=vc_dll +if %GDA_BUILD% == BUILD_32 ( + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\lib\vc_dll\wxmsw31u.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\lib\vc_dll\wxmsw31ud.lib set ALL_EXIST=false + set WX_DLL_PATH=vc_dll +) else ( + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\lib\vc_x64_dll\wxmsw31u.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\lib\vc_x64_dll\wxmsw31ud.lib set ALL_EXIST=false + set WX_DLL_PATH=vc_x64_dll +) +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_WXWIDGETS_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.7z %CURL_EXE% -L %LIB_URL% > %LIB_NAME%.7z + %UNZIP_EXE% %LIB_NAME%.7z -o%DOWNLOAD_HOME%\%LIB_NAME% +) + +cd %DOWNLOAD_HOME%\%LIB_NAME%\build\msw +set WX_HOME=%DOWNLOAD_HOME%\%LIB_NAME% + +if %GDA_BUILD% == BUILD_32 ( + nmake -f makefile.vc UNICODE=1 SHARED=1 RUNTIME_LIBS=dynamic BUILD=debug MONOLITHIC=1 USE_OPENGL=1 USE_POSTSCRIPT=1 + nmake -f makefile.vc UNICODE=1 SHARED=1 RUNTIME_LIBS=dynamic BUILD=release MONOLITHIC=1 USE_OPENGL=1 USE_POSTSCRIPT=1 +) else ( + nmake -f makefile.vc UNICODE=1 SHARED=1 RUNTIME_LIBS=dynamic BUILD=debug MONOLITHIC=1 USE_OPENGL=1 USE_POSTSCRIPT=1 TARGET_CPU=AMD64 + nmake -f makefile.vc UNICODE=1 SHARED=1 RUNTIME_LIBS=dynamic BUILD=release MONOLITHIC=1 USE_OPENGL=1 USE_POSTSCRIPT=1 TARGET_CPU=AMD64 +) +:SKIP_WXWIDGETS_BUILD + +TO_CLAPACK_BUILD +echo. +echo ##################################################### +echo # build CLAPACK +echo ##################################################### +echo. +set LIB_NAME=CLAPACK-3.1.1-VisualStudio +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/CLAPACK-3.1.1-VisualStudio.zip" + +REM # We only test for a small subset of all the CLPACK generated libraries +set ALL_EXIST=true +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\BLAS.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\libf2c.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\clapack.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\BLAS.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\libf2c.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\clapack.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_CLAPACK_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%/%LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +cd %DOWNLOAD_HOME%\%LIB_NAME% + +xcopy /E /Y %BUILD_HOME%\dep\%LIB_NAME% %DOWNLOAD_HOME%\%LIB_NAME% + +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% clapack.sln /t:libf2c /property:Configuration="ReleaseDLL" + %MSBUILD_EXE% clapack.sln /t:BLAS\blas /property:Configuration="ReleaseDLL" + %MSBUILD_EXE% clapack.sln /t:clapack /property:Configuration="ReleaseDLL" + REM %MSBUILD_EXE% clapack.sln /t:libf2c /property:Configuration="Debug" + REM %MSBUILD_EXE% clapack.sln /t:BLAS\blas /property:Configuration="Debug" + REM %MSBUILD_EXE% clapack.sln /t:clapack /property:Configuration="Debug" +) else ( + %MSBUILD_EXE% clapack.sln /t:libf2c /property:Configuration="ReleaseDLL" /p:Platform="x64" + REM %MSBUILD_EXE% clapack.sln /t:tmglib /property:Configuration="ReleaseDLL" + %MSBUILD_EXE% clapack.sln /t:BLAS\blas /property:Configuration="ReleaseDLL" /p:Platform="x64" + %MSBUILD_EXE% clapack.sln /t:clapack /property:Configuration="ReleaseDLL" /p:Platform="x64" +) +REM # We only test for a small subset of all the CLPACK generated libraries +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\BLAS.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\libf2c.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\clapack.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\BLAS.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\libf2c.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\clapack.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_CLAPACK_BUILD + + +:TO_BOOST_BUILD +echo. +echo ##################################################### +echo # build Boost 1.57 +echo ##################################################### +echo. +set LIB_NAME=boost_1_57_0 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/boost_1_57_0.zip" + +set ALL_EXIST=true +if %VS_VER% == 2017 ( + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc140-mt-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc140-mt-gd-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_chrono-vc140-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_thread-vc140-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_system-vc140-mt-1_57.dll set ALL_EXIST=false + +) else ( + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-gd-1_57.lib set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_chrono-vc100-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_thread-vc100-mt-1_57.dll set ALL_EXIST=false + if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_system-vc100-mt-1_57.dll set ALL_EXIST=false +) + +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_BOOST_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) +echo %DOWNLOAD_HOME%\%LIB_NAME% +set BOOST_HOME=%DOWNLOAD_HOME%\%LIB_NAME% +echo BOOST_HOME: %BOOST_HOME% +cd %BOOST_HOME% + +call bootstrap.bat + +if %GDA_BUILD% == BUILD_32 ( + call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=%MSVC++% --build-type=complete stage + call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=%MSVC++% --build-type=complete --debug-symbols=on stage +) else ( + call b2 --with-thread --with-date_time --with-chrono --with-system --toolset=%MSVC++% --build-type=complete architecture=x86 address-model=64 stage +) +cd %BUILD_HOME% + + +:TO_JSON_SPIRIT_BUILD +echo. +echo ##################################################### +echo # build JSON Spirit +echo ##################################################### +echo. +set LIB_NAME=json_spirit_v4.08 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/json_spirit_v4.08.zip" + +set ALL_EXIST=true +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\Release\json_spirit_lib.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\Debug\json_spirit_lib.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_JSON_SPIRIT_BUILD +) +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) +xcopy /Y /E %BUILD_DEP%\json_spirit %DOWNLOAD_HOME%\%LIB_NAME% +cd %LIB_NAME% +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% json.sln /property:Configuration="Release" /p:Platform="Win32" + %MSBUILD_EXE% json.sln /property:Configuration="Debug" /p:Platform="Win32" +) else ( + %MSBUILD_EXE% json.sln /property:Configuration="Release" /p:Platform="x64" + %MSBUILD_EXE% json.sln /property:Configuration="Debug" /p:Platform="x64" +) +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\Release\json_spirit_lib.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\Debug\json_spirit_lib.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_JSON_SPIRIT_BUILD + +goto REAL_END +REM #Create a empty unix header file, just for ref +echo. 2> %LIBRARY_HOME%\include\unistd.h + +:TO_CURL_BUILD +echo. +echo ##################################################### +echo # build cURL (by default /MD) +echo ##################################################### +echo. +set LIB_NAME=curl-7.46.0 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/curl-7.46.0.zip" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl_a.lib set ALL_EXIST=false + +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_CURL_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +cd %DOWNLOAD_HOME%\%LIB_NAME%\winbuild +if %GDA_BUILD% == BUILD_32 ( + rmdir %DOWNLOAD_HOME%\%LIB_NAME%\builds /s /q + nmake -f Makefile.vc mode=static CONFIG_NAME_LIB=curlib + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\lib\libcurl_a.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl_a.lib + + rmdir %DOWNLOAD_HOME%\%LIB_NAME%\builds /s /q + nmake -f Makefile.vc mode=dll CONFIG_NAME_LIB=curlib + + xcopy /E /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\include %LIBRARY_HOME%\include + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\lib\libcurl.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.lib + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\bin\libcurl.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.dll + + +) else ( + rmdir %DOWNLOAD_HOME%\%LIB_NAME%\builds /s /q + nmake -f Makefile.vc mode=static CONFIG_NAME_LIB=curlib MACHINE=x64 + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\lib\libcurl_a.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl_a.lib + + rmdir %DOWNLOAD_HOME%\%LIB_NAME%\builds /s /q + nmake -f Makefile.vc mode=dll CONFIG_NAME_LIB=curlib MACHINE=x64 + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\bin\libcurl.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.dll + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\lib\libcurl.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.lib + xcopy /E /Y %DOWNLOAD_HOME%\%LIB_NAME%\builds\curlib\include %LIBRARY_HOME%\include + +) +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libcurl_a.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_CURL_BUILD + + +:TO_ICONV_BUILD +echo. +echo ##################################################### +echo # build libiconv +echo ##################################################### +echo. +set LIB_NAME=libiconv-1.14 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/libiconv-1.14.tar.gz" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\iconv.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_ICONV_BUILD +) + +cd %DOWNLOAD_HOME% + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.tar.gz %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.tar.gz + %UNZIP_EXE% %LIB_NAME%.tar.gz + %UNZIP_EXE% %LIB_NAME%.tar +) + +xcopy /E /Y %BUILD_DEP%\%LIB_NAME% %DOWNLOAD_HOME%\%LIB_NAME% +cd %DOWNLOAD_HOME%\%LIB_NAME% + +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% libiconv.sln /property:Configuration="Release" /p:Platform="Win32" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\iconv.h %LIBRARY_HOME%\include\iconv.h + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Release_Win32\libiconv.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libiconv.dll + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Release_Win32\libiconv.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libiconv.lib + + %MSBUILD_EXE% libiconv.sln /property:Configuration="Release_static" /p:Platform="Win32" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Release_static_Win32\libiconv.lib %LIBRARY_HOME%\%LIB_HM_LIB%\iconv.lib + +) else ( + + %MSBUILD_EXE% libiconv.sln /property:Configuration="Release" /p:Platform="x64" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\iconv.h %LIBRARY_HOME%\include + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Release_x64\libiconv.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libiconv.dll + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Release_x64\libiconv.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libiconv.lib + + %MSBUILD_EXE% libiconv.sln /property:Configuration="Release_static" /p:Platform="x64" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Release_static_x64\libiconv.lib %LIBRARY_HOME%\%LIB_HM_LIB%\iconv.lib +) +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\iconv.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_ICONV_BUILD + + +:TO_XERCES_BUILD +echo. +echo ##################################################### +echo # build Xerces +echo ##################################################### +echo. +set LIB_NAME=xerces-c-3.1.1 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/xerces-c-3.1.1.zip" +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_static_3.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_XERCES_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +xcopy /E /Y %BUILD_DEP%\%LIB_NAME% %DOWNLOAD_HOME%\%LIB_NAME% + +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% %LIB_NAME%\projects\Win32\VC10\xerces-all\xerces-all.sln /t:XercesLib /property:Configuration="Release" + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\*.h %LIBRARY_HOME%\include + md %LIBRARY_HOME%\include\xercesc + xcopy /E /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\xercesc %LIBRARY_HOME%\include\xercesc + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Build\Win32\VC10\Release\xerces-c_3.lib %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_3.lib + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Build\Win32\VC10\Release\xerces-c_3_1.dll %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_3_1.dll + + %MSBUILD_EXE% %LIB_NAME%\projects\Win32\VC10\xerces-all\xerces-all.sln /t:XercesLib /property:Configuration="Static Release" + copy /Y "%DOWNLOAD_HOME%\%LIB_NAME%\Build\Win32\VC10\Static Release\"xerces-c_static_3.lib %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_static_3.lib + +) else ( + + %MSBUILD_EXE% %LIB_NAME%\projects\Win32\VC10\xerces-all\xerces-all.sln /t:XercesLib /property:Configuration="Release" /p:Platform="x64" + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\*.h %LIBRARY_HOME%\include + md %LIBRARY_HOME%\include\xercesc + xcopy /E /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\xercesc %LIBRARY_HOME%\include\xercesc + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Build\Win64\VC10\Release\xerces-c_3.lib %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_3.lib + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\Build\Win64\VC10\Release\xerces-c_3_1.dll %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_3_1.dll + + %MSBUILD_EXE% %LIB_NAME%\projects\Win32\VC10\xerces-all\xerces-all.sln /t:XercesLib /property:Configuration="Static Release" /p:Platform="x64" + copy /Y "%DOWNLOAD_HOME%\%LIB_NAME%\Build\Win64\VC10\Static Release\"xerces-c_static_3.lib %LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_static_3.lib +) +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\xerces-c_static_3.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_XERCES_BUILD + +:TO_GEOS_BUILD +echo. +echo ##################################################### +echo # build GEOS +echo ##################################################### +echo. +set LIB_NAME=geos-3.3.8 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/geos-3.3.8.tar.bz2" +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\geos.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\geos.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c_i.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\geos_i.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_GEOS_BUILD +) + +cd %DOWNLOAD_HOME% + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.tar.bz2 %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.tar.bz2 + %UNZIP_EXE% %LIB_NAME%.tar.bz2 + %UNZIP_EXE% %LIB_NAME%.tar +) + +cd %LIB_NAME% +call autogen.bat + +REM patch nmake.opt to support nmake with version string 10.00.40219.01 +copy /Y %BUILD_HOME%\dep\%LIB_NAME%\nmake.opt %DOWNLOAD_HOME%\%LIB_NAME%\nmake.opt +nmake -f makefile.vc MSVC_VER=%MSC_VER% BUILD_DEBUG=NO + +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\capi\*.h %LIBRARY_HOME%\include +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\include\*.h %LIBRARY_HOME%\include +md %LIBRARY_HOME%\include\geos +xcopy /E /Y %DOWNLOAD_HOME%\%LIB_NAME%\include\geos %LIBRARY_HOME%\include\geos + +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\geos.dll %LIBRARY_HOME%\%LIB_HM_LIB%\geos.dll +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\geos.lib %LIBRARY_HOME%\%LIB_HM_LIB%\geos.lib +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\geos_c.dll %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\geos_c_i.lib %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c_i.lib +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\geos_i.lib %LIBRARY_HOME%\%LIB_HM_LIB%\geos_i.lib + +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\geos.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\geos.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\geos_c_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\geos_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_GEOS_BUILD + + +:TO_PROJ4_BUILD +echo. +echo ##################################################### +echo # build PROJ4 (todo , MD,MT nmake.opt) +echo ##################################################### +echo. +set LIB_NAME=proj-4.8.0 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/proj-4.8.0.zip" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\proj.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\proj.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\proj_i.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_PROJ4_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +cd %LIB_NAME% +nmake -f makefile.vc + +set PROJ_INCLUDE=%DOWNLOAD_HOME%\%LIB_NAME%\src + +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\*.h %LIBRARY_HOME%\include +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\*.lib %LIBRARY_HOME%\%LIB_HM_LIB% +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\*.dll %LIBRARY_HOME%\%LIB_HM_LIB% + +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\proj.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\proj.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\proj_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_PROJ4_BUILD + + +:TO_FREEXL_BUILD +echo. +echo ##################################################### +echo # build freeXL +echo ##################################################### +echo. +set LIB_NAME=freexl-1.0.0e +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/freexl-1.0.0e.zip" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\freexl.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\freexl.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\freexl_i.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_FREEXL_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +cd %LIB_NAME% + +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\headers\*.h %LIBRARY_HOME%\include + +nmake -f makefile.vc OPTFLAGS="/MD /DDLL_EXPORT -DUSING_STATIC_LIBICONV -I%LIBRARY_HOME%\include" OPTLKFLAG="%LIBRARY_HOME%\%LIB_HM_LIB%\iconv.lib" + +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\freexl_i.lib %LIBRARY_HOME%\%LIB_HM_LIB%\freexl_i.lib +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\freexl.lib %LIBRARY_HOME%\%LIB_HM_LIB%\freexl.lib +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\freexl.dll %LIBRARY_HOME%\%LIB_HM_LIB%\freexl.dll + +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\freexl.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\freexl.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\freexl_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_FREEXL_BUILD + + +:TO_SQLITE_BUILD +echo. +echo ##################################################### +echo # build SQLite3 +echo ##################################################### +echo. +set LIB_NAME=sqlite-amalgamation-3071700 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/sqlite-amalgamation-3071700.zip" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite3_i.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\sqlited.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_SQLITE_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +xcopy /Y /E %BUILD_DEP%\%LIB_NAME% %DOWNLOAD_HOME%\%LIB_NAME% +cd %DOWNLOAD_HOME%\%LIB_NAME%\sqlite + +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% sqlite.sln /property:Configuration="Release_dll" + + REM lib /def:sqlite\sqlite3.def + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\Release_dll\sqlite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite3_i.lib + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\Release_dll\sqlite.dll %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.dll + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\*.h %LIBRARY_HOME%\include + + %MSBUILD_EXE% sqlite.sln /property:Configuration="Release" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\Release\sqlite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.lib + + %MSBUILD_EXE% sqlite.sln /property:Configuration="Debug" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\Debug\sqlite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\sqlited.lib + +) else ( + %MSBUILD_EXE% sqlite.sln /property:Configuration="Release_dll" /p:Platform="x64" + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\x64\Release_dll\sqlite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite3_i.lib + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\x64\Release_dll\sqlite.dll %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.dll + + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\*.h %LIBRARY_HOME%\include + + %MSBUILD_EXE% sqlite.sln /property:Configuration="Release" /p:Platform="x64" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\x64\Release\sqlite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.lib + + %MSBUILD_EXE% sqlite.sln /property:Configuration="Debug" /p:Platform="x64" + copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\sqlite\x64\Debug\sqlite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\sqlited.lib +) +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\sqlite3_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\sqlited.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_SQLITE_BUILD + + +:TO_SPATIALITE_BUILD +echo. +echo ##################################################### +echo # build SpatiaLite +echo ##################################################### +echo. +set LIB_NAME=libspatialite-4.0.0 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/libspatialite-4.0.0.zip" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite_i.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_SPATIALITE_BUILD +) + +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +if %GDA_BUILD% == BUILD_32 ( + copy /Y %BUILD_DEP%\%LIB_NAME%\makefile.vc %DOWNLOAD_HOME%\%LIB_NAME%\makefile.vc +) else ( + copy /Y %BUILD_DEP%\%LIB_NAME%\makefile64.vc %DOWNLOAD_HOME%\%LIB_NAME%\makefile.vc +) + +cd %DOWNLOAD_HOME%\%LIB_NAME% +nmake -f makefile.vc + +md %LIBRARY_HOME%\include\spatialite +xcopy /Y /E %DOWNLOAD_HOME%\%LIB_NAME%\src\headers\spatialite %LIBRARY_HOME%\include\spatialite +copy /Y %LIBRARY_HOME%\include\sqlite3.h %LIBRARY_HOME%\include\spatialite\sqlite3.h +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\src\headers\*.h %LIBRARY_HOME%\include +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\spatialite.dll %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.dll +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\spatialite_i.lib %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite_i.lib +copy /Y %DOWNLOAD_HOME%\%LIB_NAME%\spatialite.lib %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.lib + +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\spatialite_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_SPATIALITE_BUILD + + +:TO_POSTGRESQL_BUILD +echo. +echo ##################################################### +echo # build PostgreSQL +echo ##################################################### +echo. +set LIB_NAME=postgresql-9.2.4 +if %GDA_BUILD% == BUILD_32 ( + set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/postgresql-9.2.4-1-windows-binaries.zip" +) else ( + set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/postgresql-9.2.4-1-windows-x64-binaries.zip" +) + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_POSTGRESQL_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%\pgsql ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +if %GDA_BUILD% == BUILD_32 ( + copy /Y %DOWNLOAD_HOME%\pgsql\bin\libintl.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libintl.dll + copy /Y %DOWNLOAD_HOME%\pgsql\bin\libeay32.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libeay32.dll + copy /Y %DOWNLOAD_HOME%\pgsql\bin\ssleay32.dll %LIBRARY_HOME%\%LIB_HM_LIB%\ssleay32.dll + copy /Y %DOWNLOAD_HOME%\pgsql\lib\libpq.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.lib + copy /Y %DOWNLOAD_HOME%\pgsql\lib\libpq.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.dll + xcopy /Y /E %DOWNLOAD_HOME%\pgsql\include %LIBRARY_HOME%\include +) else ( + + copy /Y %DOWNLOAD_HOME%\pgsql\bin\libintl-8.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libintl-8.dll + copy /Y %DOWNLOAD_HOME%\pgsql\bin\libeay32.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libeay32.dll + copy /Y %DOWNLOAD_HOME%\pgsql\bin\ssleay32.dll %LIBRARY_HOME%\%LIB_HM_LIB%\ssleay32.dll + copy /Y %DOWNLOAD_HOME%\pgsql\lib\libpq.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.lib + copy /Y %DOWNLOAD_HOME%\pgsql\lib\libpq.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.dll + xcopy /Y /E %DOWNLOAD_HOME%\pgsql\include %LIBRARY_HOME%\include +) +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libpq.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libpq.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_POSTGRESQL_BUILD + + +:TO_MYSQL_BUILD +echo. +echo ##################################################### +echo # build MySQL +echo ##################################################### +echo. +if %GDA_BUILD% == BUILD_32 ( + set LIB_NAME=mysql-5.6.16-win32 + set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/mysql-5.6.14-win32.zip" +) else ( + set LIB_NAME=mysql-5.6.16-winx64 + set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/mysql-5.6.14-winx64.zip" +) + +REM "The downloaded DLLs are /MT builds, which can't be used. I think build " +REM "MysQL on windows is pretty complex, so I just did that once, and copy the DLLs" +REM "to plugins directory for our usage." +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\mysqlclient.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_MYSQL_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%/%LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +if %GDA_BUILD% == BUILD_32 ( + xcopy /Y /E %BUILD_HOME%\dep\mysql\my_default.h %DOWNLOAD_HOME%\%LIB_NAME%\include + copy /Y %BUILD_HOME%\plugins\mysqlclient.lib %LIBRARY_HOME%\%LIB_HM_LIB%\mysqlclient.lib + REM xcopy /Y /E %BUILD_HOME%\plugins\libmysql.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.lib + copy /Y %BUILD_HOME%\plugins\libmysql.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.dll +) else ( + xcopy /Y /E %BUILD_HOME%\dep\mysql\my_default.h %DOWNLOAD_HOME%\%LIB_NAME%\include + copy /Y %BUILD_HOME%\plugins\64\mysqlclient.lib %LIBRARY_HOME%\%LIB_HM_LIB%\mysqlclient.lib + REM xcopy /Y /E %BUILD_HOME%\plugins\x64\libmysql.lib %LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.lib + copy /Y %BUILD_HOME%\plugins\64\libmysql.dll %LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.dll +) +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +REM set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\libmysql.lib +REM IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\mysqlclient.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_MYSQL_BUILD + + +:TO_CLAPACK_BUILD +echo. +echo ##################################################### +echo # build CLAPACK +echo ##################################################### +echo. +set LIB_NAME=CLAPACK-3.1.1-VisualStudio +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/CLAPACK-3.1.1-VisualStudio.zip" + +REM # We only test for a small subset of all the CLPACK generated libraries +set ALL_EXIST=true +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\BLAS.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\libf2c.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\clapack.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\BLAS.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\libf2c.lib set ALL_EXIST=false +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\clapack.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_CLAPACK_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%/%LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip +) + +cd %DOWNLOAD_HOME%\%LIB_NAME% + +xcopy /E /Y %BUILD_HOME%\dep\%LIB_NAME% %DOWNLOAD_HOME%\%LIB_NAME% + +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% clapack.sln /t:libf2c /property:Configuration="ReleaseDLL" + %MSBUILD_EXE% clapack.sln /t:BLAS\blas /property:Configuration="ReleaseDLL" + %MSBUILD_EXE% clapack.sln /t:clapack /property:Configuration="ReleaseDLL" + REM %MSBUILD_EXE% clapack.sln /t:libf2c /property:Configuration="Debug" + REM %MSBUILD_EXE% clapack.sln /t:BLAS\blas /property:Configuration="Debug" + REM %MSBUILD_EXE% clapack.sln /t:clapack /property:Configuration="Debug" +) else ( + %MSBUILD_EXE% clapack.sln /t:libf2c /property:Configuration="ReleaseDLL" /p:Platform="x64" + REM %MSBUILD_EXE% clapack.sln /t:tmglib /property:Configuration="ReleaseDLL" + %MSBUILD_EXE% clapack.sln /t:BLAS\blas /property:Configuration="ReleaseDLL" /p:Platform="x64" + %MSBUILD_EXE% clapack.sln /t:clapack /property:Configuration="ReleaseDLL" /p:Platform="x64" +) +REM # We only test for a small subset of all the CLPACK generated libraries +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\BLAS.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\libf2c.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\Win32\clapack.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\BLAS.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\libf2c.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\LIB\x64\clapack.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_CLAPACK_BUILD + +:TO_EXPAT_BUILD +echo. +echo ##################################################### +echo # build EXPAT +echo ##################################################### +echo. +set LIB_NAME=expat-2.1.0 +set LIB_URL="https://s3.us-east-2.amazonaws.com/geodabuild/expat-2.1.0.tar.gz" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\expat.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_EXPAT_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%/%LIB_NAME% ( + %CURL_EXE% -k -# %LIB_URL% > %LIB_NAME%.tar.gz + %UNZIP_EXE% %LIB_NAME%.tar.gz + %UNZIP_EXE% %LIB_NAME%.tar +) + +cd %LIB_NAME% + +md build +cd build +if %GDA_BUILD% == BUILD_32 ( + cmake .. -G "Visual Studio 10" + %MSBUILD_EXE% expat.sln /t:ALL_BUILD /property:Configuration="Release" /p:Platform="Win32" +) else ( + cmake .. -G "Visual Studio 10 Win64" + %MSBUILD_EXE% expat.sln /t:ALL_BUILD /property:Configuration="Release" /p:Platform="x64" +) +copy /Y Release\expat.* %LIBRARY_HOME%\lib +copy /Y ..\lib\*.h %LIBRARY_HOME%\include + +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\expat.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_EXPAT_BUILD + +:TO_GDAL_OGR_BUILD +echo. +echo ##################################################### +echo # build GDAL/OGR +echo ##################################################### +echo. +set LIB_NAME=GeoDa17Merge +set LIB_URL="https://codeload.github.com/lixun910/gdal/zip/GeoDa17Merge" + +set ALL_EXIST=true +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\gdal.lib set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\gdal_geoda20.dll set ALL_EXIST=false +if NOT EXIST %LIBRARY_HOME%\%LIB_HM_LIB%\gdal_i.lib set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_GDAL_OGR_BUILD +) + +cd %DOWNLOAD_HOME% + +IF NOT EXIST %DOWNLOAD_HOME%/gdal-%LIB_NAME% ( + %CURL_EXE% -k -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip + move /Y gdal-%LIB_NAME%/gdal gdal +) + +cd gdal +if %GDA_BUILD% == BUILD_32 ( + copy /Y %BUILD_HOME%\dep\gdal-1.9.2\nmake.opt nmake.opt +) else ( + copy /Y %BUILD_HOME%\dep\gdal-1.9.2\nmake64.opt nmake.opt +) +copy /Y %BUILD_HOME%\dep\gdal-1.9.2\port\cpl_config.h port\cpl_config.h + +nmake -f makefile.vc MSVC_VER=%MSC_VER% +REM nmake -f makefile.vc MSVC_VER=%MSC_VER% DEBUG=1 + +copy /Y %DOWNLOAD_HOME%\gdal\gcore\*.h %LIBRARY_HOME%\include +copy /Y %DOWNLOAD_HOME%\gdal\port\*.h %LIBRARY_HOME%\include +copy /Y %DOWNLOAD_HOME%\gdal\ogr\*.h %LIBRARY_HOME%\include +copy /Y %DOWNLOAD_HOME%\gdal\ogr\ogrsf_frmts\*.h %LIBRARY_HOME%\include + +copy /Y %DOWNLOAD_HOME%\gdal\gdal_geoda20.dll %LIBRARY_HOME%\%LIB_HM_LIB%\gdal_geoda20.dll +copy /Y %DOWNLOAD_HOME%\gdal\gdal_i.lib %LIBRARY_HOME%\%LIB_HM_LIB%\gdal_i.lib +copy /Y %DOWNLOAD_HOME%\gdal\gdal.lib %LIBRARY_HOME%\%LIB_HM_LIB%\gdal.lib + +echo Note: building of OGR plugins skipped by default. See readme.txt +echo for information on how to build plugins. +REM call build_ogr_plugins.bat + +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\gdal.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\gdal_geoda20.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%LIBRARY_HOME%\%LIB_HM_LIB%\gdal_i.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_GDAL_OGR_BUILD + + +echo ############################################### +echo # for visual studio 2017 +echo edit project-config.jam +echo (content) +echo import option; +echo using msvc : 14.0 "c:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe"; +echo option.set keep-going : false ; +echo +echo Then, run again +echo ############################################### + +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-1_57.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\libboost_thread-vc100-mt-gd-1_57.lib +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_chrono-vc100-mt-1_57.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_thread-vc100-mt-1_57.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\stage\lib\boost_system-vc100-mt-1_57.dll +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_BOOST_BUILD + + + + +:TO_EIGEN3_BUILD +echo. +echo ##################################################### +echo # build Eigen3 +echo ##################################################### +echo. +set LIB_NAME=eigen3 +set LIB_URL="https://bitbucket.org/eigen/eigen/get/3.3.3.zip" + +set ALL_EXIST=true +if NOT EXIST %DOWNLOAD_HOME%\%LIB_NAME% set ALL_EXIST=false +if %ALL_EXIST% == true ( + echo All %LIB_NAME% library targets exist, skipping build + goto SKIP_EIGEN3_BUILD +) +cd %DOWNLOAD_HOME% +IF NOT EXIST %LIB_NAME% ( + IF NOT EXIST %LIB_NAME%.zip %CURL_EXE% -# %LIB_URL% > %LIB_NAME%.zip + %UNZIP_EXE% %LIB_NAME%.zip + move eigen-eigen-* eigen3 +) + +set CHK_LIB=%DOWNLOAD_HOME%\%LIB_NAME%\Eigen +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +:SKIP_EIGEN3_BUILD + +:TO_VISUAL_STUDIO_SETUP_BUILD +echo. +echo ##################################################### +echo # Copy over some DLLs to Debug/Release dirs for +echo # convenience when using Visual Studio +echo # to build/debug interactively. +echo ##################################################### +echo. +set LIB_NAME=visual_studio_setup +cd %BUILD_HOME% + +IF NOT EXIST %BUILD_HOME%\Debug md %BUILD_HOME%\Debug +IF NOT EXIST %BUILD_HOME%\Release md %BUILD_HOME%\Release + +copy /Y ..\CommonDistFiles\cache.sqlite Debug\. +copy /Y ..\CommonDistFiles\geoda_prefs.sqlite Debug\. +copy /Y ..\CommonDistFiles\geoda_prefs.json Debug\. +xcopy /I /S /E /Y ..\CommonDistFiles\web_plugins Debug\web_plugins +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\expat.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\gdal_geoda20.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\ssleay32.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libeay32.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\proj.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\freexl.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll Debug\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.dll Debug\. +if %GDA_BUILD% == BUILD_32 ( + copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libintl.dll Debug\. +) else ( + copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libintl-8.dll Debug\. +) +copy /Y temp\wxWidgets-3.1.0\lib\vc_x64_dll\wxmsw310ud_vc_custom.dll Debug\. +copy /Y temp\wxWidgets-3.1.0\lib\vc_x64_dll\wxmsw310ud_gl_vc_custom.dll Debug\. +copy /Y temp\boost_1_57_0\stage\lib\boost_chrono-vc100-mt-1_57.dll Debug\. +copy /Y temp\boost_1_57_0\stage\lib\boost_thread-vc100-mt-1_57.dll Debug\. +copy /Y temp\boost_1_57_0\stage\lib\boost_system-vc100-mt-1_57.dll Debug\. + +copy /Y ..\CommonDistFiles\cache.sqlite Release\. +copy /Y ..\CommonDistFiles\geoda_prefs.sqlite Release\. +copy /Y ..\CommonDistFiles\geoda_prefs.json Release\. +xcopy /I /S /E /Y ..\CommonDistFiles\web_plugins Release\web_plugins +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\expat.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\gdal_geoda20.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libpq.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\ssleay32.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libeay32.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libcurl.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\spatialite.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\proj.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\freexl.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\geos_c.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\sqlite.dll Release\. +if %GDA_BUILD% == BUILD_32 ( + copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libintl.dll Release\. +) else ( + copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\libintl-8.dll Release\. +) +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\wxmsw31u_vc_custom.dll Release\. +copy /Y %LIBRARY_HOME%\%LIB_HM_LIB%\wxmsw31u_gl_vc_custom.dll Release\. +copy /Y temp\boost_1_57_0\stage\lib\boost_chrono-vc100-mt-1_57.dll Release\. +copy /Y temp\boost_1_57_0\stage\lib\boost_thread-vc100-mt-1_57.dll Release\. +copy /Y temp\boost_1_57_0\stage\lib\boost_system-vc100-mt-1_57.dll Release\. + +md Release\basemap_cache +md Debug\basemap_cache +:SKIP_VISUAL_STUDIO_SETUP_BUILD + + +:TO_GEODA_BUILD +echo. +echo ##################################################### +echo # build GeoDa %GDA_VERSION% +echo ##################################################### +echo. +set LIB_NAME=geoda_build +cd %BUILD_HOME% + +IF EXIST %BUILD_HOME%\Release\GeoDa.lib del %BUILD_HOME%\Release\GeoDa.lib +IF EXIST %BUILD_HOME%\Release\GeoDa.exp del %BUILD_HOME%\Release\GeoDa.exp +IF EXIST %BUILD_HOME%\Release\GeoDa.exp del %BUILD_HOME%\Release\GeoDa.exe +IF EXIST %BUILD_HOME%\Debug\GeoDa.lib del %BUILD_HOME%\Debug\GeoDa.lib +IF EXIST %BUILD_HOME%\Debug\GeoDa.exp del %BUILD_HOME%\Debug\GeoDa.exp +IF EXIST %BUILD_HOME%\Debug\GeoDa.exp del %BUILD_HOME%\Debug\GeoDa.exe +if %GDA_BUILD% == BUILD_32 ( + %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Release" /p:Platform="Win32" + %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Debug" /p:Platform="Win32" +) else ( + if %VS_VER% == 2017 ( + REM %MSBUILD_EXE% GeoDa.vs2017.sln /t:GeoDa /property:Configuration="Release" /p:Platform="x64" + %MSBUILD_EXE% GeoDa.vs2017.sln /t:GeoDa /property:Configuration="Debug2017" /p:Platform="x64" + ) else ( + %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Release" /p:Platform="x64" + %MSBUILD_EXE% GeoDa.vs2010.sln /t:GeoDa /property:Configuration="Debug" /p:Platform="x64" + ) +) +set CHK_LIB=%BUILD_HOME%\Release\GeoDa.lib +REM IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%BUILD_HOME%\Release\GeoDa.exp +REM IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%BUILD_HOME%\Release\GeoDa.exe +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%BUILD_HOME%\Debug\GeoDa.lib +REM IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%BUILD_HOME%\Debug\GeoDa.exp +REM IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +set CHK_LIB=%BUILD_HOME%\Debug\GeoDa.exe +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END + +:SKIP_GEODA_BUILD + +if %VS_VER% == 2017 ( + goto REAL_END +) + +:TO_PACKAGE_BUILD +echo. +echo ##################################################### +echo # Creating GeoDa %GDA_VERSION% installer... +echo ##################################################### +echo. +set LIB_NAME=geoda_package +cd %BUILD_HOME% + +set INNO_EXE=not_found +IF EXIST "\Program Files (x86)\Inno Setup 5\ISCC.exe" ( + set INNO_EXE="\Program Files (x86)\Inno Setup 5\ISCC.exe" +) +IF EXIST "\Program Files\Inno Setup 5\ISCC.exe" ( + set INNO_EXE="\Program Files\Inno Setup 5\ISCC.exe" +) +if %INNO_EXE% == not_found ( + echo Could not find location of Inno 5 command line installer ISCC.exe. Please install Inno 5. + goto BUILD_END +) + +IF EXIST %BUILD_HOME%\geoda_setup.exe del %BUILD_HOME%\geoda_setup.exe +if %GDA_BUILD% == BUILD_32 ( + %INNO_EXE% /q installer\32bit\GeoDa.iss +) else ( + %INNO_EXE% /q installer\64bit\GeoDa.iss +) +set CHK_LIB=%BUILD_HOME%\geoda_setup.exe +IF NOT EXIST %CHK_LIB% goto MISSING_TARGET_END +if %GDA_BUILD% == BUILD_32 ( + move /Y %BUILD_HOME%\geoda_setup.exe %BUILD_HOME%\GeoDa-%GDA_VERSION%-Windows-32bit.exe + move %BUILD_HOME%\GeoDa-%GDA_VERSION%-Windows-32bit.exe \\Mac\Dropbox +) else ( + move /Y %BUILD_HOME%\geoda_setup.exe %BUILD_HOME%\GeoDa-%GDA_VERSION%-Windows-64bit.exe + move %BUILD_HOME%\GeoDa-%GDA_VERSION%-Windows-64bit.exe \\Mac\Dropbox +) +:SKIP_PACKAGE_BUILD + +echo Finished building and packaging GeoDa %GDA_VERSION% + +:BUILD_END +goto REAL_END + +:MISSING_TARGET_END +cd %BUILD_HOME% +echo. +echo Build stopped while building %LIB_NAME% due to +echo missing target: %CHK_LIB% +echo. + +:REAL_END diff --git a/DataViewer/MergeTableDlg.cpp b/DataViewer/MergeTableDlg.cpp index 807220109..c31a23289 100644 --- a/DataViewer/MergeTableDlg.cpp +++ b/DataViewer/MergeTableDlg.cpp @@ -66,7 +66,8 @@ MergeTableDlg::MergeTableDlg(wxWindow* parent, Project* _project_s, const wxPoin { wxLogMessage("Open MergeTableDlg."); SetParent(parent); - + + m_wx_encoding = NULL; //table_int->FillColIdMap(col_id_map); table_int = project_s->GetTableInt(), frames_manager = project_s->GetFramesManager(), @@ -87,7 +88,9 @@ MergeTableDlg::~MergeTableDlg() delete merge_datasource_proxy; merge_datasource_proxy = NULL; } - + if (m_wx_encoding) { + delete m_wx_encoding; + } frames_manager->removeObserver(this); } @@ -204,7 +207,10 @@ void MergeTableDlg::OnOpenClick( wxCommandEvent& ev ) int dialog_type = 1; // no gda is allowed bool showRecentPanel = false; - ConnectDatasourceDlg connect_dlg(this, pos, wxDefaultSize, showCsvConfigure, showRecentPanel, dialog_type); + ConnectDatasourceDlg connect_dlg(this, pos, wxDefaultSize, + showCsvConfigure, + showRecentPanel, + dialog_type); if (connect_dlg.ShowModal() != wxID_OK) { return; @@ -213,6 +219,10 @@ void MergeTableDlg::OnOpenClick( wxCommandEvent& ev ) wxString proj_title = connect_dlg.GetProjectTitle(); wxString layer_name = connect_dlg.GetLayerName(); IDataSource* datasource = connect_dlg.GetDataSource(); + m_wx_encoding = connect_dlg.GetEncoding(); + if (m_wx_encoding) { + m_wx_encoding = new wxCSConv(*m_wx_encoding); + } wxString datasource_name = datasource->GetOGRConnectStr(); GdaConst::DataSourceType ds_type = datasource->GetType(); @@ -417,7 +427,9 @@ void MergeTableDlg::OnMergeClick( wxCommandEvent& ev ) ev.Skip(); } -OGRColumn* MergeTableDlg::CreateNewOGRColumn(int new_rows, TableInterface* table_int, vector& undefs, int idx, int t) +OGRColumn* MergeTableDlg:: +CreateNewOGRColumn(int new_rows, TableInterface* table_int, + vector& undefs, int idx, int t) { wxString f_name = table_int->GetColName(idx, t); int f_length = table_int->GetColLength(idx, t); @@ -447,7 +459,11 @@ OGRColumn* MergeTableDlg::CreateNewOGRColumn(int new_rows, TableInterface* table return _col; } -OGRColumn* MergeTableDlg::CreateNewOGRColumn(int new_rows, OGRLayerProxy* layer_proxy, vector& undefs, wxString f_name, map& idx2_dict) +OGRColumn* MergeTableDlg::CreateNewOGRColumn(int new_rows, + OGRLayerProxy* layer_proxy, + vector& undefs, + wxString f_name, + map& idx2_dict) { int col_idx = layer_proxy->GetFieldPos(f_name); GdaConst::FieldType f_type = layer_proxy->GetFieldType(col_idx); @@ -476,14 +492,15 @@ OGRColumn* MergeTableDlg::CreateNewOGRColumn(int new_rows, OGRLayerProxy* layer_ _col = new OGRColumnString(f_name, f_length, f_decimal, new_rows); _col->SetUndefinedMarkers(undefs); for (int i=0; iGetValueAt(i, col_idx); + wxString val = layer_proxy->GetValueAt(i, col_idx, m_wx_encoding); _col->SetValueAt(idx2_dict[i], val); } } return _col; } -void MergeTableDlg::UpdateOGRColumn(OGRColumn* _col, OGRLayerProxy* layer_proxy, wxString f_name, map& idx2_dict) +void MergeTableDlg::UpdateOGRColumn(OGRColumn* _col, OGRLayerProxy* layer_proxy, + wxString f_name, map& idx2_dict) { int col_idx = layer_proxy->GetFieldPos(f_name); GdaConst::FieldType f_type = layer_proxy->GetFieldType(col_idx); @@ -505,7 +522,7 @@ void MergeTableDlg::UpdateOGRColumn(OGRColumn* _col, OGRLayerProxy* layer_proxy, } } else { for (int i=0; iGetValueAt(i, col_idx); + wxString val = layer_proxy->GetValueAt(i, col_idx, m_wx_encoding); _col->SetValueAt(idx2_dict[i], val); } } @@ -569,8 +586,7 @@ void MergeTableDlg::OuterJoinMerge() int n_merge_rows = merge_layer_proxy->GetNumRecords(); map key2_map; for (int i=0; i < n_merge_rows; i++) { - wxString tmp; - tmp << merge_layer_proxy->GetValueAt(i, col2_id); + wxString tmp = merge_layer_proxy->GetValueAt(i, col2_id, m_wx_encoding); key2_vec.push_back(tmp); } if (CheckKeys(key2_name, key2_vec, key2_map) == false) @@ -751,8 +767,10 @@ void MergeTableDlg::LeftJoinMerge() key1_vec.push_back(tmp); } } - if (CheckKeys(key1_name, key1_vec, key1_map) == false) + + if (CheckKeys(key1_name, key1_vec, key1_map) == false) { return; + } // get and check keys from import table int key2_id = m_import_key->GetSelection(); @@ -762,11 +780,12 @@ void MergeTableDlg::LeftJoinMerge() vector key2_vec; map key2_map; for (int i=0; i < n_merge_rows; i++) { - key2_vec.push_back(merge_layer_proxy->GetValueAt(i, col2_id)); + key2_vec.push_back(merge_layer_proxy->GetValueAt(i, col2_id, m_wx_encoding)); } - if (CheckKeys(key2_name, key2_vec, key2_map) == false) + if (CheckKeys(key2_name, key2_vec, key2_map) == false) { return; - + } + // make sure key1 <= key2, and store their mappings int n_matches = 0; map::iterator key1_it, key2_it; @@ -842,7 +861,7 @@ void MergeTableDlg::AppendNewField(wxString field_name, data[i] = wxEmptyString; undefs[i] = true; } else { - data[i] = wxString(merge_layer_proxy->GetValueAt(import_rid,fid)); + data[i] = wxString(merge_layer_proxy->GetValueAt(import_rid,fid,m_wx_encoding)); undefs[i] = false; } } else { diff --git a/DataViewer/MergeTableDlg.h b/DataViewer/MergeTableDlg.h index 4dea261d7..0af7ba45b 100644 --- a/DataViewer/MergeTableDlg.h +++ b/DataViewer/MergeTableDlg.h @@ -99,6 +99,8 @@ class MergeTableDlg: public wxDialog, public FramesManagerObserver private: FramesManager* frames_manager; + + wxCSConv* m_wx_encoding; std::map dedup_to_id; std::set dups; diff --git a/DataViewer/OGRColumn.cpp b/DataViewer/OGRColumn.cpp index bfcb98130..c34e1a83d 100644 --- a/DataViewer/OGRColumn.cpp +++ b/DataViewer/OGRColumn.cpp @@ -207,7 +207,7 @@ void OGRColumn::FillData(vector& data) } -void OGRColumn::FillData(vector& data) +void OGRColumn::FillData(vector& data, wxCSConv* m_wx_encoding) { wxString msg = "Internal error: FillData(wxString) not implemented."; throw GdaException(msg.mb_str()); @@ -235,7 +235,8 @@ void OGRColumn::FillData(vector &data, } void OGRColumn::FillData(vector &data, - vector& undef_markers_) + vector& undef_markers_, + wxCSConv* m_wx_encoding) { FillData(data); undef_markers_ = undef_markers; @@ -358,7 +359,7 @@ void OGRColumnInteger::FillData(vector &data) } // Return this column to a vector of wxString -void OGRColumnInteger::FillData(vector &data) +void OGRColumnInteger::FillData(vector &data, wxCSConv* m_wx_encoding) { if (is_new) { for (int i=0; i &data) } } -void OGRColumnDouble::FillData(vector &data) +void OGRColumnDouble::FillData(vector &data, wxCSConv* m_wx_encoding) { if (is_new) { for (int i=0; i &data) } // This column -> vector -void OGRColumnString::FillData(vector &data) +void OGRColumnString::FillData(vector &data, wxCSConv* m_wx_encoding) { if (is_new) { for (int i=0; i &data) } else { int col_idx = GetColIndex(); for (int i=0; idata[i]->GetFieldAsString(col_idx)); + const char* val = ogr_layer->data[i]->GetFieldAsString(col_idx); + if ( m_wx_encoding == NULL ) data[i] = wxString(val); + else data[i] = wxString(val, *m_wx_encoding); } } } @@ -1029,7 +1032,9 @@ wxString OGRColumnString::GetValueAt(int row_idx, int disp_decimals, return wxEmptyString; if (is_new) { - return new_data[row_idx]; + // should be already encoded in String, so return it directly + wxString rtn = new_data[row_idx]; + return rtn; } else { int col_idx = GetColIndex(); @@ -1037,7 +1042,7 @@ wxString OGRColumnString::GetValueAt(int row_idx, int disp_decimals, return wxEmptyString; const char* val = ogr_layer->data[row_idx]->GetFieldAsString(col_idx); - + wxString rtn; if (m_wx_encoding == NULL) rtn = wxString(val); @@ -1055,7 +1060,6 @@ void OGRColumnString::SetValueAt(int row_idx, const wxString &value) return; } - if (is_new) { new_data[row_idx] = value; } else { @@ -1157,7 +1161,7 @@ void OGRColumnDate::FillData(vector &data) } } -void OGRColumnDate::FillData(vector &data) +void OGRColumnDate::FillData(vector &data, wxCSConv* m_wx_encoding) { int year, month, day, hour, minute, second, tzflag; if (is_new) { diff --git a/DataViewer/OGRColumn.h b/DataViewer/OGRColumn.h index a480aae04..d4b21712f 100644 --- a/DataViewer/OGRColumn.h +++ b/DataViewer/OGRColumn.h @@ -125,7 +125,8 @@ class OGRColumn // interfaces for TableInterface virtual void FillData(vector& data); virtual void FillData(vector& data); - virtual void FillData(vector& data); + virtual void FillData(vector& data, + wxCSConv* m_wx_encoding = NULL); virtual void FillData(vector& data); virtual void FillData(vector& data, @@ -133,7 +134,8 @@ class OGRColumn virtual void FillData(vector& data, vector& undef_markers); virtual void FillData(vector& datam, - vector& undef_markers); + vector& undef_markers, + wxCSConv* m_wx_encoding = NULL); virtual void FillData(vector& datam, vector& undef_markers); @@ -170,7 +172,7 @@ class OGRColumnInteger : public OGRColumn virtual void FillData(vector& data); - virtual void FillData(vector& data); + virtual void FillData(vector& data, wxCSConv* m_wx_encoding=NULL); virtual void UpdateData(const vector& data); @@ -212,7 +214,7 @@ class OGRColumnDouble : public OGRColumn virtual void FillData(vector& data); - virtual void FillData(vector& data); + virtual void FillData(vector& data, wxCSConv* m_wx_encodin = NULL); virtual void UpdateData(const vector& data); @@ -256,7 +258,7 @@ class OGRColumnString : public OGRColumn virtual void FillData(vector& data); - virtual void FillData(vector& data); + virtual void FillData(vector& data, wxCSConv* m_wx_encodin = NULL); virtual void FillData(vector& data); @@ -271,7 +273,7 @@ class OGRColumnString : public OGRColumn virtual wxString GetValueAt(int row_idx, int disp_decimals=0, wxCSConv* m_wx_encoding=NULL); - + virtual void SetValueAt(int row_idx, const wxString& value); }; @@ -292,7 +294,7 @@ class OGRColumnDate: public OGRColumn virtual void FillData(vector& data); - virtual void FillData(vector& data); + virtual void FillData(vector& data, wxCSConv* m_wx_encoding = NULL); virtual void FillData(vector& data); diff --git a/DataViewer/OGRTable.cpp b/DataViewer/OGRTable.cpp index 802a4b2d3..c81816906 100644 --- a/DataViewer/OGRTable.cpp +++ b/DataViewer/OGRTable.cpp @@ -60,9 +60,11 @@ OGRTable::OGRTable(OGRLayerProxy* _ogr_layer, ogr_layer(_ogr_layer), var_order(var_order_ptree), datasource_type(ds_type) { wxLogMessage("Entering OGRTable::OGRTable"); - encoding_type = wxFONTENCODING_UTF8; - m_wx_encoding = new wxCSConv(wxFONTENCODING_UTF8); - + // default UTF-8, use can change it in menu: Table->Encoding + encoding_type = wxFONTENCODING_SYSTEM; + //m_wx_encoding = new wxCSConv(wxFONTENCODING_UTF8); + m_wx_encoding = NULL; + for (size_t i=0; ifields.size(); ++i) { AddOGRColumn(ogr_layer, i); } @@ -85,6 +87,7 @@ OGRTable::~OGRTable() if (m_wx_encoding) { delete m_wx_encoding; } + encoding_type = wxFONTENCODING_SYSTEM; wxLogMessage("In OGRTable::~OGRTable"); } @@ -565,6 +568,7 @@ int OGRTable::GetFirstNumericCol() return i; } } + return 0; } /** Return the Group column name. */ @@ -747,7 +751,7 @@ void OGRTable::GetColData(int col, s_array_type& data) if (ftr_c[t] != -1) { int col_idx = ftr_c[t]; std::vector d(rows); - columns[col_idx]->FillData(d); + columns[col_idx]->FillData(d, m_wx_encoding); for (size_t i=0; i& data) OGRColumn* ogr_col = columns[col]; if (ogr_col == NULL) return; data.resize(rows); - ogr_col->FillData(data); + ogr_col->FillData(data, m_wx_encoding); } void OGRTable::GetDirectColData(int col, std::vector& data) @@ -834,7 +838,7 @@ void OGRTable::GetColData(int col, int time, std::vector& data) OGRColumn* ogr_col = FindOGRColumn(nm); if (ogr_col == NULL) return; data.resize(rows); - ogr_col->FillData(data); + ogr_col->FillData(data, m_wx_encoding); } void OGRTable::GetColData(int col, int time, std::vector& data) diff --git a/DataViewer/TableBase.cpp b/DataViewer/TableBase.cpp index c5c511cc8..c62c1ef3f 100644 --- a/DataViewer/TableBase.cpp +++ b/DataViewer/TableBase.cpp @@ -105,8 +105,7 @@ TableBase::TableBase(Project* _project,TemplateFrame* t_frame) template_frame = t_frame; SortByDefaultDecending(); - for(int i=0;iregisterObserver(this); diff --git a/DataViewer/TableFrame.cpp b/DataViewer/TableFrame.cpp index 48039379e..847c2c9d3 100644 --- a/DataViewer/TableFrame.cpp +++ b/DataViewer/TableFrame.cpp @@ -54,8 +54,8 @@ TableFrame::TableFrame(wxFrame *parent, Project* project, const wxString& title, const wxPoint& pos, const wxSize& size, const long style) -: TemplateFrame(parent, project, title, pos, size, style), -popup_col(-1) + : TemplateFrame(parent, project, title, pos, size, style), + popup_col(-1) { wxLogMessage("Open TableFrame."); @@ -286,6 +286,7 @@ void TableFrame::DisplayPopupMenu( wxGridEvent& ev ) void TableFrame::SetEncodingCheckmarks(wxMenu* m, wxFontEncoding e) { + m->FindItem(XRCID("ID_ENCODING_UTF8")) ->Check(e==wxFONTENCODING_UTF8); m->FindItem(XRCID("ID_ENCODING_UTF16")) diff --git a/DataViewer/TableInterface.h b/DataViewer/TableInterface.h index 4952aae0d..ebad92970 100644 --- a/DataViewer/TableInterface.h +++ b/DataViewer/TableInterface.h @@ -284,7 +284,8 @@ class TableInterface * column name encoding, but for now remain more restrictive */ virtual void SetEncoding(wxFontEncoding enc_type); virtual wxFontEncoding GetFontEncoding() { return encoding_type; } - + virtual wxCSConv* GetEncoding() { return m_wx_encoding; } + /** Suggests a group name based on the member names listed in cols. * Returned value is a unique, valid group name: it is different than * all other groups and DB fields. Since group names are stored as diff --git a/DialogTools/AbstractClusterDlg.cpp b/DialogTools/AbstractClusterDlg.cpp index beed5f250..da8b1667e 100644 --- a/DialogTools/AbstractClusterDlg.cpp +++ b/DialogTools/AbstractClusterDlg.cpp @@ -40,19 +40,25 @@ #include #include +#include "../ShapeOperations/VoronoiUtils.h" #include "../ShapeOperations/PolysToContigWeights.h" #include "../Algorithms/texttable.h" #include "../Project.h" #include "../GeneralWxUtils.h" #include "../GenUtils.h" + #include "SaveToTableDlg.h" #include "AbstractClusterDlg.h" AbstractClusterDlg::AbstractClusterDlg(wxFrame* parent_s, Project* project_s, wxString title) -: frames_manager(project_s->GetFramesManager()), table_state(project_s->GetTableState()), -wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), -validator(wxFILTER_INCLUDE_CHAR_LIST), input_data(NULL), mask(NULL), weight(NULL), m_use_centroids(NULL), m_weight_centroids(NULL), m_wc_txt(NULL), chk_floor(NULL), combo_floor(NULL), txt_floor(NULL), txt_floor_pct(NULL), slider_floor(NULL), combo_var(NULL), m_reportbox(NULL), gal(NULL) + : frames_manager(project_s->GetFramesManager()), table_state(project_s->GetTableState()), + wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), + validator(wxFILTER_INCLUDE_CHAR_LIST), + input_data(NULL), mask(NULL), weight(NULL), m_use_centroids(NULL), + m_weight_centroids(NULL), m_wc_txt(NULL), chk_floor(NULL), + combo_floor(NULL), txt_floor(NULL), txt_floor_pct(NULL), + slider_floor(NULL), combo_var(NULL), m_reportbox(NULL), gal(NULL) { wxLogMessage("Open AbstractClusterDlg."); @@ -134,7 +140,15 @@ bool AbstractClusterDlg::GetDefaultContiguity() { if (gal== NULL) { bool is_queen = true; - gal = PolysToContigWeights(project->main_data, is_queen); + + if (project->IsPointTypeData()) { + std::vector > nbr_map; + project->GetVoronoiQueenNeighborMap(nbr_map); + gal = Gda::VoronoiUtils::NeighborMapToGal(nbr_map); + } else { + // assume polygons (no lines) + gal = PolysToContigWeights(project->main_data, is_queen); + } } return gal != NULL; } @@ -292,14 +306,138 @@ void AbstractClusterDlg::OnUseCentroids(wxCommandEvent& event) } } +bool AbstractClusterDlg::CheckContiguity(double w, double& ssd) +{ + int val = w * 100; + m_weight_centroids->SetValue(val); + m_wc_txt->SetValue(wxString::Format("%f", w)); + + vector clusters; + if (Run(clusters) == false) { + m_weight_centroids->SetValue(100); + m_wc_txt->SetValue("1.0"); + return false; + } + + // not show print + bool print_result = false; + ssd = CreateSummary(clusters, print_result); + + if (GetDefaultContiguity() == false) return false; + + map > groups; + map >::iterator it; + for (int i=0; i g; + g.insert(i); + groups[c] = g; + } else { + groups[c].insert(i); + } + } + + bool is_cont = true; + set::iterator item_it; + for (it = groups.begin(); it != groups.end(); it++) { + // check each group if contiguity + set g = it->second; + for (item_it=g.begin(); item_it!=g.end(); item_it++) { + int idx = *item_it; + const vector& nbrs = gal[idx].GetNbrs(); + bool not_in_group = true; + for (int i=0; i >& ssd_pairs) +{ + double delta = right - left; + + if ( delta < 0.01 ) return; + + double mid = left + delta /2.0; + + // assume left is always not contiguity and right is always contiguity + double m_ssd = 0; + bool m_conti = CheckContiguity(mid, m_ssd); + + if ( m_conti ) { + ssd_pairs.push_back( std::make_pair(mid, m_ssd) ); + return BinarySearch(left, mid, ssd_pairs); + + } else { + return BinarySearch(mid, right, ssd_pairs); + } +} + +bool AbstractClusterDlg::CheckAllInputs() +{ + // default CheckAllInputs only has "output number of cluster" check + int ncluster = 0; + wxString str_ncluster = combo_n->GetValue(); + long value_ncluster; + if (str_ncluster.ToLong(&value_ncluster)) { + ncluster = value_ncluster; + } + if (ncluster < 2 || ncluster > num_obs) { + wxString err_msg = _("Please enter a valid number of clusters."); + wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); + dlg.ShowModal(); + return false; + } + return true; +} + void AbstractClusterDlg::OnAutoWeightCentroids(wxCommandEvent& event) { + if (CheckAllInputs() == false) return; + + // apply custom algorithm to find optimal weighting value between 0 and 1 + // when w = 1 (fully geometry based) + // when w = 0 (fully attributes based) + std::vector > ssd_pairs; + BinarySearch(0.0, 1.0, ssd_pairs); + + if (ssd_pairs.empty()) return; + + double w = ssd_pairs[0].first; + double ssd = ssd_pairs[0].second; + + for (int i=1; i ssd) { + ssd = ssd_pairs[i].second; + w = ssd_pairs[i].first; + } + } + + int val = w * 100; + m_weight_centroids->SetValue(val); + m_wc_txt->SetValue(wxString::Format("%f", w)); } void AbstractClusterDlg::AddTransformation(wxPanel *panel, wxFlexGridSizer* gbox) { - wxStaticText* st14 = new wxStaticText(panel, wxID_ANY, _("Transformation:"), wxDefaultPosition, wxSize(120,-1)); - const wxString _transform[4] = {"Raw", "Demean", "Standardize (Z)", "Standardize (MAD)"}; + wxStaticText* st14 = new wxStaticText(panel, wxID_ANY, _("Transformation:"), + wxDefaultPosition, wxSize(120,-1)); + const wxString _transform[4] = {"Raw", "Demean", "Standardize (Z)", + "Standardize (MAD)"}; combo_tranform = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(120,-1), 4, _transform); combo_tranform->SetSelection(2); @@ -307,14 +445,37 @@ void AbstractClusterDlg::AddTransformation(wxPanel *panel, wxFlexGridSizer* gbox gbox->Add(combo_tranform, 1, wxEXPAND); } -void AbstractClusterDlg::AddMinBound(wxPanel *panel, wxFlexGridSizer* gbox, bool show_checkbox) +void AbstractClusterDlg::AddNumberOfClusterCtrl(wxPanel *panel, + wxFlexGridSizer* gbox, + bool allow_dropdown) +{ + wxStaticText* st1 = new wxStaticText(panel, wxID_ANY, + _("Number of Clusters:"), + wxDefaultPosition, wxSize(128,-1)); + combo_n = new wxComboBox(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, + wxSize(200,-1), 0, NULL); + max_n_clusters = num_obs < 100 ? num_obs : 100; + if (allow_dropdown) { + for (int i=2; iAppend(wxString::Format("%d", i)); + } + } + gbox->Add(st1, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); + gbox->Add(combo_n, 1, wxEXPAND); +} + +void AbstractClusterDlg::AddMinBound(wxPanel *panel, wxFlexGridSizer* gbox, + bool show_checkbox) { - wxStaticText* st = new wxStaticText(panel, wxID_ANY, _("Minimum Bound:"), wxDefaultPosition, wxSize(128,-1)); + wxStaticText* st = new wxStaticText(panel, wxID_ANY, _("Minimum Bound:"), + wxDefaultPosition, wxSize(128,-1)); wxBoxSizer *hbox0 = new wxBoxSizer(wxHORIZONTAL); chk_floor = new wxCheckBox(panel, wxID_ANY, ""); - combo_floor = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(128,-1), var_items); - txt_floor = new wxTextCtrl(panel, wxID_ANY, "1", wxDefaultPosition, wxSize(70,-1), 0, validator); + combo_floor = new wxChoice(panel, wxID_ANY, wxDefaultPosition, + wxSize(128,-1), var_items); + txt_floor = new wxTextCtrl(panel, wxID_ANY, "1", wxDefaultPosition, + wxSize(70,-1), 0, validator); hbox0->Add(chk_floor); hbox0->Add(combo_floor); hbox0->Add(txt_floor); @@ -475,6 +636,21 @@ void AbstractClusterDlg::InitVariableCombobox(wxListBox* var_box, bool integer_o } } +bool AbstractClusterDlg::IsUseCentroids() +{ + bool use_centroids = false; + + if (m_use_centroids) use_centroids = m_use_centroids->GetValue(); + + if (use_centroids && m_weight_centroids) { + if (m_weight_centroids->GetValue() == 0) { + use_centroids = false; + } + } + + return use_centroids; +} + bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) { CleanData(); @@ -484,7 +660,9 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) if (m_use_centroids) use_centroids = m_use_centroids->GetValue(); if (use_centroids && m_weight_centroids) { - if (m_weight_centroids->GetValue() == 0) use_centroids = false; + if (m_weight_centroids->GetValue() == 0) { + use_centroids = false; + } } wxArrayInt selections; @@ -501,7 +679,8 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) col_names.clear(); select_vars.clear(); - if ((!use_centroids && num_var>0) || (use_centroids && m_weight_centroids && m_weight_centroids->GetValue() != 1)) + if ((!use_centroids && num_var>0) || + (use_centroids && m_weight_centroids && m_weight_centroids->GetValue() != 1)) { col_ids.resize(num_var); var_info.resize(num_var); @@ -510,9 +689,7 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) int idx = selections[i]; wxString sel_str = combo_var->GetString(idx); select_vars.push_back(sel_str); - wxString nm = name_to_nm[sel_str]; - int col = table_int->FindColId(nm); if (col == wxNOT_FOUND) { wxString err_msg = wxString::Format(_("Variable %s is no longer in the Table. Please close and reopen this dialog to synchronize with Table data."), nm); @@ -520,17 +697,13 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) dlg.ShowModal(); return false; } - int tm = name_to_tm_id[combo_var->GetString(idx)]; - col_names.push_back(nm); - + col_names.push_back(sel_str); col_ids[i] = col; var_info[i].time = tm; - // Set Primary GdaVarTools::VarInfo attributes var_info[i].name = nm; var_info[i].is_time_variant = table_int->IsColTimeVariant(nm); - // var_info[i].time already set above table_int->GetMinMaxVals(col_ids[i], var_info[i].min, var_info[i].max); var_info[i].sync_with_global_time = var_info[i].is_time_variant; @@ -539,16 +712,13 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) // Call function to set all Secondary Attributes based on Primary Attributes GdaVarTools::UpdateVarInfoSecondaryAttribs(var_info); - + columns = 0; rows = project->GetNumRecords(); - columns = 0; - - std::vector data; - data.resize(col_ids.size()); // data[variable][time][obs] + std::vector > data; + data.resize(num_var); for (int i=0; iGetColData(col_ids[i], data[i]); + table_int->GetColData(col_ids[i], var_info[i].time, data[i]); } - // if use centroids if (use_centroids) { columns += 2; @@ -559,22 +729,15 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) // get columns (time variables always show upgrouped) columns += data.size(); - if (m_weight_centroids && m_use_centroids) - weight = GetWeights(columns); - else { - weight = new double[columns]; - for (int j=0; j vals; - int c_t = 0; - if (var_info[i].is_time_variant) { - c_t = var_info[i].time; - } - for (int k=0; k< rows;k++) { // row - vals.push_back(data[i][c_t][k]); - } + for (int i=0; i& vals = data[i]; if (transform == 3) { GenUtils::MeanAbsoluteDeviation(vals); } else if (transform == 2) { @@ -634,23 +790,30 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var) double* AbstractClusterDlg::GetWeights(int columns) { - double* weight = new double[columns]; + if (weight != NULL) { + delete[] weight; + weight = NULL; + } + double* _weight = new double[columns]; double wc = 1; for (int j=0; jGetValue() > 0 && m_use_centroids->IsChecked() ) { - double sel_wc = m_weight_centroids->GetValue(); - wc = sel_wc / 100.0; - double n_var_cols = (double)(columns - 2); - for (int j=0; jGetValue() > 0 && m_use_centroids->IsChecked()) { + double sel_wc = m_weight_centroids->GetValue(); + wc = sel_wc / 100.0; + double n_var_cols = (double)(columns - 2); + for (int j=0; j > AbstractClusterDlg::_getMeanCenters(const vector > result(n_clusters); if (columns <= 0 || rows <= 0) return result; - + + std::vector > raw_data; + raw_data.resize(col_ids.size()); + for (int i=0; iGetColData(col_ids[i], var_info[i].time, raw_data[i]); + } + for (int i=0; i means; - for (int c=0; c& clusters) { return false;} virtual double* GetWeights(int columns); @@ -91,6 +96,7 @@ class AbstractClusterDlg : public wxDialog, public FramesManagerObserver, public virtual double* GetBoundVals(); // Utils + bool IsUseCentroids(); bool CheckConnectivity(GalWeight* gw); // Input related @@ -107,12 +113,9 @@ class AbstractClusterDlg : public wxDialog, public FramesManagerObserver, public wxSlider* m_weight_centroids; wxTextCtrl* m_wc_txt; // -- functions - virtual void AddInputCtrls( - wxPanel *panel, - wxBoxSizer* vbox, - bool show_auto_button = false); - virtual void AddSimpleInputCtrls( - wxPanel *panel, + virtual void AddInputCtrls(wxPanel *panel, wxBoxSizer* vbox, + bool show_auto_button = false); + virtual void AddSimpleInputCtrls(wxPanel *panel, wxBoxSizer* vbox, bool integer_only = false); void OnUseCentroids(wxCommandEvent& event); @@ -121,6 +124,10 @@ class AbstractClusterDlg : public wxDialog, public FramesManagerObserver, public bool integer_only=false); bool GetInputData(int transform, int min_num_var=2); void OnInputWeights(wxCommandEvent& event); + + bool CheckContiguity(double w, double& ssd); + void BinarySearch(double left, double right, + std::vector >& ssd_pairs); virtual void OnAutoWeightCentroids(wxCommandEvent& event); // Transformation control @@ -149,7 +156,13 @@ class AbstractClusterDlg : public wxDialog, public FramesManagerObserver, public virtual void OnTypeMinBound(wxCommandEvent& event); virtual void OnSlideMinBound(wxCommandEvent& event); virtual bool CheckMinBound(); - + + // output controls + wxComboBox* combo_n; + int max_n_clusters; + virtual void AddNumberOfClusterCtrl(wxPanel *panel, wxFlexGridSizer* gbox, + bool allow_dropdown = true); + // Summary related // The main statistics should be: // - mean centers or centroids of each cluster in terms of the variables involved diff --git a/DialogTools/ConnectDatasourceDlg.cpp b/DialogTools/ConnectDatasourceDlg.cpp index 62cef7ffb..2fcb33d31 100644 --- a/DialogTools/ConnectDatasourceDlg.cpp +++ b/DialogTools/ConnectDatasourceDlg.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -113,40 +114,41 @@ void RecentDatasource::Init(wxString json_str_) return; // "recent_ds" : [{"ds_name":"/data/test.shp", "layer_name":"test", "ds_config":"...", "thumb":"..."}, ] - std::string json_str(json_str_.mb_str()); - json_spirit::Value v; + std::wstring json_str = json_str_.ToStdWstring(); + json_spirit::wValue v; try { if (!json_spirit::read(json_str, v)) { - throw std::runtime_error("Could not parse recent ds string"); + throw GdaException("Could not parse recent ds string"); } - const json_spirit::Array& ds_list = v.get_array(); + const json_spirit::wArray& ds_list = v.get_array(); n_ds = ds_list.size(); for (size_t i=0; iname_ == "ds_name") { + json_spirit::wValue val; + if (i->name_ == L"ds_name") { val = i->value_; - ds_name = wxString::FromUTF8(val.get_str().c_str()); + ds_name = val.get_str(); } else if (i->name_ == "layer_name") { val = i->value_; - layer_name = wxString::FromUTF8(val.get_str().c_str()); + layer_name = val.get_str(); } else if (i->name_ == "ds_config") { val = i->value_; - ds_conf = wxString::FromUTF8(val.get_str().c_str()); + ds_conf = val.get_str(); } else if (i->name_ == "ds_thumb") { val = i->value_; - ds_thumb = wxString(val.get_str()); + ds_thumb = val.get_str(); } } ds_names.push_back(ds_name); @@ -154,8 +156,6 @@ void RecentDatasource::Init(wxString json_str_) ds_confs.push_back(ds_conf); ds_thumbnails.push_back(ds_thumb); } - - } catch (std::runtime_error e) { wxString msg; msg << "Get Latest DB infor: JSON parsing failed: "; @@ -167,26 +167,31 @@ void RecentDatasource::Init(wxString json_str_) void RecentDatasource::Save() { // update ds_json_str from ds_names & ds_values - json_spirit::Array ds_list_obj; + json_spirit::wArray ds_list_obj; for (int i=0; iShow(); + m_encoding_lbl->Show(); + } + if (showRecentPanel) { RecentDatasource recent_ds; if (recent_ds.GetRecords() > 0) { @@ -416,7 +427,6 @@ ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos, recent_panel->Layout(); sizer->Fit( recent_panel ); } - InitSamplePanel(); } @@ -426,7 +436,8 @@ ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos, SetIcon(wxIcon(GeoDaIcon_16x16_xpm)); Bind(wxEVT_COMMAND_MENU_SELECTED, &ConnectDatasourceDlg::BrowseDataSource, - this, GdaConst::ID_CONNECT_POPUP_MENU, GdaConst::ID_CONNECT_POPUP_MENU + ds_names.Count()); + this, GdaConst::ID_CONNECT_POPUP_MENU, + GdaConst::ID_CONNECT_POPUP_MENU + ds_names.Count()); Centre(); Move(pos); @@ -442,6 +453,9 @@ ConnectDatasourceDlg::~ConnectDatasourceDlg() delete datasource; datasource = NULL; } + if (m_wx_encoding) { + delete m_wx_encoding; + } } @@ -614,8 +628,11 @@ void ConnectDatasourceDlg::CreateControls() recent_nb->SetSelection(1); recent_panel = XRCCTRL(*this, "dsRecentListSizer", wxPanel); smaples_panel = XRCCTRL(*this, "dsSampleList", wxPanel); + } else { wxXmlResource::Get()->LoadDialog(this, GetParent(),"IDD_CONNECT_DATASOURCE_SIMPLE"); + m_encodings = XRCCTRL(*this, "IDC_CDS_ENCODING_CHOICE",wxChoice); + m_encoding_lbl = XRCCTRL(*this, "IDC_CDS_ENCODING_LABEL",wxStaticText); } FindWindow(XRCID("wxID_OK"))->Enable(true); @@ -747,11 +764,16 @@ void ConnectDatasourceDlg::OnOkClick( wxCommandEvent& event ) } return; } - + + if (dialogType == 1) { + // case of Merge + m_wx_encoding = GetEncoding(); + } + // 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" && showCsvConfigure) { wxString csv_path = ds_file_path.GetFullPath(); - CsvFieldConfDlg csvDlg(this, csv_path); + CsvFieldConfDlg csvDlg(this, csv_path, m_wx_encoding); csvDlg.ShowModal(); } @@ -1146,3 +1168,92 @@ void ConnectDatasourceDlg::OnSample(wxCommandEvent& event) } +wxCSConv* ConnectDatasourceDlg::GetEncoding() +{ + if (m_encodings && m_encodings->IsShown()) { + + wxFontEncoding encoding_type = wxFONTENCODING_DEFAULT; + int sel = m_encodings->GetSelection(); + wxString encode_str = m_encodings->GetString(sel); + + if (sel == 0) return NULL; + + //encode_str = wxString(encode_str.wc_str(), wxCSConv(wxFONTENCODING_DEFAULT)); + if (sel == 1) { + encoding_type = wxFONTENCODING_UTF8; + } else if (sel == 2) { + encoding_type = wxFONTENCODING_UTF16LE; + + } else if (sel == 3) { + encoding_type = wxFONTENCODING_CP1256; + + } else if (sel == 4 ) { + encoding_type = wxFONTENCODING_ISO8859_2; + + } else if (sel == 5) { + encoding_type = wxFONTENCODING_CP1250; + + } else if (sel == 6) { + encoding_type = wxFONTENCODING_CP852; + + } else if (sel == 7) { + encoding_type = wxFONTENCODING_GB2312; + + } else if (sel == 8) { + encoding_type = wxFONTENCODING_BIG5; + + } else if (sel == 9) { + encoding_type = wxFONTENCODING_ISO8859_5; + + } else if (sel == 10) { + encoding_type = wxFONTENCODING_KOI8; + + } else if (sel == 11) { + encoding_type = wxFONTENCODING_CP1251; + + } else if (sel == 12) { + encoding_type = wxFONTENCODING_CP866; + + } else if (sel == 13 ) { + encoding_type = wxFONTENCODING_ISO8859_7; + + } else if (sel == 14) { + encoding_type = wxFONTENCODING_ISO8859_8; + + } else if (sel == 15) { + encoding_type = wxFONTENCODING_CP1255; + + } else if (sel == 16) { + encoding_type = wxFONTENCODING_SHIFT_JIS; + } else if (sel == 17) { + encoding_type = wxFONTENCODING_EUC_JP; + } else if (sel == 18) { + encoding_type = wxFONTENCODING_EUC_KR; + + } else if (sel == 19 ) { + encoding_type = wxFONTENCODING_ISO8859_10; + + } else if (sel == 20) { + encoding_type = wxFONTENCODING_ISO8859_3; + + } else if (sel == 21) { + encoding_type = wxFONTENCODING_ISO8859_9; + } else if (sel == 22) { + encoding_type = wxFONTENCODING_CP1254; + } else if (sel == 23) { + encoding_type = wxFONTENCODING_CP1258; + } else if (sel == 24) { + encoding_type = wxFONTENCODING_ISO8859_1; + + } else if (sel == 25) { + encoding_type = wxFONTENCODING_ISO8859_15; + } + + + + + if (m_wx_encoding) delete m_wx_encoding; + m_wx_encoding = new wxCSConv(encoding_type); + } + return m_wx_encoding; +} diff --git a/DialogTools/ConnectDatasourceDlg.h b/DialogTools/ConnectDatasourceDlg.h index ee30f7d39..8747fae35 100644 --- a/DialogTools/ConnectDatasourceDlg.h +++ b/DialogTools/ConnectDatasourceDlg.h @@ -93,6 +93,13 @@ class DnDFile; class ConnectDatasourceDlg: public DatasourceDlg { public: + enum Style { + DEFAULT_STYLE = 0, + SHOW_CSV_CONFIGURE = 1, //0b00000001 + SHOW_RECENT_PANEL = 2, //0b00000010 + ALLOW_PROJECT_FILE = 4 + }; + ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -107,13 +114,14 @@ class ConnectDatasourceDlg: public DatasourceDlg void OnLookupDSTableBtn( wxCommandEvent& event ); void OnLookupCartoDBTableBtn( wxCommandEvent& event ); IDataSource* GetDataSource(){ return datasource; } - + wxCSConv* GetEncoding(); protected: int dialogType; bool showCsvConfigure; bool showRecentPanel; - + wxCSConv* m_wx_encoding; + wxStaticBitmap* m_drag_drop_box; wxBitmapButton* m_database_lookup_table; wxBitmapButton* m_database_lookup_wslayer; @@ -126,6 +134,8 @@ class ConnectDatasourceDlg: public DatasourceDlg wxNotebook* recent_nb; wxCheckBox* noshow_recent; wxChoice* m_web_choice; + wxChoice* m_encodings; + wxStaticText* m_encoding_lbl; DnDFile* m_dnd; int base_xrcid_recent_thumb; @@ -147,8 +157,8 @@ class ConnectDatasourceDlg: public DatasourceDlg void OnRecentDelete(wxCommandEvent& event); void OnNoShowRecent(wxCommandEvent& event); - - + + DECLARE_EVENT_TABLE() }; diff --git a/DialogTools/CsvFieldConfDlg.cpp b/DialogTools/CsvFieldConfDlg.cpp index f971d601b..dc243c3f9 100644 --- a/DialogTools/CsvFieldConfDlg.cpp +++ b/DialogTools/CsvFieldConfDlg.cpp @@ -59,6 +59,7 @@ using namespace std; CsvFieldConfDlg::CsvFieldConfDlg(wxWindow* parent, wxString _filepath, + wxCSConv* encoding, wxWindowID id, const wxString& title, const wxPoint& pos, @@ -67,6 +68,7 @@ CsvFieldConfDlg::CsvFieldConfDlg(wxWindow* parent, { wxLogMessage("Open CsvFieldConfDlg."); + m_wx_encoding = encoding; HEADERS = 1; lat_box = NULL; n_max_rows = 10; @@ -514,10 +516,16 @@ void CsvFieldConfDlg::UpdatePreviewGrid( ) } else if (types[j] == "Date" || types[j] == "Time" || types[j] == "DateTime") { wxString str = poFeature->GetFieldAsString(j); - //wxString str = wxString::Format("%f", val); previewGrid->SetCellValue(i, j, str); + } else { - wxString str = poFeature->GetFieldAsString(j); + const char* val = poFeature->GetFieldAsString(j); + wxString str; + if (m_wx_encoding == NULL) { + str = val; + } else { + str = wxString(val, *m_wx_encoding); + } previewGrid->SetCellValue(i, j, str); } } diff --git a/DialogTools/CsvFieldConfDlg.h b/DialogTools/CsvFieldConfDlg.h index b1c1374de..b920a5242 100644 --- a/DialogTools/CsvFieldConfDlg.h +++ b/DialogTools/CsvFieldConfDlg.h @@ -37,6 +37,7 @@ class CsvFieldConfDlg: public wxDialog { public: CsvFieldConfDlg(wxWindow* parent, wxString filepath, + wxCSConv* encoding = NULL, wxWindowID id = wxID_ANY, const wxString& title = _("GeoDa CSV File Configuration"), const wxPoint& pos = wxDefaultPosition, @@ -61,7 +62,9 @@ class CsvFieldConfDlg: public wxDialog wxComboBox* lat_box; wxComboBox* lng_box; wxSpinCtrl* prev_spin; - + + wxCSConv* m_wx_encoding; + void ReadCSVT(); void WriteCSVT(); diff --git a/DialogTools/DatasourceDlg.cpp b/DialogTools/DatasourceDlg.cpp index 8fca74723..96878d06b 100644 --- a/DialogTools/DatasourceDlg.cpp +++ b/DialogTools/DatasourceDlg.cpp @@ -95,7 +95,6 @@ void DatasourceDlg::CreateControls() #ifdef __WIN32__ SetBackgroundColour(*wxWHITE); #endif - m_ds_filepath_txt = XRCCTRL(*this, "IDC_FIELD_ASC",wxTextCtrl); m_database_type = XRCCTRL(*this, "IDC_CDS_DB_TYPE",wxChoice); m_database_name = XRCCTRL(*this, "IDC_CDS_DB_NAME",AutoTextCtrl); diff --git a/DialogTools/DatasourceDlg.h b/DialogTools/DatasourceDlg.h index e5fe48740..1b2015c50 100644 --- a/DialogTools/DatasourceDlg.h +++ b/DialogTools/DatasourceDlg.h @@ -45,6 +45,7 @@ class DatasourceDlg : public wxDialog wxFileName ds_file_path; protected: + wxTextCtrl* m_ds_filepath_txt; wxBitmapButton* m_ds_browse_file_btn; //wxBitmapButton* m_database_lookup_table; diff --git a/DialogTools/ExportDataDlg.cpp b/DialogTools/ExportDataDlg.cpp index e660534a6..d0152f5c1 100644 --- a/DialogTools/ExportDataDlg.cpp +++ b/DialogTools/ExportDataDlg.cpp @@ -461,7 +461,8 @@ void ExportDataDlg::ExportOGRLayer(wxString& ds_name, bool is_update) return; } if (layer->export_progress == -1){ - wxString msg = wxString::Format(_("Saving to data source (%s) failed.\n\nDetails: %s"), ds_name, layer->error_message.str()); + wxString tmp = _("Saving to data source (%s) failed.\n\nDetails: %s"); + wxString msg = wxString::Format(tmp, ds_name, layer->error_message); throw GdaException(msg.c_str()); } } @@ -609,17 +610,21 @@ ExportDataDlg::CreateOGRLayer(wxString& ds_name, OGRDataAdapter::GetInstance().CancelExport(new_layer); return false; } - if (new_layer->export_progress == -1){ - wxString msg = wxString::Format(_("Saving to data source (%s) failed.\n\nDetails: %s"), ds_name, new_layer->error_message.str()); + if (new_layer->export_progress == -1) { + wxString tmp = _("Saving to data source (%s) failed.\n\nDetails: %s"); + wxString msg = wxString::Format(tmp, ds_name, + new_layer->error_message); throw GdaException(msg.c_str()); } } OGRDataAdapter::GetInstance().StopExport(); //here new_layer will be deleted - if (!is_geometry_only) - for (size_t i=0; i < geometries.size(); i++) + if (!is_geometry_only) { + for (size_t i=0; i < geometries.size(); i++) { delete geometries[i]; + } + } //NOTE: export_ds will take ownership of ogr_geometries //for (size_t i=0; iremoveObserver(this); + if (htree != NULL) { + delete[] htree; + htree = NULL; + } } void HClusterDlg::Highlight(int id) @@ -132,10 +137,14 @@ void HClusterDlg::CreateControls() // Input wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); - AddInputCtrls(panel, vbox); + bool show_auto_ctrl = true; + AddInputCtrls(panel, vbox, show_auto_ctrl); // Parameters - wxFlexGridSizer* gbox = new wxFlexGridSizer(5,2,5,0); + wxFlexGridSizer* gbox = new wxFlexGridSizer(7,2,5,0); + + // NumberOfCluster Control + AddNumberOfClusterCtrl(panel, gbox); // Transformation AddTransformation(panel, gbox); @@ -178,21 +187,6 @@ void HClusterDlg::CreateControls() // Output wxFlexGridSizer* gbox1 = new wxFlexGridSizer(5,2,5,0); - - wxStaticText* st1 = new wxStaticText(panel, wxID_ANY, _("Number of Clusters:"), - wxDefaultPosition, wxDefaultSize); - max_n_clusters = num_obs < 60 ? num_obs : 60; - wxTextValidator validator(wxFILTER_INCLUDE_CHAR_LIST); - wxArrayString list; - wxString valid_chars("0123456789"); - size_t len = valid_chars.Length(); - for (size_t i=0; iAdd(st1, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); - gbox1->Add(m_cluster, 1, wxEXPAND); wxStaticText* st3 = new wxStaticText (panel, wxID_ANY, _("Save Cluster in Field:"), wxDefaultPosition, wxDefaultSize); wxTextCtrl *box3 = new wxTextCtrl(panel, wxID_ANY, "CL", wxDefaultPosition, wxSize(120,-1)); @@ -245,7 +239,6 @@ void HClusterDlg::CreateControls() Centre(); // Content - //combo_n = box1; m_textbox = box3; //m_iterations = box11; m_method = box12; @@ -263,17 +256,16 @@ void HClusterDlg::CreateControls() sel_pos = i; } if (weights_ids.size() > 0) combo_weights->SetSelection(sel_pos); - - + // Events okButton->Bind(wxEVT_BUTTON, &HClusterDlg::OnOKClick, this); saveButton->Bind(wxEVT_BUTTON, &HClusterDlg::OnSave, this); closeButton->Bind(wxEVT_BUTTON, &HClusterDlg::OnClickClose, this); - m_cluster->Connect(wxEVT_TEXT, wxCommandEventHandler(HClusterDlg::OnClusterChoice), NULL, this); + combo_n->Connect(wxEVT_TEXT, wxCommandEventHandler(HClusterDlg::OnClusterChoice), NULL, this); + combo_n->Connect(wxEVT_CHOICE, wxCommandEventHandler(HClusterDlg::OnClusterChoice), NULL, this); + chk_contiguity->Bind(wxEVT_CHECKBOX, &HClusterDlg::OnSpatialConstraintCheck, this); saveButton->Disable(); - //combo_n->Disable(); - m_cluster->Disable(); } void HClusterDlg::OnSpatialConstraintCheck(wxCommandEvent& event) @@ -303,7 +295,6 @@ void HClusterDlg::OnSave(wxCommandEvent& event ) return; } - // save to table int time=0; int col = table_int->FindColId(field_name); @@ -325,6 +316,7 @@ void HClusterDlg::OnSave(wxCommandEvent& event ) } if (col > 0) { + vector clusters_undef(rows, false); table_int->SetColData(col, time, clusters); table_int->SetColUndefined(col, time, clusters_undef); } @@ -360,7 +352,7 @@ void HClusterDlg::OnSave(wxCommandEvent& event ) wxString ttl; ttl << "Hierachical " << _("Cluster Map ") << "("; - ttl << m_cluster->GetValue(); + ttl << combo_n->GetValue(); ttl << " clusters)"; nf->SetTitle(ttl); } @@ -381,8 +373,7 @@ void HClusterDlg::OnDistanceChoice(wxCommandEvent& event) void HClusterDlg::OnClusterChoice(wxCommandEvent& event) { - //int sel_ncluster = combo_n->GetSelection() + 2; - wxString tmp_val = m_cluster->GetValue(); + wxString tmp_val = combo_n->GetValue(); tmp_val.Trim(false); tmp_val.Trim(true); long sel_ncluster; @@ -396,11 +387,9 @@ void HClusterDlg::OnClusterChoice(wxCommandEvent& event) void HClusterDlg::UpdateClusterChoice(int n, std::vector& _clusters) { - //int sel = n - 2; - //combo_n->SetSelection(sel); wxString str_n; str_n << n; - m_cluster->SetValue(str_n); + combo_n->SetValue(str_n); for (int i=0; iGetValue() << "\n"; + txt << _("Number of clusters:\t") << combo_n->GetValue() << "\n"; txt << _("Transformation:\t") << combo_tranform->GetString(combo_tranform->GetSelection()) << "\n"; @@ -473,51 +462,142 @@ wxString HClusterDlg::_printConfiguration() return txt; } -void HClusterDlg::OnOKClick(wxCommandEvent& event ) + +bool HClusterDlg::CheckAllInputs() { - wxLogMessage("Click HClusterDlg::OnOK"); - - //int ncluster = combo_n->GetSelection() + 2; - long ncluster; - m_cluster->GetValue().ToLong(&ncluster); - - int transform = combo_tranform->GetSelection(); - bool success = GetInputData(transform,1); - if (!success) { - return; + n_cluster = 0; + wxString str_ncluster = combo_n->GetValue(); + long value_ncluster; + if (str_ncluster.ToLong(&value_ncluster)) { + n_cluster = value_ncluster; } - - char method = 's'; - char dist = 'e'; - - int transpose = 0; // row wise - int* clusterid = new int[rows]; - + if (n_cluster < 2 || n_cluster > num_obs) { + wxString err_msg = _("Please enter a valid number of clusters."); + wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); + dlg.ShowModal(); + return false; + } + + int transform = combo_tranform->GetSelection(); + if(GetInputData(transform,1) == false) return false; + + method = 's'; int method_sel = m_method->GetSelection(); char method_choices[] = {'s','w', 'm','a'}; method = method_choices[method_sel]; - + dist = 'e'; int dist_sel = m_distance->GetSelection(); char dist_choices[] = {'e','b'}; dist = dist_choices[dist_sel]; - - GdaNode* htree = new GdaNode[rows-1]; + + return true; +} + +bool HClusterDlg::Run(vector& clusters) +{ + // NOTE input_data should be retrieved first!! + // get input: weights (auto) + weight = GetWeights(columns); + + double* pwdist = NULL; + if (dist == 'e') { + pwdist = DataUtils::getPairWiseDistance(input_data, weight, rows, + columns, + DataUtils::EuclideanDistance); + } else { + pwdist = DataUtils::getPairWiseDistance(input_data, weight, rows, + columns, + DataUtils::ManhattanDistance); + } + + fastcluster::auto_array_ptr members; + if (htree != NULL) { + delete[] htree; + htree = NULL; + } + htree = new GdaNode[rows-1]; fastcluster::cluster_result Z2(rows-1); + + if (method == 's') { + fastcluster::MST_linkage_core(rows, pwdist, Z2); + } else if (method == 'w') { + members.init(rows, 1); + fastcluster::NN_chain_core(rows, pwdist, members, Z2); + } else if (method == 'm') { + fastcluster::NN_chain_core(rows, pwdist, NULL, Z2); + } else if (method == 'a') { + members.init(rows, 1); + fastcluster::NN_chain_core(rows, pwdist, members, Z2); + } + + delete[] pwdist; + + std::stable_sort(Z2[0], Z2[rows-1]); + t_index node1, node2; + int i=0; + fastcluster::union_find nodes(rows); + for (fastcluster::node const * NN=Z2[0]; NN!=Z2[rows-1]; ++NN, ++i) { + // Find the cluster identifiers for these points. + node1 = nodes.Find(NN->node1); + node2 = nodes.Find(NN->node2); + // Merge the nodes in the union-find data structure by making them + // children of a new node. + nodes.Union(node1, node2); + + node2 = node2 < rows ? node2 : rows-node2-1; + node1 = node1 < rows ? node1 : rows-node1-1; + + //cout << i<< ":" << node2 <<", " << node1 << ", " << Z2[i]->dist <dist; + } + clusters.clear(); + int* clusterid = new int[rows]; + cutoffDistance = cuttree (rows, htree, n_cluster, clusterid); + for (int i=0; iSetup(htree, rows, n_cluster, clusters, cutoffDistance); + + saveButton->Enable(); +} + +void HClusterDlg::SpatialConstraintClustering() +{ + int transpose = 0; // row wise + fastcluster::cluster_result Z2(rows-1); + if (chk_contiguity->GetValue()) { vector weights_ids; WeightsManInterface* w_man_int = project->GetWManInt(); w_man_int->GetIds(weights_ids); - + int sel = combo_weights->GetSelection(); if (sel < 0) sel = 0; if (sel >= weights_ids.size()) sel = weights_ids.size()-1; - + boost::uuids::uuid w_id = weights_ids[sel]; GalWeight* gw = w_man_int->GetGal(w_id); - + if (gw == NULL) { wxMessageDialog dlg (this, _("Invalid Weights Information:\n\n The selected weights file is not valid.\n Please choose another weights file, or use Tools > Weights > Weights Manager\n to define a valid weights file."), _("Warning"), wxOK | wxICON_WARNING); dlg.ShowModal(); @@ -531,7 +611,7 @@ void HClusterDlg::OnOKClick(wxCommandEvent& event ) dlg.ShowModal(); return; } - + double** ragged_distances = distancematrix(rows, columns, input_data, mask, weight, dist, transpose); double** distances = DataUtils::fullRaggedMatrix(ragged_distances, rows, rows); for (int i = 1; i < rows; i++) free(ragged_distances[i]); @@ -543,81 +623,11 @@ void HClusterDlg::OnOKClick(wxCommandEvent& event ) Z2[i]->node2 = redcap->ordered_edges[i]->dest->id; Z2[i]->dist = redcap->ordered_edges[i]->length; } - + delete redcap; - - } else { - - double* pwdist = NULL; - if (dist == 'e') { - pwdist = DataUtils::getPairWiseDistance(input_data, weight, rows, columns, DataUtils::EuclideanDistance); - } else { - pwdist = DataUtils::getPairWiseDistance(input_data, weight, rows, columns, DataUtils::ManhattanDistance); - } - - fastcluster::auto_array_ptr members; - - if (method == 's') { - fastcluster::MST_linkage_core(rows, pwdist, Z2); - } else if (method == 'w') { - members.init(rows, 1); - fastcluster::NN_chain_core(rows, pwdist, members, Z2); - } else if (method == 'm') { - fastcluster::NN_chain_core(rows, pwdist, NULL, Z2); - } else if (method == 'a') { - members.init(rows, 1); - fastcluster::NN_chain_core(rows, pwdist, members, Z2); - } - - delete[] pwdist; - } - std::stable_sort(Z2[0], Z2[rows-1]); - t_index node1, node2; - int i=0; - fastcluster::union_find nodes(rows); - for (fastcluster::node const * NN=Z2[0]; NN!=Z2[rows-1]; ++NN, ++i) { - // Find the cluster identifiers for these points. - node1 = nodes.Find(NN->node1); - node2 = nodes.Find(NN->node2); - // Merge the nodes in the union-find data structure by making them - // children of a new node. - nodes.Union(node1, node2); - - node2 = node2 < rows ? node2 : rows-node2-1; - node1 = node1 < rows ? node1 : rows-node1-1; - - //cout << i<< ":" << node2 <<", " << node1 << ", " << Z2[i]->dist <dist; - } - - - double cutoffDistance = cuttree (rows, htree, ncluster, clusterid); - - clusters.clear(); - clusters_undef.clear(); - - for (int i=0; iSetup(htree, rows, ncluster, clusters, cutoffDistance); - // free(htree); should be freed in m_panel since drawing still needs it's instance - - - saveButton->Enable(); - m_cluster->Enable(); } - - IMPLEMENT_ABSTRACT_CLASS(DendrogramPanel, wxPanel) BEGIN_EVENT_TABLE(DendrogramPanel, wxPanel) @@ -626,7 +636,9 @@ EVT_IDLE(DendrogramPanel::OnIdle) EVT_PAINT(DendrogramPanel::OnPaint) END_EVENT_TABLE() -DendrogramPanel::DendrogramPanel(int _max_n_clusters, wxWindow* parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +DendrogramPanel::DendrogramPanel(int _max_n_clusters, wxWindow* parent, + wxWindowID id, const wxPoint &pos, + const wxSize &size) : wxPanel(parent, id, pos, size), max_n_clusters(_max_n_clusters) { SetBackgroundStyle(wxBG_STYLE_CUSTOM); @@ -651,7 +663,7 @@ DendrogramPanel::~DendrogramPanel() delete end_nodes[i]; } end_nodes.clear(); - if (root) free(root); root = NULL; + if (root) delete[] root; if (layer_bm) { delete layer_bm; layer_bm= NULL; @@ -660,7 +672,6 @@ DendrogramPanel::~DendrogramPanel() if (split_line) { delete split_line; split_line = NULL; - } } @@ -740,18 +751,16 @@ void DendrogramPanel::OnIdle(wxIdleEvent& event) wxSize sz = GetClientSize(); if (sz.x > 0 && sz.y > 0) { - if (layer_bm) { - delete layer_bm; - layer_bm = 0; - } - - double scale_factor = GetContentScaleFactor(); - layer_bm = new wxBitmap; - layer_bm->CreateScaled(sz.x, sz.y, 32, scale_factor); + if (layer_bm) { + delete layer_bm; + layer_bm = 0; + } - if (root) { - init(); - } + double scale_factor = GetContentScaleFactor(); + layer_bm = new wxBitmap; + layer_bm->CreateScaled(sz.x, sz.y, 32, scale_factor); + + if (root) init(); } } event.Skip(); @@ -784,13 +793,16 @@ void DendrogramPanel::OnPaint( wxPaintEvent& event ) event.Skip(); } -void DendrogramPanel::Setup(GdaNode* _root, int _nelements, int _nclusters, std::vector& _clusters, double _cutoff) { - if (root && root != _root) { - // free previous tree in memory - free(root); - root = NULL; +void DendrogramPanel::Setup(GdaNode* _root, int _nelements, int _nclusters, + std::vector& _clusters, double _cutoff) +{ + if (root != NULL) { + delete[] root; + } + root = new GdaNode[_nelements]; + for (size_t i=0; i<_nelements; ++i) { + root[i] = _root[i]; } - root = _root; nelements = _nelements; clusters = _clusters; nclusters = _nclusters; diff --git a/DialogTools/HClusterDlg.h b/DialogTools/HClusterDlg.h index 306a94d47..837e93734 100644 --- a/DialogTools/HClusterDlg.h +++ b/DialogTools/HClusterDlg.h @@ -256,21 +256,26 @@ class HClusterDlg : public AbstractClusterDlg, public HighlightStateObserver void Highlight(vector& ids); protected: - int max_n_clusters; - + virtual bool Run(vector& clusters); + virtual bool CheckAllInputs(); + + void SpatialConstraintClustering(); + + GdaNode* htree; + int n_cluster; + char dist; + char method; + double cutoffDistance; vector clusters; - vector clusters_undef; wxButton *saveButton; - wxChoice* combo_n; wxChoice* combo_cov; wxChoice* combo_weights; wxTextCtrl* m_textbox; wxChoice* m_method; wxChoice* m_distance; DendrogramPanel* m_panel; - wxTextCtrl* m_cluster; wxNotebook* notebook; wxCheckBox* chk_contiguity; diff --git a/DialogTools/HDBScanDlg.cpp b/DialogTools/HDBScanDlg.cpp index 98520915a..0773cf1d6 100644 --- a/DialogTools/HDBScanDlg.cpp +++ b/DialogTools/HDBScanDlg.cpp @@ -57,7 +57,6 @@ HDBScanDlg::HDBScanDlg(wxFrame* parent_s, Project* project_s) : AbstractClusterDlg(parent_s, project_s, _("HDBScan Clustering Settings")) { wxLogMessage("Open HDBScanDlg."); - parent = parent_s; project = project_s; @@ -77,7 +76,6 @@ HDBScanDlg::HDBScanDlg(wxFrame* parent_s, Project* project_s) HDBScanDlg::~HDBScanDlg() { highlight_state->removeObserver(this); - } void HDBScanDlg::Highlight(int id) @@ -126,7 +124,8 @@ void HDBScanDlg::CreateControls() // Input wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); - AddInputCtrls(panel, vbox); + bool show_auto_ctrl = true; + AddInputCtrls(panel, vbox, show_auto_ctrl); // Parameters wxFlexGridSizer* gbox = new wxFlexGridSizer(10,2,5,0); @@ -153,9 +152,9 @@ void HDBScanDlg::CreateControls() wxStaticText* st15 = new wxStaticText(panel, wxID_ANY, _("Alpha:"), wxDefaultPosition, wxDefaultSize); - m_alpha = new wxTextCtrl(panel, wxID_ANY, "1.0", wxDefaultPosition, wxSize(120, -1),0,validator); + m_ctl_alpha = new wxTextCtrl(panel, wxID_ANY, "1.0", wxDefaultPosition, wxSize(120, -1),0,validator); gbox->Add(st15, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); - gbox->Add(m_alpha, 1, wxEXPAND); + gbox->Add(m_ctl_alpha, 1, wxEXPAND); wxStaticText* st16 = new wxStaticText(panel, wxID_ANY, _("Method of selecting clusters:"), wxDefaultPosition, wxSize(180,-1)); @@ -281,7 +280,6 @@ void HDBScanDlg::OnSave(wxCommandEvent& event ) vector undefs(rows, false); - new_data[0].d_val = &core_dist; new_data[0].label = "Core Dist"; new_data[0].field_default = "HDB_CORE"; @@ -300,9 +298,9 @@ void HDBScanDlg::OnSave(wxCommandEvent& event ) new_data[2].field_default = "HDB_OUT"; new_data[2].type = GdaConst::double_type; new_data[2].undefined = &undefs; - - SaveToTableDlg dlg(project, this, new_data, - "Save Results: HDBScan (Core Distances/Probabilities/Outliers)", + + wxString ttl = _("Save Results: HDBScan (Core Distances/Probabilities/Outliers)"); + SaveToTableDlg dlg(project, this, new_data, ttl, wxDefaultPosition, wxSize(400,400)); dlg.ShowModal(); @@ -408,7 +406,7 @@ wxString HDBScanDlg::_printConfiguration() wxString txt; txt << "Minimum cluster size:\t" << m_minpts->GetValue() << "\n"; txt << "Minimum samples:\t" << m_minsamples->GetValue() << "\n"; - txt << "Alpha:\t" << m_alpha->GetValue() << "\n"; + txt << "Alpha:\t" << m_ctl_alpha->GetValue() << "\n"; txt << "Method of selecting cluster:\t" << m_select_method->GetStringSelection() << "\n"; wxString single_cluster = chk_allowsinglecluster->IsChecked() ? "Yes" : "No"; txt << "Allow a single cluster:\t" << single_cluster << "\n"; @@ -419,79 +417,60 @@ wxString HDBScanDlg::_printConfiguration() return txt; } -void HDBScanDlg::OnOKClick(wxCommandEvent& event ) +bool HDBScanDlg::CheckAllInputs() { - wxLogMessage("Click HDBScanDlg::OnOK"); - - long minPts = 0; - m_minpts->GetValue().ToLong(&minPts); - if (minPts<=1) { + m_min_pts = 0; + long l_min_pts; + if (m_minpts->GetValue().ToLong(&l_min_pts)) { + m_min_pts = l_min_pts; + } + if (m_min_pts<=1) { wxString err_msg = _("Minimum cluster size should be greater than one."); wxMessageDialog dlg(NULL, err_msg, _("Warning"), wxOK | wxICON_WARNING); dlg.ShowModal(); - return; + return false; } - - int transform = combo_tranform->GetSelection(); - bool success = GetInputData(transform,1); - if (!success) { - return; + + m_min_samples = 10; + long l_min_samples; + if (m_minsamples->GetValue().ToLong(&l_min_samples)) { + m_min_samples = l_min_samples; } - - char method = 's'; - char dist = 'e'; - - int transpose = 0; // row wise - - int dist_sel = m_distance->GetSelection(); - char dist_choices[] = {'e','b'}; - dist = dist_choices[dist_sel]; - - long minSamples = 10; - m_minsamples->GetValue().ToLong(&minSamples); - if (minSamples<=1) { + if (m_min_samples <= 1) { wxString err_msg = _("Minimum samples should be greater than zero."); wxMessageDialog dlg(NULL, err_msg, _("Warning"), wxOK | wxICON_WARNING); dlg.ShowModal(); - return; + return false; } - - double alpha = 1; - m_alpha->GetValue().ToDouble(&alpha); - - int cluster_selection_method = m_select_method->GetSelection(); - bool allow_single_cluster = chk_allowsinglecluster->IsChecked(); - - clusters.clear(); - clusters_undef.clear(); - - - // 3gb 3*1024*1024/4 = 786432 - unsigned long long total_pairs = rows * rows; - int block_size = total_pairs / 780000; - - /* - wxString exePath = GenUtils::GetBasemapCacheDir(); - wxString clPath = exePath + "distmat_kernel.cl"; - float* r = gpu_distmatrix(clPath.mb_str(), rows, columns, input_data); - double** _distances = new double*[rows]; - unsigned long long idx; - unsigned long long _row = rows; - for (unsigned long long i=0; iGetValue().ToDouble(&d_alpha)) { + m_alpha = d_alpha; } - free(r); - */ - double** ragged_distances = distancematrix(rows, columns, input_data, mask, weight, dist, transpose); - double** distances = DataUtils::fullRaggedMatrix(ragged_distances, rows, rows); - - for (int i = 1; i < rows; i++) free(ragged_distances[i]); - free(ragged_distances); - + + m_cluster_selection_method = m_select_method->GetSelection(); + m_allow_single_cluster = chk_allowsinglecluster->IsChecked(); + + int transform = combo_tranform->GetSelection(); + if ( GetInputData(transform,1) == false) return false; + + dist = 'e'; + int dist_sel = m_distance->GetSelection(); + char dist_choices[] = {'e','b'}; + dist = dist_choices[dist_sel]; + + return true; +} + +bool HDBScanDlg::Run(vector& clusters) +{ + cluster_ids.clear(); + clusters.clear(); + clusters.resize(rows, 0); + + // NOTE input_data should be retrieved first!! + // get input: weights (auto) + weight = GetWeights(columns); // add weight to input_data double** data = new double*[rows]; for (int i=0; i clusters(rows, 0); - vector clusters_undef(rows, false); - + // sort result std::sort(cluster_ids.begin(), cluster_ids.end(), GenUtils::less_vectors); - + for (int i=0; i < ncluster; i++) { int c = i + 1; for (int j=0; jGetValue(); + if (field_name.IsEmpty()) { + wxString err_msg = _("Please enter a field name for saving clustering results."); + wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); + dlg.ShowModal(); + return; + } + + if (CheckAllInputs() == false) return; + + if (Run(clusters) == false) return; // in case not clustered int not_clustered =0; @@ -547,15 +556,6 @@ void HDBScanDlg::OnOKClick(wxCommandEvent& event ) // summary CreateSummary(clusters); - // save to table - wxString field_name = m_textbox->GetValue(); - if (field_name.IsEmpty()) { - wxString err_msg = _("Please enter a field name for saving clustering results."); - wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); - dlg.ShowModal(); - return; - } - int time=0; int col = table_int->FindColId(field_name); if ( col == wxNOT_FOUND) { @@ -576,21 +576,14 @@ void HDBScanDlg::OnOKClick(wxCommandEvent& event ) } if (col > 0) { + vector clusters_undef(rows, false); table_int->SetColData(col, time, clusters); table_int->SetColUndefined(col, time, clusters_undef); } - // free memory - for (int i = 1; i < rows; i++) free(distances[i]); - free(distances); - - //delete[] bound_vals; - //bound_vals = NULL; - // show a cluster map - if (project->IsTableOnlyProject()) { - return; - } + if (project->IsTableOnlyProject()) return; + std::vector new_var_info; std::vector new_col_ids; new_col_ids.resize(1); @@ -612,15 +605,10 @@ void HDBScanDlg::OnOKClick(wxCommandEvent& event ) boost::uuids::nil_uuid(), wxDefaultPosition, GdaConst::map_default_size); - wxString ttl; - ttl << "HDBScan " << _("Cluster Map ") << "("; - ttl << cluster_ids.size(); - ttl << " clusters)"; + wxString tmp = _("HDBScan Cluster Map (%d clusters)"); + wxString ttl = wxString::Format(tmp, (int)cluster_ids.size()); nf->SetTitle(ttl); - - if (not_clustered>0) { - nf->SetLegendLabel(0, _("Not Clustered")); - } + if (not_clustered >0) nf->SetLegendLabel(0, _("Not Clustered")); saveButton->Enable(); @@ -640,5 +628,4 @@ void HDBScanDlg::OnOKClick(wxCommandEvent& event ) */ saveButton->Enable(); - //m_cluster->Enable(); } diff --git a/DialogTools/HDBScanDlg.h b/DialogTools/HDBScanDlg.h index d9ea59773..d0c1cd703 100644 --- a/DialogTools/HDBScanDlg.h +++ b/DialogTools/HDBScanDlg.h @@ -62,8 +62,19 @@ class HDBScanDlg : public AbstractClusterDlg, public HighlightStateObserver void UpdateClusterChoice(int n, std::vector& clusters); void Highlight(int id); void Highlight(vector& ids); - + +protected: + virtual bool Run(vector& clusters); + virtual bool CheckAllInputs(); + protected: + char dist; + int m_min_pts; + int m_min_samples; + double m_alpha; + int m_cluster_selection_method; + bool m_allow_single_cluster; + vector core_dist; vector probabilities; vector outliers; @@ -73,7 +84,6 @@ class HDBScanDlg : public AbstractClusterDlg, public HighlightStateObserver double cutoffDistance; vector clusters; - vector clusters_undef; wxButton *saveButton; wxChoice* combo_n; @@ -83,12 +93,13 @@ class HDBScanDlg : public AbstractClusterDlg, public HighlightStateObserver DendrogramPanel* m_panel; wxTextCtrl* m_minpts; wxTextCtrl* m_minsamples; - wxTextCtrl* m_alpha; + wxTextCtrl* m_ctl_alpha; wxTextCtrl* m_cluster; wxNotebook* notebook; wxChoice* m_select_method; wxCheckBox* chk_allowsinglecluster; - + + DECLARE_EVENT_TABLE() }; diff --git a/DialogTools/KMeansDlg.cpp b/DialogTools/KMeansDlg.cpp index 5559fa4d8..27b7f20da 100644 --- a/DialogTools/KMeansDlg.cpp +++ b/DialogTools/KMeansDlg.cpp @@ -75,21 +75,14 @@ void KClusterDlg::CreateControls() wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); // Input - AddInputCtrls(panel, vbox, true); + bool show_auto_button = true; + AddInputCtrls(panel, vbox, show_auto_button); // Parameters wxFlexGridSizer* gbox = new wxFlexGridSizer(9,2,5,0); // NumberOfCluster Control - wxStaticText* st1 = new wxStaticText(panel, wxID_ANY, - _("Number of Clusters:"), - wxDefaultPosition, wxSize(128,-1)); - combo_n = new wxComboBox(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200,-1), 0, NULL); - max_n_clusters = num_obs < 100 ? num_obs : 100; - for (int i=2; iAppend(wxString::Format("%d", i)); - gbox->Add(st1, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); - gbox->Add(combo_n, 1, wxEXPAND); + AddNumberOfClusterCtrl(panel, gbox); // Minimum Bound Control AddMinBound(panel, gbox); @@ -355,127 +348,49 @@ wxString KClusterDlg::_printConfiguration() void KClusterDlg::ComputeDistMatrix(int dist_sel) { - -} - -bool KClusterDlg::CheckContiguity(double w, double& ssd) -{ - int val = w * 100; - m_weight_centroids->SetValue(val); - m_wc_txt->SetValue(wxString::Format("%f", w)); - - vector clusters; - if (Run(clusters) == false) { - m_weight_centroids->SetValue(100); - m_wc_txt->SetValue("1.0"); - return false; - } - - // not show print - ssd = CreateSummary(clusters, false); - - if (GetDefaultContiguity() == false) - return false; - - map > groups; - map >::iterator it; - for (int i=0; i g; - g.insert(i); - groups[c] = g; - } else { - groups[c].insert(i); - } - } - - bool is_cont = true; - set::iterator item_it; - for (it = groups.begin(); it != groups.end(); it++) { - // check each group if contiguity - set g = it->second; - for (item_it=g.begin(); item_it!=g.end(); item_it++) { - int idx = *item_it; - const vector& nbrs = gal[idx].GetNbrs(); - bool not_in_group = true; - for (int i=0; i >& ssd_pairs) +bool KClusterDlg::CheckAllInputs() { - double delta = right - left; - - if ( delta < 0.01 ) - return; - - int ncluster = 0; + n_cluster = 0; wxString str_ncluster = combo_n->GetValue(); long value_ncluster; if (str_ncluster.ToLong(&value_ncluster)) { - ncluster = value_ncluster; + n_cluster = value_ncluster; } - if (ncluster < 2 || ncluster > num_obs) { + if (n_cluster < 2 || n_cluster > num_obs) { wxString err_msg = _("Please enter a valid number of clusters."); wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); - return; + return false; } - - double mid = left + delta /2.0; - - // assume left is always not contiguity and right is always contiguity - //bool l_conti = CheckContiguity(left); - double m_ssd = 0; - bool m_conti = CheckContiguity(mid, m_ssd); - - if ( m_conti ) { - ssd_pairs.push_back( std::make_pair(mid, m_ssd) ); - return BinarySearch(left, mid, ssd_pairs); - - } else { - return BinarySearch(mid, right, ssd_pairs); + + transform = combo_tranform->GetSelection(); + + if (GetInputData(transform,1) == false) return false; + + if (!CheckMinBound()) return false; + + n_pass = 10; + wxString str_pass = m_pass->GetValue(); + long l_pass; + if(str_pass.ToLong(&l_pass)) { + n_pass = l_pass; } -} -void KClusterDlg::OnAutoWeightCentroids(wxCommandEvent& event) -{ - // apply custom algorithm to find optimal weighting value between 0 and 1 - // when w = 1 (fully geometry based) - // when w = 0 (fully attributes based) - std::vector > ssd_pairs; - BinarySearch(0.0, 1.0, ssd_pairs); - - if (ssd_pairs.empty()) return; - - double w = ssd_pairs[0].first; - double ssd = ssd_pairs[0].second; - - for (int i=1; i ssd) { - ssd = ssd_pairs[i].second; - w = ssd_pairs[i].first; - } + n_maxiter = 300; // max iteration of EM + wxString iterations = m_iterations->GetValue(); + long l_maxiter; + if(iterations.ToLong(&l_maxiter)) { + n_maxiter = l_maxiter; } - - int val = w * 100; - m_weight_centroids->SetValue(val); - m_wc_txt->SetValue(wxString::Format("%f", w)); + + meth_sel = combo_method->GetSelection(); + + dist_sel = m_distance->GetSelection(); + + return true; } bool KClusterDlg::Run(vector& clusters) @@ -487,48 +402,16 @@ bool KClusterDlg::Run(vector& clusters) setrandomstate(-1); resetrandom(); } - - int ncluster = 0; - wxString str_ncluster = combo_n->GetValue(); - long value_ncluster; - if (str_ncluster.ToLong(&value_ncluster)) { - ncluster = value_ncluster; - } - if (ncluster < 2 || ncluster > num_obs) { - wxString err_msg = _("Please enter a valid number of clusters."); - wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); - dlg.ShowModal(); - return false; - } - - int transform = combo_tranform->GetSelection(); - - if (!GetInputData(transform,1)) - return false; - - if (!CheckMinBound()) - return false; - - int npass = 10; - wxString str_pass = m_pass->GetValue(); - long value_pass; - if(str_pass.ToLong(&value_pass)) { - npass = value_pass; - } - - int n_maxiter = 300; // max iteration of EM - wxString iterations = m_iterations->GetValue(); - long value; - if(iterations.ToLong(&value)) { - n_maxiter = value; - } - - int meth_sel = combo_method->GetSelection(); - + + // NOTE input_data should be retrieved first!! + // get input: weights (auto) + // this function has to be called when use auto-weighting + weight = GetWeights(columns); + // start working int nCPUs = boost::thread::hardware_concurrency(); - int quotient = npass / nCPUs; - int remainder = npass % nCPUs; + int quotient = n_pass / nCPUs; + int remainder = n_pass % nCPUs; int tot_threads = (quotient > 0) ? nCPUs : remainder; map >::iterator it; @@ -536,9 +419,7 @@ bool KClusterDlg::Run(vector& clusters) it->second.clear(); } sub_clusters.clear(); - - int dist_sel = m_distance->GetSelection(); - + ComputeDistMatrix(dist_sel); double min_bound = GetMinBound(); @@ -565,7 +446,9 @@ bool KClusterDlg::Run(vector& clusters) if (s1 >0) s1 = a + 1; int n_runs = b - a + 1; - boost::thread* worker = new boost::thread(boost::bind(&KClusterDlg::doRun, this, s1, ncluster, n_runs, n_maxiter, meth_sel, dist_sel, min_bound, bound_vals)); + boost::thread* worker = new boost::thread( + boost::bind(&KClusterDlg::doRun, this, s1, n_cluster, n_runs, + n_maxiter, meth_sel, dist_sel, min_bound, bound_vals)); threadPool.add_thread(worker); } @@ -596,14 +479,7 @@ bool KClusterDlg::Run(vector& clusters) void KClusterDlg::OnOK(wxCommandEvent& event ) { wxLogMessage("Click KClusterDlg::OnOK"); - - int ncluster = 0; - wxString str_ncluster = combo_n->GetValue(); - long value_ncluster; - if (str_ncluster.ToLong(&value_ncluster)) { - ncluster = value_ncluster; - } - + wxString field_name = m_textbox->GetValue(); if (field_name.IsEmpty()) { wxString err_msg = _("Please enter a field name for saving clustering results."); @@ -611,21 +487,19 @@ void KClusterDlg::OnOK(wxCommandEvent& event ) dlg.ShowModal(); return; } - - vector clusters_undef(num_obs, false); - + if (CheckAllInputs() == false) return; + vector clusters; - if (Run(clusters) == false) - return; + if (Run(clusters) == false) return; // sort result - std::vector > cluster_ids(ncluster); + std::vector > cluster_ids(n_cluster); for (int i=0; i < clusters.size(); i++) { cluster_ids[ clusters[i] - 1 ].push_back(i); } std::sort(cluster_ids.begin(), cluster_ids.end(), GenUtils::less_vectors); - for (int i=0; i < ncluster; i++) { + for (int i=0; i < n_cluster; i++) { int c = i + 1; for (int j=0; jInsertCol(GdaConst::long64_type, field_name, col_insert_pos, time_steps, m_length_val, m_decimals_val); + col = table_int->InsertCol(GdaConst::long64_type, field_name, + col_insert_pos, time_steps, + m_length_val, m_decimals_val); } else { // detect if column is integer field, if not raise a warning if (table_int->GetColType(col) != GdaConst::long64_type ) { @@ -657,14 +533,13 @@ void KClusterDlg::OnOK(wxCommandEvent& event ) } if (col > 0) { + vector clusters_undef(num_obs, false); table_int->SetColData(col, time, clusters); table_int->SetColUndefined(col, time, clusters_undef); } // show a cluster map - if (project->IsTableOnlyProject()) { - return; - } + if (project->IsTableOnlyProject()) return; std::vector new_var_info; std::vector new_col_ids; @@ -687,10 +562,8 @@ void KClusterDlg::OnOK(wxCommandEvent& event ) boost::uuids::nil_uuid(), wxDefaultPosition, GdaConst::map_default_size); - wxString ttl; - ttl << cluster_method << " " << _("Cluster Map ") << "("; - ttl << ncluster; - ttl << " clusters)"; + wxString tmp = _("%s Cluster Map (%d clusters)"); + wxString ttl = wxString::Format(tmp, cluster_method, n_cluster); nf->SetTitle(ttl); } @@ -798,17 +671,31 @@ vector > KMediansDlg::_getMeanCenters(const vector >& vector > result(n_clusters); if (columns <= 0 || rows <= 0) return result; - + + std::vector > raw_data; + raw_data.resize(col_ids.size()); + for (int i=0; iGetColData(col_ids[i], var_info[i].time, raw_data[i]); + } + + int start = IsUseCentroids() ? 2 : 0; for (int i=0; i medians; - for (int c=0; c > KMedoidsDlg::_getMeanCenters(const vector >& solutions) +vector > KMedoidsDlg::_getMeanCenters( + const vector >& solutions) { // The centroid is defined as the element with the // smallest sum of distances to the other elements. @@ -895,7 +783,13 @@ vector > KMedoidsDlg::_getMeanCenters(const vector >& vector > result(n_clusters); if (columns <= 0 || rows <= 0) return result; - + + std::vector > raw_data; + raw_data.resize(col_ids.size()); + for (int i=0; iGetColData(col_ids[i], var_info[i].time, raw_data[i]); + } + vector centroid_ids(n_clusters,0); vector errors(n_clusters); for (int j=0; j > KMedoidsDlg::_getMeanCenters(const vector >& } } } - + for (int i=0; i means; - for (int c=0; c >& ssd_pairs); - bool CheckContiguity(double w, double& ss); - bool Run(vector& clusters); - + virtual void ComputeDistMatrix(int dist_sel); virtual wxString _printConfiguration(); virtual vector > _getMeanCenters(const vector >& solution); @@ -65,7 +61,15 @@ class KClusterDlg : public AbstractClusterDlg std::vector col_ids; protected: - virtual void OnAutoWeightCentroids(wxCommandEvent& event); + virtual bool Run(vector& clusters); + virtual bool CheckAllInputs(); + + int n_cluster; + int transform; + int n_pass; + int n_maxiter; + int meth_sel; + int dist_sel; bool show_initmethod; bool show_distance; @@ -73,7 +77,7 @@ class KClusterDlg : public AbstractClusterDlg wxCheckBox* chk_seed; wxChoice* combo_method; - wxComboBox* combo_n; + wxChoice* combo_cov; wxTextCtrl* m_textbox; wxTextCtrl* m_iterations; diff --git a/DialogTools/RedcapDlg.cpp b/DialogTools/RedcapDlg.cpp index 8799c11b4..1a4aaedcc 100644 --- a/DialogTools/RedcapDlg.cpp +++ b/DialogTools/RedcapDlg.cpp @@ -442,7 +442,8 @@ void RedcapDlg::OnSaveTree(wxCommandEvent& event ) file.Close(); // Load the weights file into Weights Manager - WeightUtils::LoadGwtInMan(w_man_int, new_txt, table_int, id); + WeightUtils::LoadGwtInMan(w_man_int, new_txt, table_int, id, + WeightsMetaInfo::WT_tree); } } diff --git a/DialogTools/ReportBugDlg.cpp b/DialogTools/ReportBugDlg.cpp index d6c1fcc17..b6e503300 100644 --- a/DialogTools/ReportBugDlg.cpp +++ b/DialogTools/ReportBugDlg.cpp @@ -148,48 +148,37 @@ size_t write_to_string_(void *ptr, size_t size, size_t count, void *stream) { return size*count; } -string CreateIssueOnGithub(string& post_data) +string CreateIssueOnGithub(wxString& post_data) { std::vector tester_ids = OGRDataAdapter::GetInstance().GetHistory("tester_id"); - if (tester_ids.empty()) { - return ""; - } + if (tester_ids.empty()) return ""; wxString tester_id = tester_ids[0]; - - string url = "https://api.github.com/repos/GeoDaCenter/geoda/issues"; - + const char url[] = "https://api.github.com/repos/GeoDaCenter/geoda/issues"; wxString header_auth = "Authorization: token " + tester_id; - wxString header_user_agent = "User-Agent: GeoDaTester"; string response; - CURL* curl = curl_easy_init(); CURLcode res; if (curl) { struct curl_slist *chunk = NULL; - chunk = curl_slist_append(chunk, header_auth.c_str()); chunk = curl_slist_append(chunk, header_user_agent.c_str()); - // set our custom set of headers res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); - - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data.c_str()); - + curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, + (const char*)post_data.mb_str(wxConvUTF8)); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_to_string_); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1L); - res = curl_easy_perform(curl); curl_easy_cleanup(curl); - /* free the custom headers */ curl_slist_free_all(chunk); - } + return response; } @@ -273,8 +262,6 @@ ReportBugDlg::ReportBugDlg(wxWindow* parent, wxWindowID id, SetParent(parent); SetPosition(pos); Centre(); - - } ReportBugDlg::~ReportBugDlg() @@ -349,8 +336,7 @@ bool ReportBugDlg::CreateIssue(wxString title, wxString body) wxTextFile tfile; if (tfile.Open(logger_path)) { - while (!tfile.Eof()) - { + while (!tfile.Eof()) { body << tfile.GetNextLine() << "\\n"; } } @@ -370,14 +356,9 @@ bool ReportBugDlg::CreateIssue(wxString title, wxString body) json_msg << "\", \"labels\": "; json_msg << labels; json_msg << "}"; - //wxString json_msg = wxString::Format(msg_templ, title, body, labels); - - string msg(json_msg.mb_str(wxConvUTF8)); - - string result = CreateIssueOnGithub(msg); + string result = CreateIssueOnGithub(json_msg); // parse results - if (!result.empty()) { json_spirit::Value v; try { @@ -392,8 +373,7 @@ bool ReportBugDlg::CreateIssue(wxString title, wxString body) ReportResultDlg dlg(NULL, url_issue); dlg.ShowModal(); return true; - } - catch (std::runtime_error e) { + } catch (std::runtime_error e) { wxString msg; msg << "JSON parsing failed: "; msg << e.what(); diff --git a/DialogTools/SkaterDlg.cpp b/DialogTools/SkaterDlg.cpp index 660cac2ad..6424dea1a 100644 --- a/DialogTools/SkaterDlg.cpp +++ b/DialogTools/SkaterDlg.cpp @@ -279,7 +279,8 @@ void SkaterDlg::OnSaveTree(wxCommandEvent& event ) file.Close(); // Load the weights file into Weights Manager - WeightUtils::LoadGwtInMan(w_man_int, new_txt, table_int, id); + WeightUtils::LoadGwtInMan(w_man_int, new_txt, table_int, id, + WeightsMetaInfo::WT_tree); } } diff --git a/DialogTools/SpectralClusteringDlg.cpp b/DialogTools/SpectralClusteringDlg.cpp index 20ddf6c8f..316683605 100644 --- a/DialogTools/SpectralClusteringDlg.cpp +++ b/DialogTools/SpectralClusteringDlg.cpp @@ -54,7 +54,8 @@ BEGIN_EVENT_TABLE( SpectralClusteringDlg, wxDialog ) EVT_CLOSE( SpectralClusteringDlg::OnClose ) END_EVENT_TABLE() -SpectralClusteringDlg::SpectralClusteringDlg(wxFrame* parent_s, Project* project_s) +SpectralClusteringDlg::SpectralClusteringDlg(wxFrame* parent_s, + Project* project_s) : AbstractClusterDlg(parent_s, project_s, _("Spectral Clustering Settings")) { wxLogMessage("Open SpectralClusteringDlg."); @@ -91,7 +92,10 @@ bool SpectralClusteringDlg::Init() void SpectralClusteringDlg::CreateControls() { - wxScrolledWindow* scrl = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(820,880), wxHSCROLL|wxVSCROLL ); + wxScrolledWindow* scrl = new wxScrolledWindow(this, wxID_ANY, + wxDefaultPosition, + wxSize(820,880), + wxHSCROLL|wxVSCROLL ); scrl->SetScrollRate( 5, 5 ); wxPanel *panel = new wxPanel(scrl); @@ -99,22 +103,18 @@ void SpectralClusteringDlg::CreateControls() wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); // Input - AddInputCtrls(panel, vbox); + bool show_auto_button = true; + AddInputCtrls(panel, vbox, show_auto_button); // Parameters wxFlexGridSizer* gbox = new wxFlexGridSizer(14,2,5,0); - // NumberOfCluster Control - wxStaticText* st1 = new wxStaticText(panel, wxID_ANY, _("Number of Clusters:"), wxDefaultPosition, wxSize(128,-1)); - combo_n = new wxComboBox(panel, wxID_ANY); - int max_n_clusters = num_obs < 100 ? num_obs : 100; - for (int i=2; iAppend(wxString::Format("%d", i)); - gbox->Add(st1, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); - gbox->Add(combo_n, 1, wxEXPAND); + // NumberOfCluster Control + AddNumberOfClusterCtrl(panel, gbox); // Spectral controls: KNN - lbl_knn = new wxStaticText(panel, wxID_ANY, _("Affinity with K-NN:"), wxDefaultPosition, wxSize(130,-1)); + lbl_knn = new wxStaticText(panel, wxID_ANY, _("Affinity with K-NN:"), + wxDefaultPosition, wxSize(130,-1)); wxBoxSizer* hbox19 = new wxBoxSizer(wxHORIZONTAL); chk_knn = new wxCheckBox(panel, wxID_ANY, ""); lbl_neighbors = new wxStaticText(panel, wxID_ANY, _("# Neighors:")); @@ -134,7 +134,8 @@ void SpectralClusteringDlg::CreateControls() wxBoxSizer* hbox18 = new wxBoxSizer(wxHORIZONTAL); chk_kernel = new wxCheckBox(panel, wxID_ANY, ""); lbl_sigma = new wxStaticText(panel, wxID_ANY, _("(Gaussian) Sigma:")); - m_sigma = new wxTextCtrl(panel, wxID_ANY, str_sigma, wxDefaultPosition, wxSize(40,-1)); + m_sigma = new wxTextCtrl(panel, wxID_ANY, str_sigma, + wxDefaultPosition, wxSize(40,-1)); hbox18->Add(chk_kernel); hbox18->Add(lbl_sigma); hbox18->Add(m_sigma); @@ -154,14 +155,19 @@ void SpectralClusteringDlg::CreateControls() gbox->Add(hbox22, 1, wxEXPAND); // power iteration option approximation - wxStaticText* st15 = new wxStaticText(panel, wxID_ANY, _("Use Power Iteration:"), wxDefaultPosition, wxSize(134,-1)); + wxStaticText* st15 = new wxStaticText(panel, wxID_ANY, + _("Use Power Iteration:"), + wxDefaultPosition, wxSize(134,-1)); wxBoxSizer *hbox15 = new wxBoxSizer(wxHORIZONTAL); chk_poweriteration = new wxCheckBox(panel, wxID_ANY, ""); lbl_poweriteration = new wxStaticText(panel, wxID_ANY, _("# Max Iteration:")); - txt_poweriteration = new wxTextCtrl(panel, wxID_ANY, "300",wxDefaultPosition, wxSize(70,-1)); + txt_poweriteration = new wxTextCtrl(panel, wxID_ANY, "300", + wxDefaultPosition, wxSize(70,-1)); txt_poweriteration->SetValidator( wxTextValidator(wxFILTER_NUMERIC) ); - chk_poweriteration->Bind(wxEVT_CHECKBOX, &SpectralClusteringDlg::OnCheckPowerIteration, this); - if (project->GetNumRecords() < 2000) { + chk_poweriteration->Bind(wxEVT_CHECKBOX, + &SpectralClusteringDlg::OnCheckPowerIteration, + this); + if (project->GetNumRecords() < 100) { lbl_poweriteration->Disable(); txt_poweriteration->Disable(); } else { @@ -183,7 +189,9 @@ void SpectralClusteringDlg::CreateControls() gbox->Add(st20, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); gbox->Add(st21, 1, wxEXPAND); - wxStaticText* st16 = new wxStaticText(panel, wxID_ANY, _("Initialization Method:"), wxDefaultPosition, wxSize(128,-1)); + wxStaticText* st16 = new wxStaticText(panel, wxID_ANY, + _("Initialization Method:"), + wxDefaultPosition, wxSize(128,-1)); wxString choices16[] = {"KMeans++", "Random"}; combo_method = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(160,-1), 2, choices16); @@ -193,7 +201,9 @@ void SpectralClusteringDlg::CreateControls() gbox->Add(combo_method, 1, wxEXPAND); - wxStaticText* st10 = new wxStaticText(panel, wxID_ANY, _("Initialization Re-runs:"), wxDefaultPosition, wxSize(128,-1)); + wxStaticText* st10 = new wxStaticText(panel, wxID_ANY, + _("Initialization Re-runs:"), + wxDefaultPosition, wxSize(128,-1)); wxTextCtrl *box10 = new wxTextCtrl(panel, wxID_ANY, "150", wxDefaultPosition, wxSize(160,-1)); gbox->Add(st10, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); gbox->Add(box10, 1, wxEXPAND); @@ -215,7 +225,9 @@ void SpectralClusteringDlg::CreateControls() seedButton->Enable(); } - wxStaticText* st11 = new wxStaticText(panel, wxID_ANY, _("Maximum Iterations:"),wxDefaultPosition, wxSize(128,-1)); + wxStaticText* st11 = new wxStaticText(panel, wxID_ANY, + _("Maximum Iterations:"), + wxDefaultPosition, wxSize(128,-1)); wxTextCtrl *box11 = new wxTextCtrl(panel, wxID_ANY, "300"); gbox->Add(st11, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); gbox->Add(box11, 1, wxEXPAND); @@ -230,24 +242,30 @@ void SpectralClusteringDlg::CreateControls() gbox->Add(st12, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); gbox->Add(box12, 1, wxEXPAND); */ - wxStaticText* st13 = new wxStaticText(panel, wxID_ANY, _("Distance Function:"), + wxStaticText* st13 = new wxStaticText(panel, wxID_ANY, + _("Distance Function:"), wxDefaultPosition, wxSize(128,-1)); wxString choices13[] = {"Euclidean", "Manhattan"}; - wxChoice* box13 = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(160,-1), 2, choices13); + wxChoice* box13 = new wxChoice(panel, wxID_ANY, wxDefaultPosition, + wxSize(160,-1), 2, choices13); box13->SetSelection(0); gbox->Add(st13, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 10); gbox->Add(box13, 1, wxEXPAND); - wxStaticBoxSizer *hbox = new wxStaticBoxSizer(wxHORIZONTAL, panel, _("Parameters:")); + wxStaticBoxSizer *hbox = new wxStaticBoxSizer(wxHORIZONTAL, panel, + _("Parameters:")); hbox->Add(gbox, 1, wxEXPAND); // Output - wxStaticText* st3 = new wxStaticText (panel, wxID_ANY, _("Save Cluster in Field:"), + wxStaticText* st3 = new wxStaticText (panel, wxID_ANY, + _("Save Cluster in Field:"), wxDefaultPosition, wxDefaultSize); - wxTextCtrl *box3 = new wxTextCtrl(panel, wxID_ANY, "CL", wxDefaultPosition, wxSize(158,-1)); - wxStaticBoxSizer *hbox1 = new wxStaticBoxSizer(wxHORIZONTAL, panel, _("Output:")); + wxTextCtrl *box3 = new wxTextCtrl(panel, wxID_ANY, "CL", wxDefaultPosition, + wxSize(158,-1)); + wxStaticBoxSizer *hbox1 = new wxStaticBoxSizer(wxHORIZONTAL, panel, + _("Output:")); hbox1->Add(st3, 0, wxALIGN_CENTER_VERTICAL); hbox1->Add(box3, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, 10); @@ -357,7 +375,9 @@ void SpectralClusteringDlg::OnKernelCheck(wxCommandEvent& event) chk_knn->SetValue(!flag); lbl_neighbors->Enable(!flag); m_knn->Enable(!flag); - + lbl_knn->Enable(!flag); + + lbl_kernel->Enable(flag); lbl_sigma->Enable(flag); m_sigma->Enable(flag); } @@ -367,8 +387,10 @@ void SpectralClusteringDlg::OnKNNCheck(wxCommandEvent& event) bool flag = chk_knn->IsChecked(); lbl_neighbors->Enable(flag); m_knn->Enable(flag); - + lbl_knn->Enable(flag); + chk_kernel->SetValue(!flag); + lbl_kernel->Enable(!flag); lbl_sigma->Enable(!flag); m_sigma->Enable(!flag); } @@ -506,7 +528,9 @@ wxString SpectralClusteringDlg::_printConfiguration() if (chk_knn->IsChecked()) { txt << _("Affinity with K-Nearest Neighbors:\tK=") << m_knn->GetValue() << "\n"; } - + if (chk_poweriteration->IsChecked()) { + txt << _("Use Power Iteration method:\tMax iterations=") << txt_poweriteration->GetValue() << "\n"; + } txt << _("Transformation:\t") << combo_tranform->GetString(combo_tranform->GetSelection()) << "\n"; txt << _("Distance function:\t") << m_distance->GetString(m_distance->GetSelection()) << "\n"; @@ -518,98 +542,98 @@ wxString SpectralClusteringDlg::_printConfiguration() return txt; } -void SpectralClusteringDlg::OnOK(wxCommandEvent& event ) +bool SpectralClusteringDlg::CheckAllInputs() { - wxLogMessage("Click SpectralClusteringDlg::OnOK"); - - if (GdaConst::use_gda_user_seed) { - setrandomstate(GdaConst::gda_user_seed); - resetrandom(); - } - - int ncluster = 0; + // get input: variables and data, and auto weights + transform = combo_tranform->GetSelection(); + if( GetInputData(transform, 1) == false) return false; + + // get input: number of cluster + n_cluster = 0; wxString str_ncluster = combo_n->GetValue(); long value_ncluster; if (str_ncluster.ToLong(&value_ncluster)) { - ncluster = value_ncluster; + n_cluster = value_ncluster; } - if (ncluster < 2 || ncluster > num_obs) { + if (n_cluster < 2 || n_cluster > num_obs) { wxString err_msg = _("Please enter a valid number of cluster."); wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); - return; - } - - wxString field_name = m_textbox->GetValue(); - if (field_name.IsEmpty()) { - wxString err_msg = _("Please enter a field name for saving clustering results."); - wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); - dlg.ShowModal(); - return; + return false; } - - int transform = combo_tranform->GetSelection(); - - bool success = GetInputData(transform, 1); - if (!success) { - return; + + // get input: iterations + n_power_iter = 0; + long l_iterations; + if (chk_poweriteration->IsChecked()) { + wxString str_iterations; + str_iterations = txt_poweriteration->GetValue(); + if (str_iterations.ToLong(&l_iterations)) { + n_power_iter = l_iterations; + } } - - wxString field_sigma = m_sigma->GetValue(); - if (field_sigma.IsEmpty()) { - wxString err_msg = _("Please enter a sigma value."); - wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); - dlg.ShowModal(); - return; + + // get input: sigma + value_sigma = 0.018; + double d_value_sigma; + wxString str_sigma = m_sigma->GetValue(); + if(str_sigma.ToDouble(&d_value_sigma)) { + value_sigma = d_value_sigma; } - - char method = 'a'; // mean, 'm' median - char dist = 'e'; // euclidean - int npass = 10; - int n_maxiter = 300; // max iteration of EM - int transpose = 0; // row wise - int* clusterid = new int[rows]; - - wxString iterations = m_iterations->GetValue(); - long value; - if(iterations.ToLong(&value)) { - n_maxiter = value; + + // get input: knn + knn = 4; + wxString str_knn = m_knn->GetValue(); + long value_knn; + if(str_knn.ToLong(&value_knn)) { + knn = value_knn; } - + + // get input: kmeans init + method = 'a'; // mean, 'm' median if (combo_method->GetSelection() == 0) method = 'b'; // mean with kmeans++ - + + // get input: kmeans reruns + npass = 10; wxString str_pass = m_pass->GetValue(); long value_pass; if(str_pass.ToLong(&value_pass)) { npass = value_pass; } - + + // get input: kmeans max iteration + n_maxiter = 300; // max iteration of EM + wxString iterations = m_iterations->GetValue(); + long l_maxiter; + if(iterations.ToLong(&l_maxiter)) { + n_maxiter = l_maxiter; + } + + // get input: distance + dist = 'e'; // euclidean int dist_sel = m_distance->GetSelection(); - char dist_choices[] = {'e','e','b','c','c','a','u','u','x','s','s','k'}; + char dist_choices[] = {'e','b'}; dist = dist_choices[dist_sel]; - - wxString str_sigma = m_sigma->GetValue(); - double value_sigma; - if(str_sigma.ToDouble(&value_sigma)) { - value_sigma = value_sigma; - } - long l_iterations = 0; - if (chk_poweriteration->IsChecked()) { - wxString str_iterations; - str_iterations = txt_poweriteration->GetValue(); - str_iterations.ToLong(&l_iterations); - } - - int knn = 4; - wxString str_knn = m_knn->GetValue(); - long value_knn; - if(str_knn.ToLong(&value_knn)) { - knn = value_knn; + // get input: affinity + affinity_type = chk_kernel->IsChecked() ? 0 : 1; + + return true; +} + +bool SpectralClusteringDlg::Run(vector& clusters) +{ + if (GdaConst::use_gda_user_seed) { + setrandomstate(GdaConst::gda_user_seed); + resetrandom(); + } else { + setrandomstate(-1); + resetrandom(); } - - int affinity_type = 0; - + + // NOTE input_data should be retrieved first!! + // get input: weights (auto) + weight = GetWeights(columns); // add weight to input_data double** data = new double*[rows]; for (int i=0; iIsChecked()) { + spectral.set_centers(n_cluster); + spectral.set_power_iters(n_power_iter); + if (affinity_type == 0) { spectral.set_kernel(0); spectral.set_sigma(value_sigma); - affinity_type = 0; } else { spectral.set_knn(knn); - affinity_type = 1; } + spectral.set_kmeans_dist(dist); + spectral.set_kmeans_method(method); + spectral.set_kmeans_npass(npass); + spectral.set_kmeans_maxiter(n_maxiter); spectral.cluster(affinity_type); + clusters = spectral.get_assignments(); - vector clusters = spectral.get_assignments(); - - for (int i=0; i clusters_undef; - // sort result - std::vector > cluster_ids(ncluster); - + std::vector > cluster_ids(n_cluster); + for (int i=0; i < clusters.size(); i++) { cluster_ids[ clusters[i] - 1 ].push_back(i); } std::sort(cluster_ids.begin(), cluster_ids.end(), GenUtils::less_vectors); - - for (int i=0; i < ncluster; i++) { + + for (int i=0; i < n_cluster; i++) { int c = i + 1; for (int j=0; jGetValue(); + if (field_name.IsEmpty()) { + wxString err_msg = _("Please enter a field name for saving clustering results."); + wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); + dlg.ShowModal(); + return; + } + + vector clusters; + + if (Run(clusters) == false) return; // summary CreateSummary(clusters); - for (int i=0; iFindColId(field_name); @@ -687,14 +724,14 @@ void SpectralClusteringDlg::OnOK(wxCommandEvent& event ) } if (col > 0) { + vector clusters_undef(rows, false); table_int->SetColData(col, time, clusters); table_int->SetColUndefined(col, time, clusters_undef); } // show a cluster map - if (project->IsTableOnlyProject()) { - return; - } + if (project->IsTableOnlyProject()) return; + std::vector new_var_info; std::vector new_col_ids; new_col_ids.resize(1); @@ -716,10 +753,8 @@ void SpectralClusteringDlg::OnOK(wxCommandEvent& event ) boost::uuids::nil_uuid(), wxDefaultPosition, GdaConst::map_default_size); - - wxString ttl; - ttl << "Spectral Clustering Map ("; - ttl << ncluster; - ttl << " clusters)"; + + wxString tmp = _("Spectral Clustering Map (%d clusters)"); + wxString ttl = wxString::Format(tmp, n_cluster); nf->SetTitle(ttl); } diff --git a/DialogTools/SpectralClusteringDlg.h b/DialogTools/SpectralClusteringDlg.h index 96fdcd511..2cd9c45d7 100644 --- a/DialogTools/SpectralClusteringDlg.h +++ b/DialogTools/SpectralClusteringDlg.h @@ -57,10 +57,25 @@ class SpectralClusteringDlg : public AbstractClusterDlg virtual void InitVariableCombobox(wxListBox* var_box); virtual wxString _printConfiguration(); + +protected: + virtual bool Run(vector& clusters); + virtual bool CheckAllInputs(); + protected: + int transform; + int n_cluster; + int n_power_iter; + double value_sigma; + int knn; + char method; + int npass; + int n_maxiter; + char dist; + int affinity_type; + wxCheckBox* chk_seed; wxChoice* combo_method; - wxComboBox* combo_n; wxChoice* combo_cov; wxTextCtrl* m_textbox; wxTextCtrl* m_iterations; diff --git a/DialogTools/VariableSettingsDlg.cpp b/DialogTools/VariableSettingsDlg.cpp index b6e354f4c..e05b8fc71 100644 --- a/DialogTools/VariableSettingsDlg.cpp +++ b/DialogTools/VariableSettingsDlg.cpp @@ -1425,9 +1425,9 @@ void VariableSettingsDlg::InitFieldChoices() GdaConst::FieldType ftype = table_int->GetColType(col_id_map[i]); wxString name = table_int->GetColName(col_id_map[i]); - if (table_int->IsColTimeVariant(col_id_map[i])) + if (table_int->IsColTimeVariant(col_id_map[i])) { name << t1; - + } if ((var1_str) || (!var1_str && ftype == GdaConst::double_type) || (!var1_str && ftype == GdaConst::long64_type)) @@ -1440,8 +1440,9 @@ void VariableSettingsDlg::InitFieldChoices() if (num_var >= 2) { wxString name = table_int->GetColName(col_id_map[i]); - if (table_int->IsColTimeVariant(col_id_map[i])) - name << t2; + if (table_int->IsColTimeVariant(col_id_map[i])) { + name << t2; + } if ((var2_str) || (!var2_str && ftype == GdaConst::double_type) || (!var2_str && ftype == GdaConst::long64_type)) @@ -1455,8 +1456,9 @@ void VariableSettingsDlg::InitFieldChoices() if (num_var >= 3) { wxString name = table_int->GetColName(col_id_map[i]); - if (table_int->IsColTimeVariant(col_id_map[i])) - name << t3; + if (table_int->IsColTimeVariant(col_id_map[i])) { + name << t3; + } if ((var3_str) || (!var3_str && ftype == GdaConst::double_type) || (!var3_str && ftype == GdaConst::long64_type)) @@ -1470,8 +1472,9 @@ void VariableSettingsDlg::InitFieldChoices() if (num_var >= 4) { wxString name = table_int->GetColName(col_id_map[i]); - if (table_int->IsColTimeVariant(col_id_map[i])) - name << t4; + if (table_int->IsColTimeVariant(col_id_map[i])) { + name << t4; + } if ((var4_str) || (!var4_str && ftype == GdaConst::double_type) || (!var4_str && ftype == GdaConst::long64_type)) @@ -1484,20 +1487,24 @@ void VariableSettingsDlg::InitFieldChoices() } } - - - + for (int i=0, iend=col_id_map.size(); iGetColName(col_id_map[i]); if (item_str == default_var_name1) { - lb1_cur_sel = idx_sel1_map[i]; + lb1_cur_sel = idx_sel1_map[i]; + if (style & ALLOW_EMPTY_IN_FIRST) { + lb1_cur_sel = lb1_cur_sel > 0 ? lb1_cur_sel + 1 : 0; + } if (set_second_from_first_mode && num_var >= 2) { - lb2_cur_sel = idx_sel1_map[i]; + lb2_cur_sel = lb1_cur_sel; } } if (num_var >= 2 && item_str == default_var_name2) { if (!set_second_from_first_mode) { - lb2_cur_sel = idx_sel2_map[i]; + lb2_cur_sel = idx_sel2_map[i]; + if (style & ALLOW_EMPTY_IN_SECOND) { + lb1_cur_sel = lb1_cur_sel > 0 ? lb1_cur_sel + 1 : 0; + } } } if (num_var >= 3 && item_str == default_var_name3){ @@ -1514,7 +1521,6 @@ void VariableSettingsDlg::InitFieldChoices() } if (sel1_idx > 0) { - int pos = lb1->GetScrollPos(wxVERTICAL); lb1->SetSelection(lb1_cur_sel); lb1->SetFirstItem(lb1->GetSelection()); } diff --git a/Explore/Basemap.cpp b/Explore/Basemap.cpp index ca990ce90..ab5267cea 100644 --- a/Explore/Basemap.cpp +++ b/Explore/Basemap.cpp @@ -724,15 +724,13 @@ wxString Basemap::GetTilePath(int x, int y) filepathBuf << zoom << "-" << x << "-" << y << imageSuffix; wxString newpath; - for (int i = 0; i < filepathBuf.length() ;i++) - { - if(filepathBuf[i] == '\\') - { + for (int i = 0; i < filepathBuf.length() ;i++) { + if(filepathBuf[i] == '\\') { newpath += filepathBuf[i]; newpath += filepathBuf[i]; - } - else + } else { newpath += filepathBuf[i]; + } } return newpath; } @@ -744,8 +742,7 @@ bool Basemap::Draw(wxBitmap* buffer) dc.SetBackground(*wxWHITE); dc.Clear(); wxGraphicsContext* gc = wxGraphicsContext::Create(dc); - if (!gc) - return false; + if (!gc) return false; int x0 = startX; int x1 = endX; @@ -755,19 +752,20 @@ bool Basemap::Draw(wxBitmap* buffer) int pos_y = (j-startY) * 256 - offsetY; int idx_x = i; - if ( i >= nn) + if ( i >= nn) { idx_x = i - nn; - else if (i < 0) + } else if (i < 0) { idx_x = nn + i; + } - //int idx_y = j < 0 ? nn + j : j; int idx_y = j; wxString wxFilePath = GetTilePath(idx_x, idx_y); wxFileName fp(wxFilePath); wxBitmap bmp; - if (imageSuffix == ".png") { + if (imageSuffix.CmpNoCase(".png") == 0) { bmp.LoadFile(wxFilePath, wxBITMAP_TYPE_PNG); - } else if (imageSuffix == ".jpeg" || imageSuffix == ".jpg" ) { + } else if (imageSuffix.CmpNoCase(".jpeg") == 0 || + imageSuffix.CmpNoCase(".jpg") == 0 ) { bmp.LoadFile(wxFilePath, wxBITMAP_TYPE_JPEG); } if (bmp.IsOk()) { diff --git a/Explore/ConditionalMapView.cpp b/Explore/ConditionalMapView.cpp index 04b5f83b0..f20b10211 100644 --- a/Explore/ConditionalMapView.cpp +++ b/Explore/ConditionalMapView.cpp @@ -167,8 +167,8 @@ void ConditionalMapCanvas::AppendCustomCategories(wxMenu* menu, CatClassifManage for (int i=0; iDelete(items[i]); } - - sm->Append(menu_id[i], _("Create New Custom"), _("Create new custom categories classification.")); + sm->Append(menu_id[i], _("Create New Custom"), + _("Create new custom categories classification.")); sm->AppendSeparator(); vector titles; @@ -176,17 +176,30 @@ void ConditionalMapCanvas::AppendCustomCategories(wxMenu* menu, CatClassifManage for (size_t j=0; jAppend(base_id[i]+j, titles[j]); } - + + GdaFrame* gda_frame = GdaFrame::GetGdaFrame(); + if (i==0) { // regular map men - GdaFrame::GetGdaFrame()->Bind(wxEVT_COMMAND_MENU_SELECTED, - &ConditionalMapCanvas::OnCustomCategoryClick, this, GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_A0, GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_A0 + titles.size()); + int win_id = GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_A0; + int last_id = win_id + titles.size(); + gda_frame->Bind(wxEVT_COMMAND_MENU_SELECTED, + &ConditionalMapCanvas::OnCustomCategoryClick, + this, win_id, last_id); } else if (i==1) { // conditional horizontal map menu - GdaFrame::GetGdaFrame()->Bind(wxEVT_COMMAND_MENU_SELECTED, &GdaFrame::OnCustomCategoryClick_B, GdaFrame::GetGdaFrame(), GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_B0, GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_B0 + titles.size()); + int win_id = GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_B0; + int last_id = win_id + titles.size(); + gda_frame->Bind(wxEVT_COMMAND_MENU_SELECTED, + &GdaFrame::OnCustomCategoryClick_B, + gda_frame, win_id, last_id); } else if (i==2) { // conditional verticle map menu - GdaFrame::GetGdaFrame()->Bind(wxEVT_COMMAND_MENU_SELECTED, &GdaFrame::OnCustomCategoryClick_C, GdaFrame::GetGdaFrame(), GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_C0, GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_C0 + titles.size()); + int win_id = GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_C0; + int last_id = win_id + titles.size(); + gda_frame->Bind(wxEVT_COMMAND_MENU_SELECTED, + &GdaFrame::OnCustomCategoryClick_C, + gda_frame, win_id, last_id); } } } @@ -201,8 +214,9 @@ void ConditionalMapCanvas::OnCustomCategoryClick(wxCommandEvent& event) int idx = xrc_id - GdaConst::ID_CUSTOM_CAT_CLASSIF_CHOICE_A0; if (idx < 0 || idx >= titles.size()) return; wxString cc_title = titles[idx]; - - ((ConditionalMapFrame*) template_frame)->ChangeThemeType(CatClassification::custom, 4, cc_title); + + ConditionalMapFrame* cmap_frame = (ConditionalMapFrame*) template_frame; + cmap_frame->ChangeThemeType(CatClassification::custom, 4, cc_title); } /** * Overwrite TemplaceCanvas Scroll @@ -371,9 +385,9 @@ void ConditionalMapCanvas::NewCustomCatClassifMap() and col_ids. It calls CreateAndUpdateCategories which does all of the category classification. */ void ConditionalMapCanvas::ChangeCatThemeType( - CatClassification::CatClassifType new_cat_theme, - int num_categories_s, - const wxString& custom_classif_title) + CatClassification::CatClassifType new_cat_theme, + int num_categories_s, + const wxString& custom_classif_title) { num_categories = num_categories_s; diff --git a/Explore/ConditionalNewView.cpp b/Explore/ConditionalNewView.cpp index c4077e8b3..d141ca26b 100644 --- a/Explore/ConditionalNewView.cpp +++ b/Explore/ConditionalNewView.cpp @@ -180,7 +180,7 @@ full_map_redraw_needed(true) SetCatType(HOR_VAR, CatClassification::unique_values, horiz_num_cats); } - // case that user only need horizontal axe + // case that user only need horizontal or verticle axe if (var_info[VERT_VAR].is_hide == true) { SetCatType(VERT_VAR, CatClassification::no_theme, 1); } else if (var_info[HOR_VAR].is_hide == true) { diff --git a/Explore/MapLayer.cpp b/Explore/MapLayer.cpp index abe591a6c..23de96dba 100644 --- a/Explore/MapLayer.cpp +++ b/Explore/MapLayer.cpp @@ -22,18 +22,20 @@ map_boundary(NULL) is_hide = true; } -BackgroundMapLayer::BackgroundMapLayer(wxString name, OGRLayerProxy* _layer_proxy, OGRSpatialReference* sr) -: AssociateLayerInt(), -layer_name(name), -layer_proxy(_layer_proxy), -pen_color(wxColour(192, 192, 192)), -brush_color(wxColour(255, 255, 255, 255)), -point_radius(2), -opacity(255), -pen_size(1), -show_boundary(false), -map_boundary(NULL), -show_connect_line(false) +BackgroundMapLayer::BackgroundMapLayer(wxString name, + OGRLayerProxy* _layer_proxy, + OGRSpatialReference* sr) + : AssociateLayerInt(), + layer_name(name), + layer_proxy(_layer_proxy), + pen_color(wxColour(192, 192, 192)), + brush_color(wxColour(255, 255, 255, 255)), + point_radius(2), + opacity(255), + pen_size(1), + show_boundary(false), + map_boundary(NULL), + show_connect_line(false) { is_hide = false; num_obs = layer_proxy->GetNumRecords(); @@ -424,11 +426,6 @@ vector& BackgroundMapLayer::GetShapes() } - - - - - GdaShapeLayer::GdaShapeLayer(wxString _name, BackgroundMapLayer* _ml) : name(_name), ml(_ml) { diff --git a/GenUtils.cpp b/GenUtils.cpp index d9cd648f9..71a77b205 100644 --- a/GenUtils.cpp +++ b/GenUtils.cpp @@ -1263,7 +1263,15 @@ wxString GenUtils::DblToStr(double x, int precision) if (x < 10000000) { ss << std::fixed; } - ss << std::setprecision(precision); + /* + if (x == (int)x) { + ss << (int)x; + } else { + ss << std::setprecision(precision); + ss << x; + } + */ + ss << std::setprecision(precision); ss << x; return wxString(ss.str().c_str(), wxConvUTF8); } @@ -1272,13 +1280,12 @@ wxString GenUtils::IntToStr(int x, int precision) { std::stringstream ss; + if (x < 10000000) { + ss << std::fixed; + } + ss << std::setprecision(precision); + ss << x; - if (x < 10000000) { - ss << std::fixed; - } - ss << std::setprecision(precision); - ss << x; - return wxString(ss.str().c_str(), wxConvUTF8); } diff --git a/GeoDa.cpp b/GeoDa.cpp index c001af0fb..93ae9e232 100644 --- a/GeoDa.cpp +++ b/GeoDa.cpp @@ -34,8 +34,6 @@ #include #include -#include - #include "ogrsf_frmts.h" #include "cpl_conv.h" @@ -230,8 +228,8 @@ bool GdaApp::OnInit(void) CPLSetConfigOption("GDAL_LOCALE_SEPARATOR", poLconv->thousands_sep); CPLSetConfigOption("GDAL_LOCALE_DECIMAL", poLconv->decimal_point); - // forcing to C locale, which is used internally in GeoDa - setlocale(LC_ALL, "C"); + // forcing to UTF-8 locale, which is used internally in GeoDa + setlocale(LC_ALL, "en_US.UTF-8"); // load preferences PreferenceDlg::ReadFromCache(); @@ -261,6 +259,8 @@ bool GdaApp::OnInit(void) } CPLSetConfigOption("OGR_XLS_HEADERS", "FORCE"); CPLSetConfigOption("OGR_XLSX_HEADERS", "FORCE"); + // For reaching DBF file, set SHAPE_ENCODING to "" to avoid any recoding + CPLSetConfigOption("SHAPE_ENCODING", ""); // will suppress "iCCP: known incorrect sRGB profile" warning message // in wxWidgets 2.9.5. This is a bug in libpng. See wxWidgets trac @@ -522,7 +522,6 @@ void GdaFrame::UpdateToolbarAndMenus() GeneralWxUtils::EnableMenuItem(mb, XRCID("ID_SAVE_AS_PROJECT"), proj_open); GeneralWxUtils::EnableMenuItem(mb, XRCID("ID_EXPORT_LAYER"), proj_open); GeneralWxUtils::EnableMenuItem(mb, XRCID("ID_EXPORT_SELECTED"), proj_open); - GeneralWxUtils::EnableMenuItem(mb, XRCID("ID_SHOW_PROJECT_INFO"), proj_open); GeneralWxUtils::CheckMenuItem(mb, XRCID("ID_SELECT_WITH_RECT"), true); @@ -1060,6 +1059,7 @@ void GdaFrame::UpdateRecentDatasourceMenu() } for (size_t i=0; iAppend(wxID_ANY, recent_ds_list[i]); int xrc_id = recent_item->GetId(); @@ -2854,14 +2854,14 @@ void GdaFrame::OnShowConditionalHistView(wxCommandEvent& WXUNUSED(event)) { Project* p = GetProject(); if (!p) return; - - VariableSettingsDlg dlg(project_p, VariableSettingsDlg::trivariate, false, false, - _("Conditional Histogram Variables"), - _("Horizontal Cells"), + + int style = VariableSettingsDlg::ALLOW_STRING_IN_FIRST | VariableSettingsDlg::ALLOW_STRING_IN_SECOND | VariableSettingsDlg::ALLOW_EMPTY_IN_FIRST | VariableSettingsDlg::ALLOW_EMPTY_IN_SECOND; + + VariableSettingsDlg dlg(project_p, VariableSettingsDlg::trivariate, style, + _("Conditional Histogram Variables"), + _("Horizontal Cells"), _("Vertical Cells"), - _("Histogram Variable"), - "", false, false, false, - true, true, false, false); + _("Histogram Variable")); if (dlg.ShowModal() != wxID_OK) return; ConditionalHistogramFrame* subframe = @@ -2875,16 +2875,16 @@ void GdaFrame::OnShowConditionalScatterView(wxCommandEvent& WXUNUSED(event)) { Project* p = GetProject(); if (!p) return; - - VariableSettingsDlg dlg(project_p, VariableSettingsDlg::quadvariate, - false, false, - _("Conditional Scatter Plot Variables"), - _("Horizontal Cells"), + + int style = VariableSettingsDlg::ALLOW_STRING_IN_FIRST | VariableSettingsDlg::ALLOW_STRING_IN_SECOND | VariableSettingsDlg::ALLOW_EMPTY_IN_FIRST | VariableSettingsDlg::ALLOW_EMPTY_IN_SECOND; + + VariableSettingsDlg dlg(project_p, VariableSettingsDlg::quadvariate, style, + _("Conditional Scatter Plot Variables"), + _("Horizontal Cells"), _("Vertical Cells"), - _("Independent Var (x-axis)"), - _("Dependent Var (y-axis)"), - false, false, false, - true, true, false, false); + _("Independent Var (x-axis)"), + _("Dependent Var (y-axis)")); + if (dlg.ShowModal() != wxID_OK) return; ConditionalScatterPlotFrame* subframe = @@ -6488,9 +6488,10 @@ bool GdaFrame::GetHtmlMenuItemsSqlite() int GdaFrame::sqlite3_GetHtmlMenuItemsCB(void *data, int argc, char **argv, char **azColName) { - if (argc != 2) return SQLITE_ERROR; - htmlMenuItems.push_back(MenuItem(argv[0], argv[1])); - return SQLITE_OK; + //if (argc != 2) return SQLITE_ERROR; + //htmlMenuItems.push_back(MenuItem(argv[0], argv[1])); + //return SQLITE_OK; + return 0; } LineChartEventDelay::LineChartEventDelay() diff --git a/Project.cpp b/Project.cpp index 54f43f32c..759993abc 100644 --- a/Project.cpp +++ b/Project.cpp @@ -579,7 +579,7 @@ void Project::SaveDataSourceAs(const wxString& new_ds_name, bool is_update) } if ( new_layer->export_progress == -1 ) { wxString msg = wxString::Format(_("Save as data source (%s) failed.\n\nDetails:"),new_ds_name); - msg << new_layer->error_message.str(); + msg << new_layer->error_message; throw GdaException(msg.mb_str()); } wxMilliSleep(100); @@ -1403,7 +1403,7 @@ bool Project::CommonProjectInit() if (sourceSR ) { project_unit = sourceSR->GetAttrValue("UNIT"); } - + // configurations for save gda project file LayerConfiguration* layer_conf = project_conf->GetLayerConfiguration(); CustomClassifPtree* cust_classif_ptree = layer_conf->GetCustClassifPtree(); WeightsManPtree* spatial_weights = layer_conf->GetWeightsManPtree(); @@ -1427,13 +1427,13 @@ bool Project::CommonProjectInit() ((WeightsNewManager*) w_man_int)-> Init(spatial_weights->GetWeightsMetaInfoList()); } - + // For create Variable Selection Dialog, which has maximum 4 variables + // to select from table for (int i=0; i<4; i++) { default_var_name[i] = ""; default_var_time[i] = 0; } - - if (default_vars) { + if (default_vars != NULL) { int i=0; std::vector tm_strs; table_int->GetTimeStrings(tm_strs); @@ -1543,13 +1543,13 @@ bool Project::InitFromOgrLayer() throw GdaException(open_err_msg.c_str()); } else if ( layer_proxy->HasError() ) { - open_err_msg << layer_proxy->error_message.str(); + open_err_msg << layer_proxy->error_message; throw GdaException(open_err_msg.c_str()); } OGRDatasourceProxy* ds_proxy = OGRDataAdapter::GetInstance().GetDatasourceProxy(datasource_name, ds_type); - + // for some datasource, writable flag can only be obtained after ready layer datasource->UpdateWritable(ds_proxy->is_writable); // Correct variable_order information, which will be used by OGRTable @@ -1565,16 +1565,16 @@ bool Project::InitFromOgrLayer() time_state = new TimeState; table_int = new OGRTable(layer_proxy, ds_type, table_state, time_state, *variable_order); - if (!table_int) { open_err_msg << _("There was a problem reading the table"); delete table_state; + delete time_state; throw GdaException(open_err_msg.c_str()); } - if (!table_int->IsValid()) { open_err_msg = table_int->GetOpenErrorMessage(); delete table_state; + delete time_state; delete table_int; return false; } @@ -1589,26 +1589,15 @@ bool Project::InitFromOgrLayer() if (wxFileExists(cpg_fn)) { wxTextFile cpg_file; cpg_file.Open(cpg_fn); - // read the first line wxString encode_str = cpg_file.GetFirstLine(); SetupEncoding(encode_str); } } - isTableOnly = layer_proxy->IsTableOnly(); - if (ds_type == GdaConst::ds_dbf) isTableOnly = true; - - if (!isTableOnly) { - layer_proxy->ReadGeometries(main_data); - } else { - // prompt user to select X/Y columns to create a geometry layer + if (!isTableOnly) layer_proxy->ReadGeometries(main_data); - } - // run caching in background - // OGRDataAdapter::GetInstance().CacheLayer - //(ds_name.ToStdString(), layer_name.ToStdString(), layer_proxy); return true; } diff --git a/ShapeOperations/GdaCache.cpp b/ShapeOperations/GdaCache.cpp index e73f5aafe..cd361e39e 100644 --- a/ShapeOperations/GdaCache.cpp +++ b/ShapeOperations/GdaCache.cpp @@ -17,7 +17,7 @@ const wxString GdaCache::DB_HOST_HIST = "db_host"; const wxString GdaCache::DB_PORT_HIST = "db_port"; const wxString GdaCache::DB_NAME_HIST = "db_name"; const wxString GdaCache::DB_UNAME_HIST = "db_uname"; -const wxString GdaCache::WS_URL_HIST = "ws_url"; +const wxString GdaCache::WS_URL_HIST = "ws_url"; wxString GdaCache::GetFullPath() { @@ -53,14 +53,16 @@ GdaCache::GdaCache() history_table->ReadData(); - for ( int i=0; i< history_table->n_rows; i++){ + for ( int i=0; i< history_table->n_rows; i++) { + // all strings are encoded and stored using UTF8, so use + // wxString::FromUTF8 to read from char* wxString key = history_table->GetValueAt(i, 0); wxString val = history_table->GetValueAt(i, 1); history_keys.push_back(key); history_vals.push_back(val); } - }catch(GdaException& e) { - //XXX + } catch(GdaException& e) { + throw GdaException("Construct GdaCache Failed."); } } @@ -98,8 +100,9 @@ void GdaCache::AddHistory(wxString param_key, wxString param_val) history_keys.push_back( param_key ); history_vals.push_back( param_val ); // add to spatialite table - wxString sql = "INSERT INTO history VALUES('" + wxString _sql = "INSERT INTO history VALUES('" + param_key +"','"+param_val + "')"; + const char * sql = (const char*) _sql.mb_str(wxConvUTF8); cach_ds_proxy->ExecuteSQL(sql); } @@ -109,7 +112,8 @@ void GdaCache::AddEntry(wxString param_key, wxString param_val) if ( param_key == history_keys[i] ){ // update existing Entry history_vals[i] = param_val; - wxString sql = "UPDATE history SET param_val='" + param_val +"' WHERE param_key='" + param_key + "'"; + wxString _sql = "UPDATE history SET param_val='" + param_val +"' WHERE param_key='" + param_key + "'"; + const char * sql = (const char*) _sql.mb_str(wxConvUTF8); cach_ds_proxy->ExecuteSQL(sql); return; } @@ -118,9 +122,9 @@ void GdaCache::AddEntry(wxString param_key, wxString param_val) history_keys.push_back( param_key ); history_vals.push_back( param_val ); // add to spatialite table - wxString sql = "INSERT INTO history VALUES('" + param_key +"','"+param_val + "')"; - //cach_ds_proxy->ExecuteSQL(sql); - OGRLayer* tmp_layer = cach_ds_proxy->ds->ExecuteSQL(GET_ENCODED_FILENAME(sql), 0, "SQLITE"); + wxString _sql = "INSERT INTO history VALUES('" + param_key +"','"+param_val + "')"; + const char * sql = (const char*) _sql.mb_str(wxConvUTF8); + OGRLayer* tmp_layer = cach_ds_proxy->ds->ExecuteSQL(sql, 0, "SQLITE"); cach_ds_proxy->ds->ReleaseResultSet(tmp_layer); } @@ -188,19 +192,20 @@ bool GdaCache::CacheLayer(wxString ext_ds_name, //Setup coordinate transformation if we need it. OGRCoordinateTransformation *poCT = NULL; - bool bTransform = FALSE; + bool bTransform = FALSE; OGRSpatialReference *poSourceSRS = NULL; // todo OGRSpatialReference *poOutputSRS = new OGRSpatialReference("EPSG:4326"); // Cache - char *papszLCO[] = {"OVERWRITE=yes","FORMAT=Spatialite"}; - wxString cache_layer_name = ext_ds_name + "_"+ext_layer_proxy->name; + const char *papszLCO[255] = {"OVERWRITE=yes","FORMAT=Spatialite"}; + wxString cache_layer_name = ext_ds_name + "_" + ext_layer_proxy->name; + const char *pszName = (const char*)cache_layer_name.mb_str(wxConvUTF8); GDALDataset *poDstDS = cach_ds_proxy->ds; - OGRLayer *poDstLayer = poDstDS->CreateLayer(cache_layer_name.c_str(), + OGRLayer *poDstLayer = poDstDS->CreateLayer(pszName, poOutputSRS, (OGRwkbGeometryType)eGType, - papszLCO); + (char**)papszLCO); if (poDstLayer == NULL) { // raise create cache failed. return false; @@ -232,8 +237,7 @@ bool GdaCache::CacheLayer(wxString ext_ds_name, GIntBig nFeaturesWritten = 0; poSrcLayer->ResetReading(); - while (poFeature = poSrcLayer->GetNextFeature()) - { + while ((poFeature = poSrcLayer->GetNextFeature()) != NULL) { OGRFeature *poDstFeature = OGRFeature::CreateFeature( poDstLayer->GetLayerDefn() ); poDstFeature->SetFrom(poFeature); diff --git a/ShapeOperations/OGRDatasourceProxy.cpp b/ShapeOperations/OGRDatasourceProxy.cpp index 5b347073e..89d217c49 100644 --- a/ShapeOperations/OGRDatasourceProxy.cpp +++ b/ShapeOperations/OGRDatasourceProxy.cpp @@ -47,7 +47,10 @@ OGRDatasourceProxy::OGRDatasourceProxy(wxString _ds_name, GdaConst::DataSourceTy const char* pszDsPath = GET_ENCODED_FILENAME(ds_name); wxString msg; - 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"); + 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 (ds_type == GdaConst::ds_unknown) { throw GdaException(GET_ENCODED_FILENAME(msg)); @@ -66,7 +69,10 @@ OGRDatasourceProxy::OGRDatasourceProxy(wxString _ds_name, GdaConst::DataSourceTy const char *papszOpenOptions[255] = {"AUTODETECT_TYPE=YES", "EMPTY_STRING_AS_NULL=YES"}; ds = (GDALDataset*) GDALOpenEx(pszDsPath, GDAL_OF_VECTOR|GDAL_OF_UPDATE, NULL, papszOpenOptions, NULL); } - + } else if(ds_type == GdaConst::ds_shapefile) { + //const char* papszOpenOptions[255] = {"ENCODING=CP936"}; + //ds = (GDALDataset*) GDALOpenEx(pszDsPath, GDAL_OF_VECTOR|GDAL_OF_UPDATE, NULL, papszOpenOptions, NULL); + ds = (GDALDataset*) GDALOpenEx(pszDsPath, GDAL_OF_VECTOR|GDAL_OF_UPDATE, NULL, NULL, NULL); } else { ds = (GDALDataset*) GDALOpenEx(pszDsPath, GDAL_OF_VECTOR|GDAL_OF_UPDATE, NULL, NULL, NULL); } @@ -126,11 +132,8 @@ OGRDatasourceProxy::OGRDatasourceProxy(wxString format, wxString dest_datasource ds_type = GetGdaDataSourceType(poDriver); // create the output data source. - const char *papszLCO[50] = {"OVERWRITE=yes"}; - //ds = poDriver->CreateDataSource( pszDestDataSource, papszLCO); ds = poDriver->Create( pszDestDataSource, 0,0,0,GDT_Unknown, NULL); - - + if(ds == NULL ) { // driver failed to load error_message << "Unfortunately, GeoDa is not able to execute this request. \n\nDetails: "<< CPLGetLastErrorMsg(); @@ -226,20 +229,22 @@ vector OGRDatasourceProxy::GetLayerNames() return this->layer_names; } -OGRLayerProxy* OGRDatasourceProxy::ExecuteSQL(wxString sql) +OGRLayerProxy* OGRDatasourceProxy::ExecuteSQL(wxString _sql) { - OGRLayer* tmp_layer = ds->ExecuteSQL(GET_ENCODED_FILENAME(sql), 0, 0); + const char * sql = (const char*) _sql.mb_str(wxConvUTF8); + OGRLayer* tmp_layer = ds->ExecuteSQL(sql, 0, 0); //tmp_layer->SyncToDisk(); ds->ReleaseResultSet(tmp_layer); return NULL; } -OGRLayerProxy* OGRDatasourceProxy::GetLayerProxyBySQL(wxString sql) +OGRLayerProxy* OGRDatasourceProxy::GetLayerProxyBySQL(wxString _sql) { // Note: layer is not managed here. Memory leak is possible. - OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0); + const char * sql = (const char*) _sql.mb_str(wxConvUTF8); + OGRLayer* layer = ds->ExecuteSQL(sql, 0, 0); if (layer == NULL) return NULL; - OGRLayerProxy* layer_proxy = new OGRLayerProxy(sql, layer, ds_type); + OGRLayerProxy* layer_proxy = new OGRLayerProxy(_sql, layer, ds_type); return layer_proxy; } @@ -287,16 +292,13 @@ OGRLayerProxy* OGRDatasourceProxy::GetLayerProxy(wxString layer_name) // for some files, there's no layer name. Just get the first one layer = ds->GetLayer(0); if (layer == NULL) { - ostringstream error_message; - error_message << "No layer was found in this datasource."; - throw GdaException(error_message.str().c_str()); + wxString error_message; + error_message << _("No layer was found in this datasource."); + throw GdaException(error_message.mb_str()); } } - //bool is_thread_safe = layer->TestCapability(OLCRandomRead); layer_proxy = new OGRLayerProxy(layer_name, layer, ds_type); - - //todo: if there is one already existed, clean/delete the old first layer_pool[layer_name] = layer_proxy; } @@ -306,25 +308,28 @@ OGRLayerProxy* OGRDatasourceProxy::GetLayerProxy(wxString layer_name) void OGRDatasourceProxy::CreateDataSource(wxString format, wxString dest_datasource) { - ostringstream error_message; + wxString error_message; const char* pszFormat = format.c_str(); const char* pszDestDataSource = dest_datasource.c_str(); GDALDriver *poDriver; poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if( poDriver == NULL ){ - error_message << "Current OGR dirver " + format + " is not supported by GeoDa.\n" << CPLGetLastErrorMsg(); - throw GdaException(error_message.str().c_str()); + error_message << _("Current OGR dirver "); + error_message << format; + error_message << _(" is not supported by GeoDa.\n"); + error_message << CPLGetLastErrorMsg(); + throw GdaException(error_message.mb_str()); } // Create the output data source. GDALDataset *poODS = poDriver->Create( pszDestDataSource, 0,0,0,GDT_Unknown, NULL); if( poODS == NULL ) { // driver failed to load - error_message << "Can't create output OGR driver. \n\nDetails:"<< CPLGetLastErrorMsg(); - throw GdaException(error_message.str().c_str()); + error_message << _("Can't create output OGR driver. \n\nDetails:"); + error_message << CPLGetLastErrorMsg(); + throw GdaException(error_message.mb_str()); } - //OGRDataSource::DestroyDataSource( poODS ); GDALClose(poODS); } @@ -338,28 +343,31 @@ OGRDatasourceProxy::CreateLayer(wxString layer_name, vector& selected_rows, OGRSpatialReference* spatial_ref) { - ostringstream error_message; + wxString error_message; if(!ds->TestCapability(ODsCCreateLayer)) { // driver failed to load - error_message << "GeoDa can't create a layer." - <<"\n\nDetails: "<< CPLGetLastErrorMsg(); - throw GdaException(error_message.str().c_str()); + error_message << _("GeoDa can't create a layer."); + error_message << _("\n\nDetails: "); + error_message << CPLGetLastErrorMsg(); + throw GdaException(error_message.mb_str()); } OGRSpatialReference *poOutputSRS = spatial_ref; - - + // PRECISION is for database e.g. MSSQL // LAUNDER is for database: rename desired field name - char* papszLCO[50] = {"OVERWRITE=yes", "PRECISION=no", "LAUNDER=yes"}; + // ENCODING: set to "" to avoid any recoding + const char* papszLCO[50] = {"OVERWRITE=yes", "PRECISION=no", "LAUNDER=yes", "ENCODING="}; OGRLayer *poDstLayer = ds->CreateLayer(layer_name.mb_str(), - poOutputSRS, eGType, papszLCO); + poOutputSRS, eGType, (char**)papszLCO); if( poDstLayer == NULL ) { - error_message << "Can't write/create layer \"" << layer_name.mb_str() << "\". \n\nDetails: Attemp to write a readonly database, or " - << CPLGetLastErrorMsg(); - throw GdaException(error_message.str().c_str()); + error_message << _("Can't write/create layer \""); + error_message << layer_name; + error_message << _("\". \n\nDetails: Attemp to write a readonly database, or "); + error_message << CPLGetLastErrorMsg(); + throw GdaException(error_message.mb_str()); } map >::iterator field_it; @@ -379,9 +387,9 @@ OGRDatasourceProxy::CreateLayer(wxString layer_name, wxString fname = table->GetColName(id, t); if (fname.empty()) { - error_message << "Can't create layer \"" << layer_name.mb_str() - << "\" with empty field(" << id << ") name."; - throw GdaException(error_message.str().c_str()); + wxString tmp = _("Can't create layer %s with empty field (%s) name."); + error_message << wxString::Format(tmp, layer_name, id); + throw GdaException(error_message.mb_str()); } OGRFieldType ogr_type; @@ -409,8 +417,9 @@ OGRDatasourceProxy::CreateLayer(wxString layer_name, oField.SetPrecision(ogr_fprecision); } if( poDstLayer->CreateField( &oField ) != OGRERR_NONE ) { - error_message << "Creating a field failed.\n\nDetails:" << CPLGetLastErrorMsg(); - throw GdaException(error_message.str().c_str()); + error_message << _("Creating a field failed.\n\nDetails:"); + error_message << CPLGetLastErrorMsg(); + throw GdaException(error_message.mb_str()); } } } diff --git a/ShapeOperations/OGRLayerProxy.cpp b/ShapeOperations/OGRLayerProxy.cpp index f774f82d8..754f94852 100644 --- a/ShapeOperations/OGRLayerProxy.cpp +++ b/ShapeOperations/OGRLayerProxy.cpp @@ -24,7 +24,7 @@ #include #include #include - +#include #include "../ShpFile.h" #include "../GdaException.h" #include "../logger.h" @@ -37,6 +37,7 @@ #include "OGRFieldProxy.h" using namespace std; +using namespace boost; namespace bt = boost::posix_time; /** @@ -46,8 +47,8 @@ OGRLayerProxy::OGRLayerProxy(wxString layer_name, OGRLayer* _layer, GdaConst::DataSourceType _ds_type, bool isNew) -: mapContour(0), n_rows(0), n_cols(0), name(layer_name),ds_type(_ds_type), layer(_layer), -load_progress(0), stop_reading(false), export_progress(0) +: mapContour(0), n_rows(0), n_cols(0), name(layer_name),ds_type(_ds_type), +layer(_layer), load_progress(0), stop_reading(false), export_progress(0) { if (!isNew) n_rows = layer->GetFeatureCount(FALSE); is_writable = layer->TestCapability(OLCCreateField) != 0; @@ -68,8 +69,9 @@ OGRLayerProxy::OGRLayerProxy(OGRLayer* _layer, GdaConst::DataSourceType _ds_type, OGRwkbGeometryType eGType, int _n_rows) -: mapContour(0), layer(_layer), name(_layer->GetName()), ds_type(_ds_type), n_rows(_n_rows), -eLayerType(eGType), load_progress(0), stop_reading(false), export_progress(0) +: mapContour(0), layer(_layer), name(_layer->GetName()), ds_type(_ds_type), +n_rows(_n_rows), eLayerType(eGType), load_progress(0), stop_reading(false), +export_progress(0) { if (n_rows==0) { n_rows = layer->GetFeatureCount(); @@ -224,9 +226,16 @@ bool OGRLayerProxy::IsUndefined(int rid, int cid) return !data[rid]->IsFieldSet(cid); } -wxString OGRLayerProxy::GetValueAt(int rid, int cid) +wxString OGRLayerProxy::GetValueAt(int rid, int cid, wxCSConv* m_wx_encoding) { - wxString rst(data[rid]->GetFieldAsString(cid)); + wxString rst; + if (m_wx_encoding == NULL) { + // following GDAL/OGR using UTF8 to read table data, + // if no custom encoding specified + rst = wxString(data[rid]->GetFieldAsString(cid), wxConvUTF8); + } else { + rst = wxString(data[rid]->GetFieldAsString(cid), *m_wx_encoding); + } return rst; } @@ -245,7 +254,8 @@ void OGRLayerProxy::SetValueAt(int rid, int cid, GIntBig val, bool undef) if (undef) data[rid]->UnsetField(cid); else data[rid]->SetField( cid, val); if (layer->SetFeature(data[rid]) != OGRERR_NONE){ - throw GdaException(wxString("Set value to cell failed.").mb_str()); + wxString msg = _("Set value to cell failed."); + throw GdaException(msg.mb_str()); } } @@ -254,7 +264,8 @@ void OGRLayerProxy::SetValueAt(int rid, int cid, double val, bool undef) if (undef) data[rid]->UnsetField(cid); else data[rid]->SetField( cid, val); if (layer->SetFeature(data[rid]) != OGRERR_NONE){ - throw GdaException(wxString("Set value to cell failed.").mb_str()); + wxString msg = _("Set value to cell failed."); + throw GdaException(msg.mb_str()); } } @@ -263,7 +274,8 @@ void OGRLayerProxy::SetValueAt(int rid, int cid, int year, int month, int day, b if (undef) data[rid]->UnsetField(cid); else data[rid]->SetField( cid, year, month, day); if (layer->SetFeature(data[rid]) != OGRERR_NONE){ - throw GdaException(wxString("Set value to cell failed.").mb_str()); + wxString msg = _("Set value to cell failed."); + throw GdaException(msg.mb_str()); } } @@ -271,8 +283,9 @@ void OGRLayerProxy::SetValueAt(int rid, int cid, int year, int month, int day, i { if (undef) data[rid]->UnsetField(cid); else data[rid]->SetField( cid, year, month, day, hour, minute, second); - if (layer->SetFeature(data[rid]) != OGRERR_NONE){ - throw GdaException(wxString("Set value to cell failed.").mb_str()); + if (layer->SetFeature(data[rid]) != OGRERR_NONE) { + wxString msg = _("Set value to cell failed."); + throw GdaException(msg.mb_str()); } } @@ -281,7 +294,8 @@ void OGRLayerProxy::SetValueAt(int rid, int cid, const char* val, bool is_new, b if (undef) data[rid]->UnsetField(cid); else data[rid]->SetField( cid, val); if (layer->SetFeature(data[rid]) != OGRERR_NONE){ - throw GdaException(wxString("Set value to cell failed.").mb_str()); + wxString msg = _("Set value to cell failed."); + throw GdaException(msg.mb_str()); } } @@ -329,9 +343,8 @@ void OGRLayerProxy::UpdateFieldProperties(int col) field_proxy->Update(); if ( layer->AlterFieldDefn(col, field_proxy->GetFieldDefn(), ALTER_WIDTH_PRECISION_FLAG)!= OGRERR_NONE ) { - wxString msg; - msg << "Change field properties (" << name <<") failed."; - msg << "\n\nDetails:" << CPLGetLastErrorMsg(); + wxString tmp = _("Change field properties (%s) failed.\n\nDetails: %s"); + wxString msg = wxString::Format(tmp, name, CPLGetLastErrorMsg()); throw GdaException(msg.mb_str()); } } @@ -343,16 +356,16 @@ int OGRLayerProxy::AddField(const wxString& field_name, { // check if field existed if (IsFieldExisted(field_name)) { - wxString msg; - msg << "Field (" << field_name <<") already exited."; + wxString tmp = _("Field (%s) already exited."); + wxString msg = wxString::Format(tmp, field_name); throw GdaException(msg.mb_str()); } OGRFieldType ogr_type = GetOGRFieldType(field_type); OGRFieldProxy *oField = new OGRFieldProxy(field_name, ogr_type, field_length, field_precision); if ( layer->CreateField( oField->GetFieldDefn() ) != OGRERR_NONE ) { - wxString msg = wxString::Format(_("Internal Error: Add new field (%s) failed.\n\nDetails:"), field_name); - msg << CPLGetLastErrorMsg(); + wxString tmp = _("Internal Error: Add new field (%s) failed.\n\nDetails:%s"); + wxString msg = wxString::Format(tmp, field_name, CPLGetLastErrorMsg()); throw GdaException(msg.mb_str()); } n_cols++; @@ -370,9 +383,8 @@ void OGRLayerProxy::DeleteField(int pos) } // delete field in actual datasource if( this->layer->DeleteField(pos) != OGRERR_NONE ) { - wxString msg; - msg << "Internal Error: Delete field failed." - << "\n\nDetails:" << CPLGetLastErrorMsg(); + wxString msg = _("Internal Error: Delete field failed.\n\nDetails:"); + msg << CPLGetLastErrorMsg(); throw GdaException(msg.mb_str()); } n_cols--; @@ -519,11 +531,12 @@ vector OGRLayerProxy::GetIntegerAndStringFieldNames() return names; } -Shapefile::ShapeType OGRLayerProxy::GetOGRGeometries(vector& geoms, OGRSpatialReference* input_sr) +Shapefile::ShapeType OGRLayerProxy::GetOGRGeometries(vector& geoms, + OGRSpatialReference* dest_sr) { OGRCoordinateTransformation *poCT = NULL; - if (input_sr && spatialRef) { - poCT = OGRCreateCoordinateTransformation(input_sr, spatialRef); + if (dest_sr && spatialRef) { + poCT = OGRCreateCoordinateTransformation(spatialRef, dest_sr); } Shapefile::ShapeType shape_type; //read OGR geometry features @@ -554,11 +567,12 @@ Shapefile::ShapeType OGRLayerProxy::GetOGRGeometries(vector& geoms return shape_type; } -Shapefile::ShapeType OGRLayerProxy::GetGdaGeometries(vector& geoms, OGRSpatialReference* input_sr) +Shapefile::ShapeType OGRLayerProxy::GetGdaGeometries(vector& geoms, + OGRSpatialReference* dest_sr) { OGRCoordinateTransformation *poCT = NULL; - if (input_sr && spatialRef) { - poCT = OGRCreateCoordinateTransformation(input_sr, spatialRef); + if (dest_sr && spatialRef) { + poCT = OGRCreateCoordinateTransformation(spatialRef, dest_sr); } Shapefile::ShapeType shape_type; //read OGR geometry features @@ -575,7 +589,11 @@ Shapefile::ShapeType OGRLayerProxy::GetGdaGeometries(vector& geoms, O shape_type = Shapefile::POINT_TYP; if (geometry) { OGRPoint* p = (OGRPoint *) geometry; - geoms.push_back(new GdaPoint(p->getX(), p->getY())); + double ptX = p->getX(), ptY = p->getY(); + if (poCT) { + poCT->Transform(1, &ptX, &ptY); + } + geoms.push_back(new GdaPoint(ptX, ptY)); } } else if (eType == wkbMultiPoint) { shape_type = Shapefile::POINT_TYP; @@ -693,8 +711,8 @@ Shapefile::ShapeType OGRLayerProxy::GetGdaGeometries(vector& geoms, O } geoms.push_back(new GdaPolygon(pc)); } else { - string open_err_msg = "GeoDa does not support datasource with line data at this time. Please choose a datasource with either point or polygon data."; - throw GdaException(open_err_msg.c_str()); + wxString msg = _("GeoDa does not support datasource with line data at this time. Please choose a datasource with either point or polygon data."); + throw GdaException(msg.mb_str()); } } return shape_type; @@ -707,6 +725,7 @@ OGRLayerProxy::AddFeatures(vector& geometries, { export_progress = 0; stop_exporting = false; + wxCSConv* encoding = table->GetEncoding(); // Create features in memory first for (size_t i=0; i& geometries, int col_pos = table->GetColIdx(fname, ignore_case); if (col_pos < 0) { - //wxString msg = wxString::Format(_(" Save column %s failed. Please check your data, or contact GeoDa team."), fname); - //error_message << msg; - //export_progress = -1; - //return; continue; } @@ -825,7 +840,7 @@ OGRLayerProxy::AddFeatures(vector& geometries, vector col_data; table->GetDirectColData(col_pos, col_data); table->GetDirectColUndefined(col_pos, undefs); - + if (ds_type == GdaConst::ds_csv) { for (int m=0; m& geometries, if (undefs[orig_id]) { data[k]->UnsetField(j); } else { - data[k]->SetField(j, col_data[orig_id].mb_str()); + char* val = NULL; + if (encoding == NULL) + val = (char*)col_data[orig_id].mb_str().data(); + else + val = (char*)col_data[orig_id].mb_str(*encoding).data(); + data[k]->SetField(j, val); } if (stop_exporting) return; } @@ -887,7 +907,7 @@ void OGRLayerProxy::Save() bool OGRLayerProxy::HasError() { - return !error_message.str().empty(); + return error_message.IsEmpty() == false; } bool OGRLayerProxy::CheckIsTableOnly() @@ -901,7 +921,7 @@ bool OGRLayerProxy::CheckIsTableOnly() bool OGRLayerProxy::ReadData() { if (n_rows > 0 && n_rows == data.size()) { - // if data already been read, skip + // skip if data has already been read/loaded return true; } if (n_rows == 0) { @@ -911,41 +931,31 @@ bool OGRLayerProxy::ReadData() } int row_idx = 0; OGRFeature *feature = NULL; - map feature_dict; - + unordered_map feature_dict; layer->ResetReading(); while ((feature = layer->GetNextFeature()) != NULL) { - if (feature == NULL) { - error_message << "GeoDa can't read data from datasource." - << "\n\nDetails:"<< CPLGetLastErrorMsg(); - return false; - } - // thread feature: user can stop reading - if (stop_reading) - break; - - //long fid = feature->GetFID(); + if (stop_reading) break; feature_dict[row_idx] = feature; - - // keep load_progress not 100%, so that it can finish this function load_progress = row_idx++; } if (row_idx == 0) { - error_message << "GeoDa can't read data from datasource." - << "\n\nDetails: Datasource is empty. "<< CPLGetLastErrorMsg(); - + error_message << _("GeoDa can't read data from datasource. \n\nDetails: Datasource is empty."); + error_message << CPLGetLastErrorMsg(); return false; } if (stop_reading) { error_message << "Reading data was interrupted."; + // clean just read OGRFeatures + for (int i = 0; i < row_idx; i++) { + OGRFeature::DestroyFeature(feature_dict[i]); + } return false; } - n_rows = row_idx; - - // check empty rows at the end of table, remove empty rows #563 - for (int i = n_rows-1; i>=0; i--) { + // check empty rows at the end of table -- this often occurs in a csv file + // , then remove empty rows see issue#563 + for (int i = n_rows-1; i >= 0; --i) { OGRFeature* my_feature = feature_dict[i]; bool is_empty = true; for (int j= 0; jClone(); data.push_back(my_feature); OGRFeature::DestroyFeature(feature_dict[i]); } - + // Set load_progress 100% to continue load_progress = row_idx; feature_dict.clear(); - return true; } @@ -1126,7 +1138,9 @@ bool OGRLayerProxy::AddGeometries(Shapefile::Main& p_main) } } } - layer->SetFeature(data[id]); + if (layer->SetFeature(data[id]) != OGRERR_NONE) { + return false; + } } return true; } @@ -1135,14 +1149,15 @@ bool OGRLayerProxy::GetExtent(double& minx, double& miny, double& maxx, double& maxy) { OGREnvelope pEnvelope; - layer->GetExtent(&pEnvelope); + if (layer->GetExtent(&pEnvelope) != OGRERR_NONE) return false; minx = pEnvelope.MinX; miny = pEnvelope.MinY; maxx = pEnvelope.MaxX; maxy = pEnvelope.MaxY; - if ( minx == miny && maxx == maxy && minx == 0 && maxx==0) + if ( minx == miny && maxx == maxy && minx == 0 && maxx==0) { return false; + } return true; } diff --git a/ShapeOperations/OGRLayerProxy.h b/ShapeOperations/OGRLayerProxy.h index 19f63325e..7c6e39a16 100644 --- a/ShapeOperations/OGRLayerProxy.h +++ b/ShapeOperations/OGRLayerProxy.h @@ -58,14 +58,14 @@ class OGRLayerProxy { ~OGRLayerProxy(); GdaConst::DataSourceType ds_type; - ostringstream error_message; + // progress indicator: -1 means error, otherwise means progress int load_progress; bool stop_reading; int export_progress; bool stop_exporting; - + wxString error_message; bool is_writable; wxString name; @@ -270,7 +270,7 @@ class OGRLayerProxy { bool IsUndefined(int rid, int cid); - wxString GetValueAt(int rid, int cid); + wxString GetValueAt(int rid, int cid, wxCSConv* m_wx_encoding = NULL); void GetValueAt(int rid, int cid, GIntBig* val); diff --git a/ShapeOperations/WeightUtils.cpp b/ShapeOperations/WeightUtils.cpp index 1c8def1d3..63e68db72 100644 --- a/ShapeOperations/WeightUtils.cpp +++ b/ShapeOperations/WeightUtils.cpp @@ -857,7 +857,11 @@ GalElement* WeightUtils::Gwt2Gal(GwtElement* Gwt, long obs) } -void WeightUtils::LoadGwtInMan(WeightsManInterface* w_man_int, wxString filepath, TableInterface* table_int, wxString id_field) +void WeightUtils::LoadGwtInMan(WeightsManInterface* w_man_int, + wxString filepath, + TableInterface* table_int, + wxString id_field, + WeightsMetaInfo::WeightTypeEnum type) { int rows = table_int->GetNumberRows(); @@ -885,7 +889,8 @@ void WeightUtils::LoadGwtInMan(WeightsManInterface* w_man_int, wxString filepath wmi.SetMedianNumNbrs(w->GetMedianNumNbrs()); wmi.SetSparsity(w->GetSparsity()); wmi.SetDensity(w->GetDensity()); - + wmi.SetWeightsType(type); + WeightsMetaInfo e(wmi); e.filename = filepath; diff --git a/ShapeOperations/WeightUtils.h b/ShapeOperations/WeightUtils.h index aea3a9820..e82d96639 100644 --- a/ShapeOperations/WeightUtils.h +++ b/ShapeOperations/WeightUtils.h @@ -20,6 +20,8 @@ #ifndef __GEODA_CENTER_WEIGHT_UTILS_H__ #define __GEODA_CENTER_WEIGHT_UTILS_H__ +#include "../VarCalc/WeightsMetaInfo.h" + class TableInterface; class GalWeight; class GwtWeight; @@ -35,7 +37,9 @@ namespace WeightUtils { TableInterface* table_int); GwtElement* ReadGwt(const wxString& w_fname, TableInterface* table_int); GalElement* Gwt2Gal(GwtElement* Gwt, long obs); - void LoadGwtInMan(WeightsManInterface* w_man_int, wxString filepath, TableInterface* table_int, wxString id_field); + void LoadGwtInMan(WeightsManInterface* w_man_int, wxString filepath, + TableInterface* table_int, wxString id_field, + WeightsMetaInfo::WeightTypeEnum type); } #endif diff --git a/ShapeOperations/WeightsManPtree.cpp b/ShapeOperations/WeightsManPtree.cpp index 8756e8cf1..ed62a30c2 100644 --- a/ShapeOperations/WeightsManPtree.cpp +++ b/ShapeOperations/WeightsManPtree.cpp @@ -106,6 +106,8 @@ void WeightsManPtree::ReadPtree(const boost::property_tree::ptree& pt, e.wmi.weights_type = WeightsMetaInfo::WT_knn; } else if (s == "kernel") { e.wmi.weights_type = WeightsMetaInfo::WT_kernel; + } else if (s == "tree") { + e.wmi.weights_type = WeightsMetaInfo::WT_tree; } else { // s == "custom" e.wmi.weights_type = WeightsMetaInfo::WT_custom; } @@ -304,9 +306,10 @@ void WeightsManPtree::WritePtree(boost::property_tree::ptree& pt, if (!e.title.IsEmpty()) ssub.put("title", e.title); if (e.is_default) ssub.put("default", ""); ptree& sssub = ssub.add("meta_info", ""); - if (e.wmi.weights_type == WeightsMetaInfo::WT_custom) - { + + if (e.wmi.weights_type == WeightsMetaInfo::WT_custom) { sssub.put("weights_type", "custom"); + } else if (e.wmi.weights_type == WeightsMetaInfo::WT_rook || e.wmi.weights_type == WeightsMetaInfo::WT_queen) { @@ -319,9 +322,11 @@ void WeightsManPtree::WritePtree(boost::property_tree::ptree& pt, } else { sssub.put("inc_lower_orders", "false"); } + } else if (e.wmi.weights_type == WeightsMetaInfo::WT_threshold || e.wmi.weights_type == WeightsMetaInfo::WT_knn || - e.wmi.weights_type == WeightsMetaInfo::WT_kernel) + e.wmi.weights_type == WeightsMetaInfo::WT_kernel || + e.wmi.weights_type == WeightsMetaInfo::WT_tree) { if (e.wmi.weights_type == WeightsMetaInfo::WT_knn) sssub.put("weights_type", "knn"); @@ -329,6 +334,8 @@ void WeightsManPtree::WritePtree(boost::property_tree::ptree& pt, sssub.put("weights_type", "threshold"); else if (e.wmi.weights_type == WeightsMetaInfo::WT_kernel) sssub.put("weights_type", "kernel"); + else if (e.wmi.weights_type == WeightsMetaInfo::WT_tree) + sssub.put("weights_type", "tree"); else sssub.put("weights_type", "custom"); diff --git a/TemplateLegend.h b/TemplateLegend.h index 98d04dfac..052805266 100644 --- a/TemplateLegend.h +++ b/TemplateLegend.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/VarCalc/WeightsMetaInfo.cpp b/VarCalc/WeightsMetaInfo.cpp index 8bb70eae8..085f11b0b 100644 --- a/VarCalc/WeightsMetaInfo.cpp +++ b/VarCalc/WeightsMetaInfo.cpp @@ -97,6 +97,11 @@ void WeightsMetaInfo::SetSymmetric(bool is_sym) sym_type = is_sym ? SYM_symmetric : SYM_unknown; } +void WeightsMetaInfo::SetWeightsType(WeightTypeEnum type) +{ + weights_type = type; +} + void WeightsMetaInfo::SetToRook(const wxString& idv, long order_, bool inc_lower_orders_) { SetToDefaults(); @@ -258,7 +263,9 @@ wxString WeightsMetaInfo::TypeToStr() const return "kernel"; } else if (weights_type == WT_knn) { return "k-NN"; - } + } else if (weights_type == WT_tree) { + return "tree"; + } return "custom"; } diff --git a/VarCalc/WeightsMetaInfo.h b/VarCalc/WeightsMetaInfo.h index 7c0bdc319..0efb68cf4 100644 --- a/VarCalc/WeightsMetaInfo.h +++ b/VarCalc/WeightsMetaInfo.h @@ -26,7 +26,7 @@ struct WeightsMetaInfo { enum WeightTypeEnum { - WT_custom, WT_rook, WT_queen, WT_threshold, WT_inverse, WT_kernel, WT_knn + WT_custom, WT_rook, WT_queen, WT_threshold, WT_inverse, WT_kernel, WT_knn, WT_tree }; enum SymmetryEnum { SYM_unknown, SYM_symmetric, SYM_asymmetric @@ -163,6 +163,7 @@ struct WeightsMetaInfo void SetMeanNumNbrs(double val); void SetMedianNumNbrs(double val); void SetSymmetric(bool is_sym); + void SetWeightsType(WeightTypeEnum type); }; #endif diff --git a/Weights/DistUtils.cpp b/Weights/DistUtils.cpp index 80afbc16b..e79f299c5 100644 --- a/Weights/DistUtils.cpp +++ b/Weights/DistUtils.cpp @@ -15,7 +15,8 @@ using namespace GeoDa; -DistUtils::DistUtils(const std::vector >& input_data, int distance_metric) +DistUtils::DistUtils(const std::vector >& input_data, + int distance_metric) { eps = 0.0; diff --git a/rc/GdaAppResources.cpp b/rc/GdaAppResources.cpp index fa22a4369..b1a6edf85 100644 --- a/rc/GdaAppResources.cpp +++ b/rc/GdaAppResources.cpp @@ -15530,7 +15530,7 @@ static unsigned char xml_res_file_7[] = { 16,48,4,12,1,67,192,16,48,4,12,1,67,160,133,35,240,255,75,175,9,51,209, 227,12,205,0,0,0,0,73,69,78,68,174,66,96,130}; -static size_t xml_res_size_8 = 392239; +static size_t xml_res_size_8 = 394927; static unsigned char xml_res_file_8[] = { 60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101, 110,99,111,100,105,110,103,61,34,117,116,102,45,56,34,63,62,10,60,114,101, @@ -30947,7 +30947,7 @@ static unsigned char xml_res_file_8[] = { 99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,112,97,99,101,114, 34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,60,115,105,122,101,62,48,44,52,48,60,47,115,105,122,101,62,10,32,32, +32,60,115,105,122,101,62,50,44,51,48,60,47,115,105,122,101,62,10,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106, 101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, @@ -30957,7 +30957,7 @@ static unsigned char xml_res_file_8[] = { 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, 116,32,99,108,97,115,115,61,34,115,112,97,99,101,114,34,62,10,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, -115,105,122,101,62,52,44,49,48,60,47,115,105,122,101,62,10,32,32,32,32, +115,105,122,101,62,52,44,49,52,60,47,115,105,122,101,62,10,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98, 106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34, @@ -30997,148 +30997,235 @@ static unsigned char xml_res_file_8[] = { 99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62, -10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101, -99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,108,97, -98,101,108,62,70,105,108,101,60,47,108,97,98,101,108,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97, -115,115,61,34,110,111,116,101,98,111,111,107,112,97,103,101,34,62,10,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32, -99,108,97,115,115,61,34,119,120,80,97,110,101,108,34,32,110,97,109,101, -61,34,100,115,68,97,116,97,98,97,115,101,34,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97, -115,115,61,34,119,120,66,111,120,83,105,122,101,114,34,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,114,105,101,110, -116,62,119,120,86,69,82,84,73,67,65,76,60,47,111,114,105,101,110,116,62, -10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98, -106,101,99,116,32,99,108,97,115,115,61,34,115,112,97,99,101,114,34,62,10, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115, -105,122,101,62,48,44,49,48,60,47,115,105,122,101,62,10,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62, -10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98, -106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101, -109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,70,108, -101,120,71,114,105,100,83,105,122,101,114,34,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, -116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62, -10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83, -116,97,116,105,99,84,101,120,116,34,32,110,97,109,101,61,34,73,68,95,83, -84,65,84,73,67,84,69,88,84,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62, -68,97,116,97,98,97,115,101,32,84,121,112,101,60,47,108,97,98,101,108,62, -10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114, -62,53,60,47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62, -10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, -114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108, -97,115,115,61,34,119,120,67,104,111,105,99,101,34,32,110,97,109,101,61, -34,73,68,67,95,67,68,83,95,68,66,95,84,89,80,69,34,62,10,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, -115,105,122,101,62,51,52,48,44,45,49,60,47,115,105,122,101,62,10,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,99,111,110,116,101,110,116,47,62,10,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101, -99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32, -99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116, +32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111, +98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,66,111,120,83,105, +122,101,114,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,60,111,114,105,101,110,116,62,119,120,72,79,82,73, +90,79,78,84,65,76,60,47,111,114,105,101,110,116,62,10,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101, +99,116,32,99,108,97,115,115,61,34,115,112,97,99,101,114,34,62,10,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97, -116,105,99,84,101,120,116,34,47,62,10,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103,62,119,120, -65,76,73,71,78,95,67,69,78,84,82,69,95,72,79,82,73,90,79,78,84,65,76,60, -47,102,108,97,103,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,53,60,47,98, -111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106, +60,115,105,122,101,62,52,44,49,52,60,47,115,105,122,101,62,10,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111, +98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, +34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101, +99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120, +116,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,69,78,67,79,68,73, +78,71,95,76,65,66,69,76,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,83, +101,108,101,99,116,32,101,110,99,111,100,105,110,103,32,40,111,112,116, +105,111,110,97,108,41,58,32,60,47,108,97,98,101,108,62,10,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111, +98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106, 101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109, 34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119, -120,83,116,97,116,105,99,84,101,120,116,34,32,110,97,109,101,61,34,73,68, -67,95,83,84,65,84,73,67,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,68, -97,116,97,98,97,115,101,32,72,111,115,116,60,47,108,97,98,101,108,62,10, +120,67,104,111,105,99,101,34,32,110,97,109,101,61,34,73,68,67,95,67,68, +83,95,69,78,67,79,68,73,78,71,95,67,72,79,73,67,69,34,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,115,105,122,101,62,49,54,48,44,45,49,60,47,115,105,122,101,62,10,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,99,111,110,116,101,110,116,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116, +101,109,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109,62,85,110,105,99, +111,100,101,32,40,85,84,70,45,56,41,60,47,105,116,101,109,62,10,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,105,116,101,109,62,85,110,105,99,111,100,101,32,40,85,84,70, +45,49,54,76,69,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116, +101,109,62,65,114,97,98,105,99,32,40,87,105,110,100,111,119,115,45,49,50, +53,54,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109, +62,67,101,110,116,114,97,108,32,69,117,114,111,112,101,97,110,32,76,97, +116,105,110,45,50,32,40,73,83,79,45,56,56,53,57,45,50,41,60,47,105,116, +101,109,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109,62,67,101,110,116,114, +97,108,32,69,117,114,111,112,101,97,110,32,40,87,105,110,100,111,119,115, +45,49,50,53,48,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116, +101,109,62,67,101,110,116,114,97,108,32,69,117,114,111,112,101,97,110,32, +40,67,80,56,53,50,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105, +116,101,109,62,67,104,105,110,101,115,101,32,83,105,109,112,108,105,102, +105,101,100,32,40,71,66,50,51,49,50,41,60,47,105,116,101,109,62,10,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10, +32,32,32,32,60,105,116,101,109,62,67,104,105,110,101,115,101,32,84,114, +97,100,105,116,105,111,110,97,108,32,40,66,105,103,53,41,60,47,105,116, +101,109,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109,62,67,121,114,105,108, +108,105,99,32,40,73,83,79,45,56,56,53,57,45,53,41,60,47,105,116,101,109, +62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,105,116,101,109,62,67,121,114,105,108,108,105, +99,32,40,75,79,73,56,45,82,41,60,47,105,116,101,109,62,10,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114, -105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115, -115,61,34,119,120,84,101,120,116,67,116,114,108,34,32,110,97,109,101,61, -34,73,68,67,95,67,68,83,95,68,66,95,72,79,83,84,34,32,115,117,98,99,108, -97,115,115,61,34,65,117,116,111,84,101,120,116,67,116,114,108,34,62,10, +32,60,105,116,101,109,62,67,121,114,105,108,108,105,99,32,40,87,105,110, +100,111,119,115,45,49,50,53,49,41,60,47,105,116,101,109,62,10,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,60,115,105,122,101,62,49,55,48,44,45,49,100,60,47,115,105,122, -101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32, +32,32,32,60,105,116,101,109,62,67,121,114,105,108,108,105,99,47,82,117, +115,115,105,97,110,32,40,67,80,56,54,54,41,60,47,105,116,101,109,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,60,105,116,101,109,62,71,114,101,101,107,32,40,73,83, +79,45,56,56,53,57,45,55,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,105,116,101,109,62,72,101,98,114,101,119,32,40,73,83,79,45,56,56,53, +57,45,56,45,49,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116, +101,109,62,72,101,98,114,101,119,32,40,87,105,110,100,111,119,115,45,49, +50,53,53,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116,101, +109,62,74,97,112,97,110,101,115,101,32,40,83,104,105,102,116,95,74,73,83, +41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109,62,74, +97,112,97,110,101,115,101,32,40,69,85,67,45,74,80,41,60,47,105,116,101, +109,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,60,105,116,101,109,62,75,111,114,101,97,110, +32,40,69,85,67,45,75,82,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,105,116,101,109,62,78,111,114,100,105,99,32,76,97,116,105,110,45,54, +32,40,73,83,79,45,56,56,53,57,45,49,48,41,60,47,105,116,101,109,62,10,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,105,116,101,109,62,83,111,117,116,104,32,69,117,114,111, +112,101,97,110,32,76,97,116,105,110,45,51,32,40,73,83,79,45,56,56,53,57, +45,51,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109, +62,84,117,114,107,105,115,104,32,76,97,116,105,110,45,53,32,40,73,83,79, +45,56,56,53,57,45,57,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, +105,116,101,109,62,84,117,114,107,105,115,104,32,40,87,105,110,100,111, +119,115,45,49,50,53,52,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,105,116,101,109,62,86,105,101,116,110,97,109,101,115,101,32,40,87,105, +110,100,111,119,115,45,49,50,53,56,41,60,47,105,116,101,109,62,10,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,60,105,116,101,109,62,87,101,115,116,32,69,117,114,111,112, +101,97,110,32,76,97,116,105,110,45,49,32,40,73,83,79,45,56,56,53,57,45, +49,41,60,47,105,116,101,109,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,105,116,101,109,62, +87,101,115,116,32,69,117,114,111,112,101,97,110,32,76,97,116,105,110,45, +57,32,40,73,83,79,45,56,56,53,57,45,49,53,41,60,47,105,116,101,109,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,60,47,99,111,110,116,101,110,116,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106, +101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116, +62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47, +111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,70,105,108,101,60,47, +108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47, +111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, +111,98,106,101,99,116,32,99,108,97,115,115,61,34,110,111,116,101,98,111, +111,107,112,97,103,101,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,80, +97,110,101,108,34,32,110,97,109,101,61,34,100,115,68,97,116,97,98,97,115, +101,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111, +98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,66,111,120,83,105, +122,101,114,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,111,114,105,101,110,116,62,119,120,86,69,82,84,73,67,65,76, +60,47,111,114,105,101,110,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, +34,115,112,97,99,101,114,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,48,44,49,48,60,47,115, +105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115, +61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32, +99,108,97,115,115,61,34,119,120,70,108,101,120,71,114,105,100,83,105,122, +101,114,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115, +105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116, +32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120,116, +34,32,110,97,109,101,61,34,73,68,95,83,84,65,84,73,67,84,69,88,84,34,62, +10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,108,97,98,101,108,62,68,97,116,97,98,97,115,101,32,84, +121,112,101,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99, 116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122, -101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108, +32,32,32,32,32,60,98,111,114,100,101,114,62,53,60,47,98,111,114,100,101, +114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99, +108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,67,104,111, +105,99,101,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95, +84,89,80,69,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,51,52,48,44,45,49, +60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,60,99,111,110,116,101,110,116,47, +62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116, +62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, +114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108, 97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120,116,34,47,62,10, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,60,102,108,97,103,62,119,120,65,76,73,71,78,95,67,69,78,84,82,69, +95,72,79,82,73,90,79,78,84,65,76,60,47,102,108,97,103,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,98, +111,114,100,101,114,62,53,60,47,98,111,114,100,101,114,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98, +106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34, +115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, +116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120, +116,34,32,110,97,109,101,61,34,73,68,67,95,83,84,65,84,73,67,34,62,10,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,108,97,98,101,108,62,68,97,116,97,98,97,115,101,32,72,111,115, +116,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97, 115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111, -98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105, -99,84,101,120,116,34,32,110,97,109,101,61,34,73,68,67,95,83,84,65,84,73, -67,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,68,97,116,97,98,97,115, -101,32,80,111,114,116,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106, +98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,84,101,120,116,67, +116,114,108,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95, +72,79,83,84,34,32,115,117,98,99,108,97,115,115,61,34,65,117,116,111,84, +101,120,116,67,116,114,108,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,49, +55,48,44,45,49,100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106, 101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, 116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62, 10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,84, -101,120,116,67,116,114,108,34,32,110,97,109,101,61,34,73,68,67,95,67,68, -83,95,68,66,95,80,79,82,84,34,32,115,117,98,99,108,97,115,115,61,34,65, -117,116,111,84,101,120,116,67,116,114,108,34,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,105, -122,101,62,49,55,48,44,45,49,100,60,47,115,105,122,101,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,118,97,108,117,101,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32, +32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83, +116,97,116,105,99,84,101,120,116,34,47,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116, +62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, +114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108, +97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120,116,34,32,110, +97,109,101,61,34,73,68,67,95,83,84,65,84,73,67,34,62,10,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, -47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115, -115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106, -101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101, -120,116,34,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32, +108,97,98,101,108,62,68,97,116,97,98,97,115,101,32,80,111,114,116,60,47, +108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111, +98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, +34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101, -99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34, -62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120, -83,116,97,116,105,99,84,101,120,116,34,32,110,97,109,101,61,34,73,68,67, -95,83,84,65,84,73,67,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,68,97, -116,97,98,97,115,101,47,73,110,115,116,97,110,99,101,32,78,97,109,101,60, -47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,98,111,114,100,101,114,62,53,60,47,98,111,114,100,101,114,62,10,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47, -111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115, -61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106, -101,99,116,32,99,108,97,115,115,61,34,119,120,84,101,120,116,67,116,114, -108,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95,78,65,77, -69,34,32,115,117,98,99,108,97,115,115,61,34,65,117,116,111,84,101,120,116, +99,116,32,99,108,97,115,115,61,34,119,120,84,101,120,116,67,116,114,108, +34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95,80,79,82,84, +34,32,115,117,98,99,108,97,115,115,61,34,65,117,116,111,84,101,120,116, 67,116,114,108,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,49,55,48,44,45, 49,100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32, @@ -31159,127 +31246,161 @@ static unsigned char xml_res_file_8[] = { 98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105, 99,84,101,120,116,34,32,110,97,109,101,61,34,73,68,67,95,83,84,65,84,73, 67,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,85,115,101,114,32,110,97, -109,101,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116, -62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,68,97,116,97,98,97,115, +101,47,73,110,115,116,97,110,99,101,32,78,97,109,101,60,47,108,97,98,101, +108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100, +101,114,62,53,60,47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99, +116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122, +101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108, -97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, -111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,84,101,120,116, -67,116,114,108,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66, -95,85,78,65,77,69,34,32,115,117,98,99,108,97,115,115,61,34,65,117,116,111, -84,101,120,116,67,116,114,108,34,62,10,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62, -49,55,48,44,45,49,100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,118,97, -108,117,101,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +97,115,115,61,34,119,120,84,101,120,116,67,116,114,108,34,32,110,97,109, +101,61,34,73,68,67,95,67,68,83,95,68,66,95,78,65,77,69,34,32,115,117,98, +99,108,97,115,115,61,34,65,117,116,111,84,101,120,116,67,116,114,108,34, +62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,60,115,105,122,101,62,49,55,48,44,45,49,100,60,47,115, +105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,60,118,97,108,117,101,47,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47, +111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98, -106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34, -115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, -116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120, -116,34,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116, -32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83,116, -97,116,105,99,84,101,120,116,34,32,110,97,109,101,61,34,73,68,67,95,83, -84,65,84,73,67,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,80,97,115,115, -119,111,114,100,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106, +101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109, +34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119, +120,83,116,97,116,105,99,84,101,120,116,34,47,62,10,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101, 99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32, -99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32, +32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105, +122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99, +108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120,116,34,32, +110,97,109,101,61,34,73,68,67,95,83,84,65,84,73,67,34,62,10,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,84,101,120, -116,67,116,114,108,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68, -66,95,85,80,87,68,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,49,55,48,44, -45,49,100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,118,97,108,117,101, -47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,60,115,116,121,108,101,62,119,120,84,69,95,80,65,83, -83,87,79,82,68,60,47,115,116,121,108,101,62,10,32,32,32,32,32,32,32,32, +60,108,97,98,101,108,62,85,115,101,114,32,110,97,109,101,60,47,108,97,98, +101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106, 101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, -116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62, +32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115, +105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116, +32,99,108,97,115,115,61,34,119,120,84,101,120,116,67,116,114,108,34,32, +110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95,85,78,65,77,69,34, +32,115,117,98,99,108,97,115,115,61,34,65,117,116,111,84,101,120,116,67, +116,114,108,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,49,55,48,44,45,49, +100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,118,97,108,117,101,47,62, 10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83, -116,97,116,105,99,84,101,120,116,34,47,62,10,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116, -62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, +32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62, +10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, 114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108, -97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120,116,34,32,110, -97,109,101,61,34,73,68,67,95,83,84,65,84,73,67,95,68,66,95,84,65,66,76, -69,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,84,97,98,108,101,32,78, -97,109,101,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32, +97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,120,116,34,47,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97, +115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111, +98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105, +99,84,101,120,116,34,32,110,97,109,101,61,34,73,68,67,95,83,84,65,84,73, +67,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,80,97,115,115,119,111,114, +100,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97, +115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111, +98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,84,101,120,116,67, +116,114,108,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95, +85,80,87,68,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,49,55,48,44,45,49, +100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,118,97,108,117,101,47,62, +10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,115,116,121,108,101,62,119,120,84,69,95,80,65,83,83,87, +79,82,68,60,47,115,116,121,108,101,62,10,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99, 116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99, 108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,84,101,120, -116,67,116,114,108,34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68, -66,95,84,65,66,76,69,34,32,115,117,98,99,108,97,115,115,61,34,65,117,116, -111,84,101,120,116,67,116,114,108,34,62,10,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101, -62,49,55,48,44,45,49,100,60,47,115,105,122,101,62,10,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,101, -110,97,98,108,101,100,62,48,60,47,101,110,97,98,108,101,100,62,10,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116, +105,99,84,101,120,116,34,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111, 98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116, 101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, -34,119,120,66,105,116,109,97,112,66,117,116,116,111,110,34,32,110,97,109, -101,61,34,73,68,95,66,84,78,95,76,79,79,75,85,80,95,84,65,66,76,69,34,62, +34,119,120,83,116,97,116,105,99,84,101,120,116,34,32,110,97,109,101,61, +34,73,68,67,95,83,84,65,84,73,67,95,68,66,95,84,65,66,76,69,34,62,10,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,108,97,98,101,108,62,84,97,98,108,101,32,78,97,109,101,60,47, +108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111, +98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, +34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101, +99,116,32,99,108,97,115,115,61,34,119,120,84,101,120,116,67,116,114,108, +34,32,110,97,109,101,61,34,73,68,67,95,67,68,83,95,68,66,95,84,65,66,76, +69,34,32,115,117,98,99,108,97,115,115,61,34,65,117,116,111,84,101,120,116, +67,116,114,108,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,60,115,105,122,101,62,49,55,48,44,45, +49,100,60,47,115,105,122,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,101,110,97,98,108,101, +100,62,48,60,47,101,110,97,98,108,101,100,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106, +101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99, +116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62, 10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,60,98,105,116,109,97,112,32,115,116,111,99,107,95,105,100, -61,34,119,120,65,82,84,95,70,73,78,68,34,47,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,116, -121,108,101,62,119,120,66,79,82,68,69,82,95,78,79,78,69,60,47,115,116,121, -108,101,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108, -97,103,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,99,111,108,115,62,51, -60,47,99,111,108,115,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,60,114,111,119,115,62,56,60,47,114,111,119,115, -62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,60,118,103,97,112,62,49,53,60,47,118,103,97,112,62,10,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,104,103, -97,112,62,49,48,60,47,104,103,97,112,62,10,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108, -97,103,62,119,120,76,69,70,84,124,119,120,65,76,76,124,119,120,65,76,73, -71,78,95,67,69,78,84,82,69,95,72,79,82,73,90,79,78,84,65,76,60,47,102,108, -97,103,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,68,97,116,97,98, -97,115,101,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,66, +105,116,109,97,112,66,117,116,116,111,110,34,32,110,97,109,101,61,34,73, +68,95,66,84,78,95,76,79,79,75,85,80,95,84,65,66,76,69,34,62,10,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,60,98,105,116,109,97,112,32,115,116,111,99,107,95,105,100,61,34,119, +120,65,82,84,95,70,73,78,68,34,47,62,10,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,115,116,121,108,101, +62,119,120,66,79,82,68,69,82,95,78,79,78,69,60,47,115,116,121,108,101,62, +10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103,47,62, +10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,60,99,111,108,115,62,51,60,47,99,111, +108,115,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,114,111,119,115,62,56,60,47,114,111,119,115,62,10,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, +118,103,97,112,62,49,53,60,47,118,103,97,112,62,10,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,104,103,97,112,62, +49,48,60,47,104,103,97,112,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103, +62,119,120,76,69,70,84,124,119,120,65,76,76,124,119,120,65,76,73,71,78, +95,67,69,78,84,82,69,95,72,79,82,73,90,79,78,84,65,76,60,47,102,108,97, +103,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60, +47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32, -32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,110, -111,116,101,98,111,111,107,112,97,103,101,34,62,10,32,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115, -61,34,119,120,80,97,110,101,108,34,32,110,97,109,101,61,34,100,115,87,101, +32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,68,97,116,97,98,97, +115,101,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,110,111, +116,101,98,111,111,107,112,97,103,101,34,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, +34,119,120,80,97,110,101,108,34,32,110,97,109,101,61,34,100,115,87,101, 98,83,101,114,118,105,99,101,115,34,62,10,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61, 34,119,120,66,111,120,83,105,122,101,114,34,62,10,32,32,32,32,32,32,32, diff --git a/rc/dialogs.xrc b/rc/dialogs.xrc index b26a86302..a9c1fd83b 100644 --- a/rc/dialogs.xrc +++ b/rc/dialogs.xrc @@ -7801,6 +7801,7 @@ + @@ -8201,12 +8202,12 @@ - 0,40 + 2,30 - 4,10 + 4,14 @@ -8226,6 +8227,52 @@ + + + wxHORIZONTAL + + 4,14 + + + + + + + + + 160,-1 + + + Unicode (UTF-8) + Unicode (UTF-16LE) + Arabic (Windows-1256) + Central European Latin-2 (ISO-8859-2) + Central European (Windows-1250) + Central European (CP852) + Chinese Simplified (GB2312) + Chinese Traditional (Big5) + Cyrillic (ISO-8859-5) + Cyrillic (KOI8-R) + Cyrillic (Windows-1251) + Cyrillic/Russian (CP866) + Greek (ISO-8859-7) + Hebrew (ISO-8859-8-1) + Hebrew (Windows-1255) + Japanese (Shift_JIS) + Japanese (EUC-JP) + Korean (EUC-KR) + Nordic Latin-6 (ISO-8859-10) + South European Latin-3 (ISO-8859-3) + Turkish Latin-5 (ISO-8859-9) + Turkish (Windows-1254) + Vietnamese (Windows-1258) + West European Latin-1 (ISO-8859-1) + West European Latin-9 (ISO-8859-15) + + + + + diff --git a/version.h b/version.h index c06183662..46b852a10 100644 --- a/version.h +++ b/version.h @@ -2,10 +2,10 @@ namespace Gda { const int version_major = 1; const int version_minor = 12; const int version_build = 1; - const int version_subbuild = 181; + const int version_subbuild = 183; const int version_year = 2018; const int version_month = 12; - const int version_day = 6; + const int version_day = 19; const int version_night = 0; const int version_type = 2; // 0: alpha, 1: beta, 2: release }