Make code prettier

This updates ESLint and our shared eslint-config-openlayers to use Prettier.  Most formatting changes were automatically applied with this:

    npm run lint -- --fix

A few manual changes were required:

 * In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
 * In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason.  While editing this, I reworked `ExampleBuilder` to be a class.
 * In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
Tim Schaub
2020-04-06 12:25:12 -06:00
parent 53b48baf62
commit 054af09032
790 changed files with 46833 additions and 33765 deletions

View File

@@ -1,13 +1,12 @@
/**
* @module ol/layer/Base
*/
import {abstract} from '../util.js';
import BaseObject from '../Object.js';
import LayerProperty from './Property.js';
import {clamp} from '../math.js';
import {assign} from '../obj.js';
import {abstract} from '../util.js';
import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {clamp} from '../math.js';
/**
* @typedef {Object} Options
@@ -30,7 +29,6 @@ import {assert} from '../asserts.js';
* be visible.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
@@ -46,7 +44,6 @@ class BaseLayer extends BaseObject {
* @param {Options} options Layer options.
*/
constructor(options) {
super();
/**
@@ -55,26 +52,27 @@ class BaseLayer extends BaseObject {
const properties = assign({}, options);
properties[LayerProperty.OPACITY] =
options.opacity !== undefined ? options.opacity : 1;
options.opacity !== undefined ? options.opacity : 1;
assert(typeof properties[LayerProperty.OPACITY] === 'number', 64); // Layer opacity must be a number
properties[LayerProperty.VISIBLE] =
options.visible !== undefined ? options.visible : true;
options.visible !== undefined ? options.visible : true;
properties[LayerProperty.Z_INDEX] = options.zIndex;
properties[LayerProperty.MAX_RESOLUTION] =
options.maxResolution !== undefined ? options.maxResolution : Infinity;
options.maxResolution !== undefined ? options.maxResolution : Infinity;
properties[LayerProperty.MIN_RESOLUTION] =
options.minResolution !== undefined ? options.minResolution : 0;
options.minResolution !== undefined ? options.minResolution : 0;
properties[LayerProperty.MIN_ZOOM] =
options.minZoom !== undefined ? options.minZoom : -Infinity;
options.minZoom !== undefined ? options.minZoom : -Infinity;
properties[LayerProperty.MAX_ZOOM] =
options.maxZoom !== undefined ? options.maxZoom : Infinity;
options.maxZoom !== undefined ? options.maxZoom : Infinity;
/**
* @type {string}
* @private
*/
this.className_ = properties.className !== undefined ? options.className : 'ol-layer';
this.className_ =
properties.className !== undefined ? options.className : 'ol-layer';
delete properties.className;
this.setProperties(properties);
@@ -84,7 +82,6 @@ class BaseLayer extends BaseObject {
* @private
*/
this.state_ = null;
}
/**
@@ -103,16 +100,19 @@ class BaseLayer extends BaseObject {
*/
getLayerState(opt_managed) {
/** @type {import("./Layer.js").State} */
const state = this.state_ || /** @type {?} */ ({
layer: this,
managed: opt_managed === undefined ? true : opt_managed
});
const state =
this.state_ ||
/** @type {?} */ ({
layer: this,
managed: opt_managed === undefined ? true : opt_managed,
});
const zIndex = this.getZIndex();
state.opacity = clamp(Math.round(this.getOpacity() * 100) / 100, 0, 1);
state.sourceState = this.getSourceState();
state.visible = this.getVisible();
state.extent = this.getExtent();
state.zIndex = zIndex !== undefined ? zIndex : (state.managed === false ? Infinity : 0);
state.zIndex =
zIndex !== undefined ? zIndex : state.managed === false ? Infinity : 0;
state.maxResolution = this.getMaxResolution();
state.minResolution = Math.max(this.getMinResolution(), 0);
state.minZoom = this.getMinZoom();
@@ -150,9 +150,9 @@ class BaseLayer extends BaseObject {
* @api
*/
getExtent() {
return (
/** @type {import("../extent.js").Extent|undefined} */ (this.get(LayerProperty.EXTENT))
);
return /** @type {import("../extent.js").Extent|undefined} */ (this.get(
LayerProperty.EXTENT
));
}
/**
@@ -333,5 +333,4 @@ class BaseLayer extends BaseObject {
}
}
export default BaseLayer;

View File

@@ -3,7 +3,6 @@
*/
import Layer from './Layer.js';
/**
* @typedef {Object} Options
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
@@ -30,7 +29,6 @@ import Layer from './Layer.js';
* @property {import("../source/Image.js").default} [source] Source for this layer.
*/
/**
* @classdesc
* Server-rendered images that are available for arbitrary extents and
@@ -43,7 +41,6 @@ import Layer from './Layer.js';
* @api
*/
class BaseImageLayer extends Layer {
/**
* @param {Options=} opt_options Layer options.
*/
@@ -51,7 +48,6 @@ class BaseImageLayer extends Layer {
const options = opt_options ? opt_options : {};
super(options);
}
}
export default BaseImageLayer;

View File

@@ -5,7 +5,6 @@ import Layer from './Layer.js';
import TileProperty from './TileProperty.js';
import {assign} from '../obj.js';
/**
* @typedef {Object} Options
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
@@ -35,7 +34,6 @@ import {assign} from '../obj.js';
* @property {boolean} [useInterimTilesOnError=true] Use interim tiles on error.
*/
/**
* @classdesc
* For layer sources that provide pre-rendered, tiled images in grids that are
@@ -61,51 +59,54 @@ class BaseTileLayer extends Layer {
super(baseOptions);
this.setPreload(options.preload !== undefined ? options.preload : 0);
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
options.useInterimTilesOnError : true);
this.setUseInterimTilesOnError(
options.useInterimTilesOnError !== undefined
? options.useInterimTilesOnError
: true
);
}
/**
* Return the level as number to which we will preload tiles up to.
* @return {number} The level to preload tiles up to.
* @observable
* @api
*/
* Return the level as number to which we will preload tiles up to.
* @return {number} The level to preload tiles up to.
* @observable
* @api
*/
getPreload() {
return /** @type {number} */ (this.get(TileProperty.PRELOAD));
}
/**
* Set the level as number to which we will preload tiles up to.
* @param {number} preload The level to preload tiles up to.
* @observable
* @api
*/
* Set the level as number to which we will preload tiles up to.
* @param {number} preload The level to preload tiles up to.
* @observable
* @api
*/
setPreload(preload) {
this.set(TileProperty.PRELOAD, preload);
}
/**
* Whether we use interim tiles on error.
* @return {boolean} Use interim tiles on error.
* @observable
* @api
*/
* Whether we use interim tiles on error.
* @return {boolean} Use interim tiles on error.
* @observable
* @api
*/
getUseInterimTilesOnError() {
return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
return /** @type {boolean} */ (this.get(
TileProperty.USE_INTERIM_TILES_ON_ERROR
));
}
/**
* Set whether we use interim tiles on error.
* @param {boolean} useInterimTilesOnError Use interim tiles on error.
* @observable
* @api
*/
* Set whether we use interim tiles on error.
* @param {boolean} useInterimTilesOnError Use interim tiles on error.
* @observable
* @api
*/
setUseInterimTilesOnError(useInterimTilesOnError) {
this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
}
}
export default BaseTileLayer;

View File

@@ -3,8 +3,10 @@
*/
import Layer from './Layer.js';
import {assign} from '../obj.js';
import {createDefaultStyle, toFunction as toStyleFunction} from '../style/Style.js';
import {
createDefaultStyle,
toFunction as toStyleFunction,
} from '../style/Style.js';
/**
* @typedef {Object} Options
@@ -51,16 +53,14 @@ import {createDefaultStyle, toFunction as toStyleFunction} from '../style/Style.
* be recreated during interactions. See also `updateWhileAnimating`.
*/
/**
* @enum {string}
* @private
*/
const Property = {
RENDER_ORDER: 'renderOrder'
RENDER_ORDER: 'renderOrder',
};
/**
* @classdesc
* Vector data that is rendered client-side.
@@ -91,14 +91,15 @@ class BaseVectorLayer extends Layer {
* @private
* @type {boolean}
*/
this.declutter_ = options.declutter !== undefined ? options.declutter : false;
this.declutter_ =
options.declutter !== undefined ? options.declutter : false;
/**
* @type {number}
* @private
*/
this.renderBuffer_ = options.renderBuffer !== undefined ?
options.renderBuffer : 100;
this.renderBuffer_ =
options.renderBuffer !== undefined ? options.renderBuffer : 100;
/**
* User provided style.
@@ -120,16 +121,19 @@ class BaseVectorLayer extends Layer {
* @type {boolean}
* @private
*/
this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ?
options.updateWhileAnimating : false;
this.updateWhileAnimating_ =
options.updateWhileAnimating !== undefined
? options.updateWhileAnimating
: false;
/**
* @type {boolean}
* @private
*/
this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ?
options.updateWhileInteracting : false;
this.updateWhileInteracting_ =
options.updateWhileInteracting !== undefined
? options.updateWhileInteracting
: false;
}
/**
@@ -169,9 +173,9 @@ class BaseVectorLayer extends Layer {
* order.
*/
getRenderOrder() {
return (
/** @type {import("../render.js").OrderFunction|null|undefined} */ (this.get(Property.RENDER_ORDER))
);
return /** @type {import("../render.js").OrderFunction|null|undefined} */ (this.get(
Property.RENDER_ORDER
));
}
/**
@@ -230,12 +234,10 @@ class BaseVectorLayer extends Layer {
*/
setStyle(style) {
this.style_ = style !== undefined ? style : createDefaultStyle;
this.styleFunction_ = style === null ?
undefined : toStyleFunction(this.style_);
this.styleFunction_ =
style === null ? undefined : toStyleFunction(this.style_);
this.changed();
}
}
export default BaseVectorLayer;

