diff --git a/.gitignore b/.gitignore index 3bf3dd50a..7a139b8d6 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,10 @@ BuildTools/macosx/build/ BuildTools/macosx/GeoDa.xcodeproj/ BuildTools/macosx/GeoDa.xcodeproj/xcuserdata/ BuildTools/macosx/GeoDa-leopard.xcodeproj/ +BuildTools/reactgeoda +BuildTools/node_modules + +build/ *.dmg *.mode1v3 diff --git a/BuildTools/macosx/GNUmakefile b/BuildTools/macosx/GNUmakefile index 9b6dbe2e6..1ef33985d 100644 --- a/BuildTools/macosx/GNUmakefile +++ b/BuildTools/macosx/GNUmakefile @@ -95,12 +95,12 @@ build-geoda-mac: cp /usr/local/opt/gdal/share/gdal/* build/GeoDa.app/Contents/Resources/gdaldata cp libraries/lib/libwx_osx_cocoau-3.1.4.0.0.dylib build/GeoDa.app/Contents/Frameworks/libwx_osx_cocoau-3.1.dylib cp libraries/lib/libwx_osx_cocoau_gl-3.1.4.0.0.dylib build/GeoDa.app/Contents/Frameworks/libwx_osx_cocoau_gl-3.1.dylib - cp /usr/local/opt/gdal/lib/libgdal.32.dylib build/GeoDa.app/Contents/Frameworks + cp /usr/local/opt/gdal/lib/libgdal.33.dylib build/GeoDa.app/Contents/Frameworks install_name_tool -id "GeoDa" build/GeoDa.app/Contents/MacOS/GeoDa install_name_tool -change "$(GEODA_HOME)/libraries/lib/libwx_osx_cocoau_gl-3.1.dylib" "@executable_path/../Frameworks/libwx_osx_cocoau_gl-3.1.dylib" build/GeoDa.app/Contents/MacOS/GeoDa install_name_tool -change "$(GEODA_HOME)/libraries/lib/libwx_osx_cocoau-3.1.dylib" "@executable_path/../Frameworks/libwx_osx_cocoau-3.1.dylib" build/GeoDa.app/Contents/MacOS/GeoDa - install_name_tool -change "/usr/local/opt/gdal/lib/libgdal.32.dylib" "@executable_path/../Frameworks/libgdal.32.dylib" build/GeoDa.app/Contents/MacOS/GeoDa - install_name_tool -change "/opt/homebrew/opt/gdal/lib/libgdal.32.dylib" "@executable_path/../Frameworks/libgdal.32.dylib" build/GeoDa.app/Contents/MacOS/GeoDa + install_name_tool -change "/usr/local/opt/gdal/lib/libgdal.33.dylib" "@executable_path/../Frameworks/libgdal.33.dylib" build/GeoDa.app/Contents/MacOS/GeoDa + install_name_tool -change "/opt/homebrew/opt/gdal/lib/libgdal.33.dylib" "@executable_path/../Frameworks/libgdal.33.dylib" build/GeoDa.app/Contents/MacOS/GeoDa python3 install_name.py $(GEODA_HOME)/build/GeoDa.app/Contents/Frameworks "Developer ID Application: Geodapress LLC (26M5NG43GP)" install_name_tool -change "@executable_path/../Frameworks/libwx_osx_cocoau-3.1.4.0.0.dylib" "@executable_path/../Frameworks/libwx_osx_cocoau-3.1.dylib" build/GeoDa.app/Contents/Frameworks/libwx_osx_cocoau_gl-3.1.dylib codesign -f --timestamp -o runtime -s "Developer ID Application: Geodapress LLC (26M5NG43GP)" build/GeoDa.app/Contents/Frameworks/libwx_osx_cocoau_gl-3.1.dylib diff --git a/BuildTools/macosx/code_sign.py b/BuildTools/macosx/code_sign.py index 393c9f10a..388325ff0 100755 --- a/BuildTools/macosx/code_sign.py +++ b/BuildTools/macosx/code_sign.py @@ -57,6 +57,10 @@ def ProcessDependency(dylib_path, cid): m = re.search('@rpath/(libaws.*)', dylib_path) if m: dylib_path = '/usr/local/opt/aws-sdk-cpp/lib/' + m.group(1) + + m = re.search('@loader_path/../../../../(opt*)', dylib_path) + if m: + dylib_path = '/usr/local/' + m.group(1) print("Process:", dylib_path) diff --git a/BuildTools/macosx/install_name.py b/BuildTools/macosx/install_name.py index 2655ec039..37bcd6260 100644 --- a/BuildTools/macosx/install_name.py +++ b/BuildTools/macosx/install_name.py @@ -1,18 +1,44 @@ +''' +Update the install name of dependent libraries of libgdal and libwx +Code sign each dependent library +''' import subprocess -import os, sys, re +import os +import sys +import re +from pathlib import Path from shutil import copyfile -framework_path = sys.argv[1] #e.g. '/Users/xun/Github/geoda/BuildTools/macosx/build/GeoDa.app/Contents/Frameworks' -id = sys.argv[2] -codesign_only = bool(sys.argv[3]) if len(sys.argv) > 3 else False +# e.g. '/Users/xun/Github/geoda/BuildTools/macosx/build/GeoDa.app/Contents/Frameworks' +FRAMEWORK_PATH = sys.argv[1] +CODESIGN_ID = sys.argv[2] +CODESIGN_ONLY = bool(sys.argv[3]) if len(sys.argv) > 3 else False -print(id, codesign_only) +print(CODESIGN_ID, CODESIGN_ONLY) -def ProcessDependency(dir_path, dylib_name): - dylib_path = dir_path + '/' + dylib_name - dep_libs = subprocess.check_output(['otool', '-L', dylib_path]).decode('utf-8') - items = dep_libs.split('\n')[2:-1] +PROCESSED_DYLIBS = {} + + +def process_dependency(framework_path, dylib_name): + """_Process each dependent library_ + + Args: + framework_path (_str_): _Framework path_ + dylib_name (_str_): _dylib file name_ + """ + if dylib_name in PROCESSED_DYLIBS: + print(f'{dylib_name} has been processed') + return + PROCESSED_DYLIBS[dylib_name] = True + dylib_path = framework_path + '/' + dylib_name + dep_libs = subprocess.check_output( + ['otool', '-L', dylib_path]).decode('utf-8') + all_items = dep_libs.split('\n') + # e.g. '\t/opt/homebrew/opt/gdal/lib/libgdal.33.dylib (compatibility version 33.0.0, current version 33.3.7)' + current_item = all_items[1].strip().split(" ")[0] + items = all_items[2:-1] for item in items: + # e.g. '@loader_path/../../../../opt/libarchive/lib/libarchive.13.dylib (compatibility version 20.0.0, current version 20.2.0)' item = item.strip().split(" ")[0] # workaround for gdal 3.3.3 that @rpath/libgeos.3.10.2.dylib was used instead of dir path @@ -62,33 +88,45 @@ def ProcessDependency(dir_path, dylib_name): if item == '@rpath/libabsl_base.2301.0.0.dylib': copyitem = '/usr/local/opt/abseil/lib/libabsl_base.2301.0.0.dylib' - m = re.search('@rpath/(libabsl.*)', item) - if m: - copyitem = '/usr/local/opt/abseil/lib/' + m.group(1) - - m = re.search('@rpath/(libaws.*)', item) - if m: - copyitem = '/usr/local/opt/aws-sdk-cpp/lib/' + m.group(1) + name_matches = re.search('@rpath/(libabsl.*)', item) + if name_matches: + copyitem = '/usr/local/opt/abseil/lib/' + name_matches.group(1) + + name_matches = re.search('@rpath/(libaws.*)', item) + if name_matches: + copyitem = '/usr/local/opt/aws-sdk-cpp/lib/' + \ + name_matches.group(1) + + if item.startswith('@loader_path'): + item_filename = os.path.basename(item) + upper_levels = item.count('../') + copy_dir = str(Path(current_item).parent) + if upper_levels - 1 >= 0: + current_dir = Path(current_item).parents[upper_levels - 1] + copy_dir = str(current_dir) + item_filename = item[item.rindex('../') + 3:] + copyitem = f'{copy_dir}/{item_filename}' - if item.startswith('/usr/lib') == False and item.startswith('/System') == False and (codesign_only or item.startswith('@executable_path/')==False): + if not item.startswith('/usr/lib') and not item.startswith('/System') \ + and not (CODESIGN_ONLY or item.startswith('@executable_path/')): print("Process:", item) file_name = os.path.basename(item) # Copy the dylib to Frameworks if needed - dest = dir_path + '/' + file_name - if os.path.exists(dest) == False and not codesign_only: + dest = framework_path + '/' + file_name + if not os.path.exists(dest) and not CODESIGN_ONLY: copyfile(copyitem, dest, follow_symlinks=True) # install_name_tool current item - new_path = "@executable_path/../Frameworks/{}".format(file_name) - cmd = "install_name_tool -change \"{}\" \"{}\" {}".format(item, new_path, dylib_path) - if not codesign_only: + new_path = f"@executable_path/../Frameworks/{file_name}" + cmd = f'install_name_tool -change "{item}" "{new_path}" {dylib_path}' + if not CODESIGN_ONLY: os.system(cmd) # process item - ProcessDependency(dir_path, file_name) + process_dependency(framework_path, file_name) print("codesign {}", dylib_path) - cmd = 'codesign --force --timestamp -o runtime -s "{}" {}'.format(id, dylib_path) + cmd = f'codesign --force --timestamp -o runtime -s "{CODESIGN_ID}" {dylib_path}' os.system(cmd) -ProcessDependency(framework_path, "libwx_osx_cocoau_gl-3.1.dylib") -ProcessDependency(framework_path, "libwx_osx_cocoau-3.1.dylib") -ProcessDependency(framework_path, "libgdal.32.dylib") +process_dependency(FRAMEWORK_PATH, "libwx_osx_cocoau_gl-3.1.dylib") +process_dependency(FRAMEWORK_PATH, "libwx_osx_cocoau-3.1.dylib") +process_dependency(FRAMEWORK_PATH, "libgdal.33.dylib") diff --git a/Explore/Basemap.cpp b/Explore/Basemap.cpp index 4893e3432..24bd52ee6 100644 --- a/Explore/Basemap.cpp +++ b/Explore/Basemap.cpp @@ -42,6 +42,8 @@ #include #include +#include "../GdaConst.h" +#include "../GeneralWxUtils.h" #include "../ShapeOperations/OGRDataAdapter.h" #include "Basemap.h" @@ -156,8 +158,6 @@ XYFraction::XYFraction(double _x, double _y) yfrac = modf(_y, &yint); } -const char *Basemap::USER_AGENT = "GeoDa 1.14 contact spatial@uchiago.edu"; - Basemap::Basemap(BasemapItem& _basemap_item, Screen* _screen, MapLayer* _map, @@ -612,6 +612,21 @@ size_t curlCallback(void *ptr, size_t size, size_t nmemb, void* userdata) return written; } +wxString Basemap::GetUserAgent(const wxString& url) +{ + if (url.Find("openstreetmap") != wxNOT_FOUND) { + return GdaConst::gda_basemap_osm_useragent; + } + if (GeneralWxUtils::isWindows()) { + return GdaConst::gda_basemap_win_useragent; + } else if (GeneralWxUtils::isMac()) { + return GdaConst::gda_basemap_mac_useragent; + } else { + return GdaConst::gda_basemap_linux_useragent; + } + +} + wxString Basemap::GetContentType() { wxString url = GetTileUrl(16, 11); // guerry @@ -621,7 +636,8 @@ wxString Basemap::GetContentType() if(curl) { curl_easy_setopt(curl, CURLOPT_URL, url.ToUTF8().data()); curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); - curl_easy_setopt(curl, CURLOPT_USERAGENT, Basemap::USER_AGENT); + curl_easy_setopt(curl, CURLOPT_USERAGENT, GetUserAgent(url).ToUTF8().data()); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1L); @@ -670,10 +686,10 @@ void Basemap::DownloadTile(int x, int y) if (fp) { curl_easy_setopt(image, CURLOPT_URL, url.ToUTF8().data()); curl_easy_setopt(image, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); - curl_easy_setopt(image, CURLOPT_USERAGENT, Basemap::USER_AGENT); + curl_easy_setopt(image, CURLOPT_USERAGENT, GetUserAgent(url).ToUTF8().data()); curl_easy_setopt(image, CURLOPT_WRITEFUNCTION, curlCallback); curl_easy_setopt(image, CURLOPT_WRITEDATA, fp); - //curl_easy_setopt(image, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(image, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(image, CURLOPT_SSL_VERIFYHOST, 0); curl_easy_setopt(image, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(image, CURLOPT_CONNECTTIMEOUT, 1L); diff --git a/Explore/Basemap.h b/Explore/Basemap.h index 022ffaf87..a529b7b9d 100644 --- a/Explore/Basemap.h +++ b/Explore/Basemap.h @@ -235,11 +235,11 @@ namespace Gda { east = _e; south = _s; } - OGRSpatialReference* s1 = poCT->GetTargetCS(); - OGRSpatialReference* s2 = poCT->GetSourceCS(); + const OGRSpatialReference* s1 = poCT->GetTargetCS(); + const OGRSpatialReference* s2 = poCT->GetSourceCS(); #ifdef __PROJ6__ - s1->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); - s2->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); + const_cast(s1)->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); + const_cast(s2)->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); #endif poCT_rev = OGRCreateCoordinateTransformation(s1, s2); } @@ -327,20 +327,20 @@ namespace Gda { poCT_rev = NULL; if (other) { if (other->poCT) { - OGRSpatialReference* s1 = other->poCT->GetSourceCS(); - OGRSpatialReference* s2 = other->poCT->GetTargetCS(); + const OGRSpatialReference* s1 = other->poCT->GetSourceCS(); + const OGRSpatialReference* s2 = other->poCT->GetTargetCS(); #ifdef __PROJ6__ - s1->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); - s2->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); + const_cast(s1)->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); + const_cast(s2)->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); #endif poCT = OGRCreateCoordinateTransformation(s1, s2); } if (other->poCT_rev) { - OGRSpatialReference* s1 = other->poCT_rev->GetSourceCS(); - OGRSpatialReference* s2 = other->poCT_rev->GetTargetCS(); + const OGRSpatialReference* s1 = other->poCT_rev->GetSourceCS(); + const OGRSpatialReference* s2 = other->poCT_rev->GetTargetCS(); #ifdef __PROJ6__ - s1->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); - s2->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); + const_cast(s1)->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); + const_cast(s2)->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); #endif poCT_rev = OGRCreateCoordinateTransformation(s1, s2); } @@ -377,7 +377,6 @@ namespace Gda { double scale_factor = 1.0); ~Basemap(); - static const char* USER_AGENT; OGRCoordinateTransformation *poCT; BasemapItem basemap_item; wxString basemapName; @@ -439,6 +438,7 @@ namespace Gda { void CleanCache(); wxString GetContentType(); + wxString GetUserAgent(const wxString& url); }; } diff --git a/GdaConst.cpp b/GdaConst.cpp index e4ccc1290..aa9bf048d 100644 --- a/GdaConst.cpp +++ b/GdaConst.cpp @@ -395,6 +395,10 @@ wxString GdaConst::gda_basemap_sources = "\nOther (China).GaoDe,http://webst{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}" "\nOther (China).GaoDe(Satellite),http://webst{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}" ; +const wxString GdaConst::gda_basemap_osm_useragent = "GeoDa 1.14 contact spatial@uchiago.edu"; +const wxString GdaConst::gda_basemap_win_useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"; +const wxString GdaConst::gda_basemap_mac_useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"; +const wxString GdaConst::gda_basemap_linux_useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"; const wxString GdaConst::gda_lbl_not_sig = _("Not Significant"); const wxString GdaConst::gda_lbl_undefined = _("Undefined"); diff --git a/GdaConst.h b/GdaConst.h index 495d21d0c..9fdc94ad2 100644 --- a/GdaConst.h +++ b/GdaConst.h @@ -413,6 +413,12 @@ class GdaConst { static const int ShpHeaderSize = 50; // size of the header record in Shapefile static const int ShpObjIdLen = 20; // length of the ID of shape object + // Basemap + static const wxString gda_basemap_osm_useragent; + static const wxString gda_basemap_win_useragent; + static const wxString gda_basemap_mac_useragent; + static const wxString gda_basemap_linux_useragent; + static wxCursor zoomInCursor; static wxCursor zoomOutCursor; diff --git a/Project.cpp b/Project.cpp index 5b56e8b92..63bb1b56d 100644 --- a/Project.cpp +++ b/Project.cpp @@ -427,7 +427,6 @@ rtree_box_2d_t& Project::GetBBoxRtree() void Project::CalcEucPlaneRtreeStats() { wxLogMessage("Project::CalcEucPlaneRtreeStats()"); - using namespace std; GetCentroids(); size_t num_obs = centroids.size(); @@ -451,7 +450,6 @@ void Project::CalcEucPlaneRtreeStats() void Project::CalcUnitSphereRtreeStats() { wxLogMessage("Project::CalcUnitSphereRtreeStats()"); - using namespace std; GetCentroids(); size_t num_obs = centroids.size(); std::vector pts_ll(num_obs); @@ -992,10 +990,9 @@ CovSpHLStateProxy* Project::GetPairsHLState() TableBase* Project::FindTableBase() { - using namespace std; if (frames_manager == NULL) return NULL; - list observers(frames_manager->getCopyObservers()); - list::iterator it; + std::list observers(frames_manager->getCopyObservers()); + std::list::iterator it; for (it=observers.begin(); it != observers.end(); ++it) { if (TableFrame* w = dynamic_cast(*it)) { return w->GetTableBase(); diff --git a/SpatialIndAlgs.cpp b/SpatialIndAlgs.cpp index 40de5a667..b8cf953d9 100644 --- a/SpatialIndAlgs.cpp +++ b/SpatialIndAlgs.cpp @@ -38,27 +38,25 @@ #include "GdaException.h" #include "logger.h" -using namespace std; - -void SpatialIndAlgs::to_3d_centroids(const vector& pt2d, - vector& pt3d) +void SpatialIndAlgs::to_3d_centroids(const std::vector& pt2d, + std::vector& pt3d) { size_t obs = pt2d.size(); pt3d.resize(obs); for (size_t i=0; i(pt2d[i]), bg::get<1>(pt2d[i]), 0); + pt3d[i] = pt_3d(boost::geometry::get<0>(pt2d[i]), boost::geometry::get<1>(pt2d[i]), 0); } } -void SpatialIndAlgs::to_3d_centroids(const vector& ptll, - vector& pt3d) +void SpatialIndAlgs::to_3d_centroids(const std::vector& ptll, + std::vector& pt3d) { size_t obs = ptll.size(); pt3d.resize(obs); for (size_t i=0; i(ptll[i]), - bg::get<1>(ptll[i]), + GenGeomAlgs::LongLatDegToUnit(boost::geometry::get<0>(ptll[i]), + boost::geometry::get<1>(ptll[i]), x, y, z); pt3d[i] = pt_3d(x, y, z); } @@ -83,35 +81,35 @@ void SpatialIndAlgs::default_test() // find values intersecting some area defined by a box box_2d query_box(pt_2d(0, 0), pt_2d(5, 5)); std::vector result_s; - rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); + rtree.query(boost::geometry::index::intersects(query_box), std::back_inserter(result_s)); const int k=3; // find k nearest values to a point std::vector result_n; - rtree.query(bgi::nearest(pt_2d(0, 0), k), std::back_inserter(result_n)); + rtree.query(boost::geometry::index::nearest(pt_2d(0, 0), k), std::back_inserter(result_n)); // note: in Boost.Geometry WKT representation of a box is polygon // display results stringstream ss; ss << "spatial query box:" << std::endl; - ss << bg::wkt(query_box) << std::endl; + ss << boost::geometry::wkt(query_box) << std::endl; ss << "spatial query result:" << std::endl; BOOST_FOREACH(box_2d_val const& v, result_s) { - ss << bg::wkt(v.first) << " - " << v.second << std::endl; + ss << boost::geometry::wkt(v.first) << " - " << v.second << std::endl; } ss << k << "-nn query point:" << std::endl; - ss << bg::wkt(pt_2d(0, 0)) << std::endl; + ss << boost::geometry::wkt(pt_2d(0, 0)) << std::endl; ss << k << "-nn query result:" << std::endl; BOOST_FOREACH(box_2d_val const& v, result_n) { - ss << bg::wkt(v.first) << " - " << v.second << std::endl; + ss << boost::geometry::wkt(v.first) << " - " << v.second << std::endl; } pt_lonlat sp(0, 45); - ss << "Spherical pt get<0>: " << bg::get<0>(sp) << std::endl; - ss << "Spherical pt get<1>: " << bg::get<1>(sp) << std::endl; - ss << "Spherical pt: " << bg::wkt(sp) << std::endl; + ss << "Spherical pt get<0>: " << boost::geometry::get<0>(sp) << std::endl; + ss << "Spherical pt get<1>: " << boost::geometry::get<1>(sp) << std::endl; + ss << "Spherical pt: " << boost::geometry::wkt(sp) << std::endl; ss << "default_test() END"; } @@ -123,7 +121,7 @@ void SpatialIndAlgs::print_rtree_stats(rtree_box_2d_t& rtree) ss << " size: " << rtree.size() << endl; ss << " empty?: " << rtree.empty() << endl; box_2d bnds = rtree.bounds(); - ss << " bounds: " << bg::wkt(bnds); + ss << " bounds: " << boost::geometry::wkt(bnds); } void SpatialIndAlgs::query_all_boxes(rtree_box_2d_t& rtree) @@ -134,19 +132,19 @@ void SpatialIndAlgs::query_all_boxes(rtree_box_2d_t& rtree) box_2d bnds = rtree.bounds(); for (rtree_box_2d_t::const_query_iterator it = - rtree.qbegin(bgi::intersects(rtree.bounds())); + rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend() ; ++it) { ++cnt; } cnt = 0; rtree_box_2d_t::const_query_iterator it; - for (it=rtree.qbegin(bgi::intersects(rtree.bounds())); it != rtree.qend(); ++it) + for (it=rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend(); ++it) { const box_2d_val& v = *it; pt_2d c; boost::geometry::centroid(v.first, c); - vector q; - rtree.query(bgi::intersects(v.first), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::intersects(v.first), std::back_inserter(q)); int qcnt=0; BOOST_FOREACH(box_2d_val const& w, q) { if (w.second == v.second) @@ -163,7 +161,7 @@ void SpatialIndAlgs::knn_query(const rtree_pt_2d_t& rtree, int nn) box_2d bnds = rtree.bounds(); rtree_pt_2d_t::const_query_iterator it; - for (it= rtree.qbegin(bgi::intersects(rtree.bounds())); it != rtree.qend(); ++it) + for (it= rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend(); ++it) { ++cnt; } @@ -171,11 +169,11 @@ void SpatialIndAlgs::knn_query(const rtree_pt_2d_t& rtree, int nn) cnt = 0; const int k=nn+1; - for (it= rtree.qbegin(bgi::intersects(rtree.bounds())); it != rtree.qend(); ++it) + for (it= rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend(); ++it) { const pt_2d_val& v = *it; - vector q; - rtree.query(bgi::nearest(v.first, k), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::nearest(v.first, k), std::back_inserter(q)); BOOST_FOREACH(pt_2d_val const& w, q) { if (w.second == v.second) { continue; @@ -185,8 +183,8 @@ void SpatialIndAlgs::knn_query(const rtree_pt_2d_t& rtree, int nn) } } -GwtWeight* SpatialIndAlgs::knn_build(const vector& x, - const vector& y, +GwtWeight* SpatialIndAlgs::knn_build(const std::vector& x, + const std::vector& y, int nn, bool is_arc, bool is_mi, bool is_inverse, double power, @@ -200,9 +198,9 @@ GwtWeight* SpatialIndAlgs::knn_build(const vector& x, if (is_arc) { rtree_pt_3d_t rtree; { - vector pts; + std::vector pts; { - vector ptll(nobs); + std::vector ptll(nobs); for (int i=0; i& x, } else { rtree_pt_2d_t rtree; { - vector pts(nobs); + std::vector pts(nobs); for (int i=0; i q; - rtree.query(bgi::nearest(v.first, k), std::back_inserter(q)); // self is included + std::vector q; + rtree.query(boost::geometry::index::nearest(v.first, k), std::back_inserter(q)); // self is included GwtElement& e = Wp->gwt[obs]; e.alloc(kernel.IsEmpty() ? nn : k); // nn or (nn+1) kernel weights double local_bandwidth = 0; @@ -282,7 +280,7 @@ GwtWeight* SpatialIndAlgs::knn_build(const rtree_pt_2d_t& rtree, int nn, bool is continue; GwtNeighbor neigh; neigh.nbx = w.second; - double d = bg::distance(v.first, w.first); + double d = boost::geometry::distance(v.first, w.first); if (bandwidth_ ==0 && d > bandwidth) bandwidth = d; if (d > local_bandwidth) local_bandwidth = d; if (is_inverse) d = pow(d, power); @@ -344,24 +342,24 @@ GwtWeight* SpatialIndAlgs::knn_build(const rtree_pt_3d_t& rtree, int nn, // if not set, use max knn distance as bandwidth for (rtree_pt_3d_t::const_query_iterator it = - rtree.qbegin(bgi::intersects(rtree.bounds())); + rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend() ; ++it) { int cnt=0; const pt_3d_val& v = *it; size_t obs = v.second; - vector q; - rtree.query(bgi::nearest(v.first, k), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::nearest(v.first, k), std::back_inserter(q)); GwtElement& e = Wp->gwt[obs]; e.alloc(kernel.IsEmpty() ? nn : k); double lon_v, lat_v; double x_v, y_v; if (is_arc) { - UnitToLongLatDeg(bg::get<0>(v.first), bg::get<1>(v.first), - bg::get<2>(v.first), lon_v, lat_v); + UnitToLongLatDeg(boost::geometry::get<0>(v.first), boost::geometry::get<1>(v.first), + boost::geometry::get<2>(v.first), lon_v, lat_v); } else { - x_v = bg::get<0>(v.first); - y_v = bg::get<1>(v.first); + x_v = boost::geometry::get<0>(v.first); + y_v = boost::geometry::get<1>(v.first); } double local_bandwidth = 0; BOOST_FOREACH(pt_3d_val const& w, q) { @@ -371,18 +369,18 @@ GwtWeight* SpatialIndAlgs::knn_build(const rtree_pt_3d_t& rtree, int nn, neigh.nbx = w.second; if (is_arc) { double lon_w, lat_w; - UnitToLongLatDeg(bg::get<0>(w.first), bg::get<1>(w.first), - bg::get<2>(w.first), lon_w, lat_w); + UnitToLongLatDeg(boost::geometry::get<0>(w.first), boost::geometry::get<1>(w.first), + boost::geometry::get<2>(w.first), lon_w, lat_w); if (is_mi) { neigh.weight = ComputeArcDistMi(lon_v, lat_v, lon_w, lat_w); } else { neigh.weight = ComputeArcDistKm(lon_v, lat_v, lon_w, lat_w); } } else { - //neigh.weight = bg::distance(v.first, w.first); + //neigh.weight = boost::geometry::distance(v.first, w.first); neigh.weight = ComputeEucDist(x_v, y_v, - bg::get<0>(w.first), - bg::get<1>(w.first)); + boost::geometry::get<0>(w.first), + boost::geometry::get<1>(w.first)); } if (is_inverse) neigh.weight = pow(neigh.weight, power); @@ -435,7 +433,7 @@ double SpatialIndAlgs::est_thresh_for_num_pairs(const rtree_pt_2d_t& rtree, { double nobs_d = (double) rtree.size(); if (num_pairs >= (nobs_d*(nobs_d-1.0))/2.0) { - return bg::distance(rtree.bounds().min_corner(), rtree.bounds().max_corner()); + return boost::geometry::distance(rtree.bounds().min_corner(), rtree.bounds().max_corner()); } // Need roughly double since pairs are visited twice. double avg_n = (num_pairs / nobs_d)*2.0; @@ -458,7 +456,7 @@ double SpatialIndAlgs::est_thresh_for_avg_num_neigh(const rtree_pt_2d_t& rtree, double lower = 0; double lower_avg = 0; box_2d bnds(rtree.bounds()); - double upper = bg::distance(bnds.min_corner(), bnds.max_corner()); + double upper = boost::geometry::distance(bnds.min_corner(), bnds.max_corner()); double upper_avg = (double) rtree.size(); double guess = upper; double guess_avg = upper_avg; @@ -516,7 +514,7 @@ double SpatialIndAlgs::est_avg_num_neigh_thresh(const rtree_pt_2d_t& rtree, using namespace GenGeomAlgs; vector query_pts; - rtree.query(bgi::intersects(rtree.bounds()), back_inserter(query_pts)); + rtree.query(boost::geometry::index::intersects(rtree.bounds()), back_inserter(query_pts)); // Mersenne Twister random number generator, randomly seeded // with current time in seconds since Jan 1 1970. static boost::mt19937 rng((unsigned int)std::time(0)); @@ -527,10 +525,10 @@ double SpatialIndAlgs::est_avg_num_neigh_thresh(const rtree_pt_2d_t& rtree, double x = v.first.get<0>(); double y = v.first.get<1>(); box_2d b(pt_2d(x-th, y-th), pt_2d(x+th, y+th)); - vector q; - rtree.query(bgi::intersects(b), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::intersects(b), std::back_inserter(q)); BOOST_FOREACH(const pt_2d_val& w, q) { - if (w.second != v.second && bg::distance(v.first, w.first) <= th) + if (w.second != v.second && boost::geometry::distance(v.first, w.first) <= th) { ++tot_neigh; } @@ -648,9 +646,9 @@ GwtWeight* SpatialIndAlgs::thresh_build(const std::vector& x, double u_th = RadToUnitDist(r_th); rtree_pt_3d_t rtree; { - vector pts; + std::vector pts; { - vector ptll(nobs); + std::vector ptll(nobs); for (int i=0; i& x, } else { rtree_pt_2d_t rtree; { - vector pts(nobs); + std::vector pts(nobs); for (int i=0; i(); box_2d b(pt_2d(x-th, y-th), pt_2d(x+th, y+th)); size_t obs = v.second; - vector q; - rtree.query(bgi::intersects(b), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::intersects(b), std::back_inserter(q)); size_t lcnt = 0; list l; BOOST_FOREACH(pt_2d_val const& w, q) { if (w.second != v.second && - bg::distance(v.first, w.first) <= th) + boost::geometry::distance(v.first, w.first) <= th) { l.push_front(w); ++lcnt; @@ -726,7 +724,7 @@ GwtWeight* SpatialIndAlgs::thresh_build(const rtree_pt_2d_t& rtree, double th, d BOOST_FOREACH(pt_2d_val const& w, l) { GwtNeighbor neigh; neigh.nbx = w.second; - double w_val = bg::distance(v.first, w.first); + double w_val = boost::geometry::distance(v.first, w.first); if (power != 1) w_val = pow(w_val, power); if (!kernel.IsEmpty()) w_val = w_val / th; neigh.weight = w_val; @@ -760,7 +758,7 @@ double SpatialIndAlgs::est_avg_num_neigh_thresh(const rtree_pt_3d_t& rtree, using namespace GenGeomAlgs; vector query_pts; - rtree.query(bgi::intersects(rtree.bounds()), back_inserter(query_pts)); + rtree.query(boost::geometry::index::intersects(rtree.bounds()), back_inserter(query_pts)); // Mersenne Twister random number generator, randomly seeded // with current time in seconds since Jan 1 1970. static boost::mt19937 rng((unsigned int)std::time(0)); @@ -772,10 +770,10 @@ double SpatialIndAlgs::est_avg_num_neigh_thresh(const rtree_pt_3d_t& rtree, double y = v.first.get<1>(); double z = v.first.get<2>(); box_3d b(pt_3d(x-th, y-th, z-th), pt_3d(x+th, y+th, z+th)); - vector q; - rtree.query(bgi::intersects(b), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::intersects(b), std::back_inserter(q)); BOOST_FOREACH(const pt_3d_val& w, q) { - if (w.second != v.second && bg::distance(v.first, w.first) <= th) + if (w.second != v.second && boost::geometry::distance(v.first, w.first) <= th) { ++tot_neigh; } @@ -815,7 +813,7 @@ GwtWeight* SpatialIndAlgs::thresh_build(const rtree_pt_3d_t& rtree, double th, d } int cnt=0; for (rtree_pt_3d_t::const_query_iterator it = - rtree.qbegin(bgi::intersects(rtree.bounds())); + rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend() ; ++it) { const pt_3d_val& v = *it; @@ -826,13 +824,13 @@ GwtWeight* SpatialIndAlgs::thresh_build(const rtree_pt_3d_t& rtree, double th, d UnitToLongLatDeg(vx, vy, vz, lon_v, lat_v); box_3d b(pt_3d(vx-th, vy-th, vz-th), pt_3d(vx+th, vy+th, vz+th)); size_t obs = v.second; - vector q; - rtree.query(bgi::intersects(b), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::intersects(b), std::back_inserter(q)); size_t lcnt = 0; list l; BOOST_FOREACH(pt_3d_val const& w, q) { if (w.second != v.second && - bg::distance(v.first, w.first) <= th) + boost::geometry::distance(v.first, w.first) <= th) { l.push_front(w); ++lcnt; @@ -892,9 +890,9 @@ double SpatialIndAlgs::find_max_1nn_dist(const std::vector& x, if (is_arc) { rtree_pt_3d_t rtree; { - vector pts; + std::vector pts; { - vector ptll(nobs); + std::vector ptll(nobs); for (int i=0; i& x, } else { rtree_pt_2d_t rtree; { - vector pts(nobs); + std::vector pts(nobs); for (int i=0; i d(obs); for (rtree_pt_2d_t::const_query_iterator it = - rtree.qbegin(bgi::intersects(rtree.bounds())); + rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend() ; ++it) { const pt_2d_val& v = *it; - vector q; - rtree.query(bgi::nearest(v.first, k), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::nearest(v.first, k), std::back_inserter(q)); BOOST_FOREACH(pt_2d_val const& w, q) { if (w.second == v.second) continue; - d[v.second] = bg::distance(v.first, w.first); + d[v.second] = boost::geometry::distance(v.first, w.first); } } sort(d.begin(), d.end()); @@ -962,12 +960,12 @@ void SpatialIndAlgs::get_pt_rtree_stats(const rtree_pt_3d_t& rtree, size_t obs = rtree.size(); vector d(obs); for (rtree_pt_3d_t::const_query_iterator it = - rtree.qbegin(bgi::intersects(rtree.bounds())); + rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend() ; ++it) { const pt_3d_val& v = *it; - vector q; - rtree.query(bgi::nearest(v.first, 2), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::nearest(v.first, 2), std::back_inserter(q)); BOOST_FOREACH(pt_3d_val const& w, q) { if (w.second == v.second) continue; double lonv, latv, lonw, latw; @@ -1018,20 +1016,20 @@ GwtWeight* SpatialIndAlgs::knn_build(const rtree_pt_lonlat_t& rtree, int nn) int cnt=0; const int k=nn+1; for (rtree_pt_lonlat_t::const_query_iterator it = - rtree.qbegin(bgi::intersects(rtree.bounds())); + rtree.qbegin(boost::geometry::index::intersects(rtree.bounds())); it != rtree.qend() ; ++it) { const pt_lonlat_val& v = *it; size_t obs = v.second; - vector q; - rtree.query(bgi::nearest(v.first, k), std::back_inserter(q)); + std::vector q; + rtree.query(boost::geometry::index::nearest(v.first, k), std::back_inserter(q)); GwtElement& e = Wp->gwt[obs]; e.alloc((int)q.size()); BOOST_FOREACH(const pt_lonlat_val& w, q) { if (w.second == v.second) continue; GwtNeighbor neigh; neigh.nbx = w.second; - neigh.weight = bg::distance(v.first, w.first); + neigh.weight = boost::geometry::distance(v.first, w.first); e.Push(neigh); ++cnt; } diff --git a/SpatialIndTypes.h b/SpatialIndTypes.h index fd6465d05..deb425a37 100644 --- a/SpatialIndTypes.h +++ b/SpatialIndTypes.h @@ -20,7 +20,7 @@ #ifndef __GEODA_CENTER_SPATIAL_IND_TYPES_H__ #define __GEODA_CENTER_SPATIAL_IND_TYPES_H__ -#include +#include #include #include #include diff --git a/TemplateCanvas.cpp b/TemplateCanvas.cpp index f891b4a64..46b6abd9c 100644 --- a/TemplateCanvas.cpp +++ b/TemplateCanvas.cpp @@ -60,7 +60,6 @@ #include "logger.h" -using namespace std; //////////////////////////////////////////////////////////////////////////////// // // @@ -453,7 +452,7 @@ std::vector TemplateCanvas::CreateSelShpsFromProj(std::vector& s int num_recs = project->GetNumRecords(); selectable_shps.resize(num_recs); - vector& records = project->main_data.records; + std::vector& records = project->main_data.records; Header& hdr = project->main_data.header; if (hdr.shape_type == Shapefile::POINT_TYP) { @@ -645,7 +644,7 @@ void TemplateCanvas::RenderToSVG(wxDC &dc, int w, int h) BOOST_FOREACH( GdaShape* shp, background_shps ) { shp->paintSelf(dc); } - vector& hs = highlight_state->GetHighlight(); + std::vector& hs = highlight_state->GetHighlight(); if (use_category_brushes) { helper_DrawSelectableShapes_dc(dc, hs, false, false); @@ -867,7 +866,7 @@ void TemplateCanvas::DrawHighlightedShapes(wxMemoryDC &dc) DrawSelectableShapes_dc(dc, highlight_only); } else { - vector& hs = GetSelBitVec(); + std::vector& hs = GetSelBitVec(); for (size_t i=0, iend=selectable_shps.size(); ipaintSelf(dc); @@ -879,7 +878,7 @@ void TemplateCanvas::DrawHighlightedShapes(wxMemoryDC &dc) void TemplateCanvas::DrawSelectableShapes_dc(wxMemoryDC &_dc, bool hl_only, bool revert) { - vector& hs = highlight_state->GetHighlight(); + std::vector& hs = highlight_state->GetHighlight(); #ifdef __WXOSX__ wxGCDC dc(_dc); helper_DrawSelectableShapes_dc(dc, hs, hl_only, revert); @@ -1042,7 +1041,7 @@ void TemplateCanvas::helper_DrawSelectableShapes_dc(wxDC &dc, vector& hs, } void TemplateCanvas::DrawPoints(wxGCDC& dc, CatClassifData& cat_data, - vector& hs, double radius, int alpha, + std::vector& hs, double radius, int alpha, wxColour fixed_pen_color, bool cross_hatch) { //int alpha = GdaConst::plot_transparency_unhighlighted;; @@ -1052,7 +1051,7 @@ void TemplateCanvas::DrawPoints(wxGCDC& dc, CatClassifData& cat_data, int w = sz.GetWidth(); int h = sz.GetHeight(); int bnd = w * h; - vector dirty(bnd, false); + std::vector dirty(bnd, false); dc.SetBrush(*wxTRANSPARENT_BRUSH); GdaPoint* p; @@ -1079,7 +1078,7 @@ void TemplateCanvas::DrawPoints(wxGCDC& dc, CatClassifData& cat_data, brush_color.Blue(), alpha); dc.SetBrush(wxBrush(brush_color_alpha)); } - vector& ids = cat_data.GetIdsRef(cc_ts, cat); + std::vector& ids = cat_data.GetIdsRef(cc_ts, cat); for (int i=0, iend=ids.size(); i& hs, int alpha, + std::vector& hs, int alpha, wxColour fixed_pen_color, bool cross_hatch) { //int alpha = GdaConst::plot_transparency_unhighlighted;; @@ -1128,7 +1127,7 @@ void TemplateCanvas::DrawPolygons(wxGCDC& dc, CatClassifData& cat_data, wxColour brush_color_alpha(brush_color.Red(), brush_color.Green(), brush_color.Blue(), alpha); dc.SetBrush(wxBrush(brush_color_alpha)); } - vector& ids = cat_data.GetIdsRef(cc_ts, cat); + std::vector& ids = cat_data.GetIdsRef(cc_ts, cat); for (int i=0, iend=ids.size(); i& ids = cat_data.GetIdsRef(cc_ts, cat); + std::vector& ids = cat_data.GetIdsRef(cc_ts, cat); for (int i=0, iend=ids.size(); i& hs, int alpha, + std::vector& hs, int alpha, wxColour fixed_pen_color, bool cross_hatch) { //int alpha = GdaConst::plot_transparency_unhighlighted;; @@ -1221,7 +1220,7 @@ void TemplateCanvas::DrawLines(wxGCDC& dc, CatClassifData& cat_data, pen_color.Blue(), alpha); dc.SetPen(wxPen(pen_color_alpha)); - vector& ids = cat_data.GetIdsRef(cc_ts, cat); + std::vector& ids = cat_data.GetIdsRef(cc_ts, cat); for (int i=0, iend=ids.size(); i& hs, + std::vector& hs, bool hl_only, bool revert, bool crosshatch, @@ -1307,7 +1306,7 @@ void TemplateCanvas::helper_DrawSelectableShapes_gc(wxGraphicsContext &gc, gc.SetBrush(newBrush); } - vector& ids = cat_data.GetIdsRef(cc_ts, cat); + std::vector& ids = cat_data.GetIdsRef(cc_ts, cat); for (int i=0, iend=ids.size(); i TemplateCanvas::SaveCategories(const wxString& title, const wxString& label, const wxString& field_default, - vector& undefs) + std::vector& undefs) { std::vector new_fields; if (project->GetNumRecords() != selectable_shps.size()) return new_fields; @@ -2484,8 +2483,8 @@ void TemplateCanvas::GetVizInfo(map >& colors) } void TemplateCanvas::GetVizInfo(wxString& shape_type, - vector& clrs, - vector& bins) + std::vector& clrs, + std::vector& bins) { if (selectable_shps_type == points) { diff --git a/io/MatfileReader.cpp b/io/MatfileReader.cpp index b1daa5349..a11cfb3c7 100644 --- a/io/MatfileReader.cpp +++ b/io/MatfileReader.cpp @@ -3,7 +3,6 @@ #include #include #include -using namespace std; #include #include "MatfileReader.h" @@ -30,7 +29,7 @@ inline void endianSwap(uint64_t& x) { } //========================================= -pair classify(char* data, bool endianSwap) { +std::pair classify(char* data, bool endianSwap) { uint32_t dataType; bool isSmallDataElement = (data[2] & 0xFF) || (data[3] & 0xFF); if (isSmallDataElement) @@ -38,7 +37,7 @@ pair classify(char* data, bool endianSwap) { else dataType = *(reinterpret_cast(data)); if (static_cast(dataType) != miMATRIX) - return make_pair(static_cast(dataType), mxINVALID); + return std::make_pair(static_cast(dataType), mxINVALID); // miMATRIX must not be small element //assert(!isSmallDataElement); @@ -46,13 +45,13 @@ pair classify(char* data, bool endianSwap) { EMatrixClass matrixClass; matrixClass = af->klass(); - return make_pair(static_cast(dataType), matrixClass); + return std::make_pair(static_cast(dataType), matrixClass); } DataElement* parse(char* data, bool endianSwap) { DataElement* de = NULL; // dispatch - pair kind = classify(data, endianSwap); + std::pair kind = classify(data, endianSwap); EDataType dataType = kind.first; EMatrixClass matrixClass = kind.second; switch (dataType) { @@ -146,14 +145,14 @@ DataElement* parse(char* data, bool endianSwap) { de = new NumericArray(data, endianSwap); break; default: - cerr << "invalid EMatrixClass!\n"; + std::cerr << "invalid EMatrixClass!\n"; } break; default: - cerr << "invalid EDataType!\n"; + std::cerr << "invalid EDataType!\n"; } if (!de) { - cerr << "failed to parse!\n"; + std::cerr << "failed to parse!\n"; } return de; } @@ -185,8 +184,8 @@ FlatDataElement::FlatDataElement(char* data, bool endianSwap) : DataElement(e FieldNames::FieldNames(char* data, bool endianSwap, int32_t fieldNameLength) : FlatDataElement(data, endianSwap), _fieldNameLength(fieldNameLength), _fieldNames() { - string name; - for (vector::iterator iter = _data.begin(); + std::string name; + for (std::vector::iterator iter = _data.begin(); iter + _fieldNameLength <= _data.end(); iter += _fieldNameLength) { name.assign(iter, iter+_fieldNameLength); @@ -212,13 +211,13 @@ CompressedDataElement::CompressedDataElement(char* data, bool endianSwap) : size *= 2; _decompressedData = new char[size]; if (!_decompressedData) { - cerr << "FlatDataElement::parseData new failed!\n"; + std::cerr << "FlatDataElement::parseData new failed!\n"; } rsize = size; res = uncompress(reinterpret_cast(_decompressedData), &size, reinterpret_cast(data), _numberOfBytes); } else { - cerr << "FlatDataElement::parseData uncompress failed!\n"; + std::cerr << "FlatDataElement::parseData uncompress failed!\n"; } } _decompressedSize = static_cast(rsize); @@ -370,7 +369,7 @@ MatfileReader::MatfileReader(std::ifstream& inputStream) _version(0), _endianIndicator(), _endianSwap(false) { //_inputStream.open(_matfile.c_str(), ios_base::in | ios_base::binary); if(!_inputStream.is_open()) { - cerr << "open " << _matfile.c_str() << " error!\n"; + std::cerr << "open " << _matfile.c_str() << " error!\n"; } } diff --git a/io/MatfileReader.h b/io/MatfileReader.h index e5187e18c..d46517b38 100644 --- a/io/MatfileReader.h +++ b/io/MatfileReader.h @@ -12,8 +12,6 @@ #include #include -using namespace std; - enum EDataType { miINT8 = 1, miUINT8 = 2, @@ -286,9 +284,9 @@ class Cell: public MatrixDataElement delete _cells[i]; } public: - vector& cells() { return _cells; } + std::vector& cells() { return _cells; } protected: - vector _cells; + std::vector _cells; }; class Struct: public MatrixDataElement @@ -306,7 +304,7 @@ class Struct: public MatrixDataElement public: FieldNameLength* fieldNameLength() { return _fieldNameLength; } FieldNames* fieldNames() { return _fieldNames; } - vector fields() { return _fields; } + std::vector fields() { return _fields; } protected: void parseFieldNameLength(char* fieldNameLength) { _fieldNameLength = new FieldNameLength(fieldNameLength, _endianSwap); @@ -317,7 +315,7 @@ class Struct: public MatrixDataElement protected: FieldNameLength* _fieldNameLength; FieldNames* _fieldNames; - vector _fields; + std::vector _fields; }; class Object: public Struct @@ -351,8 +349,8 @@ class MatfileReader int numberDataElements() { return _dataElements.size(); } std::vector dataElements() { return _dataElements; } public: - void gotoHeader() { _inputStream.seekg(0, ios_base::beg); } - void gotoData() { _inputStream.seekg(128, ios_base::beg); } + void gotoHeader() { _inputStream.seekg(0, std::ios_base::beg); } + void gotoData() { _inputStream.seekg(128, std::ios_base::beg); } void parseHeader(); bool parseDataElement(); void parseAllDataElements(); diff --git a/io/weights_interface.h b/io/weights_interface.h index 2cb6564f0..b867da24d 100644 --- a/io/weights_interface.h +++ b/io/weights_interface.h @@ -24,8 +24,6 @@ #include "../ShapeOperations/GalWeight.h" -using namespace std; - class WeightsNotValidException: public std::exception { virtual const char* what() const throw() { return "weights exception: weights file not valid";