diff --git a/src/ol/array.js b/src/ol/array.js index be51a83c2c..11fb9ab03e 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -38,38 +38,6 @@ ol.array.binarySearch = function(haystack, needle, opt_comparator) { return found ? low : ~low; }; -/** - * @param {Array.} arr Array. - * @param {number} target Target. - * @return {number} Index. - */ -ol.array.binaryFindNearest = function(arr, target) { - var index = ol.array.binarySearch(arr, target, - /** - * @param {number} a A. - * @param {number} b B. - * @return {number} b minus a. - */ - function(a, b) { - return b - a; - }); - if (index >= 0) { - return index; - } else if (index == -1) { - return 0; - } else if (index == -arr.length - 1) { - return arr.length - 1; - } else { - var left = -index - 2; - var right = -index - 1; - if (arr[left] - target < target - arr[right]) { - return left; - } else { - return right; - } - } -}; - /** * Compare function for array sort that is safe for numbers. diff --git a/test/spec/ol/array.test.js b/test/spec/ol/array.test.js index 8bb4f5e624..2090489545 100644 --- a/test/spec/ol/array.test.js +++ b/test/spec/ol/array.test.js @@ -307,28 +307,6 @@ describe('ol.array', function() { }); }); - describe('binaryFindNearest', function() { - it('returns expected value', function() { - var arr = [1000, 500, 100]; - - expect(ol.array.binaryFindNearest(arr, 10000)).to.eql(0); - expect(ol.array.binaryFindNearest(arr, 1000)).to.eql(0); - expect(ol.array.binaryFindNearest(arr, 900)).to.eql(0); - - expect(ol.array.binaryFindNearest(arr, 750)).to.eql(1); - - expect(ol.array.binaryFindNearest(arr, 550)).to.eql(1); - expect(ol.array.binaryFindNearest(arr, 500)).to.eql(1); - expect(ol.array.binaryFindNearest(arr, 450)).to.eql(1); - - expect(ol.array.binaryFindNearest(arr, 300)).to.eql(2); - - expect(ol.array.binaryFindNearest(arr, 200)).to.eql(2); - expect(ol.array.binaryFindNearest(arr, 100)).to.eql(2); - expect(ol.array.binaryFindNearest(arr, 50)).to.eql(2); - }); - }); - describe('equals', function() { it('returns true for [] == []', function() { expect(ol.array.equals([], [])).to.be(true);