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:
@@ -1,13 +1,15 @@
|
||||
/**
|
||||
* @module ol/render/canvas/PolygonBuilder
|
||||
*/
|
||||
import {snap} from '../../geom/flat/simplify.js';
|
||||
import {defaultFillStyle} from '../canvas.js';
|
||||
import CanvasInstruction, {
|
||||
fillInstruction, strokeInstruction, beginPathInstruction, closePathInstruction
|
||||
} from './Instruction.js';
|
||||
import CanvasBuilder from './Builder.js';
|
||||
|
||||
import CanvasInstruction, {
|
||||
beginPathInstruction,
|
||||
closePathInstruction,
|
||||
fillInstruction,
|
||||
strokeInstruction,
|
||||
} from './Instruction.js';
|
||||
import {defaultFillStyle} from '../canvas.js';
|
||||
import {snap} from '../../geom/flat/simplify.js';
|
||||
|
||||
class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
/**
|
||||
@@ -38,8 +40,19 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
for (let i = 0; i < numEnds; ++i) {
|
||||
const end = ends[i];
|
||||
const myBegin = this.coordinates.length;
|
||||
const myEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, true, !stroke);
|
||||
const moveToLineToInstruction = [CanvasInstruction.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||
const myEnd = this.appendFlatCoordinates(
|
||||
flatCoordinates,
|
||||
offset,
|
||||
end,
|
||||
stride,
|
||||
true,
|
||||
!stroke
|
||||
);
|
||||
const moveToLineToInstruction = [
|
||||
CanvasInstruction.MOVE_TO_LINE_TO,
|
||||
myBegin,
|
||||
myEnd,
|
||||
];
|
||||
this.instructions.push(moveToLineToInstruction);
|
||||
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
||||
if (stroke) {
|
||||
@@ -77,21 +90,32 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
if (state.fillStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.SET_FILL_STYLE,
|
||||
defaultFillStyle
|
||||
defaultFillStyle,
|
||||
]);
|
||||
}
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
state.strokeStyle,
|
||||
state.lineWidth,
|
||||
state.lineCap,
|
||||
state.lineJoin,
|
||||
state.miterLimit,
|
||||
state.lineDash,
|
||||
state.lineDashOffset,
|
||||
]);
|
||||
}
|
||||
const flatCoordinates = circleGeometry.getFlatCoordinates();
|
||||
const stride = circleGeometry.getStride();
|
||||
const myBegin = this.coordinates.length;
|
||||
this.appendFlatCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||
flatCoordinates,
|
||||
0,
|
||||
flatCoordinates.length,
|
||||
stride,
|
||||
false,
|
||||
false
|
||||
);
|
||||
const circleInstruction = [CanvasInstruction.CIRCLE, myBegin];
|
||||
this.instructions.push(beginPathInstruction, circleInstruction);
|
||||
this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
|
||||
@@ -122,20 +146,30 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
if (state.fillStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.SET_FILL_STYLE,
|
||||
defaultFillStyle
|
||||
defaultFillStyle,
|
||||
]);
|
||||
}
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
state.strokeStyle,
|
||||
state.lineWidth,
|
||||
state.lineCap,
|
||||
state.lineJoin,
|
||||
state.miterLimit,
|
||||
state.lineDash,
|
||||
state.lineDashOffset,
|
||||
]);
|
||||
}
|
||||
const ends = polygonGeometry.getEnds();
|
||||
const flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
|
||||
const stride = polygonGeometry.getStride();
|
||||
this.drawFlatCoordinatess_(flatCoordinates, 0, /** @type {Array<number>} */ (ends), stride);
|
||||
this.drawFlatCoordinatess_(
|
||||
flatCoordinates,
|
||||
0,
|
||||
/** @type {Array<number>} */ (ends),
|
||||
stride
|
||||
);
|
||||
this.endGeometry(feature);
|
||||
}
|
||||
|
||||
@@ -155,14 +189,19 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
if (state.fillStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.SET_FILL_STYLE,
|
||||
defaultFillStyle
|
||||
defaultFillStyle,
|
||||
]);
|
||||
}
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
CanvasInstruction.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
state.strokeStyle,
|
||||
state.lineWidth,
|
||||
state.lineCap,
|
||||
state.lineJoin,
|
||||
state.miterLimit,
|
||||
state.lineDash,
|
||||
state.lineDashOffset,
|
||||
]);
|
||||
}
|
||||
const endss = multiPolygonGeometry.getEndss();
|
||||
@@ -170,7 +209,12 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
const stride = multiPolygonGeometry.getStride();
|
||||
let offset = 0;
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride);
|
||||
offset = this.drawFlatCoordinatess_(
|
||||
flatCoordinates,
|
||||
offset,
|
||||
endss[i],
|
||||
stride
|
||||
);
|
||||
}
|
||||
this.endGeometry(feature);
|
||||
}
|
||||
@@ -210,5 +254,4 @@ class CanvasPolygonBuilder extends CanvasBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default CanvasPolygonBuilder;
|
||||
|
||||
Reference in New Issue
Block a user