OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
import_export::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 import_export::GDAL::init ( )
static

Definition at line 56 of file GDAL.cpp.

References import_export::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(), and supportsDriver().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 105 of file GDAL.cpp.

References init().

105  {
106  init();
107  return GetGDALDriverManager()->GetDriverByName(driver_name) != nullptr;
108 }
static void init()
Definition: GDAL.cpp:56

+ Here is the call graph for this function:

bool import_export::GDAL::supportsNetworkFileAccess ( )
static

Definition at line 97 of file GDAL.cpp.

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

97  {
98 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 2)
99  return true;
100 #else
101  return false;
102 #endif
103 }

+ Here is the caller graph for this function:

Member Data Documentation

std::mutex import_export::GDAL::init_mutex_
staticprivate

Definition at line 31 of file GDAL.h.

Referenced by init().

bool import_export::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: