Lint removal
This commit is contained in:
@@ -8,15 +8,15 @@ import {UNDEFINED} from './functions.js';
|
||||
* @constructor
|
||||
*/
|
||||
class Disposable {
|
||||
/**
|
||||
/**
|
||||
* Clean up.
|
||||
*/
|
||||
dispose() {
|
||||
if (!this.disposed_) {
|
||||
this.disposed_ = true;
|
||||
this.disposeInternal();
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
if (!this.disposed_) {
|
||||
this.disposed_ = true;
|
||||
this.disposeInternal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
116
src/ol/Image.js
116
src/ol/Image.js
@@ -39,115 +39,115 @@ import {getHeight} from './extent.js';
|
||||
* @param {module:ol/Image~LoadFunction} imageLoadFunction Image load function.
|
||||
*/
|
||||
class ImageWrapper {
|
||||
constructor(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
|
||||
constructor(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
|
||||
|
||||
ImageBase.call(this, extent, resolution, pixelRatio, ImageState.IDLE);
|
||||
ImageBase.call(this, extent, resolution, pixelRatio, ImageState.IDLE);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.src_ = src;
|
||||
this.src_ = src;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement}
|
||||
*/
|
||||
this.image_ = new Image();
|
||||
if (crossOrigin !== null) {
|
||||
this.image_.crossOrigin = crossOrigin;
|
||||
}
|
||||
this.image_ = new Image();
|
||||
if (crossOrigin !== null) {
|
||||
this.image_.crossOrigin = crossOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<module:ol/events~EventsKey>}
|
||||
*/
|
||||
this.imageListenerKeys_ = null;
|
||||
this.imageListenerKeys_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:ol/ImageState}
|
||||
*/
|
||||
this.state = ImageState.IDLE;
|
||||
this.state = ImageState.IDLE;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/Image~LoadFunction}
|
||||
*/
|
||||
this.imageLoadFunction_ = imageLoadFunction;
|
||||
this.imageLoadFunction_ = imageLoadFunction;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @api
|
||||
*/
|
||||
getImage() {
|
||||
return this.image_;
|
||||
}
|
||||
getImage() {
|
||||
return this.image_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Tracks loading or read errors.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
handleImageError_() {
|
||||
this.state = ImageState.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
}
|
||||
handleImageError_() {
|
||||
this.state = ImageState.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Tracks successful image load.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
handleImageLoad_() {
|
||||
if (this.resolution === undefined) {
|
||||
this.resolution = getHeight(this.extent) / this.image_.height;
|
||||
}
|
||||
this.state = ImageState.LOADED;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
}
|
||||
handleImageLoad_() {
|
||||
if (this.resolution === undefined) {
|
||||
this.resolution = getHeight(this.extent) / this.image_.height;
|
||||
}
|
||||
this.state = ImageState.LOADED;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Load the image or retry if loading previously failed.
|
||||
* Loading is taken care of by the tile queue, and calling this method is
|
||||
* only needed for preloading or for reloading in case of an error.
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
load() {
|
||||
if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.imageLoadFunction_(this, this.src_);
|
||||
}
|
||||
}
|
||||
load() {
|
||||
if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.imageLoadFunction_(this, this.src_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
|
||||
*/
|
||||
setImage(image) {
|
||||
this.image_ = image;
|
||||
}
|
||||
setImage(image) {
|
||||
this.image_ = image;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Discards event handlers which listen for load completion or errors.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
unlistenImage_() {
|
||||
this.imageListenerKeys_.forEach(unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
}
|
||||
unlistenImage_() {
|
||||
this.imageListenerKeys_.forEach(unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(ImageWrapper, ImageBase);
|
||||
|
||||
@@ -15,82 +15,82 @@ import EventType from './events/EventType.js';
|
||||
* @param {module:ol/ImageState} state State.
|
||||
*/
|
||||
class ImageBase {
|
||||
constructor(extent, resolution, pixelRatio, state) {
|
||||
constructor(extent, resolution, pixelRatio, state) {
|
||||
|
||||
EventTarget.call(this);
|
||||
EventTarget.call(this);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
this.extent = extent;
|
||||
this.extent = extent;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.pixelRatio_ = pixelRatio;
|
||||
this.pixelRatio_ = pixelRatio;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.resolution = resolution;
|
||||
this.resolution = resolution;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:ol/ImageState}
|
||||
*/
|
||||
this.state = state;
|
||||
this.state = state;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
*/
|
||||
changed() {
|
||||
this.dispatchEvent(EventType.CHANGE);
|
||||
}
|
||||
changed() {
|
||||
this.dispatchEvent(EventType.CHANGE);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/extent~Extent} Extent.
|
||||
*/
|
||||
getExtent() {
|
||||
return this.extent;
|
||||
}
|
||||
getExtent() {
|
||||
return this.extent;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
|
||||
*/
|
||||
getImage() {}
|
||||
getImage() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} PixelRatio.
|
||||
*/
|
||||
getPixelRatio() {
|
||||
return this.pixelRatio_;
|
||||
}
|
||||
getPixelRatio() {
|
||||
return this.pixelRatio_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Resolution.
|
||||
*/
|
||||
getResolution() {
|
||||
return /** @type {number} */ (this.resolution);
|
||||
}
|
||||
getResolution() {
|
||||
return /** @type {number} */ (this.resolution);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/ImageState} State.
|
||||
*/
|
||||
getState() {
|
||||
return this.state;
|
||||
}
|
||||
getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Load not yet loaded URI.
|
||||
* @abstract
|
||||
*/
|
||||
load() {}
|
||||
load() {}
|
||||
}
|
||||
|
||||
inherits(ImageBase, EventTarget);
|
||||
|
||||
@@ -27,73 +27,73 @@ import ImageState from './ImageState.js';
|
||||
* support asynchronous canvas drawing.
|
||||
*/
|
||||
class ImageCanvas {
|
||||
constructor(extent, resolution, pixelRatio, canvas, opt_loader) {
|
||||
constructor(extent, resolution, pixelRatio, canvas, opt_loader) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Optional canvas loader function.
|
||||
* @type {?module:ol/ImageCanvas~Loader}
|
||||
* @private
|
||||
*/
|
||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||
|
||||
const state = opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
const state = opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
|
||||
ImageBase.call(this, extent, resolution, pixelRatio, state);
|
||||
ImageBase.call(this, extent, resolution, pixelRatio, state);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
this.canvas_ = canvas;
|
||||
this.canvas_ = canvas;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Error}
|
||||
*/
|
||||
this.error_ = null;
|
||||
this.error_ = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get any error associated with asynchronous rendering.
|
||||
* @return {Error} Any error that occurred during rendering.
|
||||
*/
|
||||
getError() {
|
||||
return this.error_;
|
||||
}
|
||||
getError() {
|
||||
return this.error_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handle async drawing complete.
|
||||
* @param {Error} err Any error during drawing.
|
||||
* @private
|
||||
*/
|
||||
handleLoad_(err) {
|
||||
if (err) {
|
||||
this.error_ = err;
|
||||
this.state = ImageState.ERROR;
|
||||
} else {
|
||||
this.state = ImageState.LOADED;
|
||||
}
|
||||
this.changed();
|
||||
}
|
||||
handleLoad_(err) {
|
||||
if (err) {
|
||||
this.error_ = err;
|
||||
this.state = ImageState.ERROR;
|
||||
} else {
|
||||
this.state = ImageState.LOADED;
|
||||
}
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
load() {
|
||||
if (this.state == ImageState.IDLE) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.loader_(this.handleLoad_.bind(this));
|
||||
}
|
||||
}
|
||||
load() {
|
||||
if (this.state == ImageState.IDLE) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.loader_(this.handleLoad_.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {HTMLCanvasElement} Canvas element.
|
||||
*/
|
||||
getImage() {
|
||||
return this.canvas_;
|
||||
}
|
||||
getImage() {
|
||||
return this.canvas_;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(ImageCanvas, ImageBase);
|
||||
|
||||
@@ -15,113 +15,113 @@
|
||||
* @api
|
||||
*/
|
||||
class Kinetic {
|
||||
constructor(decay, minVelocity, delay) {
|
||||
constructor(decay, minVelocity, delay) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.decay_ = decay;
|
||||
this.decay_ = decay;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.minVelocity_ = minVelocity;
|
||||
this.minVelocity_ = minVelocity;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.delay_ = delay;
|
||||
this.delay_ = delay;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.points_ = [];
|
||||
this.points_ = [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.angle_ = 0;
|
||||
this.angle_ = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.initialVelocity_ = 0;
|
||||
}
|
||||
this.initialVelocity_ = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
begin() {
|
||||
this.points_.length = 0;
|
||||
this.angle_ = 0;
|
||||
this.initialVelocity_ = 0;
|
||||
}
|
||||
begin() {
|
||||
this.points_.length = 0;
|
||||
this.angle_ = 0;
|
||||
this.initialVelocity_ = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
*/
|
||||
update(x, y) {
|
||||
this.points_.push(x, y, Date.now());
|
||||
}
|
||||
update(x, y) {
|
||||
this.points_.push(x, y, Date.now());
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {boolean} Whether we should do kinetic animation.
|
||||
*/
|
||||
end() {
|
||||
if (this.points_.length < 6) {
|
||||
// at least 2 points are required (i.e. there must be at least 6 elements
|
||||
// in the array)
|
||||
return false;
|
||||
}
|
||||
const delay = Date.now() - this.delay_;
|
||||
const lastIndex = this.points_.length - 3;
|
||||
if (this.points_[lastIndex + 2] < delay) {
|
||||
// the last tracked point is too old, which means that the user stopped
|
||||
// panning before releasing the map
|
||||
return false;
|
||||
}
|
||||
end() {
|
||||
if (this.points_.length < 6) {
|
||||
// at least 2 points are required (i.e. there must be at least 6 elements
|
||||
// in the array)
|
||||
return false;
|
||||
}
|
||||
const delay = Date.now() - this.delay_;
|
||||
const lastIndex = this.points_.length - 3;
|
||||
if (this.points_[lastIndex + 2] < delay) {
|
||||
// the last tracked point is too old, which means that the user stopped
|
||||
// panning before releasing the map
|
||||
return false;
|
||||
}
|
||||
|
||||
// get the first point which still falls into the delay time
|
||||
let firstIndex = lastIndex - 3;
|
||||
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
||||
firstIndex -= 3;
|
||||
}
|
||||
// get the first point which still falls into the delay time
|
||||
let firstIndex = lastIndex - 3;
|
||||
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
||||
firstIndex -= 3;
|
||||
}
|
||||
|
||||
const duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
||||
// we don't want a duration of 0 (divide by zero)
|
||||
// we also make sure the user panned for a duration of at least one frame
|
||||
// (1/60s) to compute sane displacement values
|
||||
if (duration < 1000 / 60) {
|
||||
return false;
|
||||
}
|
||||
const duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
||||
// we don't want a duration of 0 (divide by zero)
|
||||
// we also make sure the user panned for a duration of at least one frame
|
||||
// (1/60s) to compute sane displacement values
|
||||
if (duration < 1000 / 60) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const dx = this.points_[lastIndex] - this.points_[firstIndex];
|
||||
const dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
||||
this.angle_ = Math.atan2(dy, dx);
|
||||
this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / duration;
|
||||
return this.initialVelocity_ > this.minVelocity_;
|
||||
}
|
||||
const dx = this.points_[lastIndex] - this.points_[firstIndex];
|
||||
const dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
||||
this.angle_ = Math.atan2(dy, dx);
|
||||
this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / duration;
|
||||
return this.initialVelocity_ > this.minVelocity_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Total distance travelled (pixels).
|
||||
*/
|
||||
getDistance() {
|
||||
return (this.minVelocity_ - this.initialVelocity_) / this.decay_;
|
||||
}
|
||||
getDistance() {
|
||||
return (this.minVelocity_ - this.initialVelocity_) / this.decay_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Angle of the kinetic panning animation (radians).
|
||||
*/
|
||||
getAngle() {
|
||||
return this.angle_;
|
||||
}
|
||||
getAngle() {
|
||||
return this.angle_;
|
||||
}
|
||||
}
|
||||
|
||||
export default Kinetic;
|
||||
|
||||
@@ -18,64 +18,64 @@ import MapEvent from './MapEvent.js';
|
||||
* @param {?module:ol/PluggableMap~FrameState=} opt_frameState Frame state.
|
||||
*/
|
||||
class MapBrowserEvent {
|
||||
constructor(type, map, browserEvent, opt_dragging, opt_frameState) {
|
||||
constructor(type, map, browserEvent, opt_dragging, opt_frameState) {
|
||||
|
||||
MapEvent.call(this, type, map, opt_frameState);
|
||||
MapEvent.call(this, type, map, opt_frameState);
|
||||
|
||||
/**
|
||||
/**
|
||||
* The original browser event.
|
||||
* @const
|
||||
* @type {Event}
|
||||
* @api
|
||||
*/
|
||||
this.originalEvent = browserEvent;
|
||||
this.originalEvent = browserEvent;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The map pixel relative to the viewport corresponding to the original browser event.
|
||||
* @type {module:ol~Pixel}
|
||||
* @api
|
||||
*/
|
||||
this.pixel = map.getEventPixel(browserEvent);
|
||||
this.pixel = map.getEventPixel(browserEvent);
|
||||
|
||||
/**
|
||||
/**
|
||||
* The coordinate in view projection corresponding to the original browser event.
|
||||
* @type {module:ol/coordinate~Coordinate}
|
||||
* @api
|
||||
*/
|
||||
this.coordinate = map.getCoordinateFromPixel(this.pixel);
|
||||
this.coordinate = map.getCoordinateFromPixel(this.pixel);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Indicates if the map is currently being dragged. Only set for
|
||||
* `POINTERDRAG` and `POINTERMOVE` events. Default is `false`.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @api
|
||||
*/
|
||||
this.dragging = opt_dragging !== undefined ? opt_dragging : false;
|
||||
this.dragging = opt_dragging !== undefined ? opt_dragging : false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Prevents the default browser action.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
preventDefault() {
|
||||
MapEvent.prototype.preventDefault.call(this);
|
||||
this.originalEvent.preventDefault();
|
||||
}
|
||||
preventDefault() {
|
||||
MapEvent.prototype.preventDefault.call(this);
|
||||
this.originalEvent.preventDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Prevents further propagation of the current event.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
stopPropagation() {
|
||||
MapEvent.prototype.stopPropagation.call(this);
|
||||
this.originalEvent.stopPropagation();
|
||||
}
|
||||
stopPropagation() {
|
||||
MapEvent.prototype.stopPropagation.call(this);
|
||||
this.originalEvent.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MapBrowserEvent, MapEvent);
|
||||
|
||||
@@ -13,114 +13,114 @@
|
||||
* @struct
|
||||
*/
|
||||
class TileRange {
|
||||
constructor(minX, maxX, minY, maxY) {
|
||||
constructor(minX, maxX, minY, maxY) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minX = minX;
|
||||
this.minX = minX;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxX = maxX;
|
||||
this.maxX = maxX;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minY = minY;
|
||||
this.minY = minY;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxY = maxY;
|
||||
this.maxY = maxY;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/tilecoord~TileCoord} tileCoord Tile coordinate.
|
||||
* @return {boolean} Contains tile coordinate.
|
||||
*/
|
||||
contains(tileCoord) {
|
||||
return this.containsXY(tileCoord[1], tileCoord[2]);
|
||||
}
|
||||
contains(tileCoord) {
|
||||
return this.containsXY(tileCoord[1], tileCoord[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/TileRange} tileRange Tile range.
|
||||
* @return {boolean} Contains.
|
||||
*/
|
||||
containsTileRange(tileRange) {
|
||||
return this.minX <= tileRange.minX && tileRange.maxX <= this.maxX &&
|
||||
containsTileRange(tileRange) {
|
||||
return this.minX <= tileRange.minX && tileRange.maxX <= this.maxX &&
|
||||
this.minY <= tileRange.minY && tileRange.maxY <= this.maxY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {number} x Tile coordinate x.
|
||||
* @param {number} y Tile coordinate y.
|
||||
* @return {boolean} Contains coordinate.
|
||||
*/
|
||||
containsXY(x, y) {
|
||||
return this.minX <= x && x <= this.maxX && this.minY <= y && y <= this.maxY;
|
||||
}
|
||||
containsXY(x, y) {
|
||||
return this.minX <= x && x <= this.maxX && this.minY <= y && y <= this.maxY;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/TileRange} tileRange Tile range.
|
||||
* @return {boolean} Equals.
|
||||
*/
|
||||
equals(tileRange) {
|
||||
return this.minX == tileRange.minX && this.minY == tileRange.minY &&
|
||||
equals(tileRange) {
|
||||
return this.minX == tileRange.minX && this.minY == tileRange.minY &&
|
||||
this.maxX == tileRange.maxX && this.maxY == tileRange.maxY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/TileRange} tileRange Tile range.
|
||||
*/
|
||||
extend(tileRange) {
|
||||
if (tileRange.minX < this.minX) {
|
||||
this.minX = tileRange.minX;
|
||||
}
|
||||
if (tileRange.maxX > this.maxX) {
|
||||
this.maxX = tileRange.maxX;
|
||||
}
|
||||
if (tileRange.minY < this.minY) {
|
||||
this.minY = tileRange.minY;
|
||||
}
|
||||
if (tileRange.maxY > this.maxY) {
|
||||
this.maxY = tileRange.maxY;
|
||||
}
|
||||
}
|
||||
extend(tileRange) {
|
||||
if (tileRange.minX < this.minX) {
|
||||
this.minX = tileRange.minX;
|
||||
}
|
||||
if (tileRange.maxX > this.maxX) {
|
||||
this.maxX = tileRange.maxX;
|
||||
}
|
||||
if (tileRange.minY < this.minY) {
|
||||
this.minY = tileRange.minY;
|
||||
}
|
||||
if (tileRange.maxY > this.maxY) {
|
||||
this.maxY = tileRange.maxY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Height.
|
||||
*/
|
||||
getHeight() {
|
||||
return this.maxY - this.minY + 1;
|
||||
}
|
||||
getHeight() {
|
||||
return this.maxY - this.minY + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/size~Size} Size.
|
||||
*/
|
||||
getSize() {
|
||||
return [this.getWidth(), this.getHeight()];
|
||||
}
|
||||
getSize() {
|
||||
return [this.getWidth(), this.getHeight()];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Width.
|
||||
*/
|
||||
getWidth() {
|
||||
return this.maxX - this.minX + 1;
|
||||
}
|
||||
getWidth() {
|
||||
return this.maxX - this.minX + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/TileRange} tileRange Tile range.
|
||||
* @return {boolean} Intersects.
|
||||
*/
|
||||
intersects(tileRange) {
|
||||
return this.minX <= tileRange.maxX &&
|
||||
intersects(tileRange) {
|
||||
return this.minX <= tileRange.maxX &&
|
||||
this.maxX >= tileRange.minX &&
|
||||
this.minY <= tileRange.maxY &&
|
||||
this.maxY >= tileRange.minY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,13 @@ import {getUid, inherits} from './util.js';
|
||||
import Tile from './Tile.js';
|
||||
import TileState from './TileState.js';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
const DEFAULT_EXTENT = [0, 0, 4096, 4096];
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function(new: module:ol/VectorTile, module:ol/tilecoord~TileCoord,
|
||||
* module:ol/TileState, string, ?string, module:ol/Tile~LoadFunction)} TileClass
|
||||
@@ -22,162 +29,162 @@ import TileState from './TileState.js';
|
||||
* @param {module:ol/Tile~Options=} opt_options Tile options.
|
||||
*/
|
||||
class VectorTile {
|
||||
constructor(tileCoord, state, src, format, tileLoadFunction, opt_options) {
|
||||
constructor(tileCoord, state, src, format, tileLoadFunction, opt_options) {
|
||||
|
||||
Tile.call(this, tileCoord, state, opt_options);
|
||||
Tile.call(this, tileCoord, state, opt_options);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.consumers = 0;
|
||||
this.consumers = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
this.extent_ = null;
|
||||
this.extent_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/format/Feature}
|
||||
*/
|
||||
this.format_ = format;
|
||||
this.format_ = format;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<module:ol/Feature>}
|
||||
*/
|
||||
this.features_ = null;
|
||||
this.features_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/featureloader~FeatureLoader}
|
||||
*/
|
||||
this.loader_;
|
||||
this.loader_;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Data projection
|
||||
* @private
|
||||
* @type {module:ol/proj/Projection}
|
||||
*/
|
||||
this.projection_ = null;
|
||||
this.projection_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Object.<string, module:ol/render/ReplayGroup>}
|
||||
*/
|
||||
this.replayGroups_ = {};
|
||||
this.replayGroups_ = {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/Tile~LoadFunction}
|
||||
*/
|
||||
this.tileLoadFunction_ = tileLoadFunction;
|
||||
this.tileLoadFunction_ = tileLoadFunction;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.url_ = src;
|
||||
this.url_ = src;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
this.features_ = null;
|
||||
this.replayGroups_ = {};
|
||||
this.state = TileState.ABORT;
|
||||
this.changed();
|
||||
Tile.prototype.disposeInternal.call(this);
|
||||
}
|
||||
disposeInternal() {
|
||||
this.features_ = null;
|
||||
this.replayGroups_ = {};
|
||||
this.state = TileState.ABORT;
|
||||
this.changed();
|
||||
Tile.prototype.disposeInternal.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Gets the extent of the vector tile.
|
||||
* @return {module:ol/extent~Extent} The extent.
|
||||
* @api
|
||||
*/
|
||||
getExtent() {
|
||||
return this.extent_ || DEFAULT_EXTENT;
|
||||
}
|
||||
getExtent() {
|
||||
return this.extent_ || DEFAULT_EXTENT;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the feature format assigned for reading this tile's features.
|
||||
* @return {module:ol/format/Feature} Feature format.
|
||||
* @api
|
||||
*/
|
||||
getFormat() {
|
||||
return this.format_;
|
||||
}
|
||||
getFormat() {
|
||||
return this.format_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the features for this tile. Geometries will be in the projection returned
|
||||
* by {@link module:ol/VectorTile~VectorTile#getProjection}.
|
||||
* @return {Array.<module:ol/Feature|module:ol/render/Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
getFeatures() {
|
||||
return this.features_;
|
||||
}
|
||||
getFeatures() {
|
||||
return this.features_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getKey() {
|
||||
return this.url_;
|
||||
}
|
||||
getKey() {
|
||||
return this.url_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the feature projection of features returned by
|
||||
* {@link module:ol/VectorTile~VectorTile#getFeatures}.
|
||||
* @return {module:ol/proj/Projection} Feature projection.
|
||||
* @api
|
||||
*/
|
||||
getProjection() {
|
||||
return this.projection_;
|
||||
}
|
||||
getProjection() {
|
||||
return this.projection_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/layer/Layer} layer Layer.
|
||||
* @param {string} key Key.
|
||||
* @return {module:ol/render/ReplayGroup} Replay group.
|
||||
*/
|
||||
getReplayGroup(layer, key) {
|
||||
return this.replayGroups_[getUid(layer) + ',' + key];
|
||||
}
|
||||
getReplayGroup(layer, key) {
|
||||
return this.replayGroups_[getUid(layer) + ',' + key];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
load() {
|
||||
if (this.state == TileState.IDLE) {
|
||||
this.setState(TileState.LOADING);
|
||||
this.tileLoadFunction_(this, this.url_);
|
||||
this.loader_(null, NaN, null);
|
||||
}
|
||||
}
|
||||
load() {
|
||||
if (this.state == TileState.IDLE) {
|
||||
this.setState(TileState.LOADING);
|
||||
this.tileLoadFunction_(this, this.url_);
|
||||
this.loader_(null, NaN, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for successful tile load.
|
||||
* @param {Array.<module:ol/Feature>} features The loaded features.
|
||||
* @param {module:ol/proj/Projection} dataProjection Data projection.
|
||||
* @param {module:ol/extent~Extent} extent Extent.
|
||||
*/
|
||||
onLoad(features, dataProjection, extent) {
|
||||
this.setProjection(dataProjection);
|
||||
this.setFeatures(features);
|
||||
this.setExtent(extent);
|
||||
}
|
||||
onLoad(features, dataProjection, extent) {
|
||||
this.setProjection(dataProjection);
|
||||
this.setFeatures(features);
|
||||
this.setExtent(extent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for tile load errors.
|
||||
*/
|
||||
onError() {
|
||||
this.setState(TileState.ERROR);
|
||||
}
|
||||
onError() {
|
||||
this.setState(TileState.ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Function for use in an {@link module:ol/source/VectorTile~VectorTile}'s
|
||||
* `tileLoadFunction`. Sets the extent of the vector tile. This is only required
|
||||
* for tiles in projections with `tile-pixels` as units. The extent should be
|
||||
@@ -189,58 +196,51 @@ class VectorTile {
|
||||
* @param {module:ol/extent~Extent} extent The extent.
|
||||
* @api
|
||||
*/
|
||||
setExtent(extent) {
|
||||
this.extent_ = extent;
|
||||
}
|
||||
setExtent(extent) {
|
||||
this.extent_ = extent;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Function for use in an {@link module:ol/source/VectorTile~VectorTile}'s `tileLoadFunction`.
|
||||
* Sets the features for the tile.
|
||||
* @param {Array.<module:ol/Feature>} features Features.
|
||||
* @api
|
||||
*/
|
||||
setFeatures(features) {
|
||||
this.features_ = features;
|
||||
this.setState(TileState.LOADED);
|
||||
}
|
||||
setFeatures(features) {
|
||||
this.features_ = features;
|
||||
this.setState(TileState.LOADED);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Function for use in an {@link module:ol/source/VectorTile~VectorTile}'s `tileLoadFunction`.
|
||||
* Sets the projection of the features that were added with
|
||||
* {@link module:ol/VectorTile~VectorTile#setFeatures}.
|
||||
* @param {module:ol/proj/Projection} projection Feature projection.
|
||||
* @api
|
||||
*/
|
||||
setProjection(projection) {
|
||||
this.projection_ = projection;
|
||||
}
|
||||
setProjection(projection) {
|
||||
this.projection_ = projection;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/layer/Layer} layer Layer.
|
||||
* @param {string} key Key.
|
||||
* @param {module:ol/render/ReplayGroup} replayGroup Replay group.
|
||||
*/
|
||||
setReplayGroup(layer, key, replayGroup) {
|
||||
this.replayGroups_[getUid(layer) + ',' + key] = replayGroup;
|
||||
}
|
||||
setReplayGroup(layer, key, replayGroup) {
|
||||
this.replayGroups_[getUid(layer) + ',' + key] = replayGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the feature loader for reading this tile's features.
|
||||
* @param {module:ol/featureloader~FeatureLoader} loader Feature loader.
|
||||
* @api
|
||||
*/
|
||||
setLoader(loader) {
|
||||
this.loader_ = loader;
|
||||
}
|
||||
setLoader(loader) {
|
||||
this.loader_ = loader;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(VectorTile, Tile);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
const DEFAULT_EXTENT = [0, 0, 4096, 4096];
|
||||
|
||||
|
||||
export default VectorTile;
|
||||
|
||||
@@ -50,91 +50,91 @@ import {listen, unlistenByKey} from '../events.js';
|
||||
* @api
|
||||
*/
|
||||
class Control {
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
BaseObject.call(this);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {Element}
|
||||
*/
|
||||
this.element = options.element ? options.element : null;
|
||||
this.element = options.element ? options.element : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
this.target_ = null;
|
||||
this.target_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/PluggableMap}
|
||||
*/
|
||||
this.map_ = null;
|
||||
this.map_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {!Array.<module:ol/events~EventsKey>}
|
||||
*/
|
||||
this.listenerKeys = [];
|
||||
this.listenerKeys = [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {function(module:ol/MapEvent)}
|
||||
*/
|
||||
this.render = options.render ? options.render : UNDEFINED;
|
||||
this.render = options.render ? options.render : UNDEFINED;
|
||||
|
||||
if (options.target) {
|
||||
this.setTarget(options.target);
|
||||
}
|
||||
if (options.target) {
|
||||
this.setTarget(options.target);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
removeNode(this.element);
|
||||
BaseObject.prototype.disposeInternal.call(this);
|
||||
}
|
||||
disposeInternal() {
|
||||
removeNode(this.element);
|
||||
BaseObject.prototype.disposeInternal.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the map associated with this control.
|
||||
* @return {module:ol/PluggableMap} Map.
|
||||
* @api
|
||||
*/
|
||||
getMap() {
|
||||
return this.map_;
|
||||
}
|
||||
getMap() {
|
||||
return this.map_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Remove the control from its current map and attach it to the new map.
|
||||
* Subclasses may set up event handlers to get notified about changes to
|
||||
* the map here.
|
||||
* @param {module:ol/PluggableMap} map Map.
|
||||
* @api
|
||||
*/
|
||||
setMap(map) {
|
||||
if (this.map_) {
|
||||
removeNode(this.element);
|
||||
}
|
||||
for (let i = 0, ii = this.listenerKeys.length; i < ii; ++i) {
|
||||
unlistenByKey(this.listenerKeys[i]);
|
||||
}
|
||||
this.listenerKeys.length = 0;
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
const target = this.target_ ?
|
||||
this.target_ : map.getOverlayContainerStopEvent();
|
||||
target.appendChild(this.element);
|
||||
if (this.render !== UNDEFINED) {
|
||||
this.listenerKeys.push(listen(map,
|
||||
MapEventType.POSTRENDER, this.render, this));
|
||||
}
|
||||
map.render();
|
||||
}
|
||||
}
|
||||
setMap(map) {
|
||||
if (this.map_) {
|
||||
removeNode(this.element);
|
||||
}
|
||||
for (let i = 0, ii = this.listenerKeys.length; i < ii; ++i) {
|
||||
unlistenByKey(this.listenerKeys[i]);
|
||||
}
|
||||
this.listenerKeys.length = 0;
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
const target = this.target_ ?
|
||||
this.target_ : map.getOverlayContainerStopEvent();
|
||||
target.appendChild(this.element);
|
||||
if (this.render !== UNDEFINED) {
|
||||
this.listenerKeys.push(listen(map,
|
||||
MapEventType.POSTRENDER, this.render, this));
|
||||
}
|
||||
map.render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This function is used to set a target element for the control. It has no
|
||||
* effect if it is called after the control has been added to the map (i.e.
|
||||
* after `setMap` is called on the control). If no `target` is set in the
|
||||
@@ -143,11 +143,11 @@ class Control {
|
||||
* @param {Element|string} target Target.
|
||||
* @api
|
||||
*/
|
||||
setTarget(target) {
|
||||
this.target_ = typeof target === 'string' ?
|
||||
document.getElementById(target) :
|
||||
target;
|
||||
}
|
||||
setTarget(target) {
|
||||
this.target_ = typeof target === 'string' ?
|
||||
document.getElementById(target) :
|
||||
target;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Control, BaseObject);
|
||||
|
||||
@@ -32,57 +32,57 @@ import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
* @api
|
||||
*/
|
||||
class ZoomToExtent {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {module:ol/extent~Extent}
|
||||
* @protected
|
||||
*/
|
||||
this.extent = options.extent ? options.extent : null;
|
||||
this.extent = options.extent ? options.extent : null;
|
||||
|
||||
const className = options.className !== undefined ? options.className : 'ol-zoom-extent';
|
||||
const className = options.className !== undefined ? options.className : 'ol-zoom-extent';
|
||||
|
||||
const label = options.label !== undefined ? options.label : 'E';
|
||||
const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Fit to extent';
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(
|
||||
typeof label === 'string' ? document.createTextNode(label) : label
|
||||
);
|
||||
const label = options.label !== undefined ? options.label : 'E';
|
||||
const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Fit to extent';
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(
|
||||
typeof label === 'string' ? document.createTextNode(label) : label
|
||||
);
|
||||
|
||||
listen(button, EventType.CLICK, this.handleClick_, this);
|
||||
listen(button, EventType.CLICK, this.handleClick_, this);
|
||||
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(button);
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(button);
|
||||
|
||||
Control.call(this, {
|
||||
element: element,
|
||||
target: options.target
|
||||
});
|
||||
}
|
||||
Control.call(this, {
|
||||
element: element,
|
||||
target: options.target
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {MouseEvent} event The event to handle
|
||||
* @private
|
||||
*/
|
||||
handleClick_(event) {
|
||||
event.preventDefault();
|
||||
this.handleZoomToExtent();
|
||||
}
|
||||
handleClick_(event) {
|
||||
event.preventDefault();
|
||||
this.handleZoomToExtent();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
*/
|
||||
handleZoomToExtent() {
|
||||
const map = this.getMap();
|
||||
const view = map.getView();
|
||||
const extent = !this.extent ? view.getProjection().getExtent() : this.extent;
|
||||
view.fit(extent);
|
||||
}
|
||||
handleZoomToExtent() {
|
||||
const map = this.getMap();
|
||||
const view = map.getView();
|
||||
const extent = !this.extent ? view.getProjection().getExtent() : this.extent;
|
||||
view.fit(extent);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(ZoomToExtent, Control);
|
||||
|
||||
@@ -61,42 +61,42 @@ import {get as getProjection, equivalent as equivalentProjection, transformExten
|
||||
* @api
|
||||
*/
|
||||
class FeatureFormat {
|
||||
constructor() {
|
||||
constructor() {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:ol/proj/Projection}
|
||||
*/
|
||||
this.dataProjection = null;
|
||||
this.dataProjection = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:ol/proj/Projection}
|
||||
*/
|
||||
this.defaultFeatureProjection = null;
|
||||
this.defaultFeatureProjection = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Adds the data projection to the read options.
|
||||
* @param {Document|Node|Object|string} source Source.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Options.
|
||||
* @return {module:ol/format/Feature~ReadOptions|undefined} Options.
|
||||
* @protected
|
||||
*/
|
||||
getReadOptions(source, opt_options) {
|
||||
let options;
|
||||
if (opt_options) {
|
||||
options = {
|
||||
dataProjection: opt_options.dataProjection ?
|
||||
opt_options.dataProjection : this.readProjection(source),
|
||||
featureProjection: opt_options.featureProjection
|
||||
};
|
||||
}
|
||||
return this.adaptOptions(options);
|
||||
}
|
||||
getReadOptions(source, opt_options) {
|
||||
let options;
|
||||
if (opt_options) {
|
||||
options = {
|
||||
dataProjection: opt_options.dataProjection ?
|
||||
opt_options.dataProjection : this.readProjection(source),
|
||||
featureProjection: opt_options.featureProjection
|
||||
};
|
||||
}
|
||||
return this.adaptOptions(options);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the `dataProjection` on the options, if no `dataProjection`
|
||||
* is set.
|
||||
* @param {module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions|undefined} options
|
||||
@@ -105,28 +105,28 @@ class FeatureFormat {
|
||||
* @return {module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions|undefined}
|
||||
* Updated options.
|
||||
*/
|
||||
adaptOptions(options) {
|
||||
return assign({
|
||||
dataProjection: this.dataProjection,
|
||||
featureProjection: this.defaultFeatureProjection
|
||||
}, options);
|
||||
}
|
||||
adaptOptions(options) {
|
||||
return assign({
|
||||
dataProjection: this.dataProjection,
|
||||
featureProjection: this.defaultFeatureProjection
|
||||
}, options);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the extent from the source of the last {@link readFeatures} call.
|
||||
* @return {module:ol/extent~Extent} Tile extent.
|
||||
*/
|
||||
getLastExtent() {
|
||||
return null;
|
||||
}
|
||||
getLastExtent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {module:ol/format/FormatType} Format.
|
||||
*/
|
||||
getType() {}
|
||||
getType() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Read a single feature from a source.
|
||||
*
|
||||
* @abstract
|
||||
@@ -134,9 +134,9 @@ class FeatureFormat {
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @return {module:ol/Feature} Feature.
|
||||
*/
|
||||
readFeature(source, opt_options) {}
|
||||
readFeature(source, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Read all features from a source.
|
||||
*
|
||||
* @abstract
|
||||
@@ -144,9 +144,9 @@ class FeatureFormat {
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<module:ol/Feature>} Features.
|
||||
*/
|
||||
readFeatures(source, opt_options) {}
|
||||
readFeatures(source, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Read a single geometry from a source.
|
||||
*
|
||||
* @abstract
|
||||
@@ -154,18 +154,18 @@ class FeatureFormat {
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @return {module:ol/geom/Geometry} Geometry.
|
||||
*/
|
||||
readGeometry(source, opt_options) {}
|
||||
readGeometry(source, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Read the projection from a source.
|
||||
*
|
||||
* @abstract
|
||||
* @param {Document|Node|Object|string} source Source.
|
||||
* @return {module:ol/proj/Projection} Projection.
|
||||
*/
|
||||
readProjection(source) {}
|
||||
readProjection(source) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Encode a feature in this format.
|
||||
*
|
||||
* @abstract
|
||||
@@ -173,9 +173,9 @@ class FeatureFormat {
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {string} Result.
|
||||
*/
|
||||
writeFeature(feature, opt_options) {}
|
||||
writeFeature(feature, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Encode an array of features in this format.
|
||||
*
|
||||
* @abstract
|
||||
@@ -183,9 +183,9 @@ class FeatureFormat {
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {string} Result.
|
||||
*/
|
||||
writeFeatures(features, opt_options) {}
|
||||
writeFeatures(features, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Write a single geometry in this format.
|
||||
*
|
||||
* @abstract
|
||||
@@ -193,7 +193,7 @@ class FeatureFormat {
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {string} Result.
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {}
|
||||
writeGeometry(geometry, opt_options) {}
|
||||
}
|
||||
|
||||
export default FeatureFormat;
|
||||
|
||||
@@ -20,6 +20,18 @@ import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
|
||||
const schemaLocation = GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, string>}
|
||||
*/
|
||||
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
|
||||
'MultiLineString': 'lineStringMember',
|
||||
'MultiCurve': 'curveMember',
|
||||
'MultiPolygon': 'polygonMember',
|
||||
'MultiSurface': 'surfaceMember'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Feature format for reading and writing data in the GML format,
|
||||
@@ -576,18 +588,6 @@ class GML2 {
|
||||
inherits(GML2, GMLBase);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, string>}
|
||||
*/
|
||||
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
|
||||
'MultiLineString': 'lineStringMember',
|
||||
'MultiCurve': 'curveMember',
|
||||
'MultiPolygon': 'polygonMember',
|
||||
'MultiSurface': 'surfaceMember'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
|
||||
@@ -30,6 +30,18 @@ const schemaLocation = GMLNS +
|
||||
'1.0.0/gmlsf.xsd';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, string>}
|
||||
*/
|
||||
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
|
||||
'MultiLineString': 'lineStringMember',
|
||||
'MultiCurve': 'curveMember',
|
||||
'MultiPolygon': 'polygonMember',
|
||||
'MultiSurface': 'surfaceMember'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Feature format for reading and writing data in the GML format
|
||||
@@ -1088,18 +1100,6 @@ GML3.prototype.SEGMENTS_PARSERS_ = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, string>}
|
||||
*/
|
||||
const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
|
||||
'MultiLineString': 'lineStringMember',
|
||||
'MultiCurve': 'curveMember',
|
||||
'MultiPolygon': 'polygonMember',
|
||||
'MultiSurface': 'surfaceMember'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Encode an array of features in GML 3.1.1 Simple Features.
|
||||
*
|
||||
|
||||
@@ -29,6 +29,20 @@ import {getAllTextContent, getAttributeNS, makeArrayPusher, makeReplacer, parseN
|
||||
export const GMLNS = 'http://www.opengis.net/gml';
|
||||
|
||||
|
||||
/**
|
||||
* A regular expression that matches if a string only contains whitespace
|
||||
* characters. It will e.g. match `''`, `' '`, `'\n'` etc. The non-breaking
|
||||
* space (0xa0) is explicitly included as IE doesn't include it in its
|
||||
* definition of `\s`.
|
||||
*
|
||||
* Information from `goog.string.isEmptyOrWhitespace`: https://github.com/google/closure-library/blob/e877b1e/closure/goog/string/string.js#L156-L160
|
||||
*
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {Object.<string, string>|string} [featureNS] Feature
|
||||
@@ -458,20 +472,6 @@ class GMLBase {
|
||||
inherits(GMLBase, XMLFeature);
|
||||
|
||||
|
||||
/**
|
||||
* A regular expression that matches if a string only contains whitespace
|
||||
* characters. It will e.g. match `''`, `' '`, `'\n'` etc. The non-breaking
|
||||
* space (0xa0) is explicitly included as IE doesn't include it in its
|
||||
* definition of `\s`.
|
||||
*
|
||||
* Information from `goog.string.isEmptyOrWhitespace`: https://github.com/google/closure-library/blob/e877b1e/closure/goog/string/string.js#L156-L160
|
||||
*
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
|
||||
@@ -18,6 +18,71 @@ import {createElementNS, makeArrayPusher, makeArraySerializer, makeChildAppender
|
||||
XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.topografix.com/GPX/1/0',
|
||||
'http://www.topografix.com/GPX/1/1'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
|
||||
'http://www.topografix.com/GPX/1/1/gpx.xsd';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, function(Node, Array.<*>): (module:ol/Feature|undefined)>}
|
||||
*/
|
||||
const FEATURE_READER = {
|
||||
'rte': readRte,
|
||||
'trk': readTrk,
|
||||
'wpt': readWpt
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const GPX_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'rte': makeArrayPusher(readRte),
|
||||
'trk': makeArrayPusher(readTrk),
|
||||
'wpt': makeArrayPusher(readWpt)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const LINK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'text': makeObjectPropertySetter(readString, 'linkText'),
|
||||
'type': makeObjectPropertySetter(readString, 'linkType')
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const GPX_SERIALIZERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'rte': makeChildAppender(writeRte),
|
||||
'trk': makeChildAppender(writeTrk),
|
||||
'wpt': makeChildAppender(writeWpt)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {function(module:ol/Feature, Node)} [readExtensions] Callback function
|
||||
@@ -150,59 +215,6 @@ class GPX {
|
||||
inherits(GPX, XMLFeature);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.topografix.com/GPX/1/0',
|
||||
'http://www.topografix.com/GPX/1/1'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
|
||||
'http://www.topografix.com/GPX/1/1/gpx.xsd';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, function(Node, Array.<*>): (module:ol/Feature|undefined)>}
|
||||
*/
|
||||
const FEATURE_READER = {
|
||||
'rte': readRte,
|
||||
'trk': readTrk,
|
||||
'wpt': readWpt
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const GPX_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'rte': makeArrayPusher(readRte),
|
||||
'trk': makeArrayPusher(readTrk),
|
||||
'wpt': makeArrayPusher(readWpt)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const LINK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'text': makeObjectPropertySetter(readString, 'linkText'),
|
||||
'type': makeObjectPropertySetter(readString, 'linkType')
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
@@ -466,18 +478,6 @@ function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const GPX_SERIALIZERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'rte': makeChildAppender(writeRte),
|
||||
'trk': makeChildAppender(writeTrk),
|
||||
'wpt': makeChildAppender(writeWpt)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||
* @param {module:ol/format/GPX~LayoutOptions} layoutOptions Layout options.
|
||||
|
||||
@@ -19,6 +19,36 @@ const IGCZ = {
|
||||
NONE: 'none'
|
||||
};
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const B_RECORD_RE =
|
||||
/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
|
||||
|
||||
|
||||
/**
|
||||
* A regular expression matching the newline characters `\r\n`, `\r` and `\n`.
|
||||
*
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const NEWLINE_RE = /\r\n|\r|\n/;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
@@ -170,37 +200,6 @@ class IGC {
|
||||
inherits(IGC, TextFeature);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const B_RECORD_RE =
|
||||
/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
|
||||
|
||||
|
||||
/**
|
||||
* A regular expression matching the newline characters `\r\n`, `\r` and `\n`.
|
||||
*
|
||||
* @const
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const NEWLINE_RE = /\r\n|\r|\n/;
|
||||
|
||||
|
||||
/**
|
||||
* Read the feature from the IGC source.
|
||||
*
|
||||
|
||||
@@ -16,127 +16,127 @@ import FormatType from '../format/FormatType.js';
|
||||
* @extends {module:ol/format/Feature}
|
||||
*/
|
||||
class JSONFeature {
|
||||
constructor() {
|
||||
FeatureFormat.call(this);
|
||||
}
|
||||
constructor() {
|
||||
FeatureFormat.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getType() {
|
||||
return FormatType.JSON;
|
||||
}
|
||||
getType() {
|
||||
return FormatType.JSON;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
return this.readFeatureFromObject(
|
||||
getObject(source), this.getReadOptions(source, opt_options));
|
||||
}
|
||||
readFeature(source, opt_options) {
|
||||
return this.readFeatureFromObject(
|
||||
getObject(source), this.getReadOptions(source, opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
return this.readFeaturesFromObject(
|
||||
getObject(source), this.getReadOptions(source, opt_options));
|
||||
}
|
||||
readFeatures(source, opt_options) {
|
||||
return this.readFeaturesFromObject(
|
||||
getObject(source), this.getReadOptions(source, opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {module:ol/Feature} Feature.
|
||||
*/
|
||||
readFeatureFromObject(object, opt_options) {}
|
||||
readFeatureFromObject(object, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {Array.<module:ol/Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromObject(object, opt_options) {}
|
||||
readFeaturesFromObject(object, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
return this.readGeometryFromObject(
|
||||
getObject(source), this.getReadOptions(source, opt_options));
|
||||
}
|
||||
readGeometry(source, opt_options) {
|
||||
return this.readGeometryFromObject(
|
||||
getObject(source), this.getReadOptions(source, opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {module:ol/geom/Geometry} Geometry.
|
||||
*/
|
||||
readGeometryFromObject(object, opt_options) {}
|
||||
readGeometryFromObject(object, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readProjection(source) {
|
||||
return this.readProjectionFromObject(getObject(source));
|
||||
}
|
||||
readProjection(source) {
|
||||
return this.readProjectionFromObject(getObject(source));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @protected
|
||||
* @return {module:ol/proj/Projection} Projection.
|
||||
*/
|
||||
readProjectionFromObject(object) {}
|
||||
readProjectionFromObject(object) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
return JSON.stringify(this.writeFeatureObject(feature, opt_options));
|
||||
}
|
||||
writeFeature(feature, opt_options) {
|
||||
return JSON.stringify(this.writeFeatureObject(feature, opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/Feature} feature Feature.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
writeFeatureObject(feature, opt_options) {}
|
||||
writeFeatureObject(feature, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
return JSON.stringify(this.writeFeaturesObject(features, opt_options));
|
||||
}
|
||||
writeFeatures(features, opt_options) {
|
||||
return JSON.stringify(this.writeFeaturesObject(features, opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array.<module:ol/Feature>} features Features.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
writeFeaturesObject(features, opt_options) {}
|
||||
writeFeaturesObject(features, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
return JSON.stringify(this.writeGeometryObject(geometry, opt_options));
|
||||
}
|
||||
writeGeometry(geometry, opt_options) {
|
||||
return JSON.stringify(this.writeGeometryObject(geometry, opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/geom/Geometry} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
writeGeometryObject(geometry, opt_options) {}
|
||||
writeGeometryObject(geometry, opt_options) {}
|
||||
}
|
||||
|
||||
inherits(JSONFeature, FeatureFormat);
|
||||
|
||||
@@ -48,6 +48,143 @@ import {createElementNS, getAllTextContent, isDocument, isNode, makeArrayExtende
|
||||
* @property {Array.<number>} whens
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
const GX_NAMESPACE_URIS = [
|
||||
'http://www.google.com/kml/ext/2.2'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://earth.google.com/kml/2.0',
|
||||
'http://earth.google.com/kml/2.1',
|
||||
'http://earth.google.com/kml/2.2',
|
||||
'http://www.opengis.net/kml/2.2'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const SCHEMA_LOCATION = 'http://www.opengis.net/kml/2.2 ' +
|
||||
'https://developers.google.com/kml/schema/kml22gx.xsd';
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, module:ol/style/IconAnchorUnits>}
|
||||
*/
|
||||
const ICON_ANCHOR_UNITS_MAP = {
|
||||
'fraction': IconAnchorUnits.FRACTION,
|
||||
'pixels': IconAnchorUnits.PIXELS,
|
||||
'insetPixels': IconAnchorUnits.PIXELS
|
||||
};
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PLACEMARK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ExtendedData': extendedDataParser,
|
||||
'Region': regionParser,
|
||||
'MultiGeometry': makeObjectPropertySetter(
|
||||
readMultiGeometry, 'geometry'),
|
||||
'LineString': makeObjectPropertySetter(
|
||||
readLineString, 'geometry'),
|
||||
'LinearRing': makeObjectPropertySetter(
|
||||
readLinearRing, 'geometry'),
|
||||
'Point': makeObjectPropertySetter(
|
||||
readPoint, 'geometry'),
|
||||
'Polygon': makeObjectPropertySetter(
|
||||
readPolygon, 'geometry'),
|
||||
'Style': makeObjectPropertySetter(readStyle),
|
||||
'StyleMap': placemarkStyleMapParser,
|
||||
'address': makeObjectPropertySetter(readString),
|
||||
'description': makeObjectPropertySetter(readString),
|
||||
'name': makeObjectPropertySetter(readString),
|
||||
'open': makeObjectPropertySetter(readBoolean),
|
||||
'phoneNumber': makeObjectPropertySetter(readString),
|
||||
'styleUrl': makeObjectPropertySetter(readURI),
|
||||
'visibility': makeObjectPropertySetter(readBoolean)
|
||||
}, makeStructureNS(
|
||||
GX_NAMESPACE_URIS, {
|
||||
'MultiTrack': makeObjectPropertySetter(
|
||||
readGxMultiTrack, 'geometry'),
|
||||
'Track': makeObjectPropertySetter(
|
||||
readGxTrack, 'geometry')
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const NETWORK_LINK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ExtendedData': extendedDataParser,
|
||||
'Region': regionParser,
|
||||
'Link': linkParser,
|
||||
'address': makeObjectPropertySetter(readString),
|
||||
'description': makeObjectPropertySetter(readString),
|
||||
'name': makeObjectPropertySetter(readString),
|
||||
'open': makeObjectPropertySetter(readBoolean),
|
||||
'phoneNumber': makeObjectPropertySetter(readString),
|
||||
'visibility': makeObjectPropertySetter(readBoolean)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const LINK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'href': makeObjectPropertySetter(readURI)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const REGION_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'LatLonAltBox': latLonAltBoxParser,
|
||||
'Lod': lodParser
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Array.<string>>}
|
||||
*/
|
||||
const KML_SEQUENCE = makeStructureNS(
|
||||
NAMESPACE_URIS, [
|
||||
'Document', 'Placemark'
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const KML_SERIALIZERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Document': makeChildAppender(writeDocument),
|
||||
'Placemark': makeChildAppender(writePlacemark)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/color~Color}
|
||||
*/
|
||||
@@ -713,46 +850,6 @@ class KML {
|
||||
inherits(KML, XMLFeature);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
const GX_NAMESPACE_URIS = [
|
||||
'http://www.google.com/kml/ext/2.2'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://earth.google.com/kml/2.0',
|
||||
'http://earth.google.com/kml/2.1',
|
||||
'http://earth.google.com/kml/2.2',
|
||||
'http://www.opengis.net/kml/2.2'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const SCHEMA_LOCATION = 'http://www.opengis.net/kml/2.2 ' +
|
||||
'https://developers.google.com/kml/schema/kml22gx.xsd';
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, module:ol/style/IconAnchorUnits>}
|
||||
*/
|
||||
const ICON_ANCHOR_UNITS_MAP = {
|
||||
'fraction': IconAnchorUnits.FRACTION,
|
||||
'pixels': IconAnchorUnits.PIXELS,
|
||||
'insetPixels': IconAnchorUnits.PIXELS
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/style/Style|undefined} foundStyle Style.
|
||||
* @param {string} name Name.
|
||||
@@ -1723,17 +1820,6 @@ function extendedDataParser(node, objectStack) {
|
||||
parseNode(EXTENDED_DATA_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const REGION_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'LatLonAltBox': latLonAltBoxParser,
|
||||
'Lod': lodParser
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
@@ -1955,34 +2041,6 @@ function outerBoundaryIsParser(node, objectStack) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const NETWORK_LINK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ExtendedData': extendedDataParser,
|
||||
'Region': regionParser,
|
||||
'Link': linkParser,
|
||||
'address': makeObjectPropertySetter(readString),
|
||||
'description': makeObjectPropertySetter(readString),
|
||||
'name': makeObjectPropertySetter(readString),
|
||||
'open': makeObjectPropertySetter(readBoolean),
|
||||
'phoneNumber': makeObjectPropertySetter(readString),
|
||||
'visibility': makeObjectPropertySetter(readBoolean)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const LINK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'href': makeObjectPropertySetter(readURI)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
@@ -2006,43 +2064,6 @@ function whenParser(node, objectStack) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PLACEMARK_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ExtendedData': extendedDataParser,
|
||||
'Region': regionParser,
|
||||
'MultiGeometry': makeObjectPropertySetter(
|
||||
readMultiGeometry, 'geometry'),
|
||||
'LineString': makeObjectPropertySetter(
|
||||
readLineString, 'geometry'),
|
||||
'LinearRing': makeObjectPropertySetter(
|
||||
readLinearRing, 'geometry'),
|
||||
'Point': makeObjectPropertySetter(
|
||||
readPoint, 'geometry'),
|
||||
'Polygon': makeObjectPropertySetter(
|
||||
readPolygon, 'geometry'),
|
||||
'Style': makeObjectPropertySetter(readStyle),
|
||||
'StyleMap': placemarkStyleMapParser,
|
||||
'address': makeObjectPropertySetter(readString),
|
||||
'description': makeObjectPropertySetter(readString),
|
||||
'name': makeObjectPropertySetter(readString),
|
||||
'open': makeObjectPropertySetter(readBoolean),
|
||||
'phoneNumber': makeObjectPropertySetter(readString),
|
||||
'styleUrl': makeObjectPropertySetter(readURI),
|
||||
'visibility': makeObjectPropertySetter(readBoolean)
|
||||
}, makeStructureNS(
|
||||
GX_NAMESPACE_URIS, {
|
||||
'MultiTrack': makeObjectPropertySetter(
|
||||
readGxMultiTrack, 'geometry'),
|
||||
'Track': makeObjectPropertySetter(
|
||||
readGxTrack, 'geometry')
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
/**
|
||||
* Read the first feature from a KML source. MultiGeometries are converted into
|
||||
* GeometryCollections if they are a mix of geometry types, and into MultiPoint/
|
||||
@@ -2941,27 +2962,6 @@ function writeVec2(node, vec2) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Array.<string>>}
|
||||
*/
|
||||
const KML_SEQUENCE = makeStructureNS(
|
||||
NAMESPACE_URIS, [
|
||||
'Document', 'Placemark'
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const KML_SERIALIZERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Document': makeChildAppender(writeDocument),
|
||||
'Placemark': makeChildAppender(writePlacemark)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Encode an array of features in the KML format. GeometryCollections, MultiPoints,
|
||||
* MultiLineStrings, and MultiPolygons are output as MultiGeometries.
|
||||
|
||||
@@ -15,6 +15,36 @@ import {isEmpty} from '../obj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
import {pushParseAndPop, makeStructureNS} from '../xml.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [null];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const WAY_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'nd': readNd,
|
||||
'tag': readTag
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'node': readNode,
|
||||
'way': readWay
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Feature format for reading data in the
|
||||
@@ -96,35 +126,6 @@ class OSMXML {
|
||||
inherits(OSMXML, XMLFeature);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [null];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const WAY_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'nd': readNd,
|
||||
'tag': readTag
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'node': readNode,
|
||||
'way': readWay
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
|
||||
@@ -7,6 +7,26 @@ import XML from '../format/XML.js';
|
||||
import {readString} from '../format/xsd.js';
|
||||
import {makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop} from '../xml.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
|
||||
'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
|
||||
'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {module:ol/format/XML}
|
||||
@@ -41,25 +61,6 @@ class OWS {
|
||||
inherits(OWS, XML);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
|
||||
'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
|
||||
'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
|
||||
@@ -16,128 +16,128 @@ import FormatType from '../format/FormatType.js';
|
||||
* @extends {module:ol/format/Feature}
|
||||
*/
|
||||
class TextFeature {
|
||||
constructor() {
|
||||
FeatureFormat.call(this);
|
||||
}
|
||||
constructor() {
|
||||
FeatureFormat.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getType() {
|
||||
return FormatType.TEXT;
|
||||
}
|
||||
getType() {
|
||||
return FormatType.TEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
return this.readFeatureFromText(getText(source), this.adaptOptions(opt_options));
|
||||
}
|
||||
readFeature(source, opt_options) {
|
||||
return this.readFeatureFromText(getText(source), this.adaptOptions(opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {string} text Text.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {module:ol/Feature} Feature.
|
||||
*/
|
||||
readFeatureFromText(text, opt_options) {}
|
||||
readFeatureFromText(text, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
return this.readFeaturesFromText(getText(source), this.adaptOptions(opt_options));
|
||||
}
|
||||
readFeatures(source, opt_options) {
|
||||
return this.readFeaturesFromText(getText(source), this.adaptOptions(opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {string} text Text.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {Array.<module:ol/Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromText(text, opt_options) {}
|
||||
readFeaturesFromText(text, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
|
||||
}
|
||||
readGeometry(source, opt_options) {
|
||||
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {string} text Text.
|
||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {module:ol/geom/Geometry} Geometry.
|
||||
*/
|
||||
readGeometryFromText(text, opt_options) {}
|
||||
readGeometryFromText(text, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
readProjection(source) {
|
||||
return this.readProjectionFromText(getText(source));
|
||||
}
|
||||
readProjection(source) {
|
||||
return this.readProjectionFromText(getText(source));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @protected
|
||||
* @return {module:ol/proj/Projection} Projection.
|
||||
*/
|
||||
readProjectionFromText(text) {
|
||||
return this.dataProjection;
|
||||
}
|
||||
readProjectionFromText(text) {
|
||||
return this.dataProjection;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
|
||||
}
|
||||
writeFeature(feature, opt_options) {
|
||||
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/Feature} feature Features.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeatureText(feature, opt_options) {}
|
||||
writeFeatureText(feature, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
|
||||
}
|
||||
writeFeatures(features, opt_options) {
|
||||
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array.<module:ol/Feature>} features Features.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeaturesText(features, opt_options) {}
|
||||
writeFeaturesText(features, opt_options) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
|
||||
}
|
||||
writeGeometry(geometry, opt_options) {
|
||||
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/geom/Geometry} geometry Geometry.
|
||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeGeometryText(geometry, opt_options) {}
|
||||
writeGeometryText(geometry, opt_options) {}
|
||||
}
|
||||
|
||||
inherits(TextFeature, FeatureFormat);
|
||||
|
||||
@@ -17,6 +17,69 @@ import {createElementNS, isDocument, isNode, makeArrayPusher, makeChildAppender,
|
||||
pushParseAndPop, pushSerializeAndPop, XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const FEATURE_COLLECTION_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'boundedBy': makeObjectPropertySetter(
|
||||
GMLBase.prototype.readGeometryElement, 'bounds')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const TRANSACTION_SUMMARY_PARSERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'totalInserted': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'totalUpdated': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'totalDeleted': makeObjectPropertySetter(readNonNegativeInteger)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const TRANSACTION_RESPONSE_PARSERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'TransactionSummary': makeObjectPropertySetter(
|
||||
readTransactionSummary, 'transactionSummary'),
|
||||
'InsertResults': makeObjectPropertySetter(
|
||||
readInsertResults, 'insertIds')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const QUERY_SERIALIZERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'PropertyName': makeChildAppender(writeStringTextNode)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const TRANSACTION_SERIALIZERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'Insert': makeChildAppender(writeFeature),
|
||||
'Update': makeChildAppender(writeUpdate),
|
||||
'Delete': makeChildAppender(writeDelete),
|
||||
'Property': makeChildAppender(writeProperty),
|
||||
'Native': makeChildAppender(writeNative)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {Object.<string, string>|string} [featureNS] The namespace URI used for features.
|
||||
@@ -487,31 +550,6 @@ inherits(WFS, XMLFeature);
|
||||
WFS.prototype.readFeatures;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const FEATURE_COLLECTION_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'boundedBy': makeObjectPropertySetter(
|
||||
GMLBase.prototype.readGeometryElement, 'bounds')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const TRANSACTION_SUMMARY_PARSERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'totalInserted': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'totalUpdated': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'totalDeleted': makeObjectPropertySetter(readNonNegativeInteger)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
@@ -567,30 +605,6 @@ function readInsertResults(node, objectStack) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const TRANSACTION_RESPONSE_PARSERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'TransactionSummary': makeObjectPropertySetter(
|
||||
readTransactionSummary, 'transactionSummary'),
|
||||
'InsertResults': makeObjectPropertySetter(
|
||||
readInsertResults, 'insertIds')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const QUERY_SERIALIZERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'PropertyName': makeChildAppender(writeStringTextNode)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {module:ol/Feature} feature Feature.
|
||||
@@ -663,20 +677,6 @@ function writeDelete(node, feature, objectStack) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Serializer>>}
|
||||
*/
|
||||
const TRANSACTION_SERIALIZERS = {
|
||||
'http://www.opengis.net/wfs': {
|
||||
'Insert': makeChildAppender(writeFeature),
|
||||
'Update': makeChildAppender(writeUpdate),
|
||||
'Delete': makeChildAppender(writeDelete),
|
||||
'Property': makeChildAppender(writeProperty),
|
||||
'Native': makeChildAppender(writeNative)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {module:ol/Feature} feature Feature.
|
||||
|
||||
@@ -17,6 +17,19 @@ import Polygon from '../geom/Polygon.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
|
||||
|
||||
/**
|
||||
* @enum {function (new:module:ol/geom/Geometry, Array, module:ol/geom/GeometryLayout)}
|
||||
*/
|
||||
const GeometryConstructor = {
|
||||
'POINT': Point,
|
||||
'LINESTRING': LineString,
|
||||
'POLYGON': Polygon,
|
||||
'MULTIPOINT': MultiPoint,
|
||||
'MULTILINESTRING': MultiLineString,
|
||||
'MULTIPOLYGON': MultiPolygon
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {boolean} [splitCollection=false] Whether to split GeometryCollections into
|
||||
@@ -521,12 +534,42 @@ class Parser {
|
||||
const geometries = this.parseGeometryCollectionText_();
|
||||
return new GeometryCollection(geometries);
|
||||
} else {
|
||||
const parser = GeometryParser[geomType];
|
||||
const ctor = GeometryConstructor[geomType];
|
||||
if (!parser || !ctor) {
|
||||
if (!ctor) {
|
||||
throw new Error('Invalid geometry type: ' + geomType);
|
||||
}
|
||||
let coordinates = parser.call(this);
|
||||
|
||||
let coordinates;
|
||||
switch (geomType) {
|
||||
case GeometryType.POINT: {
|
||||
coordinates = this.parsePointText_();
|
||||
break;
|
||||
}
|
||||
case GeometryType.LINESTRING: {
|
||||
coordinates = this.parseLineStringText_();
|
||||
break;
|
||||
}
|
||||
case GeometryType.POLYGON: {
|
||||
coordinates = Parser.prototype.parsePolygonText_();
|
||||
break;
|
||||
}
|
||||
case GeometryType.MULTIPOINT: {
|
||||
coordinates = Parser.prototype.parseMultiPointText_();
|
||||
break;
|
||||
}
|
||||
case GeometryType.MULTILINESTRING: {
|
||||
coordinates = Parser.prototype.parseMultiLineStringText_();
|
||||
break;
|
||||
}
|
||||
case GeometryType.MULTIPOLYGON: {
|
||||
coordinates = Parser.prototype.parseMultiPolygonText_();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error('Invalid geometry type: ' + geomType);
|
||||
}
|
||||
}
|
||||
|
||||
if (!coordinates) {
|
||||
if (ctor === GeometryConstructor[GeometryType.POINT]) {
|
||||
coordinates = [NaN, NaN];
|
||||
@@ -541,6 +584,7 @@ class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Geometry format for reading and writing data in the `WellKnownText` (WKT)
|
||||
@@ -855,32 +899,6 @@ WKT.prototype.readFeatures;
|
||||
WKT.prototype.readGeometry;
|
||||
|
||||
|
||||
/**
|
||||
* @enum {function (new:module:ol/geom/Geometry, Array, module:ol/geom/GeometryLayout)}
|
||||
*/
|
||||
const GeometryConstructor = {
|
||||
'POINT': Point,
|
||||
'LINESTRING': LineString,
|
||||
'POLYGON': Polygon,
|
||||
'MULTIPOINT': MultiPoint,
|
||||
'MULTILINESTRING': MultiLineString,
|
||||
'MULTIPOLYGON': MultiPolygon
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {(function(): Array)}
|
||||
*/
|
||||
const GeometryParser = {
|
||||
'POINT': Parser.prototype.parsePointText_,
|
||||
'LINESTRING': Parser.prototype.parseLineStringText_,
|
||||
'POLYGON': Parser.prototype.parsePolygonText_,
|
||||
'MULTIPOINT': Parser.prototype.parseMultiPointText_,
|
||||
'MULTILINESTRING': Parser.prototype.parseMultiLineStringText_,
|
||||
'MULTIPOLYGON': Parser.prototype.parseMultiPolygonText_
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Encode a feature as a WKT string.
|
||||
*
|
||||
|
||||
@@ -9,6 +9,39 @@ import {makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter,
|
||||
makeStructureNS, pushParseAndPop} from '../xml.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/wms'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Service': makeObjectPropertySetter(readService),
|
||||
'Capability': makeObjectPropertySetter(readCapability)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const CAPABILITY_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Request': makeObjectPropertySetter(readRequest),
|
||||
'Exception': makeObjectPropertySetter(readException),
|
||||
'Layer': makeObjectPropertySetter(readCapabilityLayer)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Format for reading WMS capabilities data
|
||||
@@ -55,39 +88,6 @@ class WMSCapabilities {
|
||||
inherits(WMSCapabilities, XML);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/wms'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Service': makeObjectPropertySetter(readService),
|
||||
'Capability': makeObjectPropertySetter(readCapability)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const CAPABILITY_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Request': makeObjectPropertySetter(readRequest),
|
||||
'Exception': makeObjectPropertySetter(readException),
|
||||
'Layer': makeObjectPropertySetter(readCapabilityLayer)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
|
||||
@@ -15,6 +15,20 @@ import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js';
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const featureIdentifier = '_feature';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const layerIdentifier = '_layer';
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Format for reading WMSGetFeatureInfo format. It uses
|
||||
@@ -159,20 +173,6 @@ class WMSGetFeatureInfo {
|
||||
inherits(WMSGetFeatureInfo, XMLFeature);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const featureIdentifier = '_feature';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const layerIdentifier = '_layer';
|
||||
|
||||
|
||||
/**
|
||||
* Read all features from a WMSGetFeatureInfo response.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,37 @@ import {readString, readNonNegativeInteger, readDecimal} from '../format/xsd.js'
|
||||
import {pushParseAndPop, makeStructureNS,
|
||||
makeObjectPropertySetter, makeObjectPropertyPusher, makeArrayPusher} from '../xml.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/wmts/1.0'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const OWS_NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/ows/1.1'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Contents': makeObjectPropertySetter(readContents)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Format for reading WMTS capabilities data.
|
||||
@@ -59,36 +90,6 @@ class WMTSCapabilities {
|
||||
inherits(WMTSCapabilities, XML);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/wmts/1.0'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<null|string>}
|
||||
*/
|
||||
const OWS_NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/ows/1.1'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
*/
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Contents': makeObjectPropertySetter(readContents)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, module:ol/xml~Parser>>}
|
||||
|
||||
@@ -12,36 +12,36 @@ import {isDocument, isNode, parse} from '../xml.js';
|
||||
* @struct
|
||||
*/
|
||||
class XML {
|
||||
/**
|
||||
/**
|
||||
* @param {Document|Node|string} source Source.
|
||||
* @return {Object} The parsed result.
|
||||
*/
|
||||
read(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readFromDocument(/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readFromNode(/** @type {Node} */ (source));
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFromDocument(doc);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
read(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readFromDocument(/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readFromNode(/** @type {Node} */ (source));
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFromDocument(doc);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Document} doc Document.
|
||||
* @return {Object} Object
|
||||
*/
|
||||
readFromDocument(doc) {}
|
||||
readFromDocument(doc) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Node} node Node.
|
||||
* @return {Object} Object
|
||||
*/
|
||||
readFromNode(node) {}
|
||||
readFromNode(node) {}
|
||||
}
|
||||
|
||||
export default XML;
|
||||
|
||||
@@ -14,22 +14,22 @@
|
||||
* @struct
|
||||
*/
|
||||
class Filter {
|
||||
constructor(tagName) {
|
||||
constructor(tagName) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {!string}
|
||||
*/
|
||||
this.tagName_ = tagName;
|
||||
}
|
||||
this.tagName_ = tagName;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* The XML tag name for a filter.
|
||||
* @returns {!string} Name.
|
||||
*/
|
||||
getTagName() {
|
||||
return this.tagName_;
|
||||
}
|
||||
getTagName() {
|
||||
return this.tagName_;
|
||||
}
|
||||
}
|
||||
|
||||
export default Filter;
|
||||
|
||||
@@ -11,6 +11,12 @@ import Units from '../proj/Units.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../transform.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Abstract base class; normally only used for creating subclasses and not
|
||||
@@ -26,50 +32,50 @@ import {create as createTransform, compose as composeTransform} from '../transfo
|
||||
* @api
|
||||
*/
|
||||
class Geometry {
|
||||
constructor() {
|
||||
constructor() {
|
||||
|
||||
BaseObject.call(this);
|
||||
BaseObject.call(this);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
this.extent_ = createEmpty();
|
||||
this.extent_ = createEmpty();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.extentRevision_ = -1;
|
||||
this.extentRevision_ = -1;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {Object.<string, module:ol/geom/Geometry>}
|
||||
*/
|
||||
this.simplifiedGeometryCache = {};
|
||||
this.simplifiedGeometryCache = {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
||||
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.simplifiedGeometryRevision = 0;
|
||||
this.simplifiedGeometryRevision = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Make a complete copy of the geometry.
|
||||
* @abstract
|
||||
* @return {!module:ol/geom/Geometry} Clone.
|
||||
*/
|
||||
clone() {}
|
||||
clone() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
@@ -77,9 +83,9 @@ class Geometry {
|
||||
* @param {number} minSquaredDistance Minimum squared distance.
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
closestPointXY(x, y, closestPoint, minSquaredDistance) {}
|
||||
closestPointXY(x, y, closestPoint, minSquaredDistance) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the closest point of the geometry to the passed point as
|
||||
* {@link module:ol/coordinate~Coordinate coordinate}.
|
||||
* @param {module:ol/coordinate~Coordinate} point Point.
|
||||
@@ -87,46 +93,46 @@ class Geometry {
|
||||
* @return {module:ol/coordinate~Coordinate} Closest point.
|
||||
* @api
|
||||
*/
|
||||
getClosestPoint(point, opt_closestPoint) {
|
||||
const closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
|
||||
this.closestPointXY(point[0], point[1], closestPoint, Infinity);
|
||||
return closestPoint;
|
||||
}
|
||||
getClosestPoint(point, opt_closestPoint) {
|
||||
const closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
|
||||
this.closestPointXY(point[0], point[1], closestPoint, Infinity);
|
||||
return closestPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns true if this geometry includes the specified coordinate. If the
|
||||
* coordinate is on the boundary of the geometry, returns false.
|
||||
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
|
||||
* @return {boolean} Contains coordinate.
|
||||
* @api
|
||||
*/
|
||||
intersectsCoordinate(coordinate) {
|
||||
return this.containsXY(coordinate[0], coordinate[1]);
|
||||
}
|
||||
intersectsCoordinate(coordinate) {
|
||||
return this.containsXY(coordinate[0], coordinate[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/extent~Extent} extent Extent.
|
||||
* @protected
|
||||
* @return {module:ol/extent~Extent} extent Extent.
|
||||
*/
|
||||
computeExtent(extent) {}
|
||||
computeExtent(extent) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the extent of the geometry.
|
||||
* @param {module:ol/extent~Extent=} opt_extent Extent.
|
||||
* @return {module:ol/extent~Extent} extent Extent.
|
||||
* @api
|
||||
*/
|
||||
getExtent(opt_extent) {
|
||||
if (this.extentRevision_ != this.getRevision()) {
|
||||
this.extent_ = this.computeExtent(this.extent_);
|
||||
this.extentRevision_ = this.getRevision();
|
||||
}
|
||||
return returnOrUpdate(this.extent_, opt_extent);
|
||||
}
|
||||
getExtent(opt_extent) {
|
||||
if (this.extentRevision_ != this.getRevision()) {
|
||||
this.extent_ = this.computeExtent(this.extent_);
|
||||
this.extentRevision_ = this.getRevision();
|
||||
}
|
||||
return returnOrUpdate(this.extent_, opt_extent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Rotate the geometry around a given coordinate. This modifies the geometry
|
||||
* coordinates in place.
|
||||
* @abstract
|
||||
@@ -134,9 +140,9 @@ class Geometry {
|
||||
* @param {module:ol/coordinate~Coordinate} anchor The rotation center.
|
||||
* @api
|
||||
*/
|
||||
rotate(angle, anchor) {}
|
||||
rotate(angle, anchor) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Scale the geometry (with an optional origin). This modifies the geometry
|
||||
* coordinates in place.
|
||||
* @abstract
|
||||
@@ -147,9 +153,9 @@ class Geometry {
|
||||
* of the geometry extent).
|
||||
* @api
|
||||
*/
|
||||
scale(sx, opt_sy, opt_anchor) {}
|
||||
scale(sx, opt_sy, opt_anchor) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a simplified version of this geometry. For linestrings, this uses
|
||||
* the the {@link
|
||||
* https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
|
||||
@@ -161,11 +167,11 @@ class Geometry {
|
||||
* geometry.
|
||||
* @api
|
||||
*/
|
||||
simplify(tolerance) {
|
||||
return this.getSimplifiedGeometry(tolerance * tolerance);
|
||||
}
|
||||
simplify(tolerance) {
|
||||
return this.getSimplifiedGeometry(tolerance * tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a simplified version of this geometry using the Douglas Peucker
|
||||
* algorithm.
|
||||
* @see https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
|
||||
@@ -173,16 +179,16 @@ class Geometry {
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @return {module:ol/geom/Geometry} Simplified geometry.
|
||||
*/
|
||||
getSimplifiedGeometry(squaredTolerance) {}
|
||||
getSimplifiedGeometry(squaredTolerance) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @abstract
|
||||
* @return {module:ol/geom/GeometryType} Geometry type.
|
||||
*/
|
||||
getType() {}
|
||||
getType() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Apply a transform function to each coordinate of the geometry.
|
||||
* The geometry is modified in place.
|
||||
* If you do not want the geometry modified in place, first `clone()` it and
|
||||
@@ -190,26 +196,26 @@ class Geometry {
|
||||
* @abstract
|
||||
* @param {module:ol/proj~TransformFunction} transformFn Transform.
|
||||
*/
|
||||
applyTransform(transformFn) {}
|
||||
applyTransform(transformFn) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test if the geometry and the passed extent intersect.
|
||||
* @abstract
|
||||
* @param {module:ol/extent~Extent} extent Extent.
|
||||
* @return {boolean} `true` if the geometry and the extent intersect.
|
||||
*/
|
||||
intersectsExtent(extent) {}
|
||||
intersectsExtent(extent) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Translate the geometry. This modifies the geometry coordinates in place. If
|
||||
* instead you want a new geometry, first `clone()` this geometry.
|
||||
* @abstract
|
||||
* @param {number} deltaX Delta X.
|
||||
* @param {number} deltaY Delta Y.
|
||||
*/
|
||||
translate(deltaX, deltaY) {}
|
||||
translate(deltaX, deltaY) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Transform each coordinate of the geometry from one coordinate reference
|
||||
* system to another. The geometry is modified in place.
|
||||
* For example, a line will be transformed to a line and a circle to a circle.
|
||||
@@ -224,36 +230,30 @@ class Geometry {
|
||||
* modified in place.
|
||||
* @api
|
||||
*/
|
||||
transform(source, destination) {
|
||||
source = getProjection(source);
|
||||
const transformFn = source.getUnits() == Units.TILE_PIXELS ?
|
||||
function(inCoordinates, outCoordinates, stride) {
|
||||
const pixelExtent = source.getExtent();
|
||||
const projectedExtent = source.getWorldExtent();
|
||||
const scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
composeTransform(tmpTransform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
transform2D(inCoordinates, 0, inCoordinates.length, stride,
|
||||
tmpTransform, outCoordinates);
|
||||
return getTransform(source, destination)(inCoordinates, outCoordinates, stride);
|
||||
} :
|
||||
getTransform(source, destination);
|
||||
this.applyTransform(transformFn);
|
||||
return this;
|
||||
}
|
||||
transform(source, destination) {
|
||||
source = getProjection(source);
|
||||
const transformFn = source.getUnits() == Units.TILE_PIXELS ?
|
||||
function(inCoordinates, outCoordinates, stride) {
|
||||
const pixelExtent = source.getExtent();
|
||||
const projectedExtent = source.getWorldExtent();
|
||||
const scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
composeTransform(tmpTransform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
transform2D(inCoordinates, 0, inCoordinates.length, stride,
|
||||
tmpTransform, outCoordinates);
|
||||
return getTransform(source, destination)(inCoordinates, outCoordinates, stride);
|
||||
} :
|
||||
getTransform(source, destination);
|
||||
this.applyTransform(transformFn);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Geometry, BaseObject);
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
|
||||
@@ -24,6 +24,21 @@ import RBush from '../structs/RBush.js';
|
||||
import {createEditingStyle} from '../style/Style.js';
|
||||
|
||||
|
||||
/**
|
||||
* The segment index assigned to a circle's center when
|
||||
* breaking up a circle into ModifySegmentDataType segments.
|
||||
* @type {number}
|
||||
*/
|
||||
const CIRCLE_CENTER_INDEX = 0;
|
||||
|
||||
/**
|
||||
* The segment index assigned to a circle's circumference when
|
||||
* breaking up a circle into ModifySegmentDataType segments.
|
||||
* @type {number}
|
||||
*/
|
||||
const CIRCLE_CIRCUMFERENCE_INDEX = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -958,21 +973,6 @@ class Modify {
|
||||
inherits(Modify, PointerInteraction);
|
||||
|
||||
|
||||
/**
|
||||
* The segment index assigned to a circle's center when
|
||||
* breaking up a circle into ModifySegmentDataType segments.
|
||||
* @type {number}
|
||||
*/
|
||||
const CIRCLE_CENTER_INDEX = 0;
|
||||
|
||||
/**
|
||||
* The segment index assigned to a circle's circumference when
|
||||
* breaking up a circle into ModifySegmentDataType segments.
|
||||
* @type {number}
|
||||
*/
|
||||
const CIRCLE_CIRCUMFERENCE_INDEX = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/interaction/Modify~SegmentData} a The first segment data.
|
||||
* @param {module:ol/interaction/Modify~SegmentData} b The second segment data.
|
||||
|
||||
@@ -38,215 +38,215 @@ import {assign} from '../obj.js';
|
||||
* @api
|
||||
*/
|
||||
class BaseLayer {
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
BaseObject.call(this);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {Object.<string, *>}
|
||||
*/
|
||||
const properties = assign({}, options);
|
||||
properties[LayerProperty.OPACITY] =
|
||||
const properties = assign({}, options);
|
||||
properties[LayerProperty.OPACITY] =
|
||||
options.opacity !== undefined ? options.opacity : 1;
|
||||
properties[LayerProperty.VISIBLE] =
|
||||
properties[LayerProperty.VISIBLE] =
|
||||
options.visible !== undefined ? options.visible : true;
|
||||
properties[LayerProperty.Z_INDEX] =
|
||||
properties[LayerProperty.Z_INDEX] =
|
||||
options.zIndex !== undefined ? options.zIndex : 0;
|
||||
properties[LayerProperty.MAX_RESOLUTION] =
|
||||
properties[LayerProperty.MAX_RESOLUTION] =
|
||||
options.maxResolution !== undefined ? options.maxResolution : Infinity;
|
||||
properties[LayerProperty.MIN_RESOLUTION] =
|
||||
properties[LayerProperty.MIN_RESOLUTION] =
|
||||
options.minResolution !== undefined ? options.minResolution : 0;
|
||||
|
||||
this.setProperties(properties);
|
||||
this.setProperties(properties);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {module:ol/layer/Layer~State}
|
||||
* @private
|
||||
*/
|
||||
this.state_ = /** @type {module:ol/layer/Layer~State} */ ({
|
||||
layer: /** @type {module:ol/layer/Layer} */ (this),
|
||||
managed: true
|
||||
});
|
||||
this.state_ = /** @type {module:ol/layer/Layer~State} */ ({
|
||||
layer: /** @type {module:ol/layer/Layer} */ (this),
|
||||
managed: true
|
||||
});
|
||||
|
||||
/**
|
||||
/**
|
||||
* The layer type.
|
||||
* @type {module:ol/LayerType}
|
||||
* @protected;
|
||||
*/
|
||||
this.type;
|
||||
this.type;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the layer type (used when creating a layer renderer).
|
||||
* @return {module:ol/LayerType} The layer type.
|
||||
*/
|
||||
getType() {
|
||||
return this.type;
|
||||
}
|
||||
getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/layer/Layer~State} Layer state.
|
||||
*/
|
||||
getLayerState() {
|
||||
this.state_.opacity = clamp(this.getOpacity(), 0, 1);
|
||||
this.state_.sourceState = this.getSourceState();
|
||||
this.state_.visible = this.getVisible();
|
||||
this.state_.extent = this.getExtent();
|
||||
this.state_.zIndex = this.getZIndex();
|
||||
this.state_.maxResolution = this.getMaxResolution();
|
||||
this.state_.minResolution = Math.max(this.getMinResolution(), 0);
|
||||
getLayerState() {
|
||||
this.state_.opacity = clamp(this.getOpacity(), 0, 1);
|
||||
this.state_.sourceState = this.getSourceState();
|
||||
this.state_.visible = this.getVisible();
|
||||
this.state_.extent = this.getExtent();
|
||||
this.state_.zIndex = this.getZIndex();
|
||||
this.state_.maxResolution = this.getMaxResolution();
|
||||
this.state_.minResolution = Math.max(this.getMinResolution(), 0);
|
||||
|
||||
return this.state_;
|
||||
}
|
||||
return this.state_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array.<module:ol/layer/Layer>=} opt_array Array of layers (to be
|
||||
* modified in place).
|
||||
* @return {Array.<module:ol/layer/Layer>} Array of layers.
|
||||
*/
|
||||
getLayersArray(opt_array) {}
|
||||
getLayersArray(opt_array) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array.<module:ol/layer/Layer~State>=} opt_states Optional list of layer
|
||||
* states (to be modified in place).
|
||||
* @return {Array.<module:ol/layer/Layer~State>} List of layer states.
|
||||
*/
|
||||
getLayerStatesArray(opt_states) {}
|
||||
getLayerStatesArray(opt_states) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it
|
||||
* will be visible regardless of extent.
|
||||
* @return {module:ol/extent~Extent|undefined} The layer extent.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getExtent() {
|
||||
return (
|
||||
/** @type {module:ol/extent~Extent|undefined} */ (this.get(LayerProperty.EXTENT))
|
||||
);
|
||||
}
|
||||
getExtent() {
|
||||
return (
|
||||
/** @type {module:ol/extent~Extent|undefined} */ (this.get(LayerProperty.EXTENT))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the maximum resolution of the layer.
|
||||
* @return {number} The maximum resolution of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getMaxResolution() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.MAX_RESOLUTION));
|
||||
}
|
||||
getMaxResolution() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.MAX_RESOLUTION));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the minimum resolution of the layer.
|
||||
* @return {number} The minimum resolution of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getMinResolution() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.MIN_RESOLUTION));
|
||||
}
|
||||
getMinResolution() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.MIN_RESOLUTION));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the opacity of the layer (between 0 and 1).
|
||||
* @return {number} The opacity of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getOpacity() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.OPACITY));
|
||||
}
|
||||
getOpacity() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.OPACITY));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {module:ol/source/State} Source state.
|
||||
*/
|
||||
getSourceState() {}
|
||||
getSourceState() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the visibility of the layer (`true` or `false`).
|
||||
* @return {boolean} The visibility of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getVisible() {
|
||||
return /** @type {boolean} */ (this.get(LayerProperty.VISIBLE));
|
||||
}
|
||||
getVisible() {
|
||||
return /** @type {boolean} */ (this.get(LayerProperty.VISIBLE));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the Z-index of the layer, which is used to order layers before
|
||||
* rendering. The default Z-index is 0.
|
||||
* @return {number} The Z-index of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getZIndex() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.Z_INDEX));
|
||||
}
|
||||
getZIndex() {
|
||||
return /** @type {number} */ (this.get(LayerProperty.Z_INDEX));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the extent at which the layer is visible. If `undefined`, the layer
|
||||
* will be visible at all extents.
|
||||
* @param {module:ol/extent~Extent|undefined} extent The extent of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setExtent(extent) {
|
||||
this.set(LayerProperty.EXTENT, extent);
|
||||
}
|
||||
setExtent(extent) {
|
||||
this.set(LayerProperty.EXTENT, extent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the maximum resolution at which the layer is visible.
|
||||
* @param {number} maxResolution The maximum resolution of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setMaxResolution(maxResolution) {
|
||||
this.set(LayerProperty.MAX_RESOLUTION, maxResolution);
|
||||
}
|
||||
setMaxResolution(maxResolution) {
|
||||
this.set(LayerProperty.MAX_RESOLUTION, maxResolution);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the minimum resolution at which the layer is visible.
|
||||
* @param {number} minResolution The minimum resolution of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setMinResolution(minResolution) {
|
||||
this.set(LayerProperty.MIN_RESOLUTION, minResolution);
|
||||
}
|
||||
setMinResolution(minResolution) {
|
||||
this.set(LayerProperty.MIN_RESOLUTION, minResolution);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the opacity of the layer, allowed values range from 0 to 1.
|
||||
* @param {number} opacity The opacity of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setOpacity(opacity) {
|
||||
this.set(LayerProperty.OPACITY, opacity);
|
||||
}
|
||||
setOpacity(opacity) {
|
||||
this.set(LayerProperty.OPACITY, opacity);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the visibility of the layer (`true` or `false`).
|
||||
* @param {boolean} visible The visibility of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setVisible(visible) {
|
||||
this.set(LayerProperty.VISIBLE, visible);
|
||||
}
|
||||
setVisible(visible) {
|
||||
this.set(LayerProperty.VISIBLE, visible);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set Z-index of the layer, which is used to order layers before rendering.
|
||||
* The default Z-index is 0.
|
||||
* @param {number} zindex The z-index of the layer.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setZIndex(zindex) {
|
||||
this.set(LayerProperty.Z_INDEX, zindex);
|
||||
}
|
||||
setZIndex(zindex) {
|
||||
this.set(LayerProperty.Z_INDEX, zindex);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(BaseLayer, BaseObject);
|
||||
|
||||
@@ -289,9 +289,8 @@ inherits(Heatmap, VectorLayer);
|
||||
/**
|
||||
* @param {Array.<string>} colors A list of colored.
|
||||
* @return {Uint8ClampedArray} An array.
|
||||
* @private
|
||||
*/
|
||||
const createGradient = function(colors) {
|
||||
function createGradient(colors) {
|
||||
const width = 1;
|
||||
const height = 256;
|
||||
const context = createCanvasContext2D(width, height);
|
||||
@@ -306,7 +305,7 @@ const createGradient = function(colors) {
|
||||
context.fillRect(0, 0, width, height);
|
||||
|
||||
return context.getImageData(0, 0, width, height).data;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export default Heatmap;
|
||||
|
||||
@@ -46,67 +46,67 @@ import {assign} from '../obj.js';
|
||||
* @api
|
||||
*/
|
||||
class TileLayer {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
const baseOptions = assign({}, options);
|
||||
const baseOptions = assign({}, options);
|
||||
|
||||
delete baseOptions.preload;
|
||||
delete baseOptions.useInterimTilesOnError;
|
||||
Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (baseOptions));
|
||||
delete baseOptions.preload;
|
||||
delete baseOptions.useInterimTilesOnError;
|
||||
Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (baseOptions));
|
||||
|
||||
this.setPreload(options.preload !== undefined ? options.preload : 0);
|
||||
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
|
||||
options.useInterimTilesOnError : true);
|
||||
this.setPreload(options.preload !== undefined ? options.preload : 0);
|
||||
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
|
||||
options.useInterimTilesOnError : true);
|
||||
|
||||
/**
|
||||
/**
|
||||
* The layer type.
|
||||
* @protected
|
||||
* @type {module:ol/LayerType}
|
||||
*/
|
||||
this.type = LayerType.TILE;
|
||||
this.type = LayerType.TILE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the level as number to which we will preload tiles up to.
|
||||
* @return {number} The level to preload tiles up to.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getPreload() {
|
||||
return /** @type {number} */ (this.get(TileProperty.PRELOAD));
|
||||
}
|
||||
getPreload() {
|
||||
return /** @type {number} */ (this.get(TileProperty.PRELOAD));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the level as number to which we will preload tiles up to.
|
||||
* @param {number} preload The level to preload tiles up to.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setPreload(preload) {
|
||||
this.set(TileProperty.PRELOAD, preload);
|
||||
}
|
||||
setPreload(preload) {
|
||||
this.set(TileProperty.PRELOAD, preload);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Whether we use interim tiles on error.
|
||||
* @return {boolean} Use interim tiles on error.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getUseInterimTilesOnError() {
|
||||
return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
|
||||
}
|
||||
getUseInterimTilesOnError() {
|
||||
return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set whether we use interim tiles on error.
|
||||
* @param {boolean} useInterimTilesOnError Use interim tiles on error.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setUseInterimTilesOnError(useInterimTilesOnError) {
|
||||
this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
|
||||
}
|
||||
setUseInterimTilesOnError(useInterimTilesOnError) {
|
||||
this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(TileLayer, Layer);
|
||||
|
||||
@@ -92,152 +92,152 @@ const Property = {
|
||||
* @api
|
||||
*/
|
||||
class VectorLayer {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ?
|
||||
opt_options : /** @type {module:ol/layer/Vector~Options} */ ({});
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ?
|
||||
opt_options : /** @type {module:ol/layer/Vector~Options} */ ({});
|
||||
|
||||
const baseOptions = assign({}, options);
|
||||
const baseOptions = assign({}, options);
|
||||
|
||||
delete baseOptions.style;
|
||||
delete baseOptions.renderBuffer;
|
||||
delete baseOptions.updateWhileAnimating;
|
||||
delete baseOptions.updateWhileInteracting;
|
||||
Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (baseOptions));
|
||||
delete baseOptions.style;
|
||||
delete baseOptions.renderBuffer;
|
||||
delete baseOptions.updateWhileAnimating;
|
||||
delete baseOptions.updateWhileInteracting;
|
||||
Layer.call(this, /** @type {module:ol/layer/Layer~Options} */ (baseOptions));
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.declutter_ = options.declutter !== undefined ? options.declutter : false;
|
||||
this.declutter_ = options.declutter !== undefined ? options.declutter : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.renderBuffer_ = options.renderBuffer !== undefined ?
|
||||
options.renderBuffer : 100;
|
||||
this.renderBuffer_ = options.renderBuffer !== undefined ?
|
||||
options.renderBuffer : 100;
|
||||
|
||||
/**
|
||||
/**
|
||||
* User provided style.
|
||||
* @type {module:ol/style/Style|Array.<module:ol/style/Style>|module:ol/style/Style~StyleFunction}
|
||||
* @private
|
||||
*/
|
||||
this.style_ = null;
|
||||
this.style_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Style function for use within the library.
|
||||
* @type {module:ol/style/Style~StyleFunction|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.styleFunction_ = undefined;
|
||||
this.styleFunction_ = undefined;
|
||||
|
||||
this.setStyle(options.style);
|
||||
this.setStyle(options.style);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ?
|
||||
options.updateWhileAnimating : false;
|
||||
this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ?
|
||||
options.updateWhileAnimating : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ?
|
||||
options.updateWhileInteracting : false;
|
||||
this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ?
|
||||
options.updateWhileInteracting : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/layer/VectorTileRenderType|string}
|
||||
*/
|
||||
this.renderMode_ = options.renderMode || VectorRenderType.VECTOR;
|
||||
this.renderMode_ = options.renderMode || VectorRenderType.VECTOR;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The layer type.
|
||||
* @protected
|
||||
* @type {module:ol/LayerType}
|
||||
*/
|
||||
this.type = LayerType.VECTOR;
|
||||
this.type = LayerType.VECTOR;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {boolean} Declutter.
|
||||
*/
|
||||
getDeclutter() {
|
||||
return this.declutter_;
|
||||
}
|
||||
getDeclutter() {
|
||||
return this.declutter_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {boolean} declutter Declutter.
|
||||
*/
|
||||
setDeclutter(declutter) {
|
||||
this.declutter_ = declutter;
|
||||
}
|
||||
setDeclutter(declutter) {
|
||||
this.declutter_ = declutter;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number|undefined} Render buffer.
|
||||
*/
|
||||
getRenderBuffer() {
|
||||
return this.renderBuffer_;
|
||||
}
|
||||
getRenderBuffer() {
|
||||
return this.renderBuffer_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {function(module:ol/Feature, module:ol/Feature): number|null|undefined} Render
|
||||
* order.
|
||||
*/
|
||||
getRenderOrder() {
|
||||
return (
|
||||
/** @type {module:ol/render~OrderFunction|null|undefined} */ (this.get(Property.RENDER_ORDER))
|
||||
);
|
||||
}
|
||||
getRenderOrder() {
|
||||
return (
|
||||
/** @type {module:ol/render~OrderFunction|null|undefined} */ (this.get(Property.RENDER_ORDER))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the style for features. This returns whatever was passed to the `style`
|
||||
* option at construction or to the `setStyle` method.
|
||||
* @return {module:ol/style/Style|Array.<module:ol/style/Style>|module:ol/style/Style~StyleFunction}
|
||||
* Layer style.
|
||||
* @api
|
||||
*/
|
||||
getStyle() {
|
||||
return this.style_;
|
||||
}
|
||||
getStyle() {
|
||||
return this.style_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the style function.
|
||||
* @return {module:ol/style/Style~StyleFunction|undefined} Layer style function.
|
||||
* @api
|
||||
*/
|
||||
getStyleFunction() {
|
||||
return this.styleFunction_;
|
||||
}
|
||||
getStyleFunction() {
|
||||
return this.styleFunction_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {boolean} Whether the rendered layer should be updated while
|
||||
* animating.
|
||||
*/
|
||||
getUpdateWhileAnimating() {
|
||||
return this.updateWhileAnimating_;
|
||||
}
|
||||
getUpdateWhileAnimating() {
|
||||
return this.updateWhileAnimating_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {boolean} Whether the rendered layer should be updated while
|
||||
* interacting.
|
||||
*/
|
||||
getUpdateWhileInteracting() {
|
||||
return this.updateWhileInteracting_;
|
||||
}
|
||||
getUpdateWhileInteracting() {
|
||||
return this.updateWhileInteracting_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/render~OrderFunction|null|undefined} renderOrder
|
||||
* Render order.
|
||||
*/
|
||||
setRenderOrder(renderOrder) {
|
||||
this.set(Property.RENDER_ORDER, renderOrder);
|
||||
}
|
||||
setRenderOrder(renderOrder) {
|
||||
this.set(Property.RENDER_ORDER, renderOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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
|
||||
@@ -248,19 +248,19 @@ class VectorLayer {
|
||||
* style Layer style.
|
||||
* @api
|
||||
*/
|
||||
setStyle(style) {
|
||||
this.style_ = style !== undefined ? style : createDefaultStyle;
|
||||
this.styleFunction_ = style === null ?
|
||||
undefined : toStyleFunction(this.style_);
|
||||
this.changed();
|
||||
}
|
||||
setStyle(style) {
|
||||
this.style_ = style !== undefined ? style : createDefaultStyle;
|
||||
this.styleFunction_ = style === null ?
|
||||
undefined : toStyleFunction(this.style_);
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/layer/VectorRenderType|string} The render mode.
|
||||
*/
|
||||
getRenderMode() {
|
||||
return this.renderMode_;
|
||||
}
|
||||
getRenderMode() {
|
||||
return this.renderMode_;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(VectorLayer, Layer);
|
||||
|
||||
@@ -100,78 +100,78 @@ export const RenderType = {
|
||||
* @api
|
||||
*/
|
||||
class VectorTileLayer {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
let renderMode = options.renderMode || VectorTileRenderType.HYBRID;
|
||||
assert(renderMode == undefined ||
|
||||
let renderMode = options.renderMode || VectorTileRenderType.HYBRID;
|
||||
assert(renderMode == undefined ||
|
||||
renderMode == VectorTileRenderType.IMAGE ||
|
||||
renderMode == VectorTileRenderType.HYBRID ||
|
||||
renderMode == VectorTileRenderType.VECTOR,
|
||||
28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'`
|
||||
if (options.declutter && renderMode == VectorTileRenderType.IMAGE) {
|
||||
renderMode = VectorTileRenderType.HYBRID;
|
||||
}
|
||||
options.renderMode = renderMode;
|
||||
28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'`
|
||||
if (options.declutter && renderMode == VectorTileRenderType.IMAGE) {
|
||||
renderMode = VectorTileRenderType.HYBRID;
|
||||
}
|
||||
options.renderMode = renderMode;
|
||||
|
||||
const baseOptions = assign({}, options);
|
||||
const baseOptions = assign({}, options);
|
||||
|
||||
delete baseOptions.preload;
|
||||
delete baseOptions.useInterimTilesOnError;
|
||||
VectorLayer.call(this, /** @type {module:ol/layer/Vector~Options} */ (baseOptions));
|
||||
delete baseOptions.preload;
|
||||
delete baseOptions.useInterimTilesOnError;
|
||||
VectorLayer.call(this, /** @type {module:ol/layer/Vector~Options} */ (baseOptions));
|
||||
|
||||
this.setPreload(options.preload ? options.preload : 0);
|
||||
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
|
||||
options.useInterimTilesOnError : true);
|
||||
this.setPreload(options.preload ? options.preload : 0);
|
||||
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
|
||||
options.useInterimTilesOnError : true);
|
||||
|
||||
/**
|
||||
/**
|
||||
* The layer type.
|
||||
* @protected
|
||||
* @type {module:ol/LayerType}
|
||||
*/
|
||||
this.type = LayerType.VECTOR_TILE;
|
||||
this.type = LayerType.VECTOR_TILE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the level as number to which we will preload tiles up to.
|
||||
* @return {number} The level to preload tiles up to.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getPreload() {
|
||||
return /** @type {number} */ (this.get(TileProperty.PRELOAD));
|
||||
}
|
||||
getPreload() {
|
||||
return /** @type {number} */ (this.get(TileProperty.PRELOAD));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Whether we use interim tiles on error.
|
||||
* @return {boolean} Use interim tiles on error.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
getUseInterimTilesOnError() {
|
||||
return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
|
||||
}
|
||||
getUseInterimTilesOnError() {
|
||||
return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the level as number to which we will preload tiles up to.
|
||||
* @param {number} preload The level to preload tiles up to.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setPreload(preload) {
|
||||
this.set(TileProperty.PRELOAD, preload);
|
||||
}
|
||||
setPreload(preload) {
|
||||
this.set(TileProperty.PRELOAD, preload);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set whether we use interim tiles on error.
|
||||
* @param {boolean} useInterimTilesOnError Use interim tiles on error.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
setUseInterimTilesOnError(useInterimTilesOnError) {
|
||||
this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
|
||||
}
|
||||
setUseInterimTilesOnError(useInterimTilesOnError) {
|
||||
this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(VectorTileLayer, VectorLayer);
|
||||
|
||||
@@ -7,36 +7,36 @@
|
||||
* @constructor
|
||||
*/
|
||||
class EventSource {
|
||||
constructor(dispatcher, mapping) {
|
||||
/**
|
||||
constructor(dispatcher, mapping) {
|
||||
/**
|
||||
* @type {module:ol/pointer/PointerEventHandler}
|
||||
*/
|
||||
this.dispatcher = dispatcher;
|
||||
this.dispatcher = dispatcher;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @const
|
||||
* @type {!Object.<string, function(Event)>}
|
||||
*/
|
||||
this.mapping_ = mapping;
|
||||
}
|
||||
this.mapping_ = mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* List of events supported by this source.
|
||||
* @return {Array.<string>} Event names
|
||||
*/
|
||||
getEvents() {
|
||||
return Object.keys(this.mapping_);
|
||||
}
|
||||
getEvents() {
|
||||
return Object.keys(this.mapping_);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the handler that should handle a given event type.
|
||||
* @param {string} eventType The event type.
|
||||
* @return {function(Event)} Handler
|
||||
*/
|
||||
getHandlerForEvent(eventType) {
|
||||
return this.mapping_[eventType];
|
||||
}
|
||||
getHandlerForEvent(eventType) {
|
||||
return this.mapping_[eventType];
|
||||
}
|
||||
}
|
||||
|
||||
export default EventSource;
|
||||
|
||||
@@ -34,6 +34,27 @@
|
||||
import {inherits} from '../util.js';
|
||||
import EventSource from '../pointer/EventSource.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const POINTER_ID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
export const POINTER_TYPE = 'mouse';
|
||||
|
||||
|
||||
/**
|
||||
* Radius around touchend that swallows mouse events.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const DEDUP_DIST = 25;
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
|
||||
* @constructor
|
||||
@@ -195,26 +216,6 @@ class MouseSource {
|
||||
inherits(MouseSource, EventSource);
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const POINTER_ID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
export const POINTER_TYPE = 'mouse';
|
||||
|
||||
|
||||
/**
|
||||
* Radius around touchend that swallows mouse events.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const DEDUP_DIST = 25;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a copy of the original event that will be used
|
||||
* for the fake pointer event.
|
||||
|
||||
@@ -34,143 +34,6 @@
|
||||
import {inherits} from '../util.js';
|
||||
import EventSource from '../pointer/EventSource.js';
|
||||
|
||||
/**
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
|
||||
* @constructor
|
||||
* @extends {module:ol/pointer/EventSource}
|
||||
*/
|
||||
class MsSource {
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'MSPointerDown': this.msPointerDown,
|
||||
'MSPointerMove': this.msPointerMove,
|
||||
'MSPointerUp': this.msPointerUp,
|
||||
'MSPointerOut': this.msPointerOut,
|
||||
'MSPointerOver': this.msPointerOver,
|
||||
'MSPointerCancel': this.msPointerCancel,
|
||||
'MSGotPointerCapture': this.msGotPointerCapture,
|
||||
'MSLostPointerCapture': this.msLostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {!Object.<string, MSPointerEvent|Object>}
|
||||
*/
|
||||
this.pointerMap = dispatcher.pointerMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the original event that will be used
|
||||
* for the fake pointer event.
|
||||
*
|
||||
* @private
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
* @return {Object} The copied event.
|
||||
*/
|
||||
prepareEvent_(inEvent) {
|
||||
let e = inEvent;
|
||||
if (typeof inEvent.pointerType === 'number') {
|
||||
e = this.dispatcher.cloneEvent(inEvent, inEvent);
|
||||
e.pointerType = POINTER_TYPES[inEvent.pointerType];
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this pointer from the list of active pointers.
|
||||
* @param {number} pointerId Pointer identifier.
|
||||
*/
|
||||
cleanup(pointerId) {
|
||||
delete this.pointerMap[pointerId.toString()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerDown`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerDown(inEvent) {
|
||||
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.down(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerMove`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerMove(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.move(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerUp`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerUp(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.up(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOut`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOut(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.leaveOut(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOver`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOver(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.enterOver(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerCancel`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerCancel(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.cancel(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msLostPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msLostPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msGotPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msGotPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MsSource, EventSource);
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -185,4 +48,142 @@ const POINTER_TYPES = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
|
||||
* @constructor
|
||||
* @extends {module:ol/pointer/EventSource}
|
||||
*/
|
||||
class MsSource {
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'MSPointerDown': this.msPointerDown,
|
||||
'MSPointerMove': this.msPointerMove,
|
||||
'MSPointerUp': this.msPointerUp,
|
||||
'MSPointerOut': this.msPointerOut,
|
||||
'MSPointerOver': this.msPointerOver,
|
||||
'MSPointerCancel': this.msPointerCancel,
|
||||
'MSGotPointerCapture': this.msGotPointerCapture,
|
||||
'MSLostPointerCapture': this.msLostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {!Object.<string, MSPointerEvent|Object>}
|
||||
*/
|
||||
this.pointerMap = dispatcher.pointerMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the original event that will be used
|
||||
* for the fake pointer event.
|
||||
*
|
||||
* @private
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
* @return {Object} The copied event.
|
||||
*/
|
||||
prepareEvent_(inEvent) {
|
||||
let e = inEvent;
|
||||
if (typeof inEvent.pointerType === 'number') {
|
||||
e = this.dispatcher.cloneEvent(inEvent, inEvent);
|
||||
e.pointerType = POINTER_TYPES[inEvent.pointerType];
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this pointer from the list of active pointers.
|
||||
* @param {number} pointerId Pointer identifier.
|
||||
*/
|
||||
cleanup(pointerId) {
|
||||
delete this.pointerMap[pointerId.toString()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerDown`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerDown(inEvent) {
|
||||
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.down(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerMove`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerMove(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.move(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerUp`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerUp(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.up(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOut`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOut(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.leaveOut(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOver`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOver(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.enterOver(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerCancel`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerCancel(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.cancel(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msLostPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msLostPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msGotPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msGotPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MsSource, EventSource);
|
||||
|
||||
export default MsSource;
|
||||
|
||||
@@ -40,91 +40,91 @@ import EventSource from '../pointer/EventSource.js';
|
||||
* @extends {module:ol/pointer/EventSource}
|
||||
*/
|
||||
class NativeSource {
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'pointerdown': this.pointerDown,
|
||||
'pointermove': this.pointerMove,
|
||||
'pointerup': this.pointerUp,
|
||||
'pointerout': this.pointerOut,
|
||||
'pointerover': this.pointerOver,
|
||||
'pointercancel': this.pointerCancel,
|
||||
'gotpointercapture': this.gotPointerCapture,
|
||||
'lostpointercapture': this.lostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
}
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'pointerdown': this.pointerDown,
|
||||
'pointermove': this.pointerMove,
|
||||
'pointerup': this.pointerUp,
|
||||
'pointerout': this.pointerOut,
|
||||
'pointerover': this.pointerOver,
|
||||
'pointercancel': this.pointerCancel,
|
||||
'gotpointercapture': this.gotPointerCapture,
|
||||
'lostpointercapture': this.lostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerdown`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerDown(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerDown(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointermove`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerMove(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerMove(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerup`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerUp(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerUp(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerout`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerOut(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerOut(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerover`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerOver(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerOver(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointercancel`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerCancel(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerCancel(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `lostpointercapture`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
lostPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
lostPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `gotpointercapture`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
gotPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
gotPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(NativeSource, EventSource);
|
||||
|
||||
@@ -34,6 +34,14 @@
|
||||
import {inherits} from '../util.js';
|
||||
import Event from '../events/Event.js';
|
||||
|
||||
|
||||
/**
|
||||
* Is the `buttons` property supported?
|
||||
* @type {boolean}
|
||||
*/
|
||||
let HAS_BUTTONS = false;
|
||||
|
||||
|
||||
/**
|
||||
* A class for pointer events.
|
||||
*
|
||||
@@ -48,221 +56,214 @@ import Event from '../events/Event.js';
|
||||
* initial event properties.
|
||||
*/
|
||||
class PointerEvent {
|
||||
constructor(type, originalEvent, opt_eventDict) {
|
||||
Event.call(this, type);
|
||||
constructor(type, originalEvent, opt_eventDict) {
|
||||
Event.call(this, type);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @const
|
||||
* @type {Event}
|
||||
*/
|
||||
this.originalEvent = originalEvent;
|
||||
this.originalEvent = originalEvent;
|
||||
|
||||
const eventDict = opt_eventDict ? opt_eventDict : {};
|
||||
const eventDict = opt_eventDict ? opt_eventDict : {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.buttons = this.getButtons_(eventDict);
|
||||
this.buttons = this.getButtons_(eventDict);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.pressure = this.getPressure_(eventDict, this.buttons);
|
||||
this.pressure = this.getPressure_(eventDict, this.buttons);
|
||||
|
||||
// MouseEvent related properties
|
||||
// MouseEvent related properties
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.bubbles = 'bubbles' in eventDict ? eventDict['bubbles'] : false;
|
||||
this.bubbles = 'bubbles' in eventDict ? eventDict['bubbles'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.cancelable = 'cancelable' in eventDict ? eventDict['cancelable'] : false;
|
||||
this.cancelable = 'cancelable' in eventDict ? eventDict['cancelable'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
this.view = 'view' in eventDict ? eventDict['view'] : null;
|
||||
this.view = 'view' in eventDict ? eventDict['view'] : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.detail = 'detail' in eventDict ? eventDict['detail'] : null;
|
||||
this.detail = 'detail' in eventDict ? eventDict['detail'] : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.screenX = 'screenX' in eventDict ? eventDict['screenX'] : 0;
|
||||
this.screenX = 'screenX' in eventDict ? eventDict['screenX'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.screenY = 'screenY' in eventDict ? eventDict['screenY'] : 0;
|
||||
this.screenY = 'screenY' in eventDict ? eventDict['screenY'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.clientX = 'clientX' in eventDict ? eventDict['clientX'] : 0;
|
||||
this.clientX = 'clientX' in eventDict ? eventDict['clientX'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.clientY = 'clientY' in eventDict ? eventDict['clientY'] : 0;
|
||||
this.clientY = 'clientY' in eventDict ? eventDict['clientY'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.ctrlKey = 'ctrlKey' in eventDict ? eventDict['ctrlKey'] : false;
|
||||
this.ctrlKey = 'ctrlKey' in eventDict ? eventDict['ctrlKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.altKey = 'altKey' in eventDict ? eventDict['altKey'] : false;
|
||||
this.altKey = 'altKey' in eventDict ? eventDict['altKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.shiftKey = 'shiftKey' in eventDict ? eventDict['shiftKey'] : false;
|
||||
this.shiftKey = 'shiftKey' in eventDict ? eventDict['shiftKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.metaKey = 'metaKey' in eventDict ? eventDict['metaKey'] : false;
|
||||
this.metaKey = 'metaKey' in eventDict ? eventDict['metaKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.button = 'button' in eventDict ? eventDict['button'] : 0;
|
||||
this.button = 'button' in eventDict ? eventDict['button'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {Node}
|
||||
*/
|
||||
this.relatedTarget = 'relatedTarget' in eventDict ?
|
||||
eventDict['relatedTarget'] : null;
|
||||
this.relatedTarget = 'relatedTarget' in eventDict ?
|
||||
eventDict['relatedTarget'] : null;
|
||||
|
||||
// PointerEvent related properties
|
||||
// PointerEvent related properties
|
||||
|
||||
/**
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
this.pointerId = 'pointerId' in eventDict ? eventDict['pointerId'] : 0;
|
||||
this.pointerId = 'pointerId' in eventDict ? eventDict['pointerId'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.width = 'width' in eventDict ? eventDict['width'] : 0;
|
||||
this.width = 'width' in eventDict ? eventDict['width'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.height = 'height' in eventDict ? eventDict['height'] : 0;
|
||||
this.height = 'height' in eventDict ? eventDict['height'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.tiltX = 'tiltX' in eventDict ? eventDict['tiltX'] : 0;
|
||||
this.tiltX = 'tiltX' in eventDict ? eventDict['tiltX'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.tiltY = 'tiltY' in eventDict ? eventDict['tiltY'] : 0;
|
||||
this.tiltY = 'tiltY' in eventDict ? eventDict['tiltY'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
this.pointerType = 'pointerType' in eventDict ? eventDict['pointerType'] : '';
|
||||
this.pointerType = 'pointerType' in eventDict ? eventDict['pointerType'] : '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.hwTimestamp = 'hwTimestamp' in eventDict ? eventDict['hwTimestamp'] : 0;
|
||||
this.hwTimestamp = 'hwTimestamp' in eventDict ? eventDict['hwTimestamp'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isPrimary = 'isPrimary' in eventDict ? eventDict['isPrimary'] : false;
|
||||
this.isPrimary = 'isPrimary' in eventDict ? eventDict['isPrimary'] : false;
|
||||
|
||||
// keep the semantics of preventDefault
|
||||
if (originalEvent.preventDefault) {
|
||||
this.preventDefault = function() {
|
||||
originalEvent.preventDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
// keep the semantics of preventDefault
|
||||
if (originalEvent.preventDefault) {
|
||||
this.preventDefault = function() {
|
||||
originalEvent.preventDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @param {Object.<string, ?>} eventDict The event dictionary.
|
||||
* @return {number} Button indicator.
|
||||
*/
|
||||
getButtons_(eventDict) {
|
||||
// According to the w3c spec,
|
||||
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
|
||||
// MouseEvent.button == 0 can mean either no mouse button depressed, or the
|
||||
// left mouse button depressed.
|
||||
//
|
||||
// As of now, the only way to distinguish between the two states of
|
||||
// MouseEvent.button is by using the deprecated MouseEvent.which property, as
|
||||
// this maps mouse buttons to positive integers > 0, and uses 0 to mean that
|
||||
// no mouse button is held.
|
||||
//
|
||||
// MouseEvent.which is derived from MouseEvent.button at MouseEvent creation,
|
||||
// but initMouseEvent does not expose an argument with which to set
|
||||
// MouseEvent.which. Calling initMouseEvent with a buttonArg of 0 will set
|
||||
// MouseEvent.button == 0 and MouseEvent.which == 1, breaking the expectations
|
||||
// of app developers.
|
||||
//
|
||||
// The only way to propagate the correct state of MouseEvent.which and
|
||||
// MouseEvent.button to a new MouseEvent.button == 0 and MouseEvent.which == 0
|
||||
// is to call initMouseEvent with a buttonArg value of -1.
|
||||
//
|
||||
// This is fixed with DOM Level 4's use of buttons
|
||||
let buttons;
|
||||
if (eventDict.buttons || HAS_BUTTONS) {
|
||||
buttons = eventDict.buttons;
|
||||
} else {
|
||||
switch (eventDict.which) {
|
||||
case 1: buttons = 1; break;
|
||||
case 2: buttons = 4; break;
|
||||
case 3: buttons = 2; break;
|
||||
default: buttons = 0;
|
||||
}
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
getButtons_(eventDict) {
|
||||
// According to the w3c spec,
|
||||
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
|
||||
// MouseEvent.button == 0 can mean either no mouse button depressed, or the
|
||||
// left mouse button depressed.
|
||||
//
|
||||
// As of now, the only way to distinguish between the two states of
|
||||
// MouseEvent.button is by using the deprecated MouseEvent.which property, as
|
||||
// this maps mouse buttons to positive integers > 0, and uses 0 to mean that
|
||||
// no mouse button is held.
|
||||
//
|
||||
// MouseEvent.which is derived from MouseEvent.button at MouseEvent creation,
|
||||
// but initMouseEvent does not expose an argument with which to set
|
||||
// MouseEvent.which. Calling initMouseEvent with a buttonArg of 0 will set
|
||||
// MouseEvent.button == 0 and MouseEvent.which == 1, breaking the expectations
|
||||
// of app developers.
|
||||
//
|
||||
// The only way to propagate the correct state of MouseEvent.which and
|
||||
// MouseEvent.button to a new MouseEvent.button == 0 and MouseEvent.which == 0
|
||||
// is to call initMouseEvent with a buttonArg value of -1.
|
||||
//
|
||||
// This is fixed with DOM Level 4's use of buttons
|
||||
let buttons;
|
||||
if (eventDict.buttons || HAS_BUTTONS) {
|
||||
buttons = eventDict.buttons;
|
||||
} else {
|
||||
switch (eventDict.which) {
|
||||
case 1: buttons = 1; break;
|
||||
case 2: buttons = 4; break;
|
||||
case 3: buttons = 2; break;
|
||||
default: buttons = 0;
|
||||
}
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @param {Object.<string, ?>} eventDict The event dictionary.
|
||||
* @param {number} buttons Button indicator.
|
||||
* @return {number} The pressure.
|
||||
*/
|
||||
getPressure_(eventDict, buttons) {
|
||||
// Spec requires that pointers without pressure specified use 0.5 for down
|
||||
// state and 0 for up state.
|
||||
let pressure = 0;
|
||||
if (eventDict.pressure) {
|
||||
pressure = eventDict.pressure;
|
||||
} else {
|
||||
pressure = buttons ? 0.5 : 0;
|
||||
}
|
||||
return pressure;
|
||||
}
|
||||
getPressure_(eventDict, buttons) {
|
||||
// Spec requires that pointers without pressure specified use 0.5 for down
|
||||
// state and 0 for up state.
|
||||
let pressure = 0;
|
||||
if (eventDict.pressure) {
|
||||
pressure = eventDict.pressure;
|
||||
} else {
|
||||
pressure = buttons ? 0.5 : 0;
|
||||
}
|
||||
return pressure;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(PointerEvent, Event);
|
||||
|
||||
|
||||
/**
|
||||
* Is the `buttons` property supported?
|
||||
* @type {boolean}
|
||||
*/
|
||||
let HAS_BUTTONS = false;
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the `buttons` property is supported.
|
||||
*/
|
||||
@@ -274,4 +275,5 @@ let HAS_BUTTONS = false;
|
||||
// pass
|
||||
}
|
||||
})();
|
||||
|
||||
export default PointerEvent;
|
||||
|
||||
@@ -42,6 +42,47 @@ import NativeSource from '../pointer/NativeSource.js';
|
||||
import PointerEvent from '../pointer/PointerEvent.js';
|
||||
import TouchSource from '../pointer/TouchSource.js';
|
||||
|
||||
|
||||
/**
|
||||
* Properties to copy when cloning an event, with default values.
|
||||
* @type {Array.<Array>}
|
||||
*/
|
||||
const CLONE_PROPS = [
|
||||
// MouseEvent
|
||||
['bubbles', false],
|
||||
['cancelable', false],
|
||||
['view', null],
|
||||
['detail', null],
|
||||
['screenX', 0],
|
||||
['screenY', 0],
|
||||
['clientX', 0],
|
||||
['clientY', 0],
|
||||
['ctrlKey', false],
|
||||
['altKey', false],
|
||||
['shiftKey', false],
|
||||
['metaKey', false],
|
||||
['button', 0],
|
||||
['relatedTarget', null],
|
||||
// DOM Level 3
|
||||
['buttons', 0],
|
||||
// PointerEvent
|
||||
['pointerId', 0],
|
||||
['width', 0],
|
||||
['height', 0],
|
||||
['pressure', 0],
|
||||
['tiltX', 0],
|
||||
['tiltY', 0],
|
||||
['pointerType', ''],
|
||||
['hwTimestamp', 0],
|
||||
['isPrimary', false],
|
||||
// event instance
|
||||
['type', ''],
|
||||
['target', null],
|
||||
['currentTarget', null],
|
||||
['which', 0]
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {module:ol/events/EventTarget}
|
||||
@@ -377,44 +418,4 @@ class PointerEventHandler {
|
||||
|
||||
inherits(PointerEventHandler, EventTarget);
|
||||
|
||||
/**
|
||||
* Properties to copy when cloning an event, with default values.
|
||||
* @type {Array.<Array>}
|
||||
*/
|
||||
const CLONE_PROPS = [
|
||||
// MouseEvent
|
||||
['bubbles', false],
|
||||
['cancelable', false],
|
||||
['view', null],
|
||||
['detail', null],
|
||||
['screenX', 0],
|
||||
['screenY', 0],
|
||||
['clientX', 0],
|
||||
['clientY', 0],
|
||||
['ctrlKey', false],
|
||||
['altKey', false],
|
||||
['shiftKey', false],
|
||||
['metaKey', false],
|
||||
['button', 0],
|
||||
['relatedTarget', null],
|
||||
// DOM Level 3
|
||||
['buttons', 0],
|
||||
// PointerEvent
|
||||
['pointerId', 0],
|
||||
['width', 0],
|
||||
['height', 0],
|
||||
['pressure', 0],
|
||||
['tiltX', 0],
|
||||
['tiltY', 0],
|
||||
['pointerType', ''],
|
||||
['hwTimestamp', 0],
|
||||
['isPrimary', false],
|
||||
// event instance
|
||||
['type', ''],
|
||||
['target', null],
|
||||
['currentTarget', null],
|
||||
['which', 0]
|
||||
];
|
||||
|
||||
|
||||
export default PointerEventHandler;
|
||||
|
||||
@@ -37,6 +37,18 @@ import EventSource from '../pointer/EventSource.js';
|
||||
import {POINTER_ID} from '../pointer/MouseSource.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
const CLICK_COUNT_TIMEOUT = 200;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const POINTER_TYPE = 'touch';
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher The event handler.
|
||||
@@ -411,15 +423,4 @@ class TouchSource {
|
||||
inherits(TouchSource, EventSource);
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
const CLICK_COUNT_TIMEOUT = 200;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const POINTER_TYPE = 'touch';
|
||||
|
||||
export default TouchSource;
|
||||
|
||||
@@ -13,117 +13,117 @@ import Polygon from '../geom/Polygon.js';
|
||||
* @param {string} className CSS class name.
|
||||
*/
|
||||
class RenderBox {
|
||||
constructor(className) {
|
||||
constructor(className) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {module:ol/geom/Polygon}
|
||||
* @private
|
||||
*/
|
||||
this.geometry_ = null;
|
||||
this.geometry_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {HTMLDivElement}
|
||||
* @private
|
||||
*/
|
||||
this.element_ = /** @type {HTMLDivElement} */ (document.createElement('div'));
|
||||
this.element_.style.position = 'absolute';
|
||||
this.element_.className = 'ol-box ' + className;
|
||||
this.element_ = /** @type {HTMLDivElement} */ (document.createElement('div'));
|
||||
this.element_.style.position = 'absolute';
|
||||
this.element_.className = 'ol-box ' + className;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/PluggableMap}
|
||||
*/
|
||||
this.map_ = null;
|
||||
this.map_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
*/
|
||||
this.startPixel_ = null;
|
||||
this.startPixel_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
*/
|
||||
this.endPixel_ = null;
|
||||
this.endPixel_ = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
this.setMap(null);
|
||||
}
|
||||
disposeInternal() {
|
||||
this.setMap(null);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
render_() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const px = 'px';
|
||||
const style = this.element_.style;
|
||||
style.left = Math.min(startPixel[0], endPixel[0]) + px;
|
||||
style.top = Math.min(startPixel[1], endPixel[1]) + px;
|
||||
style.width = Math.abs(endPixel[0] - startPixel[0]) + px;
|
||||
style.height = Math.abs(endPixel[1] - startPixel[1]) + px;
|
||||
}
|
||||
render_() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const px = 'px';
|
||||
const style = this.element_.style;
|
||||
style.left = Math.min(startPixel[0], endPixel[0]) + px;
|
||||
style.top = Math.min(startPixel[1], endPixel[1]) + px;
|
||||
style.width = Math.abs(endPixel[0] - startPixel[0]) + px;
|
||||
style.height = Math.abs(endPixel[1] - startPixel[1]) + px;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/PluggableMap} map Map.
|
||||
*/
|
||||
setMap(map) {
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().removeChild(this.element_);
|
||||
const style = this.element_.style;
|
||||
style.left = style.top = style.width = style.height = 'inherit';
|
||||
}
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().appendChild(this.element_);
|
||||
}
|
||||
}
|
||||
setMap(map) {
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().removeChild(this.element_);
|
||||
const style = this.element_.style;
|
||||
style.left = style.top = style.width = style.height = 'inherit';
|
||||
}
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().appendChild(this.element_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol~Pixel} startPixel Start pixel.
|
||||
* @param {module:ol~Pixel} endPixel End pixel.
|
||||
*/
|
||||
setPixels(startPixel, endPixel) {
|
||||
this.startPixel_ = startPixel;
|
||||
this.endPixel_ = endPixel;
|
||||
this.createOrUpdateGeometry();
|
||||
this.render_();
|
||||
}
|
||||
setPixels(startPixel, endPixel) {
|
||||
this.startPixel_ = startPixel;
|
||||
this.endPixel_ = endPixel;
|
||||
this.createOrUpdateGeometry();
|
||||
this.render_();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates or updates the cached geometry.
|
||||
*/
|
||||
createOrUpdateGeometry() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const pixels = [
|
||||
startPixel,
|
||||
[startPixel[0], endPixel[1]],
|
||||
endPixel,
|
||||
[endPixel[0], startPixel[1]]
|
||||
];
|
||||
const coordinates = pixels.map(this.map_.getCoordinateFromPixel, this.map_);
|
||||
// close the polygon
|
||||
coordinates[4] = coordinates[0].slice();
|
||||
if (!this.geometry_) {
|
||||
this.geometry_ = new Polygon([coordinates]);
|
||||
} else {
|
||||
this.geometry_.setCoordinates([coordinates]);
|
||||
}
|
||||
}
|
||||
createOrUpdateGeometry() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const pixels = [
|
||||
startPixel,
|
||||
[startPixel[0], endPixel[1]],
|
||||
endPixel,
|
||||
[endPixel[0], startPixel[1]]
|
||||
];
|
||||
const coordinates = pixels.map(this.map_.getCoordinateFromPixel, this.map_);
|
||||
// close the polygon
|
||||
coordinates[4] = coordinates[0].slice();
|
||||
if (!this.geometry_) {
|
||||
this.geometry_ = new Polygon([coordinates]);
|
||||
} else {
|
||||
this.geometry_.setCoordinates([coordinates]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/geom/Polygon} Geometry.
|
||||
*/
|
||||
getGeometry() {
|
||||
return this.geometry_;
|
||||
}
|
||||
getGeometry() {
|
||||
return this.geometry_;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(RenderBox, Disposable);
|
||||
|
||||
@@ -12,6 +12,13 @@ import {get as getProjection} from '../proj.js';
|
||||
import {transform2D} from '../geom/flat/transform.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../transform.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
* Lightweight, read-only, {@link module:ol/Feature~Feature} and {@link module:ol/geom/Geometry~Geometry} like
|
||||
* structure, optimized for vector tile rendering and styling. Geometry access
|
||||
@@ -26,219 +33,213 @@ import {create as createTransform, compose as composeTransform} from '../transfo
|
||||
* @param {number|string|undefined} id Feature id.
|
||||
*/
|
||||
class RenderFeature {
|
||||
constructor(type, flatCoordinates, ends, properties, id) {
|
||||
/**
|
||||
constructor(type, flatCoordinates, ends, properties, id) {
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/extent~Extent|undefined}
|
||||
*/
|
||||
this.extent_;
|
||||
this.extent_;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|string|undefined}
|
||||
*/
|
||||
this.id_ = id;
|
||||
this.id_ = id;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/geom/GeometryType}
|
||||
*/
|
||||
this.type_ = type;
|
||||
this.type_ = type;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.flatCoordinates_ = flatCoordinates;
|
||||
this.flatCoordinates_ = flatCoordinates;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.flatInteriorPoints_ = null;
|
||||
this.flatInteriorPoints_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.flatMidpoints_ = null;
|
||||
this.flatMidpoints_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>|Array.<Array.<number>>}
|
||||
*/
|
||||
this.ends_ = ends;
|
||||
this.ends_ = ends;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Object.<string, *>}
|
||||
*/
|
||||
this.properties_ = properties;
|
||||
this.properties_ = properties;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get a feature property by its key.
|
||||
* @param {string} key Key
|
||||
* @return {*} Value for the requested key.
|
||||
* @api
|
||||
*/
|
||||
get(key) {
|
||||
return this.properties_[key];
|
||||
}
|
||||
get(key) {
|
||||
return this.properties_[key];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the extent of this feature's geometry.
|
||||
* @return {module:ol/extent~Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
getExtent() {
|
||||
if (!this.extent_) {
|
||||
this.extent_ = this.type_ === GeometryType.POINT ?
|
||||
createOrUpdateFromCoordinate(this.flatCoordinates_) :
|
||||
createOrUpdateFromFlatCoordinates(
|
||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2);
|
||||
getExtent() {
|
||||
if (!this.extent_) {
|
||||
this.extent_ = this.type_ === GeometryType.POINT ?
|
||||
createOrUpdateFromCoordinate(this.flatCoordinates_) :
|
||||
createOrUpdateFromFlatCoordinates(
|
||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2);
|
||||
|
||||
}
|
||||
return this.extent_;
|
||||
}
|
||||
}
|
||||
return this.extent_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {Array.<number>} Flat interior points.
|
||||
*/
|
||||
getFlatInteriorPoint() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
const flatCenter = getCenter(this.getExtent());
|
||||
this.flatInteriorPoints_ = getInteriorPointOfArray(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0);
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
}
|
||||
getFlatInteriorPoint() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
const flatCenter = getCenter(this.getExtent());
|
||||
this.flatInteriorPoints_ = getInteriorPointOfArray(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0);
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {Array.<number>} Flat interior points.
|
||||
*/
|
||||
getFlatInteriorPoints() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
const flatCenters = linearRingssCenter(
|
||||
this.flatCoordinates_, 0, this.ends_, 2);
|
||||
this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
}
|
||||
getFlatInteriorPoints() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
const flatCenters = linearRingssCenter(
|
||||
this.flatCoordinates_, 0, this.ends_, 2);
|
||||
this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {Array.<number>} Flat midpoint.
|
||||
*/
|
||||
getFlatMidpoint() {
|
||||
if (!this.flatMidpoints_) {
|
||||
this.flatMidpoints_ = interpolatePoint(
|
||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
|
||||
}
|
||||
return this.flatMidpoints_;
|
||||
}
|
||||
getFlatMidpoint() {
|
||||
if (!this.flatMidpoints_) {
|
||||
this.flatMidpoints_ = interpolatePoint(
|
||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
|
||||
}
|
||||
return this.flatMidpoints_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {Array.<number>} Flat midpoints.
|
||||
*/
|
||||
getFlatMidpoints() {
|
||||
if (!this.flatMidpoints_) {
|
||||
this.flatMidpoints_ = [];
|
||||
const flatCoordinates = this.flatCoordinates_;
|
||||
let offset = 0;
|
||||
const ends = this.ends_;
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
const midpoint = interpolatePoint(
|
||||
flatCoordinates, offset, end, 2, 0.5);
|
||||
extend(this.flatMidpoints_, midpoint);
|
||||
offset = end;
|
||||
}
|
||||
}
|
||||
return this.flatMidpoints_;
|
||||
}
|
||||
getFlatMidpoints() {
|
||||
if (!this.flatMidpoints_) {
|
||||
this.flatMidpoints_ = [];
|
||||
const flatCoordinates = this.flatCoordinates_;
|
||||
let offset = 0;
|
||||
const ends = this.ends_;
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
const midpoint = interpolatePoint(
|
||||
flatCoordinates, offset, end, 2, 0.5);
|
||||
extend(this.flatMidpoints_, midpoint);
|
||||
offset = end;
|
||||
}
|
||||
}
|
||||
return this.flatMidpoints_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the feature identifier. This is a stable identifier for the feature and
|
||||
* is set when reading data from a remote source.
|
||||
* @return {number|string|undefined} Id.
|
||||
* @api
|
||||
*/
|
||||
getId() {
|
||||
return this.id_;
|
||||
}
|
||||
getId() {
|
||||
return this.id_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
getOrientedFlatCoordinates() {
|
||||
return this.flatCoordinates_;
|
||||
}
|
||||
getOrientedFlatCoordinates() {
|
||||
return this.flatCoordinates_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when
|
||||
* determining the geometry type in style function (see {@link #getType}).
|
||||
* @return {module:ol/render/Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
getGeometry() {
|
||||
return this;
|
||||
}
|
||||
getGeometry() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the feature properties.
|
||||
* @return {Object.<string, *>} Feature properties.
|
||||
* @api
|
||||
*/
|
||||
getProperties() {
|
||||
return this.properties_;
|
||||
}
|
||||
getProperties() {
|
||||
return this.properties_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Stride.
|
||||
*/
|
||||
getStride() {
|
||||
return 2;
|
||||
}
|
||||
getStride() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the type of this feature's geometry.
|
||||
* @return {module:ol/geom/GeometryType} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return this.type_;
|
||||
}
|
||||
getType() {
|
||||
return this.type_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Transform geometry coordinates from tile pixel space to projected.
|
||||
* The SRS of the source and destination are expected to be the same.
|
||||
*
|
||||
* @param {module:ol/proj~ProjectionLike} source The current projection
|
||||
* @param {module:ol/proj~ProjectionLike} destination The desired projection.
|
||||
*/
|
||||
transform(source, destination) {
|
||||
source = getProjection(source);
|
||||
const pixelExtent = source.getExtent();
|
||||
const projectedExtent = source.getWorldExtent();
|
||||
const scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
composeTransform(tmpTransform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
|
||||
tmpTransform, this.flatCoordinates_);
|
||||
}
|
||||
transform(source, destination) {
|
||||
source = getProjection(source);
|
||||
const pixelExtent = source.getExtent();
|
||||
const projectedExtent = source.getWorldExtent();
|
||||
const scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
composeTransform(tmpTransform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
|
||||
tmpTransform, this.flatCoordinates_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
* @return {Array.<number>|Array.<Array.<number>>} Ends or endss.
|
||||
*/
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
* @abstract
|
||||
*/
|
||||
class ReplayGroup {
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number|undefined} zIndex Z index.
|
||||
* @param {module:ol/render/ReplayType} replayType Replay type.
|
||||
* @return {module:ol/render/VectorContext} Replay.
|
||||
*/
|
||||
getReplay(zIndex, replayType) {}
|
||||
getReplay(zIndex, replayType) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
isEmpty() {}
|
||||
isEmpty() {}
|
||||
}
|
||||
|
||||
export default ReplayGroup;
|
||||
|
||||
@@ -10,107 +10,107 @@
|
||||
* @api
|
||||
*/
|
||||
class VectorContext {
|
||||
/**
|
||||
/**
|
||||
* Render a geometry with a custom renderer.
|
||||
*
|
||||
* @param {module:ol/geom/SimpleGeometry} geometry Geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
* @param {Function} renderer Renderer.
|
||||
*/
|
||||
drawCustom(geometry, feature, renderer) {}
|
||||
drawCustom(geometry, feature, renderer) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Render a geometry.
|
||||
*
|
||||
* @param {module:ol/geom/Geometry} geometry The geometry to render.
|
||||
*/
|
||||
drawGeometry(geometry) {}
|
||||
drawGeometry(geometry) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the rendering style.
|
||||
*
|
||||
* @param {module:ol/style/Style} style The rendering style.
|
||||
*/
|
||||
setStyle(style) {}
|
||||
setStyle(style) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/Circle} circleGeometry Circle geometry.
|
||||
* @param {module:ol/Feature} feature Feature.
|
||||
*/
|
||||
drawCircle(circleGeometry, feature) {}
|
||||
drawCircle(circleGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/Feature} feature Feature.
|
||||
* @param {module:ol/style/Style} style Style.
|
||||
*/
|
||||
drawFeature(feature, style) {}
|
||||
drawFeature(feature, style) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/GeometryCollection} geometryCollectionGeometry Geometry
|
||||
* collection.
|
||||
* @param {module:ol/Feature} feature Feature.
|
||||
*/
|
||||
drawGeometryCollection(geometryCollectionGeometry, feature) {}
|
||||
drawGeometryCollection(geometryCollectionGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/LineString|module:ol/render/Feature} lineStringGeometry Line string geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawLineString(lineStringGeometry, feature) {}
|
||||
drawLineString(lineStringGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/MultiLineString|module:ol/render/Feature} multiLineStringGeometry MultiLineString geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawMultiLineString(multiLineStringGeometry, feature) {}
|
||||
drawMultiLineString(multiLineStringGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/MultiPoint|module:ol/render/Feature} multiPointGeometry MultiPoint geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawMultiPoint(multiPointGeometry, feature) {}
|
||||
drawMultiPoint(multiPointGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/MultiPolygon} multiPolygonGeometry MultiPolygon geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawMultiPolygon(multiPolygonGeometry, feature) {}
|
||||
drawMultiPolygon(multiPolygonGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/Point|module:ol/render/Feature} pointGeometry Point geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawPoint(pointGeometry, feature) {}
|
||||
drawPoint(pointGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/Polygon|module:ol/render/Feature} polygonGeometry Polygon geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawPolygon(polygonGeometry, feature) {}
|
||||
drawPolygon(polygonGeometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/geom/Geometry|module:ol/render/Feature} geometry Geometry.
|
||||
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
|
||||
*/
|
||||
drawText(geometry, feature) {}
|
||||
drawText(geometry, feature) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/style/Fill} fillStyle Fill style.
|
||||
* @param {module:ol/style/Stroke} strokeStyle Stroke style.
|
||||
*/
|
||||
setFillStrokeStyle(fillStyle, strokeStyle) {}
|
||||
setFillStrokeStyle(fillStyle, strokeStyle) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/style/Image} imageStyle Image style.
|
||||
* @param {module:ol/render/canvas~DeclutterGroup=} opt_declutterGroup Declutter.
|
||||
*/
|
||||
setImageStyle(imageStyle, opt_declutterGroup) {}
|
||||
setImageStyle(imageStyle, opt_declutterGroup) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/style/Text} textStyle Text style.
|
||||
* @param {module:ol/render/canvas~DeclutterGroup=} opt_declutterGroup Declutter.
|
||||
*/
|
||||
setTextStyle(textStyle, opt_declutterGroup) {}
|
||||
setTextStyle(textStyle, opt_declutterGroup) {}
|
||||
}
|
||||
|
||||
export default VectorContext;
|
||||
|
||||
@@ -17,97 +17,97 @@ import CanvasReplay from '../canvas/Replay.js';
|
||||
* @struct
|
||||
*/
|
||||
class CanvasImageReplay {
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
CanvasReplay.call(this,
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
constructor(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
CanvasReplay.call(this,
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/render/canvas~DeclutterGroup}
|
||||
*/
|
||||
this.declutterGroup_ = null;
|
||||
this.declutterGroup_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement}
|
||||
*/
|
||||
this.hitDetectionImage_ = null;
|
||||
this.hitDetectionImage_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement}
|
||||
*/
|
||||
this.image_ = null;
|
||||
this.image_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.anchorX_ = undefined;
|
||||
this.anchorX_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.anchorY_ = undefined;
|
||||
this.anchorY_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.height_ = undefined;
|
||||
this.height_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.opacity_ = undefined;
|
||||
this.opacity_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.originX_ = undefined;
|
||||
this.originX_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.originY_ = undefined;
|
||||
this.originY_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.rotateWithView_ = undefined;
|
||||
this.rotateWithView_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.rotation_ = undefined;
|
||||
this.rotation_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.scale_ = undefined;
|
||||
this.scale_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.snapToPixel_ = undefined;
|
||||
this.snapToPixel_ = undefined;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.width_ = undefined;
|
||||
this.width_ = undefined;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {number} end End.
|
||||
@@ -115,114 +115,114 @@ class CanvasImageReplay {
|
||||
* @private
|
||||
* @return {number} My end.
|
||||
*/
|
||||
drawCoordinates_(flatCoordinates, offset, end, stride) {
|
||||
return this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
|
||||
}
|
||||
drawCoordinates_(flatCoordinates, offset, end, stride) {
|
||||
return this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
drawPoint(pointGeometry, feature) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
this.beginGeometry(pointGeometry, feature);
|
||||
const flatCoordinates = pointGeometry.getFlatCoordinates();
|
||||
const stride = pointGeometry.getStride();
|
||||
const myBegin = this.coordinates.length;
|
||||
const myEnd = this.drawCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.instructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.endGeometry(pointGeometry, feature);
|
||||
}
|
||||
drawPoint(pointGeometry, feature) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
this.beginGeometry(pointGeometry, feature);
|
||||
const flatCoordinates = pointGeometry.getFlatCoordinates();
|
||||
const stride = pointGeometry.getStride();
|
||||
const myBegin = this.coordinates.length;
|
||||
const myEnd = this.drawCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.instructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.endGeometry(pointGeometry, feature);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
drawMultiPoint(multiPointGeometry, feature) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
this.beginGeometry(multiPointGeometry, feature);
|
||||
const flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
||||
const stride = multiPointGeometry.getStride();
|
||||
const myBegin = this.coordinates.length;
|
||||
const myEnd = this.drawCoordinates_(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.instructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.endGeometry(multiPointGeometry, feature);
|
||||
}
|
||||
drawMultiPoint(multiPointGeometry, feature) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
this.beginGeometry(multiPointGeometry, feature);
|
||||
const flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
||||
const stride = multiPointGeometry.getStride();
|
||||
const myBegin = this.coordinates.length;
|
||||
const myEnd = this.drawCoordinates_(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.instructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.endGeometry(multiPointGeometry, feature);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
finish() {
|
||||
this.reverseHitDetectionInstructions();
|
||||
// FIXME this doesn't really protect us against further calls to draw*Geometry
|
||||
this.anchorX_ = undefined;
|
||||
this.anchorY_ = undefined;
|
||||
this.hitDetectionImage_ = null;
|
||||
this.image_ = null;
|
||||
this.height_ = undefined;
|
||||
this.scale_ = undefined;
|
||||
this.opacity_ = undefined;
|
||||
this.originX_ = undefined;
|
||||
this.originY_ = undefined;
|
||||
this.rotateWithView_ = undefined;
|
||||
this.rotation_ = undefined;
|
||||
this.snapToPixel_ = undefined;
|
||||
this.width_ = undefined;
|
||||
}
|
||||
finish() {
|
||||
this.reverseHitDetectionInstructions();
|
||||
// FIXME this doesn't really protect us against further calls to draw*Geometry
|
||||
this.anchorX_ = undefined;
|
||||
this.anchorY_ = undefined;
|
||||
this.hitDetectionImage_ = null;
|
||||
this.image_ = null;
|
||||
this.height_ = undefined;
|
||||
this.scale_ = undefined;
|
||||
this.opacity_ = undefined;
|
||||
this.originX_ = undefined;
|
||||
this.originY_ = undefined;
|
||||
this.rotateWithView_ = undefined;
|
||||
this.rotation_ = undefined;
|
||||
this.snapToPixel_ = undefined;
|
||||
this.width_ = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
setImageStyle(imageStyle, declutterGroup) {
|
||||
const anchor = imageStyle.getAnchor();
|
||||
const size = imageStyle.getSize();
|
||||
const hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
||||
const image = imageStyle.getImage(1);
|
||||
const origin = imageStyle.getOrigin();
|
||||
this.anchorX_ = anchor[0];
|
||||
this.anchorY_ = anchor[1];
|
||||
this.declutterGroup_ = /** @type {module:ol/render/canvas~DeclutterGroup} */ (declutterGroup);
|
||||
this.hitDetectionImage_ = hitDetectionImage;
|
||||
this.image_ = image;
|
||||
this.height_ = size[1];
|
||||
this.opacity_ = imageStyle.getOpacity();
|
||||
this.originX_ = origin[0];
|
||||
this.originY_ = origin[1];
|
||||
this.rotateWithView_ = imageStyle.getRotateWithView();
|
||||
this.rotation_ = imageStyle.getRotation();
|
||||
this.scale_ = imageStyle.getScale();
|
||||
this.snapToPixel_ = imageStyle.getSnapToPixel();
|
||||
this.width_ = size[0];
|
||||
}
|
||||
setImageStyle(imageStyle, declutterGroup) {
|
||||
const anchor = imageStyle.getAnchor();
|
||||
const size = imageStyle.getSize();
|
||||
const hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
||||
const image = imageStyle.getImage(1);
|
||||
const origin = imageStyle.getOrigin();
|
||||
this.anchorX_ = anchor[0];
|
||||
this.anchorY_ = anchor[1];
|
||||
this.declutterGroup_ = /** @type {module:ol/render/canvas~DeclutterGroup} */ (declutterGroup);
|
||||
this.hitDetectionImage_ = hitDetectionImage;
|
||||
this.image_ = image;
|
||||
this.height_ = size[1];
|
||||
this.opacity_ = imageStyle.getOpacity();
|
||||
this.originX_ = origin[0];
|
||||
this.originY_ = origin[1];
|
||||
this.rotateWithView_ = imageStyle.getRotateWithView();
|
||||
this.rotation_ = imageStyle.getRotation();
|
||||
this.scale_ = imageStyle.getScale();
|
||||
this.snapToPixel_ = imageStyle.getSnapToPixel();
|
||||
this.width_ = size[0];
|
||||
}
|
||||
}
|
||||
|
||||
inherits(CanvasImageReplay, CanvasReplay);
|
||||
|
||||
@@ -28,6 +28,19 @@ import {
|
||||
setFromArray as transformSetFromArray
|
||||
} from '../../transform.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
const tmpExtent = createEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* @type {!module:ol/transform~Transform}
|
||||
*/
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {module:ol/render/VectorContext}
|
||||
@@ -1072,18 +1085,6 @@ class CanvasReplay {
|
||||
inherits(CanvasReplay, VectorContext);
|
||||
|
||||
|
||||
/**
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
const tmpExtent = createEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* @type {!module:ol/transform~Transform}
|
||||
*/
|
||||
const tmpTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
|
||||
@@ -24,23 +24,23 @@ import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TRIANGLES,
|
||||
* @struct
|
||||
*/
|
||||
class WebGLReplay {
|
||||
constructor(tolerance, maxExtent) {
|
||||
VectorContext.call(this);
|
||||
constructor(tolerance, maxExtent) {
|
||||
VectorContext.call(this);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.tolerance = tolerance;
|
||||
this.tolerance = tolerance;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @const
|
||||
* @type {module:ol/extent~Extent}
|
||||
*/
|
||||
this.maxExtent = maxExtent;
|
||||
this.maxExtent = maxExtent;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The origin of the coordinate system for the point coordinates sent to
|
||||
* the GPU. To eliminate jitter caused by precision problems in the GPU
|
||||
* we use the "Rendering Relative to Eye" technique described in the "3D
|
||||
@@ -48,93 +48,93 @@ class WebGLReplay {
|
||||
* @protected
|
||||
* @type {module:ol/coordinate~Coordinate}
|
||||
*/
|
||||
this.origin = getCenter(maxExtent);
|
||||
this.origin = getCenter(maxExtent);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
this.projectionMatrix_ = createTransform();
|
||||
this.projectionMatrix_ = createTransform();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
this.offsetRotateMatrix_ = createTransform();
|
||||
this.offsetRotateMatrix_ = createTransform();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/transform~Transform}
|
||||
*/
|
||||
this.offsetScaleMatrix_ = createTransform();
|
||||
this.offsetScaleMatrix_ = createTransform();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.tmpMat4_ = create();
|
||||
this.tmpMat4_ = create();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.indices = [];
|
||||
this.indices = [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {?module:ol/webgl/Buffer}
|
||||
*/
|
||||
this.indicesBuffer = null;
|
||||
this.indicesBuffer = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Start index per feature (the index).
|
||||
* @protected
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.startIndices = [];
|
||||
this.startIndices = [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* Start index per feature (the feature).
|
||||
* @protected
|
||||
* @type {Array.<module:ol/Feature|module:ol/render/Feature>}
|
||||
*/
|
||||
this.startIndicesFeature = [];
|
||||
this.startIndicesFeature = [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.vertices = [];
|
||||
this.vertices = [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @type {?module:ol/webgl/Buffer}
|
||||
*/
|
||||
this.verticesBuffer = null;
|
||||
this.verticesBuffer = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Optional parameter for PolygonReplay instances.
|
||||
* @protected
|
||||
* @type {module:ol/render/webgl/LineStringReplay|undefined}
|
||||
*/
|
||||
this.lineStringReplay = undefined;
|
||||
this.lineStringReplay = undefined;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/webgl/Context} context WebGL context.
|
||||
* @return {function()} Delete resources function.
|
||||
*/
|
||||
getDeleteResourcesFunction(context) {}
|
||||
getDeleteResourcesFunction(context) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol/webgl/Context} context Context.
|
||||
*/
|
||||
finish(context) {}
|
||||
finish(context) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
@@ -146,9 +146,9 @@ class WebGLReplay {
|
||||
module:ol/render/webgl/polygonreplay/defaultshader/Locations|
|
||||
module:ol/render/webgl/texturereplay/defaultshader/Locations} Locations.
|
||||
*/
|
||||
setUpProgram(gl, context, size, pixelRatio) {}
|
||||
setUpProgram(gl, context, size, pixelRatio) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
@@ -157,9 +157,9 @@ class WebGLReplay {
|
||||
module:ol/render/webgl/polygonreplay/defaultshader/Locations|
|
||||
module:ol/render/webgl/texturereplay/defaultshader/Locations} locations Locations.
|
||||
*/
|
||||
shutDownProgram(gl, locations) {}
|
||||
shutDownProgram(gl, locations) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
@@ -167,9 +167,9 @@ class WebGLReplay {
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features to skip.
|
||||
* @param {boolean} hitDetection Hit detection mode.
|
||||
*/
|
||||
drawReplay(gl, context, skippedFeaturesHash, hitDetection) {}
|
||||
drawReplay(gl, context, skippedFeaturesHash, hitDetection) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
@@ -180,9 +180,9 @@ class WebGLReplay {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {}
|
||||
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
* @param {module:ol/webgl/Context} context Context.
|
||||
@@ -194,19 +194,19 @@ class WebGLReplay {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
drawHitDetectionReplay(gl, context, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) {
|
||||
if (!oneByOne) {
|
||||
// draw all hit-detection features in "once" (by texture group)
|
||||
return this.drawHitDetectionReplayAll(gl, context,
|
||||
skippedFeaturesHash, featureCallback);
|
||||
} else {
|
||||
// draw hit-detection features one by one
|
||||
return this.drawHitDetectionReplayOneByOne(gl, context,
|
||||
skippedFeaturesHash, featureCallback, opt_hitExtent);
|
||||
}
|
||||
}
|
||||
drawHitDetectionReplay(gl, context, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) {
|
||||
if (!oneByOne) {
|
||||
// draw all hit-detection features in "once" (by texture group)
|
||||
return this.drawHitDetectionReplayAll(gl, context,
|
||||
skippedFeaturesHash, featureCallback);
|
||||
} else {
|
||||
// draw hit-detection features one by one
|
||||
return this.drawHitDetectionReplayOneByOne(gl, context,
|
||||
skippedFeaturesHash, featureCallback, opt_hitExtent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
* @param {module:ol/webgl/Context} context Context.
|
||||
@@ -215,19 +215,19 @@ class WebGLReplay {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
drawHitDetectionReplayAll(gl, context, skippedFeaturesHash, featureCallback) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
this.drawReplay(gl, context, skippedFeaturesHash, true);
|
||||
drawHitDetectionReplayAll(gl, context, skippedFeaturesHash, featureCallback) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
this.drawReplay(gl, context, skippedFeaturesHash, true);
|
||||
|
||||
const result = featureCallback(null);
|
||||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
const result = featureCallback(null);
|
||||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/webgl/Context} context Context.
|
||||
* @param {module:ol/coordinate~Coordinate} center Center.
|
||||
* @param {number} resolution Resolution.
|
||||
@@ -243,120 +243,120 @@ class WebGLReplay {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
replay(
|
||||
context,
|
||||
center,
|
||||
resolution,
|
||||
rotation,
|
||||
size,
|
||||
pixelRatio,
|
||||
opacity,
|
||||
skippedFeaturesHash,
|
||||
featureCallback,
|
||||
oneByOne,
|
||||
opt_hitExtent
|
||||
) {
|
||||
const gl = context.getGL();
|
||||
let tmpStencil, tmpStencilFunc, tmpStencilMaskVal, tmpStencilRef, tmpStencilMask,
|
||||
tmpStencilOpFail, tmpStencilOpPass, tmpStencilOpZFail;
|
||||
replay(
|
||||
context,
|
||||
center,
|
||||
resolution,
|
||||
rotation,
|
||||
size,
|
||||
pixelRatio,
|
||||
opacity,
|
||||
skippedFeaturesHash,
|
||||
featureCallback,
|
||||
oneByOne,
|
||||
opt_hitExtent
|
||||
) {
|
||||
const gl = context.getGL();
|
||||
let tmpStencil, tmpStencilFunc, tmpStencilMaskVal, tmpStencilRef, tmpStencilMask,
|
||||
tmpStencilOpFail, tmpStencilOpPass, tmpStencilOpZFail;
|
||||
|
||||
if (this.lineStringReplay) {
|
||||
tmpStencil = gl.isEnabled(gl.STENCIL_TEST);
|
||||
tmpStencilFunc = gl.getParameter(gl.STENCIL_FUNC);
|
||||
tmpStencilMaskVal = gl.getParameter(gl.STENCIL_VALUE_MASK);
|
||||
tmpStencilRef = gl.getParameter(gl.STENCIL_REF);
|
||||
tmpStencilMask = gl.getParameter(gl.STENCIL_WRITEMASK);
|
||||
tmpStencilOpFail = gl.getParameter(gl.STENCIL_FAIL);
|
||||
tmpStencilOpPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS);
|
||||
tmpStencilOpZFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL);
|
||||
if (this.lineStringReplay) {
|
||||
tmpStencil = gl.isEnabled(gl.STENCIL_TEST);
|
||||
tmpStencilFunc = gl.getParameter(gl.STENCIL_FUNC);
|
||||
tmpStencilMaskVal = gl.getParameter(gl.STENCIL_VALUE_MASK);
|
||||
tmpStencilRef = gl.getParameter(gl.STENCIL_REF);
|
||||
tmpStencilMask = gl.getParameter(gl.STENCIL_WRITEMASK);
|
||||
tmpStencilOpFail = gl.getParameter(gl.STENCIL_FAIL);
|
||||
tmpStencilOpPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS);
|
||||
tmpStencilOpZFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL);
|
||||
|
||||
gl.enable(gl.STENCIL_TEST);
|
||||
gl.clear(gl.STENCIL_BUFFER_BIT);
|
||||
gl.stencilMask(255);
|
||||
gl.stencilFunc(gl.ALWAYS, 1, 255);
|
||||
gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
|
||||
gl.enable(gl.STENCIL_TEST);
|
||||
gl.clear(gl.STENCIL_BUFFER_BIT);
|
||||
gl.stencilMask(255);
|
||||
gl.stencilFunc(gl.ALWAYS, 1, 255);
|
||||
gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
|
||||
|
||||
this.lineStringReplay.replay(context,
|
||||
center, resolution, rotation, size, pixelRatio,
|
||||
opacity, skippedFeaturesHash,
|
||||
featureCallback, oneByOne, opt_hitExtent);
|
||||
this.lineStringReplay.replay(context,
|
||||
center, resolution, rotation, size, pixelRatio,
|
||||
opacity, skippedFeaturesHash,
|
||||
featureCallback, oneByOne, opt_hitExtent);
|
||||
|
||||
gl.stencilMask(0);
|
||||
gl.stencilFunc(gl.NOTEQUAL, 1, 255);
|
||||
}
|
||||
gl.stencilMask(0);
|
||||
gl.stencilFunc(gl.NOTEQUAL, 1, 255);
|
||||
}
|
||||
|
||||
context.bindBuffer(ARRAY_BUFFER, this.verticesBuffer);
|
||||
context.bindBuffer(ARRAY_BUFFER, this.verticesBuffer);
|
||||
|
||||
context.bindBuffer(ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
|
||||
context.bindBuffer(ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
|
||||
|
||||
const locations = this.setUpProgram(gl, context, size, pixelRatio);
|
||||
const locations = this.setUpProgram(gl, context, size, pixelRatio);
|
||||
|
||||
// set the "uniform" values
|
||||
const projectionMatrix = resetTransform(this.projectionMatrix_);
|
||||
scaleTransform(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1]));
|
||||
rotateTransform(projectionMatrix, -rotation);
|
||||
translateTransform(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1]));
|
||||
// set the "uniform" values
|
||||
const projectionMatrix = resetTransform(this.projectionMatrix_);
|
||||
scaleTransform(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1]));
|
||||
rotateTransform(projectionMatrix, -rotation);
|
||||
translateTransform(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1]));
|
||||
|
||||
const offsetScaleMatrix = resetTransform(this.offsetScaleMatrix_);
|
||||
scaleTransform(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
const offsetScaleMatrix = resetTransform(this.offsetScaleMatrix_);
|
||||
scaleTransform(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
|
||||
const offsetRotateMatrix = resetTransform(this.offsetRotateMatrix_);
|
||||
if (rotation !== 0) {
|
||||
rotateTransform(offsetRotateMatrix, -rotation);
|
||||
}
|
||||
const offsetRotateMatrix = resetTransform(this.offsetRotateMatrix_);
|
||||
if (rotation !== 0) {
|
||||
rotateTransform(offsetRotateMatrix, -rotation);
|
||||
}
|
||||
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
fromTransform(this.tmpMat4_, projectionMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetScaleMatrix, false,
|
||||
fromTransform(this.tmpMat4_, offsetScaleMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false,
|
||||
fromTransform(this.tmpMat4_, offsetRotateMatrix));
|
||||
gl.uniform1f(locations.u_opacity, opacity);
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
fromTransform(this.tmpMat4_, projectionMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetScaleMatrix, false,
|
||||
fromTransform(this.tmpMat4_, offsetScaleMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false,
|
||||
fromTransform(this.tmpMat4_, offsetRotateMatrix));
|
||||
gl.uniform1f(locations.u_opacity, opacity);
|
||||
|
||||
// draw!
|
||||
let result;
|
||||
if (featureCallback === undefined) {
|
||||
this.drawReplay(gl, context, skippedFeaturesHash, false);
|
||||
} else {
|
||||
// draw feature by feature for the hit-detection
|
||||
result = this.drawHitDetectionReplay(gl, context, skippedFeaturesHash,
|
||||
featureCallback, oneByOne, opt_hitExtent);
|
||||
}
|
||||
// draw!
|
||||
let result;
|
||||
if (featureCallback === undefined) {
|
||||
this.drawReplay(gl, context, skippedFeaturesHash, false);
|
||||
} else {
|
||||
// draw feature by feature for the hit-detection
|
||||
result = this.drawHitDetectionReplay(gl, context, skippedFeaturesHash,
|
||||
featureCallback, oneByOne, opt_hitExtent);
|
||||
}
|
||||
|
||||
// disable the vertex attrib arrays
|
||||
this.shutDownProgram(gl, locations);
|
||||
// disable the vertex attrib arrays
|
||||
this.shutDownProgram(gl, locations);
|
||||
|
||||
if (this.lineStringReplay) {
|
||||
if (!tmpStencil) {
|
||||
gl.disable(gl.STENCIL_TEST);
|
||||
}
|
||||
gl.clear(gl.STENCIL_BUFFER_BIT);
|
||||
gl.stencilFunc(/** @type {number} */ (tmpStencilFunc),
|
||||
/** @type {number} */ (tmpStencilRef), /** @type {number} */ (tmpStencilMaskVal));
|
||||
gl.stencilMask(/** @type {number} */ (tmpStencilMask));
|
||||
gl.stencilOp(/** @type {number} */ (tmpStencilOpFail),
|
||||
/** @type {number} */ (tmpStencilOpZFail), /** @type {number} */ (tmpStencilOpPass));
|
||||
}
|
||||
if (this.lineStringReplay) {
|
||||
if (!tmpStencil) {
|
||||
gl.disable(gl.STENCIL_TEST);
|
||||
}
|
||||
gl.clear(gl.STENCIL_BUFFER_BIT);
|
||||
gl.stencilFunc(/** @type {number} */ (tmpStencilFunc),
|
||||
/** @type {number} */ (tmpStencilRef), /** @type {number} */ (tmpStencilMaskVal));
|
||||
gl.stencilMask(/** @type {number} */ (tmpStencilMask));
|
||||
gl.stencilOp(/** @type {number} */ (tmpStencilOpFail),
|
||||
/** @type {number} */ (tmpStencilOpZFail), /** @type {number} */ (tmpStencilOpPass));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @protected
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
* @param {module:ol/webgl/Context} context Context.
|
||||
* @param {number} start Start index.
|
||||
* @param {number} end End index.
|
||||
*/
|
||||
drawElements(gl, context, start, end) {
|
||||
const elementType = context.hasOESElementIndexUint ?
|
||||
UNSIGNED_INT : UNSIGNED_SHORT;
|
||||
const elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||
drawElements(gl, context, start, end) {
|
||||
const elementType = context.hasOESElementIndexUint ?
|
||||
UNSIGNED_INT : UNSIGNED_SHORT;
|
||||
const elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||
|
||||
const numItems = end - start;
|
||||
const offsetInBytes = start * elementSize;
|
||||
gl.drawElements(TRIANGLES, numItems, elementType, offsetInBytes);
|
||||
}
|
||||
const numItems = end - start;
|
||||
const offsetInBytes = start * elementSize;
|
||||
gl.drawElements(TRIANGLES, numItems, elementType, offsetInBytes);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(WebGLReplay, VectorContext);
|
||||
|
||||
@@ -11,6 +11,18 @@ import TileImage from '../source/TileImage.js';
|
||||
import {createOrUpdate, quadKey} from '../tilecoord.js';
|
||||
import {createXYZ, extentFromProjection} from '../tilegrid.js';
|
||||
|
||||
|
||||
/**
|
||||
* The attribution containing a link to the Microsoft® Bing™ Maps Platform APIs’
|
||||
* Terms Of Use.
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
|
||||
'href="https://www.microsoft.com/maps/product/terms.html">' +
|
||||
'Terms of Use</a>';
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {number} [cacheSize=2048] Cache size.
|
||||
@@ -213,16 +225,4 @@ class BingMaps {
|
||||
|
||||
inherits(BingMaps, TileImage);
|
||||
|
||||
|
||||
/**
|
||||
* The attribution containing a link to the Microsoft® Bing™ Maps Platform APIs’
|
||||
* Terms Of Use.
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
const TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
|
||||
'href="https://www.microsoft.com/maps/product/terms.html">' +
|
||||
'Terms of Use</a>';
|
||||
|
||||
|
||||
export default BingMaps;
|
||||
|
||||
@@ -52,73 +52,73 @@ import ImageSource from '../source/Image.js';
|
||||
* @api
|
||||
*/
|
||||
class ImageCanvasSource {
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
ImageSource.call(this, {
|
||||
attributions: options.attributions,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
state: options.state
|
||||
});
|
||||
ImageSource.call(this, {
|
||||
attributions: options.attributions,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
state: options.state
|
||||
});
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/source/ImageCanvas~FunctionType}
|
||||
*/
|
||||
this.canvasFunction_ = options.canvasFunction;
|
||||
this.canvasFunction_ = options.canvasFunction;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/ImageCanvas}
|
||||
*/
|
||||
this.canvas_ = null;
|
||||
this.canvas_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.renderedRevision_ = 0;
|
||||
this.renderedRevision_ = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.ratio_ = options.ratio !== undefined ?
|
||||
options.ratio : 1.5;
|
||||
this.ratio_ = options.ratio !== undefined ?
|
||||
options.ratio : 1.5;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getImageInternal(extent, resolution, pixelRatio, projection) {
|
||||
resolution = this.findNearestResolution(resolution);
|
||||
getImageInternal(extent, resolution, pixelRatio, projection) {
|
||||
resolution = this.findNearestResolution(resolution);
|
||||
|
||||
let canvas = this.canvas_;
|
||||
if (canvas &&
|
||||
let canvas = this.canvas_;
|
||||
if (canvas &&
|
||||
this.renderedRevision_ == this.getRevision() &&
|
||||
canvas.getResolution() == resolution &&
|
||||
canvas.getPixelRatio() == pixelRatio &&
|
||||
containsExtent(canvas.getExtent(), extent)) {
|
||||
return canvas;
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
|
||||
extent = extent.slice();
|
||||
scaleFromCenter(extent, this.ratio_);
|
||||
const width = getWidth(extent) / resolution;
|
||||
const height = getHeight(extent) / resolution;
|
||||
const size = [width * pixelRatio, height * pixelRatio];
|
||||
extent = extent.slice();
|
||||
scaleFromCenter(extent, this.ratio_);
|
||||
const width = getWidth(extent) / resolution;
|
||||
const height = getHeight(extent) / resolution;
|
||||
const size = [width * pixelRatio, height * pixelRatio];
|
||||
|
||||
const canvasElement = this.canvasFunction_(
|
||||
extent, resolution, pixelRatio, size, projection);
|
||||
if (canvasElement) {
|
||||
canvas = new ImageCanvas(extent, resolution, pixelRatio, canvasElement);
|
||||
}
|
||||
this.canvas_ = canvas;
|
||||
this.renderedRevision_ = this.getRevision();
|
||||
const canvasElement = this.canvasFunction_(
|
||||
extent, resolution, pixelRatio, size, projection);
|
||||
if (canvasElement) {
|
||||
canvas = new ImageCanvas(extent, resolution, pixelRatio, canvasElement);
|
||||
}
|
||||
this.canvas_ = canvas;
|
||||
this.renderedRevision_ = this.getRevision();
|
||||
|
||||
return canvas;
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(ImageCanvasSource, ImageSource);
|
||||
|
||||
@@ -17,6 +17,14 @@ import WMSServerType from '../source/WMSServerType.js';
|
||||
import {compareVersions} from '../string.js';
|
||||
import {appendParams} from '../uri.js';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {module:ol/size~Size}
|
||||
*/
|
||||
const GETFEATUREINFO_IMAGE_SIZE = [101, 101];
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {module:ol/source/Source~AttributionLike} [attributions] Attributions.
|
||||
@@ -380,11 +388,4 @@ class ImageWMS {
|
||||
inherits(ImageWMS, ImageSource);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {module:ol/size~Size}
|
||||
*/
|
||||
const GETFEATUREINFO_IMAGE_SIZE = [101, 101];
|
||||
|
||||
|
||||
export default ImageWMS;
|
||||
|
||||
@@ -52,129 +52,129 @@ import SourceState from '../source/State.js';
|
||||
* @api
|
||||
*/
|
||||
class Source {
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
BaseObject.call(this);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/proj/Projection}
|
||||
*/
|
||||
this.projection_ = getProjection(options.projection);
|
||||
this.projection_ = getProjection(options.projection);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {?module:ol/source/Source~Attribution}
|
||||
*/
|
||||
this.attributions_ = this.adaptAttributions_(options.attributions);
|
||||
this.attributions_ = this.adaptAttributions_(options.attributions);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/source/State}
|
||||
*/
|
||||
this.state_ = options.state !== undefined ?
|
||||
options.state : SourceState.READY;
|
||||
this.state_ = options.state !== undefined ?
|
||||
options.state : SourceState.READY;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
|
||||
this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Turns the attributions option into an attributions function.
|
||||
* @param {module:ol/source/Source~AttributionLike|undefined} attributionLike The attribution option.
|
||||
* @return {?module:ol/source/Source~Attribution} An attribution function (or null).
|
||||
*/
|
||||
adaptAttributions_(attributionLike) {
|
||||
if (!attributionLike) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(attributionLike)) {
|
||||
return function(frameState) {
|
||||
return attributionLike;
|
||||
};
|
||||
}
|
||||
adaptAttributions_(attributionLike) {
|
||||
if (!attributionLike) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(attributionLike)) {
|
||||
return function(frameState) {
|
||||
return attributionLike;
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof attributionLike === 'function') {
|
||||
return attributionLike;
|
||||
}
|
||||
if (typeof attributionLike === 'function') {
|
||||
return attributionLike;
|
||||
}
|
||||
|
||||
return function(frameState) {
|
||||
return [attributionLike];
|
||||
};
|
||||
}
|
||||
return function(frameState) {
|
||||
return [attributionLike];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the attribution function for the source.
|
||||
* @return {?module:ol/source/Source~Attribution} Attribution function.
|
||||
*/
|
||||
getAttributions() {
|
||||
return this.attributions_;
|
||||
}
|
||||
getAttributions() {
|
||||
return this.attributions_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the projection of the source.
|
||||
* @return {module:ol/proj/Projection} Projection.
|
||||
* @api
|
||||
*/
|
||||
getProjection() {
|
||||
return this.projection_;
|
||||
}
|
||||
getProjection() {
|
||||
return this.projection_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {Array.<number>|undefined} Resolutions.
|
||||
*/
|
||||
getResolutions() {}
|
||||
getResolutions() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the state of the source, see {@link module:ol/source/State~State} for possible states.
|
||||
* @return {module:ol/source/State} State.
|
||||
* @api
|
||||
*/
|
||||
getState() {
|
||||
return this.state_;
|
||||
}
|
||||
getState() {
|
||||
return this.state_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {boolean|undefined} Wrap X.
|
||||
*/
|
||||
getWrapX() {
|
||||
return this.wrapX_;
|
||||
}
|
||||
getWrapX() {
|
||||
return this.wrapX_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Refreshes the source and finally dispatches a 'change' event.
|
||||
* @api
|
||||
*/
|
||||
refresh() {
|
||||
this.changed();
|
||||
}
|
||||
refresh() {
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the attributions of the source.
|
||||
* @param {module:ol/source/Source~AttributionLike|undefined} attributions Attributions.
|
||||
* Can be passed as `string`, `Array<string>`, `{@link module:ol/source/Source~Attribution}`,
|
||||
* or `undefined`.
|
||||
* @api
|
||||
*/
|
||||
setAttributions(attributions) {
|
||||
this.attributions_ = this.adaptAttributions_(attributions);
|
||||
this.changed();
|
||||
}
|
||||
setAttributions(attributions) {
|
||||
this.attributions_ = this.adaptAttributions_(attributions);
|
||||
this.changed();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the state of the source.
|
||||
* @param {module:ol/source/State} state State.
|
||||
* @protected
|
||||
*/
|
||||
setState(state) {
|
||||
this.state_ = state;
|
||||
this.changed();
|
||||
}
|
||||
setState(state) {
|
||||
this.state_ = state;
|
||||
this.changed();
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Source, BaseObject);
|
||||
|
||||
@@ -18,59 +18,59 @@ import {getKeyZXY} from '../tilecoord.js';
|
||||
* @param {string} text Text.
|
||||
*/
|
||||
class LabeledTile {
|
||||
constructor(tileCoord, tileSize, text) {
|
||||
constructor(tileCoord, tileSize, text) {
|
||||
|
||||
Tile.call(this, tileCoord, TileState.LOADED);
|
||||
Tile.call(this, tileCoord, TileState.LOADED);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/size~Size}
|
||||
*/
|
||||
this.tileSize_ = tileSize;
|
||||
this.tileSize_ = tileSize;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.text_ = text;
|
||||
this.text_ = text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
this.canvas_ = null;
|
||||
this.canvas_ = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the image element for this tile.
|
||||
* @return {HTMLCanvasElement} Image.
|
||||
*/
|
||||
getImage() {
|
||||
if (this.canvas_) {
|
||||
return this.canvas_;
|
||||
} else {
|
||||
const tileSize = this.tileSize_;
|
||||
const context = createCanvasContext2D(tileSize[0], tileSize[1]);
|
||||
getImage() {
|
||||
if (this.canvas_) {
|
||||
return this.canvas_;
|
||||
} else {
|
||||
const tileSize = this.tileSize_;
|
||||
const context = createCanvasContext2D(tileSize[0], tileSize[1]);
|
||||
|
||||
context.strokeStyle = 'black';
|
||||
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
|
||||
context.strokeStyle = 'black';
|
||||
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
|
||||
|
||||
context.fillStyle = 'black';
|
||||
context.textAlign = 'center';
|
||||
context.textBaseline = 'middle';
|
||||
context.font = '24px sans-serif';
|
||||
context.fillText(this.text_, tileSize[0] / 2, tileSize[1] / 2);
|
||||
context.fillStyle = 'black';
|
||||
context.textAlign = 'center';
|
||||
context.textBaseline = 'middle';
|
||||
context.font = '24px sans-serif';
|
||||
context.fillText(this.text_, tileSize[0] / 2, tileSize[1] / 2);
|
||||
|
||||
this.canvas_ = context.canvas;
|
||||
return context.canvas;
|
||||
}
|
||||
}
|
||||
this.canvas_ = context.canvas;
|
||||
return context.canvas;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
load() {}
|
||||
load() {}
|
||||
}
|
||||
|
||||
inherits(LabeledTile, Tile);
|
||||
@@ -98,35 +98,35 @@ inherits(LabeledTile, Tile);
|
||||
* @api
|
||||
*/
|
||||
class TileDebug {
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
TileSource.call(this, {
|
||||
opaque: false,
|
||||
projection: options.projection,
|
||||
tileGrid: options.tileGrid,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
});
|
||||
TileSource.call(this, {
|
||||
opaque: false,
|
||||
projection: options.projection,
|
||||
tileGrid: options.tileGrid,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getTile(z, x, y) {
|
||||
const tileCoordKey = getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
return /** @type {!module:ol/source/TileDebug~LabeledTile} */ (this.tileCache.get(tileCoordKey));
|
||||
} else {
|
||||
const tileSize = toSize(this.tileGrid.getTileSize(z));
|
||||
const tileCoord = [z, x, y];
|
||||
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
|
||||
const text = !textTileCoord ? '' :
|
||||
this.getTileCoordForTileUrlFunction(textTileCoord).toString();
|
||||
const tile = new LabeledTile(tileCoord, tileSize, text);
|
||||
this.tileCache.set(tileCoordKey, tile);
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
getTile(z, x, y) {
|
||||
const tileCoordKey = getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
return /** @type {!module:ol/source/TileDebug~LabeledTile} */ (this.tileCache.get(tileCoordKey));
|
||||
} else {
|
||||
const tileSize = toSize(this.tileGrid.getTileSize(z));
|
||||
const tileCoord = [z, x, y];
|
||||
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
|
||||
const text = !textTileCoord ? '' :
|
||||
this.getTileCoordForTileUrlFunction(textTileCoord).toString();
|
||||
const tile = new LabeledTile(tileCoord, tileSize, text);
|
||||
this.tileCache.set(tileCoordKey, tile);
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inherits(TileDebug, TileSource);
|
||||
|
||||
@@ -30,50 +30,50 @@ import RegularShape from '../style/RegularShape.js';
|
||||
* @api
|
||||
*/
|
||||
class CircleStyle {
|
||||
constructor(opt_options) {
|
||||
constructor(opt_options) {
|
||||
|
||||
const options = opt_options || {};
|
||||
const options = opt_options || {};
|
||||
|
||||
RegularShape.call(this, {
|
||||
points: Infinity,
|
||||
fill: options.fill,
|
||||
radius: options.radius,
|
||||
snapToPixel: options.snapToPixel,
|
||||
stroke: options.stroke,
|
||||
atlasManager: options.atlasManager
|
||||
});
|
||||
RegularShape.call(this, {
|
||||
points: Infinity,
|
||||
fill: options.fill,
|
||||
radius: options.radius,
|
||||
snapToPixel: options.snapToPixel,
|
||||
stroke: options.stroke,
|
||||
atlasManager: options.atlasManager
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Clones the style. If an atlasmanager was provided to the original style it will be used in the cloned style, too.
|
||||
* @return {module:ol/style/Circle} The cloned style.
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
clone() {
|
||||
const style = new CircleStyle({
|
||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
|
||||
radius: this.getRadius(),
|
||||
snapToPixel: this.getSnapToPixel(),
|
||||
atlasManager: this.atlasManager_
|
||||
});
|
||||
style.setOpacity(this.getOpacity());
|
||||
style.setScale(this.getScale());
|
||||
return style;
|
||||
}
|
||||
clone() {
|
||||
const style = new CircleStyle({
|
||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
|
||||
radius: this.getRadius(),
|
||||
snapToPixel: this.getSnapToPixel(),
|
||||
atlasManager: this.atlasManager_
|
||||
});
|
||||
style.setOpacity(this.getOpacity());
|
||||
style.setScale(this.getScale());
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the circle radius.
|
||||
*
|
||||
* @param {number} radius Circle radius.
|
||||
* @api
|
||||
*/
|
||||
setRadius(radius) {
|
||||
this.radius_ = radius;
|
||||
this.render_(this.atlasManager_);
|
||||
}
|
||||
setRadius(radius) {
|
||||
this.radius_ = radius;
|
||||
this.render_(this.atlasManager_);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(CircleStyle, RegularShape);
|
||||
|
||||
@@ -8,85 +8,85 @@ import {asString} from '../color.js';
|
||||
* @constructor
|
||||
*/
|
||||
class IconImageCache {
|
||||
constructor() {
|
||||
constructor() {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {!Object.<string, module:ol/style/IconImage>}
|
||||
* @private
|
||||
*/
|
||||
this.cache_ = {};
|
||||
this.cache_ = {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.cacheSize_ = 0;
|
||||
this.cacheSize_ = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.maxCacheSize_ = 32;
|
||||
}
|
||||
this.maxCacheSize_ = 32;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
clear() {
|
||||
this.cache_ = {};
|
||||
this.cacheSize_ = 0;
|
||||
}
|
||||
clear() {
|
||||
this.cache_ = {};
|
||||
this.cacheSize_ = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
expire() {
|
||||
if (this.cacheSize_ > this.maxCacheSize_) {
|
||||
let i = 0;
|
||||
for (const key in this.cache_) {
|
||||
const iconImage = this.cache_[key];
|
||||
if ((i++ & 3) === 0 && !iconImage.hasListener()) {
|
||||
delete this.cache_[key];
|
||||
--this.cacheSize_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
expire() {
|
||||
if (this.cacheSize_ > this.maxCacheSize_) {
|
||||
let i = 0;
|
||||
for (const key in this.cache_) {
|
||||
const iconImage = this.cache_[key];
|
||||
if ((i++ & 3) === 0 && !iconImage.hasListener()) {
|
||||
delete this.cache_[key];
|
||||
--this.cacheSize_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {string} src Src.
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
* @param {module:ol/color~Color} color Color.
|
||||
* @return {module:ol/style/IconImage} Icon image.
|
||||
*/
|
||||
get(src, crossOrigin, color) {
|
||||
const key = getKey(src, crossOrigin, color);
|
||||
return key in this.cache_ ? this.cache_[key] : null;
|
||||
}
|
||||
get(src, crossOrigin, color) {
|
||||
const key = getKey(src, crossOrigin, color);
|
||||
return key in this.cache_ ? this.cache_[key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {string} src Src.
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
* @param {module:ol/color~Color} color Color.
|
||||
* @param {module:ol/style/IconImage} iconImage Icon image.
|
||||
*/
|
||||
set(src, crossOrigin, color, iconImage) {
|
||||
const key = getKey(src, crossOrigin, color);
|
||||
this.cache_[key] = iconImage;
|
||||
++this.cacheSize_;
|
||||
}
|
||||
set(src, crossOrigin, color, iconImage) {
|
||||
const key = getKey(src, crossOrigin, color);
|
||||
this.cache_[key] = iconImage;
|
||||
++this.cacheSize_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the cache size of the icon cache. Default is `32`. Change this value when
|
||||
* your map uses more than 32 different icon images and you are not caching icon
|
||||
* styles on the application level.
|
||||
* @param {number} maxCacheSize Cache max size.
|
||||
* @api
|
||||
*/
|
||||
setSize(maxCacheSize) {
|
||||
this.maxCacheSize_ = maxCacheSize;
|
||||
this.expire();
|
||||
}
|
||||
setSize(maxCacheSize) {
|
||||
this.maxCacheSize_ = maxCacheSize;
|
||||
this.expire();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,212 +25,212 @@
|
||||
* @api
|
||||
*/
|
||||
class ImageStyle {
|
||||
constructor(options) {
|
||||
constructor(options) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.opacity_ = options.opacity;
|
||||
this.opacity_ = options.opacity;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.rotateWithView_ = options.rotateWithView;
|
||||
this.rotateWithView_ = options.rotateWithView;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.rotation_ = options.rotation;
|
||||
this.rotation_ = options.rotation;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.scale_ = options.scale;
|
||||
this.scale_ = options.scale;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.snapToPixel_ = options.snapToPixel;
|
||||
this.snapToPixel_ = options.snapToPixel;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the symbolizer opacity.
|
||||
* @return {number} Opacity.
|
||||
* @api
|
||||
*/
|
||||
getOpacity() {
|
||||
return this.opacity_;
|
||||
}
|
||||
getOpacity() {
|
||||
return this.opacity_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Determine whether the symbolizer rotates with the map.
|
||||
* @return {boolean} Rotate with map.
|
||||
* @api
|
||||
*/
|
||||
getRotateWithView() {
|
||||
return this.rotateWithView_;
|
||||
}
|
||||
getRotateWithView() {
|
||||
return this.rotateWithView_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the symoblizer rotation.
|
||||
* @return {number} Rotation.
|
||||
* @api
|
||||
*/
|
||||
getRotation() {
|
||||
return this.rotation_;
|
||||
}
|
||||
getRotation() {
|
||||
return this.rotation_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the symbolizer scale.
|
||||
* @return {number} Scale.
|
||||
* @api
|
||||
*/
|
||||
getScale() {
|
||||
return this.scale_;
|
||||
}
|
||||
getScale() {
|
||||
return this.scale_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Determine whether the symbolizer should be snapped to a pixel.
|
||||
* @return {boolean} The symbolizer should snap to a pixel.
|
||||
* @api
|
||||
*/
|
||||
getSnapToPixel() {
|
||||
return this.snapToPixel_;
|
||||
}
|
||||
getSnapToPixel() {
|
||||
return this.snapToPixel_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the anchor point in pixels. The anchor determines the center point for the
|
||||
* symbolizer.
|
||||
* @abstract
|
||||
* @return {Array.<number>} Anchor.
|
||||
*/
|
||||
getAnchor() {}
|
||||
getAnchor() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the image element for the symbolizer.
|
||||
* @abstract
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
|
||||
*/
|
||||
getImage(pixelRatio) {}
|
||||
getImage(pixelRatio) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
|
||||
*/
|
||||
getHitDetectionImage(pixelRatio) {}
|
||||
getHitDetectionImage(pixelRatio) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {module:ol/ImageState} Image state.
|
||||
*/
|
||||
getImageState() {}
|
||||
getImageState() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {module:ol/size~Size} Image size.
|
||||
*/
|
||||
getImageSize() {}
|
||||
getImageSize() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {module:ol/size~Size} Size of the hit-detection image.
|
||||
*/
|
||||
getHitDetectionImageSize() {}
|
||||
getHitDetectionImageSize() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the origin of the symbolizer.
|
||||
* @abstract
|
||||
* @return {Array.<number>} Origin.
|
||||
*/
|
||||
getOrigin() {}
|
||||
getOrigin() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the size of the symbolizer (in pixels).
|
||||
* @abstract
|
||||
* @return {module:ol/size~Size} Size.
|
||||
*/
|
||||
getSize() {}
|
||||
getSize() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the opacity.
|
||||
*
|
||||
* @param {number} opacity Opacity.
|
||||
* @api
|
||||
*/
|
||||
setOpacity(opacity) {
|
||||
this.opacity_ = opacity;
|
||||
}
|
||||
setOpacity(opacity) {
|
||||
this.opacity_ = opacity;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set whether to rotate the style with the view.
|
||||
*
|
||||
* @param {boolean} rotateWithView Rotate with map.
|
||||
* @api
|
||||
*/
|
||||
setRotateWithView(rotateWithView) {
|
||||
this.rotateWithView_ = rotateWithView;
|
||||
}
|
||||
setRotateWithView(rotateWithView) {
|
||||
this.rotateWithView_ = rotateWithView;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the rotation.
|
||||
*
|
||||
* @param {number} rotation Rotation.
|
||||
* @api
|
||||
*/
|
||||
setRotation(rotation) {
|
||||
this.rotation_ = rotation;
|
||||
}
|
||||
setRotation(rotation) {
|
||||
this.rotation_ = rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the scale.
|
||||
*
|
||||
* @param {number} scale Scale.
|
||||
* @api
|
||||
*/
|
||||
setScale(scale) {
|
||||
this.scale_ = scale;
|
||||
}
|
||||
setScale(scale) {
|
||||
this.scale_ = scale;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set whether to snap the image to the closest pixel.
|
||||
*
|
||||
* @param {boolean} snapToPixel Snap to pixel?
|
||||
* @api
|
||||
*/
|
||||
setSnapToPixel(snapToPixel) {
|
||||
this.snapToPixel_ = snapToPixel;
|
||||
}
|
||||
setSnapToPixel(snapToPixel) {
|
||||
this.snapToPixel_ = snapToPixel;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {function(this: T, module:ol/events/Event)} listener Listener function.
|
||||
* @param {T} thisArg Value to use as `this` when executing `listener`.
|
||||
* @return {module:ol/events~EventsKey|undefined} Listener key.
|
||||
* @template T
|
||||
*/
|
||||
listenImageChange(listener, thisArg) {}
|
||||
listenImageChange(listener, thisArg) {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Load not yet loaded URI.
|
||||
* @abstract
|
||||
*/
|
||||
load() {}
|
||||
load() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @param {function(this: T, module:ol/events/Event)} listener Listener function.
|
||||
* @param {T} thisArg Value to use as `this` when executing `listener`.
|
||||
* @template T
|
||||
*/
|
||||
unlistenImageChange(listener, thisArg) {}
|
||||
unlistenImageChange(listener, thisArg) {}
|
||||
}
|
||||
|
||||
export default ImageStyle;
|
||||
|
||||
@@ -54,452 +54,452 @@ const DEFAULT_FILL_COLOR = '#333';
|
||||
* @api
|
||||
*/
|
||||
class Text {
|
||||
constructor(opt_options) {
|
||||
constructor(opt_options) {
|
||||
|
||||
const options = opt_options || {};
|
||||
const options = opt_options || {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.font_ = options.font;
|
||||
this.font_ = options.font;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.rotation_ = options.rotation;
|
||||
this.rotation_ = options.rotation;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.rotateWithView_ = options.rotateWithView;
|
||||
this.rotateWithView_ = options.rotateWithView;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.scale_ = options.scale;
|
||||
this.scale_ = options.scale;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.text_ = options.text;
|
||||
this.text_ = options.text;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.textAlign_ = options.textAlign;
|
||||
this.textAlign_ = options.textAlign;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.textBaseline_ = options.textBaseline;
|
||||
this.textBaseline_ = options.textBaseline;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/style/Fill}
|
||||
*/
|
||||
this.fill_ = options.fill !== undefined ? options.fill :
|
||||
new Fill({color: DEFAULT_FILL_COLOR});
|
||||
this.fill_ = options.fill !== undefined ? options.fill :
|
||||
new Fill({color: DEFAULT_FILL_COLOR});
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxAngle_ = options.maxAngle !== undefined ? options.maxAngle : Math.PI / 4;
|
||||
this.maxAngle_ = options.maxAngle !== undefined ? options.maxAngle : Math.PI / 4;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/style/TextPlacement|string}
|
||||
*/
|
||||
this.placement_ = options.placement !== undefined ? options.placement : TextPlacement.POINT;
|
||||
this.placement_ = options.placement !== undefined ? options.placement : TextPlacement.POINT;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.overflow_ = !!options.overflow;
|
||||
this.overflow_ = !!options.overflow;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/style/Stroke}
|
||||
*/
|
||||
this.stroke_ = options.stroke !== undefined ? options.stroke : null;
|
||||
this.stroke_ = options.stroke !== undefined ? options.stroke : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.offsetX_ = options.offsetX !== undefined ? options.offsetX : 0;
|
||||
this.offsetX_ = options.offsetX !== undefined ? options.offsetX : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.offsetY_ = options.offsetY !== undefined ? options.offsetY : 0;
|
||||
this.offsetY_ = options.offsetY !== undefined ? options.offsetY : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/style/Fill}
|
||||
*/
|
||||
this.backgroundFill_ = options.backgroundFill ? options.backgroundFill : null;
|
||||
this.backgroundFill_ = options.backgroundFill ? options.backgroundFill : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/style/Stroke}
|
||||
*/
|
||||
this.backgroundStroke_ = options.backgroundStroke ? options.backgroundStroke : null;
|
||||
this.backgroundStroke_ = options.backgroundStroke ? options.backgroundStroke : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.padding_ = options.padding === undefined ? null : options.padding;
|
||||
}
|
||||
this.padding_ = options.padding === undefined ? null : options.padding;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Clones the style.
|
||||
* @return {module:ol/style/Text} The cloned style.
|
||||
* @api
|
||||
*/
|
||||
clone() {
|
||||
return new Text({
|
||||
font: this.getFont(),
|
||||
placement: this.getPlacement(),
|
||||
maxAngle: this.getMaxAngle(),
|
||||
overflow: this.getOverflow(),
|
||||
rotation: this.getRotation(),
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
scale: this.getScale(),
|
||||
text: this.getText(),
|
||||
textAlign: this.getTextAlign(),
|
||||
textBaseline: this.getTextBaseline(),
|
||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
|
||||
offsetX: this.getOffsetX(),
|
||||
offsetY: this.getOffsetY(),
|
||||
backgroundFill: this.getBackgroundFill() ? this.getBackgroundFill().clone() : undefined,
|
||||
backgroundStroke: this.getBackgroundStroke() ? this.getBackgroundStroke().clone() : undefined
|
||||
});
|
||||
}
|
||||
clone() {
|
||||
return new Text({
|
||||
font: this.getFont(),
|
||||
placement: this.getPlacement(),
|
||||
maxAngle: this.getMaxAngle(),
|
||||
overflow: this.getOverflow(),
|
||||
rotation: this.getRotation(),
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
scale: this.getScale(),
|
||||
text: this.getText(),
|
||||
textAlign: this.getTextAlign(),
|
||||
textBaseline: this.getTextBaseline(),
|
||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
|
||||
offsetX: this.getOffsetX(),
|
||||
offsetY: this.getOffsetY(),
|
||||
backgroundFill: this.getBackgroundFill() ? this.getBackgroundFill().clone() : undefined,
|
||||
backgroundStroke: this.getBackgroundStroke() ? this.getBackgroundStroke().clone() : undefined
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the `overflow` configuration.
|
||||
* @return {boolean} Let text overflow the length of the path they follow.
|
||||
* @api
|
||||
*/
|
||||
getOverflow() {
|
||||
return this.overflow_;
|
||||
}
|
||||
getOverflow() {
|
||||
return this.overflow_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the font name.
|
||||
* @return {string|undefined} Font.
|
||||
* @api
|
||||
*/
|
||||
getFont() {
|
||||
return this.font_;
|
||||
}
|
||||
getFont() {
|
||||
return this.font_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the maximum angle between adjacent characters.
|
||||
* @return {number} Angle in radians.
|
||||
* @api
|
||||
*/
|
||||
getMaxAngle() {
|
||||
return this.maxAngle_;
|
||||
}
|
||||
getMaxAngle() {
|
||||
return this.maxAngle_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the label placement.
|
||||
* @return {module:ol/style/TextPlacement|string} Text placement.
|
||||
* @api
|
||||
*/
|
||||
getPlacement() {
|
||||
return this.placement_;
|
||||
}
|
||||
getPlacement() {
|
||||
return this.placement_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the x-offset for the text.
|
||||
* @return {number} Horizontal text offset.
|
||||
* @api
|
||||
*/
|
||||
getOffsetX() {
|
||||
return this.offsetX_;
|
||||
}
|
||||
getOffsetX() {
|
||||
return this.offsetX_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the y-offset for the text.
|
||||
* @return {number} Vertical text offset.
|
||||
* @api
|
||||
*/
|
||||
getOffsetY() {
|
||||
return this.offsetY_;
|
||||
}
|
||||
getOffsetY() {
|
||||
return this.offsetY_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the fill style for the text.
|
||||
* @return {module:ol/style/Fill} Fill style.
|
||||
* @api
|
||||
*/
|
||||
getFill() {
|
||||
return this.fill_;
|
||||
}
|
||||
getFill() {
|
||||
return this.fill_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Determine whether the text rotates with the map.
|
||||
* @return {boolean|undefined} Rotate with map.
|
||||
* @api
|
||||
*/
|
||||
getRotateWithView() {
|
||||
return this.rotateWithView_;
|
||||
}
|
||||
getRotateWithView() {
|
||||
return this.rotateWithView_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the text rotation.
|
||||
* @return {number|undefined} Rotation.
|
||||
* @api
|
||||
*/
|
||||
getRotation() {
|
||||
return this.rotation_;
|
||||
}
|
||||
getRotation() {
|
||||
return this.rotation_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the text scale.
|
||||
* @return {number|undefined} Scale.
|
||||
* @api
|
||||
*/
|
||||
getScale() {
|
||||
return this.scale_;
|
||||
}
|
||||
getScale() {
|
||||
return this.scale_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the stroke style for the text.
|
||||
* @return {module:ol/style/Stroke} Stroke style.
|
||||
* @api
|
||||
*/
|
||||
getStroke() {
|
||||
return this.stroke_;
|
||||
}
|
||||
getStroke() {
|
||||
return this.stroke_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the text to be rendered.
|
||||
* @return {string|undefined} Text.
|
||||
* @api
|
||||
*/
|
||||
getText() {
|
||||
return this.text_;
|
||||
}
|
||||
getText() {
|
||||
return this.text_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the text alignment.
|
||||
* @return {string|undefined} Text align.
|
||||
* @api
|
||||
*/
|
||||
getTextAlign() {
|
||||
return this.textAlign_;
|
||||
}
|
||||
getTextAlign() {
|
||||
return this.textAlign_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the text baseline.
|
||||
* @return {string|undefined} Text baseline.
|
||||
* @api
|
||||
*/
|
||||
getTextBaseline() {
|
||||
return this.textBaseline_;
|
||||
}
|
||||
getTextBaseline() {
|
||||
return this.textBaseline_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the background fill style for the text.
|
||||
* @return {module:ol/style/Fill} Fill style.
|
||||
* @api
|
||||
*/
|
||||
getBackgroundFill() {
|
||||
return this.backgroundFill_;
|
||||
}
|
||||
getBackgroundFill() {
|
||||
return this.backgroundFill_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the background stroke style for the text.
|
||||
* @return {module:ol/style/Stroke} Stroke style.
|
||||
* @api
|
||||
*/
|
||||
getBackgroundStroke() {
|
||||
return this.backgroundStroke_;
|
||||
}
|
||||
getBackgroundStroke() {
|
||||
return this.backgroundStroke_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the padding for the text.
|
||||
* @return {Array.<number>} Padding.
|
||||
* @api
|
||||
*/
|
||||
getPadding() {
|
||||
return this.padding_;
|
||||
}
|
||||
getPadding() {
|
||||
return this.padding_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the `overflow` property.
|
||||
*
|
||||
* @param {boolean} overflow Let text overflow the path that it follows.
|
||||
* @api
|
||||
*/
|
||||
setOverflow(overflow) {
|
||||
this.overflow_ = overflow;
|
||||
}
|
||||
setOverflow(overflow) {
|
||||
this.overflow_ = overflow;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the font.
|
||||
*
|
||||
* @param {string|undefined} font Font.
|
||||
* @api
|
||||
*/
|
||||
setFont(font) {
|
||||
this.font_ = font;
|
||||
}
|
||||
setFont(font) {
|
||||
this.font_ = font;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the maximum angle between adjacent characters.
|
||||
*
|
||||
* @param {number} maxAngle Angle in radians.
|
||||
* @api
|
||||
*/
|
||||
setMaxAngle(maxAngle) {
|
||||
this.maxAngle_ = maxAngle;
|
||||
}
|
||||
setMaxAngle(maxAngle) {
|
||||
this.maxAngle_ = maxAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the x offset.
|
||||
*
|
||||
* @param {number} offsetX Horizontal text offset.
|
||||
* @api
|
||||
*/
|
||||
setOffsetX(offsetX) {
|
||||
this.offsetX_ = offsetX;
|
||||
}
|
||||
setOffsetX(offsetX) {
|
||||
this.offsetX_ = offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the y offset.
|
||||
*
|
||||
* @param {number} offsetY Vertical text offset.
|
||||
* @api
|
||||
*/
|
||||
setOffsetY(offsetY) {
|
||||
this.offsetY_ = offsetY;
|
||||
}
|
||||
setOffsetY(offsetY) {
|
||||
this.offsetY_ = offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the text placement.
|
||||
*
|
||||
* @param {module:ol/style/TextPlacement|string} placement Placement.
|
||||
* @api
|
||||
*/
|
||||
setPlacement(placement) {
|
||||
this.placement_ = placement;
|
||||
}
|
||||
setPlacement(placement) {
|
||||
this.placement_ = placement;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the fill.
|
||||
*
|
||||
* @param {module:ol/style/Fill} fill Fill style.
|
||||
* @api
|
||||
*/
|
||||
setFill(fill) {
|
||||
this.fill_ = fill;
|
||||
}
|
||||
setFill(fill) {
|
||||
this.fill_ = fill;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the rotation.
|
||||
*
|
||||
* @param {number|undefined} rotation Rotation.
|
||||
* @api
|
||||
*/
|
||||
setRotation(rotation) {
|
||||
this.rotation_ = rotation;
|
||||
}
|
||||
setRotation(rotation) {
|
||||
this.rotation_ = rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the scale.
|
||||
*
|
||||
* @param {number|undefined} scale Scale.
|
||||
* @api
|
||||
*/
|
||||
setScale(scale) {
|
||||
this.scale_ = scale;
|
||||
}
|
||||
setScale(scale) {
|
||||
this.scale_ = scale;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the stroke.
|
||||
*
|
||||
* @param {module:ol/style/Stroke} stroke Stroke style.
|
||||
* @api
|
||||
*/
|
||||
setStroke(stroke) {
|
||||
this.stroke_ = stroke;
|
||||
}
|
||||
setStroke(stroke) {
|
||||
this.stroke_ = stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the text.
|
||||
*
|
||||
* @param {string|undefined} text Text.
|
||||
* @api
|
||||
*/
|
||||
setText(text) {
|
||||
this.text_ = text;
|
||||
}
|
||||
setText(text) {
|
||||
this.text_ = text;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the text alignment.
|
||||
*
|
||||
* @param {string|undefined} textAlign Text align.
|
||||
* @api
|
||||
*/
|
||||
setTextAlign(textAlign) {
|
||||
this.textAlign_ = textAlign;
|
||||
}
|
||||
setTextAlign(textAlign) {
|
||||
this.textAlign_ = textAlign;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the text baseline.
|
||||
*
|
||||
* @param {string|undefined} textBaseline Text baseline.
|
||||
* @api
|
||||
*/
|
||||
setTextBaseline(textBaseline) {
|
||||
this.textBaseline_ = textBaseline;
|
||||
}
|
||||
setTextBaseline(textBaseline) {
|
||||
this.textBaseline_ = textBaseline;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the background fill.
|
||||
*
|
||||
* @param {module:ol/style/Fill} fill Fill style.
|
||||
* @api
|
||||
*/
|
||||
setBackgroundFill(fill) {
|
||||
this.backgroundFill_ = fill;
|
||||
}
|
||||
setBackgroundFill(fill) {
|
||||
this.backgroundFill_ = fill;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the background stroke.
|
||||
*
|
||||
* @param {module:ol/style/Stroke} stroke Stroke style.
|
||||
* @api
|
||||
*/
|
||||
setBackgroundStroke(stroke) {
|
||||
this.backgroundStroke_ = stroke;
|
||||
}
|
||||
setBackgroundStroke(stroke) {
|
||||
this.backgroundStroke_ = stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the padding (`[top, right, bottom, left]`).
|
||||
*
|
||||
* @param {!Array.<number>} padding Padding.
|
||||
* @api
|
||||
*/
|
||||
setPadding(padding) {
|
||||
this.padding_ = padding;
|
||||
}
|
||||
setPadding(padding) {
|
||||
this.padding_ = padding;
|
||||
}
|
||||
}
|
||||
|
||||
export default Text;
|
||||
|
||||
@@ -11,6 +11,13 @@ import {toSize} from '../size.js';
|
||||
import {createOrUpdate as createOrUpdateTileCoord} from '../tilecoord.js';
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/tilecoord~TileCoord}
|
||||
*/
|
||||
const tmpTileCoord = [0, 0, 0];
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {module:ol/extent~Extent} [extent] Extent for the tile grid. No tiles outside this
|
||||
@@ -544,11 +551,4 @@ class TileGrid {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/tilecoord~TileCoord}
|
||||
*/
|
||||
const tmpTileCoord = [0, 0, 0];
|
||||
|
||||
|
||||
export default TileGrid;
|
||||
|
||||
@@ -19,35 +19,35 @@ const BufferUsage = {
|
||||
* @struct
|
||||
*/
|
||||
class WebGLBuffer {
|
||||
constructor(opt_arr, opt_usage) {
|
||||
constructor(opt_arr, opt_usage) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.arr_ = opt_arr !== undefined ? opt_arr : [];
|
||||
this.arr_ = opt_arr !== undefined ? opt_arr : [];
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.usage_ = opt_usage !== undefined ? opt_usage : BufferUsage.STATIC_DRAW;
|
||||
this.usage_ = opt_usage !== undefined ? opt_usage : BufferUsage.STATIC_DRAW;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {Array.<number>} Array.
|
||||
*/
|
||||
getArray() {
|
||||
return this.arr_;
|
||||
}
|
||||
getArray() {
|
||||
return this.arr_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {number} Usage.
|
||||
*/
|
||||
getUsage() {
|
||||
return this.usage_;
|
||||
}
|
||||
getUsage() {
|
||||
return this.usage_;
|
||||
}
|
||||
}
|
||||
|
||||
export default WebGLBuffer;
|
||||
|
||||
@@ -12,16 +12,16 @@ import WebGLShader from '../webgl/Shader.js';
|
||||
* @struct
|
||||
*/
|
||||
class WebGLFragment {
|
||||
constructor(source) {
|
||||
WebGLShader.call(this, source);
|
||||
}
|
||||
constructor(source) {
|
||||
WebGLShader.call(this, source);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getType() {
|
||||
return FRAGMENT_SHADER;
|
||||
}
|
||||
getType() {
|
||||
return FRAGMENT_SHADER;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(WebGLFragment, WebGLShader);
|
||||
|
||||
@@ -10,28 +10,28 @@ import {FALSE} from '../functions.js';
|
||||
* @struct
|
||||
*/
|
||||
class WebGLShader {
|
||||
constructor(source) {
|
||||
constructor(source) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.source_ = source;
|
||||
this.source_ = source;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @abstract
|
||||
* @return {number} Type.
|
||||
*/
|
||||
getType() {}
|
||||
getType() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {string} Source.
|
||||
*/
|
||||
getSource() {
|
||||
return this.source_;
|
||||
}
|
||||
getSource() {
|
||||
return this.source_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@ import WebGLShader from '../webgl/Shader.js';
|
||||
* @struct
|
||||
*/
|
||||
class WebGLVertex {
|
||||
constructor(source) {
|
||||
WebGLShader.call(this, source);
|
||||
}
|
||||
constructor(source) {
|
||||
WebGLShader.call(this, source);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
getType() {
|
||||
return VERTEX_SHADER;
|
||||
}
|
||||
getType() {
|
||||
return VERTEX_SHADER;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(WebGLVertex, WebGLShader);
|
||||
|
||||
Reference in New Issue
Block a user