Replace instanceof checks with other logic
This commit is contained in:
@@ -160,7 +160,7 @@ class Collection extends BaseObject {
|
||||
* @api
|
||||
*/
|
||||
getLength() {
|
||||
return /** @type {number} */ (this.get(Property.LENGTH));
|
||||
return this.get(Property.LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,6 @@ import {assert} from './asserts.js';
|
||||
import {listen, unlisten, unlistenByKey} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import BaseObject, {getChangeEventType} from './Object.js';
|
||||
import Geometry from './geom/Geometry.js';
|
||||
import Style from './style/Style.js';
|
||||
|
||||
/**
|
||||
* @typedef {typeof Feature|typeof import("./render/Feature.js").default} FeatureClass
|
||||
@@ -62,7 +60,7 @@ import Style from './style/Style.js';
|
||||
*/
|
||||
class Feature extends BaseObject {
|
||||
/**
|
||||
* @param {Geometry|Object<string, *>=} opt_geometryOrProperties
|
||||
* @param {import("./geom/Geometry.js").default|Object<string, *>=} opt_geometryOrProperties
|
||||
* You may pass a Geometry object directly, or an object literal containing
|
||||
* properties. If you pass an object literal, you may include a Geometry
|
||||
* associated with a `geometry` key.
|
||||
@@ -86,7 +84,7 @@ class Feature extends BaseObject {
|
||||
/**
|
||||
* User provided style.
|
||||
* @private
|
||||
* @type {Style|Array<Style>|import("./style/Style.js").StyleFunction}
|
||||
* @type {import("./style/Style.js").StyleLike}
|
||||
*/
|
||||
this.style_ = null;
|
||||
|
||||
@@ -106,10 +104,9 @@ class Feature extends BaseObject {
|
||||
this, getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
|
||||
if (opt_geometryOrProperties !== undefined) {
|
||||
if (opt_geometryOrProperties instanceof Geometry) {
|
||||
|
||||
const geometry = /** @type {Geometry} */ (opt_geometryOrProperties);
|
||||
if (opt_geometryOrProperties) {
|
||||
if (typeof /** @type {?} */ (opt_geometryOrProperties).getSimplifiedGeometry === 'function') {
|
||||
const geometry = /** @type {import("./geom/Geometry.js").default} */ (opt_geometryOrProperties);
|
||||
this.setGeometry(geometry);
|
||||
} else {
|
||||
/** @type {Object<string, *>} */
|
||||
@@ -143,13 +140,13 @@ class Feature extends BaseObject {
|
||||
* Get the feature's default geometry. A feature may have any number of named
|
||||
* geometries. The "default" geometry (the one that is rendered by default) is
|
||||
* set when calling {@link module:ol/Feature~Feature#setGeometry}.
|
||||
* @return {Geometry|undefined} The default geometry for the feature.
|
||||
* @return {import("./geom/Geometry.js").default|undefined} The default geometry for the feature.
|
||||
* @api
|
||||
* @observable
|
||||
*/
|
||||
getGeometry() {
|
||||
return (
|
||||
/** @type {Geometry|undefined} */ (this.get(this.geometryName_))
|
||||
/** @type {import("./geom/Geometry.js").default|undefined} */ (this.get(this.geometryName_))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -178,7 +175,7 @@ class Feature extends BaseObject {
|
||||
/**
|
||||
* Get the feature's style. Will return what was provided to the
|
||||
* {@link module:ol/Feature~Feature#setStyle} method.
|
||||
* @return {Style|Array<Style>|import("./style/Style.js").StyleFunction} The feature style.
|
||||
* @return {import("./style/Style.js").StyleLike} The feature style.
|
||||
* @api
|
||||
*/
|
||||
getStyle() {
|
||||
@@ -221,7 +218,7 @@ class Feature extends BaseObject {
|
||||
/**
|
||||
* Set the default geometry for the feature. This will update the property
|
||||
* with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.
|
||||
* @param {Geometry|undefined} geometry The new geometry.
|
||||
* @param {import("./geom/Geometry.js").default|undefined} geometry The new geometry.
|
||||
* @api
|
||||
* @observable
|
||||
*/
|
||||
@@ -233,7 +230,7 @@ class Feature extends BaseObject {
|
||||
* Set the style for the feature. This can be a single style object, an array
|
||||
* of styles, or a function that takes a resolution and returns an array of
|
||||
* styles. If it is `null` the feature has no style (a `null` style).
|
||||
* @param {Style|Array<Style>|import("./style/Style.js").StyleFunction} style Style for this feature.
|
||||
* @param {import("./style/Style.js").StyleLike} style Style for this feature.
|
||||
* @api
|
||||
* @fires module:ol/events/Event~Event#event:change
|
||||
*/
|
||||
@@ -281,7 +278,7 @@ class Feature extends BaseObject {
|
||||
* Convert the provided object into a feature style function. Functions passed
|
||||
* through unchanged. Arrays of Style or single style objects wrapped
|
||||
* in a new feature style function.
|
||||
* @param {import("./style/Style.js").StyleFunction|!Array<Style>|!Style} obj
|
||||
* @param {!import("./style/Style.js").StyleFunction|!Array<import("./style/Style.js").default>|!import("./style/Style.js").default} obj
|
||||
* A feature style function, a single style, or an array of styles.
|
||||
* @return {import("./style/Style.js").StyleFunction} A style function.
|
||||
*/
|
||||
@@ -290,15 +287,16 @@ export function createStyleFunction(obj) {
|
||||
return obj;
|
||||
} else {
|
||||
/**
|
||||
* @type {Array<Style>}
|
||||
* @type {Array<import("./style/Style.js").default>}
|
||||
*/
|
||||
let styles;
|
||||
if (Array.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
assert(obj instanceof Style,
|
||||
assert(typeof /** @type {?} */ (obj).getZIndex === 'function',
|
||||
41); // Expected an `import("./style/Style.js").Style` or an array of `import("./style/Style.js").Style`
|
||||
styles = [obj];
|
||||
const style = /** @type {import("./style/Style.js").default} */ (obj);
|
||||
styles = [style];
|
||||
}
|
||||
return function() {
|
||||
return styles;
|
||||
|
||||
@@ -109,8 +109,8 @@ class ImageTile extends Tile {
|
||||
* @private
|
||||
*/
|
||||
handleImageLoad_() {
|
||||
if (this.image_ instanceof HTMLImageElement &&
|
||||
this.image_.naturalWidth && this.image_.naturalHeight) {
|
||||
const image = /** @type {HTMLImageElement} */ (this.image_);
|
||||
if (image.naturalWidth && image.naturalHeight) {
|
||||
this.state = TileState.LOADED;
|
||||
} else {
|
||||
this.state = TileState.EMPTY;
|
||||
|
||||
@@ -102,7 +102,7 @@ import {create as createTransform, apply as applyTransform} from './transform.js
|
||||
* map target (i.e. the user-provided div for the map). If this is not
|
||||
* `document`, the target element needs to be focused for key events to be
|
||||
* emitted, requiring that the target element has a `tabindex` attribute.
|
||||
* @property {Array<import("./layer/Base.js").default>|Collection<import("./layer/Base.js").default>} [layers]
|
||||
* @property {Array<import("./layer/Base.js").default>|Collection<import("./layer/Base.js").default>|LayerGroup} [layers]
|
||||
* Layers. If this is not defined, a map with no layers will be rendered. Note
|
||||
* that layers are rendered in the order supplied, so if you want, for example,
|
||||
* a vector layer to appear on top of a tile layer, it must come after the tile
|
||||
@@ -1368,8 +1368,8 @@ function createOptionsInternal(options) {
|
||||
*/
|
||||
const values = {};
|
||||
|
||||
const layerGroup = (options.layers instanceof LayerGroup) ?
|
||||
options.layers : new LayerGroup({layers: options.layers});
|
||||
const layerGroup = options.layers && typeof /** @type {?} */ (options.layers).getLayers === 'function' ?
|
||||
/** @type {LayerGroup} */ (options.layers) : new LayerGroup({layers: /** @type {Collection} */ (options.layers)});
|
||||
values[MapProperty.LAYERGROUP] = layerGroup;
|
||||
|
||||
values[MapProperty.TARGET] = options.target;
|
||||
@@ -1382,9 +1382,9 @@ function createOptionsInternal(options) {
|
||||
if (Array.isArray(options.controls)) {
|
||||
controls = new Collection(options.controls.slice());
|
||||
} else {
|
||||
assert(options.controls instanceof Collection,
|
||||
assert(typeof /** @type {?} */ (options.controls).getArray === 'function',
|
||||
47); // Expected `controls` to be an array or an `import("./Collection.js").Collection`
|
||||
controls = options.controls;
|
||||
controls = /** @type {Collection} */ (options.controls);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,9 +1393,9 @@ function createOptionsInternal(options) {
|
||||
if (Array.isArray(options.interactions)) {
|
||||
interactions = new Collection(options.interactions.slice());
|
||||
} else {
|
||||
assert(options.interactions instanceof Collection,
|
||||
assert(typeof /** @type {?} */ (options.interactions).getArray === 'function',
|
||||
48); // Expected `interactions` to be an array or an `import("./Collection.js").Collection`
|
||||
interactions = options.interactions;
|
||||
interactions = /** @type {Collection} */ (options.interactions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1404,7 +1404,7 @@ function createOptionsInternal(options) {
|
||||
if (Array.isArray(options.overlays)) {
|
||||
overlays = new Collection(options.overlays.slice());
|
||||
} else {
|
||||
assert(options.overlays instanceof Collection,
|
||||
assert(typeof /** @type {?} */ (options.overlays).getArray === 'function',
|
||||
49); // Expected `overlays` to be an array or an `import("./Collection.js").Collection`
|
||||
overlays = options.overlays;
|
||||
}
|
||||
@@ -1430,8 +1430,8 @@ export default PluggableMap;
|
||||
function getLoading(layers) {
|
||||
for (let i = 0, ii = layers.length; i < ii; ++i) {
|
||||
const layer = layers[i];
|
||||
if (layer instanceof LayerGroup) {
|
||||
return getLoading(layer.getLayers().getArray());
|
||||
if (typeof /** @type {?} */ (layer).getLayers === 'function') {
|
||||
return getLoading(/** @type {LayerGroup} */ (layer).getLayers().getArray());
|
||||
} else {
|
||||
const source = /** @type {import("./layer/Layer.js").default} */ (
|
||||
layer).getSource();
|
||||
|
||||
@@ -17,7 +17,6 @@ import {inAndOut} from './easing.js';
|
||||
import {getForViewAndSize, getCenter, getHeight, getWidth, isEmpty} from './extent.js';
|
||||
import GeometryType from './geom/GeometryType.js';
|
||||
import {fromExtent as polygonFromExtent} from './geom/Polygon.js';
|
||||
import SimpleGeometry from './geom/SimpleGeometry.js';
|
||||
import {clamp, modulo} from './math.js';
|
||||
import {assign} from './obj.js';
|
||||
import {createProjection, METERS_PER_UNIT} from './proj.js';
|
||||
@@ -974,7 +973,7 @@ class View extends BaseObject {
|
||||
* The size is pixel dimensions of the box to fit the extent into.
|
||||
* In most cases you will want to use the map size, that is `map.getSize()`.
|
||||
* Takes care of the map angle.
|
||||
* @param {SimpleGeometry|import("./extent.js").Extent} geometryOrExtent The geometry or
|
||||
* @param {import("./geom/SimpleGeometry.js").default|import("./extent.js").Extent} geometryOrExtent The geometry or
|
||||
* extent to fit the view to.
|
||||
* @param {FitOptions=} opt_options Options.
|
||||
* @api
|
||||
@@ -985,11 +984,11 @@ class View extends BaseObject {
|
||||
if (!size) {
|
||||
size = this.getSizeFromViewport_();
|
||||
}
|
||||
/** @type {SimpleGeometry} */
|
||||
/** @type {import("./geom/SimpleGeometry.js").default} */
|
||||
let geometry;
|
||||
if (!(geometryOrExtent instanceof SimpleGeometry)) {
|
||||
assert(Array.isArray(geometryOrExtent),
|
||||
24); // Invalid extent or geometry provided as `geometry`
|
||||
assert(Array.isArray(geometryOrExtent) || typeof /** @type {?} */ (geometryOrExtent).getSimplifiedGeometry === 'function',
|
||||
24); // Invalid extent or geometry provided as `geometry`
|
||||
if (Array.isArray(geometryOrExtent)) {
|
||||
assert(!isEmpty(geometryOrExtent),
|
||||
25); // Cannot fit empty extent provided as `geometry`
|
||||
geometry = polygonFromExtent(geometryOrExtent);
|
||||
|
||||
@@ -133,7 +133,7 @@ export function asArray(color) {
|
||||
if (Array.isArray(color)) {
|
||||
return color;
|
||||
} else {
|
||||
return fromString(/** @type {string} */ (color));
|
||||
return fromString(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +185,7 @@ function fromStringInternal_(s) {
|
||||
} else {
|
||||
assert(false, 14); // Invalid color
|
||||
}
|
||||
return (
|
||||
/** @type {Color} */ (color)
|
||||
);
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,22 +23,9 @@ import {toString} from './color.js';
|
||||
* @api
|
||||
*/
|
||||
export function asColorLike(color) {
|
||||
if (isColorLike(color)) {
|
||||
return /** @type {string|CanvasPattern|CanvasGradient} */ (color);
|
||||
if (Array.isArray(color)) {
|
||||
return toString(color);
|
||||
} else {
|
||||
return toString(/** @type {import("./color.js").Color} */ (color));
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {?} color The value that is potentially an {@link ol/colorlike~ColorLike}.
|
||||
* @return {boolean} The color is an {@link ol/colorlike~ColorLike}.
|
||||
*/
|
||||
export function isColorLike(color) {
|
||||
return (
|
||||
typeof color === 'string' ||
|
||||
color instanceof CanvasPattern ||
|
||||
color instanceof CanvasGradient
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/events/condition
|
||||
*/
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {TRUE, FALSE} from '../functions.js';
|
||||
import {WEBKIT, MAC} from '../has.js';
|
||||
@@ -225,9 +224,10 @@ export const targetNotEditable = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
export const mouseOnly = function(mapBrowserEvent) {
|
||||
assert(mapBrowserEvent instanceof MapBrowserPointerEvent, 56); // mapBrowserEvent must originate from a pointer event
|
||||
const pointerEvent = /** @type {import("../MapBrowserPointerEvent").default} */ (mapBrowserEvent).pointerEvent;
|
||||
assert(pointerEvent !== undefined, 56); // mapBrowserEvent must originate from a pointer event
|
||||
// see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
|
||||
return /** @type {MapBrowserPointerEvent} */ (mapBrowserEvent).pointerEvent.pointerType == 'mouse';
|
||||
return pointerEvent.pointerType == 'mouse';
|
||||
};
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ export const mouseOnly = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
export const primaryAction = function(mapBrowserEvent) {
|
||||
assert(mapBrowserEvent instanceof MapBrowserPointerEvent, 56); // mapBrowserEvent must originate from a pointer event
|
||||
const pointerEvent = /** @type {MapBrowserPointerEvent} */ (mapBrowserEvent).pointerEvent;
|
||||
const pointerEvent = /** @type {import("../MapBrowserPointerEvent").default} */ (mapBrowserEvent).pointerEvent;
|
||||
assert(pointerEvent !== undefined, 56); // mapBrowserEvent must originate from a pointer event
|
||||
return pointerEvent.isPrimary && pointerEvent.button === 0;
|
||||
};
|
||||
|
||||
@@ -494,9 +494,7 @@ export function getCorner(extent, corner) {
|
||||
} else {
|
||||
assert(false, 13); // Invalid corner
|
||||
}
|
||||
return (
|
||||
/** @type {!import("./coordinate.js").Coordinate} */ (coordinate)
|
||||
);
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
import {VOID} from './functions.js';
|
||||
import FormatType from './format/FormatType.js';
|
||||
import VectorSource from './source/Vector';
|
||||
|
||||
/**
|
||||
* {@link module:ol/source/Vector} sources use a function of this type to
|
||||
@@ -17,7 +16,7 @@ import VectorSource from './source/Vector';
|
||||
*
|
||||
* The function is responsible for loading the features and adding them to the
|
||||
* source.
|
||||
* @typedef {function(this:(VectorSource|import("./VectorTile.js").default), import("./extent.js").Extent, number,
|
||||
* @typedef {function(this:(import("./source/Vector").default|import("./VectorTile.js").default), import("./extent.js").Extent, number,
|
||||
* import("./proj/Projection.js").default)} FeatureLoader
|
||||
* @api
|
||||
*/
|
||||
@@ -39,10 +38,10 @@ import VectorSource from './source/Vector';
|
||||
/**
|
||||
* @param {string|FeatureUrlFunction} url Feature URL service.
|
||||
* @param {import("./format/Feature.js").default} format Feature format.
|
||||
* @param {function(this:import("./VectorTile.js").default, Array<import("./Feature.js").default>, import("./proj/Projection.js").default, import("./extent.js").Extent)|function(this:VectorSource, Array<import("./Feature.js").default>)} success
|
||||
* @param {function(this:import("./VectorTile.js").default, Array<import("./Feature.js").default>, import("./proj/Projection.js").default, import("./extent.js").Extent)|function(this:import("./source/Vector").default, Array<import("./Feature.js").default>)} success
|
||||
* Function called with the loaded features and optionally with the data
|
||||
* projection. Called with the vector tile or source as `this`.
|
||||
* @param {function(this:import("./VectorTile.js").default)|function(this:VectorSource)} failure
|
||||
* @param {function(this:import("./VectorTile.js").default)|function(this:import("./source/Vector").default)} failure
|
||||
* Function called when loading failed. Called with the vector tile or
|
||||
* source as `this`.
|
||||
* @return {FeatureLoader} The feature loader.
|
||||
@@ -53,7 +52,7 @@ export function loadFeaturesXhr(url, format, success, failure) {
|
||||
* @param {import("./extent.js").Extent} extent Extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {import("./proj/Projection.js").default} projection Projection.
|
||||
* @this {VectorSource|import("./VectorTile.js").default}
|
||||
* @this {import("./source/Vector").default|import("./VectorTile.js").default}
|
||||
*/
|
||||
function(extent, resolution, projection) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
@@ -121,11 +120,12 @@ export function xhr(url, format) {
|
||||
* @param {Array<import("./Feature.js").default>} features The loaded features.
|
||||
* @param {import("./proj/Projection.js").default} dataProjection Data
|
||||
* projection.
|
||||
* @this {VectorSource|import("./VectorTile.js").default}
|
||||
* @this {import("./source/Vector").default|import("./VectorTile.js").default}
|
||||
*/
|
||||
function(features, dataProjection) {
|
||||
if (this instanceof VectorSource) {
|
||||
this.addFeatures(features);
|
||||
const sourceOrTile = /** @type {?} */ (this);
|
||||
if (typeof sourceOrTile.addFeatures === 'function') {
|
||||
/** @type {import("./source/Vector").default} */ (sourceOrTile).addFeatures(features);
|
||||
}
|
||||
}, /* FIXME handle error */ VOID);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/format/Feature
|
||||
*/
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js';
|
||||
|
||||
@@ -151,7 +150,7 @@ class FeatureFormat {
|
||||
* @abstract
|
||||
* @param {Document|Node|Object|string} source Source.
|
||||
* @param {ReadOptions=} opt_options Read options.
|
||||
* @return {Geometry} Geometry.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometry(source, opt_options) {}
|
||||
|
||||
@@ -188,7 +187,7 @@ class FeatureFormat {
|
||||
* Write a single geometry in this format.
|
||||
*
|
||||
* @abstract
|
||||
* @param {Geometry} geometry Geometry.
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {WriteOptions=} opt_options Write options.
|
||||
* @return {string} Result.
|
||||
*/
|
||||
@@ -198,10 +197,10 @@ class FeatureFormat {
|
||||
export default FeatureFormat;
|
||||
|
||||
/**
|
||||
* @param {Geometry|import("../extent.js").Extent} geometry Geometry.
|
||||
* @param {import("../geom/Geometry.js").default|import("../extent.js").Extent} geometry Geometry.
|
||||
* @param {boolean} write Set to true for writing, false for reading.
|
||||
* @param {(WriteOptions|ReadOptions)=} opt_options Options.
|
||||
* @return {Geometry|import("../extent.js").Extent} Transformed geometry.
|
||||
* @return {import("../geom/Geometry.js").default|import("../extent.js").Extent} Transformed geometry.
|
||||
*/
|
||||
export function transformWithOptions(geometry, write, opt_options) {
|
||||
const featureProjection = opt_options ?
|
||||
@@ -209,28 +208,28 @@ export function transformWithOptions(geometry, write, opt_options) {
|
||||
const dataProjection = opt_options ?
|
||||
getProjection(opt_options.dataProjection) : null;
|
||||
/**
|
||||
* @type {Geometry|import("../extent.js").Extent}
|
||||
* @type {import("../geom/Geometry.js").default|import("../extent.js").Extent}
|
||||
*/
|
||||
let transformed;
|
||||
if (featureProjection && dataProjection &&
|
||||
!equivalentProjection(featureProjection, dataProjection)) {
|
||||
if (geometry instanceof Geometry) {
|
||||
transformed = (write ? geometry.clone() : geometry).transform(
|
||||
write ? featureProjection : dataProjection,
|
||||
write ? dataProjection : featureProjection);
|
||||
} else {
|
||||
if (Array.isArray(geometry)) {
|
||||
// FIXME this is necessary because GML treats extents
|
||||
// as geometries
|
||||
transformed = transformExtent(
|
||||
geometry,
|
||||
dataProjection,
|
||||
featureProjection);
|
||||
} else {
|
||||
transformed = (write ? /** @type {import("../geom/Geometry").default} */ (geometry).clone() : geometry).transform(
|
||||
write ? featureProjection : dataProjection,
|
||||
write ? dataProjection : featureProjection);
|
||||
}
|
||||
} else {
|
||||
transformed = geometry;
|
||||
}
|
||||
if (write && opt_options && /** @type {WriteOptions} */ (opt_options).decimals !== undefined &&
|
||||
transformed instanceof Geometry) {
|
||||
!Array.isArray(transformed)) {
|
||||
const power = Math.pow(10, /** @type {WriteOptions} */ (opt_options).decimals);
|
||||
// if decimals option on write, round each coordinate appropriately
|
||||
/**
|
||||
@@ -244,7 +243,7 @@ export function transformWithOptions(geometry, write, opt_options) {
|
||||
return coordinates;
|
||||
};
|
||||
if (transformed === geometry) {
|
||||
transformed = transformed.clone();
|
||||
transformed = /** @type {import("../geom/Geometry").default} */ (geometry).clone();
|
||||
}
|
||||
transformed.applyTransform(transform);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import {createOrUpdate} from '../extent.js';
|
||||
import {transformWithOptions} from '../format/Feature.js';
|
||||
import GMLBase, {GMLNS} from '../format/GMLBase.js';
|
||||
import {writeStringTextNode} from '../format/xsd.js';
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {get as getProjection, transformExtent} from '../proj.js';
|
||||
import {createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender,
|
||||
@@ -196,7 +195,7 @@ class GML2 extends GMLBase {
|
||||
if (value !== null) {
|
||||
keys.push(key);
|
||||
values.push(value);
|
||||
if (key == geometryName || value instanceof Geometry) {
|
||||
if (key == geometryName || typeof /** @type {?} */ (value).getSimplifiedGeometry === 'function') {
|
||||
if (!(key in context.serializers[featureNS])) {
|
||||
context.serializers[featureNS][key] = makeChildAppender(
|
||||
this.writeGeometryElement, this);
|
||||
|
||||
@@ -6,7 +6,6 @@ import {createOrUpdate} from '../extent.js';
|
||||
import {transformWithOptions} from '../format/Feature.js';
|
||||
import GMLBase, {GMLNS} from '../format/GMLBase.js';
|
||||
import {readNonNegativeIntegerString, writeStringTextNode} from '../format/xsd.js';
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import MultiLineString from '../geom/MultiLineString.js';
|
||||
@@ -774,7 +773,7 @@ class GML3 extends GMLBase {
|
||||
if (value !== null) {
|
||||
keys.push(key);
|
||||
values.push(value);
|
||||
if (key == geometryName || value instanceof Geometry) {
|
||||
if (key == geometryName || typeof /** @type {?} */ (value).getSimplifiedGeometry === 'function') {
|
||||
if (!(key in context.serializers[featureNS])) {
|
||||
context.serializers[featureNS][key] = makeChildAppender(
|
||||
this.writeGeometryElement, this);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {transformWithOptions} from '../format/Feature.js';
|
||||
import XMLFeature from '../format/XMLFeature.js';
|
||||
import {readString, readDecimal, readNonNegativeInteger, readDateTime, writeStringTextNode, writeNonNegativeIntegerTextNode, writeDecimalTextNode, writeDateTimeTextNode} from '../format/xsd.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import MultiLineString from '../geom/MultiLineString.js';
|
||||
import Point from '../geom/Point.js';
|
||||
@@ -782,7 +783,7 @@ function writeRte(node, feature, objectStack) {
|
||||
const context = {node: node};
|
||||
context['properties'] = properties;
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry instanceof LineString) {
|
||||
if (geometry.getType() == GeometryType.LINE_STRING) {
|
||||
const lineString = /** @type {LineString} */ (transformWithOptions(geometry, true, options));
|
||||
context['geometryLayout'] = lineString.getLayout();
|
||||
properties['rtept'] = lineString.getCoordinates();
|
||||
@@ -808,7 +809,7 @@ function writeTrk(node, feature, objectStack) {
|
||||
const context = {node: node};
|
||||
context['properties'] = properties;
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry instanceof MultiLineString) {
|
||||
if (geometry.getType() == GeometryType.MULTI_LINE_STRING) {
|
||||
const multiLineString = /** @type {MultiLineString} */ (transformWithOptions(geometry, true, options));
|
||||
properties['trkseg'] = multiLineString.getLineStrings();
|
||||
}
|
||||
@@ -847,7 +848,7 @@ function writeWpt(node, feature, objectStack) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
context['properties'] = feature.getProperties();
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry instanceof Point) {
|
||||
if (geometry.getType() == GeometryType.POINT) {
|
||||
const point = /** @type {Point} */ (transformWithOptions(geometry, true, options));
|
||||
context['geometryLayout'] = point.getLayout();
|
||||
writeWptType(node, point.getCoordinates(), objectStack);
|
||||
|
||||
@@ -26,7 +26,7 @@ import IconOrigin from '../style/IconOrigin.js';
|
||||
import Stroke from '../style/Stroke.js';
|
||||
import Style from '../style/Style.js';
|
||||
import Text from '../style/Text.js';
|
||||
import {createElementNS, getAllTextContent, isDocument, isNode, makeArrayExtender,
|
||||
import {createElementNS, getAllTextContent, isDocument, makeArrayExtender,
|
||||
makeArrayPusher, makeChildAppender, makeObjectPropertySetter,
|
||||
makeReplacer, makeSequence, makeSimpleNodeFactory, makeStructureNS,
|
||||
OBJECT_PROPERTY_NODE_FACTORY, parse, parseNode, pushParseAndPop,
|
||||
@@ -639,15 +639,15 @@ class KML extends XMLFeature {
|
||||
* @api
|
||||
*/
|
||||
readName(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readNameFromDocument(/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readNameFromNode(/** @type {Element} */ (source));
|
||||
if (!source) {
|
||||
return undefined;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readNameFromDocument(doc);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readNameFromDocument(/** @type {Document} */ (source));
|
||||
} else {
|
||||
return undefined;
|
||||
return this.readNameFromNode(/** @type {Element} */ (source));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,15 +703,15 @@ class KML extends XMLFeature {
|
||||
*/
|
||||
readNetworkLinks(source) {
|
||||
const networkLinks = [];
|
||||
if (isDocument(source)) {
|
||||
extend(networkLinks, this.readNetworkLinksFromDocument(
|
||||
/** @type {Document} */ (source)));
|
||||
} else if (isNode(source)) {
|
||||
extend(networkLinks, this.readNetworkLinksFromNode(
|
||||
/** @type {Element} */ (source)));
|
||||
} else if (typeof source === 'string') {
|
||||
if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
extend(networkLinks, this.readNetworkLinksFromDocument(doc));
|
||||
} else if (isDocument(source)) {
|
||||
extend(networkLinks, this.readNetworkLinksFromDocument(
|
||||
/** @type {Document} */ (source)));
|
||||
} else {
|
||||
extend(networkLinks, this.readNetworkLinksFromNode(
|
||||
/** @type {Element} */ (source)));
|
||||
}
|
||||
return networkLinks;
|
||||
}
|
||||
@@ -765,15 +765,15 @@ class KML extends XMLFeature {
|
||||
*/
|
||||
readRegion(source) {
|
||||
const regions = [];
|
||||
if (isDocument(source)) {
|
||||
extend(regions, this.readRegionFromDocument(
|
||||
/** @type {Document} */ (source)));
|
||||
} else if (isNode(source)) {
|
||||
extend(regions, this.readRegionFromNode(
|
||||
/** @type {Element} */ (source)));
|
||||
} else if (typeof source === 'string') {
|
||||
if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
extend(regions, this.readRegionFromDocument(doc));
|
||||
} else if (isDocument(source)) {
|
||||
extend(regions, this.readRegionFromDocument(
|
||||
/** @type {Document} */ (source)));
|
||||
} else {
|
||||
extend(regions, this.readRegionFromNode(
|
||||
/** @type {Element} */ (source)));
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
@@ -2897,7 +2897,7 @@ function writeStyle(node, style, objectStack) {
|
||||
const strokeStyle = style.getStroke();
|
||||
const imageStyle = style.getImage();
|
||||
const textStyle = style.getText();
|
||||
if (imageStyle instanceof Icon) {
|
||||
if (imageStyle && typeof /** @type {?} */ (imageStyle).getSrc === 'function') {
|
||||
properties['IconStyle'] = imageStyle;
|
||||
}
|
||||
if (textStyle) {
|
||||
|
||||
@@ -8,10 +8,9 @@ import GMLBase, {GMLNS} from '../format/GMLBase.js';
|
||||
import {and as andFilter, bbox as bboxFilter} from '../format/filter.js';
|
||||
import XMLFeature from '../format/XMLFeature.js';
|
||||
import {readNonNegativeIntegerString, readNonNegativeInteger, writeStringTextNode} from '../format/xsd.js';
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
import {createElementNS, isDocument, isNode, makeArrayPusher, makeChildAppender,
|
||||
import {createElementNS, isDocument, makeArrayPusher, makeChildAppender,
|
||||
makeObjectPropertySetter, makeSimpleNodeFactory, parse, parseNode,
|
||||
pushParseAndPop, pushSerializeAndPop, XML_SCHEMA_INSTANCE_URI} from '../xml.js';
|
||||
|
||||
@@ -288,16 +287,16 @@ class WFS extends XMLFeature {
|
||||
* @api
|
||||
*/
|
||||
readTransactionResponse(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readTransactionResponseFromDocument(
|
||||
/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readTransactionResponseFromNode(/** @type {Element} */ (source));
|
||||
if (!source) {
|
||||
return undefined;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readTransactionResponseFromDocument(doc);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readTransactionResponseFromDocument(
|
||||
/** @type {Document} */ (source));
|
||||
} else {
|
||||
return undefined;
|
||||
return this.readTransactionResponseFromNode(/** @type {Element} */ (source));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,17 +309,17 @@ class WFS extends XMLFeature {
|
||||
* @api
|
||||
*/
|
||||
readFeatureCollectionMetadata(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readFeatureCollectionMetadataFromDocument(
|
||||
/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readFeatureCollectionMetadataFromNode(
|
||||
/** @type {Element} */ (source));
|
||||
if (!source) {
|
||||
return undefined;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFeatureCollectionMetadataFromDocument(doc);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readFeatureCollectionMetadataFromDocument(
|
||||
/** @type {Document} */ (source));
|
||||
} else {
|
||||
return undefined;
|
||||
return this.readFeatureCollectionMetadataFromNode(
|
||||
/** @type {Element} */ (source));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,7 +693,7 @@ function writeUpdate(node, feature, objectStack) {
|
||||
const value = feature.get(keys[i]);
|
||||
if (value !== undefined) {
|
||||
let name = keys[i];
|
||||
if (value instanceof Geometry) {
|
||||
if (value && typeof /** @type {?} */ (value).getSimplifiedGeometry === 'function') {
|
||||
name = geometryName;
|
||||
}
|
||||
values.push({name: name, value: value});
|
||||
@@ -725,7 +724,7 @@ function writeProperty(node, pair, objectStack) {
|
||||
if (pair.value !== undefined && pair.value !== null) {
|
||||
const value = createElementNS(WFSNS, 'Value');
|
||||
node.appendChild(value);
|
||||
if (pair.value instanceof Geometry) {
|
||||
if (pair.value && typeof /** @type {?} */ (pair.value).getSimplifiedGeometry === 'function') {
|
||||
if (gmlVersion === 2) {
|
||||
GML2.prototype.writeGeometryElement(value,
|
||||
pair.value, objectStack);
|
||||
|
||||
@@ -13,7 +13,6 @@ import MultiPoint from '../geom/MultiPoint.js';
|
||||
import MultiPolygon from '../geom/MultiPolygon.js';
|
||||
import Point from '../geom/Point.js';
|
||||
import Polygon from '../geom/Polygon.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -823,7 +822,7 @@ function encodeMultiPolygonGeometry(geom) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {SimpleGeometry} geom SimpleGeometry geometry.
|
||||
* @param {import("../geom/SimpleGeometry.js").default} geom SimpleGeometry geometry.
|
||||
* @return {string} Potential dimensional information for WKT type.
|
||||
*/
|
||||
function encodeGeometryLayout(geom) {
|
||||
@@ -856,7 +855,7 @@ const GeometryEncoder = {
|
||||
|
||||
/**
|
||||
* Encode a geometry as WKT.
|
||||
* @param {import("../geom/Geometry.js").default} geom The geometry to encode.
|
||||
* @param {!import("../geom/Geometry.js").default} geom The geometry to encode.
|
||||
* @return {string} WKT string for the geometry.
|
||||
*/
|
||||
function encode(geom) {
|
||||
@@ -864,8 +863,8 @@ function encode(geom) {
|
||||
const geometryEncoder = GeometryEncoder[type];
|
||||
const enc = geometryEncoder(geom);
|
||||
type = type.toUpperCase();
|
||||
if (geom instanceof SimpleGeometry) {
|
||||
const dimInfo = encodeGeometryLayout(geom);
|
||||
if (typeof /** @type {?} */ (geom).getFlatCoordinates === 'function') {
|
||||
const dimInfo = encodeGeometryLayout(/** @type {import("../geom/SimpleGeometry.js").default} */ (geom));
|
||||
if (dimInfo.length > 0) {
|
||||
type += ' ' + dimInfo;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/format/XML
|
||||
*/
|
||||
import {isDocument, isNode, parse} from '../xml.js';
|
||||
import {isDocument, parse} from '../xml.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -18,15 +18,15 @@ class XML {
|
||||
* @api
|
||||
*/
|
||||
read(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readFromDocument(/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readFromNode(/** @type {Element} */ (source));
|
||||
if (!source) {
|
||||
return null;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFromDocument(doc);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readFromDocument(/** @type {Document} */ (source));
|
||||
} else {
|
||||
return null;
|
||||
return this.readFromNode(/** @type {Element} */ (source));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {extend} from '../array.js';
|
||||
import FeatureFormat from '../format/Feature.js';
|
||||
import FormatType from '../format/FormatType.js';
|
||||
import {isDocument, isNode, parse} from '../xml.js';
|
||||
import {isDocument, parse} from '../xml.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -41,15 +41,15 @@ class XMLFeature extends FeatureFormat {
|
||||
* @api
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
if (isDocument(source)) {
|
||||
return this.readFeatureFromDocument(/** @type {Document} */ (source), opt_options);
|
||||
} else if (isNode(source)) {
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
||||
if (!source) {
|
||||
return null;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFeatureFromDocument(doc, opt_options);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readFeatureFromDocument(/** @type {Document} */ (source), opt_options);
|
||||
} else {
|
||||
return null;
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,16 +85,16 @@ class XMLFeature extends FeatureFormat {
|
||||
* @api
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
if (isDocument(source)) {
|
||||
return this.readFeaturesFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (isNode(source)) {
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options);
|
||||
if (!source) {
|
||||
return [];
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFeaturesFromDocument(doc, opt_options);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readFeaturesFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else {
|
||||
return [];
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,16 +128,16 @@ class XMLFeature extends FeatureFormat {
|
||||
* @inheritDoc
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
if (isDocument(source)) {
|
||||
return this.readGeometryFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (isNode(source)) {
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options);
|
||||
if (!source) {
|
||||
return null;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readGeometryFromDocument(doc, opt_options);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readGeometryFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else {
|
||||
return null;
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,15 +169,15 @@ class XMLFeature extends FeatureFormat {
|
||||
* @api
|
||||
*/
|
||||
readProjection(source) {
|
||||
if (isDocument(source)) {
|
||||
return this.readProjectionFromDocument(/** @type {Document} */ (source));
|
||||
} else if (isNode(source)) {
|
||||
return this.readProjectionFromNode(/** @type {Node} */ (source));
|
||||
if (!source) {
|
||||
return null;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readProjectionFromDocument(doc);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readProjectionFromDocument(/** @type {Document} */ (source));
|
||||
} else {
|
||||
return null;
|
||||
return this.readProjectionFromNode(/** @type {Node} */ (source));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import {createEditingStyle} from '../style/Style.js';
|
||||
* @property {import("../events/condition.js").Condition} [finishCondition] A function
|
||||
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
|
||||
* boolean to indicate whether the drawing can be finished.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [style]
|
||||
* @property {import("../style/Style.js").StyleLike} [style]
|
||||
* Style for sketch features.
|
||||
* @property {GeometryFunction} [geometryFunction]
|
||||
* Function that is called when a geometry's coordinates are updated.
|
||||
@@ -206,7 +206,7 @@ class Draw extends PointerInteraction {
|
||||
this.downPx_ = null;
|
||||
|
||||
/**
|
||||
* @type {any}
|
||||
* @type {?}
|
||||
* @private
|
||||
*/
|
||||
this.downTimeout_;
|
||||
@@ -734,12 +734,12 @@ class Draw extends PointerInteraction {
|
||||
}
|
||||
/** @type {LineString} */
|
||||
let sketchLineGeom;
|
||||
if (geometry instanceof Polygon &&
|
||||
if (geometry.getType() == GeometryType.POLYGON &&
|
||||
this.mode_ !== Mode.POLYGON) {
|
||||
if (!this.sketchLine_) {
|
||||
this.sketchLine_ = new Feature();
|
||||
}
|
||||
const ring = geometry.getLinearRing(0);
|
||||
const ring = /** @type {Polygon} */ (geometry).getLinearRing(0);
|
||||
sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry());
|
||||
if (!sketchLineGeom) {
|
||||
sketchLineGeom = new LineString(ring.getFlatCoordinates(), ring.getLayout());
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
import Feature from '../Feature.js';
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
|
||||
import {squaredDistanceToSegment, closestOnSegment, distance as coordinateDistance, squaredDistance as squaredCoordinateDistance} from '../coordinate.js';
|
||||
import Event from '../events/Event.js';
|
||||
import {boundingExtent, getArea} from '../extent.js';
|
||||
@@ -20,12 +19,12 @@ import {createEditingStyle} from '../style/Style.js';
|
||||
* @typedef {Object} Options
|
||||
* @property {import("../extent.js").Extent} [extent] Initial extent. Defaults to no
|
||||
* initial extent.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [boxStyle]
|
||||
* @property {import("../style/Style.js").StyleLike} [boxStyle]
|
||||
* Style for the drawn extent box. Defaults to
|
||||
* {@link module:ol/style/Style~createEditing()['Polygon']}
|
||||
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the
|
||||
* pointer close enough to a segment or vertex for editing.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [pointerStyle]
|
||||
* @property {import("../style/Style.js").StyleLike} [pointerStyle]
|
||||
* Style for the cursor used to draw the extent. Defaults to
|
||||
* {@link module:ol/style/Style~createEditing()['Point']}
|
||||
* @property {boolean} [wrapX=false] Wrap the drawn extent across multiple maps
|
||||
@@ -276,7 +275,7 @@ class ExtentInteraction extends PointerInteraction {
|
||||
* @inheritDoc
|
||||
*/
|
||||
handleEvent(mapBrowserEvent) {
|
||||
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
|
||||
if (!(/** @type {import("../MapBrowserPointerEvent.js").default} */ (mapBrowserEvent).pointerEvent)) {
|
||||
return true;
|
||||
}
|
||||
//display pointer (if not dragging)
|
||||
|
||||
@@ -6,7 +6,6 @@ import Collection from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import Feature from '../Feature.js';
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
|
||||
import {equals} from '../array.js';
|
||||
import {equals as coordinatesEqual, distance as coordinateDistance, squaredDistance as squaredCoordinateDistance, squaredDistanceToSegment, closestOnSegment} from '../coordinate.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
@@ -87,7 +86,7 @@ const ModifyEventType = {
|
||||
* features. Default is {@link module:ol/events/condition~always}.
|
||||
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the
|
||||
* pointer close enough to a segment or vertex for editing.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [style]
|
||||
* @property {import("../style/Style.js").StyleLike} [style]
|
||||
* Style used for the features being modified. By default the default edit
|
||||
* style is used (see {@link module:ol/style}).
|
||||
* @property {VectorSource} [source] The vector source with
|
||||
@@ -111,7 +110,7 @@ export class ModifyEvent extends Event {
|
||||
* @param {ModifyEventType} type Type.
|
||||
* @param {Collection<Feature>} features
|
||||
* The features modified.
|
||||
* @param {MapBrowserPointerEvent} mapBrowserPointerEvent
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserPointerEvent
|
||||
* Associated {@link module:ol/MapBrowserPointerEvent}.
|
||||
*/
|
||||
constructor(type, features, mapBrowserPointerEvent) {
|
||||
@@ -324,7 +323,7 @@ class Modify extends PointerInteraction {
|
||||
this.handleFeatureRemove_, this);
|
||||
|
||||
/**
|
||||
* @type {MapBrowserPointerEvent}
|
||||
* @type {import("../MapBrowserPointerEvent.js").default}
|
||||
* @private
|
||||
*/
|
||||
this.lastPointerEvent_ = null;
|
||||
@@ -349,7 +348,7 @@ class Modify extends PointerInteraction {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MapBrowserPointerEvent} evt Map browser event
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} evt Map browser event
|
||||
* @private
|
||||
*/
|
||||
willModifyFeatures_(evt) {
|
||||
@@ -666,7 +665,7 @@ class Modify extends PointerInteraction {
|
||||
* @override
|
||||
*/
|
||||
handleEvent(mapBrowserEvent) {
|
||||
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
|
||||
if (!(/** @type {import("../MapBrowserPointerEvent.js").default} */ (mapBrowserEvent).pointerEvent)) {
|
||||
return true;
|
||||
}
|
||||
this.lastPointerEvent_ = mapBrowserEvent;
|
||||
|
||||
@@ -108,7 +108,7 @@ class MouseWheelZoom extends Interaction {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {any}
|
||||
* @type {?}
|
||||
*/
|
||||
this.timeoutId_;
|
||||
|
||||
@@ -126,7 +126,7 @@ class MouseWheelZoom extends Interaction {
|
||||
this.trackpadEventGap_ = 400;
|
||||
|
||||
/**
|
||||
* @type {any}
|
||||
* @type {?}
|
||||
*/
|
||||
this.trackpadTimeoutId_;
|
||||
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
* @module ol/interaction/Pointer
|
||||
*/
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import {getValues} from '../obj.js';
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {function(MapBrowserPointerEvent):boolean} [handleDownEvent]
|
||||
* @property {function(import("../MapBrowserPointerEvent.js").default):boolean} [handleDownEvent]
|
||||
* Function handling "down" events. If the function returns `true` then a drag
|
||||
* sequence is started.
|
||||
* @property {function(MapBrowserPointerEvent)} [handleDragEvent]
|
||||
* @property {function(import("../MapBrowserPointerEvent.js").default)} [handleDragEvent]
|
||||
* Function handling "drag" events. This function is called on "move" events
|
||||
* during a drag sequence.
|
||||
* @property {function(import("../MapBrowserEvent.js").default):boolean} [handleEvent]
|
||||
@@ -20,11 +19,11 @@ import {getValues} from '../obj.js';
|
||||
* dispatched to the map. The function may return `false` to prevent the
|
||||
* propagation of the event to other interactions in the map's interactions
|
||||
* chain.
|
||||
* @property {function(MapBrowserPointerEvent)} [handleMoveEvent]
|
||||
* @property {function(import("../MapBrowserPointerEvent.js").default)} [handleMoveEvent]
|
||||
* Function handling "move" events. This function is called on "move" events,
|
||||
* also during a drag sequence (so during a drag sequence both the
|
||||
* `handleDragEvent` function and this function are called).
|
||||
* @property {function(MapBrowserPointerEvent):boolean} [handleUpEvent]
|
||||
* @property {function(import("../MapBrowserPointerEvent.js").default):boolean} [handleUpEvent]
|
||||
* Function handling "up" events. If the function returns `false` then the
|
||||
* current drag sequence is stopped.
|
||||
* @property {function(boolean):boolean} [stopDown]
|
||||
@@ -96,7 +95,7 @@ class PointerInteraction extends Interaction {
|
||||
|
||||
/**
|
||||
* Handle pointer down events.
|
||||
* @param {MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @return {boolean} If the event was consumed.
|
||||
* @protected
|
||||
*/
|
||||
@@ -106,7 +105,7 @@ class PointerInteraction extends Interaction {
|
||||
|
||||
/**
|
||||
* Handle pointer drag events.
|
||||
* @param {MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @protected
|
||||
*/
|
||||
handleDragEvent(mapBrowserEvent) {}
|
||||
@@ -119,7 +118,7 @@ class PointerInteraction extends Interaction {
|
||||
* @api
|
||||
*/
|
||||
handleEvent(mapBrowserEvent) {
|
||||
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
|
||||
if (!(/** @type {import("../MapBrowserPointerEvent.js").default} */ (mapBrowserEvent).pointerEvent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,14 +148,14 @@ class PointerInteraction extends Interaction {
|
||||
|
||||
/**
|
||||
* Handle pointer move events.
|
||||
* @param {MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @protected
|
||||
*/
|
||||
handleMoveEvent(mapBrowserEvent) {}
|
||||
|
||||
/**
|
||||
* Handle pointer up events.
|
||||
* @param {MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @return {boolean} If the event was consumed.
|
||||
* @protected
|
||||
*/
|
||||
@@ -175,7 +174,7 @@ class PointerInteraction extends Interaction {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @private
|
||||
*/
|
||||
updateTrackedPointers_(mapBrowserEvent) {
|
||||
@@ -216,7 +215,7 @@ export function centroid(pointerEvents) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @return {boolean} Whether the event is a pointerdown, pointerdrag
|
||||
* or pointerup event.
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ const SelectEventType = {
|
||||
* in the map and should return `true` for layers that you want to be
|
||||
* selectable. If the option is absent, all visible layers will be considered
|
||||
* selectable.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [style]
|
||||
* @property {import("../style/Style.js").StyleLike} [style]
|
||||
* Style for the selected features. By default the default edit style is used
|
||||
* (see {@link module:ol/style}).
|
||||
* @property {import("../events/condition.js").Condition} [removeCondition] A function
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/interaction/Snap
|
||||
*/
|
||||
import {getUid} from '../util.js';
|
||||
import {CollectionEvent} from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import {distance as coordinateDistance, squaredDistance as squaredCoordinateDistance, closestOnCircle, closestOnSegment, squaredDistanceToSegment} from '../coordinate.js';
|
||||
import {listen, unlistenByKey} from '../events.js';
|
||||
@@ -13,7 +12,6 @@ import GeometryType from '../geom/GeometryType.js';
|
||||
import {fromCircle} from '../geom/Polygon.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
import {getValues} from '../obj.js';
|
||||
import {VectorSourceEvent} from '../source/Vector.js';
|
||||
import VectorEventType from '../source/VectorEventType.js';
|
||||
import RBush from '../structs/RBush.js';
|
||||
|
||||
@@ -44,6 +42,19 @@ import RBush from '../structs/RBush.js';
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent} evt Event.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
function getFeatureFromEvent(evt) {
|
||||
if (/** @type {import("../source/Vector.js").VectorSourceEvent} */ (evt).feature) {
|
||||
return /** @type {import("../source/Vector.js").VectorSourceEvent} */ (evt).feature;
|
||||
} else if (/** @type {import("../Collection.js").CollectionEvent} */ (evt).element) {
|
||||
return /** @type {import("../Feature.js").default} */ (/** @type {import("../Collection.js").CollectionEvent} */ (evt).element);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Handles snapping of vector features while modifying or drawing them. The
|
||||
@@ -259,12 +270,7 @@ class Snap extends PointerInteraction {
|
||||
* @private
|
||||
*/
|
||||
handleFeatureAdd_(evt) {
|
||||
let feature;
|
||||
if (evt instanceof VectorSourceEvent) {
|
||||
feature = evt.feature;
|
||||
} else if (evt instanceof CollectionEvent) {
|
||||
feature = /** @type {import("../Feature.js").default} */ (evt.element);
|
||||
}
|
||||
const feature = getFeatureFromEvent(evt);
|
||||
this.addFeature(feature);
|
||||
}
|
||||
|
||||
@@ -273,12 +279,7 @@ class Snap extends PointerInteraction {
|
||||
* @private
|
||||
*/
|
||||
handleFeatureRemove_(evt) {
|
||||
let feature;
|
||||
if (evt instanceof VectorSourceEvent) {
|
||||
feature = evt.feature;
|
||||
} else if (evt instanceof CollectionEvent) {
|
||||
feature = /** @type {import("../Feature.js").default} */ (evt.element);
|
||||
}
|
||||
const feature = getFeatureFromEvent(evt);
|
||||
this.removeFeature(feature);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +84,8 @@ class LayerGroup extends BaseLayer {
|
||||
if (Array.isArray(layers)) {
|
||||
layers = new Collection(layers.slice(), {unique: true});
|
||||
} else {
|
||||
assert(layers instanceof Collection,
|
||||
assert(typeof /** @type {?} */ (layers).getArray === 'function',
|
||||
43); // Expected `layers` to be an array or a `Collection`
|
||||
layers = layers;
|
||||
}
|
||||
} else {
|
||||
layers = new Collection(undefined, {unique: true});
|
||||
|
||||
@@ -41,7 +41,7 @@ import {createDefaultStyle, toFunction as toStyleFunction} from '../style/Style.
|
||||
* @property {boolean} [declutter=false] Declutter images and text. Decluttering is applied to all
|
||||
* image and text styles, and the priority is defined by the z-index of the style. Lower z-index
|
||||
* means higher priority.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [style] Layer style. See
|
||||
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
|
||||
* {@link module:ol/style} for default style which will be used if this is not defined.
|
||||
* @property {boolean} [updateWhileAnimating=false] When set to `true` and `renderMode`
|
||||
* is `vector`, feature batches will be recreated during animations. This means that no
|
||||
@@ -119,7 +119,7 @@ class VectorLayer extends Layer {
|
||||
|
||||
/**
|
||||
* User provided style.
|
||||
* @type {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction}
|
||||
* @type {import("../style/Style.js").StyleLike}
|
||||
* @private
|
||||
*/
|
||||
this.style_ = null;
|
||||
@@ -196,7 +196,7 @@ class VectorLayer extends Layer {
|
||||
/**
|
||||
* Get the style for features. This returns whatever was passed to the `style`
|
||||
* option at construction or to the `setStyle` method.
|
||||
* @return {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction}
|
||||
* @return {import("../style/Style.js").StyleLike}
|
||||
* Layer style.
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -70,7 +70,7 @@ export const RenderType = {
|
||||
* image and text styles, and the priority is defined by the z-index of the style. Lower z-index
|
||||
* means higher priority. When set to `true`, a `renderMode` of `'image'` will be overridden with
|
||||
* `'hybrid'`.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [style] Layer style. See
|
||||
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
|
||||
* {@link module:ol/style} for default style which will be used if this is not defined.
|
||||
* @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will be
|
||||
* recreated during animations. This means that no vectors will be shown clipped, but the setting
|
||||
@@ -82,7 +82,7 @@ export const RenderType = {
|
||||
* means no preloading.
|
||||
* @property {import("../render.js").OrderFunction} [renderOrder] Render order. Function to be used when sorting
|
||||
* features before rendering. By default features are drawn in the order that they are created.
|
||||
* @property {import("../style/Style.js").default|Array<import("../style/Style.js").default>|import("../style/Style.js").StyleFunction} [style] Layer style. See
|
||||
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
|
||||
* {@link module:ol/style} for default style which will be used if this is not defined.
|
||||
* @property {boolean} [useInterimTilesOnError=true] Use interim tiles on error.
|
||||
*/
|
||||
|
||||
@@ -137,7 +137,7 @@ class TouchSource extends EventSource {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {any}
|
||||
* @type {?}
|
||||
*/
|
||||
this.resetId_;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import {getUid} from '../util.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import Feature from '../Feature.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import {scale as scaleCoordinate, add as addCoordinate} from '../coordinate.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
@@ -76,7 +77,7 @@ class Cluster extends VectorSource {
|
||||
*/
|
||||
this.geometryFunction = options.geometryFunction || function(feature) {
|
||||
const geometry = /** @type {Point} */ (feature.getGeometry());
|
||||
assert(geometry instanceof Point,
|
||||
assert(geometry.getType() == GeometryType.POINT,
|
||||
10); // The default `geometryFunction` can only handle `Point` geometries
|
||||
return geometry;
|
||||
};
|
||||
|
||||
@@ -230,10 +230,7 @@ class ImageSource extends Source {
|
||||
* @param {string} src Source.
|
||||
*/
|
||||
export function defaultImageLoadFunction(image, src) {
|
||||
const img = image.getImage();
|
||||
if (img instanceof HTMLImageElement || img instanceof HTMLVideoElement) {
|
||||
img.src = src;
|
||||
}
|
||||
/** @type {HTMLImageElement|HTMLVideoElement} */ (image.getImage()).src = src;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import EventType from '../events/EventType.js';
|
||||
import {Processor} from 'pixelworks/lib/index';
|
||||
import {equals, getCenter, getHeight, getWidth} from '../extent.js';
|
||||
import LayerType from '../LayerType.js';
|
||||
import Layer from '../layer/Layer.js';
|
||||
import ImageLayer from '../layer/Image.js';
|
||||
import TileLayer from '../layer/Tile.js';
|
||||
import {assign} from '../obj.js';
|
||||
@@ -19,7 +18,6 @@ import CanvasImageLayerRenderer from '../renderer/canvas/ImageLayer.js';
|
||||
import CanvasTileLayerRenderer from '../renderer/canvas/TileLayer.js';
|
||||
import ImageSource from '../source/Image.js';
|
||||
import SourceState from '../source/State.js';
|
||||
import TileSource from '../source/Tile.js';
|
||||
import {create as createTransform} from '../transform.js';
|
||||
|
||||
|
||||
@@ -488,20 +486,22 @@ function createRenderers(sources) {
|
||||
|
||||
/**
|
||||
* Create a renderer for the provided source.
|
||||
* @param {import("./Source.js").default|import("../layer/Layer.js").default} source The source.
|
||||
* @param {import("./Source.js").default|import("../layer/Layer.js").default} layerOrSource The layer or source.
|
||||
* @return {import("../renderer/canvas/Layer.js").default} The renderer.
|
||||
*/
|
||||
function createRenderer(source) {
|
||||
function createRenderer(layerOrSource) {
|
||||
const tileSource = /** @type {import("./Tile.js").default} */ (layerOrSource);
|
||||
const imageSource = /** @type {import("./Image.js").default} */ (layerOrSource);
|
||||
const layer = /** @type {import("../layer/Layer.js").default} */ (layerOrSource);
|
||||
let renderer = null;
|
||||
if (source instanceof TileSource) {
|
||||
renderer = createTileRenderer(source);
|
||||
} else if (source instanceof ImageSource) {
|
||||
renderer = createImageRenderer(source);
|
||||
} else if (source instanceof TileLayer) {
|
||||
renderer = new CanvasTileLayerRenderer(source);
|
||||
} else if (source instanceof Layer &&
|
||||
(source.getType() == LayerType.IMAGE || source.getType() == LayerType.VECTOR)) {
|
||||
renderer = new CanvasImageLayerRenderer(source);
|
||||
if (typeof tileSource.getTile === 'function') {
|
||||
renderer = createTileRenderer(tileSource);
|
||||
} else if (typeof imageSource.getImage === 'function') {
|
||||
renderer = createImageRenderer(imageSource);
|
||||
} else if (layer.getType() === LayerType.TILE) {
|
||||
renderer = new CanvasTileLayerRenderer(/** @type {import("../layer/Tile.js").default} */ (layer));
|
||||
} else if (layer.getType() == LayerType.IMAGE || layer.getType() == LayerType.VECTOR) {
|
||||
renderer = new CanvasImageLayerRenderer(/** @type {import("../layer/Image.js").default} */ (layer));
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@@ -392,10 +392,7 @@ class TileImage extends UrlTile {
|
||||
* @param {string} src Source.
|
||||
*/
|
||||
function defaultTileLoadFunction(imageTile, src) {
|
||||
const image = imageTile.getImage();
|
||||
if (image instanceof HTMLImageElement || image instanceof HTMLVideoElement) {
|
||||
image.src = src;
|
||||
}
|
||||
/** @type {HTMLImageElement|HTMLVideoElement} */ (imageTile.getImage()).src = src;
|
||||
}
|
||||
|
||||
export default TileImage;
|
||||
|
||||
@@ -258,11 +258,11 @@ class VectorSource extends Source {
|
||||
this.featuresCollection_ = null;
|
||||
|
||||
let collection, features;
|
||||
if (options.features instanceof Collection) {
|
||||
if (Array.isArray(options.features)) {
|
||||
features = options.features;
|
||||
} else if (options.features) {
|
||||
collection = options.features;
|
||||
features = collection.getArray();
|
||||
} else if (Array.isArray(options.features)) {
|
||||
features = options.features;
|
||||
}
|
||||
if (!useSpatialIndex && collection === undefined) {
|
||||
collection = new Collection(features);
|
||||
|
||||
@@ -76,13 +76,15 @@ class Fill {
|
||||
*/
|
||||
getChecksum() {
|
||||
if (this.checksum_ === undefined) {
|
||||
if (
|
||||
this.color_ instanceof CanvasPattern ||
|
||||
this.color_ instanceof CanvasGradient
|
||||
) {
|
||||
this.checksum_ = getUid(this.color_).toString();
|
||||
const color = this.color_;
|
||||
if (color) {
|
||||
if (Array.isArray(color) || typeof color == 'string') {
|
||||
this.checksum_ = 'f' + asString(/** @type {import("../Color.js").Color|string} */ (color));
|
||||
} else {
|
||||
this.checksum_ = getUid(this.color_).toString();
|
||||
}
|
||||
} else {
|
||||
this.checksum_ = 'f' + (this.color_ ? asString(this.color_) : '-');
|
||||
this.checksum_ = 'f-';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class Icon extends ImageStyle {
|
||||
5); // `imgSize` must be set when `image` is provided
|
||||
|
||||
if ((src === undefined || src.length === 0) && image) {
|
||||
src = image instanceof HTMLImageElement && image.src || getUid(image).toString();
|
||||
src = /** @type {HTMLImageElement} */ (image).src || getUid(image).toString();
|
||||
}
|
||||
assert(src !== undefined && src.length > 0,
|
||||
6); // A defined and non-empty `src` or `image` must be provided
|
||||
|
||||
@@ -34,8 +34,8 @@ class IconImage extends EventTarget {
|
||||
*/
|
||||
this.image_ = !image ? new Image() : image;
|
||||
|
||||
if (crossOrigin !== null && this.image_ instanceof HTMLImageElement) {
|
||||
this.image_.crossOrigin = crossOrigin;
|
||||
if (crossOrigin !== null) {
|
||||
/** @type {HTMLImageElement} */ (this.image_).crossOrigin = crossOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
* ```
|
||||
*/
|
||||
import {assert} from '../asserts.js';
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import CircleStyle from '../style/Circle.js';
|
||||
import Fill from '../style/Fill.js';
|
||||
@@ -103,6 +102,10 @@ import Stroke from '../style/Stroke.js';
|
||||
* @typedef {function(import("../Feature.js").FeatureLike, number):(Style|Array<Style>)} StyleFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* A {@link Style}, an array of {@link Style}, or a {@link StyleFunction}.
|
||||
* @typedef {Style|Array<Style>|StyleFunction} StyleLike
|
||||
*/
|
||||
|
||||
/**
|
||||
* A function that takes an {@link module:ol/Feature} as argument and returns an
|
||||
@@ -137,7 +140,6 @@ import Stroke from '../style/Stroke.js';
|
||||
* @property {number} [zIndex] Z index.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Container for vector feature rendering styles. Any changes made to the style
|
||||
@@ -214,8 +216,8 @@ class Style {
|
||||
*/
|
||||
clone() {
|
||||
let geometry = this.getGeometry();
|
||||
if (geometry instanceof Geometry) {
|
||||
geometry = geometry.clone();
|
||||
if (geometry && typeof geometry === 'object') {
|
||||
geometry = /** @type {import("../geom/Geometry.js").default} */ (geometry).clone();
|
||||
}
|
||||
return new Style({
|
||||
geometry: geometry,
|
||||
@@ -411,9 +413,10 @@ export function toFunction(obj) {
|
||||
if (Array.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
assert(obj instanceof Style,
|
||||
assert(typeof /** @type {?} */ (obj).getZIndex === 'function',
|
||||
41); // Expected an `Style` or an array of `Style`
|
||||
styles = [obj];
|
||||
const style = /** @type {Style} */ (obj);
|
||||
styles = [style];
|
||||
}
|
||||
styleFunction = function() {
|
||||
return styles;
|
||||
|
||||
@@ -89,20 +89,11 @@ export function getAllTextContent_(node, normalizeWhitespace, accumulator) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {?} value Value.
|
||||
* @return {boolean} Is document.
|
||||
* @param {Object} object Object.
|
||||
* @return {boolean} Is a document.
|
||||
*/
|
||||
export function isDocument(value) {
|
||||
return value instanceof Document;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {?} value Value.
|
||||
* @return {boolean} Is node.
|
||||
*/
|
||||
export function isNode(value) {
|
||||
return value instanceof Node;
|
||||
export function isDocument(object) {
|
||||
return 'documentElement' in object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user