diff --git a/CHANGELOG.md b/CHANGELOG.md index 2718898..1e36472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.5.2.0 +* Update to [Openlayers 7.5.2](https://github.com/openlayers/openlayers/releases/tag/v7.5.2) +* Expose all formats from ol.formats + ## 7.3.0.0 * Update to [Openlayers 7.3.0](https://github.com/openlayers/openlayers/releases/tag/v7.3.0) diff --git a/dist/ol-debug.js b/dist/ol-debug.js index 8e274d9..66fb936 100644 --- a/dist/ol-debug.js +++ b/dist/ol-debug.js @@ -294,6 +294,17 @@ var ol = (function () { return a > b ? 1 : a < b ? -1 : 0; } + /** + * Compare function sorting arrays in descending order. Safe to use for numeric values. + * @param {*} a The first object to be compared. + * @param {*} b The second object to be compared. + * @return {number} A negative number, zero, or a positive number as the first + * argument is greater than, equal to, or less than the second. + */ + function descending(a, b) { + return a < b ? 1 : a > b ? -1 : 0; + } + /** * {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution} can use a function * of this type to determine which nearest resolution to use. @@ -318,40 +329,58 @@ var ol = (function () { * @return {number} Index. */ function linearFindNearest(arr, target, direction) { - const n = arr.length; if (arr[0] <= target) { return 0; - } else if (target <= arr[n - 1]) { + } + + const n = arr.length; + if (target <= arr[n - 1]) { return n - 1; } - let i; + + if (typeof direction === 'function') { + for (let i = 1; i < n; ++i) { + const candidate = arr[i]; + if (candidate === target) { + return i; + } + if (candidate < target) { + if (direction(target, arr[i - 1], candidate) > 0) { + return i - 1; + } + return i; + } + } + return n - 1; + } + if (direction > 0) { - for (i = 1; i < n; ++i) { + for (let i = 1; i < n; ++i) { if (arr[i] < target) { return i - 1; } } - } else if (direction < 0) { - for (i = 1; i < n; ++i) { + return n - 1; + } + + if (direction < 0) { + for (let i = 1; i < n; ++i) { if (arr[i] <= target) { return i; } } - } else { - for (i = 1; i < n; ++i) { - if (arr[i] == target) { - return i; - } else if (arr[i] < target) { - if (typeof direction === 'function') { - if (direction(target, arr[i - 1], arr[i]) > 0) { - return i - 1; - } - return i; - } else if (arr[i - 1] - target < target - arr[i]) { - return i - 1; - } - return i; + return n - 1; + } + + for (let i = 1; i < n; ++i) { + if (arr[i] == target) { + return i; + } + if (arr[i] < target) { + if (arr[i - 1] - target < target - arr[i]) { + return i - 1; } + return i; } } return n - 1; @@ -1088,7 +1117,7 @@ var ol = (function () { * OpenLayers version. * @type {string} */ - const VERSION = '7.3.0'; + const VERSION = '7.5.2'; /** * @module ol/Object @@ -3220,6 +3249,9 @@ var ol = (function () { * @api */ function applyTransform(extent, transformFn, dest, stops) { + if (isEmpty(extent)) { + return createOrUpdateEmpty(dest); + } let coordinates = []; if (stops > 1) { const width = extent[2] - extent[0]; @@ -3310,13 +3342,15 @@ var ol = (function () { if (getWidth(extent) > worldWidth) { // the extent wraps around on itself return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]]; - } else if (extent[0] < projectionExtent[0]) { + } + if (extent[0] < projectionExtent[0]) { // the extent crosses the anti meridian, so it needs to be sliced return [ [extent[0] + worldWidth, extent[1], projectionExtent[2], extent[3]], [projectionExtent[0], extent[1], extent[2], extent[3]], ]; - } else if (extent[2] > projectionExtent[2]) { + } + if (extent[2] > projectionExtent[2]) { // the extent crosses the anti meridian, so it needs to be sliced return [ [extent[0], extent[1], projectionExtent[2], extent[3]], @@ -4241,7 +4275,8 @@ var ol = (function () { */ /** - * An array of numbers representing an xy coordinate. Example: `[16, 48]`. + * An array of numbers representing an `xy`, `xyz` or `xyzm` coordinate. + * Example: `[16, 48]`. * @typedef {Array} Coordinate * @api */ @@ -5218,7 +5253,8 @@ var ol = (function () { function createProjection(projection, defaultCode) { if (!projection) { return get$2(defaultCode); - } else if (typeof projection === 'string') { + } + if (typeof projection === 'string') { return get$2(projection); } return /** @type {Projection} */ (projection); @@ -5455,7 +5491,8 @@ var ol = (function () { /** * Set the projection for coordinates supplied from and returned by API methods. - * This includes all API methods except for those interacting with tile grids. + * This includes all API methods except for those interacting with tile grids, + * plus {@link import("./Map.js").FrameState} and {@link import("./View.js").State}. * @param {ProjectionLike} projection The user projection. * @api */ @@ -5473,8 +5510,6 @@ var ol = (function () { /** * Get the projection for coordinates supplied from and returned by API methods. - * Note that this method is not yet a part of the stable API. Support for user - * projections is not yet complete and should be considered experimental. * @return {Projection|null} The user projection (or null if not set). * @api */ @@ -5483,8 +5518,9 @@ var ol = (function () { } /** - * Use geographic coordinates (WGS-84 datum) in API methods. This includes all API - * methods except for those interacting with tile grids. + * Use geographic coordinates (WGS-84 datum) in API methods. + * This includes all API methods except for those interacting with tile grids, + * plus {@link import("./Map.js").FrameState} and {@link import("./View.js").State}. * @api */ function useGeographic() { @@ -5605,8 +5641,8 @@ var ol = (function () { * clamped to the validity range. * @param {Projection} sourceProj Source projection. * @param {Projection} destProj Destination projection. - * @param {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} transform Transform function (source to destiation). - * @return {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} Safe transform function (source to destiation). + * @param {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} transform Transform function (source to destination). + * @return {function(import("./coordinate.js").Coordinate): import("./coordinate.js").Coordinate} Safe transform function (source to destination). */ function createSafeCoordinateTransform(sourceProj, destProj, transform) { return function (coord) { @@ -8440,7 +8476,7 @@ var ol = (function () { * @param {Array} flatCoordinates Flat coordinates * @param {Array} ends Linear ring end indexes * @return {Array>} Two dimensional endss array that can - * be used to contruct a MultiPolygon + * be used to construct a MultiPolygon */ function inflateEnds(flatCoordinates, ends) { const endss = []; @@ -8887,6 +8923,9 @@ var ol = (function () { * @api */ function fromExtent(extent) { + if (isEmpty(extent)) { + throw new Error('Cannot create polygon from empty extent'); + } const minX = extent[0]; const minY = extent[1]; const maxX = extent[2]; @@ -9592,7 +9631,8 @@ var ol = (function () { return coordinate; } return null; - } else if (flatCoordinates[end - 1] < m) { + } + if (flatCoordinates[end - 1] < m) { if (extrapolate) { coordinate = flatCoordinates.slice(end - stride, end); coordinate[stride - 1] = m; @@ -9687,7 +9727,8 @@ var ol = (function () { } if (m < flatCoordinates[offset + stride - 1]) { return null; - } else if (m <= flatCoordinates[end - 1]) { + } + if (m <= flatCoordinates[end - 1]) { return lineStringCoordinateAtM( flatCoordinates, offset, @@ -11250,7 +11291,7 @@ var ol = (function () { /** * @const - * @type {import("../colorlike.js").ColorLike} + * @type {string} */ const defaultFillStyle = '#000'; @@ -12041,7 +12082,7 @@ var ol = (function () { if (lineJoin === 'miter' && miterRatio <= miterLimit) { return miterRatio * strokeWidth; } - // Calculate the distnce from center to the stroke corner where + // Calculate the distance from center to the stroke corner where // it was cut short because of the miter limit. // l // ----+---- <= distance from center to here is maxr @@ -12371,7 +12412,7 @@ var ol = (function () { * 1. The pixel coordinates of the geometry in GeoJSON notation. * 2. The {@link module:ol/render~State} of the layer renderer. * - * @typedef {function((import("../coordinate.js").Coordinate|Array|Array>),import("../render.js").State): void} RenderFunction + * @typedef {function((import("../coordinate.js").Coordinate|Array|Array>|Array>>),import("../render.js").State): void} RenderFunction */ /** @@ -12798,7 +12839,7 @@ var ol = (function () { * @param {number} resolution Resolution. * @return {Array