mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Make getNearObject always return the closest point to make the clusters do stupid things less often
This commit is contained in:
+8
-5
@@ -74,7 +74,9 @@ L.DistanceGrid.prototype = {
|
||||
getNearObject: function (point) {
|
||||
var x = this._getCoord(point.x),
|
||||
y = this._getCoord(point.y),
|
||||
i, j, k, row, cell, len, obj;
|
||||
i, j, k, row, cell, len, obj, dist,
|
||||
closestDistSq = this._sqCellSize,
|
||||
closest = null;
|
||||
|
||||
for (i = y - 1; i <= y + 1; i++) {
|
||||
row = this._grid[i];
|
||||
@@ -86,16 +88,17 @@ L.DistanceGrid.prototype = {
|
||||
|
||||
for (k = 0, len = cell.length; k < len; k++) {
|
||||
obj = cell[k];
|
||||
if (this._sqDist(obj._dGridPoint, point) < this._sqCellSize) {
|
||||
return obj;
|
||||
dist = this._sqDist(obj._dGridPoint, point);
|
||||
if (dist < closestDistSq) {
|
||||
closestDistSq = dist;
|
||||
closest = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return closest;
|
||||
},
|
||||
|
||||
_getCoord: function (x) {
|
||||
|
||||
Reference in New Issue
Block a user