-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-3282
- Loading branch information
Showing
28 changed files
with
439 additions
and
506 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 |
---|---|---|
@@ -1,19 +1,6 @@ | ||
# | ||
option(WITH_DRACO "Choose if Draco support should be built" TRUE) | ||
find_package(Draco EXACT 1.3.6) | ||
# the `pkg_check_modules` function is created with this call | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(DRACO REQUIRED draco>1.4.0) | ||
|
||
if (WITH_DRACO) | ||
set_package_properties(Draco PROPERTIES TYPE RECOMMENDED | ||
PURPOSE "Provides Draco compression") | ||
if(Draco_FOUND) | ||
include_directories(${draco_INCLUDE_DIR}) | ||
set(CMAKE_REQUIRED_LIBRARIES ${draco_LIBRARIES}) | ||
set(PDAL_HAVE_DRACO 1) | ||
set(BUILD_PLUGIN_DRACO 1) | ||
set(DRACO_LIBRARY "draco") | ||
else() | ||
set(WITH_DRACO FALSE) | ||
endif() | ||
else() | ||
set(WITH_DRACO FALSE) | ||
endif() | ||
set(PDAL_HAVE_DRACO 1) |
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,52 @@ | ||
.. _filters.zsmooth: | ||
|
||
filters.zsmooth | ||
=============================================================================== | ||
|
||
The **Zsmooth Filter** computes a new Z value as another dimension that is based | ||
on the Z values of neighboring points. | ||
|
||
All points within some distance in the X-Y plane from a reference point are ordered by Z value. | ||
The reference point's new smoothed Z value is chosen to be that of the Nth median value of | ||
the neighboring points, where N is specified as the _`medianpercent` option. | ||
|
||
Use :ref:`filters.assign` to assign the smoothed Z value to the actual Z dimension if | ||
desired. | ||
|
||
Example | ||
------- | ||
|
||
Compute the smoothed Z value as the median Z value of the neighbors within 2 units and | ||
assign the value back to the Z dimension. | ||
|
||
[ | ||
"input.las", | ||
{ | ||
"type": "filters.zsmooth", | ||
"radius": 2, | ||
"dim": "Zadj" | ||
}, | ||
{ | ||
"type": "filters.assign", | ||
"value": "Z = Zadj" | ||
}, | ||
"output.las" | ||
] | ||
|
||
Options | ||
------------------------------------------------------------------------------- | ||
|
||
radius | ||
All points within `radius` units from the reference point in the X-Y plane are considered | ||
to determine the smoothed Z value. [Default: 1] | ||
|
||
medianpercent | ||
A value between 0 and 100 that specifies the relative position of ordered Z values of neighbors | ||
to use as the new smoothed Z value. 0 specifies the minimum value. 100 specifies the | ||
maximum value. 50 specifies the mathematical median of the values. [Default: 50] | ||
|
||
dim | ||
The name of a dimension to use for the adjusted Z value. Cannot be 'Z'. [Required] | ||
|
||
.. include:: filter_opts.rst | ||
|
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,133 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2020, University Nevada, Reno | ||
* | ||
* 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. | ||
* | ||
* 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 <pdal/KDIndex.hpp> | ||
|
||
#include "ZsmoothFilter.hpp" | ||
|
||
namespace pdal | ||
{ | ||
|
||
static PluginInfo const ptstatInfo | ||
{ | ||
"filters.zsmooth", | ||
"Zsmooth Filter", | ||
"http://pdal.io/stages/filters.zsmooth.html" | ||
}; | ||
|
||
struct ZsmoothFilter::Private | ||
{ | ||
double radius; | ||
double pos; | ||
std::string dimName; | ||
Dimension::Id statDim; | ||
}; | ||
|
||
CREATE_SHARED_STAGE(ZsmoothFilter, ptstatInfo) | ||
|
||
std::string ZsmoothFilter::getName() const | ||
{ | ||
return ptstatInfo.name; | ||
} | ||
|
||
ZsmoothFilter::ZsmoothFilter() : m_p(new Private) | ||
{} | ||
|
||
|
||
ZsmoothFilter::~ZsmoothFilter() | ||
{} | ||
|
||
|
||
void ZsmoothFilter::addArgs(ProgramArgs& args) | ||
{ | ||
args.add("radius", "Radius in X/Y plane in which to find neighboring points", m_p->radius, 1.0); | ||
args.add("medianpercent", "Location (percent) in neighbor list at which to find " | ||
"neighbor Z value (min == 0, max == 100, median == 50, etc.)", m_p->pos, 50.0); | ||
args.add("dim", "Name of dimension in which to store statistic", m_p->dimName).setPositional(); | ||
} | ||
|
||
|
||
void ZsmoothFilter::addDimensions(PointLayoutPtr layout) | ||
{ | ||
m_p->statDim = layout->registerOrAssignDim(m_p->dimName, Dimension::Type::Double); | ||
if (m_p->statDim == Dimension::Id::Z) | ||
throwError("Can't use 'Z' as output dimension."); | ||
} | ||
|
||
|
||
void ZsmoothFilter::prepared(PointTableRef) | ||
{ | ||
if (m_p->pos < 0.0 || m_p->pos > 100.0) | ||
throwError("'medicanpercent' value must be in the range [0, 100]"); | ||
m_p->pos /= 100.0; | ||
} | ||
|
||
|
||
void ZsmoothFilter::filter(PointView& view) | ||
{ | ||
const KD2Index& kdi = view.build2dIndex(); | ||
|
||
for (PointId idx = 0; idx < view.size(); ++idx) | ||
{ | ||
double d = view.getFieldAs<double>(Dimension::Id::Z, idx); | ||
|
||
std::vector<double> valList; | ||
PointIdList nears = kdi.radius(idx, m_p->radius); | ||
for (PointId n = 1; n < nears.size(); ++n) | ||
{ | ||
double z = view.getFieldAs<double>(Dimension::Id::Z, nears[n]); | ||
valList.push_back(z); | ||
} | ||
std::sort(valList.begin(), valList.end()); | ||
|
||
double val; | ||
if (valList.empty()) | ||
val = view.getFieldAs<double>(Dimension::Id::Z, idx); | ||
else if (valList.size() == 1) | ||
val = valList[0]; | ||
else if (m_p->pos == 0.0) | ||
val = valList[0]; | ||
else if (m_p->pos == 1.0) | ||
val = valList[valList.size() - 1]; | ||
else | ||
{ | ||
double pos = m_p->pos * (valList.size() - 1); | ||
size_t low = std::floor(pos); | ||
size_t high = low + 1; | ||
double highfrac = pos - low; | ||
double lowfrac = 1 - highfrac; | ||
val = valList[low] * lowfrac + valList[high] * highfrac; | ||
|
||
} | ||
view.setField(m_p->statDim, idx, val); | ||
} | ||
} | ||
|
||
} // namespace pdal |
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,57 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2020, University Nevada, Reno | ||
* 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. | ||
* | ||
* 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 <memory> | ||
|
||
#include <pdal/Filter.hpp> | ||
|
||
namespace pdal | ||
{ | ||
|
||
class ZsmoothFilter : public Filter | ||
{ | ||
struct Private; | ||
|
||
public: | ||
std::string getName() const; | ||
|
||
ZsmoothFilter(); | ||
~ZsmoothFilter(); | ||
|
||
private: | ||
void addArgs(ProgramArgs& args); | ||
void addDimensions(PointLayoutPtr layout); | ||
void prepared(PointTableRef table); | ||
void filter(PointView& view); | ||
|
||
std::unique_ptr<Private> m_p; | ||
}; | ||
|
||
} // namespace pdal | ||
|
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
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
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
Oops, something went wrong.