@@ -76,10 +76,10 @@ export class CollectionEvent extends Event {
|
||||
*/
|
||||
class Collection extends BaseObject {
|
||||
/**
|
||||
* @param {Array<T>} [opt_array] Array.
|
||||
* @param {Options} [opt_options] Collection options.
|
||||
* @param {Array<T>} [array] Array.
|
||||
* @param {Options} [options] Collection options.
|
||||
*/
|
||||
constructor(opt_array, opt_options) {
|
||||
constructor(array, options) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -97,7 +97,7 @@ class Collection extends BaseObject {
|
||||
*/
|
||||
this.un;
|
||||
|
||||
const options = opt_options || {};
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -109,7 +109,7 @@ class Collection extends BaseObject {
|
||||
* @private
|
||||
* @type {!Array<T>}
|
||||
*/
|
||||
this.array_ = opt_array ? opt_array : [];
|
||||
this.array_ = array ? array : [];
|
||||
|
||||
if (this.unique_) {
|
||||
for (let i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
@@ -315,11 +315,11 @@ class Collection extends BaseObject {
|
||||
/**
|
||||
* @private
|
||||
* @param {T} elem Element.
|
||||
* @param {number} [opt_except] Optional index to ignore.
|
||||
* @param {number} [except] Optional index to ignore.
|
||||
*/
|
||||
assertUnique_(elem, opt_except) {
|
||||
assertUnique_(elem, except) {
|
||||
for (let i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
if (this.array_[i] === elem && i !== opt_except) {
|
||||
if (this.array_[i] === elem && i !== except) {
|
||||
throw new AssertionError(58);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ import {listen, unlistenByKey} from './events.js';
|
||||
*/
|
||||
class Feature extends BaseObject {
|
||||
/**
|
||||
* @param {Geometry|ObjectWithGeometry<Geometry>} [opt_geometryOrProperties]
|
||||
* @param {Geometry|ObjectWithGeometry<Geometry>} [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.
|
||||
*/
|
||||
constructor(opt_geometryOrProperties) {
|
||||
constructor(geometryOrProperties) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -130,17 +130,17 @@ class Feature extends BaseObject {
|
||||
|
||||
this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);
|
||||
|
||||
if (opt_geometryOrProperties) {
|
||||
if (geometryOrProperties) {
|
||||
if (
|
||||
typeof (
|
||||
/** @type {?} */ (opt_geometryOrProperties).getSimplifiedGeometry
|
||||
/** @type {?} */ (geometryOrProperties).getSimplifiedGeometry
|
||||
) === 'function'
|
||||
) {
|
||||
const geometry = /** @type {Geometry} */ (opt_geometryOrProperties);
|
||||
const geometry = /** @type {Geometry} */ (geometryOrProperties);
|
||||
this.setGeometry(geometry);
|
||||
} else {
|
||||
/** @type {Object<string, *>} */
|
||||
const properties = opt_geometryOrProperties;
|
||||
const properties = geometryOrProperties;
|
||||
this.setProperties(properties);
|
||||
}
|
||||
}
|
||||
@@ -265,15 +265,13 @@ class Feature extends BaseObject {
|
||||
* single style object, an array of styles, or a function that takes a
|
||||
* resolution and returns an array of styles. To unset the feature style, call
|
||||
* `setStyle()` without arguments or a falsey value.
|
||||
* @param {import("./style/Style.js").StyleLike} [opt_style] Style for this feature.
|
||||
* @param {import("./style/Style.js").StyleLike} [style] Style for this feature.
|
||||
* @api
|
||||
* @fires module:ol/events/Event~BaseEvent#event:change
|
||||
*/
|
||||
setStyle(opt_style) {
|
||||
this.style_ = opt_style;
|
||||
this.styleFunction_ = !opt_style
|
||||
? undefined
|
||||
: createStyleFunction(opt_style);
|
||||
setStyle(style) {
|
||||
this.style_ = style;
|
||||
this.styleFunction_ = !style ? undefined : createStyleFunction(style);
|
||||
this.changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ class GeolocationError extends BaseEvent {
|
||||
*/
|
||||
class Geolocation extends BaseObject {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -121,7 +121,7 @@ class Geolocation extends BaseObject {
|
||||
*/
|
||||
this.un;
|
||||
|
||||
const options = opt_options || {};
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* The unprojected (EPSG:4326) device position.
|
||||
|
||||
@@ -19,12 +19,11 @@ class ImageCanvas extends ImageBase {
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {HTMLCanvasElement} canvas Canvas.
|
||||
* @param {Loader} [opt_loader] Optional loader function to
|
||||
* @param {Loader} [loader] Optional loader function to
|
||||
* support asynchronous canvas drawing.
|
||||
*/
|
||||
constructor(extent, resolution, pixelRatio, canvas, opt_loader) {
|
||||
const state =
|
||||
opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
constructor(extent, resolution, pixelRatio, canvas, loader) {
|
||||
const state = loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
|
||||
super(extent, resolution, pixelRatio, state);
|
||||
|
||||
@@ -33,7 +32,7 @@ class ImageCanvas extends ImageBase {
|
||||
* @type {?Loader}
|
||||
* @private
|
||||
*/
|
||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||
this.loader_ = loader !== undefined ? loader : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -13,17 +13,10 @@ class ImageTile extends Tile {
|
||||
* @param {string} src Image source URI.
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
* @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
|
||||
* @param {import("./Tile.js").Options} [opt_options] Tile options.
|
||||
* @param {import("./Tile.js").Options} [options] Tile options.
|
||||
*/
|
||||
constructor(
|
||||
tileCoord,
|
||||
state,
|
||||
src,
|
||||
crossOrigin,
|
||||
tileLoadFunction,
|
||||
opt_options
|
||||
) {
|
||||
super(tileCoord, state, opt_options);
|
||||
constructor(tileCoord, state, src, crossOrigin, tileLoadFunction, options) {
|
||||
super(tileCoord, state, options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -234,12 +234,12 @@ function setLayerMapProperty(layer, map) {
|
||||
*/
|
||||
class Map extends BaseObject {
|
||||
/**
|
||||
* @param {MapOptions} [opt_options] Map options.
|
||||
* @param {MapOptions} [options] Map options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options || {};
|
||||
options = options || {};
|
||||
|
||||
/***
|
||||
* @type {MapEventHandler<import("./events").EventsKey>}
|
||||
@@ -652,7 +652,7 @@ class Map extends BaseObject {
|
||||
/**
|
||||
* Detect features that intersect a pixel on the viewport, and execute a
|
||||
* callback with each intersecting feature. Layers included in the detection can
|
||||
* be configured through the `layerFilter` option in `opt_options`.
|
||||
* be configured through the `layerFilter` option in `options`.
|
||||
* @param {import("./pixel.js").Pixel} pixel Pixel.
|
||||
* @param {function(import("./Feature.js").FeatureLike, import("./layer/Layer.js").default<import("./source/Source").default>, import("./geom/SimpleGeometry.js").default): T} callback Feature callback. The callback will be
|
||||
* called with two arguments. The first argument is one
|
||||
@@ -661,23 +661,23 @@ class Map extends BaseObject {
|
||||
* the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for
|
||||
* unmanaged layers. To stop detection, callback functions can return a
|
||||
* truthy value.
|
||||
* @param {AtPixelOptions} [opt_options] Optional options.
|
||||
* @param {AtPixelOptions} [options] Optional options.
|
||||
* @return {T|undefined} Callback result, i.e. the return value of last
|
||||
* callback execution, or the first truthy callback return value.
|
||||
* @template T
|
||||
* @api
|
||||
*/
|
||||
forEachFeatureAtPixel(pixel, callback, opt_options) {
|
||||
forEachFeatureAtPixel(pixel, callback, options) {
|
||||
if (!this.frameState_ || !this.renderer_) {
|
||||
return;
|
||||
}
|
||||
const coordinate = this.getCoordinateFromPixelInternal(pixel);
|
||||
opt_options = opt_options !== undefined ? opt_options : {};
|
||||
options = options !== undefined ? options : {};
|
||||
const hitTolerance =
|
||||
opt_options.hitTolerance !== undefined ? opt_options.hitTolerance : 0;
|
||||
options.hitTolerance !== undefined ? options.hitTolerance : 0;
|
||||
const layerFilter =
|
||||
opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
|
||||
const checkWrapped = opt_options.checkWrapped !== false;
|
||||
options.layerFilter !== undefined ? options.layerFilter : TRUE;
|
||||
const checkWrapped = options.checkWrapped !== false;
|
||||
return this.renderer_.forEachFeatureAtCoordinate(
|
||||
coordinate,
|
||||
this.frameState_,
|
||||
@@ -693,19 +693,19 @@ class Map extends BaseObject {
|
||||
/**
|
||||
* Get all features that intersect a pixel on the viewport.
|
||||
* @param {import("./pixel.js").Pixel} pixel Pixel.
|
||||
* @param {AtPixelOptions} [opt_options] Optional options.
|
||||
* @param {AtPixelOptions} [options] Optional options.
|
||||
* @return {Array<import("./Feature.js").FeatureLike>} The detected features or
|
||||
* an empty array if none were found.
|
||||
* @api
|
||||
*/
|
||||
getFeaturesAtPixel(pixel, opt_options) {
|
||||
getFeaturesAtPixel(pixel, options) {
|
||||
const features = [];
|
||||
this.forEachFeatureAtPixel(
|
||||
pixel,
|
||||
function (feature) {
|
||||
features.push(feature);
|
||||
},
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
return features;
|
||||
}
|
||||
@@ -732,23 +732,23 @@ class Map extends BaseObject {
|
||||
|
||||
/**
|
||||
* Detect if features intersect a pixel on the viewport. Layers included in the
|
||||
* detection can be configured through `opt_layerFilter`.
|
||||
* detection can be configured through the `layerFilter` option.
|
||||
* @param {import("./pixel.js").Pixel} pixel Pixel.
|
||||
* @param {AtPixelOptions} [opt_options] Optional options.
|
||||
* @param {AtPixelOptions} [options] Optional options.
|
||||
* @return {boolean} Is there a feature at the given pixel?
|
||||
* @api
|
||||
*/
|
||||
hasFeatureAtPixel(pixel, opt_options) {
|
||||
hasFeatureAtPixel(pixel, options) {
|
||||
if (!this.frameState_ || !this.renderer_) {
|
||||
return false;
|
||||
}
|
||||
const coordinate = this.getCoordinateFromPixelInternal(pixel);
|
||||
opt_options = opt_options !== undefined ? opt_options : {};
|
||||
options = options !== undefined ? options : {};
|
||||
const layerFilter =
|
||||
opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
|
||||
options.layerFilter !== undefined ? options.layerFilter : TRUE;
|
||||
const hitTolerance =
|
||||
opt_options.hitTolerance !== undefined ? opt_options.hitTolerance : 0;
|
||||
const checkWrapped = opt_options.checkWrapped !== false;
|
||||
options.hitTolerance !== undefined ? options.hitTolerance : 0;
|
||||
const checkWrapped = options.checkWrapped !== false;
|
||||
return this.renderer_.hasFeatureAtCoordinate(
|
||||
coordinate,
|
||||
this.frameState_,
|
||||
@@ -1089,10 +1089,10 @@ class Map extends BaseObject {
|
||||
|
||||
/**
|
||||
* @param {UIEvent} browserEvent Browser event.
|
||||
* @param {string} [opt_type] Type.
|
||||
* @param {string} [type] Type.
|
||||
*/
|
||||
handleBrowserEvent(browserEvent, opt_type) {
|
||||
const type = opt_type || browserEvent.type;
|
||||
handleBrowserEvent(browserEvent, type) {
|
||||
type = type || browserEvent.type;
|
||||
const mapBrowserEvent = new MapBrowserEvent(type, this, browserEvent);
|
||||
this.handleMapBrowserEvent(mapBrowserEvent);
|
||||
}
|
||||
|
||||
@@ -14,19 +14,12 @@ class MapBrowserEvent extends MapEvent {
|
||||
* @param {string} type Event type.
|
||||
* @param {import("./Map.js").default} map Map.
|
||||
* @param {EVENT} originalEvent Original event.
|
||||
* @param {boolean} [opt_dragging] Is the map currently being dragged?
|
||||
* @param {import("./Map.js").FrameState} [opt_frameState] Frame state.
|
||||
* @param {Array<PointerEvent>} [opt_activePointers] Active pointers.
|
||||
* @param {boolean} [dragging] Is the map currently being dragged?
|
||||
* @param {import("./Map.js").FrameState} [frameState] Frame state.
|
||||
* @param {Array<PointerEvent>} [activePointers] Active pointers.
|
||||
*/
|
||||
constructor(
|
||||
type,
|
||||
map,
|
||||
originalEvent,
|
||||
opt_dragging,
|
||||
opt_frameState,
|
||||
opt_activePointers
|
||||
) {
|
||||
super(type, map, opt_frameState);
|
||||
constructor(type, map, originalEvent, dragging, frameState, activePointers) {
|
||||
super(type, map, frameState);
|
||||
|
||||
/**
|
||||
* The original browser event.
|
||||
@@ -55,12 +48,12 @@ class MapBrowserEvent extends MapEvent {
|
||||
* @type {boolean}
|
||||
* @api
|
||||
*/
|
||||
this.dragging = opt_dragging !== undefined ? opt_dragging : false;
|
||||
this.dragging = dragging !== undefined ? dragging : false;
|
||||
|
||||
/**
|
||||
* @type {Array<PointerEvent>|undefined}
|
||||
*/
|
||||
this.activePointers = opt_activePointers;
|
||||
this.activePointers = activePointers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,9 +12,9 @@ class MapEvent extends Event {
|
||||
/**
|
||||
* @param {string} type Event type.
|
||||
* @param {import("./Map.js").default} map Map.
|
||||
* @param {?import("./Map.js").FrameState} [opt_frameState] Frame state.
|
||||
* @param {?import("./Map.js").FrameState} [frameState] Frame state.
|
||||
*/
|
||||
constructor(type, map, opt_frameState) {
|
||||
constructor(type, map, frameState) {
|
||||
super(type);
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ class MapEvent extends Event {
|
||||
* @type {?import("./Map.js").FrameState}
|
||||
* @api
|
||||
*/
|
||||
this.frameState = opt_frameState !== undefined ? opt_frameState : null;
|
||||
this.frameState = frameState !== undefined ? frameState : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ export class ObjectEvent extends Event {
|
||||
*/
|
||||
class BaseObject extends Observable {
|
||||
/**
|
||||
* @param {Object<string, *>} [opt_values] An object with key-value pairs.
|
||||
* @param {Object<string, *>} [values] An object with key-value pairs.
|
||||
*/
|
||||
constructor(opt_values) {
|
||||
constructor(values) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -121,8 +121,8 @@ class BaseObject extends Observable {
|
||||
*/
|
||||
this.values_ = null;
|
||||
|
||||
if (opt_values !== undefined) {
|
||||
this.setProperties(opt_values);
|
||||
if (values !== undefined) {
|
||||
this.setProperties(values);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,12 +201,12 @@ class BaseObject extends Observable {
|
||||
* Sets a value.
|
||||
* @param {string} key Key name.
|
||||
* @param {*} value Value.
|
||||
* @param {boolean} [opt_silent] Update without triggering an event.
|
||||
* @param {boolean} [silent] Update without triggering an event.
|
||||
* @api
|
||||
*/
|
||||
set(key, value, opt_silent) {
|
||||
set(key, value, silent) {
|
||||
const values = this.values_ || (this.values_ = {});
|
||||
if (opt_silent) {
|
||||
if (silent) {
|
||||
values[key] = value;
|
||||
} else {
|
||||
const oldValue = values[key];
|
||||
@@ -221,12 +221,12 @@ class BaseObject extends Observable {
|
||||
* Sets a collection of key-value pairs. Note that this changes any existing
|
||||
* properties and adds new ones (it does not remove any existing properties).
|
||||
* @param {Object<string, *>} values Values.
|
||||
* @param {boolean} [opt_silent] Update without triggering an event.
|
||||
* @param {boolean} [silent] Update without triggering an event.
|
||||
* @api
|
||||
*/
|
||||
setProperties(values, opt_silent) {
|
||||
setProperties(values, silent) {
|
||||
for (const key in values) {
|
||||
this.set(key, values[key], opt_silent);
|
||||
this.set(key, values[key], silent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,17 +245,17 @@ class BaseObject extends Observable {
|
||||
/**
|
||||
* Unsets a property.
|
||||
* @param {string} key Key name.
|
||||
* @param {boolean} [opt_silent] Unset without triggering an event.
|
||||
* @param {boolean} [silent] Unset without triggering an event.
|
||||
* @api
|
||||
*/
|
||||
unset(key, opt_silent) {
|
||||
unset(key, silent) {
|
||||
if (this.values_ && key in this.values_) {
|
||||
const oldValue = this.values_[key];
|
||||
delete this.values_[key];
|
||||
if (isEmpty(this.values_)) {
|
||||
this.values_ = null;
|
||||
}
|
||||
if (!opt_silent) {
|
||||
if (!silent) {
|
||||
this.notify(key, oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,10 +402,10 @@ class Overlay extends BaseObject {
|
||||
/**
|
||||
* Pan the map so that the overlay is entirely visible in the current viewport
|
||||
* (if necessary).
|
||||
* @param {PanIntoViewOptions} [opt_panIntoViewOptions] Options for the pan action
|
||||
* @param {PanIntoViewOptions} [panIntoViewOptions] Options for the pan action
|
||||
* @api
|
||||
*/
|
||||
panIntoView(opt_panIntoViewOptions) {
|
||||
panIntoView(panIntoViewOptions) {
|
||||
const map = this.getMap();
|
||||
|
||||
if (!map || !map.getTargetElement() || !this.get(Property.POSITION)) {
|
||||
@@ -419,7 +419,7 @@ class Overlay extends BaseObject {
|
||||
outerHeight(element),
|
||||
]);
|
||||
|
||||
const panIntoViewOptions = opt_panIntoViewOptions || {};
|
||||
panIntoViewOptions = panIntoViewOptions || {};
|
||||
|
||||
const myMargin =
|
||||
panIntoViewOptions.margin === undefined ? 20 : panIntoViewOptions.margin;
|
||||
|
||||
@@ -78,12 +78,12 @@ class Tile extends EventTarget {
|
||||
/**
|
||||
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
||||
* @param {import("./TileState.js").default} state State.
|
||||
* @param {Options} [opt_options] Tile options.
|
||||
* @param {Options} [options] Tile options.
|
||||
*/
|
||||
constructor(tileCoord, state, opt_options) {
|
||||
constructor(tileCoord, state, options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @type {import("./tilecoord.js").TileCoord}
|
||||
|
||||
@@ -11,10 +11,10 @@ class VectorTile extends Tile {
|
||||
* @param {string} src Data source url.
|
||||
* @param {import("./format/Feature.js").default} format Feature format.
|
||||
* @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
|
||||
* @param {import("./Tile.js").Options} [opt_options] Tile options.
|
||||
* @param {import("./Tile.js").Options} [options] Tile options.
|
||||
*/
|
||||
constructor(tileCoord, state, src, format, tileLoadFunction, opt_options) {
|
||||
super(tileCoord, state, opt_options);
|
||||
constructor(tileCoord, state, src, format, tileLoadFunction, options) {
|
||||
super(tileCoord, state, options);
|
||||
|
||||
/**
|
||||
* Extent of this tile; set by the source.
|
||||
|
||||
199
src/ol/View.js
199
src/ol/View.js
@@ -288,7 +288,7 @@ const DEFAULT_MIN_ZOOM = 0;
|
||||
* A consequence of this is that, when applying a delta on the view state, one
|
||||
* should use `adjustCenter`, `adjustRotation`, `adjustZoom` and `adjustResolution`
|
||||
* rather than the corresponding setters. This will let view do its internal
|
||||
* computations. Besides, the `adjust*` methods also take an `opt_anchor`
|
||||
* computations. Besides, the `adjust*` methods also take an `anchor`
|
||||
* argument which allows specifying an origin for the transformation.
|
||||
*
|
||||
* ### Interacting with the view
|
||||
@@ -303,9 +303,9 @@ const DEFAULT_MIN_ZOOM = 0;
|
||||
*/
|
||||
class View extends BaseObject {
|
||||
/**
|
||||
* @param {ViewOptions} [opt_options] View options.
|
||||
* @param {ViewOptions} [options] View options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -323,7 +323,7 @@ class View extends BaseObject {
|
||||
*/
|
||||
this.un;
|
||||
|
||||
const options = Object.assign({}, opt_options);
|
||||
options = Object.assign({}, options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -896,19 +896,17 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Returns the current viewport size.
|
||||
* @private
|
||||
* @param {number} [opt_rotation] Take into account the rotation of the viewport when giving the size
|
||||
* @param {number} [rotation] Take into account the rotation of the viewport when giving the size
|
||||
* @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
|
||||
*/
|
||||
getViewportSize_(opt_rotation) {
|
||||
getViewportSize_(rotation) {
|
||||
const size = this.viewportSize_;
|
||||
if (opt_rotation) {
|
||||
if (rotation) {
|
||||
const w = size[0];
|
||||
const h = size[1];
|
||||
return [
|
||||
Math.abs(w * Math.cos(opt_rotation)) +
|
||||
Math.abs(h * Math.sin(opt_rotation)),
|
||||
Math.abs(w * Math.sin(opt_rotation)) +
|
||||
Math.abs(h * Math.cos(opt_rotation)),
|
||||
Math.abs(w * Math.cos(rotation)) + Math.abs(h * Math.sin(rotation)),
|
||||
Math.abs(w * Math.sin(rotation)) + Math.abs(h * Math.cos(rotation)),
|
||||
];
|
||||
} else {
|
||||
return size;
|
||||
@@ -920,12 +918,10 @@ class View extends BaseObject {
|
||||
* to avoid performance hit and layout reflow.
|
||||
* This should be done on map size change.
|
||||
* Note: the constraints are not resolved during an animation to avoid stopping it
|
||||
* @param {import("./size.js").Size} [opt_size] Viewport size; if undefined, [100, 100] is assumed
|
||||
* @param {import("./size.js").Size} [size] Viewport size; if undefined, [100, 100] is assumed
|
||||
*/
|
||||
setViewportSize(opt_size) {
|
||||
this.viewportSize_ = Array.isArray(opt_size)
|
||||
? opt_size.slice()
|
||||
: [100, 100];
|
||||
setViewportSize(size) {
|
||||
this.viewportSize_ = Array.isArray(size) ? size.slice() : [100, 100];
|
||||
if (!this.getAnimating()) {
|
||||
this.resolveConstraints(0);
|
||||
}
|
||||
@@ -970,14 +966,14 @@ class View extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<number>} [opt_hints] Destination array.
|
||||
* @param {Array<number>} [hints] Destination array.
|
||||
* @return {Array<number>} Hint.
|
||||
*/
|
||||
getHints(opt_hints) {
|
||||
if (opt_hints !== undefined) {
|
||||
opt_hints[0] = this.hints_[0];
|
||||
opt_hints[1] = this.hints_[1];
|
||||
return opt_hints;
|
||||
getHints(hints) {
|
||||
if (hints !== undefined) {
|
||||
hints[0] = this.hints_[0];
|
||||
hints[1] = this.hints_[1];
|
||||
return hints;
|
||||
} else {
|
||||
return this.hints_.slice();
|
||||
}
|
||||
@@ -988,23 +984,23 @@ class View extends BaseObject {
|
||||
* The size is the pixel dimensions of the box into which the calculated extent
|
||||
* should fit. In most cases you want to get the extent of the entire map,
|
||||
* that is `map.getSize()`.
|
||||
* @param {import("./size.js").Size} [opt_size] Box pixel size. If not provided, the size
|
||||
* @param {import("./size.js").Size} [size] Box pixel size. If not provided, the size
|
||||
* of the map that uses this view will be used.
|
||||
* @return {import("./extent.js").Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
calculateExtent(opt_size) {
|
||||
const extent = this.calculateExtentInternal(opt_size);
|
||||
calculateExtent(size) {
|
||||
const extent = this.calculateExtentInternal(size);
|
||||
return toUserExtent(extent, this.getProjection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("./size.js").Size} [opt_size] Box pixel size. If not provided,
|
||||
* @param {import("./size.js").Size} [size] Box pixel size. If not provided,
|
||||
* the map's last known viewport size will be used.
|
||||
* @return {import("./extent.js").Extent} Extent.
|
||||
*/
|
||||
calculateExtentInternal(opt_size) {
|
||||
const size = opt_size || this.getViewportSizeMinusPadding_();
|
||||
calculateExtentInternal(size) {
|
||||
size = size || this.getViewportSizeMinusPadding_();
|
||||
const center = /** @type {!import("./coordinate.js").Coordinate} */ (
|
||||
this.getCenterInternal()
|
||||
);
|
||||
@@ -1116,27 +1112,27 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Get the resolution for a provided extent (in map units) and size (in pixels).
|
||||
* @param {import("./extent.js").Extent} extent Extent.
|
||||
* @param {import("./size.js").Size} [opt_size] Box pixel size.
|
||||
* @param {import("./size.js").Size} [size] Box pixel size.
|
||||
* @return {number} The resolution at which the provided extent will render at
|
||||
* the given size.
|
||||
* @api
|
||||
*/
|
||||
getResolutionForExtent(extent, opt_size) {
|
||||
getResolutionForExtent(extent, size) {
|
||||
return this.getResolutionForExtentInternal(
|
||||
fromUserExtent(extent, this.getProjection()),
|
||||
opt_size
|
||||
size
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resolution for a provided extent (in map units) and size (in pixels).
|
||||
* @param {import("./extent.js").Extent} extent Extent.
|
||||
* @param {import("./size.js").Size} [opt_size] Box pixel size.
|
||||
* @param {import("./size.js").Size} [size] Box pixel size.
|
||||
* @return {number} The resolution at which the provided extent will render at
|
||||
* the given size.
|
||||
*/
|
||||
getResolutionForExtentInternal(extent, opt_size) {
|
||||
const size = opt_size || this.getViewportSizeMinusPadding_();
|
||||
getResolutionForExtentInternal(extent, size) {
|
||||
size = size || this.getViewportSizeMinusPadding_();
|
||||
const xResolution = getWidth(extent) / size[0];
|
||||
const yResolution = getHeight(extent) / size[1];
|
||||
return Math.max(xResolution, yResolution);
|
||||
@@ -1145,11 +1141,11 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Return a function that returns a value between 0 and 1 for a
|
||||
* resolution. Exponential scaling is assumed.
|
||||
* @param {number} [opt_power] Power.
|
||||
* @param {number} [power] Power.
|
||||
* @return {function(number): number} Resolution for value function.
|
||||
*/
|
||||
getResolutionForValueFunction(opt_power) {
|
||||
const power = opt_power || 2;
|
||||
getResolutionForValueFunction(power) {
|
||||
power = power || 2;
|
||||
const maxResolution = this.getConstrainedResolution(this.maxResolution_);
|
||||
const minResolution = this.minResolution_;
|
||||
const max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||
@@ -1178,11 +1174,11 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Return a function that returns a resolution for a value between
|
||||
* 0 and 1. Exponential scaling is assumed.
|
||||
* @param {number} [opt_power] Power.
|
||||
* @param {number} [power] Power.
|
||||
* @return {function(number): number} Value for resolution function.
|
||||
*/
|
||||
getValueForResolutionFunction(opt_power) {
|
||||
const logPower = Math.log(opt_power || 2);
|
||||
getValueForResolutionFunction(power) {
|
||||
const logPower = Math.log(power || 2);
|
||||
const maxResolution = this.getConstrainedResolution(this.maxResolution_);
|
||||
const minResolution = this.minResolution_;
|
||||
const max = Math.log(maxResolution / minResolution) / logPower;
|
||||
@@ -1201,11 +1197,11 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Returns the size of the viewport minus padding.
|
||||
* @private
|
||||
* @param {number} [opt_rotation] Take into account the rotation of the viewport when giving the size
|
||||
* @param {number} [rotation] Take into account the rotation of the viewport when giving the size
|
||||
* @return {import("./size.js").Size} Viewport size reduced by the padding.
|
||||
*/
|
||||
getViewportSizeMinusPadding_(opt_rotation) {
|
||||
let size = this.getViewportSize_(opt_rotation);
|
||||
getViewportSizeMinusPadding_(rotation) {
|
||||
let size = this.getViewportSize_(rotation);
|
||||
const padding = this.padding_;
|
||||
if (padding) {
|
||||
size = [
|
||||
@@ -1326,10 +1322,10 @@ class View extends BaseObject {
|
||||
* Takes care of the map angle.
|
||||
* @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.
|
||||
* @param {FitOptions} [options] Options.
|
||||
* @api
|
||||
*/
|
||||
fit(geometryOrExtent, opt_options) {
|
||||
fit(geometryOrExtent, options) {
|
||||
/** @type {import("./geom/SimpleGeometry.js").default} */
|
||||
let geometry;
|
||||
assert(
|
||||
@@ -1362,7 +1358,7 @@ class View extends BaseObject {
|
||||
}
|
||||
}
|
||||
|
||||
this.fitInternal(geometry, opt_options);
|
||||
this.fitInternal(geometry, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1393,10 +1389,10 @@ class View extends BaseObject {
|
||||
|
||||
/**
|
||||
* @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
|
||||
* @param {FitOptions} [opt_options] Options.
|
||||
* @param {FitOptions} [options] Options.
|
||||
*/
|
||||
fitInternal(geometry, opt_options) {
|
||||
const options = opt_options || {};
|
||||
fitInternal(geometry, options) {
|
||||
options = options || {};
|
||||
let size = options.size;
|
||||
if (!size) {
|
||||
size = this.getViewportSizeMinusPadding_();
|
||||
@@ -1551,12 +1547,11 @@ class View extends BaseObject {
|
||||
* Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
|
||||
* constraint will apply.
|
||||
* @param {number} ratio The ratio to apply on the view resolution.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
|
||||
* @api
|
||||
*/
|
||||
adjustResolution(ratio, opt_anchor) {
|
||||
const anchor =
|
||||
opt_anchor && fromUserCoordinate(opt_anchor, this.getProjection());
|
||||
adjustResolution(ratio, anchor) {
|
||||
anchor = anchor && fromUserCoordinate(anchor, this.getProjection());
|
||||
this.adjustResolutionInternal(ratio, anchor);
|
||||
}
|
||||
|
||||
@@ -1564,9 +1559,9 @@ class View extends BaseObject {
|
||||
* Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
|
||||
* constraint will apply.
|
||||
* @param {number} ratio The ratio to apply on the view resolution.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
|
||||
*/
|
||||
adjustResolutionInternal(ratio, opt_anchor) {
|
||||
adjustResolutionInternal(ratio, anchor) {
|
||||
const isMoving = this.getAnimating() || this.getInteracting();
|
||||
const size = this.getViewportSize_(this.getRotation());
|
||||
const newResolution = this.constraints_.resolution(
|
||||
@@ -1576,8 +1571,8 @@ class View extends BaseObject {
|
||||
isMoving
|
||||
);
|
||||
|
||||
if (opt_anchor) {
|
||||
this.targetCenter_ = this.calculateCenterZoom(newResolution, opt_anchor);
|
||||
if (anchor) {
|
||||
this.targetCenter_ = this.calculateCenterZoom(newResolution, anchor);
|
||||
}
|
||||
|
||||
this.targetResolution_ *= ratio;
|
||||
@@ -1588,39 +1583,39 @@ class View extends BaseObject {
|
||||
* Adds a value to the view zoom level, optionally using an anchor. Any resolution
|
||||
* constraint will apply.
|
||||
* @param {number} delta Relative value to add to the zoom level.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
|
||||
* @api
|
||||
*/
|
||||
adjustZoom(delta, opt_anchor) {
|
||||
this.adjustResolution(Math.pow(this.zoomFactor_, -delta), opt_anchor);
|
||||
adjustZoom(delta, anchor) {
|
||||
this.adjustResolution(Math.pow(this.zoomFactor_, -delta), anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value to the view rotation, optionally using an anchor. Any rotation
|
||||
* constraint will apply.
|
||||
* @param {number} delta Relative value to add to the zoom rotation, in radians.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The rotation center.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
|
||||
* @api
|
||||
*/
|
||||
adjustRotation(delta, opt_anchor) {
|
||||
if (opt_anchor) {
|
||||
opt_anchor = fromUserCoordinate(opt_anchor, this.getProjection());
|
||||
adjustRotation(delta, anchor) {
|
||||
if (anchor) {
|
||||
anchor = fromUserCoordinate(anchor, this.getProjection());
|
||||
}
|
||||
this.adjustRotationInternal(delta, opt_anchor);
|
||||
this.adjustRotationInternal(delta, anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} delta Relative value to add to the zoom rotation, in radians.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The rotation center.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
|
||||
*/
|
||||
adjustRotationInternal(delta, opt_anchor) {
|
||||
adjustRotationInternal(delta, anchor) {
|
||||
const isMoving = this.getAnimating() || this.getInteracting();
|
||||
const newRotation = this.constraints_.rotation(
|
||||
this.targetRotation_ + delta,
|
||||
isMoving
|
||||
);
|
||||
if (opt_anchor) {
|
||||
this.targetCenter_ = this.calculateCenterRotate(newRotation, opt_anchor);
|
||||
if (anchor) {
|
||||
this.targetCenter_ = this.calculateCenterRotate(newRotation, anchor);
|
||||
}
|
||||
this.targetRotation_ += delta;
|
||||
this.applyTargetState_();
|
||||
@@ -1693,13 +1688,13 @@ class View extends BaseObject {
|
||||
* Recompute rotation/resolution/center based on target values.
|
||||
* Note: we have to compute rotation first, then resolution and center considering that
|
||||
* parameters can influence one another in case a view extent constraint is present.
|
||||
* @param {boolean} [opt_doNotCancelAnims] Do not cancel animations.
|
||||
* @param {boolean} [opt_forceMoving] Apply constraints as if the view is moving.
|
||||
* @param {boolean} [doNotCancelAnims] Do not cancel animations.
|
||||
* @param {boolean} [forceMoving] Apply constraints as if the view is moving.
|
||||
* @private
|
||||
*/
|
||||
applyTargetState_(opt_doNotCancelAnims, opt_forceMoving) {
|
||||
applyTargetState_(doNotCancelAnims, forceMoving) {
|
||||
const isMoving =
|
||||
this.getAnimating() || this.getInteracting() || opt_forceMoving;
|
||||
this.getAnimating() || this.getInteracting() || forceMoving;
|
||||
|
||||
// compute rotation
|
||||
const newRotation = this.constraints_.rotation(
|
||||
@@ -1741,7 +1736,7 @@ class View extends BaseObject {
|
||||
this.set(ViewProperty.CENTER, newCenter);
|
||||
}
|
||||
|
||||
if (this.getAnimating() && !opt_doNotCancelAnims) {
|
||||
if (this.getAnimating() && !doNotCancelAnims) {
|
||||
this.cancelAnimations();
|
||||
}
|
||||
this.cancelAnchor_ = undefined;
|
||||
@@ -1752,13 +1747,13 @@ class View extends BaseObject {
|
||||
* This is typically done on interaction end.
|
||||
* Note: calling this with a duration of 0 will apply the constrained values straight away,
|
||||
* without animation.
|
||||
* @param {number} [opt_duration] The animation duration in ms.
|
||||
* @param {number} [opt_resolutionDirection] Which direction to zoom.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
|
||||
* @param {number} [duration] The animation duration in ms.
|
||||
* @param {number} [resolutionDirection] Which direction to zoom.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
|
||||
*/
|
||||
resolveConstraints(opt_duration, opt_resolutionDirection, opt_anchor) {
|
||||
const duration = opt_duration !== undefined ? opt_duration : 200;
|
||||
const direction = opt_resolutionDirection || 0;
|
||||
resolveConstraints(duration, resolutionDirection, anchor) {
|
||||
duration = duration !== undefined ? duration : 200;
|
||||
const direction = resolutionDirection || 0;
|
||||
|
||||
const newRotation = this.constraints_.rotation(this.targetRotation_);
|
||||
const size = this.getViewportSize_(newRotation);
|
||||
@@ -1788,8 +1783,7 @@ class View extends BaseObject {
|
||||
return;
|
||||
}
|
||||
|
||||
const anchor =
|
||||
opt_anchor || (duration === 0 ? this.cancelAnchor_ : undefined);
|
||||
anchor = anchor || (duration === 0 ? this.cancelAnchor_ : undefined);
|
||||
this.cancelAnchor_ = undefined;
|
||||
|
||||
if (
|
||||
@@ -1828,42 +1822,41 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Notify the View that an interaction has ended. The view state will be resolved
|
||||
* to a stable one if needed (depending on its constraints).
|
||||
* @param {number} [opt_duration] Animation duration in ms.
|
||||
* @param {number} [opt_resolutionDirection] Which direction to zoom.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
|
||||
* @param {number} [duration] Animation duration in ms.
|
||||
* @param {number} [resolutionDirection] Which direction to zoom.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
|
||||
* @api
|
||||
*/
|
||||
endInteraction(opt_duration, opt_resolutionDirection, opt_anchor) {
|
||||
const anchor =
|
||||
opt_anchor && fromUserCoordinate(opt_anchor, this.getProjection());
|
||||
this.endInteractionInternal(opt_duration, opt_resolutionDirection, anchor);
|
||||
endInteraction(duration, resolutionDirection, anchor) {
|
||||
anchor = anchor && fromUserCoordinate(anchor, this.getProjection());
|
||||
this.endInteractionInternal(duration, resolutionDirection, anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the View that an interaction has ended. The view state will be resolved
|
||||
* to a stable one if needed (depending on its constraints).
|
||||
* @param {number} [opt_duration] Animation duration in ms.
|
||||
* @param {number} [opt_resolutionDirection] Which direction to zoom.
|
||||
* @param {import("./coordinate.js").Coordinate} [opt_anchor] The origin of the transformation.
|
||||
* @param {number} [duration] Animation duration in ms.
|
||||
* @param {number} [resolutionDirection] Which direction to zoom.
|
||||
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
|
||||
*/
|
||||
endInteractionInternal(opt_duration, opt_resolutionDirection, opt_anchor) {
|
||||
endInteractionInternal(duration, resolutionDirection, anchor) {
|
||||
this.setHint(ViewHint.INTERACTING, -1);
|
||||
|
||||
this.resolveConstraints(opt_duration, opt_resolutionDirection, opt_anchor);
|
||||
this.resolveConstraints(duration, resolutionDirection, anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a valid position for the view center according to the current constraints.
|
||||
* @param {import("./coordinate.js").Coordinate|undefined} targetCenter Target center position.
|
||||
* @param {number} [opt_targetResolution] Target resolution. If not supplied, the current one will be used.
|
||||
* @param {number} [targetResolution] Target resolution. If not supplied, the current one will be used.
|
||||
* This is useful to guess a valid center position at a different zoom level.
|
||||
* @return {import("./coordinate.js").Coordinate|undefined} Valid center position.
|
||||
*/
|
||||
getConstrainedCenter(targetCenter, opt_targetResolution) {
|
||||
getConstrainedCenter(targetCenter, targetResolution) {
|
||||
const size = this.getViewportSize_(this.getRotation());
|
||||
return this.constraints_.center(
|
||||
targetCenter,
|
||||
opt_targetResolution || this.getResolution(),
|
||||
targetResolution || this.getResolution(),
|
||||
size
|
||||
);
|
||||
}
|
||||
@@ -1871,30 +1864,30 @@ class View extends BaseObject {
|
||||
/**
|
||||
* Get a valid zoom level according to the current view constraints.
|
||||
* @param {number|undefined} targetZoom Target zoom.
|
||||
* @param {number} [opt_direction=0] Indicate which resolution should be used
|
||||
* @param {number} [direction=0] Indicate which resolution should be used
|
||||
* by a renderer if the view resolution does not match any resolution of the tile source.
|
||||
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
|
||||
* will be used. If -1, the nearest higher resolution will be used.
|
||||
* @return {number|undefined} Valid zoom level.
|
||||
*/
|
||||
getConstrainedZoom(targetZoom, opt_direction) {
|
||||
getConstrainedZoom(targetZoom, direction) {
|
||||
const targetRes = this.getResolutionForZoom(targetZoom);
|
||||
return this.getZoomForResolution(
|
||||
this.getConstrainedResolution(targetRes, opt_direction)
|
||||
this.getConstrainedResolution(targetRes, direction)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a valid resolution according to the current view constraints.
|
||||
* @param {number|undefined} targetResolution Target resolution.
|
||||
* @param {number} [opt_direction=0] Indicate which resolution should be used
|
||||
* @param {number} [direction=0] Indicate which resolution should be used
|
||||
* by a renderer if the view resolution does not match any resolution of the tile source.
|
||||
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
|
||||
* will be used. If -1, the nearest higher resolution will be used.
|
||||
* @return {number|undefined} Valid resolution.
|
||||
*/
|
||||
getConstrainedResolution(targetResolution, opt_direction) {
|
||||
const direction = opt_direction || 0;
|
||||
getConstrainedResolution(targetResolution, direction) {
|
||||
direction = direction || 0;
|
||||
const size = this.getViewportSize_(this.getRotation());
|
||||
|
||||
return this.constraints_.resolution(targetResolution, direction, size);
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
*
|
||||
* @param {Array<*>} haystack Items to search through.
|
||||
* @param {*} needle The item to look for.
|
||||
* @param {Function} [opt_comparator] Comparator function.
|
||||
* @param {Function} [comparator] Comparator function.
|
||||
* @return {number} The index of the item if found, -1 if not.
|
||||
*/
|
||||
export function binarySearch(haystack, needle, opt_comparator) {
|
||||
export function binarySearch(haystack, needle, comparator) {
|
||||
let mid, cmp;
|
||||
const comparator = opt_comparator || numberSafeCompareFunction;
|
||||
comparator = comparator || numberSafeCompareFunction;
|
||||
let low = 0;
|
||||
let high = haystack.length;
|
||||
let found = false;
|
||||
@@ -200,17 +200,17 @@ export function stableSort(arr, compareFnc) {
|
||||
|
||||
/**
|
||||
* @param {Array<*>} arr The array to test.
|
||||
* @param {Function} [opt_func] Comparison function.
|
||||
* @param {boolean} [opt_strict] Strictly sorted (default false).
|
||||
* @param {Function} [func] Comparison function.
|
||||
* @param {boolean} [strict] Strictly sorted (default false).
|
||||
* @return {boolean} Return index.
|
||||
*/
|
||||
export function isSorted(arr, opt_func, opt_strict) {
|
||||
const compare = opt_func || numberSafeCompareFunction;
|
||||
export function isSorted(arr, func, strict) {
|
||||
const compare = func || numberSafeCompareFunction;
|
||||
return arr.every(function (currentVal, index) {
|
||||
if (index === 0) {
|
||||
return true;
|
||||
}
|
||||
const res = compare(arr[index - 1], currentVal);
|
||||
return !(res > 0 || (opt_strict && res === 0));
|
||||
return !(res > 0 || (strict && res === 0));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ export function createExtent(extent, onlyCenter, smooth) {
|
||||
* @param {import("./coordinate.js").Coordinate|undefined} center Center.
|
||||
* @param {number|undefined} resolution Resolution.
|
||||
* @param {import("./size.js").Size} size Viewport size; unused if `onlyCenter` was specified.
|
||||
* @param {boolean} [opt_isMoving] True if an interaction or animation is in progress.
|
||||
* @param {Array<number>} [opt_centerShift] Shift between map center and viewport center.
|
||||
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
|
||||
* @param {Array<number>} [centerShift] Shift between map center and viewport center.
|
||||
* @return {import("./coordinate.js").Coordinate|undefined} Center.
|
||||
*/
|
||||
function (center, resolution, size, opt_isMoving, opt_centerShift) {
|
||||
function (center, resolution, size, isMoving, centerShift) {
|
||||
if (!center) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -33,8 +33,8 @@ export function createExtent(extent, onlyCenter, smooth) {
|
||||
}
|
||||
const viewWidth = onlyCenter ? 0 : size[0] * resolution;
|
||||
const viewHeight = onlyCenter ? 0 : size[1] * resolution;
|
||||
const shiftX = opt_centerShift ? opt_centerShift[0] : 0;
|
||||
const shiftY = opt_centerShift ? opt_centerShift[1] : 0;
|
||||
const shiftX = centerShift ? centerShift[0] : 0;
|
||||
const shiftY = centerShift ? centerShift[1] : 0;
|
||||
let minX = extent[0] + viewWidth / 2 + shiftX;
|
||||
let maxX = extent[2] - viewWidth / 2 + shiftX;
|
||||
let minY = extent[1] + viewHeight / 2 + shiftY;
|
||||
@@ -55,7 +55,7 @@ export function createExtent(extent, onlyCenter, smooth) {
|
||||
let y = clamp(center[1], minY, maxY);
|
||||
|
||||
// during an interaction, allow some overscroll
|
||||
if (opt_isMoving && smooth && resolution) {
|
||||
if (isMoving && smooth && resolution) {
|
||||
const ratio = 30 * resolution;
|
||||
x +=
|
||||
-ratio * Math.log(1 + Math.max(0, minX - center[0]) / ratio) +
|
||||
|
||||
@@ -46,10 +46,10 @@ import {removeChildren, replaceNode} from '../dom.js';
|
||||
*/
|
||||
class Attribution extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Attribution options.
|
||||
* @param {Options} [options] Attribution options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -80,10 +80,10 @@ const FullScreenEventType = {
|
||||
*/
|
||||
class FullScreen extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -62,10 +62,10 @@ const COORDINATE_FORMAT = 'coordinateFormat';
|
||||
*/
|
||||
class MousePosition extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Mouse position options.
|
||||
* @param {Options} [options] Mouse position options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
const element = document.createElement('div');
|
||||
element.className =
|
||||
|
||||
@@ -66,10 +66,10 @@ const MIN_RATIO = 0.1;
|
||||
*/
|
||||
class OverviewMap extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] OverviewMap options.
|
||||
* @param {Options} [options] OverviewMap options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -33,10 +33,10 @@ import {easeOut} from '../easing.js';
|
||||
*/
|
||||
class Rotate extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Rotate options.
|
||||
* @param {Options} [options] Rotate options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -75,10 +75,10 @@ const DEFAULT_DPI = 25.4 / 0.28;
|
||||
*/
|
||||
class ScaleLine extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Scale line options.
|
||||
* @param {Options} [options] Scale line options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
const element = document.createElement('div');
|
||||
element.style.pointerEvents = 'none';
|
||||
|
||||
@@ -33,10 +33,10 @@ import {easeOut} from '../easing.js';
|
||||
*/
|
||||
class Zoom extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Zoom options.
|
||||
* @param {Options} [options] Zoom options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -41,10 +41,10 @@ const Direction = {
|
||||
*/
|
||||
class ZoomSlider extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Zoom slider options.
|
||||
* @param {Options} [options] Zoom slider options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -27,10 +27,10 @@ import {fromExtent as polygonFromExtent} from '../geom/Polygon.js';
|
||||
*/
|
||||
class ZoomToExtent extends Control {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
|
||||
@@ -29,13 +29,13 @@ import Zoom from './Zoom.js';
|
||||
* * {@link module:ol/control/Rotate~Rotate}
|
||||
* * {@link module:ol/control/Attribution~Attribution}
|
||||
*
|
||||
* @param {DefaultsOptions} [opt_options] Options for the default controls.
|
||||
* @param {DefaultsOptions} [options] Options for the default controls.
|
||||
* @return {Collection<import("./Control.js").default>} A collection of controls
|
||||
* to be used with the {@link module:ol/Map~Map} constructor's `controls` option.
|
||||
* @api
|
||||
*/
|
||||
export function defaults(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
export function defaults(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
/** @type {Collection<import("./Control.js").default>} */
|
||||
const controls = new Collection();
|
||||
|
||||
@@ -135,19 +135,19 @@ export function closestOnSegment(coordinate, segment) {
|
||||
* const out = stringifyFunc(coord);
|
||||
* // out is now '7.85, 47.98'
|
||||
*
|
||||
* @param {number} [opt_fractionDigits] The number of digits to include
|
||||
* @param {number} [fractionDigits] The number of digits to include
|
||||
* after the decimal point. Default is `0`.
|
||||
* @return {CoordinateFormat} Coordinate format.
|
||||
* @api
|
||||
*/
|
||||
export function createStringXY(opt_fractionDigits) {
|
||||
export function createStringXY(fractionDigits) {
|
||||
return (
|
||||
/**
|
||||
* @param {Coordinate} coordinate Coordinate.
|
||||
* @return {string} String XY.
|
||||
*/
|
||||
function (coordinate) {
|
||||
return toStringXY(coordinate, opt_fractionDigits);
|
||||
return toStringXY(coordinate, fractionDigits);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -155,14 +155,14 @@ export function createStringXY(opt_fractionDigits) {
|
||||
/**
|
||||
* @param {string} hemispheres Hemispheres.
|
||||
* @param {number} degrees Degrees.
|
||||
* @param {number} [opt_fractionDigits] The number of digits to include
|
||||
* @param {number} [fractionDigits] The number of digits to include
|
||||
* after the decimal point. Default is `0`.
|
||||
* @return {string} String.
|
||||
*/
|
||||
export function degreesToStringHDMS(hemispheres, degrees, opt_fractionDigits) {
|
||||
export function degreesToStringHDMS(hemispheres, degrees, fractionDigits) {
|
||||
const normalizedDegrees = modulo(degrees + 180, 360) - 180;
|
||||
const x = Math.abs(3600 * normalizedDegrees);
|
||||
const decimals = opt_fractionDigits || 0;
|
||||
const decimals = fractionDigits || 0;
|
||||
|
||||
let deg = Math.floor(x / 3600);
|
||||
let min = Math.floor((x - deg * 3600) / 60);
|
||||
@@ -218,16 +218,16 @@ export function degreesToStringHDMS(hemispheres, degrees, opt_fractionDigits) {
|
||||
* @param {Coordinate} coordinate Coordinate.
|
||||
* @param {string} template A template string with `{x}` and `{y}` placeholders
|
||||
* that will be replaced by first and second coordinate values.
|
||||
* @param {number} [opt_fractionDigits] The number of digits to include
|
||||
* @param {number} [fractionDigits] The number of digits to include
|
||||
* after the decimal point. Default is `0`.
|
||||
* @return {string} Formatted coordinate.
|
||||
* @api
|
||||
*/
|
||||
export function format(coordinate, template, opt_fractionDigits) {
|
||||
export function format(coordinate, template, fractionDigits) {
|
||||
if (coordinate) {
|
||||
return template
|
||||
.replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
|
||||
.replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
|
||||
.replace('{x}', coordinate[0].toFixed(fractionDigits))
|
||||
.replace('{y}', coordinate[1].toFixed(fractionDigits));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -353,17 +353,17 @@ export function squaredDistanceToSegment(coordinate, segment) {
|
||||
* // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'
|
||||
*
|
||||
* @param {Coordinate} coordinate Coordinate.
|
||||
* @param {number} [opt_fractionDigits] The number of digits to include
|
||||
* @param {number} [fractionDigits] The number of digits to include
|
||||
* after the decimal point. Default is `0`.
|
||||
* @return {string} Hemisphere, degrees, minutes and seconds.
|
||||
* @api
|
||||
*/
|
||||
export function toStringHDMS(coordinate, opt_fractionDigits) {
|
||||
export function toStringHDMS(coordinate, fractionDigits) {
|
||||
if (coordinate) {
|
||||
return (
|
||||
degreesToStringHDMS('NS', coordinate[1], opt_fractionDigits) +
|
||||
degreesToStringHDMS('NS', coordinate[1], fractionDigits) +
|
||||
' ' +
|
||||
degreesToStringHDMS('EW', coordinate[0], opt_fractionDigits)
|
||||
degreesToStringHDMS('EW', coordinate[0], fractionDigits)
|
||||
);
|
||||
} else {
|
||||
return '';
|
||||
@@ -390,13 +390,13 @@ export function toStringHDMS(coordinate, opt_fractionDigits) {
|
||||
* // out is now '7.8, 48.0'
|
||||
*
|
||||
* @param {Coordinate} coordinate Coordinate.
|
||||
* @param {number} [opt_fractionDigits] The number of digits to include
|
||||
* @param {number} [fractionDigits] The number of digits to include
|
||||
* after the decimal point. Default is `0`.
|
||||
* @return {string} XY.
|
||||
* @api
|
||||
*/
|
||||
export function toStringXY(coordinate, opt_fractionDigits) {
|
||||
return format(coordinate, '{x}, {y}', opt_fractionDigits);
|
||||
export function toStringXY(coordinate, fractionDigits) {
|
||||
return format(coordinate, '{x}, {y}', fractionDigits);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,18 +421,17 @@ export function wrapX(coordinate, projection) {
|
||||
/**
|
||||
* @param {Coordinate} coordinate Coordinate.
|
||||
* @param {import("./proj/Projection.js").default} projection Projection.
|
||||
* @param {number} [opt_sourceExtentWidth] Width of the source extent.
|
||||
* @param {number} [sourceExtentWidth] Width of the source extent.
|
||||
* @return {number} Offset in world widths.
|
||||
*/
|
||||
export function getWorldsAway(coordinate, projection, opt_sourceExtentWidth) {
|
||||
export function getWorldsAway(coordinate, projection, sourceExtentWidth) {
|
||||
const projectionExtent = projection.getExtent();
|
||||
let worldsAway = 0;
|
||||
if (
|
||||
projection.canWrapX() &&
|
||||
(coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])
|
||||
) {
|
||||
const sourceExtentWidth =
|
||||
opt_sourceExtentWidth || getWidth(projectionExtent);
|
||||
sourceExtentWidth = sourceExtentWidth || getWidth(projectionExtent);
|
||||
worldsAway = Math.floor(
|
||||
(coordinate[0] - projectionExtent[0]) / sourceExtentWidth
|
||||
);
|
||||
|
||||
@@ -7,36 +7,31 @@ import {WORKER_OFFSCREEN_CANVAS} from './has.js';
|
||||
//FIXME Move this function to the canvas module
|
||||
/**
|
||||
* Create an html canvas element and returns its 2d context.
|
||||
* @param {number} [opt_width] Canvas width.
|
||||
* @param {number} [opt_height] Canvas height.
|
||||
* @param {Array<HTMLCanvasElement>} [opt_canvasPool] Canvas pool to take existing canvas from.
|
||||
* @param {CanvasRenderingContext2DSettings} [opt_Context2DSettings] CanvasRenderingContext2DSettings
|
||||
* @param {number} [width] Canvas width.
|
||||
* @param {number} [height] Canvas height.
|
||||
* @param {Array<HTMLCanvasElement>} [canvasPool] Canvas pool to take existing canvas from.
|
||||
* @param {CanvasRenderingContext2DSettings} [settings] CanvasRenderingContext2DSettings
|
||||
* @return {CanvasRenderingContext2D} The context.
|
||||
*/
|
||||
export function createCanvasContext2D(
|
||||
opt_width,
|
||||
opt_height,
|
||||
opt_canvasPool,
|
||||
opt_Context2DSettings
|
||||
) {
|
||||
export function createCanvasContext2D(width, height, canvasPool, settings) {
|
||||
/** @type {HTMLCanvasElement|OffscreenCanvas} */
|
||||
let canvas;
|
||||
if (opt_canvasPool && opt_canvasPool.length) {
|
||||
canvas = opt_canvasPool.shift();
|
||||
if (canvasPool && canvasPool.length) {
|
||||
canvas = canvasPool.shift();
|
||||
} else if (WORKER_OFFSCREEN_CANVAS) {
|
||||
canvas = new OffscreenCanvas(opt_width || 300, opt_height || 300);
|
||||
canvas = new OffscreenCanvas(width || 300, height || 300);
|
||||
} else {
|
||||
canvas = document.createElement('canvas');
|
||||
}
|
||||
if (opt_width) {
|
||||
canvas.width = opt_width;
|
||||
if (width) {
|
||||
canvas.width = width;
|
||||
}
|
||||
if (opt_height) {
|
||||
canvas.height = opt_height;
|
||||
if (height) {
|
||||
canvas.height = height;
|
||||
}
|
||||
//FIXME Allow OffscreenCanvasRenderingContext2D as return type
|
||||
return /** @type {CanvasRenderingContext2D} */ (
|
||||
canvas.getContext('2d', opt_Context2DSettings)
|
||||
canvas.getContext('2d', settings)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,16 +39,16 @@ import {clear} from './obj.js';
|
||||
* @param {import("./events/Target.js").EventTargetLike} target Event target.
|
||||
* @param {string} type Event type.
|
||||
* @param {ListenerFunction} listener Listener.
|
||||
* @param {Object} [opt_this] Object referenced by the `this` keyword in the
|
||||
* @param {Object} [thisArg] Object referenced by the `this` keyword in the
|
||||
* listener. Default is the `target`.
|
||||
* @param {boolean} [opt_once] If true, add the listener as one-off listener.
|
||||
* @param {boolean} [once] If true, add the listener as one-off listener.
|
||||
* @return {EventsKey} Unique key for the listener.
|
||||
*/
|
||||
export function listen(target, type, listener, opt_this, opt_once) {
|
||||
if (opt_this && opt_this !== target) {
|
||||
listener = listener.bind(opt_this);
|
||||
export function listen(target, type, listener, thisArg, once) {
|
||||
if (thisArg && thisArg !== target) {
|
||||
listener = listener.bind(thisArg);
|
||||
}
|
||||
if (opt_once) {
|
||||
if (once) {
|
||||
const originalListener = listener;
|
||||
listener = function () {
|
||||
target.removeEventListener(type, listener);
|
||||
@@ -80,12 +80,12 @@ export function listen(target, type, listener, opt_this, opt_once) {
|
||||
* @param {import("./events/Target.js").EventTargetLike} target Event target.
|
||||
* @param {string} type Event type.
|
||||
* @param {ListenerFunction} listener Listener.
|
||||
* @param {Object} [opt_this] Object referenced by the `this` keyword in the
|
||||
* @param {Object} [thisArg] Object referenced by the `this` keyword in the
|
||||
* listener. Default is the `target`.
|
||||
* @return {EventsKey} Key for unlistenByKey.
|
||||
*/
|
||||
export function listenOnce(target, type, listener, opt_this) {
|
||||
return listen(target, type, listener, opt_this, true);
|
||||
export function listenOnce(target, type, listener, thisArg) {
|
||||
return listen(target, type, listener, thisArg, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,16 +27,16 @@ import {clear} from '../obj.js';
|
||||
*/
|
||||
class Target extends Disposable {
|
||||
/**
|
||||
* @param {*} [opt_target] Default event target for dispatched events.
|
||||
* @param {*} [target] Default event target for dispatched events.
|
||||
*/
|
||||
constructor(opt_target) {
|
||||
constructor(target) {
|
||||
super();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {*}
|
||||
*/
|
||||
this.eventTarget_ = opt_target;
|
||||
this.eventTarget_ = target;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -148,16 +148,16 @@ class Target extends Disposable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [opt_type] Type. If not provided,
|
||||
* @param {string} [type] Type. If not provided,
|
||||
* `true` will be returned if this event target has any listeners.
|
||||
* @return {boolean} Has listeners.
|
||||
*/
|
||||
hasListener(opt_type) {
|
||||
hasListener(type) {
|
||||
if (!this.listeners_) {
|
||||
return false;
|
||||
}
|
||||
return opt_type
|
||||
? opt_type in this.listeners_
|
||||
return type
|
||||
? type in this.listeners_
|
||||
: Object.keys(this.listeners_).length > 0;
|
||||
}
|
||||
|
||||
|
||||
138
src/ol/extent.js
138
src/ol/extent.js
@@ -33,33 +33,33 @@ export function boundingExtent(coordinates) {
|
||||
/**
|
||||
* @param {Array<number>} xs Xs.
|
||||
* @param {Array<number>} ys Ys.
|
||||
* @param {Extent} [opt_extent] Destination extent.
|
||||
* @param {Extent} [dest] Destination extent.
|
||||
* @private
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
function _boundingExtentXYs(xs, ys, opt_extent) {
|
||||
function _boundingExtentXYs(xs, ys, dest) {
|
||||
const minX = Math.min.apply(null, xs);
|
||||
const minY = Math.min.apply(null, ys);
|
||||
const maxX = Math.max.apply(null, xs);
|
||||
const maxY = Math.max.apply(null, ys);
|
||||
return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
|
||||
return createOrUpdate(minX, minY, maxX, maxY, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return extent increased by the provided value.
|
||||
* @param {Extent} extent Extent.
|
||||
* @param {number} value The amount by which the extent should be buffered.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
export function buffer(extent, value, opt_extent) {
|
||||
if (opt_extent) {
|
||||
opt_extent[0] = extent[0] - value;
|
||||
opt_extent[1] = extent[1] - value;
|
||||
opt_extent[2] = extent[2] + value;
|
||||
opt_extent[3] = extent[3] + value;
|
||||
return opt_extent;
|
||||
export function buffer(extent, value, dest) {
|
||||
if (dest) {
|
||||
dest[0] = extent[0] - value;
|
||||
dest[1] = extent[1] - value;
|
||||
dest[2] = extent[2] + value;
|
||||
dest[3] = extent[3] + value;
|
||||
return dest;
|
||||
} else {
|
||||
return [
|
||||
extent[0] - value,
|
||||
@@ -74,16 +74,16 @@ export function buffer(extent, value, opt_extent) {
|
||||
* Creates a clone of an extent.
|
||||
*
|
||||
* @param {Extent} extent Extent to clone.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} The clone.
|
||||
*/
|
||||
export function clone(extent, opt_extent) {
|
||||
if (opt_extent) {
|
||||
opt_extent[0] = extent[0];
|
||||
opt_extent[1] = extent[1];
|
||||
opt_extent[2] = extent[2];
|
||||
opt_extent[3] = extent[3];
|
||||
return opt_extent;
|
||||
export function clone(extent, dest) {
|
||||
if (dest) {
|
||||
dest[0] = extent[0];
|
||||
dest[1] = extent[1];
|
||||
dest[2] = extent[2];
|
||||
dest[3] = extent[3];
|
||||
return dest;
|
||||
} else {
|
||||
return extent.slice();
|
||||
}
|
||||
@@ -206,16 +206,16 @@ export function createEmpty() {
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @param {Extent} [opt_extent] Destination extent.
|
||||
* @param {Extent} [dest] Destination extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdate(minX, minY, maxX, maxY, opt_extent) {
|
||||
if (opt_extent) {
|
||||
opt_extent[0] = minX;
|
||||
opt_extent[1] = minY;
|
||||
opt_extent[2] = maxX;
|
||||
opt_extent[3] = maxY;
|
||||
return opt_extent;
|
||||
export function createOrUpdate(minX, minY, maxX, maxY, dest) {
|
||||
if (dest) {
|
||||
dest[0] = minX;
|
||||
dest[1] = minY;
|
||||
dest[2] = maxX;
|
||||
dest[3] = maxY;
|
||||
return dest;
|
||||
} else {
|
||||
return [minX, minY, maxX, maxY];
|
||||
}
|
||||
@@ -223,31 +223,31 @@ export function createOrUpdate(minX, minY, maxX, maxY, opt_extent) {
|
||||
|
||||
/**
|
||||
* Create a new empty extent or make the provided one empty.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateEmpty(opt_extent) {
|
||||
return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, opt_extent);
|
||||
export function createOrUpdateEmpty(dest) {
|
||||
return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromCoordinate(coordinate, opt_extent) {
|
||||
export function createOrUpdateFromCoordinate(coordinate, dest) {
|
||||
const x = coordinate[0];
|
||||
const y = coordinate[1];
|
||||
return createOrUpdate(x, y, x, y, opt_extent);
|
||||
return createOrUpdate(x, y, x, y, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<import("./coordinate.js").Coordinate>} coordinates Coordinates.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromCoordinates(coordinates, opt_extent) {
|
||||
const extent = createOrUpdateEmpty(opt_extent);
|
||||
export function createOrUpdateFromCoordinates(coordinates, dest) {
|
||||
const extent = createOrUpdateEmpty(dest);
|
||||
return extendCoordinates(extent, coordinates);
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ export function createOrUpdateFromCoordinates(coordinates, opt_extent) {
|
||||
* @param {number} offset Offset.
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromFlatCoordinates(
|
||||
@@ -264,19 +264,19 @@ export function createOrUpdateFromFlatCoordinates(
|
||||
offset,
|
||||
end,
|
||||
stride,
|
||||
opt_extent
|
||||
dest
|
||||
) {
|
||||
const extent = createOrUpdateEmpty(opt_extent);
|
||||
const extent = createOrUpdateEmpty(dest);
|
||||
return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<Array<import("./coordinate.js").Coordinate>>} rings Rings.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromRings(rings, opt_extent) {
|
||||
const extent = createOrUpdateEmpty(opt_extent);
|
||||
export function createOrUpdateFromRings(rings, dest) {
|
||||
const extent = createOrUpdateEmpty(dest);
|
||||
return extendRings(extent, rings);
|
||||
}
|
||||
|
||||
@@ -525,16 +525,10 @@ export function getEnlargedArea(extent1, extent2) {
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} rotation Rotation.
|
||||
* @param {import("./size.js").Size} size Size.
|
||||
* @param {Extent} [opt_extent] Destination extent.
|
||||
* @param {Extent} [dest] Destination extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function getForViewAndSize(
|
||||
center,
|
||||
resolution,
|
||||
rotation,
|
||||
size,
|
||||
opt_extent
|
||||
) {
|
||||
export function getForViewAndSize(center, resolution, rotation, size, dest) {
|
||||
const [x0, y0, x1, y1, x2, y2, x3, y3] = getRotatedViewport(
|
||||
center,
|
||||
resolution,
|
||||
@@ -546,7 +540,7 @@ export function getForViewAndSize(
|
||||
Math.min(y0, y1, y2, y3),
|
||||
Math.max(x0, x1, x2, x3),
|
||||
Math.max(y0, y1, y2, y3),
|
||||
opt_extent
|
||||
dest
|
||||
);
|
||||
}
|
||||
|
||||
@@ -606,12 +600,12 @@ export function getIntersectionArea(extent1, extent2) {
|
||||
* Get the intersection of two extents.
|
||||
* @param {Extent} extent1 Extent 1.
|
||||
* @param {Extent} extent2 Extent 2.
|
||||
* @param {Extent} [opt_extent] Optional extent to populate with intersection.
|
||||
* @param {Extent} [dest] Optional extent to populate with intersection.
|
||||
* @return {Extent} Intersecting extent.
|
||||
* @api
|
||||
*/
|
||||
export function getIntersection(extent1, extent2, opt_extent) {
|
||||
const intersection = opt_extent ? opt_extent : createEmpty();
|
||||
export function getIntersection(extent1, extent2, dest) {
|
||||
const intersection = dest ? dest : createEmpty();
|
||||
if (intersects(extent1, extent2)) {
|
||||
if (extent1[0] > extent2[0]) {
|
||||
intersection[0] = extent1[0];
|
||||
@@ -715,16 +709,16 @@ export function isEmpty(extent) {
|
||||
|
||||
/**
|
||||
* @param {Extent} extent Extent.
|
||||
* @param {Extent} [opt_extent] Extent.
|
||||
* @param {Extent} [dest] Extent.
|
||||
* @return {Extent} Extent.
|
||||
*/
|
||||
export function returnOrUpdate(extent, opt_extent) {
|
||||
if (opt_extent) {
|
||||
opt_extent[0] = extent[0];
|
||||
opt_extent[1] = extent[1];
|
||||
opt_extent[2] = extent[2];
|
||||
opt_extent[3] = extent[3];
|
||||
return opt_extent;
|
||||
export function returnOrUpdate(extent, dest) {
|
||||
if (dest) {
|
||||
dest[0] = extent[0];
|
||||
dest[1] = extent[1];
|
||||
dest[2] = extent[2];
|
||||
dest[3] = extent[3];
|
||||
return dest;
|
||||
} else {
|
||||
return extent;
|
||||
}
|
||||
@@ -812,27 +806,27 @@ export function intersectsSegment(extent, start, end) {
|
||||
* @param {Extent} extent Extent.
|
||||
* @param {import("./proj.js").TransformFunction} transformFn Transform function.
|
||||
* Called with `[minX, minY, maxX, maxY]` extent coordinates.
|
||||
* @param {Extent} [opt_extent] Destination extent.
|
||||
* @param {number} [opt_stops] Number of stops per side used for the transform.
|
||||
* @param {Extent} [dest] Destination extent.
|
||||
* @param {number} [stops] Number of stops per side used for the transform.
|
||||
* By default only the corners are used.
|
||||
* @return {Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
export function applyTransform(extent, transformFn, opt_extent, opt_stops) {
|
||||
export function applyTransform(extent, transformFn, dest, stops) {
|
||||
let coordinates = [];
|
||||
if (opt_stops > 1) {
|
||||
if (stops > 1) {
|
||||
const width = extent[2] - extent[0];
|
||||
const height = extent[3] - extent[1];
|
||||
for (let i = 0; i < opt_stops; ++i) {
|
||||
for (let i = 0; i < stops; ++i) {
|
||||
coordinates.push(
|
||||
extent[0] + (width * i) / opt_stops,
|
||||
extent[0] + (width * i) / stops,
|
||||
extent[1],
|
||||
extent[2],
|
||||
extent[1] + (height * i) / opt_stops,
|
||||
extent[2] - (width * i) / opt_stops,
|
||||
extent[1] + (height * i) / stops,
|
||||
extent[2] - (width * i) / stops,
|
||||
extent[3],
|
||||
extent[0],
|
||||
extent[3] - (height * i) / opt_stops
|
||||
extent[3] - (height * i) / stops
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -854,7 +848,7 @@ export function applyTransform(extent, transformFn, opt_extent, opt_stops) {
|
||||
xs.push(coordinates[i]);
|
||||
ys.push(coordinates[i + 1]);
|
||||
}
|
||||
return _boundingExtentXYs(xs, ys, opt_extent);
|
||||
return _boundingExtentXYs(xs, ys, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,10 +78,10 @@ const GEOMETRY_WRITERS = {
|
||||
*/
|
||||
class EsriJSON extends JSONFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super();
|
||||
|
||||
@@ -95,14 +95,14 @@ class EsriJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {string} [opt_idField] Name of the field where to get the id from.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @param {string} [idField] Name of the field where to get the id from.
|
||||
* @protected
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromObject(object, opt_options, opt_idField) {
|
||||
readFeatureFromObject(object, options, idField) {
|
||||
const esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
|
||||
const geometry = readGeometry(esriJSONFeature.geometry, opt_options);
|
||||
const geometry = readGeometry(esriJSONFeature.geometry, options);
|
||||
const feature = new Feature();
|
||||
if (this.geometryName_) {
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
@@ -110,7 +110,7 @@ class EsriJSON extends JSONFeature {
|
||||
feature.setGeometry(geometry);
|
||||
if (esriJSONFeature.attributes) {
|
||||
feature.setProperties(esriJSONFeature.attributes, true);
|
||||
const id = esriJSONFeature.attributes[opt_idField];
|
||||
const id = esriJSONFeature.attributes[idField];
|
||||
if (id !== undefined) {
|
||||
feature.setId(/** @type {number} */ (id));
|
||||
}
|
||||
@@ -120,12 +120,12 @@ class EsriJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromObject(object, opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
readFeaturesFromObject(object, options) {
|
||||
options = options ? options : {};
|
||||
if (object['features']) {
|
||||
const esriJSONFeatureSet = /** @type {EsriJSONFeatureSet} */ (object);
|
||||
/** @type {Array<import("../Feature.js").default>} */
|
||||
@@ -148,12 +148,12 @@ class EsriJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {EsriJSONGeometry} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromObject(object, opt_options) {
|
||||
return readGeometry(object, opt_options);
|
||||
readGeometryFromObject(object, options) {
|
||||
return readGeometry(object, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,24 +180,24 @@ class EsriJSON extends JSONFeature {
|
||||
* Encode a geometry as a EsriJSON object.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONGeometry} Object.
|
||||
* @api
|
||||
*/
|
||||
writeGeometryObject(geometry, opt_options) {
|
||||
return writeGeometry(geometry, this.adaptOptions(opt_options));
|
||||
writeGeometryObject(geometry, options) {
|
||||
return writeGeometry(geometry, this.adaptOptions(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a feature as a esriJSON Feature object.
|
||||
*
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {Object} Object.
|
||||
* @api
|
||||
*/
|
||||
writeFeatureObject(feature, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeatureObject(feature, options) {
|
||||
options = this.adaptOptions(options);
|
||||
const object = {};
|
||||
if (!feature.hasProperties()) {
|
||||
object['attributes'] = {};
|
||||
@@ -206,10 +206,9 @@ class EsriJSON extends JSONFeature {
|
||||
const properties = feature.getProperties();
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
object['geometry'] = writeGeometry(geometry, opt_options);
|
||||
object['geometry'] = writeGeometry(geometry, options);
|
||||
const projection =
|
||||
opt_options &&
|
||||
(opt_options.dataProjection || opt_options.featureProjection);
|
||||
options && (options.dataProjection || options.featureProjection);
|
||||
if (projection) {
|
||||
object['geometry']['spatialReference'] =
|
||||
/** @type {EsriJSONSpatialReferenceWkid} */ ({
|
||||
@@ -230,15 +229,15 @@ class EsriJSON extends JSONFeature {
|
||||
* Encode an array of features as a EsriJSON object.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONFeatureSet} EsriJSON Object.
|
||||
* @api
|
||||
*/
|
||||
writeFeaturesObject(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeaturesObject(features, options) {
|
||||
options = this.adaptOptions(options);
|
||||
const objects = [];
|
||||
for (let i = 0, ii = features.length; i < ii; ++i) {
|
||||
objects.push(this.writeFeatureObject(features[i], opt_options));
|
||||
objects.push(this.writeFeatureObject(features[i], options));
|
||||
}
|
||||
return {
|
||||
'features': objects,
|
||||
@@ -248,10 +247,10 @@ class EsriJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {EsriJSONGeometry} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
function readGeometry(object, opt_options) {
|
||||
function readGeometry(object, options) {
|
||||
if (!object) {
|
||||
return null;
|
||||
}
|
||||
@@ -281,11 +280,7 @@ function readGeometry(object, opt_options) {
|
||||
}
|
||||
}
|
||||
const geometryReader = GEOMETRY_READERS[type];
|
||||
return transformGeometryWithOptions(
|
||||
geometryReader(object),
|
||||
false,
|
||||
opt_options
|
||||
);
|
||||
return transformGeometryWithOptions(geometryReader(object), false, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,10 +421,10 @@ function readPolygonGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/Point.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONPoint} EsriJSON geometry.
|
||||
*/
|
||||
function writePointGeometry(geometry, opt_options) {
|
||||
function writePointGeometry(geometry, options) {
|
||||
const coordinates = geometry.getCoordinates();
|
||||
/** @type {EsriJSONPoint} */
|
||||
let esriJSON;
|
||||
@@ -478,10 +473,10 @@ function getHasZM(geometry) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/LineString.js").default} lineString Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||
*/
|
||||
function writeLineStringGeometry(lineString, opt_options) {
|
||||
function writeLineStringGeometry(lineString, options) {
|
||||
const hasZM = getHasZM(lineString);
|
||||
return {
|
||||
hasZ: hasZM.hasZ,
|
||||
@@ -494,10 +489,10 @@ function writeLineStringGeometry(lineString, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/Polygon.js").default} polygon Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONPolygon} EsriJSON geometry.
|
||||
*/
|
||||
function writePolygonGeometry(polygon, opt_options) {
|
||||
function writePolygonGeometry(polygon, options) {
|
||||
// Esri geometries use the left-hand rule
|
||||
const hasZM = getHasZM(polygon);
|
||||
return {
|
||||
@@ -511,10 +506,10 @@ function writePolygonGeometry(polygon, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/MultiLineString.js").default} multiLineString Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||
*/
|
||||
function writeMultiLineStringGeometry(multiLineString, opt_options) {
|
||||
function writeMultiLineStringGeometry(multiLineString, options) {
|
||||
const hasZM = getHasZM(multiLineString);
|
||||
return {
|
||||
hasZ: hasZM.hasZ,
|
||||
@@ -527,10 +522,10 @@ function writeMultiLineStringGeometry(multiLineString, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/MultiPoint.js").default} multiPoint Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
||||
*/
|
||||
function writeMultiPointGeometry(multiPoint, opt_options) {
|
||||
function writeMultiPointGeometry(multiPoint, options) {
|
||||
const hasZM = getHasZM(multiPoint);
|
||||
return {
|
||||
hasZ: hasZM.hasZ,
|
||||
@@ -543,10 +538,10 @@ function writeMultiPointGeometry(multiPoint, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONPolygon} EsriJSON geometry.
|
||||
*/
|
||||
function writeMultiPolygonGeometry(geometry, opt_options) {
|
||||
function writeMultiPolygonGeometry(geometry, options) {
|
||||
const hasZM = getHasZM(geometry);
|
||||
const coordinates = geometry.getCoordinates(false);
|
||||
const output = [];
|
||||
@@ -564,14 +559,14 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {EsriJSONGeometry} EsriJSON geometry.
|
||||
*/
|
||||
function writeGeometry(geometry, opt_options) {
|
||||
function writeGeometry(geometry, options) {
|
||||
const geometryWriter = GEOMETRY_WRITERS[geometry.getType()];
|
||||
return geometryWriter(
|
||||
transformGeometryWithOptions(geometry, true, opt_options),
|
||||
opt_options
|
||||
transformGeometryWithOptions(geometry, true, options),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,27 +89,26 @@ class FeatureFormat {
|
||||
/**
|
||||
* Adds the data projection to the read options.
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {ReadOptions} [opt_options] Options.
|
||||
* @param {ReadOptions} [options] Options.
|
||||
* @return {ReadOptions|undefined} Options.
|
||||
* @protected
|
||||
*/
|
||||
getReadOptions(source, opt_options) {
|
||||
let options;
|
||||
if (opt_options) {
|
||||
let dataProjection = opt_options.dataProjection
|
||||
? getProjection(opt_options.dataProjection)
|
||||
getReadOptions(source, options) {
|
||||
if (options) {
|
||||
let dataProjection = options.dataProjection
|
||||
? getProjection(options.dataProjection)
|
||||
: this.readProjection(source);
|
||||
if (
|
||||
opt_options.extent &&
|
||||
options.extent &&
|
||||
dataProjection &&
|
||||
dataProjection.getUnits() === 'tile-pixels'
|
||||
) {
|
||||
dataProjection = getProjection(dataProjection);
|
||||
dataProjection.setWorldExtent(opt_options.extent);
|
||||
dataProjection.setWorldExtent(options.extent);
|
||||
}
|
||||
options = {
|
||||
dataProjection: dataProjection,
|
||||
featureProjection: opt_options.featureProjection,
|
||||
featureProjection: options.featureProjection,
|
||||
};
|
||||
}
|
||||
return this.adaptOptions(options);
|
||||
@@ -147,10 +146,10 @@ class FeatureFormat {
|
||||
*
|
||||
* @abstract
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {ReadOptions} [opt_options] Read options.
|
||||
* @param {ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").FeatureLike} Feature.
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
readFeature(source, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -159,10 +158,10 @@ class FeatureFormat {
|
||||
*
|
||||
* @abstract
|
||||
* @param {Document|Element|ArrayBuffer|Object|string} source Source.
|
||||
* @param {ReadOptions} [opt_options] Read options.
|
||||
* @param {ReadOptions} [options] Read options.
|
||||
* @return {Array<import("../Feature.js").FeatureLike>} Features.
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
readFeatures(source, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -171,10 +170,10 @@ class FeatureFormat {
|
||||
*
|
||||
* @abstract
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {ReadOptions} [opt_options] Read options.
|
||||
* @param {ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
readGeometry(source, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -194,10 +193,10 @@ class FeatureFormat {
|
||||
*
|
||||
* @abstract
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {WriteOptions} [opt_options] Write options.
|
||||
* @param {WriteOptions} [options] Write options.
|
||||
* @return {string|ArrayBuffer} Result.
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
writeFeature(feature, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -206,10 +205,10 @@ class FeatureFormat {
|
||||
*
|
||||
* @abstract
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {WriteOptions} [opt_options] Write options.
|
||||
* @param {WriteOptions} [options] Write options.
|
||||
* @return {string|ArrayBuffer} Result.
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
writeFeatures(features, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -218,10 +217,10 @@ class FeatureFormat {
|
||||
*
|
||||
* @abstract
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {WriteOptions} [opt_options] Write options.
|
||||
* @param {WriteOptions} [options] Write options.
|
||||
* @return {string|ArrayBuffer} Result.
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
writeGeometry(geometry, options) {
|
||||
return abstract();
|
||||
}
|
||||
}
|
||||
@@ -231,16 +230,14 @@ export default FeatureFormat;
|
||||
/**
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {boolean} write Set to true for writing, false for reading.
|
||||
* @param {WriteOptions|ReadOptions} [opt_options] Options.
|
||||
* @param {WriteOptions|ReadOptions} [options] Options.
|
||||
* @return {import("../geom/Geometry.js").default} Transformed geometry.
|
||||
*/
|
||||
export function transformGeometryWithOptions(geometry, write, opt_options) {
|
||||
const featureProjection = opt_options
|
||||
? getProjection(opt_options.featureProjection)
|
||||
: null;
|
||||
const dataProjection = opt_options
|
||||
? getProjection(opt_options.dataProjection)
|
||||
export function transformGeometryWithOptions(geometry, write, options) {
|
||||
const featureProjection = options
|
||||
? getProjection(options.featureProjection)
|
||||
: null;
|
||||
const dataProjection = options ? getProjection(options.dataProjection) : null;
|
||||
|
||||
let transformed;
|
||||
if (
|
||||
@@ -257,13 +254,10 @@ export function transformGeometryWithOptions(geometry, write, opt_options) {
|
||||
}
|
||||
if (
|
||||
write &&
|
||||
opt_options &&
|
||||
/** @type {WriteOptions} */ (opt_options).decimals !== undefined
|
||||
options &&
|
||||
/** @type {WriteOptions} */ (options).decimals !== undefined
|
||||
) {
|
||||
const power = Math.pow(
|
||||
10,
|
||||
/** @type {WriteOptions} */ (opt_options).decimals
|
||||
);
|
||||
const power = Math.pow(10, /** @type {WriteOptions} */ (options).decimals);
|
||||
// if decimals option on write, round each coordinate appropriately
|
||||
/**
|
||||
* @param {Array<number>} coordinates Coordinates.
|
||||
@@ -285,16 +279,14 @@ export function transformGeometryWithOptions(geometry, write, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {import("../extent.js").Extent} extent Extent.
|
||||
* @param {ReadOptions} [opt_options] Read options.
|
||||
* @param {ReadOptions} [options] Read options.
|
||||
* @return {import("../extent.js").Extent} Transformed extent.
|
||||
*/
|
||||
export function transformExtentWithOptions(extent, opt_options) {
|
||||
const featureProjection = opt_options
|
||||
? getProjection(opt_options.featureProjection)
|
||||
: null;
|
||||
const dataProjection = opt_options
|
||||
? getProjection(opt_options.dataProjection)
|
||||
export function transformExtentWithOptions(extent, options) {
|
||||
const featureProjection = options
|
||||
? getProjection(options.featureProjection)
|
||||
: null;
|
||||
const dataProjection = options ? getProjection(options.dataProjection) : null;
|
||||
|
||||
if (
|
||||
featureProjection &&
|
||||
|
||||
@@ -9,7 +9,7 @@ import GML3 from './GML3.js';
|
||||
* Currently only supports GML 3.1.1 Simple Features profile.
|
||||
*
|
||||
* @class
|
||||
* @param {import("./GMLBase.js").Options} [opt_options]
|
||||
* @param {import("./GMLBase.js").Options} [options]
|
||||
* Optional configuration object.
|
||||
* @api
|
||||
*/
|
||||
@@ -20,7 +20,7 @@ const GML = GML3;
|
||||
*
|
||||
* @function
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {string} Result.
|
||||
* @api
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ GML.prototype.writeFeatures;
|
||||
*
|
||||
* @function
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Node} Node.
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -48,12 +48,10 @@ const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
|
||||
*/
|
||||
class GML2 extends GMLBase {
|
||||
/**
|
||||
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
|
||||
* @param {import("./GMLBase.js").Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options =
|
||||
/** @type {import("./GMLBase.js").Options} */
|
||||
(opt_options ? opt_options : {});
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super(options);
|
||||
|
||||
@@ -171,16 +169,15 @@ class GML2 extends GMLBase {
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Element|undefined} Node.
|
||||
* @private
|
||||
*/
|
||||
GEOMETRY_NODE_FACTORY_(value, objectStack, opt_nodeName) {
|
||||
GEOMETRY_NODE_FACTORY_(value, objectStack, nodeName) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const multiSurface = context['multiSurface'];
|
||||
const surface = context['surface'];
|
||||
const multiCurve = context['multiCurve'];
|
||||
let nodeName;
|
||||
if (!Array.isArray(value)) {
|
||||
nodeName = /** @type {import("../geom/Geometry.js").default} */ (
|
||||
value
|
||||
@@ -436,11 +433,11 @@ class GML2 extends GMLBase {
|
||||
/**
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node} Node.
|
||||
* @private
|
||||
*/
|
||||
RING_NODE_FACTORY_(value, objectStack, opt_nodeName) {
|
||||
RING_NODE_FACTORY_(value, objectStack, nodeName) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const parentNode = context.node;
|
||||
const exteriorWritten = context['exteriorWritten'];
|
||||
@@ -478,21 +475,21 @@ class GML2 extends GMLBase {
|
||||
|
||||
/**
|
||||
* @param {Array<number>} point Point geometry.
|
||||
* @param {string} [opt_srsName] Optional srsName
|
||||
* @param {boolean} [opt_hasZ] whether the geometry has a Z coordinate (is 3D) or not.
|
||||
* @param {string} [srsName] Optional srsName
|
||||
* @param {boolean} [hasZ] whether the geometry has a Z coordinate (is 3D) or not.
|
||||
* @return {string} The coords string.
|
||||
* @private
|
||||
*/
|
||||
getCoords_(point, opt_srsName, opt_hasZ) {
|
||||
getCoords_(point, srsName, hasZ) {
|
||||
let axisOrientation = 'enu';
|
||||
if (opt_srsName) {
|
||||
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
|
||||
if (srsName) {
|
||||
axisOrientation = getProjection(srsName).getAxisOrientation();
|
||||
}
|
||||
let coords =
|
||||
axisOrientation.substr(0, 2) === 'en'
|
||||
? point[0] + ',' + point[1]
|
||||
: point[1] + ',' + point[0];
|
||||
if (opt_hasZ) {
|
||||
if (hasZ) {
|
||||
// For newly created points, Z can be undefined.
|
||||
const z = point[2] || 0;
|
||||
coords += ',' + z;
|
||||
@@ -638,11 +635,11 @@ class GML2 extends GMLBase {
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
* @private
|
||||
*/
|
||||
MULTIGEOMETRY_MEMBER_NODE_FACTORY_(value, objectStack, opt_nodeName) {
|
||||
MULTIGEOMETRY_MEMBER_NODE_FACTORY_(value, objectStack, nodeName) {
|
||||
const parentNode = objectStack[objectStack.length - 1].node;
|
||||
return createElementNS(
|
||||
'http://www.opengis.net/gml',
|
||||
|
||||
@@ -61,12 +61,10 @@ const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
|
||||
*/
|
||||
class GML3 extends GMLBase {
|
||||
/**
|
||||
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
|
||||
* @param {import("./GMLBase.js").Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options =
|
||||
/** @type {import("./GMLBase.js").Options} */
|
||||
(opt_options ? opt_options : {});
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super(options);
|
||||
|
||||
@@ -480,21 +478,21 @@ class GML3 extends GMLBase {
|
||||
|
||||
/**
|
||||
* @param {Array<number>} point Point geometry.
|
||||
* @param {string} [opt_srsName] Optional srsName
|
||||
* @param {boolean} [opt_hasZ] whether the geometry has a Z coordinate (is 3D) or not.
|
||||
* @param {string} [srsName] Optional srsName
|
||||
* @param {boolean} [hasZ] whether the geometry has a Z coordinate (is 3D) or not.
|
||||
* @return {string} The coords string.
|
||||
* @private
|
||||
*/
|
||||
getCoords_(point, opt_srsName, opt_hasZ) {
|
||||
getCoords_(point, srsName, hasZ) {
|
||||
let axisOrientation = 'enu';
|
||||
if (opt_srsName) {
|
||||
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
|
||||
if (srsName) {
|
||||
axisOrientation = getProjection(srsName).getAxisOrientation();
|
||||
}
|
||||
let coords =
|
||||
axisOrientation.substr(0, 2) === 'en'
|
||||
? point[0] + ' ' + point[1]
|
||||
: point[1] + ' ' + point[0];
|
||||
if (opt_hasZ) {
|
||||
if (hasZ) {
|
||||
// For newly created points, Z can be undefined.
|
||||
const z = point[2] || 0;
|
||||
coords += ' ' + z;
|
||||
@@ -587,11 +585,11 @@ class GML3 extends GMLBase {
|
||||
/**
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node} Node.
|
||||
* @private
|
||||
*/
|
||||
RING_NODE_FACTORY_(value, objectStack, opt_nodeName) {
|
||||
RING_NODE_FACTORY_(value, objectStack, nodeName) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const parentNode = context.node;
|
||||
const exteriorWritten = context['exteriorWritten'];
|
||||
@@ -933,11 +931,11 @@ class GML3 extends GMLBase {
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
* @private
|
||||
*/
|
||||
MULTIGEOMETRY_MEMBER_NODE_FACTORY_(value, objectStack, opt_nodeName) {
|
||||
MULTIGEOMETRY_MEMBER_NODE_FACTORY_(value, objectStack, nodeName) {
|
||||
const parentNode = objectStack[objectStack.length - 1].node;
|
||||
return createElementNS(
|
||||
this.namespace,
|
||||
@@ -949,17 +947,16 @@ class GML3 extends GMLBase {
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Element|undefined} Node.
|
||||
* @private
|
||||
*/
|
||||
GEOMETRY_NODE_FACTORY_(value, objectStack, opt_nodeName) {
|
||||
GEOMETRY_NODE_FACTORY_(value, objectStack, nodeName) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const multiSurface = context['multiSurface'];
|
||||
const surface = context['surface'];
|
||||
const curve = context['curve'];
|
||||
const multiCurve = context['multiCurve'];
|
||||
let nodeName;
|
||||
if (!Array.isArray(value)) {
|
||||
nodeName = /** @type {import("../geom/Geometry.js").default} */ (
|
||||
value
|
||||
@@ -983,12 +980,12 @@ class GML3 extends GMLBase {
|
||||
* Encode a geometry in GML 3.1.1 Simple Features.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Node} Node.
|
||||
* @api
|
||||
*/
|
||||
writeGeometryNode(geometry, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeGeometryNode(geometry, options) {
|
||||
options = this.adaptOptions(options);
|
||||
const geom = createElementNS(this.namespace, 'geom');
|
||||
const context = {
|
||||
node: geom,
|
||||
@@ -999,8 +996,8 @@ class GML3 extends GMLBase {
|
||||
multiSurface: this.multiSurface_,
|
||||
multiCurve: this.multiCurve_,
|
||||
};
|
||||
if (opt_options) {
|
||||
Object.assign(context, opt_options);
|
||||
if (options) {
|
||||
Object.assign(context, options);
|
||||
}
|
||||
this.writeGeometryElement(geom, geometry, [context]);
|
||||
return geom;
|
||||
@@ -1010,12 +1007,12 @@ class GML3 extends GMLBase {
|
||||
* Encode an array of features in the GML 3.1.1 format as an XML node.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Element} Node.
|
||||
* @api
|
||||
*/
|
||||
writeFeaturesNode(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeaturesNode(features, options) {
|
||||
options = this.adaptOptions(options);
|
||||
const node = createElementNS(this.namespace, 'featureMembers');
|
||||
node.setAttributeNS(
|
||||
XML_SCHEMA_INSTANCE_URI,
|
||||
@@ -1032,8 +1029,8 @@ class GML3 extends GMLBase {
|
||||
featureNS: this.featureNS,
|
||||
featureType: this.featureType,
|
||||
};
|
||||
if (opt_options) {
|
||||
Object.assign(context, opt_options);
|
||||
if (options) {
|
||||
Object.assign(context, options);
|
||||
}
|
||||
this.writeFeatureMembers_(node, features, [context]);
|
||||
return node;
|
||||
@@ -1197,7 +1194,7 @@ GMLBase.prototype.RING_PARSERS = {
|
||||
*
|
||||
* @function
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {string} Result.
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,10 @@ import {writeStringTextNode} from '../format/xsd.js';
|
||||
*/
|
||||
class GML32 extends GML3 {
|
||||
/**
|
||||
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
|
||||
* @param {import("./GMLBase.js").Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = /** @type {import("./GMLBase.js").Options} */ (
|
||||
opt_options ? opt_options : {}
|
||||
);
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super(options);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const ONLY_WHITESPACE_RE = /^\s*$/;
|
||||
* So for instance there might be a featureType item `topp:states` and then
|
||||
* there will be a key named `topp` in the featureNS object with value
|
||||
* `http://www.openplans.org/topp`.
|
||||
* @property {string} srsName srsName to use when writing geometries.
|
||||
* @property {string} [srsName] srsName to use when writing geometries.
|
||||
* @property {boolean} [surface=false] Write gml:Surface instead of gml:Polygon
|
||||
* elements. This also affects the elements in multi-part geometries.
|
||||
* @property {boolean} [curve=false] Write gml:Curve instead of gml:LineString
|
||||
@@ -88,12 +88,12 @@ const ONLY_WHITESPACE_RE = /^\s*$/;
|
||||
*/
|
||||
class GMLBase extends XMLFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Optional configuration object.
|
||||
* @param {Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = /** @type {Options} */ (opt_options ? opt_options : {});
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -109,7 +109,7 @@ class GMLBase extends XMLFeature {
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {string}
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.srsName = options.srsName;
|
||||
|
||||
@@ -542,31 +542,31 @@ class GMLBase extends XMLFeature {
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromNode(node, opt_options) {
|
||||
readGeometryFromNode(node, options) {
|
||||
const geometry = this.readGeometryElement(node, [
|
||||
this.getReadOptions(node, opt_options ? opt_options : {}),
|
||||
this.getReadOptions(node, options ? options : {}),
|
||||
]);
|
||||
return geometry ? geometry : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
const options = {
|
||||
readFeaturesFromNode(node, options) {
|
||||
const internalOptions = {
|
||||
featureType: this.featureType,
|
||||
featureNS: this.featureNS,
|
||||
};
|
||||
if (opt_options) {
|
||||
Object.assign(options, this.getReadOptions(node, opt_options));
|
||||
if (internalOptions) {
|
||||
Object.assign(internalOptions, this.getReadOptions(node, options));
|
||||
}
|
||||
const features = this.readFeaturesInternal(node, [options]);
|
||||
const features = this.readFeaturesInternal(node, [internalOptions]);
|
||||
return features || [];
|
||||
}
|
||||
|
||||
|
||||
@@ -128,12 +128,12 @@ const GPX_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
*/
|
||||
class GPX extends XMLFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @type {import("../proj/Projection.js").default}
|
||||
@@ -167,10 +167,10 @@ class GPX extends XMLFeature {
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromNode(node, opt_options) {
|
||||
readFeatureFromNode(node, options) {
|
||||
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||
return null;
|
||||
}
|
||||
@@ -178,9 +178,7 @@ class GPX extends XMLFeature {
|
||||
if (!featureReader) {
|
||||
return null;
|
||||
}
|
||||
const feature = featureReader(node, [
|
||||
this.getReadOptions(node, opt_options),
|
||||
]);
|
||||
const feature = featureReader(node, [this.getReadOptions(node, options)]);
|
||||
if (!feature) {
|
||||
return null;
|
||||
}
|
||||
@@ -190,17 +188,17 @@ class GPX extends XMLFeature {
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
readFeaturesFromNode(node, options) {
|
||||
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||
return [];
|
||||
}
|
||||
if (node.localName == 'gpx') {
|
||||
/** @type {Array<Feature>} */
|
||||
const features = pushParseAndPop([], GPX_PARSERS, node, [
|
||||
this.getReadOptions(node, opt_options),
|
||||
this.getReadOptions(node, options),
|
||||
]);
|
||||
if (features) {
|
||||
this.handleReadExtensions_(features);
|
||||
@@ -218,12 +216,12 @@ class GPX extends XMLFeature {
|
||||
* as tracks (`<trk>`).
|
||||
*
|
||||
* @param {Array<Feature>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Node} Node.
|
||||
* @api
|
||||
*/
|
||||
writeFeaturesNode(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeaturesNode(features, options) {
|
||||
options = this.adaptOptions(options);
|
||||
//FIXME Serialize metadata
|
||||
const gpx = createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
|
||||
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
||||
@@ -242,7 +240,7 @@ class GPX extends XMLFeature {
|
||||
GPX_SERIALIZERS,
|
||||
GPX_NODE_FACTORY,
|
||||
features,
|
||||
[opt_options]
|
||||
[options]
|
||||
);
|
||||
return gpx;
|
||||
}
|
||||
@@ -505,10 +503,10 @@ const GEOMETRY_TYPE_TO_NODENAME = {
|
||||
/**
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
*/
|
||||
function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
|
||||
function GPX_NODE_FACTORY(value, objectStack, nodeName) {
|
||||
const geometry = /** @type {Feature} */ (value).getGeometry();
|
||||
if (geometry) {
|
||||
const nodeName = GEOMETRY_TYPE_TO_NODENAME[geometry.getType()];
|
||||
|
||||
@@ -50,10 +50,10 @@ import {transformGeometryWithOptions} from './Feature.js';
|
||||
*/
|
||||
class GeoJSON extends JSONFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super();
|
||||
|
||||
@@ -93,11 +93,11 @@ class GeoJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromObject(object, opt_options) {
|
||||
readFeatureFromObject(object, options) {
|
||||
/**
|
||||
* @type {GeoJSONFeature}
|
||||
*/
|
||||
@@ -112,7 +112,7 @@ class GeoJSON extends JSONFeature {
|
||||
};
|
||||
}
|
||||
|
||||
const geometry = readGeometry(geoJSONFeature['geometry'], opt_options);
|
||||
const geometry = readGeometry(geoJSONFeature['geometry'], options);
|
||||
const feature = new Feature();
|
||||
if (this.geometryName_) {
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
@@ -136,11 +136,11 @@ class GeoJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromObject(object, opt_options) {
|
||||
readFeaturesFromObject(object, options) {
|
||||
const geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||
/** @type {Array<import("../Feature.js").default>} */
|
||||
let features = null;
|
||||
@@ -151,24 +151,22 @@ class GeoJSON extends JSONFeature {
|
||||
features = [];
|
||||
const geoJSONFeatures = geoJSONFeatureCollection['features'];
|
||||
for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
||||
features.push(
|
||||
this.readFeatureFromObject(geoJSONFeatures[i], opt_options)
|
||||
);
|
||||
features.push(this.readFeatureFromObject(geoJSONFeatures[i], options));
|
||||
}
|
||||
} else {
|
||||
features = [this.readFeatureFromObject(object, opt_options)];
|
||||
features = [this.readFeatureFromObject(object, options)];
|
||||
}
|
||||
return features;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromObject(object, opt_options) {
|
||||
return readGeometry(object, opt_options);
|
||||
readGeometryFromObject(object, options) {
|
||||
return readGeometry(object, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,12 +195,12 @@ class GeoJSON extends JSONFeature {
|
||||
* Encode a feature as a GeoJSON Feature object.
|
||||
*
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONFeature} Object.
|
||||
* @api
|
||||
*/
|
||||
writeFeatureObject(feature, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeatureObject(feature, options) {
|
||||
options = this.adaptOptions(options);
|
||||
|
||||
/** @type {GeoJSONFeature} */
|
||||
const object = {
|
||||
@@ -223,7 +221,7 @@ class GeoJSON extends JSONFeature {
|
||||
const properties = feature.getProperties();
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
object.geometry = writeGeometry(geometry, opt_options);
|
||||
object.geometry = writeGeometry(geometry, options);
|
||||
|
||||
delete properties[feature.getGeometryName()];
|
||||
}
|
||||
@@ -239,15 +237,15 @@ class GeoJSON extends JSONFeature {
|
||||
* Encode an array of features as a GeoJSON object.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONFeatureCollection} GeoJSON Object.
|
||||
* @api
|
||||
*/
|
||||
writeFeaturesObject(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeaturesObject(features, options) {
|
||||
options = this.adaptOptions(options);
|
||||
const objects = [];
|
||||
for (let i = 0, ii = features.length; i < ii; ++i) {
|
||||
objects.push(this.writeFeatureObject(features[i], opt_options));
|
||||
objects.push(this.writeFeatureObject(features[i], options));
|
||||
}
|
||||
return {
|
||||
type: 'FeatureCollection',
|
||||
@@ -259,21 +257,21 @@ class GeoJSON extends JSONFeature {
|
||||
* Encode a geometry as a GeoJSON object.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
|
||||
* @api
|
||||
*/
|
||||
writeGeometryObject(geometry, opt_options) {
|
||||
return writeGeometry(geometry, this.adaptOptions(opt_options));
|
||||
writeGeometryObject(geometry, options) {
|
||||
return writeGeometry(geometry, this.adaptOptions(options));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
function readGeometry(object, opt_options) {
|
||||
function readGeometry(object, options) {
|
||||
if (!object) {
|
||||
return null;
|
||||
}
|
||||
@@ -325,22 +323,22 @@ function readGeometry(object, opt_options) {
|
||||
throw new Error('Unsupported GeoJSON type: ' + object['type']);
|
||||
}
|
||||
}
|
||||
return transformGeometryWithOptions(geometry, false, opt_options);
|
||||
return transformGeometryWithOptions(geometry, false, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometryCollection} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {GeometryCollection} Geometry collection.
|
||||
*/
|
||||
function readGeometryCollectionGeometry(object, opt_options) {
|
||||
function readGeometryCollectionGeometry(object, options) {
|
||||
const geometries = object['geometries'].map(
|
||||
/**
|
||||
* @param {GeoJSONGeometry} geometry Geometry.
|
||||
* @return {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
*/
|
||||
function (geometry) {
|
||||
return readGeometry(geometry, opt_options);
|
||||
return readGeometry(geometry, options);
|
||||
}
|
||||
);
|
||||
return new GeometryCollection(geometries);
|
||||
@@ -396,62 +394,59 @@ function readPolygonGeometry(object) {
|
||||
|
||||
/**
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writeGeometry(geometry, opt_options) {
|
||||
geometry = transformGeometryWithOptions(geometry, true, opt_options);
|
||||
function writeGeometry(geometry, options) {
|
||||
geometry = transformGeometryWithOptions(geometry, true, options);
|
||||
const type = geometry.getType();
|
||||
|
||||
/** @type {GeoJSONGeometry} */
|
||||
let geoJSON;
|
||||
switch (type) {
|
||||
case 'Point': {
|
||||
geoJSON = writePointGeometry(
|
||||
/** @type {Point} */ (geometry),
|
||||
opt_options
|
||||
);
|
||||
geoJSON = writePointGeometry(/** @type {Point} */ (geometry), options);
|
||||
break;
|
||||
}
|
||||
case 'LineString': {
|
||||
geoJSON = writeLineStringGeometry(
|
||||
/** @type {LineString} */ (geometry),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'Polygon': {
|
||||
geoJSON = writePolygonGeometry(
|
||||
/** @type {Polygon} */ (geometry),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'MultiPoint': {
|
||||
geoJSON = writeMultiPointGeometry(
|
||||
/** @type {MultiPoint} */ (geometry),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'MultiLineString': {
|
||||
geoJSON = writeMultiLineStringGeometry(
|
||||
/** @type {MultiLineString} */ (geometry),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'MultiPolygon': {
|
||||
geoJSON = writeMultiPolygonGeometry(
|
||||
/** @type {MultiPolygon} */ (geometry),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'GeometryCollection': {
|
||||
geoJSON = writeGeometryCollectionGeometry(
|
||||
/** @type {GeometryCollection} */ (geometry),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -471,13 +466,13 @@ function writeGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {GeometryCollection} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
|
||||
*/
|
||||
function writeGeometryCollectionGeometry(geometry, opt_options) {
|
||||
function writeGeometryCollectionGeometry(geometry, options) {
|
||||
options = Object.assign({}, options);
|
||||
delete options.featureProjection;
|
||||
const geometries = geometry.getGeometriesArray().map(function (geometry) {
|
||||
const options = Object.assign({}, opt_options);
|
||||
delete options.featureProjection;
|
||||
return writeGeometry(geometry, options);
|
||||
});
|
||||
return {
|
||||
@@ -488,10 +483,10 @@ function writeGeometryCollectionGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {LineString} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writeLineStringGeometry(geometry, opt_options) {
|
||||
function writeLineStringGeometry(geometry, options) {
|
||||
return {
|
||||
type: 'LineString',
|
||||
coordinates: geometry.getCoordinates(),
|
||||
@@ -500,10 +495,10 @@ function writeLineStringGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {MultiLineString} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writeMultiLineStringGeometry(geometry, opt_options) {
|
||||
function writeMultiLineStringGeometry(geometry, options) {
|
||||
return {
|
||||
type: 'MultiLineString',
|
||||
coordinates: geometry.getCoordinates(),
|
||||
@@ -512,10 +507,10 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {MultiPoint} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writeMultiPointGeometry(geometry, opt_options) {
|
||||
function writeMultiPointGeometry(geometry, options) {
|
||||
return {
|
||||
type: 'MultiPoint',
|
||||
coordinates: geometry.getCoordinates(),
|
||||
@@ -524,13 +519,13 @@ function writeMultiPointGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {MultiPolygon} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writeMultiPolygonGeometry(geometry, opt_options) {
|
||||
function writeMultiPolygonGeometry(geometry, options) {
|
||||
let right;
|
||||
if (opt_options) {
|
||||
right = opt_options.rightHanded;
|
||||
if (options) {
|
||||
right = options.rightHanded;
|
||||
}
|
||||
return {
|
||||
type: 'MultiPolygon',
|
||||
@@ -540,10 +535,10 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {Point} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writePointGeometry(geometry, opt_options) {
|
||||
function writePointGeometry(geometry, options) {
|
||||
return {
|
||||
type: 'Point',
|
||||
coordinates: geometry.getCoordinates(),
|
||||
@@ -552,13 +547,13 @@ function writePointGeometry(geometry, opt_options) {
|
||||
|
||||
/**
|
||||
* @param {Polygon} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {GeoJSONGeometry} GeoJSON geometry.
|
||||
*/
|
||||
function writePolygonGeometry(geometry, opt_options) {
|
||||
function writePolygonGeometry(geometry, options) {
|
||||
let right;
|
||||
if (opt_options) {
|
||||
right = opt_options.rightHanded;
|
||||
if (options) {
|
||||
right = options.rightHanded;
|
||||
}
|
||||
return {
|
||||
type: 'Polygon',
|
||||
|
||||
@@ -57,12 +57,12 @@ const NEWLINE_RE = /\r\n|\r|\n/;
|
||||
*/
|
||||
class IGC extends TextFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @type {import("../proj/Projection.js").default}
|
||||
@@ -79,10 +79,10 @@ class IGC extends TextFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromText(text, opt_options) {
|
||||
readFeatureFromText(text, options) {
|
||||
const altitudeMode = this.altitudeMode_;
|
||||
const lines = text.split(NEWLINE_RE);
|
||||
/** @type {Object<string, string>} */
|
||||
@@ -150,7 +150,7 @@ class IGC extends TextFeature {
|
||||
const layout = altitudeMode == 'none' ? 'XYM' : 'XYZM';
|
||||
const lineString = new LineString(flatCoordinates, layout);
|
||||
const feature = new Feature(
|
||||
transformGeometryWithOptions(lineString, false, opt_options)
|
||||
transformGeometryWithOptions(lineString, false, options)
|
||||
);
|
||||
feature.setProperties(properties, true);
|
||||
return feature;
|
||||
@@ -158,12 +158,12 @@ class IGC extends TextFeature {
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromText(text, opt_options) {
|
||||
const feature = this.readFeatureFromText(text, opt_options);
|
||||
readFeaturesFromText(text, options) {
|
||||
const feature = this.readFeatureFromText(text, options);
|
||||
if (feature) {
|
||||
return [feature];
|
||||
} else {
|
||||
|
||||
@@ -437,12 +437,12 @@ class IIIFInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PreferredOptions} [opt_preferredOptions] Optional options for preferred format and quality.
|
||||
* @param {PreferredOptions} [preferredOptions] Optional options for preferred format and quality.
|
||||
* @return {import("../source/IIIF.js").Options} IIIF tile source ready constructor options.
|
||||
* @api
|
||||
*/
|
||||
getTileSourceOptions(opt_preferredOptions) {
|
||||
const options = opt_preferredOptions || {},
|
||||
getTileSourceOptions(preferredOptions) {
|
||||
const options = preferredOptions || {},
|
||||
version = this.getImageApiVersion();
|
||||
if (version === undefined) {
|
||||
return;
|
||||
|
||||
@@ -29,14 +29,14 @@ class JSONFeature extends FeatureFormat {
|
||||
* read a feature collection.
|
||||
*
|
||||
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
* @api
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
readFeature(source, options) {
|
||||
return this.readFeatureFromObject(
|
||||
getObject(source),
|
||||
this.getReadOptions(source, opt_options)
|
||||
this.getReadOptions(source, options)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,36 +45,36 @@ class JSONFeature extends FeatureFormat {
|
||||
* collection.
|
||||
*
|
||||
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
* @api
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
readFeatures(source, options) {
|
||||
return this.readFeaturesFromObject(
|
||||
getObject(source),
|
||||
this.getReadOptions(source, opt_options)
|
||||
this.getReadOptions(source, options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromObject(object, opt_options) {
|
||||
readFeatureFromObject(object, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromObject(object, opt_options) {
|
||||
readFeaturesFromObject(object, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -82,25 +82,25 @@ class JSONFeature extends FeatureFormat {
|
||||
* Read a geometry.
|
||||
*
|
||||
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
* @api
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
readGeometry(source, options) {
|
||||
return this.readGeometryFromObject(
|
||||
getObject(source),
|
||||
this.getReadOptions(source, opt_options)
|
||||
this.getReadOptions(source, options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromObject(object, opt_options) {
|
||||
readGeometryFromObject(object, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -129,21 +129,21 @@ class JSONFeature extends FeatureFormat {
|
||||
* Encode a feature as string.
|
||||
*
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded feature.
|
||||
* @api
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
return JSON.stringify(this.writeFeatureObject(feature, opt_options));
|
||||
writeFeature(feature, options) {
|
||||
return JSON.stringify(this.writeFeatureObject(feature, options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
writeFeatureObject(feature, opt_options) {
|
||||
writeFeatureObject(feature, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -151,21 +151,21 @@ class JSONFeature extends FeatureFormat {
|
||||
* Encode an array of features as string.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded features.
|
||||
* @api
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
return JSON.stringify(this.writeFeaturesObject(features, opt_options));
|
||||
writeFeatures(features, options) {
|
||||
return JSON.stringify(this.writeFeaturesObject(features, options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
writeFeaturesObject(features, opt_options) {
|
||||
writeFeaturesObject(features, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -173,21 +173,21 @@ class JSONFeature extends FeatureFormat {
|
||||
* Encode a geometry as string.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded geometry.
|
||||
* @api
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
return JSON.stringify(this.writeGeometryObject(geometry, opt_options));
|
||||
writeGeometry(geometry, options) {
|
||||
return JSON.stringify(this.writeGeometryObject(geometry, options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
writeGeometryObject(geometry, opt_options) {
|
||||
writeGeometryObject(geometry, options) {
|
||||
return abstract();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,12 +423,12 @@ function defaultIconUrlFunction(href) {
|
||||
*/
|
||||
class KML extends XMLFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
if (!DEFAULT_STYLE_ARRAY) {
|
||||
createStyleDefaults();
|
||||
@@ -624,15 +624,15 @@ class KML extends XMLFeature {
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromNode(node, opt_options) {
|
||||
readFeatureFromNode(node, options) {
|
||||
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||
return null;
|
||||
}
|
||||
const feature = this.readPlacemark_(node, [
|
||||
this.getReadOptions(node, opt_options),
|
||||
this.getReadOptions(node, options),
|
||||
]);
|
||||
if (feature) {
|
||||
return feature;
|
||||
@@ -644,10 +644,10 @@ class KML extends XMLFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
readFeaturesFromNode(node, options) {
|
||||
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||
return [];
|
||||
}
|
||||
@@ -655,7 +655,7 @@ class KML extends XMLFeature {
|
||||
const localName = node.localName;
|
||||
if (localName == 'Document' || localName == 'Folder') {
|
||||
features = this.readDocumentOrFolder_(node, [
|
||||
this.getReadOptions(node, opt_options),
|
||||
this.getReadOptions(node, options),
|
||||
]);
|
||||
if (features) {
|
||||
return features;
|
||||
@@ -664,7 +664,7 @@ class KML extends XMLFeature {
|
||||
}
|
||||
} else if (localName == 'Placemark') {
|
||||
const feature = this.readPlacemark_(node, [
|
||||
this.getReadOptions(node, opt_options),
|
||||
this.getReadOptions(node, options),
|
||||
]);
|
||||
if (feature) {
|
||||
return [feature];
|
||||
@@ -674,7 +674,7 @@ class KML extends XMLFeature {
|
||||
} else if (localName == 'kml') {
|
||||
features = [];
|
||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||
const fs = this.readFeaturesFromNode(n, opt_options);
|
||||
const fs = this.readFeaturesFromNode(n, options);
|
||||
if (fs) {
|
||||
extend(features, fs);
|
||||
}
|
||||
@@ -886,12 +886,12 @@ class KML extends XMLFeature {
|
||||
* MultiPoints, MultiLineStrings, and MultiPolygons are output as MultiGeometries.
|
||||
*
|
||||
* @param {Array<Feature>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Node} Node.
|
||||
* @api
|
||||
*/
|
||||
writeFeaturesNode(features, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
writeFeaturesNode(features, options) {
|
||||
options = this.adaptOptions(options);
|
||||
const kml = createElementNS(NAMESPACE_URIS[4], 'kml');
|
||||
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
||||
kml.setAttributeNS(xmlnsUri, 'xmlns:gx', GX_NAMESPACE_URIS[0]);
|
||||
@@ -919,7 +919,7 @@ class KML extends XMLFeature {
|
||||
KML_SERIALIZERS,
|
||||
OBJECT_PROPERTY_NODE_FACTORY,
|
||||
values,
|
||||
[opt_options],
|
||||
[options],
|
||||
orderedKeys,
|
||||
this
|
||||
);
|
||||
@@ -2444,10 +2444,10 @@ const DOCUMENT_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
*/
|
||||
const DOCUMENT_NODE_FACTORY = function (value, objectStack, opt_nodeName) {
|
||||
const DOCUMENT_NODE_FACTORY = function (value, objectStack, nodeName) {
|
||||
const parentNode = objectStack[objectStack.length - 1].node;
|
||||
return createElementNS(parentNode.namespaceURI, 'Placemark');
|
||||
};
|
||||
@@ -2533,11 +2533,11 @@ const ICON_SERIALIZERS = makeStructureNS(
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
*/
|
||||
const GX_NODE_FACTORY = function (value, objectStack, opt_nodeName) {
|
||||
return createElementNS(GX_NAMESPACE_URIS[0], 'gx:' + opt_nodeName);
|
||||
const GX_NODE_FACTORY = function (value, objectStack, nodeName) {
|
||||
return createElementNS(GX_NAMESPACE_URIS[0], 'gx:' + nodeName);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2780,10 +2780,10 @@ const GEOMETRY_TYPE_TO_NODENAME = {
|
||||
* @const
|
||||
* @param {*} value Value.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @param {string} [opt_nodeName] Node name.
|
||||
* @param {string} [nodeName] Node name.
|
||||
* @return {Node|undefined} Node.
|
||||
*/
|
||||
const GEOMETRY_NODE_FACTORY = function (value, objectStack, opt_nodeName) {
|
||||
const GEOMETRY_NODE_FACTORY = function (value, objectStack, nodeName) {
|
||||
if (value) {
|
||||
const parentNode = objectStack[objectStack.length - 1].node;
|
||||
return createElementNS(
|
||||
|
||||
@@ -34,17 +34,17 @@ import {inflateEnds} from '../geom/flat/orient.js';
|
||||
* @classdesc
|
||||
* Feature format for reading data in the Mapbox MVT format.
|
||||
*
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
* @api
|
||||
*/
|
||||
class MVT extends FeatureFormat {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @type {Projection}
|
||||
@@ -245,15 +245,13 @@ class MVT extends FeatureFormat {
|
||||
* Read all features.
|
||||
*
|
||||
* @param {ArrayBuffer} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {Array<import("../Feature.js").FeatureLike>} Features.
|
||||
* @api
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
readFeatures(source, options) {
|
||||
const layers = this.layers_;
|
||||
const options = /** @type {import("./Feature.js").ReadOptions} */ (
|
||||
this.adaptOptions(opt_options)
|
||||
);
|
||||
options = this.adaptOptions(options);
|
||||
const dataProjection = get(options.dataProjection);
|
||||
dataProjection.setWorldExtent(options.extent);
|
||||
options.dataProjection = dataProjection;
|
||||
|
||||
@@ -59,11 +59,11 @@ class OSMXML extends XMLFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
const options = this.getReadOptions(node, opt_options);
|
||||
readFeaturesFromNode(node, options) {
|
||||
options = this.getReadOptions(node, options);
|
||||
if (node.localName == 'osm') {
|
||||
const state = pushParseAndPop(
|
||||
{
|
||||
|
||||
@@ -34,12 +34,12 @@ import {transformGeometryWithOptions} from './Feature.js';
|
||||
*/
|
||||
class Polyline extends TextFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Optional configuration object.
|
||||
* @param {Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @type {import("../proj/Projection.js").default}
|
||||
@@ -64,32 +64,32 @@ class Polyline extends TextFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromText(text, opt_options) {
|
||||
const geometry = this.readGeometryFromText(text, opt_options);
|
||||
readFeatureFromText(text, options) {
|
||||
const geometry = this.readGeometryFromText(text, options);
|
||||
return new Feature(geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromText(text, opt_options) {
|
||||
const feature = this.readFeatureFromText(text, opt_options);
|
||||
readFeaturesFromText(text, options) {
|
||||
const feature = this.readFeatureFromText(text, options);
|
||||
return [feature];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromText(text, opt_options) {
|
||||
readGeometryFromText(text, options) {
|
||||
const stride = getStrideForLayout(this.geometryLayout_);
|
||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
@@ -104,20 +104,20 @@ class Polyline extends TextFeature {
|
||||
return transformGeometryWithOptions(
|
||||
lineString,
|
||||
false,
|
||||
this.adaptOptions(opt_options)
|
||||
this.adaptOptions(options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../Feature.js").default<LineString>} feature Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeatureText(feature, opt_options) {
|
||||
writeFeatureText(feature, options) {
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
return this.writeGeometryText(geometry, opt_options);
|
||||
return this.writeGeometryText(geometry, options);
|
||||
} else {
|
||||
assert(false, 40); // Expected `feature` to have a geometry
|
||||
return '';
|
||||
@@ -126,29 +126,25 @@ class Polyline extends TextFeature {
|
||||
|
||||
/**
|
||||
* @param {Array<import("../Feature.js").default<LineString>>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeaturesText(features, opt_options) {
|
||||
return this.writeFeatureText(features[0], opt_options);
|
||||
writeFeaturesText(features, options) {
|
||||
return this.writeFeatureText(features[0], options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {LineString} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeGeometryText(geometry, opt_options) {
|
||||
writeGeometryText(geometry, options) {
|
||||
geometry =
|
||||
/** @type {LineString} */
|
||||
(
|
||||
transformGeometryWithOptions(
|
||||
geometry,
|
||||
true,
|
||||
this.adaptOptions(opt_options)
|
||||
)
|
||||
transformGeometryWithOptions(geometry, true, this.adaptOptions(options))
|
||||
);
|
||||
const flatCoordinates = geometry.getFlatCoordinates();
|
||||
const stride = geometry.getStride();
|
||||
@@ -164,14 +160,14 @@ class Polyline extends TextFeature {
|
||||
*
|
||||
* @param {Array<number>} numbers A list of n-dimensional points.
|
||||
* @param {number} stride The number of dimension of the points in the list.
|
||||
* @param {number} [opt_factor] The factor by which the numbers will be
|
||||
* @param {number} [factor] The factor by which the numbers will be
|
||||
* multiplied. The remaining decimal places will get rounded away.
|
||||
* Default is `1e5`.
|
||||
* @return {string} The encoded string.
|
||||
* @api
|
||||
*/
|
||||
export function encodeDeltas(numbers, stride, opt_factor) {
|
||||
const factor = opt_factor ? opt_factor : 1e5;
|
||||
export function encodeDeltas(numbers, stride, factor) {
|
||||
factor = factor ? factor : 1e5;
|
||||
let d;
|
||||
|
||||
const lastNumbers = new Array(stride);
|
||||
@@ -198,13 +194,13 @@ export function encodeDeltas(numbers, stride, opt_factor) {
|
||||
* @param {string} encoded An encoded string.
|
||||
* @param {number} stride The number of dimension of the points in the
|
||||
* encoded string.
|
||||
* @param {number} [opt_factor] The factor by which the resulting numbers will
|
||||
* @param {number} [factor] The factor by which the resulting numbers will
|
||||
* be divided. Default is `1e5`.
|
||||
* @return {Array<number>} A list of n-dimensional points.
|
||||
* @api
|
||||
*/
|
||||
export function decodeDeltas(encoded, stride, opt_factor) {
|
||||
const factor = opt_factor ? opt_factor : 1e5;
|
||||
export function decodeDeltas(encoded, stride, factor) {
|
||||
factor = factor ? factor : 1e5;
|
||||
let d;
|
||||
|
||||
/** @type {Array<number>} */
|
||||
@@ -232,14 +228,14 @@ export function decodeDeltas(encoded, stride, opt_factor) {
|
||||
* Attention: This function will modify the passed array!
|
||||
*
|
||||
* @param {Array<number>} numbers A list of floating point numbers.
|
||||
* @param {number} [opt_factor] The factor by which the numbers will be
|
||||
* @param {number} [factor] The factor by which the numbers will be
|
||||
* multiplied. The remaining decimal places will get rounded away.
|
||||
* Default is `1e5`.
|
||||
* @return {string} The encoded string.
|
||||
* @api
|
||||
*/
|
||||
export function encodeFloats(numbers, opt_factor) {
|
||||
const factor = opt_factor ? opt_factor : 1e5;
|
||||
export function encodeFloats(numbers, factor) {
|
||||
factor = factor ? factor : 1e5;
|
||||
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||
numbers[i] = Math.round(numbers[i] * factor);
|
||||
}
|
||||
@@ -251,13 +247,13 @@ export function encodeFloats(numbers, opt_factor) {
|
||||
* Decode a list of floating point numbers from an encoded string
|
||||
*
|
||||
* @param {string} encoded An encoded string.
|
||||
* @param {number} [opt_factor] The factor by which the result will be divided.
|
||||
* @param {number} [factor] The factor by which the result will be divided.
|
||||
* Default is `1e5`.
|
||||
* @return {Array<number>} A list of floating point numbers.
|
||||
* @api
|
||||
*/
|
||||
export function decodeFloats(encoded, opt_factor) {
|
||||
const factor = opt_factor ? opt_factor : 1e5;
|
||||
export function decodeFloats(encoded, factor) {
|
||||
factor = factor ? factor : 1e5;
|
||||
const numbers = decodeSignedIntegers(encoded);
|
||||
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||
numbers[i] /= factor;
|
||||
|
||||
@@ -28,25 +28,25 @@ class TextFeature extends FeatureFormat {
|
||||
* Read the feature from the source.
|
||||
*
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
* @api
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
readFeature(source, options) {
|
||||
return this.readFeatureFromText(
|
||||
getText(source),
|
||||
this.adaptOptions(opt_options)
|
||||
this.adaptOptions(options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromText(text, opt_options) {
|
||||
readFeatureFromText(text, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -54,25 +54,25 @@ class TextFeature extends FeatureFormat {
|
||||
* Read the features from the source.
|
||||
*
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
* @api
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
readFeatures(source, options) {
|
||||
return this.readFeaturesFromText(
|
||||
getText(source),
|
||||
this.adaptOptions(opt_options)
|
||||
this.adaptOptions(options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromText(text, opt_options) {
|
||||
readFeaturesFromText(text, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -80,25 +80,25 @@ class TextFeature extends FeatureFormat {
|
||||
* Read the geometry from the source.
|
||||
*
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
* @api
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
readGeometry(source, options) {
|
||||
return this.readGeometryFromText(
|
||||
getText(source),
|
||||
this.adaptOptions(opt_options)
|
||||
this.adaptOptions(options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromText(text, opt_options) {
|
||||
readGeometryFromText(text, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -126,22 +126,22 @@ class TextFeature extends FeatureFormat {
|
||||
* Encode a feature as a string.
|
||||
*
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded feature.
|
||||
* @api
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
|
||||
writeFeature(feature, options) {
|
||||
return this.writeFeatureText(feature, this.adaptOptions(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {import("../Feature.js").default} feature Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeatureText(feature, opt_options) {
|
||||
writeFeatureText(feature, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -149,22 +149,22 @@ class TextFeature extends FeatureFormat {
|
||||
* Encode an array of features as string.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded features.
|
||||
* @api
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
|
||||
writeFeatures(features, options) {
|
||||
return this.writeFeaturesText(features, this.adaptOptions(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeaturesText(features, opt_options) {
|
||||
writeFeaturesText(features, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -172,22 +172,22 @@ class TextFeature extends FeatureFormat {
|
||||
* Write a single geometry.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Geometry.
|
||||
* @api
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
|
||||
writeGeometry(geometry, options) {
|
||||
return this.writeGeometryText(geometry, this.adaptOptions(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeGeometryText(geometry, opt_options) {
|
||||
writeGeometryText(geometry, options) {
|
||||
return abstract();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +56,12 @@ import {transformGeometryWithOptions} from './Feature.js';
|
||||
*/
|
||||
class TopoJSON extends JSONFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -85,11 +85,11 @@ class TopoJSON extends JSONFeature {
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromObject(object, opt_options) {
|
||||
readFeaturesFromObject(object, options) {
|
||||
if (object.type == 'Topology') {
|
||||
const topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
|
||||
let transform,
|
||||
@@ -126,7 +126,7 @@ class TopoJSON extends JSONFeature {
|
||||
translate,
|
||||
property,
|
||||
objectName,
|
||||
opt_options
|
||||
options
|
||||
)
|
||||
);
|
||||
} else {
|
||||
@@ -141,7 +141,7 @@ class TopoJSON extends JSONFeature {
|
||||
translate,
|
||||
property,
|
||||
objectName,
|
||||
opt_options
|
||||
options
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -319,7 +319,7 @@ function readMultiPolygonGeometry(object, arcs) {
|
||||
* @param {string|undefined} property Property to set the `GeometryCollection`'s parent
|
||||
* object to.
|
||||
* @param {string} name Name of the `Topology`'s child object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {Array<Feature>} Array of features.
|
||||
*/
|
||||
function readFeaturesFromGeometryCollection(
|
||||
@@ -329,7 +329,7 @@ function readFeaturesFromGeometryCollection(
|
||||
translate,
|
||||
property,
|
||||
name,
|
||||
opt_options
|
||||
options
|
||||
) {
|
||||
const geometries = collection['geometries'];
|
||||
const features = [];
|
||||
@@ -341,7 +341,7 @@ function readFeaturesFromGeometryCollection(
|
||||
translate,
|
||||
property,
|
||||
name,
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
}
|
||||
return features;
|
||||
@@ -357,7 +357,7 @@ function readFeaturesFromGeometryCollection(
|
||||
* @param {string|undefined} property Property to set the `GeometryCollection`'s parent
|
||||
* object to.
|
||||
* @param {string} name Name of the `Topology`'s child object.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {Feature} Feature.
|
||||
*/
|
||||
function readFeatureFromGeometry(
|
||||
@@ -367,7 +367,7 @@ function readFeatureFromGeometry(
|
||||
translate,
|
||||
property,
|
||||
name,
|
||||
opt_options
|
||||
options
|
||||
) {
|
||||
let geometry = null;
|
||||
const type = object.type;
|
||||
@@ -378,7 +378,7 @@ function readFeatureFromGeometry(
|
||||
} else {
|
||||
geometry = geometryReader(object, arcs);
|
||||
}
|
||||
geometry = transformGeometryWithOptions(geometry, false, opt_options);
|
||||
geometry = transformGeometryWithOptions(geometry, false, options);
|
||||
}
|
||||
const feature = new Feature({geometry: geometry});
|
||||
if (object.id !== undefined) {
|
||||
|
||||
@@ -265,12 +265,12 @@ const DEFAULT_VERSION = '1.1.0';
|
||||
*/
|
||||
class WFS extends XMLFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Optional configuration object.
|
||||
* @param {Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -324,10 +324,10 @@ class WFS extends XMLFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
readFeaturesFromNode(node, options) {
|
||||
/** @type {import("../xml.js").NodeStackItem} */
|
||||
const context = {
|
||||
node,
|
||||
@@ -337,10 +337,7 @@ class WFS extends XMLFeature {
|
||||
'featureNS': this.featureNS_,
|
||||
});
|
||||
|
||||
Object.assign(
|
||||
context,
|
||||
this.getReadOptions(node, opt_options ? opt_options : {})
|
||||
);
|
||||
Object.assign(context, this.getReadOptions(node, options ? options : {}));
|
||||
const objectStack = [context];
|
||||
let featuresNS;
|
||||
if (this.version_ === '2.0.0') {
|
||||
@@ -565,16 +562,16 @@ class WFS extends XMLFeature {
|
||||
*
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../extent.js").Extent} extent Extent.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @param {import("./filter/Filter.js").default} [opt_filter] Filter condition.
|
||||
* @param {import("./filter/Filter.js").default} [filter] Filter condition.
|
||||
* @return {import("./filter/Filter.js").default} The filter.
|
||||
*/
|
||||
combineBboxAndFilter(geometryName, extent, opt_srsName, opt_filter) {
|
||||
const bboxFilter = bboxFilterFn(geometryName, extent, opt_srsName);
|
||||
if (opt_filter) {
|
||||
combineBboxAndFilter(geometryName, extent, srsName, filter) {
|
||||
const bboxFilter = bboxFilterFn(geometryName, extent, srsName);
|
||||
if (filter) {
|
||||
// if bbox and filter are both set, combine the two into a single filter
|
||||
return andFilterFn(opt_filter, bboxFilter);
|
||||
return andFilterFn(filter, bboxFilter);
|
||||
}
|
||||
return bboxFilter;
|
||||
}
|
||||
@@ -1324,12 +1321,12 @@ function writeTimeInstant(node, time) {
|
||||
* Encode filter as WFS `Filter` and return the Node.
|
||||
*
|
||||
* @param {import("./filter/Filter.js").default} filter Filter.
|
||||
* @param {string} opt_version WFS version. If not provided defaults to '1.1.0'
|
||||
* @param {string} version WFS version. If not provided defaults to '1.1.0'
|
||||
* @return {Node} Result.
|
||||
* @api
|
||||
*/
|
||||
export function writeFilter(filter, opt_version) {
|
||||
const version = opt_version || '1.1.0';
|
||||
export function writeFilter(filter, version) {
|
||||
version = version || '1.1.0';
|
||||
const child = createElementNS(getFilterNS(version), 'Filter');
|
||||
const context = {
|
||||
node: child,
|
||||
|
||||
@@ -700,12 +700,12 @@ class WkbWriter {
|
||||
*/
|
||||
class WKB extends FeatureFormat {
|
||||
/**
|
||||
* @param {Options} [opt_options] Optional configuration object.
|
||||
* @param {Options} [options] Optional configuration object.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
this.splitCollection = Boolean(options.splitCollection);
|
||||
|
||||
@@ -733,13 +733,13 @@ class WKB extends FeatureFormat {
|
||||
* Read a single feature from a source.
|
||||
*
|
||||
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
* @api
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
readFeature(source, options) {
|
||||
return new Feature({
|
||||
geometry: this.readGeometry(source, opt_options),
|
||||
geometry: this.readGeometry(source, options),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -747,13 +747,13 @@ class WKB extends FeatureFormat {
|
||||
* Read all features from a source.
|
||||
*
|
||||
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
* @api
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
readFeatures(source, options) {
|
||||
let geometries = [];
|
||||
const geometry = this.readGeometry(source, opt_options);
|
||||
const geometry = this.readGeometry(source, options);
|
||||
if (this.splitCollection && geometry instanceof GeometryCollection) {
|
||||
geometries = geometry.getGeometriesArray();
|
||||
} else {
|
||||
@@ -766,11 +766,11 @@ class WKB extends FeatureFormat {
|
||||
* Read a single geometry from a source.
|
||||
*
|
||||
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
* @api
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
readGeometry(source, options) {
|
||||
const view = getDataView(source);
|
||||
if (!view) {
|
||||
return null;
|
||||
@@ -780,7 +780,7 @@ class WKB extends FeatureFormat {
|
||||
const geometry = reader.readGeometry();
|
||||
|
||||
this.viewCache_ = view; // cache for internal subsequent call of readProjection()
|
||||
const options = this.getReadOptions(source, opt_options);
|
||||
options = this.getReadOptions(source, options);
|
||||
this.viewCache_ = null; // release
|
||||
|
||||
return transformGeometryWithOptions(geometry, false, options);
|
||||
@@ -812,26 +812,26 @@ class WKB extends FeatureFormat {
|
||||
* Encode a feature in this format.
|
||||
*
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string|ArrayBuffer} Result.
|
||||
* @api
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
return this.writeGeometry(feature.getGeometry(), opt_options);
|
||||
writeFeature(feature, options) {
|
||||
return this.writeGeometry(feature.getGeometry(), options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode an array of features in this format.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string|ArrayBuffer} Result.
|
||||
* @api
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
writeFeatures(features, options) {
|
||||
return this.writeGeometry(
|
||||
new GeometryCollection(features.map((f) => f.getGeometry())),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
@@ -839,12 +839,12 @@ class WKB extends FeatureFormat {
|
||||
* Write a single geometry in this format.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string|ArrayBuffer} Result.
|
||||
* @api
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
const options = this.adaptOptions(opt_options);
|
||||
writeGeometry(geometry, options) {
|
||||
options = this.adaptOptions(options);
|
||||
|
||||
const writer = new WkbWriter({
|
||||
layout: this.layout_,
|
||||
|
||||
@@ -121,13 +121,13 @@ class Lexer {
|
||||
|
||||
/**
|
||||
* @param {string} c Character.
|
||||
* @param {boolean} [opt_decimal] Whether the string number
|
||||
* @param {boolean} [decimal] Whether the string number
|
||||
* contains a dot, i.e. is a decimal number.
|
||||
* @return {boolean} Whether the character is numeric.
|
||||
* @private
|
||||
*/
|
||||
isNumeric_(c, opt_decimal) {
|
||||
const decimal = opt_decimal !== undefined ? opt_decimal : false;
|
||||
isNumeric_(c, decimal) {
|
||||
decimal = decimal !== undefined ? decimal : false;
|
||||
return (c >= '0' && c <= '9') || (c == '.' && !decimal);
|
||||
}
|
||||
|
||||
@@ -601,12 +601,12 @@ class Parser {
|
||||
*/
|
||||
class WKT extends TextFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* Split GeometryCollection into multiple features.
|
||||
@@ -633,11 +633,11 @@ class WKT extends TextFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromText(text, opt_options) {
|
||||
const geom = this.readGeometryFromText(text, opt_options);
|
||||
readFeatureFromText(text, options) {
|
||||
const geom = this.readGeometryFromText(text, options);
|
||||
const feature = new Feature();
|
||||
feature.setGeometry(geom);
|
||||
return feature;
|
||||
@@ -645,13 +645,13 @@ class WKT extends TextFeature {
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {Array<Feature>} Features.
|
||||
*/
|
||||
readFeaturesFromText(text, opt_options) {
|
||||
readFeaturesFromText(text, options) {
|
||||
let geometries = [];
|
||||
const geometry = this.readGeometryFromText(text, opt_options);
|
||||
const geometry = this.readGeometryFromText(text, options);
|
||||
if (this.splitCollection_ && geometry.getType() == 'GeometryCollection') {
|
||||
geometries = /** @type {GeometryCollection} */ (
|
||||
geometry
|
||||
@@ -670,55 +670,55 @@ class WKT extends TextFeature {
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromText(text, opt_options) {
|
||||
readGeometryFromText(text, options) {
|
||||
const geometry = this.parse_(text);
|
||||
return transformGeometryWithOptions(geometry, false, opt_options);
|
||||
return transformGeometryWithOptions(geometry, false, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../Feature.js").default} feature Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeatureText(feature, opt_options) {
|
||||
writeFeatureText(feature, options) {
|
||||
const geometry = feature.getGeometry();
|
||||
if (geometry) {
|
||||
return this.writeGeometryText(geometry, opt_options);
|
||||
return this.writeGeometryText(geometry, options);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeFeaturesText(features, opt_options) {
|
||||
writeFeaturesText(features, options) {
|
||||
if (features.length == 1) {
|
||||
return this.writeFeatureText(features[0], opt_options);
|
||||
return this.writeFeatureText(features[0], options);
|
||||
}
|
||||
const geometries = [];
|
||||
for (let i = 0, ii = features.length; i < ii; ++i) {
|
||||
geometries.push(features[i].getGeometry());
|
||||
}
|
||||
const collection = new GeometryCollection(geometries);
|
||||
return this.writeGeometryText(collection, opt_options);
|
||||
return this.writeGeometryText(collection, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeGeometryText(geometry, opt_options) {
|
||||
return encode(transformGeometryWithOptions(geometry, true, opt_options));
|
||||
writeGeometryText(geometry, options) {
|
||||
return encode(transformGeometryWithOptions(geometry, true, options));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ const layerIdentifier = '_layer';
|
||||
*/
|
||||
class WMSGetFeatureInfo extends XMLFeature {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -150,15 +150,15 @@ class WMSGetFeatureInfo extends XMLFeature {
|
||||
/**
|
||||
* @protected
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
const options = {};
|
||||
if (opt_options) {
|
||||
Object.assign(options, this.getReadOptions(node, opt_options));
|
||||
readFeaturesFromNode(node, options) {
|
||||
const internalOptions = {};
|
||||
if (options) {
|
||||
Object.assign(internalOptions, this.getReadOptions(node, options));
|
||||
}
|
||||
return this.readFeatures_(node, [options]);
|
||||
return this.readFeatures_(node, [internalOptions]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,36 +36,33 @@ class XMLFeature extends FeatureFormat {
|
||||
* Read a single feature.
|
||||
*
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
* @api
|
||||
*/
|
||||
readFeature(source, opt_options) {
|
||||
readFeature(source, options) {
|
||||
if (!source) {
|
||||
return null;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFeatureFromDocument(doc, opt_options);
|
||||
return this.readFeatureFromDocument(doc, options);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readFeatureFromDocument(
|
||||
/** @type {Document} */ (source),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
} else {
|
||||
return this.readFeatureFromNode(
|
||||
/** @type {Element} */ (source),
|
||||
opt_options
|
||||
);
|
||||
return this.readFeatureFromNode(/** @type {Element} */ (source), options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromDocument(doc, opt_options) {
|
||||
const features = this.readFeaturesFromDocument(doc, opt_options);
|
||||
readFeatureFromDocument(doc, options) {
|
||||
const features = this.readFeaturesFromDocument(doc, options);
|
||||
if (features.length > 0) {
|
||||
return features[0];
|
||||
} else {
|
||||
@@ -75,10 +72,10 @@ class XMLFeature extends FeatureFormat {
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {import("../Feature.js").default} Feature.
|
||||
*/
|
||||
readFeatureFromNode(node, opt_options) {
|
||||
readFeatureFromNode(node, options) {
|
||||
return null; // not implemented
|
||||
}
|
||||
|
||||
@@ -86,43 +83,43 @@ class XMLFeature extends FeatureFormat {
|
||||
* Read all features from a feature collection.
|
||||
*
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
* @api
|
||||
*/
|
||||
readFeatures(source, opt_options) {
|
||||
readFeatures(source, options) {
|
||||
if (!source) {
|
||||
return [];
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readFeaturesFromDocument(doc, opt_options);
|
||||
return this.readFeaturesFromDocument(doc, options);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readFeaturesFromDocument(
|
||||
/** @type {Document} */ (source),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
} else {
|
||||
return this.readFeaturesFromNode(
|
||||
/** @type {Element} */ (source),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @protected
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromDocument(doc, opt_options) {
|
||||
readFeaturesFromDocument(doc, options) {
|
||||
/** @type {Array<import("../Feature.js").default>} */
|
||||
const features = [];
|
||||
for (let n = doc.firstChild; n; n = n.nextSibling) {
|
||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||
extend(
|
||||
features,
|
||||
this.readFeaturesFromNode(/** @type {Element} */ (n), opt_options)
|
||||
this.readFeaturesFromNode(/** @type {Element} */ (n), options)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -132,11 +129,11 @@ class XMLFeature extends FeatureFormat {
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @protected
|
||||
* @return {Array<import("../Feature.js").default>} Features.
|
||||
*/
|
||||
readFeaturesFromNode(node, opt_options) {
|
||||
readFeaturesFromNode(node, options) {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
@@ -144,45 +141,45 @@ class XMLFeature extends FeatureFormat {
|
||||
* Read a single geometry from a source.
|
||||
*
|
||||
* @param {Document|Element|Object|string} source Source.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Read options.
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometry(source, opt_options) {
|
||||
readGeometry(source, options) {
|
||||
if (!source) {
|
||||
return null;
|
||||
} else if (typeof source === 'string') {
|
||||
const doc = parse(source);
|
||||
return this.readGeometryFromDocument(doc, opt_options);
|
||||
return this.readGeometryFromDocument(doc, options);
|
||||
} else if (isDocument(source)) {
|
||||
return this.readGeometryFromDocument(
|
||||
/** @type {Document} */ (source),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
} else {
|
||||
return this.readGeometryFromNode(
|
||||
/** @type {Element} */ (source),
|
||||
opt_options
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromDocument(doc, opt_options) {
|
||||
readGeometryFromDocument(doc, options) {
|
||||
return null; // not implemented
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").ReadOptions} [options] Options.
|
||||
* @protected
|
||||
* @return {import("../geom/Geometry.js").default} Geometry.
|
||||
*/
|
||||
readGeometryFromNode(node, opt_options) {
|
||||
readGeometryFromNode(node, options) {
|
||||
return null; // not implemented
|
||||
}
|
||||
|
||||
@@ -228,21 +225,21 @@ class XMLFeature extends FeatureFormat {
|
||||
* Encode a feature as string.
|
||||
*
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded feature.
|
||||
*/
|
||||
writeFeature(feature, opt_options) {
|
||||
const node = this.writeFeatureNode(feature, opt_options);
|
||||
writeFeature(feature, options) {
|
||||
const node = this.writeFeatureNode(feature, options);
|
||||
return this.xmlSerializer_.serializeToString(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../Feature.js").default} feature Feature.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
writeFeatureNode(feature, opt_options) {
|
||||
writeFeatureNode(feature, options) {
|
||||
return null; // not implemented
|
||||
}
|
||||
|
||||
@@ -250,21 +247,21 @@ class XMLFeature extends FeatureFormat {
|
||||
* Encode an array of features as string.
|
||||
*
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Result.
|
||||
* @api
|
||||
*/
|
||||
writeFeatures(features, opt_options) {
|
||||
const node = this.writeFeaturesNode(features, opt_options);
|
||||
writeFeatures(features, options) {
|
||||
const node = this.writeFeaturesNode(features, options);
|
||||
return this.xmlSerializer_.serializeToString(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<import("../Feature.js").default>} features Features.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
writeFeaturesNode(features, opt_options) {
|
||||
writeFeaturesNode(features, options) {
|
||||
return null; // not implemented
|
||||
}
|
||||
|
||||
@@ -272,20 +269,20 @@ class XMLFeature extends FeatureFormat {
|
||||
* Encode a geometry as string.
|
||||
*
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Write options.
|
||||
* @return {string} Encoded geometry.
|
||||
*/
|
||||
writeGeometry(geometry, opt_options) {
|
||||
const node = this.writeGeometryNode(geometry, opt_options);
|
||||
writeGeometry(geometry, options) {
|
||||
const node = this.writeGeometryNode(geometry, options);
|
||||
return this.xmlSerializer_.serializeToString(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
|
||||
* @param {import("./Feature.js").WriteOptions} [options] Options.
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
writeGeometryNode(geometry, opt_options) {
|
||||
writeGeometryNode(geometry, options) {
|
||||
return null; // not implemented
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,13 +63,13 @@ export function not(condition) {
|
||||
*
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../extent.js").Extent} extent Extent.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @return {!Bbox} `<BBOX>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function bbox(geometryName, extent, opt_srsName) {
|
||||
return new Bbox(geometryName, extent, opt_srsName);
|
||||
export function bbox(geometryName, extent, srsName) {
|
||||
return new Bbox(geometryName, extent, srsName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,13 +78,13 @@ export function bbox(geometryName, extent, opt_srsName) {
|
||||
*
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @return {!Contains} `<Contains>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function contains(geometryName, geometry, opt_srsName) {
|
||||
return new Contains(geometryName, geometry, opt_srsName);
|
||||
export function contains(geometryName, geometry, srsName) {
|
||||
return new Contains(geometryName, geometry, srsName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,13 +93,13 @@ export function contains(geometryName, geometry, opt_srsName) {
|
||||
*
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @return {!Intersects} `<Intersects>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function intersects(geometryName, geometry, opt_srsName) {
|
||||
return new Intersects(geometryName, geometry, opt_srsName);
|
||||
export function intersects(geometryName, geometry, srsName) {
|
||||
return new Intersects(geometryName, geometry, srsName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,13 +108,13 @@ export function intersects(geometryName, geometry, opt_srsName) {
|
||||
*
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @return {!Disjoint} `<Disjoint>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function disjoint(geometryName, geometry, opt_srsName) {
|
||||
return new Disjoint(geometryName, geometry, opt_srsName);
|
||||
export function disjoint(geometryName, geometry, srsName) {
|
||||
return new Disjoint(geometryName, geometry, srsName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,13 +123,13 @@ export function disjoint(geometryName, geometry, opt_srsName) {
|
||||
*
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @return {!Within} `<Within>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function within(geometryName, geometry, opt_srsName) {
|
||||
return new Within(geometryName, geometry, opt_srsName);
|
||||
export function within(geometryName, geometry, srsName) {
|
||||
return new Within(geometryName, geometry, srsName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,13 +140,13 @@ export function within(geometryName, geometry, opt_srsName) {
|
||||
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {!number} distance Distance.
|
||||
* @param {!string} unit Unit.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
* @return {!DWithin} `<DWithin>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function dwithin(geometryName, geometry, distance, unit, opt_srsName) {
|
||||
return new DWithin(geometryName, geometry, distance, unit, opt_srsName);
|
||||
export function dwithin(geometryName, geometry, distance, unit, srsName) {
|
||||
return new DWithin(geometryName, geometry, distance, unit, srsName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,12 +154,12 @@ export function dwithin(geometryName, geometry, distance, unit, opt_srsName) {
|
||||
*
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!(string|number)} expression The value to compare.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
* @return {!EqualTo} `<PropertyIsEqualTo>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function equalTo(propertyName, expression, opt_matchCase) {
|
||||
return new EqualTo(propertyName, expression, opt_matchCase);
|
||||
export function equalTo(propertyName, expression, matchCase) {
|
||||
return new EqualTo(propertyName, expression, matchCase);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,12 +167,12 @@ export function equalTo(propertyName, expression, opt_matchCase) {
|
||||
*
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!(string|number)} expression The value to compare.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
* @return {!NotEqualTo} `<PropertyIsNotEqualTo>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function notEqualTo(propertyName, expression, opt_matchCase) {
|
||||
return new NotEqualTo(propertyName, expression, opt_matchCase);
|
||||
export function notEqualTo(propertyName, expression, matchCase) {
|
||||
return new NotEqualTo(propertyName, expression, matchCase);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,31 +255,31 @@ export function between(propertyName, lowerBoundary, upperBoundary) {
|
||||
*
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!string} pattern Text pattern.
|
||||
* @param {string} [opt_wildCard] Pattern character which matches any sequence of
|
||||
* @param {string} [wildCard] Pattern character which matches any sequence of
|
||||
* zero or more string characters. Default is '*'.
|
||||
* @param {string} [opt_singleChar] pattern character which matches any single
|
||||
* @param {string} [singleChar] pattern character which matches any single
|
||||
* string character. Default is '.'.
|
||||
* @param {string} [opt_escapeChar] Escape character which can be used to escape
|
||||
* @param {string} [escapeChar] Escape character which can be used to escape
|
||||
* the pattern characters. Default is '!'.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
* @return {!IsLike} `<PropertyIsLike>` operator.
|
||||
* @api
|
||||
*/
|
||||
export function like(
|
||||
propertyName,
|
||||
pattern,
|
||||
opt_wildCard,
|
||||
opt_singleChar,
|
||||
opt_escapeChar,
|
||||
opt_matchCase
|
||||
wildCard,
|
||||
singleChar,
|
||||
escapeChar,
|
||||
matchCase
|
||||
) {
|
||||
return new IsLike(
|
||||
propertyName,
|
||||
pattern,
|
||||
opt_wildCard,
|
||||
opt_singleChar,
|
||||
opt_escapeChar,
|
||||
opt_matchCase
|
||||
wildCard,
|
||||
singleChar,
|
||||
escapeChar,
|
||||
matchCase
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ class Bbox extends Filter {
|
||||
/**
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../../extent.js").Extent} extent Extent.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be set
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be set
|
||||
* on geometries when this is not provided.
|
||||
*/
|
||||
constructor(geometryName, extent, opt_srsName) {
|
||||
constructor(geometryName, extent, srsName) {
|
||||
super('BBOX');
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ class Bbox extends Filter {
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.srsName = opt_srsName;
|
||||
this.srsName = srsName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ class ComparisonBinary extends Comparison {
|
||||
* @param {!string} tagName The XML tag name for this filter.
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!(string|number)} expression The value to compare.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
*/
|
||||
constructor(tagName, propertyName, expression, opt_matchCase) {
|
||||
constructor(tagName, propertyName, expression, matchCase) {
|
||||
super(tagName, propertyName);
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ class ComparisonBinary extends Comparison {
|
||||
/**
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.matchCase = opt_matchCase;
|
||||
this.matchCase = matchCase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ class Contains extends Spatial {
|
||||
/**
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
*/
|
||||
constructor(geometryName, geometry, opt_srsName) {
|
||||
super('Contains', geometryName, geometry, opt_srsName);
|
||||
constructor(geometryName, geometry, srsName) {
|
||||
super('Contains', geometryName, geometry, srsName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ class DWithin extends Spatial {
|
||||
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {!number} distance Distance.
|
||||
* @param {!string} unit Unit.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
*/
|
||||
constructor(geometryName, geometry, distance, unit, opt_srsName) {
|
||||
super('DWithin', geometryName, geometry, opt_srsName);
|
||||
constructor(geometryName, geometry, distance, unit, srsName) {
|
||||
super('DWithin', geometryName, geometry, srsName);
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
||||
@@ -13,11 +13,11 @@ class Disjoint extends Spatial {
|
||||
/**
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
*/
|
||||
constructor(geometryName, geometry, opt_srsName) {
|
||||
super('Disjoint', geometryName, geometry, opt_srsName);
|
||||
constructor(geometryName, geometry, srsName) {
|
||||
super('Disjoint', geometryName, geometry, srsName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ class EqualTo extends ComparisonBinary {
|
||||
/**
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!(string|number)} expression The value to compare.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
*/
|
||||
constructor(propertyName, expression, opt_matchCase) {
|
||||
super('PropertyIsEqualTo', propertyName, expression, opt_matchCase);
|
||||
constructor(propertyName, expression, matchCase) {
|
||||
super('PropertyIsEqualTo', propertyName, expression, matchCase);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ class Intersects extends Spatial {
|
||||
/**
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
*/
|
||||
constructor(geometryName, geometry, opt_srsName) {
|
||||
super('Intersects', geometryName, geometry, opt_srsName);
|
||||
constructor(geometryName, geometry, srsName) {
|
||||
super('Intersects', geometryName, geometry, srsName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,21 +13,21 @@ class IsLike extends Comparison {
|
||||
* [constructor description]
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!string} pattern Text pattern.
|
||||
* @param {string} [opt_wildCard] Pattern character which matches any sequence of
|
||||
* @param {string} [wildCard] Pattern character which matches any sequence of
|
||||
* zero or more string characters. Default is '*'.
|
||||
* @param {string} [opt_singleChar] pattern character which matches any single
|
||||
* @param {string} [singleChar] pattern character which matches any single
|
||||
* string character. Default is '.'.
|
||||
* @param {string} [opt_escapeChar] Escape character which can be used to escape
|
||||
* @param {string} [escapeChar] Escape character which can be used to escape
|
||||
* the pattern characters. Default is '!'.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
*/
|
||||
constructor(
|
||||
propertyName,
|
||||
pattern,
|
||||
opt_wildCard,
|
||||
opt_singleChar,
|
||||
opt_escapeChar,
|
||||
opt_matchCase
|
||||
wildCard,
|
||||
singleChar,
|
||||
escapeChar,
|
||||
matchCase
|
||||
) {
|
||||
super('PropertyIsLike', propertyName);
|
||||
|
||||
@@ -39,22 +39,22 @@ class IsLike extends Comparison {
|
||||
/**
|
||||
* @type {!string}
|
||||
*/
|
||||
this.wildCard = opt_wildCard !== undefined ? opt_wildCard : '*';
|
||||
this.wildCard = wildCard !== undefined ? wildCard : '*';
|
||||
|
||||
/**
|
||||
* @type {!string}
|
||||
*/
|
||||
this.singleChar = opt_singleChar !== undefined ? opt_singleChar : '.';
|
||||
this.singleChar = singleChar !== undefined ? singleChar : '.';
|
||||
|
||||
/**
|
||||
* @type {!string}
|
||||
*/
|
||||
this.escapeChar = opt_escapeChar !== undefined ? opt_escapeChar : '!';
|
||||
this.escapeChar = escapeChar !== undefined ? escapeChar : '!';
|
||||
|
||||
/**
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.matchCase = opt_matchCase;
|
||||
this.matchCase = matchCase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ class NotEqualTo extends ComparisonBinary {
|
||||
/**
|
||||
* @param {!string} propertyName Name of the context property to compare.
|
||||
* @param {!(string|number)} expression The value to compare.
|
||||
* @param {boolean} [opt_matchCase] Case-sensitive?
|
||||
* @param {boolean} [matchCase] Case-sensitive?
|
||||
*/
|
||||
constructor(propertyName, expression, opt_matchCase) {
|
||||
super('PropertyIsNotEqualTo', propertyName, expression, opt_matchCase);
|
||||
constructor(propertyName, expression, matchCase) {
|
||||
super('PropertyIsNotEqualTo', propertyName, expression, matchCase);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ class Spatial extends Filter {
|
||||
* @param {!string} tagName The XML tag name for this filter.
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
*/
|
||||
constructor(tagName, geometryName, geometry, opt_srsName) {
|
||||
constructor(tagName, geometryName, geometry, srsName) {
|
||||
super(tagName);
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ class Spatial extends Filter {
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.srsName = opt_srsName;
|
||||
this.srsName = srsName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ class Within extends Spatial {
|
||||
/**
|
||||
* @param {!string} geometryName Geometry name to use.
|
||||
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
|
||||
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
|
||||
* @param {string} [srsName] SRS name. No srsName attribute will be
|
||||
* set on geometries when this is not provided.
|
||||
*/
|
||||
constructor(geometryName, geometry, opt_srsName) {
|
||||
super('Within', geometryName, geometry, opt_srsName);
|
||||
constructor(geometryName, geometry, srsName) {
|
||||
super('Within', geometryName, geometry, srsName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,18 +15,18 @@ import {rotate, translate} from './flat/transform.js';
|
||||
class Circle extends SimpleGeometry {
|
||||
/**
|
||||
* @param {!import("../coordinate.js").Coordinate} center Center.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` and no
|
||||
* `opt_radius` are also accepted.
|
||||
* @param {number} [opt_radius] Radius.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* For internal use, flat coordinates in combination with `layout` and no
|
||||
* `radius` are also accepted.
|
||||
* @param {number} [radius] Radius.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
*/
|
||||
constructor(center, opt_radius, opt_layout) {
|
||||
constructor(center, radius, layout) {
|
||||
super();
|
||||
if (opt_layout !== undefined && opt_radius === undefined) {
|
||||
this.setFlatCoordinates(opt_layout, center);
|
||||
if (layout !== undefined && radius === undefined) {
|
||||
this.setFlatCoordinates(layout, center);
|
||||
} else {
|
||||
const radius = opt_radius ? opt_radius : 0;
|
||||
this.setCenterAndRadius(center, radius, opt_layout);
|
||||
radius = radius ? radius : 0;
|
||||
this.setCenterAndRadius(center, radius, layout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,11 +188,11 @@ class Circle extends SimpleGeometry {
|
||||
* number) of the circle.
|
||||
* @param {!import("../coordinate.js").Coordinate} center Center.
|
||||
* @param {number} radius Radius.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCenterAndRadius(center, radius, opt_layout) {
|
||||
this.setLayout(opt_layout, center, 0);
|
||||
setCenterAndRadius(center, radius, layout) {
|
||||
this.setLayout(layout, center, 0);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class Circle extends SimpleGeometry {
|
||||
return null;
|
||||
}
|
||||
|
||||
setCoordinates(coordinates, opt_layout) {}
|
||||
setCoordinates(coordinates, layout) {}
|
||||
|
||||
/**
|
||||
* Set the radius of the circle. The radius is in the units of the projection.
|
||||
|
||||
@@ -80,19 +80,19 @@ class Geometry extends BaseObject {
|
||||
* @abstract
|
||||
* @param {number} revision The geometry revision.
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @param {import("../proj.js").TransformFunction} [opt_transform] Optional transform function.
|
||||
* @param {import("../proj.js").TransformFunction} [transform] Optional transform function.
|
||||
* @return {Geometry} Simplified geometry.
|
||||
*/
|
||||
this.simplifyTransformedInternal = memoizeOne(function (
|
||||
revision,
|
||||
squaredTolerance,
|
||||
opt_transform
|
||||
transform
|
||||
) {
|
||||
if (!opt_transform) {
|
||||
if (!transform) {
|
||||
return this.getSimplifiedGeometry(squaredTolerance);
|
||||
}
|
||||
const clone = this.clone();
|
||||
clone.applyTransform(opt_transform);
|
||||
clone.applyTransform(transform);
|
||||
return clone.getSimplifiedGeometry(squaredTolerance);
|
||||
});
|
||||
}
|
||||
@@ -101,14 +101,14 @@ class Geometry extends BaseObject {
|
||||
* Get a transformed and simplified version of the geometry.
|
||||
* @abstract
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @param {import("../proj.js").TransformFunction} [opt_transform] Optional transform function.
|
||||
* @param {import("../proj.js").TransformFunction} [transform] Optional transform function.
|
||||
* @return {Geometry} Simplified geometry.
|
||||
*/
|
||||
simplifyTransformed(squaredTolerance, opt_transform) {
|
||||
simplifyTransformed(squaredTolerance, transform) {
|
||||
return this.simplifyTransformedInternal(
|
||||
this.getRevision(),
|
||||
squaredTolerance,
|
||||
opt_transform
|
||||
transform
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,12 +147,12 @@ class Geometry extends BaseObject {
|
||||
* Return the closest point of the geometry to the passed point as
|
||||
* {@link module:ol/coordinate~Coordinate coordinate}.
|
||||
* @param {import("../coordinate.js").Coordinate} point Point.
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_closestPoint] Closest point.
|
||||
* @param {import("../coordinate.js").Coordinate} [closestPoint] Closest point.
|
||||
* @return {import("../coordinate.js").Coordinate} Closest point.
|
||||
* @api
|
||||
*/
|
||||
getClosestPoint(point, opt_closestPoint) {
|
||||
const closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
|
||||
getClosestPoint(point, closestPoint) {
|
||||
closestPoint = closestPoint ? closestPoint : [NaN, NaN];
|
||||
this.closestPointXY(point[0], point[1], closestPoint, Infinity);
|
||||
return closestPoint;
|
||||
}
|
||||
@@ -180,11 +180,11 @@ class Geometry extends BaseObject {
|
||||
|
||||
/**
|
||||
* Get the extent of the geometry.
|
||||
* @param {import("../extent.js").Extent} [opt_extent] Extent.
|
||||
* @param {import("../extent.js").Extent} [extent] Extent.
|
||||
* @return {import("../extent.js").Extent} extent Extent.
|
||||
* @api
|
||||
*/
|
||||
getExtent(opt_extent) {
|
||||
getExtent(extent) {
|
||||
if (this.extentRevision_ != this.getRevision()) {
|
||||
const extent = this.computeExtent(this.extent_);
|
||||
if (isNaN(extent[0]) || isNaN(extent[1])) {
|
||||
@@ -192,7 +192,7 @@ class Geometry extends BaseObject {
|
||||
}
|
||||
this.extentRevision_ = this.getRevision();
|
||||
}
|
||||
return returnOrUpdate(this.extent_, opt_extent);
|
||||
return returnOrUpdate(this.extent_, extent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,12 +212,12 @@ class Geometry extends BaseObject {
|
||||
* coordinates in place.
|
||||
* @abstract
|
||||
* @param {number} sx The scaling factor in the x-direction.
|
||||
* @param {number} [opt_sy] The scaling factor in the y-direction (defaults to sx).
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_anchor] The scale origin (defaults to the center
|
||||
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
|
||||
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
|
||||
* of the geometry extent).
|
||||
* @api
|
||||
*/
|
||||
scale(sx, opt_sy, opt_anchor) {
|
||||
scale(sx, sy, anchor) {
|
||||
abstract();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@ import {listen, unlistenByKey} from '../events.js';
|
||||
*/
|
||||
class GeometryCollection extends Geometry {
|
||||
/**
|
||||
* @param {Array<Geometry>} [opt_geometries] Geometries.
|
||||
* @param {Array<Geometry>} [geometries] Geometries.
|
||||
*/
|
||||
constructor(opt_geometries) {
|
||||
constructor(geometries) {
|
||||
super();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<Geometry>}
|
||||
*/
|
||||
this.geometries_ = opt_geometries ? opt_geometries : null;
|
||||
this.geometries_ = geometries ? geometries : null;
|
||||
|
||||
/**
|
||||
* @type {Array<import("../events.js").EventsKey>}
|
||||
@@ -253,19 +253,18 @@ class GeometryCollection extends Geometry {
|
||||
* coordinates in place.
|
||||
* @abstract
|
||||
* @param {number} sx The scaling factor in the x-direction.
|
||||
* @param {number} [opt_sy] The scaling factor in the y-direction (defaults to sx).
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_anchor] The scale origin (defaults to the center
|
||||
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
|
||||
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
|
||||
* of the geometry extent).
|
||||
* @api
|
||||
*/
|
||||
scale(sx, opt_sy, opt_anchor) {
|
||||
let anchor = opt_anchor;
|
||||
scale(sx, sy, anchor) {
|
||||
if (!anchor) {
|
||||
anchor = getCenter(this.getExtent());
|
||||
}
|
||||
const geometries = this.geometries_;
|
||||
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
geometries[i].scale(sx, opt_sy, anchor);
|
||||
geometries[i].scale(sx, sy, anchor);
|
||||
}
|
||||
this.changed();
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import {lineStringLength} from './flat/length.js';
|
||||
class LineString extends SimpleGeometry {
|
||||
/**
|
||||
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* For internal use, flat coordinates in combination with `layout` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
constructor(coordinates, layout) {
|
||||
super();
|
||||
|
||||
/**
|
||||
@@ -52,9 +52,9 @@ class LineString extends SimpleGeometry {
|
||||
*/
|
||||
this.maxDeltaRevision_ = -1;
|
||||
|
||||
if (opt_layout !== undefined && !Array.isArray(coordinates[0])) {
|
||||
if (layout !== undefined && !Array.isArray(coordinates[0])) {
|
||||
this.setFlatCoordinates(
|
||||
opt_layout,
|
||||
layout,
|
||||
/** @type {Array<number>} */ (coordinates)
|
||||
);
|
||||
} else {
|
||||
@@ -62,7 +62,7 @@ class LineString extends SimpleGeometry {
|
||||
/** @type {Array<import("../coordinate.js").Coordinate>} */ (
|
||||
coordinates
|
||||
),
|
||||
opt_layout
|
||||
layout
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -157,21 +157,21 @@ class LineString extends SimpleGeometry {
|
||||
* Returns the coordinate at `m` using linear interpolation, or `null` if no
|
||||
* such coordinate exists.
|
||||
*
|
||||
* `opt_extrapolate` controls extrapolation beyond the range of Ms in the
|
||||
* MultiLineString. If `opt_extrapolate` is `true` then Ms less than the first
|
||||
* `extrapolate` controls extrapolation beyond the range of Ms in the
|
||||
* MultiLineString. If `extrapolate` is `true` then Ms less than the first
|
||||
* M will return the first coordinate and Ms greater than the last M will
|
||||
* return the last coordinate.
|
||||
*
|
||||
* @param {number} m M.
|
||||
* @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
|
||||
* @param {boolean} [extrapolate] Extrapolate. Default is `false`.
|
||||
* @return {import("../coordinate.js").Coordinate|null} Coordinate.
|
||||
* @api
|
||||
*/
|
||||
getCoordinateAtM(m, opt_extrapolate) {
|
||||
getCoordinateAtM(m, extrapolate) {
|
||||
if (this.layout != 'XYM' && this.layout != 'XYZM') {
|
||||
return null;
|
||||
}
|
||||
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||
extrapolate = extrapolate !== undefined ? extrapolate : false;
|
||||
return lineStringCoordinateAtM(
|
||||
this.flatCoordinates,
|
||||
0,
|
||||
@@ -201,19 +201,19 @@ class LineString extends SimpleGeometry {
|
||||
* The `fraction` is a number between 0 and 1, where 0 is the start of the
|
||||
* linestring and 1 is the end.
|
||||
* @param {number} fraction Fraction.
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_dest] Optional coordinate whose values will
|
||||
* @param {import("../coordinate.js").Coordinate} [dest] Optional coordinate whose values will
|
||||
* be modified. If not provided, a new coordinate will be returned.
|
||||
* @return {import("../coordinate.js").Coordinate} Coordinate of the interpolated point.
|
||||
* @api
|
||||
*/
|
||||
getCoordinateAt(fraction, opt_dest) {
|
||||
getCoordinateAt(fraction, dest) {
|
||||
return interpolatePoint(
|
||||
this.flatCoordinates,
|
||||
0,
|
||||
this.flatCoordinates.length,
|
||||
this.stride,
|
||||
fraction,
|
||||
opt_dest,
|
||||
dest,
|
||||
this.stride
|
||||
);
|
||||
}
|
||||
@@ -290,11 +290,11 @@ class LineString extends SimpleGeometry {
|
||||
/**
|
||||
* Set the coordinates of the linestring.
|
||||
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 1);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 1);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ import {linearRing as linearRingArea} from './flat/area.js';
|
||||
class LinearRing extends SimpleGeometry {
|
||||
/**
|
||||
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* For internal use, flat coordinates in combination with `layout` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
constructor(coordinates, layout) {
|
||||
super();
|
||||
|
||||
/**
|
||||
@@ -37,9 +37,9 @@ class LinearRing extends SimpleGeometry {
|
||||
*/
|
||||
this.maxDeltaRevision_ = -1;
|
||||
|
||||
if (opt_layout !== undefined && !Array.isArray(coordinates[0])) {
|
||||
if (layout !== undefined && !Array.isArray(coordinates[0])) {
|
||||
this.setFlatCoordinates(
|
||||
opt_layout,
|
||||
layout,
|
||||
/** @type {Array<number>} */ (coordinates)
|
||||
);
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ class LinearRing extends SimpleGeometry {
|
||||
/** @type {Array<import("../coordinate.js").Coordinate>} */ (
|
||||
coordinates
|
||||
),
|
||||
opt_layout
|
||||
layout
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -167,11 +167,11 @@ class LinearRing extends SimpleGeometry {
|
||||
/**
|
||||
* Set the coordinates of the linear ring.
|
||||
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 1);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 1);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ class MultiLineString extends SimpleGeometry {
|
||||
/**
|
||||
* @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates
|
||||
* Coordinates or LineString geometries. (For internal use, flat coordinates in
|
||||
* combination with `opt_layout` and `opt_ends` are also accepted.)
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {Array<number>} [opt_ends] Flat coordinate ends for internal use.
|
||||
* combination with `layout` and `ends` are also accepted.)
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @param {Array<number>} [ends] Flat coordinate ends for internal use.
|
||||
*/
|
||||
constructor(coordinates, opt_layout, opt_ends) {
|
||||
constructor(coordinates, layout, ends) {
|
||||
super();
|
||||
|
||||
/**
|
||||
@@ -55,14 +55,14 @@ class MultiLineString extends SimpleGeometry {
|
||||
/** @type {Array<Array<import("../coordinate.js").Coordinate>>} */ (
|
||||
coordinates
|
||||
),
|
||||
opt_layout
|
||||
layout
|
||||
);
|
||||
} else if (opt_layout !== undefined && opt_ends) {
|
||||
} else if (layout !== undefined && ends) {
|
||||
this.setFlatCoordinates(
|
||||
opt_layout,
|
||||
layout,
|
||||
/** @type {Array<number>} */ (coordinates)
|
||||
);
|
||||
this.ends_ = opt_ends;
|
||||
this.ends_ = ends;
|
||||
} else {
|
||||
let layout = this.getLayout();
|
||||
const lineStrings = /** @type {Array<LineString>} */ (coordinates);
|
||||
@@ -152,33 +152,33 @@ class MultiLineString extends SimpleGeometry {
|
||||
* Returns the coordinate at `m` using linear interpolation, or `null` if no
|
||||
* such coordinate exists.
|
||||
*
|
||||
* `opt_extrapolate` controls extrapolation beyond the range of Ms in the
|
||||
* MultiLineString. If `opt_extrapolate` is `true` then Ms less than the first
|
||||
* `extrapolate` controls extrapolation beyond the range of Ms in the
|
||||
* MultiLineString. If `extrapolate` is `true` then Ms less than the first
|
||||
* M will return the first coordinate and Ms greater than the last M will
|
||||
* return the last coordinate.
|
||||
*
|
||||
* `opt_interpolate` controls interpolation between consecutive LineStrings
|
||||
* within the MultiLineString. If `opt_interpolate` is `true` the coordinates
|
||||
* `interpolate` controls interpolation between consecutive LineStrings
|
||||
* within the MultiLineString. If `interpolate` is `true` the coordinates
|
||||
* will be linearly interpolated between the last coordinate of one LineString
|
||||
* and the first coordinate of the next LineString. If `opt_interpolate` is
|
||||
* and the first coordinate of the next LineString. If `interpolate` is
|
||||
* `false` then the function will return `null` for Ms falling between
|
||||
* LineStrings.
|
||||
*
|
||||
* @param {number} m M.
|
||||
* @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
|
||||
* @param {boolean} [opt_interpolate] Interpolate. Default is `false`.
|
||||
* @param {boolean} [extrapolate] Extrapolate. Default is `false`.
|
||||
* @param {boolean} [interpolate] Interpolate. Default is `false`.
|
||||
* @return {import("../coordinate.js").Coordinate|null} Coordinate.
|
||||
* @api
|
||||
*/
|
||||
getCoordinateAtM(m, opt_extrapolate, opt_interpolate) {
|
||||
getCoordinateAtM(m, extrapolate, interpolate) {
|
||||
if (
|
||||
(this.layout != 'XYM' && this.layout != 'XYZM') ||
|
||||
this.flatCoordinates.length === 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||
const interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
|
||||
extrapolate = extrapolate !== undefined ? extrapolate : false;
|
||||
interpolate = interpolate !== undefined ? interpolate : false;
|
||||
return lineStringsCoordinateAtM(
|
||||
this.flatCoordinates,
|
||||
0,
|
||||
@@ -327,11 +327,11 @@ class MultiLineString extends SimpleGeometry {
|
||||
/**
|
||||
* Set the coordinates of the multilinestring.
|
||||
* @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 2);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 2);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ import {squaredDistance as squaredDx} from '../math.js';
|
||||
class MultiPoint extends SimpleGeometry {
|
||||
/**
|
||||
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* For internal use, flat coordinates in combination with `layout` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
constructor(coordinates, layout) {
|
||||
super();
|
||||
if (opt_layout && !Array.isArray(coordinates[0])) {
|
||||
if (layout && !Array.isArray(coordinates[0])) {
|
||||
this.setFlatCoordinates(
|
||||
opt_layout,
|
||||
layout,
|
||||
/** @type {Array<number>} */ (coordinates)
|
||||
);
|
||||
} else {
|
||||
@@ -33,7 +33,7 @@ class MultiPoint extends SimpleGeometry {
|
||||
/** @type {Array<import("../coordinate.js").Coordinate>} */ (
|
||||
coordinates
|
||||
),
|
||||
opt_layout
|
||||
layout
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -182,11 +182,11 @@ class MultiPoint extends SimpleGeometry {
|
||||
/**
|
||||
* Set the coordinates of the multipoint.
|
||||
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 1);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 1);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ import {quantizeMultiArray} from './flat/simplify.js';
|
||||
class MultiPolygon extends SimpleGeometry {
|
||||
/**
|
||||
* @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` and `opt_endss` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {Array<Array<number>>} [opt_endss] Array of ends for internal use with flat coordinates.
|
||||
* For internal use, flat coordinates in combination with `layout` and `endss` are also accepted.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @param {Array<Array<number>>} [endss] Array of ends for internal use with flat coordinates.
|
||||
*/
|
||||
constructor(coordinates, opt_layout, opt_endss) {
|
||||
constructor(coordinates, layout, endss) {
|
||||
super();
|
||||
|
||||
/**
|
||||
@@ -81,15 +81,15 @@ class MultiPolygon extends SimpleGeometry {
|
||||
*/
|
||||
this.orientedFlatCoordinates_ = null;
|
||||
|
||||
if (!opt_endss && !Array.isArray(coordinates[0])) {
|
||||
let layout = this.getLayout();
|
||||
if (!endss && !Array.isArray(coordinates[0])) {
|
||||
let thisLayout = this.getLayout();
|
||||
const polygons = /** @type {Array<Polygon>} */ (coordinates);
|
||||
const flatCoordinates = [];
|
||||
const endss = [];
|
||||
const thisEndss = [];
|
||||
for (let i = 0, ii = polygons.length; i < ii; ++i) {
|
||||
const polygon = polygons[i];
|
||||
if (i === 0) {
|
||||
layout = polygon.getLayout();
|
||||
thisLayout = polygon.getLayout();
|
||||
}
|
||||
const offset = flatCoordinates.length;
|
||||
const ends = polygon.getEnds();
|
||||
@@ -97,24 +97,24 @@ class MultiPolygon extends SimpleGeometry {
|
||||
ends[j] += offset;
|
||||
}
|
||||
extend(flatCoordinates, polygon.getFlatCoordinates());
|
||||
endss.push(ends);
|
||||
thisEndss.push(ends);
|
||||
}
|
||||
opt_layout = layout;
|
||||
layout = thisLayout;
|
||||
coordinates = flatCoordinates;
|
||||
opt_endss = endss;
|
||||
endss = thisEndss;
|
||||
}
|
||||
if (opt_layout !== undefined && opt_endss) {
|
||||
if (layout !== undefined && endss) {
|
||||
this.setFlatCoordinates(
|
||||
opt_layout,
|
||||
layout,
|
||||
/** @type {Array<number>} */ (coordinates)
|
||||
);
|
||||
this.endss_ = opt_endss;
|
||||
this.endss_ = endss;
|
||||
} else {
|
||||
this.setCoordinates(
|
||||
/** @type {Array<Array<Array<import("../coordinate.js").Coordinate>>>} */ (
|
||||
coordinates
|
||||
),
|
||||
opt_layout
|
||||
layout
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class MultiPolygon extends SimpleGeometry {
|
||||
* Get the coordinate array for this geometry. This array has the structure
|
||||
* of a GeoJSON coordinate array for multi-polygons.
|
||||
*
|
||||
* @param {boolean} [opt_right] Orient coordinates according to the right-hand
|
||||
* @param {boolean} [right] Orient coordinates according to the right-hand
|
||||
* rule (counter-clockwise for exterior and clockwise for interior rings).
|
||||
* If `false`, coordinates will be oriented according to the left-hand rule
|
||||
* (clockwise for exterior and counter-clockwise for interior rings).
|
||||
@@ -245,16 +245,16 @@ class MultiPolygon extends SimpleGeometry {
|
||||
* @return {Array<Array<Array<import("../coordinate.js").Coordinate>>>} Coordinates.
|
||||
* @api
|
||||
*/
|
||||
getCoordinates(opt_right) {
|
||||
getCoordinates(right) {
|
||||
let flatCoordinates;
|
||||
if (opt_right !== undefined) {
|
||||
if (right !== undefined) {
|
||||
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
||||
orientLinearRingsArray(
|
||||
flatCoordinates,
|
||||
0,
|
||||
this.endss_,
|
||||
this.stride,
|
||||
opt_right
|
||||
right
|
||||
);
|
||||
} else {
|
||||
flatCoordinates = this.flatCoordinates;
|
||||
@@ -442,11 +442,11 @@ class MultiPolygon extends SimpleGeometry {
|
||||
/**
|
||||
* Set the coordinates of the multipolygon.
|
||||
* @param {!Array<Array<Array<import("../coordinate.js").Coordinate>>>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 3);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 3);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ import {squaredDistance as squaredDx} from '../math.js';
|
||||
class Point extends SimpleGeometry {
|
||||
/**
|
||||
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
constructor(coordinates, layout) {
|
||||
super();
|
||||
this.setCoordinates(coordinates, opt_layout);
|
||||
this.setCoordinates(coordinates, layout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,11 +99,11 @@ class Point extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {!Array<*>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 0);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 0);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ class Polygon extends SimpleGeometry {
|
||||
* linear ring defines a hole in the surface of the polygon. A linear ring is
|
||||
* an array of vertices' coordinates where the first coordinate and the last are
|
||||
* equivalent. (For internal use, flat coordinates in combination with
|
||||
* `opt_layout` and `opt_ends` are also accepted.)
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {Array<number>} [opt_ends] Ends (for internal use with flat coordinates).
|
||||
* `layout` and `ends` are also accepted.)
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @param {Array<number>} [ends] Ends (for internal use with flat coordinates).
|
||||
*/
|
||||
constructor(coordinates, opt_layout, opt_ends) {
|
||||
constructor(coordinates, layout, ends) {
|
||||
super();
|
||||
|
||||
/**
|
||||
@@ -81,18 +81,18 @@ class Polygon extends SimpleGeometry {
|
||||
*/
|
||||
this.orientedFlatCoordinates_ = null;
|
||||
|
||||
if (opt_layout !== undefined && opt_ends) {
|
||||
if (layout !== undefined && ends) {
|
||||
this.setFlatCoordinates(
|
||||
opt_layout,
|
||||
layout,
|
||||
/** @type {Array<number>} */ (coordinates)
|
||||
);
|
||||
this.ends_ = opt_ends;
|
||||
this.ends_ = ends;
|
||||
} else {
|
||||
this.setCoordinates(
|
||||
/** @type {Array<Array<import("../coordinate.js").Coordinate>>} */ (
|
||||
coordinates
|
||||
),
|
||||
opt_layout
|
||||
layout
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ class Polygon extends SimpleGeometry {
|
||||
* Get the coordinate array for this geometry. This array has the structure
|
||||
* of a GeoJSON coordinate array for polygons.
|
||||
*
|
||||
* @param {boolean} [opt_right] Orient coordinates according to the right-hand
|
||||
* @param {boolean} [right] Orient coordinates according to the right-hand
|
||||
* rule (counter-clockwise for exterior and clockwise for interior rings).
|
||||
* If `false`, coordinates will be oriented according to the left-hand rule
|
||||
* (clockwise for exterior and counter-clockwise for interior rings).
|
||||
@@ -207,11 +207,11 @@ class Polygon extends SimpleGeometry {
|
||||
* @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
|
||||
* @api
|
||||
*/
|
||||
getCoordinates(opt_right) {
|
||||
getCoordinates(right) {
|
||||
let flatCoordinates;
|
||||
if (opt_right !== undefined) {
|
||||
if (right !== undefined) {
|
||||
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
||||
orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, opt_right);
|
||||
orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, right);
|
||||
} else {
|
||||
flatCoordinates = this.flatCoordinates;
|
||||
}
|
||||
@@ -383,11 +383,11 @@ class Polygon extends SimpleGeometry {
|
||||
/**
|
||||
* Set the coordinates of the polygon.
|
||||
* @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
* @api
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
this.setLayout(opt_layout, coordinates, 2);
|
||||
setCoordinates(coordinates, layout) {
|
||||
this.setLayout(layout, coordinates, 2);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
@@ -410,21 +410,21 @@ export default Polygon;
|
||||
* @param {import("../coordinate.js").Coordinate} center Center (`[lon, lat]` in degrees).
|
||||
* @param {number} radius The great-circle distance from the center to
|
||||
* the polygon vertices in meters.
|
||||
* @param {number} [opt_n] Optional number of vertices for the resulting
|
||||
* @param {number} [n] Optional number of vertices for the resulting
|
||||
* polygon. Default is `32`.
|
||||
* @param {number} [opt_sphereRadius] Optional radius for the sphere (defaults to
|
||||
* @param {number} [sphereRadius] Optional radius for the sphere (defaults to
|
||||
* the Earth's mean radius using the WGS84 ellipsoid).
|
||||
* @return {Polygon} The "circular" polygon.
|
||||
* @api
|
||||
*/
|
||||
export function circular(center, radius, opt_n, opt_sphereRadius) {
|
||||
const n = opt_n ? opt_n : 32;
|
||||
export function circular(center, radius, n, sphereRadius) {
|
||||
n = n ? n : 32;
|
||||
/** @type {Array<number>} */
|
||||
const flatCoordinates = [];
|
||||
for (let i = 0; i < n; ++i) {
|
||||
extend(
|
||||
flatCoordinates,
|
||||
sphereOffset(center, radius, (2 * Math.PI * i) / n, opt_sphereRadius)
|
||||
sphereOffset(center, radius, (2 * Math.PI * i) / n, sphereRadius)
|
||||
);
|
||||
}
|
||||
flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||
@@ -460,14 +460,14 @@ export function fromExtent(extent) {
|
||||
/**
|
||||
* Create a regular polygon from a circle.
|
||||
* @param {import("./Circle.js").default} circle Circle geometry.
|
||||
* @param {number} [opt_sides] Number of sides of the polygon. Default is 32.
|
||||
* @param {number} [opt_angle] Start angle for the first vertex of the polygon in
|
||||
* @param {number} [sides] Number of sides of the polygon. Default is 32.
|
||||
* @param {number} [angle] Start angle for the first vertex of the polygon in
|
||||
* counter-clockwise radians. 0 means East. Default is 0.
|
||||
* @return {Polygon} Polygon geometry.
|
||||
* @api
|
||||
*/
|
||||
export function fromCircle(circle, opt_sides, opt_angle) {
|
||||
const sides = opt_sides ? opt_sides : 32;
|
||||
export function fromCircle(circle, sides, angle) {
|
||||
sides = sides ? sides : 32;
|
||||
const stride = circle.getStride();
|
||||
const layout = circle.getLayout();
|
||||
const center = circle.getCenter();
|
||||
@@ -482,7 +482,7 @@ export function fromCircle(circle, opt_sides, opt_angle) {
|
||||
}
|
||||
const ends = [flatCoordinates.length];
|
||||
const polygon = new Polygon(flatCoordinates, layout, ends);
|
||||
makeRegular(polygon, center, circle.getRadius(), opt_angle);
|
||||
makeRegular(polygon, center, circle.getRadius(), angle);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
@@ -491,14 +491,14 @@ export function fromCircle(circle, opt_sides, opt_angle) {
|
||||
* @param {Polygon} polygon Polygon geometry.
|
||||
* @param {import("../coordinate.js").Coordinate} center Center of the regular polygon.
|
||||
* @param {number} radius Radius of the regular polygon.
|
||||
* @param {number} [opt_angle] Start angle for the first vertex of the polygon in
|
||||
* @param {number} [angle] Start angle for the first vertex of the polygon in
|
||||
* counter-clockwise radians. 0 means East. Default is 0.
|
||||
*/
|
||||
export function makeRegular(polygon, center, radius, opt_angle) {
|
||||
export function makeRegular(polygon, center, radius, angle) {
|
||||
const flatCoordinates = polygon.getFlatCoordinates();
|
||||
const stride = polygon.getStride();
|
||||
const sides = flatCoordinates.length / stride - 1;
|
||||
const startAngle = opt_angle ? opt_angle : 0;
|
||||
const startAngle = angle ? angle : 0;
|
||||
for (let i = 0; i <= sides; ++i) {
|
||||
const offset = i * stride;
|
||||
const angle = startAngle + (modulo(i, sides) * 2 * Math.PI) / sides;
|
||||
|
||||
@@ -162,9 +162,9 @@ class SimpleGeometry extends Geometry {
|
||||
/**
|
||||
* @abstract
|
||||
* @param {!Array<*>} coordinates Coordinates.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
|
||||
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
||||
*/
|
||||
setCoordinates(coordinates, opt_layout) {
|
||||
setCoordinates(coordinates, layout) {
|
||||
abstract();
|
||||
}
|
||||
|
||||
@@ -240,17 +240,15 @@ class SimpleGeometry extends Geometry {
|
||||
* Scale the geometry (with an optional origin). This modifies the geometry
|
||||
* coordinates in place.
|
||||
* @param {number} sx The scaling factor in the x-direction.
|
||||
* @param {number} [opt_sy] The scaling factor in the y-direction (defaults to sx).
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_anchor] The scale origin (defaults to the center
|
||||
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
|
||||
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
|
||||
* of the geometry extent).
|
||||
* @api
|
||||
*/
|
||||
scale(sx, opt_sy, opt_anchor) {
|
||||
let sy = opt_sy;
|
||||
scale(sx, sy, anchor) {
|
||||
if (sy === undefined) {
|
||||
sy = sx;
|
||||
}
|
||||
let anchor = opt_anchor;
|
||||
if (!anchor) {
|
||||
anchor = getCenter(this.getExtent());
|
||||
}
|
||||
@@ -331,10 +329,10 @@ export function getStrideForLayout(layout) {
|
||||
/**
|
||||
* @param {SimpleGeometry} simpleGeometry Simple geometry.
|
||||
* @param {import("../transform.js").Transform} transform Transform.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @return {Array<number>} Transformed flat coordinates.
|
||||
*/
|
||||
export function transformGeom2D(simpleGeometry, transform, opt_dest) {
|
||||
export function transformGeom2D(simpleGeometry, transform, dest) {
|
||||
const flatCoordinates = simpleGeometry.getFlatCoordinates();
|
||||
if (!flatCoordinates) {
|
||||
return null;
|
||||
@@ -346,7 +344,7 @@ export function transformGeom2D(simpleGeometry, transform, opt_dest) {
|
||||
flatCoordinates.length,
|
||||
stride,
|
||||
transform,
|
||||
opt_dest
|
||||
dest
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ export function multiArrayMaxSquaredDelta(
|
||||
* @param {number} y Y.
|
||||
* @param {Array<number>} closestPoint Closest point.
|
||||
* @param {number} minSquaredDistance Minimum squared distance.
|
||||
* @param {Array<number>} [opt_tmpPoint] Temporary point object.
|
||||
* @param {Array<number>} [tmpPoint] Temporary point object.
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
export function assignClosestPoint(
|
||||
@@ -152,7 +152,7 @@ export function assignClosestPoint(
|
||||
y,
|
||||
closestPoint,
|
||||
minSquaredDistance,
|
||||
opt_tmpPoint
|
||||
tmpPoint
|
||||
) {
|
||||
if (offset == end) {
|
||||
return minSquaredDistance;
|
||||
@@ -176,7 +176,7 @@ export function assignClosestPoint(
|
||||
return minSquaredDistance;
|
||||
}
|
||||
}
|
||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];
|
||||
let index = offset + stride;
|
||||
while (index < end) {
|
||||
assignClosest(
|
||||
@@ -251,7 +251,7 @@ export function assignClosestPoint(
|
||||
* @param {number} y Y.
|
||||
* @param {Array<number>} closestPoint Closest point.
|
||||
* @param {number} minSquaredDistance Minimum squared distance.
|
||||
* @param {Array<number>} [opt_tmpPoint] Temporary point object.
|
||||
* @param {Array<number>} [tmpPoint] Temporary point object.
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
export function assignClosestArrayPoint(
|
||||
@@ -265,9 +265,9 @@ export function assignClosestArrayPoint(
|
||||
y,
|
||||
closestPoint,
|
||||
minSquaredDistance,
|
||||
opt_tmpPoint
|
||||
tmpPoint
|
||||
) {
|
||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
minSquaredDistance = assignClosestPoint(
|
||||
@@ -299,7 +299,7 @@ export function assignClosestArrayPoint(
|
||||
* @param {number} y Y.
|
||||
* @param {Array<number>} closestPoint Closest point.
|
||||
* @param {number} minSquaredDistance Minimum squared distance.
|
||||
* @param {Array<number>} [opt_tmpPoint] Temporary point object.
|
||||
* @param {Array<number>} [tmpPoint] Temporary point object.
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
export function assignClosestMultiArrayPoint(
|
||||
@@ -313,9 +313,9 @@ export function assignClosestMultiArrayPoint(
|
||||
y,
|
||||
closestPoint,
|
||||
minSquaredDistance,
|
||||
opt_tmpPoint
|
||||
tmpPoint
|
||||
) {
|
||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
const ends = endss[i];
|
||||
minSquaredDistance = assignClosestArrayPoint(
|
||||
|
||||
@@ -43,7 +43,7 @@ export function deflateCoordinates(
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<Array<import("../../coordinate.js").Coordinate>>} coordinatess Coordinatess.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<number>} [opt_ends] Ends.
|
||||
* @param {Array<number>} [ends] Ends.
|
||||
* @return {Array<number>} Ends.
|
||||
*/
|
||||
export function deflateCoordinatesArray(
|
||||
@@ -51,9 +51,9 @@ export function deflateCoordinatesArray(
|
||||
offset,
|
||||
coordinatess,
|
||||
stride,
|
||||
opt_ends
|
||||
ends
|
||||
) {
|
||||
const ends = opt_ends ? opt_ends : [];
|
||||
ends = ends ? ends : [];
|
||||
let i = 0;
|
||||
for (let j = 0, jj = coordinatess.length; j < jj; ++j) {
|
||||
const end = deflateCoordinates(
|
||||
@@ -74,7 +74,7 @@ export function deflateCoordinatesArray(
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} coordinatesss Coordinatesss.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<Array<number>>} [opt_endss] Endss.
|
||||
* @param {Array<Array<number>>} [endss] Endss.
|
||||
* @return {Array<Array<number>>} Endss.
|
||||
*/
|
||||
export function deflateMultiCoordinatesArray(
|
||||
@@ -82,9 +82,9 @@ export function deflateMultiCoordinatesArray(
|
||||
offset,
|
||||
coordinatesss,
|
||||
stride,
|
||||
opt_endss
|
||||
endss
|
||||
) {
|
||||
const endss = opt_endss ? opt_endss : [];
|
||||
endss = endss ? endss : [];
|
||||
let i = 0;
|
||||
for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {
|
||||
const ends = deflateCoordinatesArray(
|
||||
|
||||
@@ -7,22 +7,14 @@
|
||||
* @param {number} offset Offset.
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {number} [opt_destOffset] Destination offset.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @param {number} [destOffset] Destination offset.
|
||||
* @return {Array<number>} Flat coordinates.
|
||||
*/
|
||||
export function flipXY(
|
||||
flatCoordinates,
|
||||
offset,
|
||||
end,
|
||||
stride,
|
||||
opt_dest,
|
||||
opt_destOffset
|
||||
) {
|
||||
let dest, destOffset;
|
||||
if (opt_dest !== undefined) {
|
||||
dest = opt_dest;
|
||||
destOffset = opt_destOffset !== undefined ? opt_destOffset : 0;
|
||||
export function flipXY(flatCoordinates, offset, end, stride, dest, destOffset) {
|
||||
if (dest !== undefined) {
|
||||
dest = dest;
|
||||
destOffset = destOffset !== undefined ? destOffset : 0;
|
||||
} else {
|
||||
dest = [];
|
||||
destOffset = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @param {number} offset Offset.
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<import("../../coordinate.js").Coordinate>} [opt_coordinates] Coordinates.
|
||||
* @param {Array<import("../../coordinate.js").Coordinate>} [coordinates] Coordinates.
|
||||
* @return {Array<import("../../coordinate.js").Coordinate>} Coordinates.
|
||||
*/
|
||||
export function inflateCoordinates(
|
||||
@@ -15,9 +15,9 @@ export function inflateCoordinates(
|
||||
offset,
|
||||
end,
|
||||
stride,
|
||||
opt_coordinates
|
||||
coordinates
|
||||
) {
|
||||
const coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
|
||||
coordinates = coordinates !== undefined ? coordinates : [];
|
||||
let i = 0;
|
||||
for (let j = offset; j < end; j += stride) {
|
||||
coordinates[i++] = flatCoordinates.slice(j, j + stride);
|
||||
@@ -31,7 +31,7 @@ export function inflateCoordinates(
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<number>} ends Ends.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<Array<import("../../coordinate.js").Coordinate>>} [opt_coordinatess] Coordinatess.
|
||||
* @param {Array<Array<import("../../coordinate.js").Coordinate>>} [coordinatess] Coordinatess.
|
||||
* @return {Array<Array<import("../../coordinate.js").Coordinate>>} Coordinatess.
|
||||
*/
|
||||
export function inflateCoordinatesArray(
|
||||
@@ -39,9 +39,9 @@ export function inflateCoordinatesArray(
|
||||
offset,
|
||||
ends,
|
||||
stride,
|
||||
opt_coordinatess
|
||||
coordinatess
|
||||
) {
|
||||
const coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
|
||||
coordinatess = coordinatess !== undefined ? coordinatess : [];
|
||||
let i = 0;
|
||||
for (let j = 0, jj = ends.length; j < jj; ++j) {
|
||||
const end = ends[j];
|
||||
@@ -63,7 +63,7 @@ export function inflateCoordinatesArray(
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<Array<number>>} endss Endss.
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} [opt_coordinatesss]
|
||||
* @param {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} [coordinatesss]
|
||||
* Coordinatesss.
|
||||
* @return {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} Coordinatesss.
|
||||
*/
|
||||
@@ -72,10 +72,9 @@ export function inflateMultiCoordinatesArray(
|
||||
offset,
|
||||
endss,
|
||||
stride,
|
||||
opt_coordinatesss
|
||||
coordinatesss
|
||||
) {
|
||||
const coordinatesss =
|
||||
opt_coordinatesss !== undefined ? opt_coordinatesss : [];
|
||||
coordinatesss = coordinatesss !== undefined ? coordinatesss : [];
|
||||
let i = 0;
|
||||
for (let j = 0, jj = endss.length; j < jj; ++j) {
|
||||
const ends = endss[j];
|
||||
|
||||
@@ -13,7 +13,7 @@ import {numberSafeCompareFunction} from '../../array.js';
|
||||
* @param {number} stride Stride.
|
||||
* @param {Array<number>} flatCenters Flat centers.
|
||||
* @param {number} flatCentersOffset Flat center offset.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @return {Array<number>} Destination point as XYM coordinate, where M is the
|
||||
* length of the horizontal intersection that the point belongs to.
|
||||
*/
|
||||
@@ -24,7 +24,7 @@ export function getInteriorPointOfArray(
|
||||
stride,
|
||||
flatCenters,
|
||||
flatCentersOffset,
|
||||
opt_dest
|
||||
dest
|
||||
) {
|
||||
let i, ii, x, x1, x2, y1, y2;
|
||||
const y = flatCenters[flatCentersOffset + 1];
|
||||
@@ -69,9 +69,9 @@ export function getInteriorPointOfArray(
|
||||
// ring. Use the center of the the linear ring's extent.
|
||||
pointX = flatCenters[flatCentersOffset];
|
||||
}
|
||||
if (opt_dest) {
|
||||
opt_dest.push(pointX, y, maxSegmentLength);
|
||||
return opt_dest;
|
||||
if (dest) {
|
||||
dest.push(pointX, y, maxSegmentLength);
|
||||
return dest;
|
||||
} else {
|
||||
return [pointX, y, maxSegmentLength];
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import {lerp} from '../../math.js';
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @param {number} fraction Fraction.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {number} [opt_dimension] Destination dimension (default is `2`)
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @param {number} [dimension] Destination dimension (default is `2`)
|
||||
* @return {Array<number>} Destination.
|
||||
*/
|
||||
export function interpolatePoint(
|
||||
@@ -20,8 +20,8 @@ export function interpolatePoint(
|
||||
end,
|
||||
stride,
|
||||
fraction,
|
||||
opt_dest,
|
||||
opt_dimension
|
||||
dest,
|
||||
dimension
|
||||
) {
|
||||
let o, t;
|
||||
const n = (end - offset) / stride;
|
||||
@@ -54,8 +54,8 @@ export function interpolatePoint(
|
||||
o = offset + index * stride;
|
||||
}
|
||||
}
|
||||
const dimension = opt_dimension > 1 ? opt_dimension : 2;
|
||||
const dest = opt_dest ? opt_dest : new Array(dimension);
|
||||
dimension = dimension > 1 ? dimension : 2;
|
||||
dest = dest ? dest : new Array(dimension);
|
||||
for (let i = 0; i < dimension; ++i) {
|
||||
dest[i] =
|
||||
o === undefined
|
||||
|
||||
@@ -32,13 +32,13 @@ export function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
|
||||
/**
|
||||
* Determines if linear rings are oriented. By default, left-hand orientation
|
||||
* is tested (first ring must be clockwise, remaining rings counter-clockwise).
|
||||
* To test for right-hand orientation, use the `opt_right` argument.
|
||||
* To test for right-hand orientation, use the `right` argument.
|
||||
*
|
||||
* @param {Array<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<number>} ends Array of end indexes.
|
||||
* @param {number} stride Stride.
|
||||
* @param {boolean} [opt_right] Test for right-hand orientation
|
||||
* @param {boolean} [right] Test for right-hand orientation
|
||||
* (counter-clockwise exterior ring and clockwise interior rings).
|
||||
* @return {boolean} Rings are correctly oriented.
|
||||
*/
|
||||
@@ -47,9 +47,9 @@ export function linearRingsAreOriented(
|
||||
offset,
|
||||
ends,
|
||||
stride,
|
||||
opt_right
|
||||
right
|
||||
) {
|
||||
const right = opt_right !== undefined ? opt_right : false;
|
||||
right = right !== undefined ? right : false;
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
const isClockwise = linearRingIsClockwise(
|
||||
@@ -75,13 +75,13 @@ export function linearRingsAreOriented(
|
||||
/**
|
||||
* Determines if linear rings are oriented. By default, left-hand orientation
|
||||
* is tested (first ring must be clockwise, remaining rings counter-clockwise).
|
||||
* To test for right-hand orientation, use the `opt_right` argument.
|
||||
* To test for right-hand orientation, use the `right` argument.
|
||||
*
|
||||
* @param {Array<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<Array<number>>} endss Array of array of end indexes.
|
||||
* @param {number} stride Stride.
|
||||
* @param {boolean} [opt_right] Test for right-hand orientation
|
||||
* @param {boolean} [right] Test for right-hand orientation
|
||||
* (counter-clockwise exterior ring and clockwise interior rings).
|
||||
* @return {boolean} Rings are correctly oriented.
|
||||
*/
|
||||
@@ -90,13 +90,11 @@ export function linearRingssAreOriented(
|
||||
offset,
|
||||
endss,
|
||||
stride,
|
||||
opt_right
|
||||
right
|
||||
) {
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
const ends = endss[i];
|
||||
if (
|
||||
!linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right)
|
||||
) {
|
||||
if (!linearRingsAreOriented(flatCoordinates, offset, ends, stride, right)) {
|
||||
return false;
|
||||
}
|
||||
if (ends.length) {
|
||||
@@ -110,13 +108,13 @@ export function linearRingssAreOriented(
|
||||
* Orient coordinates in a flat array of linear rings. By default, rings
|
||||
* are oriented following the left-hand rule (clockwise for exterior and
|
||||
* counter-clockwise for interior rings). To orient according to the
|
||||
* right-hand rule, use the `opt_right` argument.
|
||||
* right-hand rule, use the `right` argument.
|
||||
*
|
||||
* @param {Array<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<number>} ends Ends.
|
||||
* @param {number} stride Stride.
|
||||
* @param {boolean} [opt_right] Follow the right-hand rule for orientation.
|
||||
* @param {boolean} [right] Follow the right-hand rule for orientation.
|
||||
* @return {number} End.
|
||||
*/
|
||||
export function orientLinearRings(
|
||||
@@ -124,9 +122,9 @@ export function orientLinearRings(
|
||||
offset,
|
||||
ends,
|
||||
stride,
|
||||
opt_right
|
||||
right
|
||||
) {
|
||||
const right = opt_right !== undefined ? opt_right : false;
|
||||
right = right !== undefined ? right : false;
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
const isClockwise = linearRingIsClockwise(
|
||||
@@ -151,13 +149,13 @@ export function orientLinearRings(
|
||||
* Orient coordinates in a flat array of linear rings. By default, rings
|
||||
* are oriented following the left-hand rule (clockwise for exterior and
|
||||
* counter-clockwise for interior rings). To orient according to the
|
||||
* right-hand rule, use the `opt_right` argument.
|
||||
* right-hand rule, use the `right` argument.
|
||||
*
|
||||
* @param {Array<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {Array<Array<number>>} endss Array of array of end indexes.
|
||||
* @param {number} stride Stride.
|
||||
* @param {boolean} [opt_right] Follow the right-hand rule for orientation.
|
||||
* @param {boolean} [right] Follow the right-hand rule for orientation.
|
||||
* @return {number} End.
|
||||
*/
|
||||
export function orientLinearRingsArray(
|
||||
@@ -165,7 +163,7 @@ export function orientLinearRingsArray(
|
||||
offset,
|
||||
endss,
|
||||
stride,
|
||||
opt_right
|
||||
right
|
||||
) {
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
offset = orientLinearRings(
|
||||
@@ -173,7 +171,7 @@ export function orientLinearRingsArray(
|
||||
offset,
|
||||
endss[i],
|
||||
stride,
|
||||
opt_right
|
||||
right
|
||||
);
|
||||
}
|
||||
return offset;
|
||||
|
||||
@@ -36,7 +36,7 @@ import {squaredDistance, squaredSegmentDistance} from '../../math.js';
|
||||
* @param {number} stride Stride.
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @param {boolean} highQuality Highest quality.
|
||||
* @param {Array<number>} [opt_simplifiedFlatCoordinates] Simplified flat
|
||||
* @param {Array<number>} [simplifiedFlatCoordinates] Simplified flat
|
||||
* coordinates.
|
||||
* @return {Array<number>} Simplified line string.
|
||||
*/
|
||||
@@ -47,12 +47,10 @@ export function simplifyLineString(
|
||||
stride,
|
||||
squaredTolerance,
|
||||
highQuality,
|
||||
opt_simplifiedFlatCoordinates
|
||||
simplifiedFlatCoordinates
|
||||
) {
|
||||
const simplifiedFlatCoordinates =
|
||||
opt_simplifiedFlatCoordinates !== undefined
|
||||
? opt_simplifiedFlatCoordinates
|
||||
: [];
|
||||
simplifiedFlatCoordinates =
|
||||
simplifiedFlatCoordinates !== undefined ? simplifiedFlatCoordinates : [];
|
||||
if (!highQuality) {
|
||||
end = radialDistance(
|
||||
flatCoordinates,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @param {import("../../transform.js").Transform} transform Transform.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @return {Array<number>} Transformed coordinates.
|
||||
*/
|
||||
export function transform2D(
|
||||
@@ -17,9 +17,9 @@ export function transform2D(
|
||||
end,
|
||||
stride,
|
||||
transform,
|
||||
opt_dest
|
||||
dest
|
||||
) {
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
dest = dest ? dest : [];
|
||||
let i = 0;
|
||||
for (let j = offset; j < end; j += stride) {
|
||||
const x = flatCoordinates[j];
|
||||
@@ -27,7 +27,7 @@ export function transform2D(
|
||||
dest[i++] = transform[0] * x + transform[2] * y + transform[4];
|
||||
dest[i++] = transform[1] * x + transform[3] * y + transform[5];
|
||||
}
|
||||
if (opt_dest && dest.length != i) {
|
||||
if (dest && dest.length != i) {
|
||||
dest.length = i;
|
||||
}
|
||||
return dest;
|
||||
@@ -40,7 +40,7 @@ export function transform2D(
|
||||
* @param {number} stride Stride.
|
||||
* @param {number} angle Angle.
|
||||
* @param {Array<number>} anchor Rotation anchor point.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @return {Array<number>} Transformed coordinates.
|
||||
*/
|
||||
export function rotate(
|
||||
@@ -50,9 +50,9 @@ export function rotate(
|
||||
stride,
|
||||
angle,
|
||||
anchor,
|
||||
opt_dest
|
||||
dest
|
||||
) {
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
dest = dest ? dest : [];
|
||||
const cos = Math.cos(angle);
|
||||
const sin = Math.sin(angle);
|
||||
const anchorX = anchor[0];
|
||||
@@ -67,7 +67,7 @@ export function rotate(
|
||||
dest[i++] = flatCoordinates[k];
|
||||
}
|
||||
}
|
||||
if (opt_dest && dest.length != i) {
|
||||
if (dest && dest.length != i) {
|
||||
dest.length = i;
|
||||
}
|
||||
return dest;
|
||||
@@ -82,7 +82,7 @@ export function rotate(
|
||||
* @param {number} sx Scale factor in the x-direction.
|
||||
* @param {number} sy Scale factor in the y-direction.
|
||||
* @param {Array<number>} anchor Scale anchor point.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @return {Array<number>} Transformed coordinates.
|
||||
*/
|
||||
export function scale(
|
||||
@@ -93,9 +93,9 @@ export function scale(
|
||||
sx,
|
||||
sy,
|
||||
anchor,
|
||||
opt_dest
|
||||
dest
|
||||
) {
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
dest = dest ? dest : [];
|
||||
const anchorX = anchor[0];
|
||||
const anchorY = anchor[1];
|
||||
let i = 0;
|
||||
@@ -108,7 +108,7 @@ export function scale(
|
||||
dest[i++] = flatCoordinates[k];
|
||||
}
|
||||
}
|
||||
if (opt_dest && dest.length != i) {
|
||||
if (dest && dest.length != i) {
|
||||
dest.length = i;
|
||||
}
|
||||
return dest;
|
||||
@@ -121,7 +121,7 @@ export function scale(
|
||||
* @param {number} stride Stride.
|
||||
* @param {number} deltaX Delta X.
|
||||
* @param {number} deltaY Delta Y.
|
||||
* @param {Array<number>} [opt_dest] Destination.
|
||||
* @param {Array<number>} [dest] Destination.
|
||||
* @return {Array<number>} Transformed coordinates.
|
||||
*/
|
||||
export function translate(
|
||||
@@ -131,9 +131,9 @@ export function translate(
|
||||
stride,
|
||||
deltaX,
|
||||
deltaY,
|
||||
opt_dest
|
||||
dest
|
||||
) {
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
dest = dest ? dest : [];
|
||||
let i = 0;
|
||||
for (let j = offset; j < end; j += stride) {
|
||||
dest[i++] = flatCoordinates[j] + deltaX;
|
||||
@@ -142,7 +142,7 @@ export function translate(
|
||||
dest[i++] = flatCoordinates[k];
|
||||
}
|
||||
}
|
||||
if (opt_dest && dest.length != i) {
|
||||
if (dest && dest.length != i) {
|
||||
dest.length = i;
|
||||
}
|
||||
return dest;
|
||||
|
||||
@@ -17,12 +17,12 @@ import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
*/
|
||||
class DoubleClickZoom extends Interaction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -44,10 +44,10 @@ export class DragAndDropEvent extends Event {
|
||||
/**
|
||||
* @param {DragAndDropEventType} type Type.
|
||||
* @param {File} file File.
|
||||
* @param {Array<import("../Feature.js").default>} [opt_features] Features.
|
||||
* @param {import("../proj/Projection.js").default} [opt_projection] Projection.
|
||||
* @param {Array<import("../Feature.js").default>} [features] Features.
|
||||
* @param {import("../proj/Projection.js").default} [projection] Projection.
|
||||
*/
|
||||
constructor(type, file, opt_features, opt_projection) {
|
||||
constructor(type, file, features, projection) {
|
||||
super(type);
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ export class DragAndDropEvent extends Event {
|
||||
* @type {Array<import("../Feature.js").FeatureLike>|undefined}
|
||||
* @api
|
||||
*/
|
||||
this.features = opt_features;
|
||||
this.features = features;
|
||||
|
||||
/**
|
||||
* The dropped file.
|
||||
@@ -69,7 +69,7 @@ export class DragAndDropEvent extends Event {
|
||||
* @type {import("../proj/Projection.js").default|undefined}
|
||||
* @api
|
||||
*/
|
||||
this.projection = opt_projection;
|
||||
this.projection = projection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +93,10 @@ export class DragAndDropEvent extends Event {
|
||||
*/
|
||||
class DragAndDrop extends Interaction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
handleEvent: TRUE,
|
||||
|
||||
@@ -117,9 +117,9 @@ export class DragBoxEvent extends Event {
|
||||
*/
|
||||
class DragBox extends PointerInteraction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -137,7 +137,7 @@ class DragBox extends PointerInteraction {
|
||||
*/
|
||||
this.un;
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @type {import("../render/Box.js").default}
|
||||
|
||||
@@ -34,14 +34,14 @@ import {
|
||||
*/
|
||||
class DragPan extends PointerInteraction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super({
|
||||
stopDown: FALSE,
|
||||
});
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -30,10 +30,10 @@ import {disable} from '../rotationconstraint.js';
|
||||
*/
|
||||
class DragRotate extends PointerInteraction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super({
|
||||
stopDown: FALSE,
|
||||
|
||||
@@ -26,10 +26,10 @@ import {mouseOnly, shiftKeyOnly} from '../events/condition.js';
|
||||
*/
|
||||
class DragRotateAndZoom extends PointerInteraction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super(/** @type {import("./Pointer.js").Options} */ (options));
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ import {shiftKeyOnly} from '../events/condition.js';
|
||||
*/
|
||||
class DragZoom extends DragBox {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
const condition = options.condition ? options.condition : shiftKeyOnly;
|
||||
|
||||
|
||||
@@ -1179,17 +1179,17 @@ function getDefaultStyleFunction() {
|
||||
* Create a `geometryFunction` for `type: 'Circle'` that will create a regular
|
||||
* polygon with a user specified number of sides and start angle instead of a
|
||||
* {@link import("../geom/Circle.js").Circle} geometry.
|
||||
* @param {number} [opt_sides] Number of sides of the regular polygon.
|
||||
* @param {number} [sides] Number of sides of the regular polygon.
|
||||
* Default is 32.
|
||||
* @param {number} [opt_angle] Angle of the first point in counter-clockwise
|
||||
* @param {number} [angle] Angle of the first point in counter-clockwise
|
||||
* radians. 0 means East.
|
||||
* Default is the angle defined by the heading from the center of the
|
||||
* regular polygon to the current pointer position.
|
||||
* @return {GeometryFunction} Function that draws a polygon.
|
||||
* @api
|
||||
*/
|
||||
export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
return function (coordinates, opt_geometry, projection) {
|
||||
export function createRegularPolygon(sides, angle) {
|
||||
return function (coordinates, geometry, projection) {
|
||||
const center = fromUserCoordinate(
|
||||
/** @type {LineCoordType} */ (coordinates)[0],
|
||||
projection
|
||||
@@ -1199,17 +1199,20 @@ export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
projection
|
||||
);
|
||||
const radius = Math.sqrt(squaredCoordinateDistance(center, end));
|
||||
const geometry = opt_geometry
|
||||
? /** @type {Polygon} */ (opt_geometry)
|
||||
: fromCircle(new Circle(center), opt_sides);
|
||||
geometry = geometry || fromCircle(new Circle(center), sides);
|
||||
|
||||
let angle = opt_angle;
|
||||
if (!opt_angle && opt_angle !== 0) {
|
||||
let internalAngle = angle;
|
||||
if (!angle && angle !== 0) {
|
||||
const x = end[0] - center[0];
|
||||
const y = end[1] - center[1];
|
||||
angle = Math.atan2(y, x);
|
||||
internalAngle = Math.atan2(y, x);
|
||||
}
|
||||
makeRegular(geometry, center, radius, angle);
|
||||
makeRegular(
|
||||
/** @type {Polygon} */ (geometry),
|
||||
center,
|
||||
radius,
|
||||
internalAngle
|
||||
);
|
||||
|
||||
const userProjection = getUserProjection();
|
||||
if (userProjection) {
|
||||
@@ -1227,7 +1230,7 @@ export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
* @api
|
||||
*/
|
||||
export function createBox() {
|
||||
return function (coordinates, opt_geometry, projection) {
|
||||
return function (coordinates, geometry, projection) {
|
||||
const extent = boundingExtent(
|
||||
/** @type {LineCoordType} */ ([
|
||||
coordinates[0],
|
||||
@@ -1245,7 +1248,6 @@ export function createBox() {
|
||||
getBottomLeft(extent),
|
||||
],
|
||||
];
|
||||
let geometry = opt_geometry;
|
||||
if (geometry) {
|
||||
geometry.setCoordinates(boxCoordinates);
|
||||
} else {
|
||||
|
||||
@@ -94,10 +94,10 @@ export class ExtentEvent extends Event {
|
||||
*/
|
||||
class Extent extends PointerInteraction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options || {};
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
|
||||
super(/** @type {import("./Pointer.js").Options} */ (options));
|
||||
|
||||
@@ -166,8 +166,8 @@ class Extent extends PointerInteraction {
|
||||
*/
|
||||
this.vertexFeature_ = null;
|
||||
|
||||
if (!opt_options) {
|
||||
opt_options = {};
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,10 +178,10 @@ class Extent extends PointerInteraction {
|
||||
this.extentOverlay_ = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
useSpatialIndex: false,
|
||||
wrapX: !!opt_options.wrapX,
|
||||
wrapX: !!options.wrapX,
|
||||
}),
|
||||
style: opt_options.boxStyle
|
||||
? opt_options.boxStyle
|
||||
style: options.boxStyle
|
||||
? options.boxStyle
|
||||
: getDefaultExtentStyleFunction(),
|
||||
updateWhileAnimating: true,
|
||||
updateWhileInteracting: true,
|
||||
@@ -195,17 +195,17 @@ class Extent extends PointerInteraction {
|
||||
this.vertexOverlay_ = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
useSpatialIndex: false,
|
||||
wrapX: !!opt_options.wrapX,
|
||||
wrapX: !!options.wrapX,
|
||||
}),
|
||||
style: opt_options.pointerStyle
|
||||
? opt_options.pointerStyle
|
||||
style: options.pointerStyle
|
||||
? options.pointerStyle
|
||||
: getDefaultPointerStyleFunction(),
|
||||
updateWhileAnimating: true,
|
||||
updateWhileInteracting: true,
|
||||
});
|
||||
|
||||
if (opt_options.extent) {
|
||||
this.setExtent(opt_options.extent);
|
||||
if (options.extent) {
|
||||
this.setExtent(options.extent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ import {easeOut, linear} from '../easing.js';
|
||||
*/
|
||||
class Interaction extends BaseObject {
|
||||
/**
|
||||
* @param {InteractionOptions} [opt_options] Options.
|
||||
* @param {InteractionOptions} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
/***
|
||||
@@ -60,8 +60,8 @@ class Interaction extends BaseObject {
|
||||
*/
|
||||
this.un;
|
||||
|
||||
if (opt_options && opt_options.handleEvent) {
|
||||
this.handleEvent = opt_options.handleEvent;
|
||||
if (options && options.handleEvent) {
|
||||
this.handleEvent = options.handleEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,14 +126,14 @@ class Interaction extends BaseObject {
|
||||
/**
|
||||
* @param {import("../View.js").default} view View.
|
||||
* @param {import("../coordinate.js").Coordinate} delta Delta.
|
||||
* @param {number} [opt_duration] Duration.
|
||||
* @param {number} [duration] Duration.
|
||||
*/
|
||||
export function pan(view, delta, opt_duration) {
|
||||
export function pan(view, delta, duration) {
|
||||
const currentCenter = view.getCenterInternal();
|
||||
if (currentCenter) {
|
||||
const center = [currentCenter[0] + delta[0], currentCenter[1] + delta[1]];
|
||||
view.animateInternal({
|
||||
duration: opt_duration !== undefined ? opt_duration : 250,
|
||||
duration: duration !== undefined ? duration : 250,
|
||||
easing: linear,
|
||||
center: view.getConstrainedCenter(center),
|
||||
});
|
||||
@@ -143,10 +143,10 @@ export function pan(view, delta, opt_duration) {
|
||||
/**
|
||||
* @param {import("../View.js").default} view View.
|
||||
* @param {number} delta Delta from previous zoom level.
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_anchor] Anchor coordinate in the user projection.
|
||||
* @param {number} [opt_duration] Duration.
|
||||
* @param {import("../coordinate.js").Coordinate} [anchor] Anchor coordinate in the user projection.
|
||||
* @param {number} [duration] Duration.
|
||||
*/
|
||||
export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
|
||||
export function zoomByDelta(view, delta, anchor, duration) {
|
||||
const currentZoom = view.getZoom();
|
||||
|
||||
if (currentZoom === undefined) {
|
||||
@@ -161,8 +161,8 @@ export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
|
||||
}
|
||||
view.animate({
|
||||
resolution: newResolution,
|
||||
anchor: opt_anchor,
|
||||
duration: opt_duration !== undefined ? opt_duration : 250,
|
||||
anchor: anchor,
|
||||
duration: duration !== undefined ? duration : 250,
|
||||
easing: easeOut,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ import {rotate as rotateCoordinate} from '../coordinate.js';
|
||||
*/
|
||||
class KeyboardPan extends Interaction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options || {};
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -30,12 +30,12 @@ import {targetNotEditable} from '../events/condition.js';
|
||||
*/
|
||||
class KeyboardZoom extends Interaction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
options = options ? options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -70,14 +70,14 @@ function differentArray(a, b) {
|
||||
*/
|
||||
class Link extends Interaction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Link options.
|
||||
* @param {Options} [options] Link options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
|
||||
const options = Object.assign(
|
||||
options = Object.assign(
|
||||
{animate: true, replace: false, prefix: ''},
|
||||
opt_options || {}
|
||||
options || {}
|
||||
);
|
||||
|
||||
let animationOptions;
|
||||
|
||||
@@ -1159,11 +1159,11 @@ class Modify extends PointerInteraction {
|
||||
/**
|
||||
* @param {import("../pixel.js").Pixel} pixel Pixel
|
||||
* @param {import("../Map.js").default} map Map.
|
||||
* @param {import("../coordinate.js").Coordinate} [opt_coordinate] The pixel Coordinate.
|
||||
* @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate.
|
||||
* @private
|
||||
*/
|
||||
handlePointerAtPixel_(pixel, map, opt_coordinate) {
|
||||
const pixelCoordinate = opt_coordinate || map.getCoordinateFromPixel(pixel);
|
||||
handlePointerAtPixel_(pixel, map, coordinate) {
|
||||
const pixelCoordinate = coordinate || map.getCoordinateFromPixel(pixel);
|
||||
const projection = map.getView().getProjection();
|
||||
const sortByDistance = function (a, b) {
|
||||
return (
|
||||
|
||||
@@ -37,10 +37,10 @@ import {clamp} from '../math.js';
|
||||
*/
|
||||
class MouseWheelZoom extends Interaction {
|
||||
/**
|
||||
* @param {Options} [opt_options] Options.
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
constructor(options) {
|
||||
options = options ? options : {};
|
||||
|
||||
super(
|
||||
/** @type {import("./Interaction.js").InteractionOptions} */ (options)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user