Skip to content

Commit

Permalink
Don't emit LAS validation errors unless requested.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Aug 2, 2017
1 parent 40a1d82 commit 5dc0cf5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions io/LasError.hpp
Expand Up @@ -44,18 +44,22 @@ namespace pdal
class LasError
{
public:
LasError() : m_filename("<unknown>")
LasError() : m_filename("<unknown>"), m_validate(false)
{}

void setFilename(const std::string& filename)
{ m_filename = filename; }
void setValidate(bool validate)
{ m_validate = validate; }

void setLog(LogPtr log) { m_log = log; }

void returnNumWarning(int returnNum)
{
static std::vector<int> warned;

if (!m_validate)
return;
if (!Utils::contains(warned, returnNum))
{
warned.push_back(returnNum);
Expand All @@ -69,16 +73,20 @@ class LasError
{
static std::vector<int> warned;

if (!m_validate)
return;
if (!Utils::contains(warned, numReturns))
{
warned.push_back(numReturns);
m_log->get(LogLevel::Warning) << m_filename << ": Found invalid value "
"of '" << numReturns << "' for point's number of returns.\n";
m_log->get(LogLevel::Warning) << m_filename <<
": Found invalid value of '" << numReturns <<
"' for point's number of returns.\n";
}
}

private:
std::string m_filename;
bool m_validate;
LogPtr m_log;
};

Expand Down
3 changes: 3 additions & 0 deletions io/LasReader.cpp
Expand Up @@ -70,6 +70,8 @@ void LasReader::addArgs(ProgramArgs& args)
args.add("extra_dims", "Dimensions to assign to extra byte data",
m_extraDimSpec);
args.add("compression", "Decompressor to use", m_compression, "EITHER");
args.add("validate", "Perform some file validation as data is read",
m_validate);
}


Expand Down Expand Up @@ -148,6 +150,7 @@ void LasReader::initializeLocal(PointTableRef table, MetadataNode& m)
// Set case-corrected value.
m_compression = compression;
m_error.setFilename(m_filename);
m_error.setValidate(m_validate);

m_error.setLog(log());
m_header.setLog(log());
Expand Down
1 change: 1 addition & 0 deletions io/LasReader.hpp
Expand Up @@ -120,6 +120,7 @@ class PDAL_DLL LasReader : public pdal::Reader
StringList m_extraDimSpec;
std::vector<ExtraDim> m_extraDims;
std::string m_compression;
bool m_validate;

virtual void addArgs(ProgramArgs& args);
virtual void initialize(PointTableRef table)
Expand Down

0 comments on commit 5dc0cf5

Please sign in to comment.