Skip to content

Commit

Permalink
Report error when we can't convert geotiff keys. (#1911)
Browse files Browse the repository at this point in the history
Cloase #1910
  • Loading branch information
abellgithub authored and hobu committed May 30, 2018
1 parent d2c8f06 commit a88247b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion io/GeotiffSupport.cpp
Expand Up @@ -124,6 +124,9 @@ GeotiffSrs::GeotiffSrs(const std::vector<uint8_t>& 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))
Expand All @@ -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
Expand Down
15 changes: 9 additions & 6 deletions io/GeotiffSupport.hpp
Expand Up @@ -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:
Expand All @@ -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<uint8_t>& directoryData()
Expand Down
5 changes: 5 additions & 0 deletions io/LasHeader.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion io/LasWriter.cpp
Expand Up @@ -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());
}
Expand Down

0 comments on commit a88247b

Please sign in to comment.