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,45 +1,39 @@
|
||||
/**
|
||||
* @module ol/format/WMTSCapabilities
|
||||
*/
|
||||
import {boundingExtent} from '../extent.js';
|
||||
import OWS from './OWS.js';
|
||||
import {readHref} from './XLink.js';
|
||||
import XML from './XML.js';
|
||||
import {readString, readNonNegativeInteger, readDecimal} from './xsd.js';
|
||||
import {pushParseAndPop, makeStructureNS,
|
||||
makeObjectPropertySetter, makeObjectPropertyPusher, makeArrayPusher} from '../xml.js';
|
||||
|
||||
import {boundingExtent} from '../extent.js';
|
||||
import {
|
||||
makeArrayPusher,
|
||||
makeObjectPropertyPusher,
|
||||
makeObjectPropertySetter,
|
||||
makeStructureNS,
|
||||
pushParseAndPop,
|
||||
} from '../xml.js';
|
||||
import {readDecimal, readNonNegativeInteger, readString} from './xsd.js';
|
||||
import {readHref} from './XLink.js';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/wmts/1.0'
|
||||
];
|
||||
|
||||
const NAMESPACE_URIS = [null, 'http://www.opengis.net/wmts/1.0'];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array<null|string>}
|
||||
*/
|
||||
const OWS_NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/ows/1.1'
|
||||
];
|
||||
|
||||
const OWS_NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Contents': makeObjectPropertySetter(readContents)
|
||||
});
|
||||
|
||||
const PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Contents': makeObjectPropertySetter(readContents),
|
||||
});
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -85,23 +79,25 @@ class WMTSCapabilities extends XML {
|
||||
return null;
|
||||
}
|
||||
WMTSCapabilityObject['version'] = version;
|
||||
WMTSCapabilityObject = pushParseAndPop(WMTSCapabilityObject, PARSERS, node, []);
|
||||
WMTSCapabilityObject = pushParseAndPop(
|
||||
WMTSCapabilityObject,
|
||||
PARSERS,
|
||||
node,
|
||||
[]
|
||||
);
|
||||
return WMTSCapabilityObject ? WMTSCapabilityObject : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const CONTENTS_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Layer': makeObjectPropertyPusher(readLayer),
|
||||
'TileMatrixSet': makeObjectPropertyPusher(readTileMatrixSet)
|
||||
});
|
||||
|
||||
const CONTENTS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Layer': makeObjectPropertyPusher(readLayer),
|
||||
'TileMatrixSet': makeObjectPropertyPusher(readTileMatrixSet),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -109,19 +105,21 @@ const CONTENTS_PARSERS = makeStructureNS(
|
||||
*/
|
||||
// @ts-ignore
|
||||
const LAYER_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
NAMESPACE_URIS,
|
||||
{
|
||||
'Style': makeObjectPropertyPusher(readStyle),
|
||||
'Format': makeObjectPropertyPusher(readString),
|
||||
'TileMatrixSetLink': makeObjectPropertyPusher(readTileMatrixSetLink),
|
||||
'Dimension': makeObjectPropertyPusher(readDimensions),
|
||||
'ResourceURL': makeObjectPropertyPusher(readResourceUrl)
|
||||
}, makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'ResourceURL': makeObjectPropertyPusher(readResourceUrl),
|
||||
},
|
||||
makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'WGS84BoundingBox': makeObjectPropertySetter(readWgs84BoundingBox),
|
||||
'Identifier': makeObjectPropertySetter(readString)
|
||||
}));
|
||||
|
||||
'Identifier': makeObjectPropertySetter(readString),
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -129,50 +127,47 @@ const LAYER_PARSERS = makeStructureNS(
|
||||
*/
|
||||
// @ts-ignore
|
||||
const STYLE_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'LegendURL': makeObjectPropertyPusher(readLegendUrl)
|
||||
}, makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
NAMESPACE_URIS,
|
||||
{
|
||||
'LegendURL': makeObjectPropertyPusher(readLegendUrl),
|
||||
},
|
||||
makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Identifier': makeObjectPropertySetter(readString)
|
||||
}));
|
||||
|
||||
'Identifier': makeObjectPropertySetter(readString),
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const TMS_LINKS_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'TileMatrixSet': makeObjectPropertySetter(readString),
|
||||
'TileMatrixSetLimits': makeObjectPropertySetter(readTileMatrixLimitsList)
|
||||
});
|
||||
const TMS_LINKS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'TileMatrixSet': makeObjectPropertySetter(readString),
|
||||
'TileMatrixSetLimits': makeObjectPropertySetter(readTileMatrixLimitsList),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const TMS_LIMITS_LIST_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'TileMatrixLimits': makeArrayPusher(readTileMatrixLimits)
|
||||
});
|
||||
|
||||
const TMS_LIMITS_LIST_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'TileMatrixLimits': makeArrayPusher(readTileMatrixLimits),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const TMS_LIMITS_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'TileMatrix': makeObjectPropertySetter(readString),
|
||||
'MinTileRow': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxTileRow': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MinTileCol': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxTileCol': makeObjectPropertySetter(readNonNegativeInteger)
|
||||
});
|
||||
|
||||
const TMS_LIMITS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'TileMatrix': makeObjectPropertySetter(readString),
|
||||
'MinTileRow': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxTileRow': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MinTileCol': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxTileCol': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -180,25 +175,25 @@ const TMS_LIMITS_PARSERS = makeStructureNS(
|
||||
*/
|
||||
// @ts-ignore
|
||||
const DIMENSION_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
NAMESPACE_URIS,
|
||||
{
|
||||
'Default': makeObjectPropertySetter(readString),
|
||||
'Value': makeObjectPropertyPusher(readString)
|
||||
}, makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'Identifier': makeObjectPropertySetter(readString)
|
||||
}));
|
||||
|
||||
'Value': makeObjectPropertyPusher(readString),
|
||||
},
|
||||
makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'Identifier': makeObjectPropertySetter(readString),
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const WGS84_BBOX_READERS = makeStructureNS(
|
||||
OWS_NAMESPACE_URIS, {
|
||||
'LowerCorner': makeArrayPusher(readCoordinates),
|
||||
'UpperCorner': makeArrayPusher(readCoordinates)
|
||||
});
|
||||
|
||||
const WGS84_BBOX_READERS = makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'LowerCorner': makeArrayPusher(readCoordinates),
|
||||
'UpperCorner': makeArrayPusher(readCoordinates),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -206,14 +201,16 @@ const WGS84_BBOX_READERS = makeStructureNS(
|
||||
*/
|
||||
// @ts-ignore
|
||||
const TMS_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
NAMESPACE_URIS,
|
||||
{
|
||||
'WellKnownScaleSet': makeObjectPropertySetter(readString),
|
||||
'TileMatrix': makeObjectPropertyPusher(readTileMatrix)
|
||||
}, makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'TileMatrix': makeObjectPropertyPusher(readTileMatrix),
|
||||
},
|
||||
makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'SupportedCRS': makeObjectPropertySetter(readString),
|
||||
'Identifier': makeObjectPropertySetter(readString)
|
||||
}));
|
||||
|
||||
'Identifier': makeObjectPropertySetter(readString),
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -221,17 +218,19 @@ const TMS_PARSERS = makeStructureNS(
|
||||
*/
|
||||
// @ts-ignore
|
||||
const TM_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
NAMESPACE_URIS,
|
||||
{
|
||||
'TopLeftCorner': makeObjectPropertySetter(readCoordinates),
|
||||
'ScaleDenominator': makeObjectPropertySetter(readDecimal),
|
||||
'TileWidth': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'TileHeight': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MatrixWidth': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MatrixHeight': makeObjectPropertySetter(readNonNegativeInteger)
|
||||
}, makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'Identifier': makeObjectPropertySetter(readString)
|
||||
}));
|
||||
|
||||
'MatrixHeight': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
},
|
||||
makeStructureNS(OWS_NAMESPACE_URIS, {
|
||||
'Identifier': makeObjectPropertySetter(readString),
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
@@ -242,7 +241,6 @@ function readContents(node, objectStack) {
|
||||
return pushParseAndPop({}, CONTENTS_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -252,7 +250,6 @@ function readLayer(node, objectStack) {
|
||||
return pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -262,7 +259,6 @@ function readTileMatrixSet(node, objectStack) {
|
||||
return pushParseAndPop({}, TMS_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -276,10 +272,8 @@ function readStyle(node, objectStack) {
|
||||
const isDefault = node.getAttribute('isDefault') === 'true';
|
||||
style['isDefault'] = isDefault;
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -289,7 +283,6 @@ function readTileMatrixSetLink(node, objectStack) {
|
||||
return pushParseAndPop({}, TMS_LINKS_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -299,7 +292,6 @@ function readDimensions(node, objectStack) {
|
||||
return pushParseAndPop({}, DIMENSION_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -322,21 +314,24 @@ function readResourceUrl(node, objectStack) {
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} WGS84 BBox object.
|
||||
*/
|
||||
function readWgs84BoundingBox(node, objectStack) {
|
||||
const coordinates = pushParseAndPop([], WGS84_BBOX_READERS, node, objectStack);
|
||||
const coordinates = pushParseAndPop(
|
||||
[],
|
||||
WGS84_BBOX_READERS,
|
||||
node,
|
||||
objectStack
|
||||
);
|
||||
if (coordinates.length != 2) {
|
||||
return undefined;
|
||||
}
|
||||
return boundingExtent(coordinates);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -349,7 +344,6 @@ function readLegendUrl(node, objectStack) {
|
||||
return legend;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -368,7 +362,6 @@ function readCoordinates(node, objectStack) {
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -378,7 +371,6 @@ function readTileMatrix(node, objectStack) {
|
||||
return pushParseAndPop({}, TM_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -388,7 +380,6 @@ function readTileMatrixLimitsList(node, objectStack) {
|
||||
return pushParseAndPop([], TMS_LIMITS_LIST_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -398,5 +389,4 @@ function readTileMatrixLimits(node, objectStack) {
|
||||
return pushParseAndPop({}, TMS_LIMITS_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
export default WMTSCapabilities;
|
||||
|
||||
Reference in New Issue
Block a user