Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
alavenant committed May 29, 2024
1 parent 8ff93f0 commit 213c7b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/filter_radius_assign/RadiusAssignFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void RadiusAssignFilter::doOneNoDomain(PointRef &point)
for (PointId ptId : iNeighbors)
{
double Zpt = refView->point(ptId).getFieldAs<double>(Dimension::Id::Z);
if (m_args->m_max2d_below>0 && Zpt>Zref && (Zpt-Zref)<=m_args->m_max2d_below) {take=true; break;}
if (m_args->m_max2d_above>0 && Zpt<Zref && (Zref-Zpt)<=m_args->m_max2d_above) {take=true; break;}
if (m_args->m_max2d_below>0 && Zpt>=Zref && (Zpt-Zref)<=m_args->m_max2d_below) {take=true; break;}
if (m_args->m_max2d_above>0 && Zpt<=Zref && (Zref-Zpt)<=m_args->m_max2d_above) {take=true; break;}
}
if (!take) return;
}
Expand Down
17 changes: 8 additions & 9 deletions test/test_radius_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ def build_random_points_around_one_point(test_function):
nb_points = randint(20, 50)
nb_points_take = 0
for i in range(nb_points):
pti_x = pt_ini[0] + rand.uniform(-1.5, 1.5)
pti_y = pt_ini[1] + rand.uniform(-1.5, 1.5)

# pdal write takes 2 numbers precision (scale_z=0.01 and offset_z=0 by default)
pti_z = round(pt_ini[2] + rand.uniform(-1.5, 1.5), 2)
# round at 1 to avoid precision numeric pb
pti_x = round(pt_ini[0] + rand.uniform(-1.5, 1.5), 1)
pti_y = round(pt_ini[1] + rand.uniform(-1.5, 1.5), 1)
pti_z = round(pt_ini[2] + rand.uniform(-1.5, 1.5), 1)
pt_i = (pti_x, pti_y, pti_z, 2)

arrays_pti = np.array([pt_i], dtype=dtype)
Expand All @@ -105,7 +104,7 @@ def test_radius_assign_3d():

def func_test(pt_ini, pt):
distance_i = distance3d(pt_ini, pt)
if distance_i <= distance_radius:
if distance_i < distance_radius:
return 1
return 0

Expand All @@ -120,7 +119,7 @@ def test_radius_assign_2d():

def func_test(pt_ini, pt):
distance_i = distance2d(pt_ini, pt)
if distance_i <= distance_radius:
if distance_i < distance_radius:
return 1
return 0

Expand All @@ -136,8 +135,8 @@ def test_radius_assign_2d_cylinder():

def func_test(pt_ini, pt):
distance_i = distance2d(pt_ini, pt)
if distance_i <= distance_radius:
if abs(pt_ini[2] - pt[2]) < distance_cylinder:
if distance_i < distance_radius:
if abs(pt_ini[2] - pt[2]) <= distance_cylinder:
return 1
return 0

Expand Down

0 comments on commit 213c7b1

Please sign in to comment.