OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Geospatial::GDAL Class Reference

#include <GDAL.h>

Static Public Member Functions

static void init ()
 
static bool supportsNetworkFileAccess ()
 
static bool supportsDriver (const char *driver_name)
 

Static Private Attributes

static bool initialized_ = false
 
static std::mutex init_mutex_
 

Detailed Description

Definition at line 23 of file GDAL.h.

Member Function Documentation

void Geospatial::GDAL::init ( )
static

Definition at line 59 of file GDAL.cpp.

References Geospatial::anonymous_namespace{GDAL.cpp}::gdal_error_handler(), omnisci::get_root_abs_path(), logger::INFO, init_mutex_, initialized_, and LOG.

Referenced by import_export::QueryExporterGDAL::beginExport(), import_export::Importer::gdalGetAllFilesInArchive(), import_export::Importer::gdalGetLayersInGeoFile(), import_export::Importer::gdalStatInternal(), import_export::Importer::openGDALDataset(), supportsDriver(), and Geospatial::GeoBase::transform().

59  {
60  // this should not be called from multiple threads, but...
61  std::lock_guard<std::mutex> guard(init_mutex_);
62 
63  // init under mutex
64  if (!initialized_) {
65  // FIXME(andrewseidl): investigate if CPLPushFinderLocation can be public
66 #ifdef _MSC_VER
67  SetEnvironmentVariable(
68  L"GDAL_DATA",
69  reinterpret_cast<LPCWSTR>(
70  std::string(omnisci::get_root_abs_path() + "/ThirdParty/gdal-data").c_str()));
71 #else
72  setenv("GDAL_DATA",
73  std::string(omnisci::get_root_abs_path() + "/ThirdParty/gdal-data").c_str(),
74  true);
75 #endif
76 
77 #ifndef _MSC_VER // TODO
78  // configure SSL certificate path (per S3Archive::init_for_read)
79  // in a production build, GDAL and Curl will have been built on
80  // CentOS, so the baked-in system path will be wrong for Ubuntu
81  // and other Linux distros. Unless the user is deliberately
82  // overriding it by setting SSL_CERT_FILE explicitly in the server
83  // environment, we set it to whichever CA bundle directory exists
84  // on the machine we're running on
85  static constexpr std::array<const char*, 6> known_ca_paths{
86  "/etc/ssl/certs/ca-certificates.crt",
87  "/etc/pki/tls/certs/ca-bundle.crt",
88  "/usr/share/ssl/certs/ca-bundle.crt",
89  "/usr/local/share/certs/ca-root.crt",
90  "/etc/ssl/cert.pem",
91  "/etc/ssl/ca-bundle.pem"};
92  for (const auto& known_ca_path : known_ca_paths) {
93  if (boost::filesystem::exists(known_ca_path)) {
94  LOG(INFO) << "GDAL SSL Certificate path: " << known_ca_path;
95  setenv("SSL_CERT_FILE", known_ca_path, false); // no overwrite
96  break;
97  }
98  }
99 #endif
100 
101  GDALAllRegister();
102  OGRRegisterAll();
103  CPLSetErrorHandler(*gdal_error_handler);
104  LOG(INFO) << "GDAL Initialized: " << GDALVersionInfo("--version");
105  initialized_ = true;
106  }
107 }
void gdal_error_handler(CPLErr err_class, int err_no, const char *err_msg)
Definition: GDAL.cpp:35
#define LOG(tag)
Definition: Logger.h:188
static bool initialized_
Definition: GDAL.h:30
static std::mutex init_mutex_
Definition: GDAL.h:31
std::string get_root_abs_path()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Geospatial::GDAL::supportsDriver ( const char *  driver_name)
static

Definition at line 117 of file GDAL.cpp.

References init().

117  {
118  init();
119  return GetGDALDriverManager()->GetDriverByName(driver_name) != nullptr;
120 }
static void init()
Definition: GDAL.cpp:59

+ Here is the call graph for this function:

bool Geospatial::GDAL::supportsNetworkFileAccess ( )
static

Definition at line 109 of file GDAL.cpp.

Referenced by anonymous_namespace{DBHandler.cpp}::add_vsi_network_prefix().

109  {
110 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 2)
111  return true;
112 #else
113  return false;
114 #endif
115 }

+ Here is the caller graph for this function:

Member Data Documentation

std::mutex Geospatial::GDAL::init_mutex_
staticprivate

Definition at line 31 of file GDAL.h.

Referenced by init().

bool Geospatial::GDAL::initialized_ = false
staticprivate

Definition at line 30 of file GDAL.h.

Referenced by init().


The documentation for this class was generated from the following files: