Merge pull request #7636 from marcjansen/named-exports-array
Named exports from the ol/array module
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/ResolutionConstraint
|
||||
*/
|
||||
import _ol_array_ from './array.js';
|
||||
import {linearFindNearest} from './array.js';
|
||||
import _ol_math_ from './math.js';
|
||||
var _ol_ResolutionConstraint_ = {};
|
||||
|
||||
@@ -20,8 +20,7 @@ _ol_ResolutionConstraint_.createSnapToResolutions = function(resolutions) {
|
||||
*/
|
||||
function(resolution, delta, direction) {
|
||||
if (resolution !== undefined) {
|
||||
var z =
|
||||
_ol_array_.linearFindNearest(resolutions, resolution, direction);
|
||||
var z = linearFindNearest(resolutions, resolution, direction);
|
||||
z = _ol_math_.clamp(z + delta, 0, resolutions.length - 1);
|
||||
var index = Math.floor(z);
|
||||
if (z != index && index < resolutions.length - 1) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import _ol_ResolutionConstraint_ from './ResolutionConstraint.js';
|
||||
import _ol_RotationConstraint_ from './RotationConstraint.js';
|
||||
import _ol_ViewHint_ from './ViewHint.js';
|
||||
import _ol_ViewProperty_ from './ViewProperty.js';
|
||||
import _ol_array_ from './array.js';
|
||||
import {linearFindNearest} from './array.js';
|
||||
import {assert} from './asserts.js';
|
||||
import _ol_coordinate_ from './coordinate.js';
|
||||
import {inAndOut} from './easing.js';
|
||||
@@ -833,7 +833,7 @@ _ol_View_.prototype.getZoomForResolution = function(resolution) {
|
||||
var offset = this.minZoom_ || 0;
|
||||
var max, zoomFactor;
|
||||
if (this.resolutions_) {
|
||||
var nearest = _ol_array_.linearFindNearest(this.resolutions_, resolution, 1);
|
||||
var nearest = linearFindNearest(this.resolutions_, resolution, 1);
|
||||
offset = nearest;
|
||||
max = this.resolutions_[nearest];
|
||||
if (nearest == this.resolutions_.length - 1) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/array
|
||||
*/
|
||||
var _ol_array_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,9 +12,9 @@ var _ol_array_ = {};
|
||||
* @param {Function=} opt_comparator Comparator function.
|
||||
* @return {number} The index of the item if found, -1 if not.
|
||||
*/
|
||||
_ol_array_.binarySearch = function(haystack, needle, opt_comparator) {
|
||||
export function binarySearch(haystack, needle, opt_comparator) {
|
||||
var mid, cmp;
|
||||
var comparator = opt_comparator || _ol_array_.numberSafeCompareFunction;
|
||||
var comparator = opt_comparator || numberSafeCompareFunction;
|
||||
var low = 0;
|
||||
var high = haystack.length;
|
||||
var found = false;
|
||||
@@ -37,7 +36,7 @@ _ol_array_.binarySearch = function(haystack, needle, opt_comparator) {
|
||||
|
||||
/* Key not found. */
|
||||
return found ? low : ~low;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,9 +46,9 @@ _ol_array_.binarySearch = function(haystack, needle, opt_comparator) {
|
||||
* @return {number} A negative number, zero, or a positive number as the first
|
||||
* argument is less than, equal to, or greater than the second.
|
||||
*/
|
||||
_ol_array_.numberSafeCompareFunction = function(a, b) {
|
||||
export function numberSafeCompareFunction(a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,9 +57,9 @@ _ol_array_.numberSafeCompareFunction = function(a, b) {
|
||||
* @param {*} obj The object for which to test.
|
||||
* @return {boolean} The object is in the array.
|
||||
*/
|
||||
_ol_array_.includes = function(arr, obj) {
|
||||
export function includes(arr, obj) {
|
||||
return arr.indexOf(obj) >= 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,7 +70,7 @@ _ol_array_.includes = function(arr, obj) {
|
||||
* smallest nearest.
|
||||
* @return {number} Index.
|
||||
*/
|
||||
_ol_array_.linearFindNearest = function(arr, target, direction) {
|
||||
export function linearFindNearest(arr, target, direction) {
|
||||
var n = arr.length;
|
||||
if (arr[0] <= target) {
|
||||
return 0;
|
||||
@@ -106,7 +105,7 @@ _ol_array_.linearFindNearest = function(arr, target, direction) {
|
||||
}
|
||||
return n - 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -114,7 +113,7 @@ _ol_array_.linearFindNearest = function(arr, target, direction) {
|
||||
* @param {number} begin Begin index.
|
||||
* @param {number} end End index.
|
||||
*/
|
||||
_ol_array_.reverseSubArray = function(arr, begin, end) {
|
||||
export function reverseSubArray(arr, begin, end) {
|
||||
while (begin < end) {
|
||||
var tmp = arr[begin];
|
||||
arr[begin] = arr[end];
|
||||
@@ -122,7 +121,7 @@ _ol_array_.reverseSubArray = function(arr, begin, end) {
|
||||
++begin;
|
||||
--end;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -131,14 +130,14 @@ _ol_array_.reverseSubArray = function(arr, begin, end) {
|
||||
* to add to arr.
|
||||
* @template VALUE
|
||||
*/
|
||||
_ol_array_.extend = function(arr, data) {
|
||||
export function extend(arr, data) {
|
||||
var i;
|
||||
var extension = Array.isArray(data) ? data : [data];
|
||||
var length = extension.length;
|
||||
for (i = 0; i < length; i++) {
|
||||
arr[arr.length] = extension[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -147,14 +146,14 @@ _ol_array_.extend = function(arr, data) {
|
||||
* @template VALUE
|
||||
* @return {boolean} If the element was removed.
|
||||
*/
|
||||
_ol_array_.remove = function(arr, obj) {
|
||||
export function remove(arr, obj) {
|
||||
var i = arr.indexOf(obj);
|
||||
var found = i > -1;
|
||||
if (found) {
|
||||
arr.splice(i, 1);
|
||||
}
|
||||
return found;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -163,7 +162,7 @@ _ol_array_.remove = function(arr, obj) {
|
||||
* @template VALUE
|
||||
* @return {VALUE} The element found.
|
||||
*/
|
||||
_ol_array_.find = function(arr, func) {
|
||||
export function find(arr, func) {
|
||||
var length = arr.length >>> 0;
|
||||
var value;
|
||||
|
||||
@@ -174,7 +173,7 @@ _ol_array_.find = function(arr, func) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -182,7 +181,7 @@ _ol_array_.find = function(arr, func) {
|
||||
* @param {Array|Uint8ClampedArray} arr2 The second array to compare.
|
||||
* @return {boolean} Whether the two arrays are equal.
|
||||
*/
|
||||
_ol_array_.equals = function(arr1, arr2) {
|
||||
export function equals(arr1, arr2) {
|
||||
var len1 = arr1.length;
|
||||
if (len1 !== arr2.length) {
|
||||
return false;
|
||||
@@ -193,14 +192,14 @@ _ol_array_.equals = function(arr1, arr2) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<*>} arr The array to sort (modifies original).
|
||||
* @param {Function} compareFnc Comparison function.
|
||||
*/
|
||||
_ol_array_.stableSort = function(arr, compareFnc) {
|
||||
export function stableSort(arr, compareFnc) {
|
||||
var length = arr.length;
|
||||
var tmp = Array(arr.length);
|
||||
var i;
|
||||
@@ -213,7 +212,7 @@ _ol_array_.stableSort = function(arr, compareFnc) {
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
arr[i] = tmp[i].value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -221,14 +220,14 @@ _ol_array_.stableSort = function(arr, compareFnc) {
|
||||
* @param {Function} func Comparison function.
|
||||
* @return {number} Return index.
|
||||
*/
|
||||
_ol_array_.findIndex = function(arr, func) {
|
||||
export function findIndex(arr, func) {
|
||||
var index;
|
||||
var found = !arr.every(function(el, idx) {
|
||||
index = idx;
|
||||
return !func(el, idx, arr);
|
||||
});
|
||||
return found ? index : -1;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -237,8 +236,8 @@ _ol_array_.findIndex = function(arr, func) {
|
||||
* @param {boolean=} opt_strict Strictly sorted (default false).
|
||||
* @return {boolean} Return index.
|
||||
*/
|
||||
_ol_array_.isSorted = function(arr, opt_func, opt_strict) {
|
||||
var compare = opt_func || _ol_array_.numberSafeCompareFunction;
|
||||
export function isSorted(arr, opt_func, opt_strict) {
|
||||
var compare = opt_func || numberSafeCompareFunction;
|
||||
return arr.every(function(currentVal, index) {
|
||||
if (index === 0) {
|
||||
return true;
|
||||
@@ -246,5 +245,4 @@ _ol_array_.isSorted = function(arr, opt_func, opt_strict) {
|
||||
var res = compare(arr[index - 1], currentVal);
|
||||
return !(res > 0 || opt_strict && res === 0);
|
||||
});
|
||||
};
|
||||
export default _ol_array_;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/control/Attribution
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {equals} from '../array.js';
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
import {removeChildren, replaceNode} from '../dom.js';
|
||||
@@ -208,7 +208,7 @@ Attribution.prototype.updateElement_ = function(frameState) {
|
||||
}
|
||||
|
||||
var attributions = this.getSourceAttributions_(frameState);
|
||||
if (_ol_array_.equals(attributions, this.renderedAttributions_)) {
|
||||
if (equals(attributions, this.renderedAttributions_)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/format/GML3
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {createOrUpdate} from '../extent.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
import GMLBase from '../format/GMLBase.js';
|
||||
@@ -249,7 +249,7 @@ GML3.prototype.readSurface_ = function(node, objectStack) {
|
||||
var ends = [flatCoordinates.length];
|
||||
var i, ii;
|
||||
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
|
||||
_ol_array_.extend(flatCoordinates, flatLinearRings[i]);
|
||||
extend(flatCoordinates, flatLinearRings[i]);
|
||||
ends.push(flatCoordinates.length);
|
||||
}
|
||||
polygon.setFlatCoordinates(
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect
|
||||
// envelopes/extents, only geometries!
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import _ol_Feature_ from '../Feature.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
import XMLFeature from '../format/XMLFeature.js';
|
||||
@@ -428,7 +428,7 @@ GMLBase.prototype.readPolygon = function(node, objectStack) {
|
||||
var ends = [flatCoordinates.length];
|
||||
var i, ii;
|
||||
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
|
||||
_ol_array_.extend(flatCoordinates, flatLinearRings[i]);
|
||||
extend(flatCoordinates, flatLinearRings[i]);
|
||||
ends.push(flatCoordinates.length);
|
||||
}
|
||||
polygon.setFlatCoordinates(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Feature_ from '../Feature.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {includes} from '../array.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
import XMLFeature from '../format/XMLFeature.js';
|
||||
import XSD from '../format/XSD.js';
|
||||
@@ -489,7 +489,7 @@ GPX.prototype.readFeature;
|
||||
* @inheritDoc
|
||||
*/
|
||||
GPX.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
if (!_ol_array_.includes(GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
if (!includes(GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return null;
|
||||
}
|
||||
var featureReader = GPX.FEATURE_READER_[node.localName];
|
||||
@@ -523,7 +523,7 @@ GPX.prototype.readFeatures;
|
||||
* @inheritDoc
|
||||
*/
|
||||
GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
if (!_ol_array_.includes(GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
if (!includes(GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return [];
|
||||
}
|
||||
if (node.localName == 'gpx') {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Feature_ from '../Feature.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend, includes} from '../array.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {asArray} from '../color.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
@@ -927,7 +927,7 @@ KML.readMultiGeometry_ = function(node, objectStack) {
|
||||
flatCoordinates = point.getFlatCoordinates();
|
||||
for (i = 1, ii = geometries.length; i < ii; ++i) {
|
||||
geometry = geometries[i];
|
||||
_ol_array_.extend(flatCoordinates, geometry.getFlatCoordinates());
|
||||
extend(flatCoordinates, geometry.getFlatCoordinates());
|
||||
}
|
||||
multiGeometry = new MultiPoint(null);
|
||||
multiGeometry.setFlatCoordinates(layout, flatCoordinates);
|
||||
@@ -993,7 +993,7 @@ KML.readPolygon_ = function(node, objectStack) {
|
||||
var ends = [flatCoordinates.length];
|
||||
var i, ii;
|
||||
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
|
||||
_ol_array_.extend(flatCoordinates, flatLinearRings[i]);
|
||||
extend(flatCoordinates, flatLinearRings[i]);
|
||||
ends.push(flatCoordinates.length);
|
||||
}
|
||||
polygon.setFlatCoordinates(
|
||||
@@ -1806,7 +1806,7 @@ KML.prototype.readFeature;
|
||||
* @inheritDoc
|
||||
*/
|
||||
KML.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
if (!_ol_array_.includes(KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
if (!includes(KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return null;
|
||||
}
|
||||
var feature = this.readPlacemark_(
|
||||
@@ -1837,7 +1837,7 @@ KML.prototype.readFeatures;
|
||||
* @inheritDoc
|
||||
*/
|
||||
KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
if (!_ol_array_.includes(KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
if (!includes(KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return [];
|
||||
}
|
||||
var features;
|
||||
@@ -1864,7 +1864,7 @@ KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
var fs = this.readFeaturesFromNode(n, opt_options);
|
||||
if (fs) {
|
||||
_ol_array_.extend(features, fs);
|
||||
extend(features, fs);
|
||||
}
|
||||
}
|
||||
return features;
|
||||
@@ -1920,14 +1920,14 @@ KML.prototype.readNameFromDocument = function(doc) {
|
||||
KML.prototype.readNameFromNode = function(node) {
|
||||
var n;
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
if (_ol_array_.includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
if (includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
n.localName == 'name') {
|
||||
return XSD.readString(n);
|
||||
}
|
||||
}
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
var localName = n.localName;
|
||||
if (_ol_array_.includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
if (includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
(localName == 'Document' ||
|
||||
localName == 'Folder' ||
|
||||
localName == 'Placemark' ||
|
||||
@@ -1952,14 +1952,14 @@ KML.prototype.readNameFromNode = function(node) {
|
||||
KML.prototype.readNetworkLinks = function(source) {
|
||||
var networkLinks = [];
|
||||
if (_ol_xml_.isDocument(source)) {
|
||||
_ol_array_.extend(networkLinks, this.readNetworkLinksFromDocument(
|
||||
extend(networkLinks, this.readNetworkLinksFromDocument(
|
||||
/** @type {Document} */ (source)));
|
||||
} else if (_ol_xml_.isNode(source)) {
|
||||
_ol_array_.extend(networkLinks, this.readNetworkLinksFromNode(
|
||||
extend(networkLinks, this.readNetworkLinksFromNode(
|
||||
/** @type {Node} */ (source)));
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = _ol_xml_.parse(source);
|
||||
_ol_array_.extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
||||
extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
||||
}
|
||||
return networkLinks;
|
||||
};
|
||||
@@ -1973,7 +1973,7 @@ KML.prototype.readNetworkLinksFromDocument = function(doc) {
|
||||
var n, networkLinks = [];
|
||||
for (n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
_ol_array_.extend(networkLinks, this.readNetworkLinksFromNode(n));
|
||||
extend(networkLinks, this.readNetworkLinksFromNode(n));
|
||||
}
|
||||
}
|
||||
return networkLinks;
|
||||
@@ -1987,7 +1987,7 @@ KML.prototype.readNetworkLinksFromDocument = function(doc) {
|
||||
KML.prototype.readNetworkLinksFromNode = function(node) {
|
||||
var n, networkLinks = [];
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
if (_ol_array_.includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
if (includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
n.localName == 'NetworkLink') {
|
||||
var obj = _ol_xml_.pushParseAndPop({}, KML.NETWORK_LINK_PARSERS_,
|
||||
n, []);
|
||||
@@ -1996,11 +1996,11 @@ KML.prototype.readNetworkLinksFromNode = function(node) {
|
||||
}
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
var localName = n.localName;
|
||||
if (_ol_array_.includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
if (includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
(localName == 'Document' ||
|
||||
localName == 'Folder' ||
|
||||
localName == 'kml')) {
|
||||
_ol_array_.extend(networkLinks, this.readNetworkLinksFromNode(n));
|
||||
extend(networkLinks, this.readNetworkLinksFromNode(n));
|
||||
}
|
||||
}
|
||||
return networkLinks;
|
||||
@@ -2017,14 +2017,14 @@ KML.prototype.readNetworkLinksFromNode = function(node) {
|
||||
KML.prototype.readRegion = function(source) {
|
||||
var regions = [];
|
||||
if (_ol_xml_.isDocument(source)) {
|
||||
_ol_array_.extend(regions, this.readRegionFromDocument(
|
||||
extend(regions, this.readRegionFromDocument(
|
||||
/** @type {Document} */ (source)));
|
||||
} else if (_ol_xml_.isNode(source)) {
|
||||
_ol_array_.extend(regions, this.readRegionFromNode(
|
||||
extend(regions, this.readRegionFromNode(
|
||||
/** @type {Node} */ (source)));
|
||||
} else if (typeof source === 'string') {
|
||||
var doc = _ol_xml_.parse(source);
|
||||
_ol_array_.extend(regions, this.readRegionFromDocument(doc));
|
||||
extend(regions, this.readRegionFromDocument(doc));
|
||||
}
|
||||
return regions;
|
||||
};
|
||||
@@ -2038,7 +2038,7 @@ KML.prototype.readRegionFromDocument = function(doc) {
|
||||
var n, regions = [];
|
||||
for (n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
_ol_array_.extend(regions, this.readRegionFromNode(n));
|
||||
extend(regions, this.readRegionFromNode(n));
|
||||
}
|
||||
}
|
||||
return regions;
|
||||
@@ -2053,7 +2053,7 @@ KML.prototype.readRegionFromDocument = function(doc) {
|
||||
KML.prototype.readRegionFromNode = function(node) {
|
||||
var n, regions = [];
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
if (_ol_array_.includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
if (includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
n.localName == 'Region') {
|
||||
var obj = _ol_xml_.pushParseAndPop({}, KML.REGION_PARSERS_,
|
||||
n, []);
|
||||
@@ -2062,11 +2062,11 @@ KML.prototype.readRegionFromNode = function(node) {
|
||||
}
|
||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
var localName = n.localName;
|
||||
if (_ol_array_.includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
if (includes(KML.NAMESPACE_URIS_, n.namespaceURI) &&
|
||||
(localName == 'Document' ||
|
||||
localName == 'Folder' ||
|
||||
localName == 'kml')) {
|
||||
_ol_array_.extend(regions, this.readRegionFromNode(n));
|
||||
extend(regions, this.readRegionFromNode(n));
|
||||
}
|
||||
}
|
||||
return regions;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
// FIXME add typedef for stack state objects
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import _ol_Feature_ from '../Feature.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
import XMLFeature from '../format/XMLFeature.js';
|
||||
@@ -180,7 +180,7 @@ OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
var flatCoordinates = [];
|
||||
for (var i = 0, ii = values.ndrefs.length; i < ii; i++) {
|
||||
var point = state.nodes[values.ndrefs[i]];
|
||||
_ol_array_.extend(flatCoordinates, point);
|
||||
extend(flatCoordinates, point);
|
||||
}
|
||||
var geometry;
|
||||
if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/format/WMSGetFeatureInfo
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend, includes} from '../array.js';
|
||||
import GML2 from '../format/GML2.js';
|
||||
import XMLFeature from '../format/XMLFeature.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
@@ -105,7 +105,7 @@ WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
|
||||
var toRemove = WMSGetFeatureInfo.layerIdentifier_;
|
||||
var layerName = layer.localName.replace(toRemove, '');
|
||||
|
||||
if (this.layers_ && !_ol_array_.includes(this.layers_, layerName)) {
|
||||
if (this.layers_ && !includes(this.layers_, layerName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
|
||||
var layerFeatures = _ol_xml_.pushParseAndPop(
|
||||
[], parsersNS, layer, objectStack, this.gmlFormat_);
|
||||
if (layerFeatures) {
|
||||
_ol_array_.extend(features, layerFeatures);
|
||||
extend(features, layerFeatures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/format/XMLFeature
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
import FormatType from '../format/FormatType.js';
|
||||
import _ol_xml_ from '../xml.js';
|
||||
@@ -114,7 +114,7 @@ XMLFeature.prototype.readFeaturesFromDocument = function(
|
||||
var n;
|
||||
for (n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
_ol_array_.extend(features, this.readFeaturesFromNode(n, opt_options));
|
||||
extend(features, this.readFeaturesFromNode(n, opt_options));
|
||||
}
|
||||
}
|
||||
return features;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/LineString
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -70,7 +70,7 @@ LineString.prototype.appendCoordinate = function(coordinate) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = coordinate.slice();
|
||||
} else {
|
||||
_ol_array_.extend(this.flatCoordinates, coordinate);
|
||||
extend(this.flatCoordinates, coordinate);
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/MultiLineString
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -63,8 +63,7 @@ MultiLineString.prototype.appendLineString = function(lineString) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = lineString.getFlatCoordinates().slice();
|
||||
} else {
|
||||
_ol_array_.extend(
|
||||
this.flatCoordinates, lineString.getFlatCoordinates().slice());
|
||||
extend(this.flatCoordinates, lineString.getFlatCoordinates().slice());
|
||||
}
|
||||
this.ends_.push(this.flatCoordinates.length);
|
||||
this.changed();
|
||||
@@ -213,7 +212,7 @@ MultiLineString.prototype.getFlatMidpoints = function() {
|
||||
var end = ends[i];
|
||||
var midpoint = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, offset, end, stride, 0.5);
|
||||
_ol_array_.extend(midpoints, midpoint);
|
||||
extend(midpoints, midpoint);
|
||||
offset = end;
|
||||
}
|
||||
return midpoints;
|
||||
@@ -303,7 +302,7 @@ MultiLineString.prototype.setLineStrings = function(lineStrings) {
|
||||
if (i === 0) {
|
||||
layout = lineString.getLayout();
|
||||
}
|
||||
_ol_array_.extend(flatCoordinates, lineString.getFlatCoordinates());
|
||||
extend(flatCoordinates, lineString.getFlatCoordinates());
|
||||
ends.push(flatCoordinates.length);
|
||||
}
|
||||
this.setFlatCoordinates(layout, flatCoordinates, ends);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/MultiPoint
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY, containsXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -39,7 +39,7 @@ MultiPoint.prototype.appendPoint = function(point) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = point.getFlatCoordinates().slice();
|
||||
} else {
|
||||
_ol_array_.extend(this.flatCoordinates, point.getFlatCoordinates());
|
||||
extend(this.flatCoordinates, point.getFlatCoordinates());
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/MultiPolygon
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -97,7 +97,7 @@ MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||
this.endss_.push();
|
||||
} else {
|
||||
var offset = this.flatCoordinates.length;
|
||||
_ol_array_.extend(this.flatCoordinates, polygon.getFlatCoordinates());
|
||||
extend(this.flatCoordinates, polygon.getFlatCoordinates());
|
||||
ends = polygon.getEnds().slice();
|
||||
var i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
@@ -414,7 +414,7 @@ MultiPolygon.prototype.setPolygons = function(polygons) {
|
||||
for (j = 0, jj = ends.length; j < jj; ++j) {
|
||||
ends[j] += offset;
|
||||
}
|
||||
_ol_array_.extend(flatCoordinates, polygon.getFlatCoordinates());
|
||||
extend(flatCoordinates, polygon.getFlatCoordinates());
|
||||
endss.push(ends);
|
||||
}
|
||||
this.setFlatCoordinates(layout, flatCoordinates, endss);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/Polygon
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY, getCenter} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -97,7 +97,7 @@ Polygon.prototype.appendLinearRing = function(linearRing) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = linearRing.getFlatCoordinates().slice();
|
||||
} else {
|
||||
_ol_array_.extend(this.flatCoordinates, linearRing.getFlatCoordinates());
|
||||
extend(this.flatCoordinates, linearRing.getFlatCoordinates());
|
||||
}
|
||||
this.ends_.push(this.flatCoordinates.length);
|
||||
this.changed();
|
||||
@@ -384,8 +384,7 @@ Polygon.circular = function(sphere, center, radius, opt_n) {
|
||||
var flatCoordinates = [];
|
||||
var i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
_ol_array_.extend(
|
||||
flatCoordinates, sphere.offset(center, radius, 2 * Math.PI * i / n));
|
||||
extend(flatCoordinates, sphere.offset(center, radius, 2 * Math.PI * i / n));
|
||||
}
|
||||
flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||
var polygon = new Polygon(null);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/interiorpoint
|
||||
*/
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import _ol_geom_flat_contains_ from '../flat/contains.js';
|
||||
var _ol_geom_flat_interiorpoint_ = {};
|
||||
|
||||
@@ -45,7 +45,7 @@ _ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
||||
// inside the linear ring.
|
||||
var pointX = NaN;
|
||||
var maxSegmentLength = -Infinity;
|
||||
intersections.sort(_ol_array_.numberSafeCompareFunction);
|
||||
intersections.sort(numberSafeCompareFunction);
|
||||
x1 = intersections[0];
|
||||
for (i = 1, ii = intersections.length; i < ii; ++i) {
|
||||
x2 = intersections[i];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/interpolate
|
||||
*/
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {binarySearch} from '../../array.js';
|
||||
import _ol_math_ from '../../math.js';
|
||||
var _ol_geom_flat_interpolate_ = {};
|
||||
|
||||
@@ -42,7 +42,7 @@ _ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, s
|
||||
y1 = y2;
|
||||
}
|
||||
var target = fraction * length;
|
||||
var index = _ol_array_.binarySearch(cumulativeLengths, target);
|
||||
var index = binarySearch(cumulativeLengths, target);
|
||||
if (index < 0) {
|
||||
var t = (target - cumulativeLengths[-index - 2]) /
|
||||
(cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);
|
||||
|
||||
@@ -7,7 +7,7 @@ import CollectionEventType from '../CollectionEventType.js';
|
||||
import _ol_Feature_ from '../Feature.js';
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {equals} from '../array.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
@@ -1181,7 +1181,7 @@ _ol_interaction_Modify_.prototype.updateSegmentIndices_ = function(
|
||||
this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) {
|
||||
if (segmentDataMatch.geometry === geometry &&
|
||||
(depth === undefined || segmentDataMatch.depth === undefined ||
|
||||
_ol_array_.equals(segmentDataMatch.depth, depth)) &&
|
||||
equals(segmentDataMatch.depth, depth)) &&
|
||||
segmentDataMatch.index > index) {
|
||||
segmentDataMatch.index += delta;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {getUid, inherits} from '../index.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend, includes} from '../array.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
@@ -113,7 +113,7 @@ var _ol_interaction_Select_ = function(opt_options) {
|
||||
} else {
|
||||
var layers = options.layers;
|
||||
layerFilter = function(layer) {
|
||||
return _ol_array_.includes(layers, layer);
|
||||
return includes(layers, layer);
|
||||
};
|
||||
}
|
||||
} else {
|
||||
@@ -259,12 +259,10 @@ _ol_interaction_Select_.handleEvent = function(mapBrowserEvent) {
|
||||
*/
|
||||
function(feature, layer) {
|
||||
if (this.filter_(feature, layer)) {
|
||||
if ((add || toggle) &&
|
||||
!_ol_array_.includes(features.getArray(), feature)) {
|
||||
if ((add || toggle) && !includes(features.getArray(), feature)) {
|
||||
selected.push(feature);
|
||||
this.addFeatureLayerAssociation_(feature, layer);
|
||||
} else if ((remove || toggle) &&
|
||||
_ol_array_.includes(features.getArray(), feature)) {
|
||||
} else if ((remove || toggle) && includes(features.getArray(), feature)) {
|
||||
deselected.push(feature);
|
||||
this.removeFeatureLayerAssociation_(feature);
|
||||
}
|
||||
@@ -328,10 +326,8 @@ _ol_interaction_Select_.prototype.setMap = function(map) {
|
||||
*/
|
||||
_ol_interaction_Select_.getDefaultStyleFunction = function() {
|
||||
var styles = _ol_style_Style_.createDefaultEditing();
|
||||
_ol_array_.extend(styles[GeometryType.POLYGON],
|
||||
styles[GeometryType.LINE_STRING]);
|
||||
_ol_array_.extend(styles[GeometryType.GEOMETRY_COLLECTION],
|
||||
styles[GeometryType.LINE_STRING]);
|
||||
extend(styles[GeometryType.POLYGON], styles[GeometryType.LINE_STRING]);
|
||||
extend(styles[GeometryType.GEOMETRY_COLLECTION], styles[GeometryType.LINE_STRING]);
|
||||
|
||||
return function(feature, resolution) {
|
||||
if (!feature.getGeometry()) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import _ol_Object_ from '../Object.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import {TRUE} from '../functions.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {includes} from '../array.js';
|
||||
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
|
||||
import _ol_interaction_Property_ from '../interaction/Property.js';
|
||||
import _ol_interaction_TranslateEventType_ from '../interaction/TranslateEventType.js';
|
||||
@@ -54,7 +54,7 @@ var _ol_interaction_Translate_ = function(opt_options) {
|
||||
} else {
|
||||
var layers = options.layers;
|
||||
layerFilter = function(layer) {
|
||||
return _ol_array_.includes(layers, layer);
|
||||
return includes(layers, layer);
|
||||
};
|
||||
}
|
||||
} else {
|
||||
@@ -194,8 +194,7 @@ _ol_interaction_Translate_.handleMoveEvent_ = function(event) {
|
||||
_ol_interaction_Translate_.prototype.featuresAtPixel_ = function(pixel, map) {
|
||||
return map.forEachFeatureAtPixel(pixel,
|
||||
function(feature) {
|
||||
if (!this.features_ ||
|
||||
_ol_array_.includes(this.features_.getArray(), feature)) {
|
||||
if (!this.features_ || includes(this.features_.getArray(), feature)) {
|
||||
return feature;
|
||||
}
|
||||
}.bind(this), {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {remove} from '../array.js';
|
||||
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
|
||||
import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
|
||||
|
||||
@@ -443,7 +443,7 @@ _ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) {
|
||||
|
||||
setTimeout(function() {
|
||||
// remove touch after timeout
|
||||
_ol_array_.remove(lts, lt);
|
||||
remove(lts, lt);
|
||||
}, _ol_pointer_TouchSource_.DEDUP_TIMEOUT);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/Feature
|
||||
*/
|
||||
import {nullFunction} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import _ol_geom_flat_center_ from '../geom/flat/center.js';
|
||||
@@ -171,7 +171,7 @@ _ol_render_Feature_.prototype.getFlatMidpoints = function() {
|
||||
var end = ends[i];
|
||||
var midpoint = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, offset, end, 2, 0.5);
|
||||
_ol_array_.extend(this.flatMidpoints_, midpoint);
|
||||
extend(this.flatMidpoints_, midpoint);
|
||||
offset = end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// FIXME add offset and end to ol.geom.flat.transform.transform2D?
|
||||
|
||||
import {inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {equals} from '../../array.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
@@ -755,8 +755,7 @@ _ol_render_canvas_Immediate_.prototype.setContextStrokeState_ = function(strokeS
|
||||
contextStrokeState.lineCap = context.lineCap = strokeState.lineCap;
|
||||
}
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
if (!_ol_array_.equals(
|
||||
contextStrokeState.lineDash, strokeState.lineDash)) {
|
||||
if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {
|
||||
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
|
||||
}
|
||||
if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/canvas/Replay
|
||||
*/
|
||||
import {getUid, inherits, nullFunction} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {equals, reverseSubArray} from '../../array.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {buffer, clone, coordinateRelationship, createEmpty, createOrUpdate,
|
||||
createOrUpdateEmpty, extend, extendCoordinate, intersects} from '../../extent.js';
|
||||
@@ -542,7 +542,7 @@ _ol_render_canvas_Replay_.prototype.replay_ = function(
|
||||
instructions, featureCallback, opt_hitExtent) {
|
||||
/** @type {Array.<number>} */
|
||||
var pixelCoordinates;
|
||||
if (this.pixelCoordinates_ && _ol_array_.equals(transform, this.renderedTransform_)) {
|
||||
if (this.pixelCoordinates_ && equals(transform, this.renderedTransform_)) {
|
||||
pixelCoordinates = this.pixelCoordinates_;
|
||||
} else {
|
||||
if (!this.pixelCoordinates_) {
|
||||
@@ -898,7 +898,7 @@ _ol_render_canvas_Replay_.prototype.reverseHitDetectionInstructions = function()
|
||||
begin = i;
|
||||
} else if (type == _ol_render_canvas_Instruction_.BEGIN_GEOMETRY) {
|
||||
instruction[2] = i;
|
||||
_ol_array_.reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||
reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||
begin = -1;
|
||||
}
|
||||
}
|
||||
@@ -1013,7 +1013,7 @@ _ol_render_canvas_Replay_.prototype.updateStrokeStyle = function(state, applyStr
|
||||
var miterLimit = state.miterLimit;
|
||||
if (state.currentStrokeStyle != strokeStyle ||
|
||||
state.currentLineCap != lineCap ||
|
||||
(lineDash != state.currentLineDash && !_ol_array_.equals(state.currentLineDash, lineDash)) ||
|
||||
(lineDash != state.currentLineDash && !equals(state.currentLineDash, lineDash)) ||
|
||||
state.currentLineDashOffset != lineDashOffset ||
|
||||
state.currentLineJoin != lineJoin ||
|
||||
state.currentLineWidth != lineWidth ||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/canvas/ReplayGroup
|
||||
*/
|
||||
import {inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
@@ -192,7 +192,7 @@ _ol_render_canvas_ReplayGroup_.getCircleArray_ = function(radius) {
|
||||
* @param {number} rotation Rotation.
|
||||
*/
|
||||
_ol_render_canvas_ReplayGroup_.replayDeclutter = function(declutterReplays, context, rotation) {
|
||||
var zs = Object.keys(declutterReplays).map(Number).sort(_ol_array_.numberSafeCompareFunction);
|
||||
var zs = Object.keys(declutterReplays).map(Number).sort(numberSafeCompareFunction);
|
||||
var skippedFeatureUids = {};
|
||||
for (var z = 0, zz = zs.length; z < zz; ++z) {
|
||||
var replayData = declutterReplays[zs[z].toString()];
|
||||
@@ -423,7 +423,7 @@ _ol_render_canvas_ReplayGroup_.prototype.replay = function(context,
|
||||
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
// setup clipping so that the parts of over-simplified geometries are not
|
||||
// visible outside the current extent when panning
|
||||
@@ -479,7 +479,7 @@ _ol_render_canvas_ReplayGroup_.prototype.replayHitDetection_ = function(
|
||||
featureCallback, opt_hitExtent, opt_declutterReplays) {
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
var i, j, replays, replay, result;
|
||||
for (i = zs.length - 1; i >= 0; --i) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/webgl/CircleReplay
|
||||
*/
|
||||
import {getUid, inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {equals} from '../../array.js';
|
||||
import {asArray} from '../../color.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
@@ -409,8 +409,8 @@ _ol_render_webgl_CircleReplay_.prototype.setFillStrokeStyle = function(fillStyle
|
||||
} else {
|
||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
||||
}
|
||||
if (!this.state_.strokeColor || !_ol_array_.equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
!this.state_.fillColor || !_ol_array_.equals(this.state_.fillColor, fillStyleColor) ||
|
||||
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
!this.state_.fillColor || !equals(this.state_.fillColor, fillStyleColor) ||
|
||||
this.state_.lineWidth !== strokeStyleWidth) {
|
||||
this.state_.changed = true;
|
||||
this.state_.fillColor = fillStyleColor;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/webgl/LineStringReplay
|
||||
*/
|
||||
import {getUid, inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {equals} from '../../array.js';
|
||||
import {asArray} from '../../color.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
||||
@@ -107,7 +107,7 @@ _ol_render_webgl_LineStringReplay_.prototype.drawCoordinates_ = function(flatCoo
|
||||
//First vertex.
|
||||
if (i === offset) {
|
||||
p2 = [flatCoordinates[i + stride], flatCoordinates[i + stride + 1]];
|
||||
if (end - offset === stride * 2 && _ol_array_.equals(p1, p2)) {
|
||||
if (end - offset === stride * 2 && equals(p1, p2)) {
|
||||
break;
|
||||
}
|
||||
if (closed) {
|
||||
@@ -291,7 +291,7 @@ _ol_render_webgl_LineStringReplay_.prototype.isValid_ = function(flatCoordinates
|
||||
} else if (range === stride * 2) {
|
||||
var firstP = [flatCoordinates[offset], flatCoordinates[offset + 1]];
|
||||
var lastP = [flatCoordinates[offset + stride], flatCoordinates[offset + stride + 1]];
|
||||
return !_ol_array_.equals(firstP, lastP);
|
||||
return !equals(firstP, lastP);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -659,7 +659,7 @@ _ol_render_webgl_LineStringReplay_.prototype.setFillStrokeStyle = function(fillS
|
||||
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||
strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : _ol_render_webgl_.defaultMiterLimit;
|
||||
if (!this.state_.strokeColor || !_ol_array_.equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) {
|
||||
this.state_.changed = true;
|
||||
this.state_.strokeColor = strokeStyleColor;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/webgl/PolygonReplay
|
||||
*/
|
||||
import {getUid, inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {equals} from '../../array.js';
|
||||
import {asArray} from '../../color.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
@@ -1054,7 +1054,7 @@ _ol_render_webgl_PolygonReplay_.prototype.setFillStrokeStyle = function(fillStyl
|
||||
} else {
|
||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
||||
}
|
||||
if (!this.state_.fillColor || !_ol_array_.equals(fillStyleColor, this.state_.fillColor)) {
|
||||
if (!this.state_.fillColor || !equals(fillStyleColor, this.state_.fillColor)) {
|
||||
this.state_.fillColor = fillStyleColor;
|
||||
this.state_.changed = true;
|
||||
this.styles_.push(fillStyleColor);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/webgl/ReplayGroup
|
||||
*/
|
||||
import {inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import {buffer, createOrUpdateFromCoordinate} from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
@@ -149,7 +149,7 @@ _ol_render_webgl_ReplayGroup_.prototype.replay = function(context,
|
||||
opacity, skippedFeaturesHash) {
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
|
||||
var i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {inherits} from '../../index.js';
|
||||
import _ol_ImageCanvas_ from '../../ImageCanvas.js';
|
||||
import LayerType from '../../LayerType.js';
|
||||
import _ol_ViewHint_ from '../../ViewHint.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {equals} from '../../array.js';
|
||||
import {getHeight, getIntersection, getWidth, isEmpty} from '../../extent.js';
|
||||
import _ol_layer_VectorRenderType_ from '../../layer/VectorRenderType.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
@@ -149,7 +149,7 @@ _ol_renderer_canvas_ImageLayer_.prototype.prepareFrame = function(frameState, la
|
||||
var skippedFeatures = Object.keys(imageFrameState.skippedFeatureUids).sort();
|
||||
if (vectorRenderer.prepareFrame(imageFrameState, layerState) &&
|
||||
(vectorRenderer.replayGroupChanged ||
|
||||
!_ol_array_.equals(skippedFeatures, this.skippedFeatures_))) {
|
||||
!equals(skippedFeatures, this.skippedFeatures_))) {
|
||||
context.canvas.width = imageFrameState.size[0] * pixelRatio;
|
||||
context.canvas.height = imageFrameState.size[1] * pixelRatio;
|
||||
vectorRenderer.composeFrame(imageFrameState, layerState, context);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
import {inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {stableSort} from '../../array.js';
|
||||
import {CLASS_UNSELECTABLE} from '../../css.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import _ol_layer_Layer_ from '../../layer/Layer.js';
|
||||
@@ -166,7 +166,7 @@ _ol_renderer_canvas_Map_.prototype.renderFrame = function(frameState) {
|
||||
this.dispatchComposeEvent_(RenderEventType.PRECOMPOSE, frameState);
|
||||
|
||||
var layerStatesArray = frameState.layerStatesArray;
|
||||
_ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
|
||||
if (rotation) {
|
||||
context.save();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import {inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {stableSort} from '../../array.js';
|
||||
import {CLASS_UNSELECTABLE} from '../../css.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import _ol_events_ from '../../events.js';
|
||||
@@ -443,7 +443,7 @@ _ol_renderer_webgl_Map_.prototype.renderFrame = function(frameState) {
|
||||
/** @type {Array.<ol.LayerState>} */
|
||||
var layerStatesToDraw = [];
|
||||
var layerStatesArray = frameState.layerStatesArray;
|
||||
_ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
|
||||
var viewResolution = frameState.viewState.resolution;
|
||||
var i, ii, layerRenderer, layerState;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {inherits} from '../../index.js';
|
||||
import LayerType from '../../LayerType.js';
|
||||
import TileRange from '../../TileRange.js';
|
||||
import _ol_TileState_ from '../../TileState.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import {createEmpty, intersects} from '../../extent.js';
|
||||
import _ol_math_ from '../../math.js';
|
||||
import RendererType from '../Type.js';
|
||||
@@ -297,7 +297,7 @@ _ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, laye
|
||||
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(tilesToDrawByZ).map(Number);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
var u_tileOffset = new Float32Array(4);
|
||||
var i, ii, tileKey, tilesToDraw;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
|
||||
import {inherits} from '../index.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {linearFindNearest} from '../array.js';
|
||||
import Event from '../events/Event.js';
|
||||
import {equals} from '../extent.js';
|
||||
import {equivalent} from '../proj.js';
|
||||
@@ -72,7 +72,7 @@ _ol_source_Image_.prototype.getResolutions = function() {
|
||||
*/
|
||||
_ol_source_Image_.prototype.findNearestResolution = function(resolution) {
|
||||
if (this.resolutions_) {
|
||||
var idx = _ol_array_.linearFindNearest(this.resolutions_, resolution, 0);
|
||||
var idx = linearFindNearest(this.resolutions_, resolution, 0);
|
||||
resolution = this.resolutions_[idx];
|
||||
}
|
||||
return resolution;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {getUid, inherits, nullFunction} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import ObjectEventType from '../ObjectEventType.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {extend} from '../array.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
@@ -507,8 +507,7 @@ _ol_source_Vector_.prototype.getFeatures = function() {
|
||||
} else if (this.featuresRtree_) {
|
||||
features = this.featuresRtree_.getAll();
|
||||
if (!_ol_obj_.isEmpty(this.nullGeometryFeatures_)) {
|
||||
_ol_array_.extend(
|
||||
features, _ol_obj_.getValues(this.nullGeometryFeatures_));
|
||||
extend(features, _ol_obj_.getValues(this.nullGeometryFeatures_));
|
||||
}
|
||||
}
|
||||
return /** @type {Array.<ol.Feature>} */ (features);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import {expandUrl, createFromTileUrlFunctions, nullTileUrlFunction} from '../tileurlfunction.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {find, findIndex, includes} from '../array.js';
|
||||
import {containsExtent} from '../extent.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
import {get as getProjection, equivalent, transformExtent} from '../proj.js';
|
||||
@@ -311,7 +311,7 @@ _ol_source_WMTS_.prototype.updateDimensions = function(dimensions) {
|
||||
*/
|
||||
_ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var layers = wmtsCap['Contents']['Layer'];
|
||||
var l = _ol_array_.find(layers, function(elt, index, array) {
|
||||
var l = find(layers, function(elt, index, array) {
|
||||
return elt['Identifier'] == config['layer'];
|
||||
});
|
||||
if (l === null) {
|
||||
@@ -321,9 +321,9 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var idx, matrixSet, matrixLimits;
|
||||
if (l['TileMatrixSetLink'].length > 1) {
|
||||
if ('projection' in config) {
|
||||
idx = _ol_array_.findIndex(l['TileMatrixSetLink'],
|
||||
idx = findIndex(l['TileMatrixSetLink'],
|
||||
function(elt, index, array) {
|
||||
var tileMatrixSet = _ol_array_.find(tileMatrixSets, function(el) {
|
||||
var tileMatrixSet = find(tileMatrixSets, function(el) {
|
||||
return el['Identifier'] == elt['TileMatrixSet'];
|
||||
});
|
||||
var supportedCRS = tileMatrixSet['SupportedCRS'];
|
||||
@@ -337,7 +337,7 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
idx = _ol_array_.findIndex(l['TileMatrixSetLink'],
|
||||
idx = findIndex(l['TileMatrixSetLink'],
|
||||
function(elt, index, array) {
|
||||
return elt['TileMatrixSet'] == config['matrixSet'];
|
||||
});
|
||||
@@ -357,7 +357,7 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
if ('format' in config) {
|
||||
format = config['format'];
|
||||
}
|
||||
idx = _ol_array_.findIndex(l['Style'], function(elt, index, array) {
|
||||
idx = findIndex(l['Style'], function(elt, index, array) {
|
||||
if ('style' in config) {
|
||||
return elt['Title'] == config['style'];
|
||||
} else {
|
||||
@@ -382,7 +382,7 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
}
|
||||
|
||||
var matrixSets = wmtsCap['Contents']['TileMatrixSet'];
|
||||
var matrixSetObj = _ol_array_.find(matrixSets, function(elt, index, array) {
|
||||
var matrixSetObj = find(matrixSets, function(elt, index, array) {
|
||||
return elt['Identifier'] == matrixSet;
|
||||
});
|
||||
|
||||
@@ -432,7 +432,7 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
|
||||
for (var i = 0, ii = gets.length; i < ii; ++i) {
|
||||
if (gets[i]['Constraint']) {
|
||||
var constraint = _ol_array_.find(gets[i]['Constraint'], function(element) {
|
||||
var constraint = find(gets[i]['Constraint'], function(element) {
|
||||
return element['name'] == 'GetEncoding';
|
||||
});
|
||||
var encodings = constraint['AllowedValues']['Value'];
|
||||
@@ -442,7 +442,7 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
requestEncoding = encodings[0];
|
||||
}
|
||||
if (requestEncoding === _ol_source_WMTSRequestEncoding_.KVP) {
|
||||
if (_ol_array_.includes(encodings, _ol_source_WMTSRequestEncoding_.KVP)) {
|
||||
if (includes(encodings, _ol_source_WMTSRequestEncoding_.KVP)) {
|
||||
urls.push(/** @type {string} */ (gets[i]['href']));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {DEFAULT_TILE_SIZE} from './common.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import TileRange from '../TileRange.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {isSorted, linearFindNearest} from '../array.js';
|
||||
import {createOrUpdate, getTopLeft} from '../extent.js';
|
||||
import _ol_math_ from '../math.js';
|
||||
import _ol_size_ from '../size.js';
|
||||
@@ -33,7 +33,7 @@ var _ol_tilegrid_TileGrid_ = function(options) {
|
||||
* @type {!Array.<number>}
|
||||
*/
|
||||
this.resolutions_ = options.resolutions;
|
||||
assert(_ol_array_.isSorted(this.resolutions_, function(a, b) {
|
||||
assert(isSorted(this.resolutions_, function(a, b) {
|
||||
return b - a;
|
||||
}, true), 17); // `resolutions` must be sorted in descending order
|
||||
|
||||
@@ -528,8 +528,7 @@ _ol_tilegrid_TileGrid_.prototype.getFullTileRange = function(z) {
|
||||
*/
|
||||
_ol_tilegrid_TileGrid_.prototype.getZForResolution = function(
|
||||
resolution, opt_direction) {
|
||||
var z = _ol_array_.linearFindNearest(this.resolutions_, resolution,
|
||||
opt_direction || 0);
|
||||
var z = linearFindNearest(this.resolutions_, resolution, opt_direction || 0);
|
||||
return _ol_math_.clamp(z, this.minZoom, this.maxZoom);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/tilegrid/WMTS
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {find} from '../array.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
import _ol_tilegrid_TileGrid_ from '../tilegrid/TileGrid.js';
|
||||
|
||||
@@ -110,7 +110,7 @@ _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet = function(matrixSet, opt_ext
|
||||
// use of matrixLimits to filter TileMatrices from GetCapabilities
|
||||
// TileMatrixSet from unavailable matrix levels.
|
||||
if (matrixLimits.length > 0) {
|
||||
matrixAvailable = _ol_array_.find(matrixLimits,
|
||||
matrixAvailable = find(matrixLimits,
|
||||
function(elt_ml, index_ml, array_ml) {
|
||||
return elt[identifierPropName] == elt_ml[matrixIdsPropName];
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {WEBGL_EXTENSIONS, getUid, inherits} from '../index.js';
|
||||
import _ol_Disposable_ from '../Disposable.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {includes} from '../array.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
import _ol_webgl_ from '../webgl.js';
|
||||
@@ -77,8 +77,7 @@ var _ol_webgl_Context_ = function(canvas, gl) {
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasOESElementIndexUint = _ol_array_.includes(
|
||||
WEBGL_EXTENSIONS, 'OES_element_index_uint');
|
||||
this.hasOESElementIndexUint = includes(WEBGL_EXTENSIONS, 'OES_element_index_uint');
|
||||
|
||||
// use the OES_element_index_uint extension if available
|
||||
if (this.hasOESElementIndexUint) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/xml
|
||||
*/
|
||||
import _ol_array_ from './array.js';
|
||||
import {extend} from './array.js';
|
||||
var _ol_xml_ = {};
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ _ol_xml_.makeArrayExtender = function(valueReader, opt_this) {
|
||||
if (value !== undefined) {
|
||||
var array = /** @type {Array.<*>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
_ol_array_.extend(array, value);
|
||||
extend(array, value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
import _ol_array_ from '../../../src/ol/array.js';
|
||||
import {
|
||||
binarySearch,
|
||||
equals,
|
||||
extend,
|
||||
find,
|
||||
findIndex,
|
||||
isSorted,
|
||||
linearFindNearest,
|
||||
numberSafeCompareFunction,
|
||||
remove,
|
||||
reverseSubArray,
|
||||
stableSort
|
||||
} from '../../../src/ol/array.js';
|
||||
|
||||
|
||||
describe('ol.array', function() {
|
||||
@@ -20,43 +32,43 @@ describe('ol.array', function() {
|
||||
];
|
||||
|
||||
it('should find \'1000\' at index 0', function() {
|
||||
expect(_ol_array_.binarySearch(a, '1000')).to.be(0);
|
||||
expect(binarySearch(a, '1000')).to.be(0);
|
||||
});
|
||||
it('should find \'zzz\' at index ' + (a.length - 1), function() {
|
||||
expect(_ol_array_.binarySearch(a, 'zzz')).to.be(a.length - 1);
|
||||
expect(binarySearch(a, 'zzz')).to.be(a.length - 1);
|
||||
});
|
||||
it('should find \'C\' at index 10', function() {
|
||||
expect(_ol_array_.binarySearch(a, 'C')).to.be(10);
|
||||
expect(binarySearch(a, 'C')).to.be(10);
|
||||
});
|
||||
it('should find \'B\' at index 7 || 8 || 9', function() {
|
||||
var pos = _ol_array_.binarySearch(a, 'B');
|
||||
var pos = binarySearch(a, 'B');
|
||||
expect(pos == 7 || pos == 8 || pos == 9).to.be.ok();
|
||||
});
|
||||
it('should not find \'100\'', function() {
|
||||
var pos = _ol_array_.binarySearch(a, '100');
|
||||
var pos = binarySearch(a, '100');
|
||||
expect(pos < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 0 for \'100\'', function() {
|
||||
var pos = _ol_array_.binarySearch(a, '100');
|
||||
var pos = binarySearch(a, '100');
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find \'zzz0\'', function() {
|
||||
var pos = _ol_array_.binarySearch(a, 'zzz0');
|
||||
var pos = binarySearch(a, 'zzz0');
|
||||
expect(pos < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of ' + (a.length) + ' for \'zzz0\'',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(a, 'zzz0');
|
||||
var pos = binarySearch(a, 'zzz0');
|
||||
expect(insertionPoint(pos)).to.be(a.length);
|
||||
}
|
||||
);
|
||||
it('should not find \'BA\'', function() {
|
||||
var pos = _ol_array_.binarySearch(a, 'zzz0');
|
||||
var pos = binarySearch(a, 'zzz0');
|
||||
expect(pos < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 10 for \'BA\'',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(a, 'BA');
|
||||
var pos = binarySearch(a, 'BA');
|
||||
expect(insertionPoint(pos)).to.be(10);
|
||||
}
|
||||
);
|
||||
@@ -65,11 +77,11 @@ describe('ol.array', function() {
|
||||
describe('0 length array with default comparison', function() {
|
||||
var b = [];
|
||||
it('should not find \'a\'', function() {
|
||||
expect(_ol_array_.binarySearch(b, 'a') < 0).to.be.ok();
|
||||
expect(binarySearch(b, 'a') < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 0 for \'a\'',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(b, 'a');
|
||||
var pos = binarySearch(b, 'a');
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
}
|
||||
);
|
||||
@@ -79,23 +91,23 @@ describe('ol.array', function() {
|
||||
function() {
|
||||
var c = ['only item'];
|
||||
it('should find \'only item\' at index 0', function() {
|
||||
expect(_ol_array_.binarySearch(c, 'only item')).to.be(0);
|
||||
expect(binarySearch(c, 'only item')).to.be(0);
|
||||
});
|
||||
it('should not find \'a\'', function() {
|
||||
expect(_ol_array_.binarySearch(c, 'a') < 0).to.be.ok();
|
||||
expect(binarySearch(c, 'a') < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 0 for \'a\'',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(c, 'a');
|
||||
var pos = binarySearch(c, 'a');
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
}
|
||||
);
|
||||
it('should not find \'z\'', function() {
|
||||
expect(_ol_array_.binarySearch(c, 'z') < 0).to.be.ok();
|
||||
expect(binarySearch(c, 'z') < 0).to.be.ok();
|
||||
});
|
||||
it('should have an insertion point of 1 for \'z\'',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(c, 'z');
|
||||
var pos = binarySearch(c, 'z');
|
||||
expect(insertionPoint(pos)).to.be(1);
|
||||
}
|
||||
);
|
||||
@@ -108,42 +120,42 @@ describe('ol.array', function() {
|
||||
0.31255, 5, 142.88888708, 334, 342, 453, 54254
|
||||
];
|
||||
it('should find -897123.9 at index 0', function() {
|
||||
expect(_ol_array_.binarySearch(d, -897123.9)).to.be(0);
|
||||
expect(binarySearch(d, -897123.9)).to.be(0);
|
||||
});
|
||||
it('should find 54254 at index ' + (d.length - 1), function() {
|
||||
expect(_ol_array_.binarySearch(d, 54254)).to.be(d.length - 1);
|
||||
expect(binarySearch(d, 54254)).to.be(d.length - 1);
|
||||
});
|
||||
it('should find -3 at index 5', function() {
|
||||
expect(_ol_array_.binarySearch(d, -3)).to.be(5);
|
||||
expect(binarySearch(d, -3)).to.be(5);
|
||||
});
|
||||
it('should find 0 at index 6 || 7 || 8', function() {
|
||||
var pos = _ol_array_.binarySearch(d, 0);
|
||||
var pos = binarySearch(d, 0);
|
||||
expect(pos == 6 || pos == 7 || pos == 8).to.be(true);
|
||||
});
|
||||
it('should not find -900000', function() {
|
||||
var pos = _ol_array_.binarySearch(d, -900000);
|
||||
var pos = binarySearch(d, -900000);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for -900000', function() {
|
||||
var pos = _ol_array_.binarySearch(d, -900000);
|
||||
var pos = binarySearch(d, -900000);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find 54255', function() {
|
||||
var pos = _ol_array_.binarySearch(d, 54255);
|
||||
var pos = binarySearch(d, 54255);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of ' + (d.length) + ' for 54255',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(d, 54255);
|
||||
var pos = binarySearch(d, 54255);
|
||||
expect(insertionPoint(pos)).to.be(d.length);
|
||||
}
|
||||
);
|
||||
it('should not find 1.1', function() {
|
||||
var pos = _ol_array_.binarySearch(d, 1.1);
|
||||
var pos = binarySearch(d, 1.1);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 10 for 1.1', function() {
|
||||
var pos = _ol_array_.binarySearch(d, 1.1);
|
||||
var pos = binarySearch(d, 1.1);
|
||||
expect(insertionPoint(pos)).to.be(10);
|
||||
});
|
||||
});
|
||||
@@ -155,45 +167,45 @@ describe('ol.array', function() {
|
||||
-9, -324, -1321.3124, -321434.58758, -897123.9
|
||||
];
|
||||
it('should find 54254 at index 0', function() {
|
||||
var pos = _ol_array_.binarySearch(e, 54254, revNumCompare);
|
||||
var pos = binarySearch(e, 54254, revNumCompare);
|
||||
expect(pos).to.be(0);
|
||||
});
|
||||
it('should find -897123.9 at index ' + (e.length - 1), function() {
|
||||
var pos = _ol_array_.binarySearch(e, -897123.9, revNumCompare);
|
||||
var pos = binarySearch(e, -897123.9, revNumCompare);
|
||||
expect(pos).to.be(e.length - 1);
|
||||
});
|
||||
it('should find -3 at index 10', function() {
|
||||
var pos = _ol_array_.binarySearch(e, -3, revNumCompare);
|
||||
var pos = binarySearch(e, -3, revNumCompare);
|
||||
expect(pos).to.be(10);
|
||||
});
|
||||
it('should find 0 at index 7 || 8 || 9', function() {
|
||||
var pos = _ol_array_.binarySearch(e, 0, revNumCompare);
|
||||
var pos = binarySearch(e, 0, revNumCompare);
|
||||
expect(pos == 7 || pos == 8 || pos == 9).to.be(true);
|
||||
});
|
||||
it('should not find 54254.1', function() {
|
||||
var pos = _ol_array_.binarySearch(e, 54254.1, revNumCompare);
|
||||
var pos = binarySearch(e, 54254.1, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 54254.1', function() {
|
||||
var pos = _ol_array_.binarySearch(e, 54254.1, revNumCompare);
|
||||
var pos = binarySearch(e, 54254.1, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find -897124', function() {
|
||||
var pos = _ol_array_.binarySearch(e, -897124, revNumCompare);
|
||||
var pos = binarySearch(e, -897124, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of ' + e.length + ' for -897124',
|
||||
function() {
|
||||
var pos = _ol_array_.binarySearch(e, -897124, revNumCompare);
|
||||
var pos = binarySearch(e, -897124, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(e.length);
|
||||
}
|
||||
);
|
||||
it('should not find 1.1', function() {
|
||||
var pos = _ol_array_.binarySearch(e, 1.1, revNumCompare);
|
||||
var pos = binarySearch(e, 1.1, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 1.1', function() {
|
||||
var pos = _ol_array_.binarySearch(e, 1.1, revNumCompare);
|
||||
var pos = binarySearch(e, 1.1, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(6);
|
||||
});
|
||||
}
|
||||
@@ -202,11 +214,11 @@ describe('ol.array', function() {
|
||||
describe('0 length array with custom comparison function', function() {
|
||||
var f = [];
|
||||
it('should not find 0', function() {
|
||||
var pos = _ol_array_.binarySearch(f, 0, revNumCompare);
|
||||
var pos = binarySearch(f, 0, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 0', function() {
|
||||
var pos = _ol_array_.binarySearch(f, 0, revNumCompare);
|
||||
var pos = binarySearch(f, 0, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
});
|
||||
@@ -215,23 +227,23 @@ describe('ol.array', function() {
|
||||
function() {
|
||||
var g = [1];
|
||||
it('should find 1 at index 0', function() {
|
||||
var pos = _ol_array_.binarySearch(g, 1, revNumCompare);
|
||||
var pos = binarySearch(g, 1, revNumCompare);
|
||||
expect(pos).to.be(0);
|
||||
});
|
||||
it('should not find 2', function() {
|
||||
var pos = _ol_array_.binarySearch(g, 2, revNumCompare);
|
||||
var pos = binarySearch(g, 2, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 0 for 2', function() {
|
||||
var pos = _ol_array_.binarySearch(g, 2, revNumCompare);
|
||||
var pos = binarySearch(g, 2, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(0);
|
||||
});
|
||||
it('should not find 0', function() {
|
||||
var pos = _ol_array_.binarySearch(g, 0, revNumCompare);
|
||||
var pos = binarySearch(g, 0, revNumCompare);
|
||||
expect(pos < 0).to.be(true);
|
||||
});
|
||||
it('should have an insertion point of 1 for 0', function() {
|
||||
var pos = _ol_array_.binarySearch(g, 0, revNumCompare);
|
||||
var pos = binarySearch(g, 0, revNumCompare);
|
||||
expect(insertionPoint(pos)).to.be(1);
|
||||
});
|
||||
}
|
||||
@@ -239,10 +251,10 @@ describe('ol.array', function() {
|
||||
|
||||
describe('finding first index when multiple candidates', function() {
|
||||
it('should find the index of the first 0', function() {
|
||||
expect(_ol_array_.binarySearch([0, 0, 1], 0)).to.be(0);
|
||||
expect(binarySearch([0, 0, 1], 0)).to.be(0);
|
||||
});
|
||||
it('should find the index of the first 1', function() {
|
||||
expect(_ol_array_.binarySearch([0, 1, 1], 1)).to.be(1);
|
||||
expect(binarySearch([0, 1, 1], 1)).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -275,8 +287,8 @@ describe('ol.array', function() {
|
||||
};
|
||||
|
||||
// Now actually call and test the method twice
|
||||
_ol_array_.binarySearch(a, 48);
|
||||
_ol_array_.binarySearch(a, 13, function(a, b) {
|
||||
binarySearch(a, 48);
|
||||
binarySearch(a, 13, function(a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
});
|
||||
|
||||
@@ -298,61 +310,61 @@ describe('ol.array', function() {
|
||||
var arr = [1, 2, 2, 2, 3, 5, 9];
|
||||
|
||||
it('should return the index of where the item would go plus one, negated, if the item is not found', function() {
|
||||
expect(_ol_array_.binarySearch(arr, 4)).to.equal(-6);
|
||||
expect(binarySearch(arr, 4)).to.equal(-6);
|
||||
});
|
||||
it('should work even on empty arrays', function() {
|
||||
expect(_ol_array_.binarySearch([], 42)).to.equal(-1);
|
||||
expect(binarySearch([], 42)).to.equal(-1);
|
||||
});
|
||||
it('should work even on arrays of doubles', function() {
|
||||
expect(_ol_array_.binarySearch([0.0, 0.1, 0.2, 0.3, 0.4], 0.25)).to.equal(-4);
|
||||
expect(binarySearch([0.0, 0.1, 0.2, 0.3, 0.4], 0.25)).to.equal(-4);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('equals', function() {
|
||||
it('returns true for [] == []', function() {
|
||||
expect(_ol_array_.equals([], [])).to.be(true);
|
||||
expect(equals([], [])).to.be(true);
|
||||
});
|
||||
it('returns true for [1] == [1]', function() {
|
||||
expect(_ol_array_.equals([1], [1])).to.be(true);
|
||||
expect(equals([1], [1])).to.be(true);
|
||||
});
|
||||
it('returns true for [\'1\'] == [\'1\']', function() {
|
||||
expect(_ol_array_.equals(['1'], ['1'])).to.be(true);
|
||||
expect(equals(['1'], ['1'])).to.be(true);
|
||||
});
|
||||
it('returns false for [1] == [\'1\']', function() {
|
||||
expect(_ol_array_.equals([1], ['1'])).to.be(false);
|
||||
expect(equals([1], ['1'])).to.be(false);
|
||||
});
|
||||
it('returns true for [null] == [null]', function() {
|
||||
expect(_ol_array_.equals([null], [null])).to.be(true);
|
||||
expect(equals([null], [null])).to.be(true);
|
||||
});
|
||||
it('returns false for [null] == [undefined]', function() {
|
||||
expect(_ol_array_.equals([null], [undefined])).to.be(false);
|
||||
expect(equals([null], [undefined])).to.be(false);
|
||||
});
|
||||
it('returns true for [1, 2] == [1, 2]', function() {
|
||||
expect(_ol_array_.equals([1, 2], [1, 2])).to.be(true);
|
||||
expect(equals([1, 2], [1, 2])).to.be(true);
|
||||
});
|
||||
it('returns false for [1, 2] == [2, 1]', function() {
|
||||
expect(_ol_array_.equals([1, 2], [2, 1])).to.be(false);
|
||||
expect(equals([1, 2], [2, 1])).to.be(false);
|
||||
});
|
||||
it('returns false for [1, 2] == [1]', function() {
|
||||
expect(_ol_array_.equals([1, 2], [1])).to.be(false);
|
||||
expect(equals([1, 2], [1])).to.be(false);
|
||||
});
|
||||
it('returns false for [1] == [1, 2]', function() {
|
||||
expect(_ol_array_.equals([1], [1, 2])).to.be(false);
|
||||
expect(equals([1], [1, 2])).to.be(false);
|
||||
});
|
||||
it('returns false for [{}] == [{}]', function() {
|
||||
expect(_ol_array_.equals([{}], [{}])).to.be(false);
|
||||
expect(equals([{}], [{}])).to.be(false);
|
||||
});
|
||||
});
|
||||
describe('extend', function() {
|
||||
it('extends an array in place with an array', function() {
|
||||
var a = [0, 1];
|
||||
_ol_array_.extend(a, [2, 3]);
|
||||
extend(a, [2, 3]);
|
||||
expect(a).to.eql([0, 1, 2, 3]);
|
||||
});
|
||||
it('extends an array in place with a number', function() {
|
||||
var a = [0, 1];
|
||||
_ol_array_.extend(a, 2);
|
||||
extend(a, 2);
|
||||
expect(a).to.eql([0, 1, 2]);
|
||||
});
|
||||
it('extends an array in place with a big array', function() {
|
||||
@@ -362,7 +374,7 @@ describe('ol.array', function() {
|
||||
while (i--) {
|
||||
bigArray[i] = i;
|
||||
}
|
||||
_ol_array_.extend(a, bigArray);
|
||||
extend(a, bigArray);
|
||||
expect(a).to.eql(bigArray);
|
||||
});
|
||||
});
|
||||
@@ -370,7 +382,7 @@ describe('ol.array', function() {
|
||||
describe('find', function() {
|
||||
it('finds numbers in an array', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
var b = find(a, function(val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val > 1;
|
||||
@@ -380,7 +392,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('returns null when an item in an array is not found', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
var b = find(a, function(val, index, a2) {
|
||||
return val > 100;
|
||||
});
|
||||
expect(b).to.be(null);
|
||||
@@ -388,7 +400,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('finds items in an array-like', function() {
|
||||
var a = 'abCD';
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
var b = find(a, function(val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val >= 'A' && val <= 'Z';
|
||||
@@ -398,7 +410,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('returns null when nothing in an array-like is found', function() {
|
||||
var a = 'abcd';
|
||||
var b = _ol_array_.find(a, function(val, index, a2) {
|
||||
var b = find(a, function(val, index, a2) {
|
||||
return val >= 'A' && val <= 'Z';
|
||||
});
|
||||
expect(b).to.be(null);
|
||||
@@ -408,7 +420,7 @@ describe('ol.array', function() {
|
||||
describe('findIndex', function() {
|
||||
it('finds index of numbers in an array', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = _ol_array_.findIndex(a, function(val, index, a2) {
|
||||
var b = findIndex(a, function(val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val > 1;
|
||||
@@ -418,7 +430,7 @@ describe('ol.array', function() {
|
||||
|
||||
it('returns -1 when an item in an array is not found', function() {
|
||||
var a = [0, 1, 2, 3];
|
||||
var b = _ol_array_.findIndex(a, function(val, index, a2) {
|
||||
var b = findIndex(a, function(val, index, a2) {
|
||||
return val > 100;
|
||||
});
|
||||
expect(b).to.be(-1);
|
||||
@@ -427,23 +439,23 @@ describe('ol.array', function() {
|
||||
|
||||
describe('isSorted', function() {
|
||||
it('works with just an array as argument', function() {
|
||||
expect(_ol_array_.isSorted([1, 2, 3])).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 2])).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 1])).to.be(false);
|
||||
expect(isSorted([1, 2, 3])).to.be(true);
|
||||
expect(isSorted([1, 2, 2])).to.be(true);
|
||||
expect(isSorted([1, 2, 1])).to.be(false);
|
||||
});
|
||||
|
||||
it('works with strict comparison without compare function', function() {
|
||||
expect(_ol_array_.isSorted([1, 2, 3], null, true)).to.be(true);
|
||||
expect(_ol_array_.isSorted([1, 2, 2], null, true)).to.be(false);
|
||||
expect(_ol_array_.isSorted([1, 2, 1], null, true)).to.be(false);
|
||||
expect(isSorted([1, 2, 3], null, true)).to.be(true);
|
||||
expect(isSorted([1, 2, 2], null, true)).to.be(false);
|
||||
expect(isSorted([1, 2, 1], null, true)).to.be(false);
|
||||
});
|
||||
|
||||
it('works with a compare function', function() {
|
||||
function compare(a, b) {
|
||||
return b - a;
|
||||
}
|
||||
expect(_ol_array_.isSorted([1, 2, 3], compare)).to.be(false);
|
||||
expect(_ol_array_.isSorted([3, 2, 2], compare)).to.be(true);
|
||||
expect(isSorted([1, 2, 3], compare)).to.be(false);
|
||||
expect(isSorted([3, 2, 2], compare)).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -451,49 +463,49 @@ describe('ol.array', function() {
|
||||
it('returns expected value', function() {
|
||||
var arr = [1000, 500, 100];
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 10000, 0)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 10000, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 10000, -1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 10000, 0)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 10000, 1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 10000, -1)).to.eql(0);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 1000, 0)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 1000, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 1000, -1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 1000, 0)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 1000, 1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 1000, -1)).to.eql(0);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 900, 0)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 900, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 900, -1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 900, 0)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 900, 1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 900, -1)).to.eql(1);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 750, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 750, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 750, -1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 750, 0)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 750, 1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 750, -1)).to.eql(1);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 550, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 550, 1)).to.eql(0);
|
||||
expect(_ol_array_.linearFindNearest(arr, 550, -1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 550, 0)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 550, 1)).to.eql(0);
|
||||
expect(linearFindNearest(arr, 550, -1)).to.eql(1);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 500, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 500, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 500, -1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 500, 0)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 500, 1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 500, -1)).to.eql(1);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 450, 0)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 450, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 450, -1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 450, 0)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 450, 1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 450, -1)).to.eql(2);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 300, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 300, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 300, -1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 300, 0)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 300, 1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 300, -1)).to.eql(2);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 200, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 200, 1)).to.eql(1);
|
||||
expect(_ol_array_.linearFindNearest(arr, 200, -1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 200, 0)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 200, 1)).to.eql(1);
|
||||
expect(linearFindNearest(arr, 200, -1)).to.eql(2);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 100, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 100, 1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 100, -1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 100, 0)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 100, 1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 100, -1)).to.eql(2);
|
||||
|
||||
expect(_ol_array_.linearFindNearest(arr, 50, 0)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 50, 1)).to.eql(2);
|
||||
expect(_ol_array_.linearFindNearest(arr, 50, -1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 50, 0)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 50, 1)).to.eql(2);
|
||||
expect(linearFindNearest(arr, 50, -1)).to.eql(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -501,7 +513,7 @@ describe('ol.array', function() {
|
||||
it('sorts as expected', function() {
|
||||
var arr = [40, 200, 3000];
|
||||
// default sort would yield [200, 3000, 40]
|
||||
arr.sort(_ol_array_.numberSafeCompareFunction);
|
||||
arr.sort(numberSafeCompareFunction);
|
||||
expect(arr).to.eql(arr);
|
||||
});
|
||||
});
|
||||
@@ -509,9 +521,9 @@ describe('ol.array', function() {
|
||||
describe('remove', function() {
|
||||
it('removes elements from an array', function() {
|
||||
var a = ['a', 'b', 'c', 'd'];
|
||||
_ol_array_.remove(a, 'c');
|
||||
remove(a, 'c');
|
||||
expect(a).to.eql(['a', 'b', 'd']);
|
||||
_ol_array_.remove(a, 'x');
|
||||
remove(a, 'x');
|
||||
expect(a).to.eql(['a', 'b', 'd']);
|
||||
});
|
||||
});
|
||||
@@ -522,19 +534,19 @@ describe('ol.array', function() {
|
||||
var expected = [1, 2, 3, 4, 5, 6];
|
||||
|
||||
arr = [1, 5, 4, 3, 2, 6];
|
||||
_ol_array_.reverseSubArray(arr, 1, 4);
|
||||
reverseSubArray(arr, 1, 4);
|
||||
expect(arr).to.eql(expected);
|
||||
|
||||
arr = [3, 2, 1, 4, 5, 6];
|
||||
_ol_array_.reverseSubArray(arr, 0, 2);
|
||||
reverseSubArray(arr, 0, 2);
|
||||
expect(arr).to.eql(expected);
|
||||
|
||||
arr = [1, 2, 3, 6, 5, 4];
|
||||
_ol_array_.reverseSubArray(arr, 3, 5);
|
||||
reverseSubArray(arr, 3, 5);
|
||||
expect(arr).to.eql(expected);
|
||||
|
||||
arr = [6, 5, 4, 3, 2, 1];
|
||||
_ol_array_.reverseSubArray(arr, 0, 5);
|
||||
reverseSubArray(arr, 0, 5);
|
||||
expect(arr).to.eql(expected);
|
||||
});
|
||||
});
|
||||
@@ -552,7 +564,7 @@ describe('ol.array', function() {
|
||||
function comparisonFn(obj1, obj2) {
|
||||
return obj1.key - obj2.key;
|
||||
}
|
||||
_ol_array_.stableSort(arr, comparisonFn);
|
||||
stableSort(arr, comparisonFn);
|
||||
var sortedValues = [];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
sortedValues.push(arr[i].val);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_array_ from '../../../../src/ol/array.js';
|
||||
import {find} from '../../../../src/ol/array.js';
|
||||
import GeoJSON from '../../../../src/ol/format/GeoJSON.js';
|
||||
import KML from '../../../../src/ol/format/KML.js';
|
||||
import GeometryCollection from '../../../../src/ol/geom/GeometryCollection.js';
|
||||
@@ -3188,7 +3188,7 @@ describe('ol.format.KML', function() {
|
||||
});
|
||||
|
||||
it('creates a Point and a MultiPolygon for Alaska', function() {
|
||||
var alaska = _ol_array_.find(features, function(feature) {
|
||||
var alaska = find(features, function(feature) {
|
||||
return feature.get('name') === 'Alaska';
|
||||
});
|
||||
expect(alaska).to.be.an(_ol_Feature_);
|
||||
|
||||
@@ -2,7 +2,7 @@ import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_array_ from '../../../../src/ol/array.js';
|
||||
import {equals} from '../../../../src/ol/array.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import Circle from '../../../../src/ol/geom/Circle.js';
|
||||
@@ -431,7 +431,7 @@ describe('ol.interaction.Draw', function() {
|
||||
source: source,
|
||||
type: 'LineString',
|
||||
finishCondition: function(event) {
|
||||
if (_ol_array_.equals(event.coordinate, [30, -20])) {
|
||||
if (equals(event.coordinate, [30, -20])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {getUid} from '../../../../src/ol/index.js';
|
||||
import _ol_array_ from '../../../../src/ol/array.js';
|
||||
import {stableSort} from '../../../../src/ol/array.js';
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import * as _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_layer_Group_ from '../../../../src/ol/layer/Group.js';
|
||||
@@ -452,7 +452,7 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||
var initialArray = layerStatesArray.slice();
|
||||
_ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
expect(layerStatesArray[0]).to.eql(initialArray[0]);
|
||||
expect(layerStatesArray[1]).to.eql(initialArray[1]);
|
||||
|
||||
@@ -480,7 +480,7 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||
var initialArray = layerStatesArray.slice();
|
||||
_ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex);
|
||||
expect(layerStatesArray[0]).to.eql(initialArray[3]);
|
||||
expect(layerStatesArray[1]).to.eql(initialArray[0]);
|
||||
expect(layerStatesArray[2]).to.eql(initialArray[2]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_array_ from '../../../src/ol/array.js';
|
||||
import {equals} from '../../../src/ol/array.js';
|
||||
import _ol_has_ from '../../../src/ol/has.js';
|
||||
import _ol_render_ from '../../../src/ol/render.js';
|
||||
import _ol_render_canvas_Immediate_ from '../../../src/ol/render/canvas/Immediate.js';
|
||||
@@ -29,7 +29,7 @@ describe('ol.render', function() {
|
||||
expect(canvas.style.height).to.be(size[1] + 'px');
|
||||
var transform = _ol_transform_.scale(_ol_transform_.create(),
|
||||
pixelRatio, pixelRatio);
|
||||
expect(_ol_array_.equals(render.transform_, transform)).to.be.ok();
|
||||
expect(equals(render.transform_, transform)).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_array_ from '../src/ol/array.js';
|
||||
import {equals} from '../src/ol/array.js';
|
||||
import _ol_has_ from '../src/ol/has.js';
|
||||
// avoid importing anything that results in an instanceof check
|
||||
// since these extensions are global, instanceof checks fail with modules
|
||||
@@ -317,7 +317,7 @@ import _ol_has_ from '../src/ol/has.js';
|
||||
*/
|
||||
expect.Assertion.prototype.arreql = function(obj) {
|
||||
this.assert(
|
||||
_ol_array_.equals(this.obj, obj),
|
||||
equals(this.obj, obj),
|
||||
function() {
|
||||
return 'expected ' + expect.stringify(this.obj) +
|
||||
' to sort of equal ' + expect.stringify(obj);
|
||||
|
||||
Reference in New Issue
Block a user