View File

@@ -1,43 +1,42 @@
/**
* @module ol/layer/Graticule
*/
import VectorLayer from './Vector.js';
import {assign} from '../obj.js';
import {degreesToStringHDMS} from '../coordinate.js';
import Text from '../style/Text.js';
import Collection from '../Collection.js';
import EventType from '../render/EventType.js';
import Feature from '../Feature.js';
import Fill from '../style/Fill.js';
import Stroke from '../style/Stroke.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import Point from '../geom/Point.js';
import Stroke from '../style/Stroke.js';
import Style from '../style/Style.js';
import Text from '../style/Text.js';
import VectorLayer from './Vector.js';
import VectorSource from '../source/Vector.js';
import {
equivalent as equivalentProjection,
get as getProjection,
getTransform
} from '../proj.js';
import {
applyTransform,
approximatelyEquals,
containsCoordinate,
containsExtent,
equals,
approximatelyEquals,
getCenter,
getHeight,
getIntersection,
getWidth,
intersects,
isEmpty,
wrapX as wrapExtentX
wrapX as wrapExtentX,
} from '../extent.js';
import {assign} from '../obj.js';
import {clamp} from '../math.js';
import Style from '../style/Style.js';
import Feature from '../Feature.js';
import {meridian, parallel} from '../geom/flat/geodesic.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import Point from '../geom/Point.js';
import Collection from '../Collection.js';
import {degreesToStringHDMS} from '../coordinate.js';
import {
equivalent as equivalentProjection,
get as getProjection,
getTransform,
} from '../proj.js';
import {getVectorContext} from '../render.js';
import EventType from '../render/EventType.js';
import {meridian, parallel} from '../geom/flat/geodesic.js';
/**
* @type {Stroke}
@@ -45,7 +44,7 @@ import EventType from '../render/EventType.js';
* @const
*/
const DEFAULT_STROKE_STYLE = new Stroke({
color: 'rgba(0,0,0,0.2)'
color: 'rgba(0,0,0,0.2)',
});
/**
@@ -53,7 +52,22 @@ const DEFAULT_STROKE_STYLE = new Stroke({
* @private
*/
const INTERVALS = [
90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001
90,
45,
30,
20,
10,
5,
2,
1,
0.5,
0.2,
0.1,
0.05,
0.01,
0.005,
0.002,
0.001,
];
/**
@@ -62,7 +76,6 @@ const INTERVALS = [
* @property {string} text
*/
/**
* @typedef {Object} Options
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
@@ -153,7 +166,6 @@ const INTERVALS = [
* @property {boolean} [wrapX=true] Whether to repeat the graticule horizontally.
*/
/**
* @classdesc
* Layer that renders a grid for a coordinate system (currently only EPSG:4326 is supported).
@@ -169,11 +181,14 @@ class Graticule extends VectorLayer {
constructor(opt_options) {
const options = opt_options ? opt_options : {};
const baseOptions = assign({
updateWhileAnimating: true,
updateWhileInteracting: true,
renderBuffer: 0
}, options);
const baseOptions = assign(
{
updateWhileAnimating: true,
updateWhileInteracting: true,
renderBuffer: 0,
},
options
);
delete baseOptions.maxLines;
delete baseOptions.strokeStyle;
@@ -245,7 +260,8 @@ class Graticule extends VectorLayer {
* @type {number}
* @private
*/
this.targetSize_ = options.targetSize !== undefined ? options.targetSize : 100;
this.targetSize_ =
options.targetSize !== undefined ? options.targetSize : 100;
/**
* @type {number}
@@ -269,7 +285,10 @@ class Graticule extends VectorLayer {
* @type {Stroke}
* @private
*/
this.strokeStyle_ = options.strokeStyle !== undefined ? options.strokeStyle : DEFAULT_STROKE_STYLE;
this.strokeStyle_ =
options.strokeStyle !== undefined
? options.strokeStyle
: DEFAULT_STROKE_STYLE;
/**
* @type {import("../proj.js").TransformFunction|undefined}
@@ -326,20 +345,23 @@ class Graticule extends VectorLayer {
this.parallelsLabels_ = null;
if (options.showLabels) {
/**
* @type {null|function(number):string}
* @private
*/
this.lonLabelFormatter_ = options.lonLabelFormatter == undefined ?
degreesToStringHDMS.bind(this, 'EW') : options.lonLabelFormatter;
this.lonLabelFormatter_ =
options.lonLabelFormatter == undefined
? degreesToStringHDMS.bind(this, 'EW')
: options.lonLabelFormatter;
/**
* @type {function(number):string}
* @private
*/
this.latLabelFormatter_ = options.latLabelFormatter == undefined ?
degreesToStringHDMS.bind(this, 'NS') : options.latLabelFormatter;
this.latLabelFormatter_ =
options.latLabelFormatter == undefined
? degreesToStringHDMS.bind(this, 'NS')
: options.latLabelFormatter;
/**
* Longitude label position in fractions (0..1) of view extent. 0 means
@@ -347,8 +369,8 @@ class Graticule extends VectorLayer {
* @type {number}
* @private
*/
this.lonLabelPosition_ = options.lonLabelPosition == undefined ? 0 :
options.lonLabelPosition;
this.lonLabelPosition_ =
options.lonLabelPosition == undefined ? 0 : options.lonLabelPosition;
/**
* Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
@@ -356,26 +378,28 @@ class Graticule extends VectorLayer {
* @type {number}
* @private
*/
this.latLabelPosition_ = options.latLabelPosition == undefined ? 1 :
options.latLabelPosition;
this.latLabelPosition_ =
options.latLabelPosition == undefined ? 1 : options.latLabelPosition;
/**
* @type {Style}
* @private
*/
this.lonLabelStyleBase_ = new Style({
text: options.lonLabelStyle !== undefined ? options.lonLabelStyle.clone() :
new Text({
font: '12px Calibri,sans-serif',
textBaseline: 'bottom',
fill: new Fill({
color: 'rgba(0,0,0,1)'
}),
stroke: new Stroke({
color: 'rgba(255,255,255,1)',
width: 3
})
})
text:
options.lonLabelStyle !== undefined
? options.lonLabelStyle.clone()
: new Text({
font: '12px Calibri,sans-serif',
textBaseline: 'bottom',
fill: new Fill({
color: 'rgba(0,0,0,1)',
}),
stroke: new Stroke({
color: 'rgba(255,255,255,1)',
width: 3,
}),
}),
});
/**
@@ -383,7 +407,7 @@ class Graticule extends VectorLayer {
* @param {import("../Feature").default} feature Feature
* @return {Style} style
*/
this.lonLabelStyle_ = function(feature) {
this.lonLabelStyle_ = function (feature) {
const label = feature.get('graticule_label');
this.lonLabelStyleBase_.getText().setText(label);
return this.lonLabelStyleBase_;
@@ -394,18 +418,20 @@ class Graticule extends VectorLayer {
* @private
*/
this.latLabelStyleBase_ = new Style({
text: options.latLabelStyle !== undefined ? options.latLabelStyle.clone() :
new Text({
font: '12px Calibri,sans-serif',
textAlign: 'right',
fill: new Fill({
color: 'rgba(0,0,0,1)'
}),
stroke: new Stroke({
color: 'rgba(255,255,255,1)',
width: 3
})
})
text:
options.latLabelStyle !== undefined
? options.latLabelStyle.clone()
: new Text({
font: '12px Calibri,sans-serif',
textAlign: 'right',
fill: new Fill({
color: 'rgba(0,0,0,1)',
}),
stroke: new Stroke({
color: 'rgba(255,255,255,1)',
width: 3,
}),
}),
});
/**
@@ -413,7 +439,7 @@ class Graticule extends VectorLayer {
* @param {import("../Feature").default} feature Feature
* @return {Style} style
*/
this.latLabelStyle_ = function(feature) {
this.latLabelStyle_ = function (feature) {
const label = feature.get('graticule_label');
this.latLabelStyleBase_.getText().setText(label);
return this.latLabelStyleBase_;
@@ -429,7 +455,8 @@ class Graticule extends VectorLayer {
* @type {Array<number>}
* @private
*/
this.intervals_ = options.intervals !== undefined ? options.intervals : INTERVALS;
this.intervals_ =
options.intervals !== undefined ? options.intervals : INTERVALS;
// use a source with a custom loader for lines & text
this.setSource(
@@ -439,7 +466,7 @@ class Graticule extends VectorLayer {
features: new Collection(),
overlaps: false,
useSpatialIndex: false,
wrapX: options.wrapX
wrapX: options.wrapX,
})
);
@@ -455,7 +482,7 @@ class Graticule extends VectorLayer {
* @private
*/
this.lineStyle_ = new Style({
stroke: this.strokeStyle_
stroke: this.strokeStyle_,
});
/**
@@ -470,7 +497,6 @@ class Graticule extends VectorLayer {
this.renderedExtent_ = null;
this.setRenderOrder(null);
}
/**
@@ -487,7 +513,9 @@ class Graticule extends VectorLayer {
wrapExtentX(realWorldExtent, this.projection_);
}
if (this.loadedExtent_) {
if (approximatelyEquals(this.loadedExtent_, realWorldExtent, resolution)) {
if (
approximatelyEquals(this.loadedExtent_, realWorldExtent, resolution)
) {
// make sure result is exactly equal to previous extent
realWorldExtent = this.loadedExtent_.slice();
} else {
@@ -509,7 +537,12 @@ class Graticule extends VectorLayer {
const source = this.getSource();
// only consider the intersection between our own extent & the requested one
const layerExtent = this.getExtent() || [-Infinity, -Infinity, Infinity, Infinity];
const layerExtent = this.getExtent() || [
-Infinity,
-Infinity,
Infinity,
Infinity,
];
const renderExtent = getIntersection(layerExtent, extent);
if (this.renderedExtent_ && equals(this.renderedExtent_, renderExtent)) {
@@ -524,10 +557,10 @@ class Graticule extends VectorLayer {
// update projection info
const center = getCenter(renderExtent);
const squaredTolerance = resolution * resolution / 4;
const squaredTolerance = (resolution * resolution) / 4;
const updateProjectionInfo = !this.projection_ ||
!equivalentProjection(this.projection_, projection);
const updateProjectionInfo =
!this.projection_ || !equivalentProjection(this.projection_, projection);
if (updateProjectionInfo) {
this.updateProjectionInfo_(projection);
@@ -581,7 +614,13 @@ class Graticule extends VectorLayer {
* @private
*/
addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, index) {
const lineString = this.getMeridian_(lon, minLat, maxLat, squaredTolerance, index);
const lineString = this.getMeridian_(
lon,
minLat,
maxLat,
squaredTolerance,
index
);
if (intersects(lineString.getExtent(), extent)) {
if (this.meridiansLabels_) {
const text = this.lonLabelFormatter_(lon);
@@ -590,7 +629,7 @@ class Graticule extends VectorLayer {
} else {
this.meridiansLabels_[index] = {
geom: new Point([]),
text: text
text: text,
};
}
}
@@ -610,7 +649,13 @@ class Graticule extends VectorLayer {
* @private
*/
addParallel_(lat, minLon, maxLon, squaredTolerance, extent, index) {
const lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance, index);
const lineString = this.getParallel_(
lat,
minLon,
maxLon,
squaredTolerance,
index
);
if (intersects(lineString.getExtent(), extent)) {
if (this.parallelsLabels_) {
const text = this.latLabelFormatter_(lat);
@@ -619,7 +664,7 @@ class Graticule extends VectorLayer {
} else {
this.parallelsLabels_[index] = {
geom: new Point([]),
text: text
text: text,
};
}
}
@@ -645,8 +690,10 @@ class Graticule extends VectorLayer {
const unrotatedWidth = (sr * height - cr * width) / (sr * sr - cr * cr);
const unrotatedHeight = (sr * width - cr * height) / (sr * sr - cr * cr);
rotationExtent = [
rotationCenter[0] - unrotatedWidth / 2, rotationCenter[1] - unrotatedHeight / 2,
rotationCenter[0] + unrotatedWidth / 2, rotationCenter[1] + unrotatedHeight / 2
rotationCenter[0] - unrotatedWidth / 2,
rotationCenter[1] - unrotatedHeight / 2,
rotationCenter[0] + unrotatedWidth / 2,
rotationCenter[1] + unrotatedHeight / 2,
];
}
@@ -655,7 +702,11 @@ class Graticule extends VectorLayer {
let labelsAtStart = this.latLabelPosition_ < 0.5;
const projectionExtent = this.projection_.getExtent();
const worldWidth = getWidth(projectionExtent);
if (this.getSource().getWrapX() && this.projection_.canWrapX() && !containsExtent(projectionExtent, extent)) {
if (
this.getSource().getWrapX() &&
this.projection_.canWrapX() &&
!containsExtent(projectionExtent, extent)
) {
startWorld = Math.floor((extent[0] - projectionExtent[0]) / worldWidth);
endWorld = Math.ceil((extent[2] - projectionExtent[2]) / worldWidth);
const inverted = Math.abs(rotation) > Math.PI / 2;
@@ -686,7 +737,10 @@ class Graticule extends VectorLayer {
}
}
if (this.parallelsLabels_) {
if (world === startWorld && labelsAtStart || world === endWorld && !labelsAtStart) {
if (
(world === startWorld && labelsAtStart) ||
(world === endWorld && !labelsAtStart)
) {
for (index = 0, l = this.parallels_.length; index < l; ++index) {
const lineString = this.parallels_[index];
if (!rotation && world === 0) {
@@ -732,7 +786,11 @@ class Graticule extends VectorLayer {
let wrapX = false;
const projectionExtent = this.projection_.getExtent();
const worldWidth = getWidth(projectionExtent);
if (this.getSource().getWrapX() && this.projection_.canWrapX() && !containsExtent(projectionExtent, extent)) {
if (
this.getSource().getWrapX() &&
this.projection_.canWrapX() &&
!containsExtent(projectionExtent, extent)
) {
if (getWidth(extent) >= worldWidth) {
extent[0] = projectionExtent[0];
extent[2] = projectionExtent[2];
@@ -745,7 +803,7 @@ class Graticule extends VectorLayer {
const validCenterP = [
clamp(center[0], this.minX_, this.maxX_),
clamp(center[1], this.minY_, this.maxY_)
clamp(center[1], this.minY_, this.maxY_),
];
// Transform the center to lon lat
@@ -754,8 +812,10 @@ class Graticule extends VectorLayer {
const centerLonLat = this.toLonLatTransform_(validCenterP);
if (isNaN(centerLonLat[1])) {
centerLonLat[1] = Math.abs(this.maxLat_) >= Math.abs(this.minLat_) ?
this.maxLat_ : this.minLat_;
centerLonLat[1] =
Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
? this.maxLat_
: this.minLat_;
}
let centerLon = clamp(centerLonLat[0], this.minLon_, this.maxLon_);
let centerLat = clamp(centerLonLat[1], this.minLat_, this.maxLat_);
@@ -770,13 +830,18 @@ class Graticule extends VectorLayer {
clamp(extent[0], this.minX_, this.maxX_),
clamp(extent[1], this.minY_, this.maxY_),
clamp(extent[2], this.minX_, this.maxX_),
clamp(extent[3], this.minY_, this.maxY_)
clamp(extent[3], this.minY_, this.maxY_),
];
}
// Transform the extent to get the lon lat ranges for the edges of the extent
const validExtent = applyTransform(validExtentP, this.toLonLatTransform_, undefined, 8);
const validExtent = applyTransform(
validExtentP,
this.toLonLatTransform_,
undefined,
8
);
let maxLat = validExtent[3];
let maxLon = validExtent[2];
@@ -784,7 +849,6 @@ class Graticule extends VectorLayer {
let minLon = validExtent[0];
if (!wrapX) {
// Check if extremities of the world extent lie inside the extent
// (for example the pole in a polar projection)
// and extend the extent as appropriate
@@ -812,7 +876,6 @@ class Graticule extends VectorLayer {
maxLon = clamp(maxLon, centerLon, this.maxLon_);
minLat = clamp(minLat, this.minLat_, centerLat);
minLon = clamp(minLon, this.minLon_, centerLon);
}
// Create meridians
@@ -825,12 +888,26 @@ class Graticule extends VectorLayer {
cnt = 0;
if (wrapX) {
while ((lon -= interval) >= minLon && cnt++ < maxLines) {
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
idx = this.addMeridian_(
lon,
minLat,
maxLat,
squaredTolerance,
extent,
idx
);
}
} else {
while (lon != this.minLon_ && cnt++ < maxLines) {
lon = Math.max(lon - interval, this.minLon_);
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
idx = this.addMeridian_(
lon,
minLat,
maxLat,
squaredTolerance,
extent,
idx
);
}
}
@@ -839,12 +916,26 @@ class Graticule extends VectorLayer {
cnt = 0;
if (wrapX) {
while ((lon += interval) <= maxLon && cnt++ < maxLines) {
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
idx = this.addMeridian_(
lon,
minLat,
maxLat,
squaredTolerance,
extent,
idx
);
}
} else {
while (lon != this.maxLon_ && cnt++ < maxLines) {
lon = Math.min(lon + interval, this.maxLon_);
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
idx = this.addMeridian_(
lon,
minLat,
maxLat,
squaredTolerance,
extent,
idx
);
}
}
@@ -863,7 +954,14 @@ class Graticule extends VectorLayer {
cnt = 0;
while (lat != this.minLat_ && cnt++ < maxLines) {
lat = Math.max(lat - interval, this.minLat_);
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
idx = this.addParallel_(
lat,
minLon,
maxLon,
squaredTolerance,
extent,
idx
);
}
lat = clamp(centerLat, this.minLat_, this.maxLat_);
@@ -871,14 +969,20 @@ class Graticule extends VectorLayer {
cnt = 0;
while (lat != this.maxLat_ && cnt++ < maxLines) {
lat = Math.min(lat + interval, this.maxLat_);
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
idx = this.addParallel_(
lat,
minLon,
maxLon,
squaredTolerance,
extent,
idx
);
}
this.parallels_.length = idx;
if (this.parallelsLabels_) {
this.parallelsLabels_.length = idx;
}
}
/**
@@ -924,7 +1028,13 @@ class Graticule extends VectorLayer {
* @private
*/
getMeridian_(lon, minLat, maxLat, squaredTolerance, index) {
const flatCoordinates = meridian(lon, minLat, maxLat, this.projection_, squaredTolerance);
const flatCoordinates = meridian(
lon,
minLat,
maxLat,
this.projection_,
squaredTolerance
);
let lineString = this.meridians_[index];
if (!lineString) {
lineString = new LineString(flatCoordinates, GeometryLayout.XY);
@@ -955,10 +1065,14 @@ class Graticule extends VectorLayer {
const clampedTop = Math.min(extent[3], flatCoordinates[top]);
const lat = clamp(
extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_,
clampedBottom, clampedTop);
const coordinate0 = flatCoordinates[bottom - 1] +
(flatCoordinates[top - 1] - flatCoordinates[bottom - 1]) * (lat - flatCoordinates[bottom]) /
(flatCoordinates[top] - flatCoordinates[bottom]);
clampedBottom,
clampedTop
);
const coordinate0 =
flatCoordinates[bottom - 1] +
((flatCoordinates[top - 1] - flatCoordinates[bottom - 1]) *
(lat - flatCoordinates[bottom])) /
(flatCoordinates[top] - flatCoordinates[bottom]);
const coordinate = [coordinate0, lat];
const point = this.meridiansLabels_[index].geom;
point.setCoordinates(coordinate);
@@ -984,7 +1098,13 @@ class Graticule extends VectorLayer {
* @private
*/
getParallel_(lat, minLon, maxLon, squaredTolerance, index) {
const flatCoordinates = parallel(lat, minLon, maxLon, this.projection_, squaredTolerance);
const flatCoordinates = parallel(
lat,
minLon,
maxLon,
this.projection_,
squaredTolerance
);
let lineString = this.parallels_[index];
if (!lineString) {
lineString = new LineString(flatCoordinates, GeometryLayout.XY);
@@ -995,7 +1115,6 @@ class Graticule extends VectorLayer {
return lineString;
}
/**
* @param {LineString} lineString Parallels.
* @param {import("../extent.js").Extent} extent Extent.
@@ -1015,10 +1134,14 @@ class Graticule extends VectorLayer {
const clampedRight = Math.min(extent[2], flatCoordinates[right]);
const lon = clamp(
extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_,
clampedLeft, clampedRight);
const coordinate1 = flatCoordinates[left + 1] +
(flatCoordinates[right + 1] - flatCoordinates[left + 1]) * (lon - flatCoordinates[left]) /
(flatCoordinates[right] - flatCoordinates[left]);
clampedLeft,
clampedRight
);
const coordinate1 =
flatCoordinates[left + 1] +
((flatCoordinates[right + 1] - flatCoordinates[left + 1]) *
(lon - flatCoordinates[left])) /
(flatCoordinates[right] - flatCoordinates[left]);
const coordinate = [lon, coordinate1];
const point = this.parallelsLabels_[index].geom;
point.setCoordinates(coordinate);
@@ -1057,9 +1180,17 @@ class Graticule extends VectorLayer {
} else {
const split = this.minLon_ + this.maxLon_ / 2;
this.maxLon_ += 360;
this.toLonLatTransform_ = function(coordinates, opt_output, opt_dimension) {
this.toLonLatTransform_ = function (
coordinates,
opt_output,
opt_dimension
) {
const dimension = opt_dimension || 2;
const lonLatCoordinates = toLonLatTransform(coordinates, opt_output, dimension);
const lonLatCoordinates = toLonLatTransform(
coordinates,
opt_output,
dimension
);
for (let i = 0, l = lonLatCoordinates.length; i < l; i += dimension) {
if (lonLatCoordinates[i] < split) {
lonLatCoordinates[i] += 360;
@@ -1097,15 +1228,18 @@ class Graticule extends VectorLayer {
// Some projections may have a void area at the poles
// so replace any NaN latitudes with the min or max value closest to a pole
this.projectionCenterLonLat_ = this.toLonLatTransform_(getCenter(projection.getExtent()));
this.projectionCenterLonLat_ = this.toLonLatTransform_(
getCenter(projection.getExtent())
);
if (isNaN(this.projectionCenterLonLat_[1])) {
this.projectionCenterLonLat_[1] = Math.abs(this.maxLat_) >= Math.abs(this.minLat_) ?
this.maxLat_ : this.minLat_;
this.projectionCenterLonLat_[1] =
Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
? this.maxLat_
: this.minLat_;
}
this.projection_ = projection;
}
}
export default Graticule;

View File

@@ -1,19 +1,18 @@
/**
* @module ol/layer/Group
*/
import {getUid} from '../util.js';
import BaseLayer from './Base.js';
import Collection from '../Collection.js';
import CollectionEventType from '../CollectionEventType.js';
import {getChangeEventType} from '../Object.js';
import ObjectEventType from '../ObjectEventType.js';
import {assert} from '../asserts.js';
import {listen, unlistenByKey} from '../events.js';
import EventType from '../events/EventType.js';
import {getIntersection} from '../extent.js';
import BaseLayer from './Base.js';
import {assign, clear} from '../obj.js';
import ObjectEventType from '../ObjectEventType.js';
import SourceState from '../source/State.js';
import {assert} from '../asserts.js';
import {assign, clear} from '../obj.js';
import {getChangeEventType} from '../Object.js';
import {getIntersection} from '../extent.js';
import {getUid} from '../util.js';
import {listen, unlistenByKey} from '../events.js';
/**
* @typedef {Object} Options
@@ -40,16 +39,14 @@ import SourceState from '../source/State.js';
* @property {Array<import("./Base.js").default>|import("../Collection.js").default<import("./Base.js").default>} [layers] Child layers.
*/
/**
* @enum {string}
* @private
*/
const Property = {
LAYERS: 'layers'
LAYERS: 'layers',
};
/**
* @classdesc
* A {@link module:ol/Collection~Collection} of layers that are handled together.
@@ -63,7 +60,6 @@ class LayerGroup extends BaseLayer {
* @param {Options=} opt_options Layer options.
*/
constructor(opt_options) {
const options = opt_options || {};
const baseOptions = /** @type {Options} */ (assign({}, options));
delete baseOptions.layers;
@@ -84,21 +80,22 @@ class LayerGroup extends BaseLayer {
*/
this.listenerKeys_ = {};
this.addEventListener(getChangeEventType(Property.LAYERS), this.handleLayersChanged_);
this.addEventListener(
getChangeEventType(Property.LAYERS),
this.handleLayersChanged_
);
if (layers) {
if (Array.isArray(layers)) {
layers = new Collection(layers.slice(), {unique: true});
} else {
assert(typeof /** @type {?} */ (layers).getArray === 'function',
43); // Expected `layers` to be an array or a `Collection`
assert(typeof (/** @type {?} */ (layers).getArray) === 'function', 43); // Expected `layers` to be an array or a `Collection`
}
} else {
layers = new Collection(undefined, {unique: true});
}
this.setLayers(layers);
}
/**
@@ -130,8 +127,13 @@ class LayerGroup extends BaseLayer {
for (let i = 0, ii = layersArray.length; i < ii; i++) {
const layer = layersArray[i];
this.listenerKeys_[getUid(layer)] = [
listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
listen(layer, EventType.CHANGE, this.handleLayerChange_, this)
listen(
layer,
ObjectEventType.PROPERTYCHANGE,
this.handleLayerChange_,
this
),
listen(layer, EventType.CHANGE, this.handleLayerChange_, this),
];
}
@@ -145,8 +147,13 @@ class LayerGroup extends BaseLayer {
handleLayersAdd_(collectionEvent) {
const layer = /** @type {import("./Base.js").default} */ (collectionEvent.element);
this.listenerKeys_[getUid(layer)] = [
listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
listen(layer, EventType.CHANGE, this.handleLayerChange_, this)
listen(
layer,
ObjectEventType.PROPERTYCHANGE,
this.handleLayerChange_,
this
),
listen(layer, EventType.CHANGE, this.handleLayerChange_, this),
];
this.changed();
}
@@ -172,9 +179,9 @@ class LayerGroup extends BaseLayer {
* @api
*/
getLayers() {
return (
/** @type {!import("../Collection.js").default<import("./Base.js").default>} */ (this.get(Property.LAYERS))
);
return /** @type {!import("../Collection.js").default<import("./Base.js").default>} */ (this.get(
Property.LAYERS
));
}
/**
@@ -195,7 +202,7 @@ class LayerGroup extends BaseLayer {
*/
getLayersArray(opt_array) {
const array = opt_array !== undefined ? opt_array : [];
this.getLayers().forEach(function(layer) {
this.getLayers().forEach(function (layer) {
layer.getLayersArray(array);
});
return array;
@@ -210,7 +217,7 @@ class LayerGroup extends BaseLayer {
const pos = states.length;
this.getLayers().forEach(function(layer) {
this.getLayers().forEach(function (layer) {
layer.getLayerStatesArray(states);
});
@@ -220,16 +227,21 @@ class LayerGroup extends BaseLayer {
layerState.opacity *= ownLayerState.opacity;
layerState.visible = layerState.visible && ownLayerState.visible;
layerState.maxResolution = Math.min(
layerState.maxResolution, ownLayerState.maxResolution);
layerState.maxResolution,
ownLayerState.maxResolution
);
layerState.minResolution = Math.max(
layerState.minResolution, ownLayerState.minResolution);
layerState.minZoom = Math.max(
layerState.minZoom, ownLayerState.minZoom);
layerState.maxZoom = Math.min(
layerState.maxZoom, ownLayerState.maxZoom);
layerState.minResolution,
ownLayerState.minResolution
);
layerState.minZoom = Math.max(layerState.minZoom, ownLayerState.minZoom);
layerState.maxZoom = Math.min(layerState.maxZoom, ownLayerState.maxZoom);
if (ownLayerState.extent !== undefined) {
if (layerState.extent !== undefined) {
layerState.extent = getIntersection(layerState.extent, ownLayerState.extent);
layerState.extent = getIntersection(
layerState.extent,
ownLayerState.extent
);
} else {
layerState.extent = ownLayerState.extent;
}
@@ -247,5 +259,4 @@ class LayerGroup extends BaseLayer {
}
}
export default LayerGroup;

View File

@@ -1,13 +1,12 @@
/**
* @module ol/layer/Heatmap
*/
import {getChangeEventType} from '../Object.js';
import {createCanvasContext2D} from '../dom.js';
import VectorLayer from './Vector.js';
import {clamp} from '../math.js';
import {assign} from '../obj.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {assign} from '../obj.js';
import {clamp} from '../math.js';
import {createCanvasContext2D} from '../dom.js';
import {getChangeEventType} from '../Object.js';
/**
* @typedef {Object} Options
@@ -38,7 +37,6 @@ import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
* @property {import("../source/Vector.js").default} [source] Source.
*/
/**
* @enum {string}
* @private
@@ -46,17 +44,15 @@ import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
const Property = {
BLUR: 'blur',
GRADIENT: 'gradient',
RADIUS: 'radius'
RADIUS: 'radius',
};
/**
* @const
* @type {Array<string>}
*/
const DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00'];
/**
* @classdesc
* Layer for rendering vector data as a heatmap.
@@ -88,7 +84,10 @@ class Heatmap extends VectorLayer {
*/
this.gradient_ = null;
this.addEventListener(getChangeEventType(Property.GRADIENT), this.handleGradientChanged_);
this.addEventListener(
getChangeEventType(Property.GRADIENT),
this.handleGradientChanged_
);
this.setGradient(options.gradient ? options.gradient : DEFAULT_GRADIENT);
@@ -98,7 +97,7 @@ class Heatmap extends VectorLayer {
const weight = options.weight ? options.weight : 'weight';
if (typeof weight === 'string') {
this.weightFunction_ = function(feature) {
this.weightFunction_ = function (feature) {
return feature.get(weight);
};
} else {
@@ -186,11 +185,11 @@ class Heatmap extends VectorLayer {
attributes: [
{
name: 'weight',
callback: function(feature) {
callback: function (feature) {
const weight = this.weightFunction_(feature);
return weight !== undefined ? clamp(weight, 0, 1) : 1;
}.bind(this)
}
}.bind(this),
},
],
vertexShader: `
precision mediump float;
@@ -275,12 +274,14 @@ class Heatmap extends VectorLayer {
gl_FragColor = v_hitColor;
}`,
uniforms: {
u_size: function() {
u_size: function () {
return (this.get(Property.RADIUS) + this.get(Property.BLUR)) * 2;
}.bind(this),
u_blurSlope: function() {
return this.get(Property.RADIUS) / Math.max(1, this.get(Property.BLUR));
}.bind(this)
u_blurSlope: function () {
return (
this.get(Property.RADIUS) / Math.max(1, this.get(Property.BLUR))
);
}.bind(this),
},
postProcesses: [
{
@@ -299,17 +300,16 @@ class Heatmap extends VectorLayer {
gl_FragColor.rgb *= gl_FragColor.a;
}`,
uniforms: {
u_gradientTexture: function() {
u_gradientTexture: function () {
return this.gradient_;
}.bind(this)
}
}
]
}.bind(this),
},
},
],
});
}
}
/**
* @param {Array<string>} colors A list of colored.
* @return {HTMLCanvasElement} canvas with gradient texture.
@@ -331,5 +331,4 @@ function createGradient(colors) {
return context.canvas;
}
export default Heatmap;

View File

@@ -4,7 +4,6 @@
import BaseImageLayer from './BaseImage.js';
import CanvasImageLayerRenderer from '../renderer/canvas/ImageLayer.js';
/**
* @classdesc
* Server-rendered images that are available for arbitrary extents and
@@ -16,7 +15,6 @@ import CanvasImageLayerRenderer from '../renderer/canvas/ImageLayer.js';
* @api
*/
class ImageLayer extends BaseImageLayer {
/**
* @param {import("./BaseImage.js").Options=} opt_options Layer options.
*/
@@ -32,7 +30,6 @@ class ImageLayer extends BaseImageLayer {
createRenderer() {
return new CanvasImageLayerRenderer(this);
}
}
export default ImageLayer;

View File

@@ -1,21 +1,20 @@
/**
* @module ol/layer/Layer
*/
import {listen, unlistenByKey} from '../events.js';
import EventType from '../events/EventType.js';
import {getChangeEventType} from '../Object.js';
import BaseLayer from './Base.js';
import EventType from '../events/EventType.js';
import LayerProperty from './Property.js';
import {assign} from '../obj.js';
import RenderEventType from '../render/EventType.js';
import SourceState from '../source/State.js';
import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {getChangeEventType} from '../Object.js';
import {listen, unlistenByKey} from '../events.js';
/**
* @typedef {function(import("../PluggableMap.js").FrameState):HTMLElement} RenderFunction
*/
/**
* @typedef {Object} Options
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
@@ -43,7 +42,6 @@ import {assert} from '../asserts.js';
* HTML element. Will overwrite the default rendering for the layer.
*/
/**
* @typedef {Object} State
* @property {import("./Layer.js").default} layer
@@ -92,7 +90,6 @@ class Layer extends BaseLayer {
* @param {Options} options Layer options.
*/
constructor(options) {
const baseOptions = assign({}, options);
delete baseOptions.source;
@@ -131,9 +128,14 @@ class Layer extends BaseLayer {
this.setMap(options.map);
}
this.addEventListener(getChangeEventType(LayerProperty.SOURCE), this.handleSourcePropertyChange_);
this.addEventListener(
getChangeEventType(LayerProperty.SOURCE),
this.handleSourcePropertyChange_
);
const source = options.source ? /** @type {SourceType} */ (options.source) : null;
const source = options.source
? /** @type {SourceType} */ (options.source)
: null;
this.setSource(source);
}
@@ -192,8 +194,12 @@ class Layer extends BaseLayer {
}
const source = this.getSource();
if (source) {
this.sourceChangeKey_ = listen(source,
EventType.CHANGE, this.handleSourceChange_, this);
this.sourceChangeKey_ = listen(
source,
EventType.CHANGE,
this.handleSourceChange_,
this
);
}
this.changed();
}
@@ -248,16 +254,24 @@ class Layer extends BaseLayer {
this.mapRenderKey_ = null;
}
if (map) {
this.mapPrecomposeKey_ = listen(map, RenderEventType.PRECOMPOSE, function(evt) {
const renderEvent = /** @type {import("../render/Event.js").default} */ (evt);
const layerStatesArray = renderEvent.frameState.layerStatesArray;
const layerState = this.getLayerState(false);
// A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both.
assert(!layerStatesArray.some(function(arrayLayerState) {
return arrayLayerState.layer === layerState.layer;
}), 67);
layerStatesArray.push(layerState);
}, this);
this.mapPrecomposeKey_ = listen(
map,
RenderEventType.PRECOMPOSE,
function (evt) {
const renderEvent = /** @type {import("../render/Event.js").default} */ (evt);
const layerStatesArray = renderEvent.frameState.layerStatesArray;
const layerState = this.getLayerState(false);
// A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both.
assert(
!layerStatesArray.some(function (arrayLayerState) {
return arrayLayerState.layer === layerState.layer;
}),
67
);
layerStatesArray.push(layerState);
},
this
);
this.mapRenderKey_ = listen(this, EventType.CHANGE, map.render, map);
this.changed();
}
@@ -309,7 +323,6 @@ class Layer extends BaseLayer {
}
}
/**
* Return `true` if the layer is visible and if the provided view state
* has resolution and zoom levels that are in range of the layer's min/max.
@@ -322,7 +335,10 @@ export function inView(layerState, viewState) {
return false;
}
const resolution = viewState.resolution;
if (resolution < layerState.minResolution || resolution >= layerState.maxResolution) {
if (
resolution < layerState.minResolution ||
resolution >= layerState.maxResolution
) {
return false;
}
const zoom = viewState.zoom;

View File

@@ -14,5 +14,5 @@ export default {
MIN_RESOLUTION: 'minResolution',
MAX_ZOOM: 'maxZoom',
MIN_ZOOM: 'minZoom',
SOURCE: 'source'
SOURCE: 'source',
};

View File

@@ -4,7 +4,6 @@
import BaseTileLayer from './BaseTile.js';
import CanvasTileLayerRenderer from '../renderer/canvas/TileLayer.js';
/**
* @classdesc
* For layer sources that provide pre-rendered, tiled images in grids that are
@@ -16,7 +15,6 @@ import CanvasTileLayerRenderer from '../renderer/canvas/TileLayer.js';
* @api
*/
class TileLayer extends BaseTileLayer {
/**
* @param {import("./BaseTile.js").Options=} opt_options Tile layer options.
*/
@@ -32,7 +30,6 @@ class TileLayer extends BaseTileLayer {
createRenderer() {
return new CanvasTileLayerRenderer(this);
}
}
export default TileLayer;

View File

@@ -7,5 +7,5 @@
*/
export default {
PRELOAD: 'preload',
USE_INTERIM_TILES_ON_ERROR: 'useInterimTilesOnError'
USE_INTERIM_TILES_ON_ERROR: 'useInterimTilesOnError',
};

View File

@@ -4,7 +4,6 @@
import BaseVectorLayer from './BaseVector.js';
import CanvasVectorLayerRenderer from '../renderer/canvas/VectorLayer.js';
/**
* @classdesc
* Vector data that is rendered client-side.
@@ -33,5 +32,4 @@ class VectorLayer extends BaseVectorLayer {
}
}
export default VectorLayer;

View File

@@ -2,8 +2,8 @@
* @module ol/layer/VectorImage
*/
import BaseVectorLayer from './BaseVector.js';
import {assign} from '../obj.js';
import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.js';
import {assign} from '../obj.js';
/**
* @typedef {Object} Options
@@ -50,7 +50,6 @@ import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.
* viewport extent. A larger ratio avoids cut images during panning, but will cause a decrease in performance.
*/
/**
* @classdesc
* Vector data that is rendered client-side.
@@ -75,8 +74,8 @@ class VectorImageLayer extends BaseVectorLayer {
* @type {number}
* @private
*/
this.imageRatio_ = options.imageRatio !== undefined ? options.imageRatio : 1;
this.imageRatio_ =
options.imageRatio !== undefined ? options.imageRatio : 1;
}
/**
@@ -96,5 +95,4 @@ class VectorImageLayer extends BaseVectorLayer {
}
}
export default VectorImageLayer;

View File

@@ -1,14 +1,13 @@
/**
* @module ol/layer/VectorTile
*/
import {assert} from '../asserts.js';
import TileProperty from './TileProperty.js';
import BaseVectorLayer from './BaseVector.js';
import VectorTileRenderType from './VectorTileRenderType.js';
import CanvasVectorTileLayerRenderer from '../renderer/canvas/VectorTileLayer.js';
import TileProperty from './TileProperty.js';
import VectorTileRenderType from './VectorTileRenderType.js';
import {assert} from '../asserts.js';
import {assign} from '../obj.js';
/**
* @typedef {Object} Options
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
@@ -70,7 +69,6 @@ import {assign} from '../obj.js';
* @property {boolean} [useInterimTilesOnError=true] Use interim tiles on error.
*/
/**
* @classdesc
* Layer for vector tile data that is rendered client-side.
@@ -96,11 +94,13 @@ class VectorTileLayer extends BaseVectorLayer {
super(/** @type {import("./BaseVector.js").Options} */ (baseOptions));
const renderMode = options.renderMode || VectorTileRenderType.HYBRID;
assert(renderMode == undefined ||
assert(
renderMode == undefined ||
renderMode == VectorTileRenderType.IMAGE ||
renderMode == VectorTileRenderType.HYBRID ||
renderMode == VectorTileRenderType.VECTOR,
28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'`.
28
); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'`.
/**
* @private
@@ -109,9 +109,11 @@ class VectorTileLayer extends BaseVectorLayer {
this.renderMode_ = renderMode;
this.setPreload(options.preload ? options.preload : 0);
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
options.useInterimTilesOnError : true);
this.setUseInterimTilesOnError(
options.useInterimTilesOnError !== undefined
? options.useInterimTilesOnError
: true
);
}
/**
@@ -165,7 +167,9 @@ class VectorTileLayer extends BaseVectorLayer {
* @api
*/
getUseInterimTilesOnError() {
return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
return /** @type {boolean} */ (this.get(
TileProperty.USE_INTERIM_TILES_ON_ERROR
));
}
/**
@@ -189,5 +193,4 @@ class VectorTileLayer extends BaseVectorLayer {
}
}
export default VectorTileLayer;

View File

@@ -20,5 +20,5 @@
export default {
IMAGE: 'image',
HYBRID: 'hybrid',
VECTOR: 'vector'
VECTOR: 'vector',
};

View File

@@ -1,11 +1,10 @@
/**
* @module ol/layer/WebGLPoints
*/
import {assign} from '../obj.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {parseLiteralStyle} from '../webgl/ShaderBuilder.js';
import Layer from './Layer.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {assign} from '../obj.js';
import {parseLiteralStyle} from '../webgl/ShaderBuilder.js';
/**
* @typedef {Object} Options
@@ -32,7 +31,6 @@ import Layer from './Layer.js';
* prevent all hit detection on the layer.
*/
/**
* @classdesc
* Layer optimized for rendering large point datasets. Takes a `style` property which
@@ -100,12 +98,14 @@ class WebGLPointsLayer extends Layer {
return new WebGLPointsLayerRenderer(this, {
vertexShader: this.parseResult_.builder.getSymbolVertexShader(),
fragmentShader: this.parseResult_.builder.getSymbolFragmentShader(),
hitVertexShader: !this.hitDetectionDisabled_ &&
hitVertexShader:
!this.hitDetectionDisabled_ &&
this.parseResult_.builder.getSymbolVertexShader(true),
hitFragmentShader: !this.hitDetectionDisabled_ &&
hitFragmentShader:
!this.hitDetectionDisabled_ &&
this.parseResult_.builder.getSymbolFragmentShader(true),
uniforms: this.parseResult_.uniforms,
attributes: this.parseResult_.attributes
attributes: this.parseResult_.attributes,
});
}