Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update radius #25

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def define_marking_pipeline(input_las, output_las, dsm_dimension, dtm_dimension)
condition_src=macro.build_condition("Classification", [6, 9, 17, 67]),
condition_ref=macro.build_condition("Classification", [4, 5]),
condition_out="PT_ON_VEGET=1",
max2d_above=0,
max2d_below=-1,
max2d_above=-1,
max2d_below=0,
)
pipeline = macro.add_radius_assign(
pipeline,
Expand Down Expand Up @@ -182,8 +182,8 @@ def define_marking_pipeline(input_las, output_las, dsm_dimension, dtm_dimension)
condition_src="Classification==9",
condition_ref="Classification==2",
condition_out="PT_ON_SOL=1",
max2d_above=0,
max2d_below=-1,
max2d_above=-1,
max2d_below=0,
)
pipeline = macro.add_radius_assign(
pipeline,
Expand Down Expand Up @@ -292,8 +292,8 @@ def define_marking_pipeline(input_las, output_las, dsm_dimension, dtm_dimension)
condition_src=macro.build_condition("Classification", [2, 3, 4, 5, 6, 9, 67]),
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)
max2d_above=-1, # ne pas prendre les points qui sont en dessous des points pont (condition_ref)
alavenant marked this conversation as resolved.
Show resolved Hide resolved
max2d_below=0, # prendre tous les points qui sont au dessus des points pont (condition_ref)
)
pipeline = macro.add_radius_assign(
pipeline,
Expand All @@ -303,8 +303,8 @@ def define_marking_pipeline(input_las, output_las, dsm_dimension, dtm_dimension)
condition_ref="PT_ON_BRIDGE==0 && "
+ macro.build_condition("Classification", [2, 3, 4, 5, 6, 9, 67]),
condition_out="PT_ON_BRIDGE=0",
max2d_above=0.5, # ne pas prendre les points qui sont au dessus des points pont (condition_ref)
max2d_below=0.5, # prendre tous les points qui sont en dessous des points pont (condition_ref)
max2d_above=0.5, # ne pas prendre les points qui sont en dessous des points pont (condition_ref)
max2d_below=0.5, # prendre tous les points qui sont au dessus des points pont (condition_ref)
)
pipeline |= pdal.Filter.assign(value=[f"{dsm_dimension}=0 WHERE PT_ON_BRIDGE==1"])
###################################################################################################################
Expand Down
30 changes: 15 additions & 15 deletions src/filter_radius_assign/RadiusAssignFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,33 @@ void RadiusAssignFilter::ready(PointTableRef)
m_args->m_ptsToUpdate.clear();
}

void RadiusAssignFilter::doOneNoDomain(PointRef &point)
void RadiusAssignFilter::doOneNoDomain(PointRef &pointSrc)
{
// build3dIndex and build2dIndex are build once
PointIdList iNeighbors;
if (m_args->search3d) iNeighbors = refView->build3dIndex().radius(point, m_args->m_radius);
else iNeighbors = refView->build2dIndex().radius(point, m_args->m_radius);
if (m_args->search3d) iNeighbors = refView->build3dIndex().radius(pointSrc, m_args->m_radius);
else iNeighbors = refView->build2dIndex().radius(pointSrc, m_args->m_radius);

if (iNeighbors.size() == 0)
return;

if (!m_args->search3d)
if (!m_args->search3d && (m_args->m_max2d_below>=0 || m_args->m_max2d_above>=0))
{
double Zref = point.getFieldAs<double>(Dimension::Id::Z);
if (m_args->m_max2d_below>=0 || m_args->m_max2d_above>=0)
double Zsrc = pointSrc.getFieldAs<double>(Dimension::Id::Z);

std::set<double> ZNeib;
for (PointId ptId : iNeighbors)
{
bool take (true);
for (PointId ptId : iNeighbors)
{
double Zpt = refView->point(ptId).getFieldAs<double>(Dimension::Id::Z);
if (m_args->m_max2d_below>=0 && (Zref-Zpt)>m_args->m_max2d_below) {take=false; break;}
if (m_args->m_max2d_above>=0 && (Zpt-Zref)>m_args->m_max2d_above) {take=false; break;}
}
if (!take) return;
double Zref = refView->point(ptId).getFieldAs<double>(Dimension::Id::Z);
if (m_args->m_max2d_above>=0 && Zref>Zsrc && (Zref-Zsrc)>m_args->m_max2d_above) continue;
if (m_args->m_max2d_below>=0 && Zsrc>Zref && (Zsrc-Zref)>m_args->m_max2d_below) continue;
ZNeib.insert(Zref);
alavenant marked this conversation as resolved.
Show resolved Hide resolved
}

if (ZNeib.size()==0) return;
}

m_args->m_ptsToUpdate.push_back(point.pointId());
m_args->m_ptsToUpdate.push_back(pointSrc.pointId());
}

bool RadiusAssignFilter::doOne(PointRef& point)
Expand Down
Binary file added test/data/mnx/input/bat.laz
Binary file not shown.
Binary file added test/data/mnx/input/corse.laz
Binary file not shown.
Binary file added test/data/mnx/input/pont.laz
Binary file not shown.
Binary file added test/data/mnx/reference/bat.laz
Binary file not shown.
Binary file added test/data/mnx/reference/corse.laz
Binary file not shown.
Binary file added test/data/mnx/reference/pont.laz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def test_parse_args():
"crop_1.laz",
# "crop_2.laz", ToDo : rebuild the reference for crop_2 which is false
"crop_3.laz",
"bat.laz",
"pont.laz",
"corse.laz",
],
)
def test_algo_mark_points_for_dm_with_reference(crop):
Expand Down
Loading