diff --git a/CMakeLists.txt b/CMakeLists.txt index bd23b83..e5785cb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,5 +12,5 @@ set(CMAKE_DEBUG_POSTFIX d) ## add plugin add_subdirectory(src/filter_grid_decimation) -add_subdirectory(src/filter_radius_search) +add_subdirectory(src/filter_radius_assign) diff --git a/doc/grid_radius_search.md b/doc/grid_radius_assign.md similarity index 94% rename from doc/grid_radius_search.md rename to doc/grid_radius_assign.md index cd62bd5..dab4543 100755 --- a/doc/grid_radius_search.md +++ b/doc/grid_radius_assign.md @@ -1,9 +1,9 @@ -# filter grid decimation +# filter radius assign Purpose --------------------------------------------------------------------------------------------------------- -The **radius search filter** add a new attribut where the value depends on their neighbors in a given radius: For each point in the domain src_domain_, if it has any neighbor with a distance lower than radius_ that belongs to the domain reference_domain_, it is updated. +The **radius assign filter** add a new attribut where the value depends on their neighbors in a given radius: For each point in the domain src_domain_, if it has any neighbor with a distance lower than radius_ that belongs to the domain reference_domain_, it is updated. Example @@ -16,7 +16,7 @@ This pipeline updates the Keypoint dimension of all points with classification 1 [ "file-input.las", { - "type" : "filters.radiussearch", + "type" : "filters.radius_assign", "src_domain" : "Classification[1:2]", "reference_domain" : "Classification[6:6]", "radius" : 1, diff --git a/macro/ex_filtering_points.py b/macro/ex_filtering_points.py index 25994f9..403c26f 100755 --- a/macro/ex_filtering_points.py +++ b/macro/ex_filtering_points.py @@ -19,36 +19,36 @@ def parse_args(): pipeline = pdal.Reader.las(args.input) # step 1 a 9 - pipeline = macro.add_radius_search(pipeline, 1, False, "Classification==2", macro.build_condition("Classification", [4,5]), "Classification=102") - pipeline = macro.add_radius_search(pipeline, 1, False, "Classification==102", "Classification==2", "Classification=2") - pipeline = macro.add_radius_search(pipeline, 1, False, "Classification==3", "Classification==5", "Classification=103") + 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.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 = macro.add_radius_search(pipeline, 1.5, False, "Classification==102", macro.build_condition("Classification", [4,5,6,9,17,64,100]), "Classification=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") # step 10 - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==2", "Classification==17", "Classification=102") - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==102", macro.build_condition("Classification", [2,3,4,5]), "Classification=2") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==2", "Classification==17", "Classification=102") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==102", macro.build_condition("Classification", [2,3,4,5]), "Classification=2") # step 11 - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==3", "Classification==17", "Classification=103") - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==103", macro.build_condition("Classification", [2,3,4,5]), "Classification=3") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==3", "Classification==17", "Classification=103") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==103", macro.build_condition("Classification", [2,3,4,5]), "Classification=3") # step 12 - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==4", "Classification==17", "Classification=104") - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==104", macro.build_condition("Classification", [2,3,4,5]), "Classification=4") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==4", "Classification==17", "Classification=104") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==104", macro.build_condition("Classification", [2,3,4,5]), "Classification=4") # step 13 - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==5", "Classification==17", "Classification=105") - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==105", macro.build_condition("Classification", [2,3,4,5]), "Classification=5") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==5", "Classification==17", "Classification=105") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==105", macro.build_condition("Classification", [2,3,4,5]), "Classification=5") # step 14 - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==9", "Classification==17", "Classification=109") - pipeline = macro.add_radius_search(pipeline, 1.5, False, "Classification==109", "Classification==9", "Classification=9") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==9", "Classification==17", "Classification=109") + pipeline = macro.add_radius_assign(pipeline, 1.5, False, "Classification==109", "Classification==9", "Classification=9") pipeline |= pdal.Writer.las(extra_dims="all",minor_version=4,dataformat_id=6,filename=args.output) pipeline.execute() diff --git a/macro/macro.py b/macro/macro.py index e38dc4b..0cddaf7 100755 --- a/macro/macro.py +++ b/macro/macro.py @@ -6,7 +6,7 @@ """ -def add_radius_search(pipeline, radius, search_3d, condition_src, condition_ref, condition_out ): +def add_radius_assign(pipeline, radius, search_3d, condition_src, condition_ref, condition_out ): """ search points from "condition_src" closed from "condition_ref", and reassign them to "condition_out" This combination is equivalent to the CloseBy macro of TerraScan @@ -18,7 +18,7 @@ def add_radius_search(pipeline, radius, search_3d, condition_src, condition_ref, pipeline |= pdal.Filter.assign(value=["SRS_DOMAIN = 0", f"SRS_DOMAIN = 1 WHERE {condition_src}", "REF_DOMAIN = 0", f"REF_DOMAIN = 1 WHERE {condition_ref}", "radius_search = 0"]) - pipeline |= pdal.Filter.radius_search(radius=radius, src_domain="SRS_DOMAIN",reference_domain="REF_DOMAIN", + pipeline |= pdal.Filter.radius_assign(radius=radius, src_domain="SRS_DOMAIN",reference_domain="REF_DOMAIN", output_name_attribute="radius_search", search_3d=search_3d) pipeline |= pdal.Filter.assign(value=condition_out,where="radius_search==1") return pipeline diff --git a/src/filter_radius_assign/CMakeLists.txt b/src/filter_radius_assign/CMakeLists.txt new file mode 100755 index 0000000..2a49e7c --- /dev/null +++ b/src/filter_radius_assign/CMakeLists.txt @@ -0,0 +1,16 @@ + +file( GLOB_RECURSE GD_SRCS + ${CMAKE_SOURCE_DIR}/src/filter_radius_assign/*.hpp + ${CMAKE_SOURCE_DIR}/src/filter_radius_assign/*.cpp) + +PDAL_CREATE_PLUGIN( + TYPE filter + NAME radius_assign + VERSION 1.0 + SOURCES ${GD_SRCS} +) + +install(TARGETS + pdal_plugin_filter_radius_assign +) + diff --git a/src/filter_radius_search/radius_searchFilter.cpp b/src/filter_radius_assign/radius_assignFilter.cpp similarity index 98% rename from src/filter_radius_search/radius_searchFilter.cpp rename to src/filter_radius_assign/radius_assignFilter.cpp index 45d7ff7..cad6fbf 100644 --- a/src/filter_radius_search/radius_searchFilter.cpp +++ b/src/filter_radius_assign/radius_assignFilter.cpp @@ -1,4 +1,4 @@ -#include "radius_searchFilter.hpp" +#include "radius_assignFilter.hpp" #include #include @@ -13,7 +13,7 @@ namespace pdal { static PluginInfo const s_info = PluginInfo( - "filters.radius_search", + "filters.radius_assign", "Re-assign some point attributes based KNN voting", "" ); diff --git a/src/filter_radius_search/radius_searchFilter.hpp b/src/filter_radius_assign/radius_assignFilter.hpp similarity index 100% rename from src/filter_radius_search/radius_searchFilter.hpp rename to src/filter_radius_assign/radius_assignFilter.hpp diff --git a/src/filter_radius_search/CMakeLists.txt b/src/filter_radius_search/CMakeLists.txt deleted file mode 100755 index b7ba4e6..0000000 --- a/src/filter_radius_search/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ - -file( GLOB_RECURSE GD_SRCS - ${CMAKE_SOURCE_DIR}/src/filter_radius_search/*.hpp - ${CMAKE_SOURCE_DIR}/src/filter_radius_search/*.cpp) - -PDAL_CREATE_PLUGIN( - TYPE filter - NAME radius_search - VERSION 1.0 - SOURCES ${GD_SRCS} -) - -install(TARGETS - pdal_plugin_filter_radius_search -) - diff --git a/test/test_radius_search.py b/test/test_radius_assign.py similarity index 96% rename from test/test_radius_search.py rename to test/test_radius_assign.py index 373cbb3..f517252 100755 --- a/test/test_radius_search.py +++ b/test/test_radius_assign.py @@ -20,7 +20,7 @@ def distance3d(pt1, pt2): def run_filter(arrays_las, distance_radius, search_3d, distance_cylinder=0. ): - filter = "filters.radius_search" + filter = "filters.radius_assign" utils.pdal_has_plugin(filter) with tempfile.NamedTemporaryFile(suffix="_las_tmp.las") as las: @@ -99,7 +99,7 @@ def build_random_points_around_one_point(test_function): return arrays_las, nb_points_take -def test_radius_search_3d(): +def test_radius_assign_3d(): distance_radius = 1 @@ -114,7 +114,7 @@ def func_test(pt_ini, pt): assert nb_pts_radius_3d == nb_points_take_3d -def test_radius_search_2d(): +def test_radius_assign_2d(): distance_radius = 1 @@ -129,7 +129,7 @@ def func_test(pt_ini, pt): assert nb_pts_radius_2d == nb_points_take_2d -def test_radius_search_2d_cylinder(): +def test_radius_assign_2d_cylinder(): distance_radius = 1 distance_cylinder = 0.25