From 0559a0b3125062ec4a0d25b9aa929a02414e135f Mon Sep 17 00:00:00 2001 From: Antoine Lavenant Date: Fri, 17 May 2024 17:27:46 +0200 Subject: [PATCH] deprectated grid_decimation --- doc/grid_decimation.md | 2 ++ macro/ex_filtering_points.py | 6 +++--- macro/macro.py | 16 ---------------- .../GridDecimationFilter.cpp | 4 ++-- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/doc/grid_decimation.md b/doc/grid_decimation.md index cd2b37f..9ce662f 100755 --- a/doc/grid_decimation.md +++ b/doc/grid_decimation.md @@ -1,5 +1,7 @@ # filter grid decimation +**Deprecated** : *better use the gridDecimation filter of pdal > 2.7* + Purpose --------------------------------------------------------------------------------------------------------- diff --git a/macro/ex_filtering_points.py b/macro/ex_filtering_points.py index 403c26f..6bd34cc 100755 --- a/macro/ex_filtering_points.py +++ b/macro/ex_filtering_points.py @@ -22,11 +22,11 @@ def parse_args(): pipeline = macro.add_radius_assign(pipeline, 1, False, "Classification==2", macro.build_condition("Classification", [4,5]), "Classification=102") pipeline = macro.add_radius_assign(pipeline, 1, False, "Classification==102", "Classification==2", "Classification=2") pipeline = macro.add_radius_assign(pipeline, 1, False, "Classification==3", "Classification==5", "Classification=103") - pipeline = macro.add_grid_decimation(pipeline, 0.75, "max", macro.build_condition("Classification", [4,5,102,103]), "Classification=100") + pipeline |= pdal.Filter.gridDecimation(resolution=0.75, value="Classification=100", output_type="max", where=macro.build_condition("Classification", [4,5,102,103])) pipeline |= pdal.Filter.assign(value="Classification=2", where="Classification==102") pipeline |= pdal.Filter.assign(value="Classification=3", where="Classification==103") - pipeline = macro.add_grid_decimation(pipeline, 0.5, "max", "Classification==2", "Classification=102") - pipeline = macro.add_grid_decimation(pipeline, 0.5, "max", macro.build_condition("Classification", [2,3,4,5,6,9,17,64,100]), "Classification=200") + pipeline |= pdal.Filter.gridDecimation(resolution=0.5, value="Classification=102", output_type="max", where="Classification==2") + pipeline |= pdal.Filter.gridDecimation(resolution=0.5, value="Classification=200", output_type="max", where=macro.build_condition("Classification", [2,3,4,5,6,9,17,64,100])) pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==102", macro.build_condition("Classification", [4,5,6,9,17,64,100]), "Classification=100") pipeline |= pdal.Filter.assign(value="Classification=2", where="Classification==102") diff --git a/macro/macro.py b/macro/macro.py index 219ed58..fa50364 100755 --- a/macro/macro.py +++ b/macro/macro.py @@ -24,22 +24,6 @@ def add_radius_assign(pipeline, radius, search_3d, condition_src, condition_ref, return pipeline - -def add_grid_decimation(pipeline, grid_resolution, output_type, condition, condition_out): - """ - Select a points in a grid from "condition"; points not selected are reassign to "condition_out" - This combination is equivalent to the Thin Points macro of TerraScan - grid_resolution : resolution of the grid - output_type : "max" or "min" (the highest or lower points of the grid) - condition, condition_out : a pdal condition as "Classification==2" - """ - pipeline |= pdal.Filter.grid_decimation(resolution=grid_resolution, output_dimension="grid", - output_type=output_type, where=condition) - pipeline |= pdal.Filter.assign(value=condition_out,where=f"grid==0 && ({condition})") - return pipeline - - - def classify_hgt_ground(pipeline, hmin, hmax, condition, condition_out): """ reassign points from "condition" between "hmin" and "hmax" of the ground to "condition_out" diff --git a/src/filter_grid_decimation/GridDecimationFilter.cpp b/src/filter_grid_decimation/GridDecimationFilter.cpp index 5f6fec9..a0d82e7 100755 --- a/src/filter_grid_decimation/GridDecimationFilter.cpp +++ b/src/filter_grid_decimation/GridDecimationFilter.cpp @@ -80,8 +80,8 @@ void GridDecimationFilter::processOne(BOX2D bounds, PointRef& point, PointViewPt double y = point.getFieldAs(Dimension::Id::Y); int id = point.getFieldAs(Dimension::Id::PointId); - double d_width_pt = std::floor((x - bounds.minx) / m_args->m_edgeLength); - double d_height_pt = std::floor((y - bounds.miny) / m_args->m_edgeLength); + double d_width_pt = std::ceil((x - bounds.minx) / m_args->m_edgeLength); + double d_height_pt = std::ceil((y - bounds.miny) / m_args->m_edgeLength); int width = static_cast(d_width_pt); int height = static_cast(d_height_pt);