Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into compression
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Nov 7, 2017
2 parents fd0c2f1 + c210361 commit 62f751c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
8 changes: 8 additions & 0 deletions cmake/examples.cmake
@@ -0,0 +1,8 @@
# EXAMPLE support
#

if (WITH_EXAMPLES)

include_directories(${ROOT_DIR}/pdal )
include_directories(${ROOT_DIR}/)
endif()
7 changes: 7 additions & 0 deletions doc/stages/readers.mbio.rst
Expand Up @@ -51,6 +51,13 @@ format
Name of number of format of file being read. See MB-System documentation
for a list of `all formats`_. [Required]

timegap
The maximum number of seconds that can elapse between pings before the
end of the data stream is assumed. [Default: 1.0]

speedmin
The minimum speed that the ship can be moving to before the end of the
data stream is assumed. [Default: 0]

.. _MB-System: http://www.ldeo.columbia.edu/res/pi/MB-System/

Expand Down
12 changes: 8 additions & 4 deletions pdal/util/Utils.hpp
Expand Up @@ -879,11 +879,15 @@ namespace Utils
bool fromString(const std::string& from, T* & to)
{
void *v;
std::istringstream iss(from);

iss >> v;
// Uses sscanf instead of operator>>(istream, void*&) as a workaround
// for https://bugs.llvm.org/show_bug.cgi?id=19740, which presents with
// clang-800.0.42.1 for x86_64-apple-darwin15.6.0.
int result = sscanf(from.c_str(), "%p", &v);
if (result != 1) {
return false;
}
to = reinterpret_cast<T*>(v);
return !iss.fail();
return true;
}


Expand Down
11 changes: 7 additions & 4 deletions plugins/mbio/io/MbReader.cpp
Expand Up @@ -39,6 +39,8 @@
#include <pdal/util/ProgramArgs.hpp>
#include <pdal/DimUtil.hpp>

#include <mb_status.h>

namespace pdal
{

Expand All @@ -65,6 +67,9 @@ void MbReader::addArgs(ProgramArgs& args)
{
args.add("format", "Name or number of MBIO data format",
m_format).setPositional();
args.add("timegap", "Maximum time between records.", m_timegap, 1.0);
args.add("speedmin", "Minimum vehicle speed for data to be valid",
m_speedmin);
}


Expand All @@ -86,8 +91,6 @@ void MbReader::ready(PointTableRef table)
double bounds[4] { -180, 180, -90, 90 };
int btime_i[7] { 0, 0, 0, 0, 0, 0, 0 };
int etime_i[7] { std::numeric_limits<int>::max(), 0, 0, 0, 0, 0 };
double speedmin { 0 };
double timegap { 0 };
char *mbio_ptr;
double btime_d;
double etime_d;
Expand All @@ -98,7 +101,7 @@ void MbReader::ready(PointTableRef table)

mb_read_init(verbose, const_cast<char *>(m_filename.data()),
(int)m_format, pings, lonflip, bounds, btime_i, etime_i,
speedmin, timegap, &m_ctx, &btime_d, &etime_d,
m_speedmin, m_timegap, &m_ctx, &btime_d, &etime_d,
&beams_bath, &beams_amp, &pixels_ss, &error);
if (error > 0)
throwError("Can't initialize mb-system reader: " +
Expand Down Expand Up @@ -153,7 +156,7 @@ bool MbReader::loadData()

if (status == 0)
{
if (error > 0)
if (error > 0 && error != MB_ERROR_EOF)
throwError("Error reading data: " + MbError::text(error));
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/mbio/io/MbReader.hpp
Expand Up @@ -99,6 +99,8 @@ class PDAL_DLL MbReader : public pdal::Reader
double *m_sslat;
std::queue<BathData> m_bathQueue;
MbFormat m_format;
double m_timegap;
double m_speedmin;
};

} // namespace PDAL
4 changes: 1 addition & 3 deletions plugins/mbio/test/MBSystemTest.cpp
Expand Up @@ -55,7 +55,6 @@ TEST(MBSystemReaderTest, testRead)
Stage* reader(f.createStage("readers.mbio"));
EXPECT_TRUE(reader);

Option filename("filename", getFilePath());
Options options;
options.add("filename", getFilePath());
options.add("format", "mbf_em300raw");
Expand All @@ -66,6 +65,5 @@ TEST(MBSystemReaderTest, testRead)
PointViewSet viewSet = reader->execute(table);
EXPECT_EQ(viewSet.size(), 1u);
PointViewPtr view = *viewSet.begin();
EXPECT_EQ(view->size(), 112u);

EXPECT_EQ(view->size(), 3767u);
}

0 comments on commit 62f751c

Please sign in to comment.