diff --git a/externs/olx.js b/externs/olx.js index f1e2320d35..13ea58eac4 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -23,35 +23,6 @@ olx.CollectionOptions; olx.CollectionOptions.prototype.unique; -/** - * @typedef {{html: string, - * tileRanges: (Object.>|undefined)}} - */ -olx.AttributionOptions; - - -/** - * HTML markup for this attribution. - * @type {string} - * @api - */ -olx.AttributionOptions.prototype.html; - - -/** - * @typedef {{tracking: (boolean|undefined)}} - */ -olx.DeviceOrientationOptions; - - -/** - * Start tracking. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.DeviceOrientationOptions.prototype.tracking; - - /** * @typedef {{tracking: (boolean|undefined), * trackingOptions: (GeolocationPositionOptions|undefined), @@ -5759,90 +5730,6 @@ olx.source.ImageCanvasOptions.prototype.resolutions; olx.source.ImageCanvasOptions.prototype.state; -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * logo: (string|olx.LogoOptions|undefined), - * projection: ol.ProjectionLike, - * ratio: (number|undefined), - * renderBuffer: (number|undefined), - * resolutions: (Array.|undefined), - * source: ol.source.Vector, - * style: (ol.style.Style|Array.|ol.StyleFunction|undefined)}} - */ -olx.source.ImageVectorOptions; - - -/** - * Attributions. - * @type {ol.AttributionLike|undefined} - * @api - */ -olx.source.ImageVectorOptions.prototype.attributions; - - -/** - * Logo. - * @type {string|olx.LogoOptions|undefined} - * @api - */ -olx.source.ImageVectorOptions.prototype.logo; - - -/** - * Projection. - * @type {ol.ProjectionLike} - * @api - */ -olx.source.ImageVectorOptions.prototype.projection; - - -/** - * Ratio. 1 means canvases are the size of the map viewport, 2 means twice the - * width and height of the map viewport, and so on. Must be `1` or higher. - * Default is `1.5`. - * @type {number|undefined} - * @api - */ -olx.source.ImageVectorOptions.prototype.ratio; - - -/** - * The buffer around the viewport extent used by the renderer when getting - * features from the vector source for the rendering or hit-detection. - * Recommended value: the size of the largest symbol, line width or label. - * Default is 100 pixels. - * @type {number|undefined} - * @api - */ -olx.source.ImageVectorOptions.prototype.renderBuffer; - - -/** - * Resolutions. If specified, new canvases will be created for these resolutions - * only. - * @type {Array.|undefined} - * @api - */ -olx.source.ImageVectorOptions.prototype.resolutions; - - -/** - * The vector source from which the vector features drawn in canvas elements are - * read. - * @type {ol.source.Vector} - * @api - */ -olx.source.ImageVectorOptions.prototype.source; - - -/** - * Style to use when rendering features to the canvas. - * @type {ol.style.Style|Array.|ol.StyleFunction|undefined} - * @api - */ -olx.source.ImageVectorOptions.prototype.style; - - /** * @typedef {{sources: Array., * operation: (ol.RasterOperation|undefined), @@ -7906,7 +7793,6 @@ olx.style.StrokeOptions.prototype.width; /** * @typedef {{font: (string|undefined), - * exceedLength: (boolean|undefined), * maxAngle: (number|undefined), * offsetX: (number|undefined), * offsetY: (number|undefined), @@ -7927,19 +7813,6 @@ olx.style.StrokeOptions.prototype.width; olx.style.TextOptions; -/** - * **Deprecated**. Use the `overflow` option instead. - * - * For polygon labels or when `placement` is set to `'line'`, allow text to - * exceed the width of the polygon at the label position or the length of - * the path that it follows. Default is `false`. - * @type {boolean|undefined} - * @deprecated - * @api - */ -olx.style.TextOptions.prototype.exceedLength; - - /** * Font style as CSS 'font' value, see: * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font}. diff --git a/src/ol/Attribution.js b/src/ol/Attribution.js deleted file mode 100644 index 9a4484589d..0000000000 --- a/src/ol/Attribution.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @module ol/Attribution - */ -import _ol_TileRange_ from './TileRange.js'; -import _ol_math_ from './math.js'; -import _ol_tilegrid_ from './tilegrid.js'; - -/** - * @classdesc - * An attribution for a layer source. - * - * Example: - * - * source: new ol.source.OSM({ - * attributions: [ - * new ol.Attribution({ - * html: 'All maps © ' + - * 'OpenCycleMap' - * }), - * ol.source.OSM.ATTRIBUTION - * ], - * .. - * - * @constructor - * @deprecated This class is deprecated and will removed in the next major release. - * @param {olx.AttributionOptions} options Attribution options. - * @struct - * @api - */ -var _ol_Attribution_ = function(options) { - - /** - * @private - * @type {string} - */ - this.html_ = options.html; - - /** - * @private - * @type {Object.>} - */ - this.tileRanges_ = options.tileRanges ? options.tileRanges : null; - -}; - - -/** - * Get the attribution markup. - * @return {string} The attribution HTML. - * @api - */ -_ol_Attribution_.prototype.getHTML = function() { - return this.html_; -}; - - -/** - * @param {Object.} tileRanges Tile ranges. - * @param {!ol.tilegrid.TileGrid} tileGrid Tile grid. - * @param {!ol.proj.Projection} projection Projection. - * @return {boolean} Intersects any tile range. - */ -_ol_Attribution_.prototype.intersectsAnyTileRange = function(tileRanges, tileGrid, projection) { - if (!this.tileRanges_) { - return true; - } - var i, ii, tileRange, zKey; - for (zKey in tileRanges) { - if (!(zKey in this.tileRanges_)) { - continue; - } - tileRange = tileRanges[zKey]; - var testTileRange; - for (i = 0, ii = this.tileRanges_[zKey].length; i < ii; ++i) { - testTileRange = this.tileRanges_[zKey][i]; - if (testTileRange.intersects(tileRange)) { - return true; - } - var extentTileRange = tileGrid.getTileRangeForExtentAndZ( - _ol_tilegrid_.extentFromProjection(projection), parseInt(zKey, 10)); - var width = extentTileRange.getWidth(); - if (tileRange.minX < extentTileRange.minX || - tileRange.maxX > extentTileRange.maxX) { - if (testTileRange.intersects(new _ol_TileRange_( - _ol_math_.modulo(tileRange.minX, width), - _ol_math_.modulo(tileRange.maxX, width), - tileRange.minY, tileRange.maxY))) { - return true; - } - if (tileRange.getWidth() > width && - testTileRange.intersects(extentTileRange)) { - return true; - } - } - } - } - return false; -}; -export default _ol_Attribution_; diff --git a/src/ol/DeviceOrientation.js b/src/ol/DeviceOrientation.js deleted file mode 100644 index 9f3e9e7eab..0000000000 --- a/src/ol/DeviceOrientation.js +++ /dev/null @@ -1,238 +0,0 @@ -/** - * @module ol/DeviceOrientation - */ -import _ol_events_ from './events.js'; -import {inherits} from './index.js'; -import _ol_Object_ from './Object.js'; -import _ol_has_ from './has.js'; -import _ol_math_ from './math.js'; - -/** - * @classdesc - * The ol.DeviceOrientation class provides access to information from - * DeviceOrientation events. See the [HTML 5 DeviceOrientation Specification]( - * http://www.w3.org/TR/orientation-event/) for more details. - * - * Many new computers, and especially mobile phones - * and tablets, provide hardware support for device orientation. Web - * developers targeting mobile devices will be especially interested in this - * class. - * - * Device orientation data are relative to a common starting point. For mobile - * devices, the starting point is to lay your phone face up on a table with the - * top of the phone pointing north. This represents the zero state. All - * angles are then relative to this state. For computers, it is the same except - * the screen is open at 90 degrees. - * - * Device orientation is reported as three angles - `alpha`, `beta`, and - * `gamma` - relative to the starting position along the three planar axes X, Y - * and Z. The X axis runs from the left edge to the right edge through the - * middle of the device. Similarly, the Y axis runs from the bottom to the top - * of the device through the middle. The Z axis runs from the back to the front - * through the middle. In the starting position, the X axis points to the - * right, the Y axis points away from you and the Z axis points straight up - * from the device lying flat. - * - * The three angles representing the device orientation are relative to the - * three axes. `alpha` indicates how much the device has been rotated around the - * Z axis, which is commonly interpreted as the compass heading (see note - * below). `beta` indicates how much the device has been rotated around the X - * axis, or how much it is tilted from front to back. `gamma` indicates how - * much the device has been rotated around the Y axis, or how much it is tilted - * from left to right. - * - * For most browsers, the `alpha` value returns the compass heading so if the - * device points north, it will be 0. With Safari on iOS, the 0 value of - * `alpha` is calculated from when device orientation was first requested. - * ol.DeviceOrientation provides the `heading` property which normalizes this - * behavior across all browsers for you. - * - * It is important to note that the HTML 5 DeviceOrientation specification - * indicates that `alpha`, `beta` and `gamma` are in degrees while the - * equivalent properties in ol.DeviceOrientation are in radians for consistency - * with all other uses of angles throughout OpenLayers. - * - * To get notified of device orientation changes, register a listener for the - * generic `change` event on your `ol.DeviceOrientation` instance. - * - * @see {@link http://www.w3.org/TR/orientation-event/} - * - * @deprecated This class is deprecated and will removed in the next major release. - * - * @constructor - * @extends {ol.Object} - * @param {olx.DeviceOrientationOptions=} opt_options Options. - * @api - */ -var _ol_DeviceOrientation_ = function(opt_options) { - - _ol_Object_.call(this); - - var options = opt_options ? opt_options : {}; - - /** - * @private - * @type {?ol.EventsKey} - */ - this.listenerKey_ = null; - - _ol_events_.listen(this, - _ol_Object_.getChangeEventType(_ol_DeviceOrientation_.Property_.TRACKING), - this.handleTrackingChanged_, this); - - this.setTracking(options.tracking !== undefined ? options.tracking : false); - -}; - -inherits(_ol_DeviceOrientation_, _ol_Object_); - - -/** - * @inheritDoc - */ -_ol_DeviceOrientation_.prototype.disposeInternal = function() { - this.setTracking(false); - _ol_Object_.prototype.disposeInternal.call(this); -}; - - -/** - * @private - * @param {Event} originalEvent Event. - */ -_ol_DeviceOrientation_.prototype.orientationChange_ = function(originalEvent) { - var event = /** @type {DeviceOrientationEvent} */ (originalEvent); - if (event.alpha !== null) { - var alpha = _ol_math_.toRadians(event.alpha); - this.set(_ol_DeviceOrientation_.Property_.ALPHA, alpha); - // event.absolute is undefined in iOS. - if (typeof event.absolute === 'boolean' && event.absolute) { - this.set(_ol_DeviceOrientation_.Property_.HEADING, alpha); - } else if (typeof event.webkitCompassHeading === 'number' && - event.webkitCompassAccuracy != -1) { - var heading = _ol_math_.toRadians(event.webkitCompassHeading); - this.set(_ol_DeviceOrientation_.Property_.HEADING, heading); - } - } - if (event.beta !== null) { - this.set(_ol_DeviceOrientation_.Property_.BETA, - _ol_math_.toRadians(event.beta)); - } - if (event.gamma !== null) { - this.set(_ol_DeviceOrientation_.Property_.GAMMA, - _ol_math_.toRadians(event.gamma)); - } - this.changed(); -}; - - -/** - * Rotation around the device z-axis (in radians). - * @return {number|undefined} The euler angle in radians of the device from the - * standard Z axis. - * @observable - * @api - */ -_ol_DeviceOrientation_.prototype.getAlpha = function() { - return ( - /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.ALPHA) - ); -}; - - -/** - * Rotation around the device x-axis (in radians). - * @return {number|undefined} The euler angle in radians of the device from the - * planar X axis. - * @observable - * @api - */ -_ol_DeviceOrientation_.prototype.getBeta = function() { - return ( - /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.BETA) - ); -}; - - -/** - * Rotation around the device y-axis (in radians). - * @return {number|undefined} The euler angle in radians of the device from the - * planar Y axis. - * @observable - * @api - */ -_ol_DeviceOrientation_.prototype.getGamma = function() { - return ( - /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.GAMMA) - ); -}; - - -/** - * The heading of the device relative to north (in radians). - * @return {number|undefined} The heading of the device relative to north, in - * radians, normalizing for different browser behavior. - * @observable - * @api - */ -_ol_DeviceOrientation_.prototype.getHeading = function() { - return ( - /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.HEADING) - ); -}; - - -/** - * Determine if orientation is being tracked. - * @return {boolean} Changes in device orientation are being tracked. - * @observable - * @api - */ -_ol_DeviceOrientation_.prototype.getTracking = function() { - return ( - /** @type {boolean} */ this.get(_ol_DeviceOrientation_.Property_.TRACKING) - ); -}; - - -/** - * @private - */ -_ol_DeviceOrientation_.prototype.handleTrackingChanged_ = function() { - if (_ol_has_.DEVICE_ORIENTATION) { - var tracking = this.getTracking(); - if (tracking && !this.listenerKey_) { - this.listenerKey_ = _ol_events_.listen(window, 'deviceorientation', - this.orientationChange_, this); - } else if (!tracking && this.listenerKey_ !== null) { - _ol_events_.unlistenByKey(this.listenerKey_); - this.listenerKey_ = null; - } - } -}; - - -/** - * Enable or disable tracking of device orientation events. - * @param {boolean} tracking The status of tracking changes to alpha, beta and - * gamma. If true, changes are tracked and reported immediately. - * @observable - * @api - */ -_ol_DeviceOrientation_.prototype.setTracking = function(tracking) { - this.set(_ol_DeviceOrientation_.Property_.TRACKING, tracking); -}; - - -/** - * @enum {string} - * @private - */ -_ol_DeviceOrientation_.Property_ = { - ALPHA: 'alpha', - BETA: 'beta', - GAMMA: 'gamma', - HEADING: 'heading', - TRACKING: 'tracking' -}; -export default _ol_DeviceOrientation_; diff --git a/src/ol/control/Attribution.js b/src/ol/control/Attribution.js index d18ba642a2..fbaacd36ed 100644 --- a/src/ol/control/Attribution.js +++ b/src/ol/control/Attribution.js @@ -174,7 +174,7 @@ _ol_control_Attribution_.prototype.getSourceAttributions_ = function(frameState) continue; } - var attributionGetter = source.getAttributions2(); + var attributionGetter = source.getAttributions(); if (!attributionGetter) { continue; } diff --git a/src/ol/format/filter/And.js b/src/ol/format/filter/And.js index 07667202cb..13c5c46a48 100644 --- a/src/ol/format/filter/And.js +++ b/src/ol/format/filter/And.js @@ -2,25 +2,22 @@ * @module ol/format/filter/And */ import {inherits} from '../../index.js'; -import _ol_format_filter_LogicalNary_ from '../filter/LogicalNary.js'; +import LogicalNary from '../filter/LogicalNary.js'; /** * @classdesc * Represents a logical `` operator between two or more filter conditions. * - * deprecated: This class will no longer be exported starting from the next major version. - * * @constructor * @abstract * @param {...ol.format.filter.Filter} conditions Conditions. * @extends {ol.format.filter.LogicalNary} - * @api */ -var _ol_format_filter_And_ = function(conditions) { +var And = function(conditions) { var params = ['And'].concat(Array.prototype.slice.call(arguments)); - _ol_format_filter_LogicalNary_.apply(this, params); + LogicalNary.apply(this, params); }; -inherits(_ol_format_filter_And_, _ol_format_filter_LogicalNary_); +inherits(And, LogicalNary); -export default _ol_format_filter_And_; +export default And; diff --git a/src/ol/format/filter/Comparison.js b/src/ol/format/filter/Comparison.js index f62c31bc82..b30f1df5e7 100644 --- a/src/ol/format/filter/Comparison.js +++ b/src/ol/format/filter/Comparison.js @@ -2,25 +2,22 @@ * @module ol/format/filter/Comparison */ import {inherits} from '../../index.js'; -import _ol_format_filter_Filter_ from '../filter/Filter.js'; +import Filter from '../filter/Filter.js'; /** * @classdesc * Abstract class; normally only used for creating subclasses and not instantiated in apps. * Base class for WFS GetFeature property comparison filters. * - * deprecated: This class will no longer be exported starting from the next major version. - * * @constructor * @abstract * @param {!string} tagName The XML tag name for this filter. * @param {!string} propertyName Name of the context property to compare. * @extends {ol.format.filter.Filter} - * @api */ -var _ol_format_filter_Comparison_ = function(tagName, propertyName) { +var Comparison = function(tagName, propertyName) { - _ol_format_filter_Filter_.call(this, tagName); + Filter.call(this, tagName); /** * @public @@ -29,6 +26,6 @@ var _ol_format_filter_Comparison_ = function(tagName, propertyName) { this.propertyName = propertyName; }; -inherits(_ol_format_filter_Comparison_, _ol_format_filter_Filter_); +inherits(Comparison, Filter); -export default _ol_format_filter_Comparison_; +export default Comparison; diff --git a/src/ol/format/filter/ComparisonBinary.js b/src/ol/format/filter/ComparisonBinary.js index 8b4e0b0731..9c2e7bf958 100644 --- a/src/ol/format/filter/ComparisonBinary.js +++ b/src/ol/format/filter/ComparisonBinary.js @@ -2,15 +2,13 @@ * @module ol/format/filter/ComparisonBinary */ import {inherits} from '../../index.js'; -import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; +import Comparison from '../filter/Comparison.js'; /** * @classdesc * Abstract class; normally only used for creating subclasses and not instantiated in apps. * Base class for WFS GetFeature property binary comparison filters. * - * deprecated: This class will no longer be exported starting from the next major version. - * * @constructor * @abstract * @param {!string} tagName The XML tag name for this filter. @@ -18,12 +16,11 @@ import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; * @param {!(string|number)} expression The value to compare. * @param {boolean=} opt_matchCase Case-sensitive? * @extends {ol.format.filter.Comparison} - * @api */ -var _ol_format_filter_ComparisonBinary_ = function( +var ComparisonBinary = function( tagName, propertyName, expression, opt_matchCase) { - _ol_format_filter_Comparison_.call(this, tagName, propertyName); + Comparison.call(this, tagName, propertyName); /** * @public @@ -38,5 +35,5 @@ var _ol_format_filter_ComparisonBinary_ = function( this.matchCase = opt_matchCase; }; -inherits(_ol_format_filter_ComparisonBinary_, _ol_format_filter_Comparison_); -export default _ol_format_filter_ComparisonBinary_; +inherits(ComparisonBinary, Comparison); +export default ComparisonBinary; diff --git a/src/ol/format/filter/Filter.js b/src/ol/format/filter/Filter.js index 717fdc92be..336fe29631 100644 --- a/src/ol/format/filter/Filter.js +++ b/src/ol/format/filter/Filter.js @@ -1,20 +1,19 @@ /** * @module ol/format/filter/Filter */ + + /** * @classdesc * Abstract class; normally only used for creating subclasses and not instantiated in apps. * Base class for WFS GetFeature filters. * - * deprecated: This class will no longer be exported starting from the next major version. - * * @constructor * @abstract * @param {!string} tagName The XML tag name for this filter. * @struct - * @api */ -var _ol_format_filter_Filter_ = function(tagName) { +var Filter = function(tagName) { /** * @private @@ -27,7 +26,8 @@ var _ol_format_filter_Filter_ = function(tagName) { * The XML tag name for a filter. * @returns {!string} Name. */ -_ol_format_filter_Filter_.prototype.getTagName = function() { +Filter.prototype.getTagName = function() { return this.tagName_; }; -export default _ol_format_filter_Filter_; + +export default Filter; diff --git a/src/ol/format/filter/Spatial.js b/src/ol/format/filter/Spatial.js index 95efa3a1c5..ac838f838c 100644 --- a/src/ol/format/filter/Spatial.js +++ b/src/ol/format/filter/Spatial.js @@ -2,7 +2,7 @@ * @module ol/format/filter/Spatial */ import {inherits} from '../../index.js'; -import _ol_format_filter_Filter_ from '../filter/Filter.js'; +import Filter from '../filter/Filter.js'; /** * @classdesc @@ -10,8 +10,6 @@ import _ol_format_filter_Filter_ from '../filter/Filter.js'; * Represents a spatial operator to test whether a geometry-valued property * relates to a given geometry. * - * deprecated: This class will no longer be exported starting from the next major version. - * * @constructor * @abstract * @param {!string} tagName The XML tag name for this filter. @@ -20,11 +18,10 @@ import _ol_format_filter_Filter_ from '../filter/Filter.js'; * @param {string=} opt_srsName SRS name. No srsName attribute will be * set on geometries when this is not provided. * @extends {ol.format.filter.Filter} - * @api */ -var _ol_format_filter_Spatial_ = function(tagName, geometryName, geometry, opt_srsName) { +var Spatial = function(tagName, geometryName, geometry, opt_srsName) { - _ol_format_filter_Filter_.call(this, tagName); + Filter.call(this, tagName); /** * @public @@ -45,5 +42,6 @@ var _ol_format_filter_Spatial_ = function(tagName, geometryName, geometry, opt_s this.srsName = opt_srsName; }; -inherits(_ol_format_filter_Spatial_, _ol_format_filter_Filter_); -export default _ol_format_filter_Spatial_; +inherits(Spatial, Filter); + +export default Spatial; diff --git a/src/ol/proj/common.js b/src/ol/proj/common.js deleted file mode 100644 index 906f91fd65..0000000000 --- a/src/ol/proj/common.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @module ol/proj/common - */ -import _ol_proj_ from '../proj.js'; -var _ol_proj_common_ = {}; - - -/** - * Deprecated. Transforms between EPSG:4326 and EPSG:3857 are now included by - * default. There is no need to call this function in application code and it - * will be removed in a future major release. - * @deprecated This function is no longer necessary. - * @api - */ -_ol_proj_common_.add = _ol_proj_.addCommon; -export default _ol_proj_common_; diff --git a/src/ol/source/ImageVector.js b/src/ol/source/ImageVector.js deleted file mode 100644 index 71d868d66f..0000000000 --- a/src/ol/source/ImageVector.js +++ /dev/null @@ -1,318 +0,0 @@ -/** - * @module ol/source/ImageVector - */ -import {getUid, inherits} from '../index.js'; -import _ol_dom_ from '../dom.js'; -import _ol_events_ from '../events.js'; -import _ol_events_EventType_ from '../events/EventType.js'; -import _ol_ext_rbush_ from 'rbush'; -import _ol_extent_ from '../extent.js'; -import _ol_render_canvas_ReplayGroup_ from '../render/canvas/ReplayGroup.js'; -import _ol_renderer_vector_ from '../renderer/vector.js'; -import _ol_source_ImageCanvas_ from '../source/ImageCanvas.js'; -import _ol_style_Style_ from '../style/Style.js'; -import _ol_transform_ from '../transform.js'; - -/** - * @deprecated - * @classdesc - * **Deprecated**. Use an `ol.layer.Vector` with `renderMode: 'image'` and an - * `ol.source.Vector` instead. - * - * An image source whose images are canvas elements into which vector features - * read from a vector source (`ol.source.Vector`) are drawn. An - * `ol.source.ImageVector` object is to be used as the `source` of an image - * layer (`ol.layer.Image`). Image layers are rotated, scaled, and translated, - * as opposed to being re-rendered, during animations and interactions. So, like - * any other image layer, an image layer configured with an - * `ol.source.ImageVector` will exhibit this behaviour. This is in contrast to a - * vector layer, where vector features are re-drawn during animations and - * interactions. - * - * @constructor - * @extends {ol.source.ImageCanvas} - * @param {olx.source.ImageVectorOptions} options Options. - * @api - */ -var _ol_source_ImageVector_ = function(options) { - - /** - * @private - * @type {ol.source.Vector} - */ - this.source_ = options.source; - - /** - * @private - * @type {ol.Transform} - */ - this.transform_ = _ol_transform_.create(); - - /** - * @private - * @type {CanvasRenderingContext2D} - */ - this.canvasContext_ = _ol_dom_.createCanvasContext2D(); - - /** - * @private - * @type {ol.Size} - */ - this.canvasSize_ = [0, 0]; - - /** - * Declutter tree. - * @private - */ - this.declutterTree_ = _ol_ext_rbush_(9); - - /** - * @private - * @type {number} - */ - this.renderBuffer_ = options.renderBuffer == undefined ? 100 : options.renderBuffer; - - /** - * @private - * @type {ol.render.canvas.ReplayGroup} - */ - this.replayGroup_ = null; - - _ol_source_ImageCanvas_.call(this, { - attributions: options.attributions, - canvasFunction: this.canvasFunctionInternal_.bind(this), - logo: options.logo, - projection: options.projection, - ratio: options.ratio, - resolutions: options.resolutions, - state: this.source_.getState() - }); - - /** - * User provided style. - * @type {ol.style.Style|Array.|ol.StyleFunction} - * @private - */ - this.style_ = null; - - /** - * Style function for use within the library. - * @type {ol.StyleFunction|undefined} - * @private - */ - this.styleFunction_ = undefined; - - this.setStyle(options.style); - - _ol_events_.listen(this.source_, _ol_events_EventType_.CHANGE, - this.handleSourceChange_, this); - -}; - -inherits(_ol_source_ImageVector_, _ol_source_ImageCanvas_); - - -/** - * @param {ol.Extent} extent Extent. - * @param {number} resolution Resolution. - * @param {number} pixelRatio Pixel ratio. - * @param {ol.Size} size Size. - * @param {ol.proj.Projection} projection Projection; - * @return {HTMLCanvasElement} Canvas element. - * @private - */ -_ol_source_ImageVector_.prototype.canvasFunctionInternal_ = function(extent, resolution, pixelRatio, size, projection) { - - var replayGroup = new _ol_render_canvas_ReplayGroup_( - _ol_renderer_vector_.getTolerance(resolution, pixelRatio), extent, - resolution, pixelRatio, this.source_.getOverlaps(), this.declutterTree_, this.renderBuffer_); - - this.source_.loadFeatures(extent, resolution, projection); - - var loading = false; - this.source_.forEachFeatureInExtent(extent, - /** - * @param {ol.Feature} feature Feature. - */ - function(feature) { - loading = loading || - this.renderFeature_(feature, resolution, pixelRatio, replayGroup); - }, this); - replayGroup.finish(); - - if (loading) { - return null; - } - - if (this.canvasSize_[0] != size[0] || this.canvasSize_[1] != size[1]) { - this.canvasContext_.canvas.width = size[0]; - this.canvasContext_.canvas.height = size[1]; - this.canvasSize_[0] = size[0]; - this.canvasSize_[1] = size[1]; - } else { - this.canvasContext_.clearRect(0, 0, size[0], size[1]); - } - - this.declutterTree_.clear(); - - var transform = this.getTransform_(_ol_extent_.getCenter(extent), - resolution, pixelRatio, size); - replayGroup.replay(this.canvasContext_, transform, 0, {}); - - this.replayGroup_ = replayGroup; - - return this.canvasContext_.canvas; -}; - - -/** - * @inheritDoc - */ -_ol_source_ImageVector_.prototype.forEachFeatureAtCoordinate = function( - coordinate, resolution, rotation, hitTolerance, skippedFeatureUids, callback) { - if (!this.replayGroup_) { - return undefined; - } else { - /** @type {Object.} */ - var features = {}; - var result = this.replayGroup_.forEachFeatureAtCoordinate( - coordinate, resolution, 0, hitTolerance, skippedFeatureUids, - /** - * @param {ol.Feature|ol.render.Feature} feature Feature. - * @return {?} Callback result. - */ - function(feature) { - var key = getUid(feature).toString(); - if (!(key in features)) { - features[key] = true; - return callback(feature); - } - }, null); - return result; - } -}; - - -/** - * Get a reference to the wrapped source. - * @return {ol.source.Vector} Source. - * @api - */ -_ol_source_ImageVector_.prototype.getSource = function() { - return this.source_; -}; - - -/** - * Get the style for features. This returns whatever was passed to the `style` - * option at construction or to the `setStyle` method. - * @return {ol.style.Style|Array.|ol.StyleFunction} - * Layer style. - * @api - */ -_ol_source_ImageVector_.prototype.getStyle = function() { - return this.style_; -}; - - -/** - * Get the style function. - * @return {ol.StyleFunction|undefined} Layer style function. - * @api - */ -_ol_source_ImageVector_.prototype.getStyleFunction = function() { - return this.styleFunction_; -}; - - -/** - * @param {ol.Coordinate} center Center. - * @param {number} resolution Resolution. - * @param {number} pixelRatio Pixel ratio. - * @param {ol.Size} size Size. - * @return {!ol.Transform} Transform. - * @private - */ -_ol_source_ImageVector_.prototype.getTransform_ = function(center, resolution, pixelRatio, size) { - var dx1 = size[0] / 2; - var dy1 = size[1] / 2; - var sx = pixelRatio / resolution; - var sy = -sx; - var dx2 = -center[0]; - var dy2 = -center[1]; - - return _ol_transform_.compose(this.transform_, dx1, dy1, sx, sy, 0, dx2, dy2); -}; - - -/** - * Handle changes in image style state. - * @param {ol.events.Event} event Image style change event. - * @private - */ -_ol_source_ImageVector_.prototype.handleImageChange_ = function(event) { - this.changed(); -}; - - -/** - * @private - */ -_ol_source_ImageVector_.prototype.handleSourceChange_ = function() { - // setState will trigger a CHANGE event, so we always rely - // change events by calling setState. - this.setState(this.source_.getState()); -}; - - -/** - * @param {ol.Feature} feature Feature. - * @param {number} resolution Resolution. - * @param {number} pixelRatio Pixel ratio. - * @param {ol.render.canvas.ReplayGroup} replayGroup Replay group. - * @return {boolean} `true` if an image is loading. - * @private - */ -_ol_source_ImageVector_.prototype.renderFeature_ = function(feature, resolution, pixelRatio, replayGroup) { - var styles; - var styleFunction = feature.getStyleFunction(); - if (styleFunction) { - styles = styleFunction.call(feature, resolution); - } else if (this.styleFunction_) { - styles = this.styleFunction_(feature, resolution); - } - if (!styles) { - return false; - } - var i, ii, loading = false; - if (!Array.isArray(styles)) { - styles = [styles]; - } - for (i = 0, ii = styles.length; i < ii; ++i) { - loading = _ol_renderer_vector_.renderFeature( - replayGroup, feature, styles[i], - _ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio), - this.handleImageChange_, this) || loading; - } - return loading; -}; - - -/** - * Set the style for features. This can be a single style object, an array - * of styles, or a function that takes a feature and resolution and returns - * an array of styles. If it is `undefined` the default style is used. If - * it is `null` the layer has no style (a `null` style), so only features - * that have their own styles will be rendered in the layer. See - * {@link ol.style} for information on the default style. - * @param {ol.style.Style|Array.|ol.StyleFunction|undefined} - * style Layer style. - * @api - */ -_ol_source_ImageVector_.prototype.setStyle = function(style) { - this.style_ = style !== undefined ? style : _ol_style_Style_.defaultFunction; - this.styleFunction_ = !style ? - undefined : _ol_style_Style_.createFunction(this.style_); - this.changed(); -}; -export default _ol_source_ImageVector_; diff --git a/src/ol/source/Source.js b/src/ol/source/Source.js index 58c464c4fa..136339031d 100644 --- a/src/ol/source/Source.js +++ b/src/ol/source/Source.js @@ -2,7 +2,6 @@ * @module ol/source/Source */ import {inherits, nullFunction} from '../index.js'; -import _ol_Attribution_ from '../Attribution.js'; import _ol_Object_ from '../Object.js'; import _ol_proj_ from '../proj.js'; import _ol_source_State_ from '../source/State.js'; @@ -33,15 +32,9 @@ var _ol_source_Source_ = function(options) { /** * @private - * @type {Array.} + * @type {?ol.Attribution} */ - this.attributions_ = null; - - /** - * @private - * @type {?ol.Attribution2} - */ - this.attributions2_ = this.adaptAttributions_(options.attributions); + this.attributions_ = this.adaptAttributions_(options.attributions); /** * @private @@ -68,42 +61,14 @@ inherits(_ol_source_Source_, _ol_Object_); /** * Turns the attributions option into an attributions function. - * @suppress {deprecated} * @param {ol.AttributionLike|undefined} attributionLike The attribution option. - * @return {?ol.Attribution2} An attribution function (or null). + * @return {?ol.Attribution} An attribution function (or null). */ _ol_source_Source_.prototype.adaptAttributions_ = function(attributionLike) { if (!attributionLike) { return null; } - if (attributionLike instanceof _ol_Attribution_) { - - // TODO: remove attributions_ in next major release - this.attributions_ = [attributionLike]; - - return function(frameState) { - return [attributionLike.getHTML()]; - }; - } if (Array.isArray(attributionLike)) { - if (attributionLike[0] instanceof _ol_Attribution_) { - - // TODO: remove attributions_ in next major release - this.attributions_ = attributionLike; - - var attributions = attributionLike.map(function(attribution) { - return attribution.getHTML(); - }); - return function(frameState) { - return attributions; - }; - } - - // TODO: remove attributions_ in next major release - this.attributions_ = attributionLike.map(function(attribution) { - return new _ol_Attribution_({html: attribution}); - }); - return function(frameState) { return attributionLike; }; @@ -113,11 +78,6 @@ _ol_source_Source_.prototype.adaptAttributions_ = function(attributionLike) { return attributionLike; } - // TODO: remove attributions_ in next major release - this.attributions_ = [ - new _ol_Attribution_({html: attributionLike}) - ]; - return function(frameState) { return [attributionLike]; }; @@ -138,24 +98,14 @@ _ol_source_Source_.prototype.forEachFeatureAtCoordinate = nullFunction; /** - * Get the attributions of the source. - * @return {Array.} Attributions. - * @api + * Get the attribution function for the source. + * @return {?ol.Attribution} Attribution function. */ _ol_source_Source_.prototype.getAttributions = function() { return this.attributions_; }; -/** - * Get the attribution function for the source. - * @return {?ol.Attribution2} Attribution function. - */ -_ol_source_Source_.prototype.getAttributions2 = function() { - return this.attributions2_; -}; - - /** * Get the logo of the source. * @return {string|olx.LogoOptions|undefined} Logo. @@ -213,12 +163,12 @@ _ol_source_Source_.prototype.refresh = function() { /** * Set the attributions of the source. * @param {ol.AttributionLike|undefined} attributions Attributions. - * Can be passed as `string`, `Array`, `{@link ol.Attribution2}`, + * Can be passed as `string`, `Array`, `{@link ol.Attribution}`, * or `undefined`. * @api */ _ol_source_Source_.prototype.setAttributions = function(attributions) { - this.attributions2_ = this.adaptAttributions_(attributions); + this.attributions_ = this.adaptAttributions_(attributions); this.changed(); }; diff --git a/src/ol/source/TileJSON.js b/src/ol/source/TileJSON.js index c191736595..23728876ae 100644 --- a/src/ol/source/TileJSON.js +++ b/src/ol/source/TileJSON.js @@ -136,7 +136,7 @@ _ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) { this.tileUrlFunction = _ol_TileUrlFunction_.createFromTemplates(tileJSON.tiles, tileGrid); - if (tileJSON.attribution !== undefined && !this.getAttributions2()) { + if (tileJSON.attribution !== undefined && !this.getAttributions()) { var attributionExtent = extent !== undefined ? extent : epsg4326Projection.getExtent(); diff --git a/src/ol/style/Text.js b/src/ol/style/Text.js index 13b90f1ca0..7ac9d4b4cc 100644 --- a/src/ol/style/Text.js +++ b/src/ol/style/Text.js @@ -77,14 +77,11 @@ var _ol_style_Text_ = function(opt_options) { */ this.placement_ = options.placement !== undefined ? options.placement : _ol_style_TextPlacement_.POINT; - //TODO Use options.overflow directly after removing @deprecated exceedLength - var overflow = options.overflow === undefined ? options.exceedLength : options.overflow; - /** * @private * @type {boolean} */ - this.overflow_ = overflow !== undefined ? overflow : false; + this.overflow_ = !!options.overflow; /** * @private diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 7163d6b873..60c7569c04 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -75,10 +75,9 @@ ol.AtlasManagerInfo; * It represents either * * a simple string (e.g. `'© Acme Inc.'`) * * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`) - * * a function that returns a string or array of strings (`{@link ol.Attribution2}`) + * * a function that returns a string or array of strings (`{@link ol.Attribution}`) * - * Note that the `{@link ol.Attribution}` constructor is deprecated. - * @typedef {string|Array.|ol.Attribution2|ol.Attribution|Array.} + * @typedef {string|Array.|ol.Attribution} */ ol.AttributionLike; @@ -89,7 +88,7 @@ ol.AttributionLike; * * @typedef {function(olx.FrameState): (string|Array.)} */ -ol.Attribution2; +ol.Attribution; /** diff --git a/test/spec/ol/deviceorientation.test.js b/test/spec/ol/deviceorientation.test.js deleted file mode 100644 index 178ce1bcdb..0000000000 --- a/test/spec/ol/deviceorientation.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import _ol_DeviceOrientation_ from '../../../src/ol/DeviceOrientation.js'; - - -describe('ol.DeviceOrientation', function() { - - describe('constructor', function() { - - it('can be constructed without arguments', function() { - var instance = new _ol_DeviceOrientation_(); - expect(instance).to.be.an(_ol_DeviceOrientation_); - }); - - }); - -}); diff --git a/test/spec/ol/source/source.test.js b/test/spec/ol/source/source.test.js index 21d2085607..e05604888d 100644 --- a/test/spec/ol/source/source.test.js +++ b/test/spec/ol/source/source.test.js @@ -1,4 +1,3 @@ -import _ol_Attribution_ from '../../../../src/ol/Attribution.js'; import _ol_proj_ from '../../../../src/ol/proj.js'; import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; @@ -17,7 +16,7 @@ describe('ol.source.Source', function() { describe('config option `attributions`', function() { it('accepts undefined', function() { var source = new _ol_source_Source_({}); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.be(null); }); @@ -25,7 +24,7 @@ describe('ol.source.Source', function() { var source = new _ol_source_Source_({ attributions: 'Humpty' }); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql(['Humpty']); @@ -35,7 +34,7 @@ describe('ol.source.Source', function() { var source = new _ol_source_Source_({ attributions: ['Humpty', 'Dumpty'] }); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql(['Humpty', 'Dumpty']); @@ -47,7 +46,7 @@ describe('ol.source.Source', function() { return 'Humpty'; } }); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.be('Humpty'); @@ -59,7 +58,7 @@ describe('ol.source.Source', function() { return ['Humpty', 'Dumpty']; } }); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql(['Humpty', 'Dumpty']); @@ -78,55 +77,6 @@ describe('ol.source.Source', function() { }); }); - describe('#getAttributions()', function() { - it('maintains backwards compatibility for string option', function() { - var source = new _ol_source_Source_({ - attributions: 'foo' - }); - var attributions = source.getAttributions(); - expect(attributions.length).to.be(1); - expect(attributions[0]).to.be.an(_ol_Attribution_); - expect(attributions[0].getHTML()).to.be('foo'); - }); - - it('maintains backwards compatibility for array of strings option', function() { - var source = new _ol_source_Source_({ - attributions: ['foo', 'bar'] - }); - var attributions = source.getAttributions(); - expect(attributions.length).to.be(2); - expect(attributions[0]).to.be.an(_ol_Attribution_); - expect(attributions[0].getHTML()).to.be('foo'); - expect(attributions[1]).to.be.an(_ol_Attribution_); - expect(attributions[1].getHTML()).to.be('bar'); - }); - - it('maintains backwards compatibility for ol.Attribution option', function() { - var source = new _ol_source_Source_({ - attributions: new _ol_Attribution_({html: 'foo'}) - }); - var attributions = source.getAttributions(); - expect(attributions.length).to.be(1); - expect(attributions[0]).to.be.an(_ol_Attribution_); - expect(attributions[0].getHTML()).to.be('foo'); - }); - - it('maintains backwards compatibility for array of strings option', function() { - var source = new _ol_source_Source_({ - attributions: [ - new _ol_Attribution_({html: 'foo'}), - new _ol_Attribution_({html: 'bar'}) - ] - }); - var attributions = source.getAttributions(); - expect(attributions.length).to.be(2); - expect(attributions[0]).to.be.an(_ol_Attribution_); - expect(attributions[0].getHTML()).to.be('foo'); - expect(attributions[1]).to.be.an(_ol_Attribution_); - expect(attributions[1].getHTML()).to.be('bar'); - }); - }); - describe('#setAttributions()', function() { var source = null; @@ -142,13 +92,13 @@ describe('ol.source.Source', function() { it('accepts undefined', function() { source.setAttributions(); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.be(null); }); it('accepts a single string', function() { source.setAttributions('Humpty'); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql(['Humpty']); @@ -156,7 +106,7 @@ describe('ol.source.Source', function() { it('accepts an array of strings', function() { source.setAttributions(['Humpty', 'Dumpty']); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql(['Humpty', 'Dumpty']); @@ -166,7 +116,7 @@ describe('ol.source.Source', function() { source.setAttributions(function() { return 'Humpty'; }); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql('Humpty'); @@ -176,7 +126,7 @@ describe('ol.source.Source', function() { source.setAttributions(function() { return ['Humpty', 'Dumpty']; }); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); expect(attributions()).to.eql(['Humpty', 'Dumpty']); diff --git a/test/spec/ol/source/tileutfgrid.test.js b/test/spec/ol/source/tileutfgrid.test.js index d99ac409c9..479609bdc8 100644 --- a/test/spec/ol/source/tileutfgrid.test.js +++ b/test/spec/ol/source/tileutfgrid.test.js @@ -163,13 +163,13 @@ describe('ol.source.TileUTFGrid', function() { it('sets up correct attribution', function() { var source = getTileUTFGrid(); - expect(source.getAttributions2()).to.be(null); + expect(source.getAttributions()).to.be(null); // call the handleTileJSONResponse method with our // locally available tileJson (from `before`) source.handleTileJSONResponse(tileJson); - var attributions = source.getAttributions2(); + var attributions = source.getAttributions(); expect(attributions).to.not.be(null); expect(typeof attributions).to.be('function'); });