diff --git a/doc/stages/filters.computerange.rst b/doc/stages/filters.computerange.rst deleted file mode 100644 index 4b4dc94db3..0000000000 --- a/doc/stages/filters.computerange.rst +++ /dev/null @@ -1,36 +0,0 @@ -.. _filters.computerange: - -=============================================================================== -filters.computerange -=============================================================================== - -The Compute Range filter computes the range from the sensor to each of the -detected returns. - -.. note:: - - The Compute Range filter is specific to raw data from a particular data - provider, where the sensor coordinates for each frame are encoded as regular - points, and are identified by the pixel number -5. - -.. embed:: - -Example -------------------------------------------------------------------------------- - -.. code-block:: json - - { - "pipeline":[ - "input.bpf", - { - "type":"filters.computerange" - }, - { - "type":"writers.bpf", - "filename":"output.bpf", - "output_dims":"X,Y,Z,Range" - } - ] - } - diff --git a/filters/ComputeRangeFilter.cpp b/filters/ComputeRangeFilter.cpp deleted file mode 100644 index a99c42b26a..0000000000 --- a/filters/ComputeRangeFilter.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************** -* Copyright (c) 2016, Bradley J Chambers (brad.chambers@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. -****************************************************************************/ - -#include "ComputeRangeFilter.hpp" - -#include - -namespace pdal -{ - -static StaticPluginInfo const s_info -{ - "filters.computerange", - "Compute Range Filter", - "http://pdal.io/stages/filters.computerange.html" -}; - -CREATE_STATIC_STAGE(ComputeRangeFilter, s_info) - -std::string ComputeRangeFilter::getName() const -{ - return s_info.name; -} - - -void ComputeRangeFilter::addDimensions(PointLayoutPtr layout) -{ - m_range = layout->registerOrAssignDim("Range", Dimension::Type::Double); -} - - -void ComputeRangeFilter::prepared(PointTableRef table) -{ - using namespace Dimension; - - const PointLayoutPtr layout(table.layout()); - - m_frameNumber = layout->findDim("Frame Number"); - if (m_frameNumber == Id::Unknown) - throwError("missing Frame Number dimension in input PointView"); - - m_pixelNumber = layout->findDim("Pixel Number"); - if (m_pixelNumber == Id::Unknown) - throwError("missing Pixel Number dimension in input PointView"); -} - -void ComputeRangeFilter::filter(PointView& view) -{ - using namespace Dimension; - - // Sensor coordinates are provided for each frame. The pixel number -5 is - // used to flag the sensor position. - log()->get(LogLevel::Debug) << "Stash sensor positions...\n"; - struct sp - { - double sx, sy, sz; - }; - std::map smap; - for (PointId i = 0; i < view.size(); ++i) - { - int f = view.getFieldAs(m_frameNumber, i); - int p = view.getFieldAs(m_pixelNumber, i); - if (p == -5) - { - smap[f].sx = view.getFieldAs(Id::X, i); - smap[f].sy = view.getFieldAs(Id::Y, i); - smap[f].sz = view.getFieldAs(Id::Z, i); - } - } - - // For each XYZ coordinate, we look up the sensor position for the - // corresponding frame and compute the Euclidean distance. This is - // recorded in the Range dimension. - log()->get(LogLevel::Debug) << "Compute ranges...\n"; - for (PointId i = 0; i < view.size(); ++i) - { - int f = view.getFieldAs(m_frameNumber, i); - double dx = smap[f].sx - view.getFieldAs(Id::X, i); - double dy = smap[f].sy - view.getFieldAs(Id::Y, i); - double dz = smap[f].sz - view.getFieldAs(Id::Z, i); - double r = std::sqrt(dx * dx + dy * dy + dz * dz); - view.setField(m_range, i, r); - } -} - -} // namespace pdal diff --git a/filters/ComputeRangeFilter.hpp b/filters/ComputeRangeFilter.hpp deleted file mode 100644 index a862b9d004..0000000000 --- a/filters/ComputeRangeFilter.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** -* Copyright (c) 2016, Bradley J Chambers (brad.chambers@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. -****************************************************************************/ - -#pragma once - -#include - -#include - -namespace pdal -{ - -class PointLayout; -class PointView; - -class PDAL_DLL ComputeRangeFilter : public Filter -{ -public: - ComputeRangeFilter() : Filter() - {} - - std::string getName() const; - -private: - Dimension::Id m_pixelNumber, m_frameNumber, m_range; - - virtual void addDimensions(PointLayoutPtr layout); - virtual void filter(PointView& view); - virtual void prepared(PointTableRef table); - - ComputeRangeFilter& operator=(const ComputeRangeFilter&); // not implemented - ComputeRangeFilter(const ComputeRangeFilter&); // not implemented -}; - -} // namespace pdal diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 0011818e55..f405587ef3 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -108,7 +108,6 @@ PDAL_ADD_TEST(pdal_filters_colorinterp_test FILES filters/ColorinterpFilterTest.cpp) PDAL_ADD_TEST(pdal_filters_colorization_test FILES filters/ColorizationFilterTest.cpp) -PDAL_ADD_TEST(pdal_filters_computerange_test FILES filters/ComputeRangeFilterTest.cpp) PDAL_ADD_TEST(pdal_filters_crop_test FILES filters/CropFilterTest.cpp) PDAL_ADD_TEST(pdal_filters_decimation_test FILES filters/DecimationFilterTest.cpp) diff --git a/test/unit/filters/ComputeRangeFilterTest.cpp b/test/unit/filters/ComputeRangeFilterTest.cpp deleted file mode 100644 index 5c52421b50..0000000000 --- a/test/unit/filters/ComputeRangeFilterTest.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/****************************************************************************** -* Copyright (c) 2016, Bradley J Chambers (brad.chambers@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. -****************************************************************************/ - -#include - -#include -#include -#include -#include -#include - -#include "Support.hpp" - -using namespace pdal; - -TEST(ComputeRangeFilterTest, create) -{ - StageFactory f; - Stage* filter(f.createStage("filters.computerange")); - EXPECT_TRUE(filter); -} - -TEST(ComputeRangeFilterTest, compute) -{ - using namespace Dimension; - - PointTable table; - PointLayoutPtr layout(table.layout()); - - layout->registerDim(Id::X); - layout->registerDim(Id::Y); - layout->registerDim(Id::Z); - Id pn = layout->registerOrAssignDim("Pixel Number", Type::Double); - Id fn = layout->registerOrAssignDim("Frame Number", Type::Double); - - PointViewPtr view(new PointView(table)); - - BufferReader r; - r.addView(view); - - ComputeRangeFilter crop; - crop.setInput(r); - crop.prepare(table); - - view->setField(Id::X, 0, 0.0); - view->setField(Id::Y, 0, 0.0); - view->setField(Id::Z, 0, 0.0); - view->setField(pn, 0, 0.0); - view->setField(fn, 0, 0.0); - - view->setField(Id::X, 1, 0.0); - view->setField(Id::Y, 1, 3.0); - view->setField(Id::Z, 1, 4.0); - view->setField(pn, 1, -5.0); - view->setField(fn, 1, 0.0); - - PointViewSet s = crop.execute(table); - EXPECT_EQ(1u, s.size()); - - Id range = layout->findDim("Range"); - EXPECT_NE(Id::Unknown, range); - - PointViewPtr out = *s.begin(); - EXPECT_EQ(2u, out->size()); - - EXPECT_EQ(5.0, out->getFieldAs(range, 0)); - EXPECT_EQ(0.0, out->getFieldAs(range, 1)); -}