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:
+43
-43
@@ -1,22 +1,20 @@
|
||||
/**
|
||||
* @module ol/source/Image
|
||||
*/
|
||||
import {abstract} from '../util.js';
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import {linearFindNearest} from '../array.js';
|
||||
import Event from '../events/Event.js';
|
||||
import {equals} from '../extent.js';
|
||||
import {equivalent} from '../proj.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import ReprojImage from '../reproj/Image.js';
|
||||
import Source from './Source.js';
|
||||
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
|
||||
import {abstract} from '../util.js';
|
||||
import {equals} from '../extent.js';
|
||||
import {equivalent} from '../proj.js';
|
||||
import {linearFindNearest} from '../array.js';
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const ImageSourceEventType = {
|
||||
|
||||
/**
|
||||
* Triggered when an image starts loading.
|
||||
* @event module:ol/source/Image.ImageSourceEvent#imageloadstart
|
||||
@@ -36,11 +34,9 @@ export const ImageSourceEventType = {
|
||||
* @event module:ol/source/Image.ImageSourceEvent#imageloaderror
|
||||
* @api
|
||||
*/
|
||||
IMAGELOADERROR: 'imageloaderror'
|
||||
|
||||
IMAGELOADERROR: 'imageloaderror',
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link module:ol/source/Image~ImageSource} instances are instances of this
|
||||
@@ -52,7 +48,6 @@ export class ImageSourceEvent extends Event {
|
||||
* @param {import("../Image.js").default} image The image.
|
||||
*/
|
||||
constructor(type, image) {
|
||||
|
||||
super(type);
|
||||
|
||||
/**
|
||||
@@ -61,12 +56,9 @@ export class ImageSourceEvent extends Event {
|
||||
* @api
|
||||
*/
|
||||
this.image = image;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {import("./Source.js").AttributionLike} [attributions]
|
||||
@@ -75,7 +67,6 @@ export class ImageSourceEvent extends Event {
|
||||
* @property {import("./State.js").default} [state]
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Abstract base class; normally only used for creating subclasses and not
|
||||
@@ -93,16 +84,15 @@ class ImageSource extends Source {
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
projection: options.projection,
|
||||
state: options.state
|
||||
state: options.state,
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
this.resolutions_ = options.resolutions !== undefined ?
|
||||
options.resolutions : null;
|
||||
|
||||
this.resolutions_ =
|
||||
options.resolutions !== undefined ? options.resolutions : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -110,7 +100,6 @@ class ImageSource extends Source {
|
||||
*/
|
||||
this.reprojectedImage_ = null;
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -147,21 +136,24 @@ class ImageSource extends Source {
|
||||
*/
|
||||
getImage(extent, resolution, pixelRatio, projection) {
|
||||
const sourceProjection = this.getProjection();
|
||||
if (!ENABLE_RASTER_REPROJECTION ||
|
||||
!sourceProjection ||
|
||||
!projection ||
|
||||
equivalent(sourceProjection, projection)) {
|
||||
if (
|
||||
!ENABLE_RASTER_REPROJECTION ||
|
||||
!sourceProjection ||
|
||||
!projection ||
|
||||
equivalent(sourceProjection, projection)
|
||||
) {
|
||||
if (sourceProjection) {
|
||||
projection = sourceProjection;
|
||||
}
|
||||
return this.getImageInternal(extent, resolution, pixelRatio, projection);
|
||||
} else {
|
||||
if (this.reprojectedImage_) {
|
||||
if (this.reprojectedRevision_ == this.getRevision() &&
|
||||
equivalent(
|
||||
this.reprojectedImage_.getProjection(), projection) &&
|
||||
this.reprojectedImage_.getResolution() == resolution &&
|
||||
equals(this.reprojectedImage_.getExtent(), extent)) {
|
||||
if (
|
||||
this.reprojectedRevision_ == this.getRevision() &&
|
||||
equivalent(this.reprojectedImage_.getProjection(), projection) &&
|
||||
this.reprojectedImage_.getResolution() == resolution &&
|
||||
equals(this.reprojectedImage_.getExtent(), extent)
|
||||
) {
|
||||
return this.reprojectedImage_;
|
||||
}
|
||||
this.reprojectedImage_.dispose();
|
||||
@@ -169,11 +161,20 @@ class ImageSource extends Source {
|
||||
}
|
||||
|
||||
this.reprojectedImage_ = new ReprojImage(
|
||||
sourceProjection, projection, extent, resolution, pixelRatio,
|
||||
function(extent, resolution, pixelRatio) {
|
||||
return this.getImageInternal(extent, resolution,
|
||||
pixelRatio, sourceProjection);
|
||||
}.bind(this));
|
||||
sourceProjection,
|
||||
projection,
|
||||
extent,
|
||||
resolution,
|
||||
pixelRatio,
|
||||
function (extent, resolution, pixelRatio) {
|
||||
return this.getImageInternal(
|
||||
extent,
|
||||
resolution,
|
||||
pixelRatio,
|
||||
sourceProjection
|
||||
);
|
||||
}.bind(this)
|
||||
);
|
||||
this.reprojectedRevision_ = this.getRevision();
|
||||
|
||||
return this.reprojectedImage_;
|
||||
@@ -204,28 +205,27 @@ class ImageSource extends Source {
|
||||
case ImageState.LOADING:
|
||||
this.loading = true;
|
||||
this.dispatchEvent(
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADSTART,
|
||||
image));
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADSTART, image)
|
||||
);
|
||||
break;
|
||||
case ImageState.LOADED:
|
||||
this.loading = false;
|
||||
this.dispatchEvent(
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADEND,
|
||||
image));
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADEND, image)
|
||||
);
|
||||
break;
|
||||
case ImageState.ERROR:
|
||||
this.loading = false;
|
||||
this.dispatchEvent(
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADERROR,
|
||||
image));
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADERROR, image)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
// pass
|
||||
// pass
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default image load function for image sources that use import("../Image.js").Image image
|
||||
* instances.
|
||||
|
||||
Reference in New Issue
Block a user