Skip to content

Commit

Permalink
Making the KDIndex::neighbors const
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-chaulet committed Apr 12, 2019
1 parent e201f4e commit 4d7b849
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pdal/KDIndex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,25 @@ class PDAL_DLL KD2Index : public KDIndex<2>
throw pdal_error("KD2Index: point view missing 'Y' dimension.");
}

PointId neighbor(double x, double y)
PointId neighbor(double x, double y) const
{
std::vector<PointId> ids = neighbors(x, y, 1);
return (ids.size() ? ids[0] : 0);
}

PointId neighbor(PointId idx)
PointId neighbor(PointId idx) const
{
std::vector<PointId> ids = neighbors(idx, 1);
return (ids.size() ? ids[0] : 0);
}

PointId neighbor(PointRef &point)
PointId neighbor(PointRef &point) const
{
std::vector<PointId> ids = neighbors(point, 1);
return (ids.size() ? ids[0] : 0);
}

std::vector<PointId> neighbors(double x, double y, point_count_t k)
std::vector<PointId> neighbors(double x, double y, point_count_t k) const
{
k = (std::min)(m_buf.size(), k);
std::vector<PointId> output(k);
Expand All @@ -135,15 +135,15 @@ class PDAL_DLL KD2Index : public KDIndex<2>
return output;
}

std::vector<PointId> neighbors(PointId idx, point_count_t k)
std::vector<PointId> neighbors(PointId idx, point_count_t k) const
{
double x = m_buf.getFieldAs<double>(Dimension::Id::X, idx);
double y = m_buf.getFieldAs<double>(Dimension::Id::Y, idx);

return neighbors(x, y, k);
}

std::vector<PointId> neighbors(PointRef &point, point_count_t k)
std::vector<PointId> neighbors(PointRef &point, point_count_t k) const
{
double x = point.getFieldAs<double>(Dimension::Id::X);
double y = point.getFieldAs<double>(Dimension::Id::Y);
Expand Down Expand Up @@ -226,26 +226,26 @@ class PDAL_DLL KD3Index : public KDIndex<3>
throw pdal_error("KD3Index: point view missing 'Z' dimension.");
}

PointId neighbor(double x, double y, double z)
PointId neighbor(double x, double y, double z) const
{
std::vector<PointId> ids = neighbors(x, y, z, 1);
return (ids.size() ? ids[0] : 0);
}

PointId neighbor(PointId idx)
PointId neighbor(PointId idx) const
{
std::vector<PointId> ids = neighbors(idx, 1);
return (ids.size() ? ids[0] : 0);
}

PointId neighbor(PointRef &point)
PointId neighbor(PointRef &point) const
{
std::vector<PointId> ids = neighbors(point, 1);
return (ids.size() ? ids[0] : 0);
}

std::vector<PointId> neighbors(double x, double y, double z,
point_count_t k)
point_count_t k) const
{
k = (std::min)(m_buf.size(), k);
std::vector<PointId> output(k);
Expand All @@ -262,7 +262,7 @@ class PDAL_DLL KD3Index : public KDIndex<3>
return output;
}

std::vector<PointId> neighbors(PointId idx, point_count_t k)
std::vector<PointId> neighbors(PointId idx, point_count_t k) const
{
double x = m_buf.getFieldAs<double>(Dimension::Id::X, idx);
double y = m_buf.getFieldAs<double>(Dimension::Id::Y, idx);
Expand All @@ -271,7 +271,7 @@ class PDAL_DLL KD3Index : public KDIndex<3>
return neighbors(x, y, z, k);
}

std::vector<PointId> neighbors(PointRef &point, point_count_t k)
std::vector<PointId> neighbors(PointRef &point, point_count_t k) const
{
double x = point.getFieldAs<double>(Dimension::Id::X);
double y = point.getFieldAs<double>(Dimension::Id::Y);
Expand Down

0 comments on commit 4d7b849

Please sign in to comment.