OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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(), Geospatial::GeoBase::getTransformation(), import_export::Importer::openGDALDataset(), and supportsDriver().

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  SetEnvironmentVariable(
72  L"PROJ_LIB",
73  reinterpret_cast<LPCWSTR>(
74  std::string(omnisci::get_root_abs_path() + "/ThirdParty/gdal-data/proj")
75  .c_str()));
76 #else
77  setenv("GDAL_DATA",
78  std::string(omnisci::get_root_abs_path() + "/ThirdParty/gdal-data").c_str(),
79  true);
80  setenv(
81  "PROJ_LIB",
82  std::string(omnisci::get_root_abs_path() + "/ThirdParty/gdal-data/proj").c_str(),
83  true);
84 #endif
85 
86 #ifndef _MSC_VER // TODO
87  // configure SSL certificate path (per S3Archive::init_for_read)
88  // in a production build, GDAL and Curl will have been built on
89  // CentOS, so the baked-in system path will be wrong for Ubuntu
90  // and other Linux distros. Unless the user is deliberately
91  // overriding it by setting SSL_CERT_FILE explicitly in the server
92  // environment, we set it to whichever CA bundle directory exists
93  // on the machine we're running on
94  static constexpr std::array<const char*, 6> known_ca_paths{
95  "/etc/ssl/certs/ca-certificates.crt",
96  "/etc/pki/tls/certs/ca-bundle.crt",
97  "/usr/share/ssl/certs/ca-bundle.crt",
98  "/usr/local/share/certs/ca-root.crt",
99  "/etc/ssl/cert.pem",
100  "/etc/ssl/ca-bundle.pem"};
101  for (const auto& known_ca_path : known_ca_paths) {
102  if (boost::filesystem::exists(known_ca_path)) {
103  LOG(INFO) << "GDAL SSL Certificate path: " << known_ca_path;
104  setenv("SSL_CERT_FILE", known_ca_path, false); // no overwrite
105  break;
106  }
107  }
108 #endif
109 
110  GDALAllRegister();
111  OGRRegisterAll();
112  CPLSetErrorHandler(*gdal_error_handler);
113  LOG(INFO) << "GDAL Initialized: " << GDALVersionInfo("--version");
114  initialized_ = true;
115  }
116 }
void gdal_error_handler(CPLErr err_class, int err_no, const char *err_msg)
Definition: GDAL.cpp:35
#define LOG(tag)
Definition: Logger.h:203
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 126 of file GDAL.cpp.

References init().

126  {
127  init();
128  return GetGDALDriverManager()->GetDriverByName(driver_name) != nullptr;
129 }
static void init()
Definition: GDAL.cpp:59

+ Here is the call graph for this function:

bool Geospatial::GDAL::supportsNetworkFileAccess ( )
static

Definition at line 118 of file GDAL.cpp.

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

118  {
119 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 2)
120  return true;
121 #else
122  return false;
123 #endif
124 }

+ 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: