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,17 +1,16 @@
|
||||
/**
|
||||
* @module ol/format/Polyline
|
||||
*/
|
||||
import {assert} from '../asserts.js';
|
||||
import Feature from '../Feature.js';
|
||||
import {transformGeometryWithOptions} from './Feature.js';
|
||||
import TextFeature from './TextFeature.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
||||
import TextFeature from './TextFeature.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {flipXY} from '../geom/flat/flip.js';
|
||||
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
||||
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||
import {transformGeometryWithOptions} from './Feature.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
@@ -20,7 +19,6 @@ import {get as getProjection} from '../proj.js';
|
||||
* feature geometries created by the format reader.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Feature format for reading and writing data in the Encoded
|
||||
@@ -36,7 +34,6 @@ import {get as getProjection} from '../proj.js';
|
||||
* @api
|
||||
*/
|
||||
class Polyline extends TextFeature {
|
||||
|
||||
/**
|
||||
* @param {Options=} opt_options Optional configuration object.
|
||||
*/
|
||||
@@ -45,7 +42,6 @@ class Polyline extends TextFeature {
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {import("../proj/Projection.js").default}
|
||||
*/
|
||||
@@ -61,8 +57,9 @@ class Polyline extends TextFeature {
|
||||
* @private
|
||||
* @type {GeometryLayout}
|
||||
*/
|
||||
this.geometryLayout_ = options.geometryLayout ?
|
||||
options.geometryLayout : GeometryLayout.XY;
|
||||
this.geometryLayout_ = options.geometryLayout
|
||||
? options.geometryLayout
|
||||
: GeometryLayout.XY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,10 +94,19 @@ class Polyline extends TextFeature {
|
||||
const stride = getStrideForLayout(this.geometryLayout_);
|
||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
const coordinates = inflateCoordinates(flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
const coordinates = inflateCoordinates(
|
||||
flatCoordinates,
|
||||
0,
|
||||
flatCoordinates.length,
|
||||
stride
|
||||
);
|
||||
const lineString = new LineString(coordinates, this.geometryLayout_);
|
||||
|
||||
return transformGeometryWithOptions(lineString, false, this.adaptOptions(opt_options));
|
||||
return transformGeometryWithOptions(
|
||||
lineString,
|
||||
false,
|
||||
this.adaptOptions(opt_options)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,8 +142,13 @@ class Polyline extends TextFeature {
|
||||
* @return {string} Text.
|
||||
*/
|
||||
writeGeometryText(geometry, opt_options) {
|
||||
geometry = /** @type {LineString} */
|
||||
(transformGeometryWithOptions(geometry, true, this.adaptOptions(opt_options)));
|
||||
geometry =
|
||||
/** @type {LineString} */
|
||||
(transformGeometryWithOptions(
|
||||
geometry,
|
||||
true,
|
||||
this.adaptOptions(opt_options)
|
||||
));
|
||||
const flatCoordinates = geometry.getFlatCoordinates();
|
||||
const stride = geometry.getStride();
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
@@ -145,7 +156,6 @@ class Polyline extends TextFeature {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode a list of n-dimensional points and return an encoded string
|
||||
*
|
||||
@@ -168,7 +178,7 @@ export function encodeDeltas(numbers, stride, opt_factor) {
|
||||
lastNumbers[d] = 0;
|
||||
}
|
||||
|
||||
for (let i = 0, ii = numbers.length; i < ii;) {
|
||||
for (let i = 0, ii = numbers.length; i < ii; ) {
|
||||
for (d = 0; d < stride; ++d, ++i) {
|
||||
const num = numbers[i];
|
||||
const delta = num - lastNumbers[d];
|
||||
@@ -181,7 +191,6 @@ export function encodeDeltas(numbers, stride, opt_factor) {
|
||||
return encodeFloats(numbers, factor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decode a list of n-dimensional points from an encoded string
|
||||
*
|
||||
@@ -205,7 +214,7 @@ export function decodeDeltas(encoded, stride, opt_factor) {
|
||||
|
||||
const numbers = decodeFloats(encoded, factor);
|
||||
|
||||
for (let i = 0, ii = numbers.length; i < ii;) {
|
||||
for (let i = 0, ii = numbers.length; i < ii; ) {
|
||||
for (d = 0; d < stride; ++d, ++i) {
|
||||
lastNumbers[d] += numbers[i];
|
||||
|
||||
@@ -216,7 +225,6 @@ export function decodeDeltas(encoded, stride, opt_factor) {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode a list of floating point numbers and return an encoded string
|
||||
*
|
||||
@@ -238,7 +246,6 @@ export function encodeFloats(numbers, opt_factor) {
|
||||
return encodeSignedIntegers(numbers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decode a list of floating point numbers from an encoded string
|
||||
*
|
||||
@@ -257,7 +264,6 @@ export function decodeFloats(encoded, opt_factor) {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode a list of signed integers and return an encoded string
|
||||
*
|
||||
@@ -269,12 +275,11 @@ export function decodeFloats(encoded, opt_factor) {
|
||||
export function encodeSignedIntegers(numbers) {
|
||||
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||
const num = numbers[i];
|
||||
numbers[i] = (num < 0) ? ~(num << 1) : (num << 1);
|
||||
numbers[i] = num < 0 ? ~(num << 1) : num << 1;
|
||||
}
|
||||
return encodeUnsignedIntegers(numbers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decode a list of signed integers from an encoded string
|
||||
*
|
||||
@@ -285,12 +290,11 @@ export function decodeSignedIntegers(encoded) {
|
||||
const numbers = decodeUnsignedIntegers(encoded);
|
||||
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||
const num = numbers[i];
|
||||
numbers[i] = (num & 1) ? ~(num >> 1) : (num >> 1);
|
||||
numbers[i] = num & 1 ? ~(num >> 1) : num >> 1;
|
||||
}
|
||||
return numbers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode a list of unsigned integers and return an encoded string
|
||||
*
|
||||
@@ -305,7 +309,6 @@ export function encodeUnsignedIntegers(numbers) {
|
||||
return encoded;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decode a list of unsigned integers from an encoded string
|
||||
*
|
||||
@@ -330,7 +333,6 @@ export function decodeUnsignedIntegers(encoded) {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode one single unsigned integer and return an encoded string
|
||||
*
|
||||
@@ -338,7 +340,8 @@ export function decodeUnsignedIntegers(encoded) {
|
||||
* @return {string} The encoded string.
|
||||
*/
|
||||
export function encodeUnsignedInteger(num) {
|
||||
let value, encoded = '';
|
||||
let value,
|
||||
encoded = '';
|
||||
while (num >= 0x20) {
|
||||
value = (0x20 | (num & 0x1f)) + 63;
|
||||
encoded += String.fromCharCode(value);
|
||||
@@ -349,5 +352,4 @@ export function encodeUnsignedInteger(num) {
|
||||
return encoded;
|
||||
}
|
||||
|
||||
|
||||
export default Polyline;
|
||||
|
||||
Reference in New Issue
Block a user