22 #include <gdal_priv.h>
31 namespace Geospatial {
36 CHECK(err_class >= CE_None && err_class <= CE_Fatal);
37 static constexpr std::array<const char*, 5> err_class_strings{
44 std::string log_msg = std::string(
"GDAL ") + err_class_strings[err_class] +
": " +
46 if (err_class >= CE_Failure) {
47 throw std::runtime_error(log_msg);
67 SetEnvironmentVariable(
69 reinterpret_cast<LPCWSTR>(
77 #ifndef _MSC_VER // TODO
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",
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);
104 LOG(
INFO) <<
"GDAL Initialized: " << GDALVersionInfo(
"--version");
110 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 2)
119 return GetGDALDriverManager()->GetDriverByName(driver_name) !=
nullptr;
void gdal_error_handler(CPLErr err_class, int err_no, const char *err_msg)
static bool supportsDriver(const char *driver_name)
static bool supportsNetworkFileAccess()
static std::mutex init_mutex_
std::string get_root_abs_path()