Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
639 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
find_package(rdb COMPONENTS REQUIRED) | ||
set_package_properties(rdb PROPERTIES | ||
TYPE REQUIRED | ||
PURPOSE "Read data from Riegl databases" | ||
) | ||
|
||
PDAL_ADD_PLUGIN(libname reader rdb | ||
FILES | ||
io/RdbPointcloud.cpp | ||
io/RdbReader.cpp | ||
LINK_WITH | ||
${RDB_LIBRARY}) | ||
target_include_directories(${libname} PUBLIC ${RDB_INCLUDE_DIR}) | ||
|
||
set(RDB_TEST_NAME pdal_io_rxp_reader_test) | ||
option(BUILD_RDBLIB_TESTS "Build rdblib tests" ON) | ||
if (BUILD_RDBLIB_TESTS) | ||
configure_file( | ||
test/Config.hpp.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/test/Config.hpp" | ||
) | ||
|
||
PDAL_ADD_TEST(${RDB_TEST_NAME} | ||
FILES test/RdbReaderTest.cpp | ||
LINK_WITH ${libname}) | ||
target_include_directories(${RDB_TEST_NAME} PRIVATE | ||
${PROJECT_BINARY_DIR}/plugins/rdb/test | ||
${PROJECT_SOURCE_DIR}/plugins/rdb/io) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2015, Peter J. Gadomski (pete.gadomski@gmail.com) | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the | ||
* names of its contributors may be used to endorse or promote | ||
* products derived from this software without specific prior | ||
* written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
* OF SUCH DAMAGE. | ||
* | ||
* | ||
* This software has not been developed by RIEGL, and RIEGL will not provide any | ||
* support for this driver. Please do not contact RIEGL with any questions or | ||
* issues regarding this driver. RIEGL is not responsible for damages or other | ||
* issues that arise from use of this driver. This driver has been tested | ||
* against RiVLib version 1.39 on a Ubuntu 14.04 using gcc43. | ||
****************************************************************************/ | ||
|
||
#include "RdbPointcloud.hpp" | ||
|
||
|
||
namespace pdal | ||
{ | ||
|
||
|
||
Dimension::Id getTimeDimensionId(bool syncToPps) | ||
{ | ||
return syncToPps ? Dimension::Id::GpsTime : Dimension::Id::InternalTime; | ||
} | ||
|
||
|
||
RdbPointcloud::RdbPointcloud( | ||
const std::string& uri, | ||
bool syncToPps, | ||
bool minimal, | ||
bool reflectanceAsIntensity, | ||
float minReflectance, | ||
float maxReflectance, | ||
PointTableRef table) | ||
: | ||
, m_view(new PointView(table)) | ||
, m_idx(0) | ||
, m_syncToPps(syncToPps) | ||
, m_minimal(minimal) | ||
, m_reflectanceAsIntensity(reflectanceAsIntensity) | ||
, m_minReflectance(minReflectance) | ||
, m_maxReflectance(maxReflectance) | ||
, m_rc(scanlib::basic_rconnection::create(uri)) | ||
, m_dec(m_rc) | ||
{} | ||
|
||
|
||
RdbPointcloud::~RdbPointcloud() | ||
{ | ||
m_rc->close(); | ||
} | ||
|
||
|
||
point_count_t RdbPointcloud::read(PointViewPtr view, point_count_t count) | ||
{ | ||
point_count_t numRead = 0; | ||
|
||
if (m_idx < m_view->size()) | ||
{ | ||
numRead += writeSavedPoints(view, count); | ||
if (numRead == count) | ||
return numRead; | ||
} | ||
|
||
for (m_dec.get(m_rdbbuf); !m_dec.eoi(); m_dec.get(m_rdbbuf)) | ||
{ | ||
dispatch(m_rdbbuf.begin(), m_rdbbuf.end()); | ||
if (m_view->size() - m_idx + numRead >= count) break; | ||
} | ||
|
||
numRead += writeSavedPoints(view, count - numRead); | ||
|
||
return numRead; | ||
} | ||
|
||
|
||
point_count_t RdbPointcloud::writeSavedPoints(PointViewPtr view, point_count_t count) | ||
{ | ||
point_count_t numRead = 0; | ||
while (m_idx < m_view->size() && numRead < count) | ||
{ | ||
view->appendPoint(*m_view, m_idx); | ||
++m_idx, ++numRead; | ||
} | ||
return numRead; | ||
}; | ||
|
||
|
||
void RdbPointcloud::on_echo_transformed(echo_type echo) | ||
{ | ||
if (!(scanlib::pointcloud::single == echo || scanlib::pointcloud::last == echo)) | ||
{ | ||
// Come back later, when we've got all the echos | ||
return; | ||
} | ||
|
||
using namespace Dimension; | ||
|
||
point_count_t idx = m_view->size(); | ||
unsigned int returnNumber = 1; | ||
Id timeId = getTimeDimensionId(m_syncToPps); | ||
for (const auto& t : targets) | ||
{ | ||
m_view->setField(Id::X, idx, t.vertex[0]); | ||
m_view->setField(Id::Y, idx, t.vertex[1]); | ||
m_view->setField(Id::Z, idx, t.vertex[2]); | ||
m_view->setField(timeId, idx, t.time); | ||
if (!m_minimal) | ||
{ | ||
m_view->setField(Id::Amplitude, idx, t.amplitude); | ||
m_view->setField(Id::Reflectance, idx, t.reflectance); | ||
m_view->setField(Id::ReturnNumber, idx, returnNumber); | ||
m_view->setField(Id::NumberOfReturns, idx, targets.size()); | ||
m_view->setField(Id::EchoRange, idx, t.echo_range); | ||
m_view->setField(Id::Deviation, idx, t.deviation); | ||
m_view->setField(Id::BackgroundRadiation, idx, t.background_radiation); | ||
m_view->setField(Id::IsPpsLocked, idx, t.is_pps_locked); | ||
} | ||
if (m_reflectanceAsIntensity) { | ||
uint16_t intensity; | ||
if (t.reflectance > m_maxReflectance) { | ||
intensity = std::numeric_limits<uint16_t>::max(); | ||
} else if (t.reflectance < m_minReflectance) { | ||
intensity = 0; | ||
} else { | ||
intensity = uint16_t(std::roundf(double(std::numeric_limits<uint16_t>::max()) * | ||
(t.reflectance - m_minReflectance) / (m_maxReflectance - m_minReflectance))); | ||
} | ||
m_view->setField(Id::Intensity, idx, intensity); | ||
} | ||
++idx, ++returnNumber; | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2015, Peter J. Gadomski (pete.gadomski@gmail.com) | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the | ||
* names of its contributors may be used to endorse or promote | ||
* products derived from this software without specific prior | ||
* written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
* OF SUCH DAMAGE. | ||
* | ||
* | ||
* This software has not been developed by RIEGL, and RIEGL will not provide any | ||
* support for this driver. Please do not contact RIEGL with any questions or | ||
* issues regarding this driver. RIEGL is not responsible for damages or other | ||
* issues that arise from use of this driver. This driver has been tested | ||
* against RiVLib version 1.39 on a Ubuntu 14.04 using gcc43. | ||
****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <riegl/scanlib.hpp> | ||
|
||
#include <pdal/PointTable.hpp> | ||
#include <pdal/PointView.hpp> | ||
|
||
namespace pdal | ||
{ | ||
|
||
|
||
Dimension::Id getTimeDimensionId(bool syncToPps); | ||
|
||
|
||
class PDAL_DLL RdbPointcloud | ||
{ | ||
public: | ||
RdbPointcloud( | ||
const std::string& uri, | ||
bool isSyncToPps, | ||
bool m_minimal, | ||
bool m_reflectanceAsIntensity, | ||
float m_minReflectance, | ||
float m_maxReflectance, | ||
PointTableRef table); | ||
virtual ~RdbPointcloud(); | ||
|
||
point_count_t read(PointViewPtr view, point_count_t count); | ||
|
||
inline bool isSyncToPps() const | ||
{ | ||
return m_syncToPps; | ||
} | ||
|
||
protected: | ||
void on_echo_transformed(echo_type echo); | ||
|
||
private: | ||
virtual point_count_t writeSavedPoints(PointViewPtr view, point_count_t count); | ||
|
||
PointViewPtr m_view; | ||
point_count_t m_idx; | ||
bool m_syncToPps; | ||
bool m_minimal; | ||
bool m_reflectanceAsIntensity; | ||
float m_minReflectance; | ||
float m_maxReflectance; | ||
// std::shared_ptr<scanlib::basic_rconnection> m_rc; | ||
|
||
}; | ||
|
||
|
||
} // namespace pdal |
Oops, something went wrong.