diff --git a/macro/macro.py b/macro/macro.py index 093effd..08739c6 100755 --- a/macro/macro.py +++ b/macro/macro.py @@ -5,14 +5,37 @@ """ -def add_radius_assign(pipeline, radius, search_3d, condition_src, condition_ref, condition_out): +def add_radius_assign( + pipeline: pdal.Pipeline, + radius: float, + search_3d: bool, + condition_src: str, + condition_ref: str, + condition_out: str, + max2d_above: float = -1, + max2d_below: float = -1, +) -> pdal.Pipeline: """ - search points from "condition_src" closed from "condition_ref", and reassign them to "condition_out" + Search points from "condition_src" that are closer than "radius_search" from points that + belong to "condition_ref" and modify them with "condition_out" + This combination is equivalent to the CloseBy macro of TerraScan - radius : the search distance - search_3d : the distance research is in 3d if True - condition_src, condition_ref, condition_out : a pdal condition as "Classification==2" + + Args: + pipeline (pdal.Pipeline): pdal pipeline + radius (float): search distance + search_3d (bool): the distance research is in 3d if True (2d otherwise) + condition_src (str): pdal condition for points to apply the modification to (eg. "Classification==2") + condition_ref (str): pdal condition for the potential neighbors to search for (eg. "Classification==4") + condition_out (str): pdal condition to apply to the points that belong to "condition_src" and + have a point from "condition_ref" closer than "radius" (eg. "Classification==2") + max2d_above (float, optional): In case of 2d Search, upward limit for potential neighbors. Defaults to -1. + max2d_below (float, optional): In case of 2d Search, downward limit for potential neighbors. Defaults to -1. + + Returns: + pdal.Pipeline: output pipeline with the radius_assign steps added. """ + pipeline |= pdal.Filter.ferry(dimensions="=>REF_DOMAIN, =>SRC_DOMAIN, =>radius_search") pipeline |= pdal.Filter.assign( value=[ @@ -29,6 +52,8 @@ def add_radius_assign(pipeline, radius, search_3d, condition_src, condition_ref, reference_domain="REF_DOMAIN", output_dimension="radius_search", is3d=search_3d, + max2d_above=max2d_above, + max2d_below=max2d_below, ) pipeline |= pdal.Filter.assign(value=condition_out, where="radius_search==1") return pipeline diff --git a/scripts/mark_points_to_use_for_digital_models_with_new_dimension.py b/scripts/mark_points_to_use_for_digital_models_with_new_dimension.py index 5865e95..18aed19 100755 --- a/scripts/mark_points_to_use_for_digital_models_with_new_dimension.py +++ b/scripts/mark_points_to_use_for_digital_models_with_new_dimension.py @@ -140,9 +140,6 @@ def main(input_las, output_las, dsm_dimension, dtm_dimension, output_dsm, output # 3 - gestion des ponts # bouche trou : on filtre les points (2,3,4,5,9) au milieu du pont en les mettant à PT_ON_BRIDGE=1 - # TODO: ajouter "demi-cylindre" : - # - si végétation au dessus du pont alors on choisit la végétation - # - si végétation en dessous du pont alors on choisit le pont pipeline = macro.add_radius_assign( pipeline, @@ -151,6 +148,8 @@ def main(input_las, output_las, dsm_dimension, dtm_dimension, output_dsm, output condition_src=macro.build_condition("Classification", [2, 3, 4, 5, 9]), condition_ref="Classification==17", condition_out="PT_ON_BRIDGE=1", + max2d_above=0, # ne pas prendre les points qui sont au dessus des points pont (condition_ref) + max2d_below=-1, # prendre tous les points qui sont en dessous des points pont (condition_ref) ) pipeline = macro.add_radius_assign( pipeline,