diff --git a/io/GeotiffSupport.cpp b/io/GeotiffSupport.cpp index 8649dd8182..a0b0f025a6 100644 --- a/io/GeotiffSupport.cpp +++ b/io/GeotiffSupport.cpp @@ -124,6 +124,9 @@ GeotiffSrs::GeotiffSrs(const std::vector& directoryRec, } ctx.gtiff = GTIFNewSimpleTags(ctx.tiff); + if (!ctx.gtiff) + throw Geotiff::error("Couldn't create Geotiff tags from " + "Geotiff definition."); GTIFDefn sGTIFDefn; if (GTIFGetDefn(ctx.gtiff, &sGTIFDefn)) @@ -145,7 +148,7 @@ GeotiffTags::GeotiffTags(const SpatialReference& srs) // Set tiff tags from WKT if (!GTIFSetFromOGISDefn(ctx.gtiff, srs.getWKT().c_str())) - throw error("Could not set m_gtiff from WKT"); + throw Geotiff::error("Could not set m_gtiff from WKT"); GTIFWriteKeys(ctx.gtiff); auto sizeFromType = [](int type, int count) -> size_t diff --git a/io/GeotiffSupport.hpp b/io/GeotiffSupport.hpp index 8ae66530bc..aa3e71608d 100644 --- a/io/GeotiffSupport.hpp +++ b/io/GeotiffSupport.hpp @@ -39,6 +39,15 @@ namespace pdal { +namespace Geotiff +{ + struct error : public std::runtime_error + { + error(const std::string& err) : std::runtime_error(err) + {} + }; +} + class GeotiffSrs { public: @@ -54,12 +63,6 @@ class GeotiffSrs class GeotiffTags { public: - struct error : public std::runtime_error - { - error(const std::string& err) : std::runtime_error(err) - {} - }; - GeotiffTags(const SpatialReference& srs); std::vector& directoryData() diff --git a/io/LasHeader.cpp b/io/LasHeader.cpp index 264878066a..c503c018ec 100644 --- a/io/LasHeader.cpp +++ b/io/LasHeader.cpp @@ -220,6 +220,11 @@ void LasHeader::setSrs() else setSrsFromGeotiff(); } + catch (Geotiff::error err) + { + m_log->get(LogLevel::Error) << "Could not create an SRS: " << + err.what() << std::endl; + } catch (...) { m_log->get(LogLevel::Error) << "Could not create an SRS" << std::endl; diff --git a/io/LasWriter.cpp b/io/LasWriter.cpp index 5ede8ed26d..8225746367 100644 --- a/io/LasWriter.cpp +++ b/io/LasWriter.cpp @@ -470,7 +470,7 @@ void LasWriter::addGeotiffVlrs() addVlr(TRANSFORM_USER_ID, GEOTIFF_ASCII_RECORD_ID, "GeoTiff GeoAsciiParamsTag", tags.asciiData()); } - catch (GeotiffTags::error& err) + catch (Geotiff::error& err) { throwError(err.what()); }