Skip to content

Commit

Permalink
Update kdbush external module
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2019
1 parent 3dadc22 commit a6c563c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions external/kdbush/include/kdbush.hpp
Expand Up @@ -70,19 +70,19 @@ class KDBush {
const TNumber minY,
const TNumber maxX,
const TNumber maxY,
const TVisitor &visitor) {
const TVisitor &visitor) const {
range(minX, minY, maxX, maxY, visitor, 0, static_cast<TIndex>(points.size() - 1), 0);
}

template <typename TVisitor>
void within(const TNumber qx, const TNumber qy, const TNumber r, const TVisitor &visitor) {
void within(const TNumber qx, const TNumber qy, const TNumber r, const TVisitor &visitor) const {
within(qx, qy, r, visitor, 0, static_cast<TIndex>(points.size() - 1), 0);
}

protected:
//std::vector<TIndex> ids;
std::vector<TContainer> points;
std::uint8_t nodeSize;
const std::uint8_t nodeSize;

template <typename TVisitor>
void range(const TNumber minX,
Expand All @@ -92,7 +92,7 @@ class KDBush {
const TVisitor &visitor,
const TIndex left,
const TIndex right,
const std::uint8_t axis) {
const std::uint8_t axis) const {
if ( points.empty() )
return;

Expand Down Expand Up @@ -125,7 +125,7 @@ class KDBush {
const TVisitor &visitor,
const TIndex left,
const TIndex right,
const std::uint8_t axis) {
const std::uint8_t axis) const {

if ( points.empty() )
return;
Expand Down Expand Up @@ -171,8 +171,8 @@ class KDBush {

while (right > left) {
if (right - left > 600) {
const double n = right - left + 1;
const double m = k - left + 1;
const double n = static_cast<double>(right - left + 1);
const double m = static_cast<double>(k - left + 1);
const double z = std::log(n);
const double s = 0.5 * std::exp(2 * z / 3);
const double r =
Expand Down Expand Up @@ -209,7 +209,7 @@ class KDBush {
std::iter_swap(points.begin() + static_cast<std::int32_t>(i), points.begin() + static_cast<std::int32_t>(j));
}

TNumber sqDist(const TNumber ax, const TNumber ay, const TNumber bx, const TNumber by) {
TNumber sqDist(const TNumber ax, const TNumber ay, const TNumber bx, const TNumber by) const {
auto dx = ax - bx;
auto dy = ay - by;
return dx * dx + dy * dy;
Expand Down

0 comments on commit a6c563c

Please sign in to comment.