Skip to content

Commit

Permalink
deprectated grid_decimation
Browse files Browse the repository at this point in the history
  • Loading branch information
alavenant committed May 17, 2024
1 parent 4c94f77 commit 0559a0b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
2 changes: 2 additions & 0 deletions doc/grid_decimation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# filter grid decimation

**Deprecated** : *better use the gridDecimation filter of pdal > 2.7*

Purpose
---------------------------------------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions macro/ex_filtering_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
16 changes: 0 additions & 16 deletions macro/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/filter_grid_decimation/GridDecimationFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void GridDecimationFilter::processOne(BOX2D bounds, PointRef& point, PointViewPt
double y = point.getFieldAs<double>(Dimension::Id::Y);
int id = point.getFieldAs<double>(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<int>(d_width_pt);
int height = static_cast<int>(d_height_pt);
Expand Down

0 comments on commit 0559a0b

Please sign in to comment.