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,47 +1,50 @@
|
||||
/**
|
||||
* @module ol/format/WMSCapabilities
|
||||
*/
|
||||
import {readHref} from './XLink.js';
|
||||
import XML from './XML.js';
|
||||
import {readDecimalString, readString, readNonNegativeInteger, readDecimal, readBooleanString, readNonNegativeIntegerString} from './xsd.js';
|
||||
import {makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter,
|
||||
makeStructureNS, pushParseAndPop} from '../xml.js';
|
||||
|
||||
import {
|
||||
makeArrayPusher,
|
||||
makeObjectPropertyPusher,
|
||||
makeObjectPropertySetter,
|
||||
makeStructureNS,
|
||||
pushParseAndPop,
|
||||
} from '../xml.js';
|
||||
import {
|
||||
readBooleanString,
|
||||
readDecimal,
|
||||
readDecimalString,
|
||||
readNonNegativeInteger,
|
||||
readNonNegativeIntegerString,
|
||||
readString,
|
||||
} from './xsd.js';
|
||||
import {readHref} from './XLink.js';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array<null|string>}
|
||||
*/
|
||||
const NAMESPACE_URIS = [
|
||||
null,
|
||||
'http://www.opengis.net/wms'
|
||||
];
|
||||
|
||||
const NAMESPACE_URIS = [null, 'http://www.opengis.net/wms'];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Service': makeObjectPropertySetter(readService),
|
||||
'Capability': makeObjectPropertySetter(readCapability)
|
||||
});
|
||||
|
||||
const PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Service': makeObjectPropertySetter(readService),
|
||||
'Capability': makeObjectPropertySetter(readCapability),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const CAPABILITY_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Request': makeObjectPropertySetter(readRequest),
|
||||
'Exception': makeObjectPropertySetter(readException),
|
||||
'Layer': makeObjectPropertySetter(readCapabilityLayer)
|
||||
});
|
||||
|
||||
const CAPABILITY_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Request': makeObjectPropertySetter(readRequest),
|
||||
'Exception': makeObjectPropertySetter(readException),
|
||||
'Layer': makeObjectPropertySetter(readCapabilityLayer),
|
||||
});
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -78,231 +81,207 @@ class WMSCapabilities extends XML {
|
||||
*/
|
||||
readFromNode(node) {
|
||||
this.version = node.getAttribute('version').trim();
|
||||
const wmsCapabilityObject = pushParseAndPop({
|
||||
'version': this.version
|
||||
}, PARSERS, node, []);
|
||||
const wmsCapabilityObject = pushParseAndPop(
|
||||
{
|
||||
'version': this.version,
|
||||
},
|
||||
PARSERS,
|
||||
node,
|
||||
[]
|
||||
);
|
||||
return wmsCapabilityObject ? wmsCapabilityObject : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const SERVICE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Name': makeObjectPropertySetter(readString),
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'KeywordList': makeObjectPropertySetter(readKeywordList),
|
||||
'OnlineResource': makeObjectPropertySetter(readHref),
|
||||
'ContactInformation': makeObjectPropertySetter(readContactInformation),
|
||||
'Fees': makeObjectPropertySetter(readString),
|
||||
'AccessConstraints': makeObjectPropertySetter(readString),
|
||||
'LayerLimit': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxWidth': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxHeight': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const SERVICE_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Name': makeObjectPropertySetter(readString),
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'KeywordList': makeObjectPropertySetter(readKeywordList),
|
||||
'OnlineResource': makeObjectPropertySetter(readHref),
|
||||
'ContactInformation': makeObjectPropertySetter(readContactInformation),
|
||||
'Fees': makeObjectPropertySetter(readString),
|
||||
'AccessConstraints': makeObjectPropertySetter(readString),
|
||||
'LayerLimit': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxWidth': makeObjectPropertySetter(readNonNegativeInteger),
|
||||
'MaxHeight': makeObjectPropertySetter(readNonNegativeInteger)
|
||||
});
|
||||
|
||||
const CONTACT_INFORMATION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'ContactPersonPrimary': makeObjectPropertySetter(readContactPersonPrimary),
|
||||
'ContactPosition': makeObjectPropertySetter(readString),
|
||||
'ContactAddress': makeObjectPropertySetter(readContactAddress),
|
||||
'ContactVoiceTelephone': makeObjectPropertySetter(readString),
|
||||
'ContactFacsimileTelephone': makeObjectPropertySetter(readString),
|
||||
'ContactElectronicMailAddress': makeObjectPropertySetter(readString),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const CONTACT_INFORMATION_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ContactPersonPrimary': makeObjectPropertySetter(readContactPersonPrimary),
|
||||
'ContactPosition': makeObjectPropertySetter(readString),
|
||||
'ContactAddress': makeObjectPropertySetter(readContactAddress),
|
||||
'ContactVoiceTelephone': makeObjectPropertySetter(readString),
|
||||
'ContactFacsimileTelephone': makeObjectPropertySetter(readString),
|
||||
'ContactElectronicMailAddress': makeObjectPropertySetter(readString)
|
||||
});
|
||||
|
||||
const CONTACT_PERSON_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'ContactPerson': makeObjectPropertySetter(readString),
|
||||
'ContactOrganization': makeObjectPropertySetter(readString),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const CONTACT_PERSON_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'ContactPerson': makeObjectPropertySetter(readString),
|
||||
'ContactOrganization': makeObjectPropertySetter(readString)
|
||||
});
|
||||
|
||||
const CONTACT_ADDRESS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'AddressType': makeObjectPropertySetter(readString),
|
||||
'Address': makeObjectPropertySetter(readString),
|
||||
'City': makeObjectPropertySetter(readString),
|
||||
'StateOrProvince': makeObjectPropertySetter(readString),
|
||||
'PostCode': makeObjectPropertySetter(readString),
|
||||
'Country': makeObjectPropertySetter(readString),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const CONTACT_ADDRESS_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'AddressType': makeObjectPropertySetter(readString),
|
||||
'Address': makeObjectPropertySetter(readString),
|
||||
'City': makeObjectPropertySetter(readString),
|
||||
'StateOrProvince': makeObjectPropertySetter(readString),
|
||||
'PostCode': makeObjectPropertySetter(readString),
|
||||
'Country': makeObjectPropertySetter(readString)
|
||||
});
|
||||
|
||||
const EXCEPTION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Format': makeArrayPusher(readString),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const EXCEPTION_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Format': makeArrayPusher(readString)
|
||||
});
|
||||
|
||||
const LAYER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Name': makeObjectPropertySetter(readString),
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'KeywordList': makeObjectPropertySetter(readKeywordList),
|
||||
'CRS': makeObjectPropertyPusher(readString),
|
||||
'EX_GeographicBoundingBox': makeObjectPropertySetter(
|
||||
readEXGeographicBoundingBox
|
||||
),
|
||||
'BoundingBox': makeObjectPropertyPusher(readBoundingBox),
|
||||
'Dimension': makeObjectPropertyPusher(readDimension),
|
||||
'Attribution': makeObjectPropertySetter(readAttribution),
|
||||
'AuthorityURL': makeObjectPropertyPusher(readAuthorityURL),
|
||||
'Identifier': makeObjectPropertyPusher(readString),
|
||||
'MetadataURL': makeObjectPropertyPusher(readMetadataURL),
|
||||
'DataURL': makeObjectPropertyPusher(readFormatOnlineresource),
|
||||
'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource),
|
||||
'Style': makeObjectPropertyPusher(readStyle),
|
||||
'MinScaleDenominator': makeObjectPropertySetter(readDecimal),
|
||||
'MaxScaleDenominator': makeObjectPropertySetter(readDecimal),
|
||||
'Layer': makeObjectPropertyPusher(readLayer),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const LAYER_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Name': makeObjectPropertySetter(readString),
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'KeywordList': makeObjectPropertySetter(readKeywordList),
|
||||
'CRS': makeObjectPropertyPusher(readString),
|
||||
'EX_GeographicBoundingBox': makeObjectPropertySetter(readEXGeographicBoundingBox),
|
||||
'BoundingBox': makeObjectPropertyPusher(readBoundingBox),
|
||||
'Dimension': makeObjectPropertyPusher(readDimension),
|
||||
'Attribution': makeObjectPropertySetter(readAttribution),
|
||||
'AuthorityURL': makeObjectPropertyPusher(readAuthorityURL),
|
||||
'Identifier': makeObjectPropertyPusher(readString),
|
||||
'MetadataURL': makeObjectPropertyPusher(readMetadataURL),
|
||||
'DataURL': makeObjectPropertyPusher(readFormatOnlineresource),
|
||||
'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource),
|
||||
'Style': makeObjectPropertyPusher(readStyle),
|
||||
'MinScaleDenominator': makeObjectPropertySetter(readDecimal),
|
||||
'MaxScaleDenominator': makeObjectPropertySetter(readDecimal),
|
||||
'Layer': makeObjectPropertyPusher(readLayer)
|
||||
});
|
||||
|
||||
const ATTRIBUTION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'OnlineResource': makeObjectPropertySetter(readHref),
|
||||
'LogoURL': makeObjectPropertySetter(readSizedFormatOnlineresource),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const ATTRIBUTION_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'OnlineResource': makeObjectPropertySetter(readHref),
|
||||
'LogoURL': makeObjectPropertySetter(readSizedFormatOnlineresource)
|
||||
});
|
||||
|
||||
const EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'westBoundLongitude': makeObjectPropertySetter(readDecimal),
|
||||
'eastBoundLongitude': makeObjectPropertySetter(readDecimal),
|
||||
'southBoundLatitude': makeObjectPropertySetter(readDecimal),
|
||||
'northBoundLatitude': makeObjectPropertySetter(readDecimal),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS =
|
||||
makeStructureNS(NAMESPACE_URIS, {
|
||||
'westBoundLongitude': makeObjectPropertySetter(readDecimal),
|
||||
'eastBoundLongitude': makeObjectPropertySetter(readDecimal),
|
||||
'southBoundLatitude': makeObjectPropertySetter(readDecimal),
|
||||
'northBoundLatitude': makeObjectPropertySetter(readDecimal)
|
||||
});
|
||||
|
||||
const REQUEST_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'GetCapabilities': makeObjectPropertySetter(readOperationType),
|
||||
'GetMap': makeObjectPropertySetter(readOperationType),
|
||||
'GetFeatureInfo': makeObjectPropertySetter(readOperationType),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const REQUEST_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'GetCapabilities': makeObjectPropertySetter(readOperationType),
|
||||
'GetMap': makeObjectPropertySetter(readOperationType),
|
||||
'GetFeatureInfo': makeObjectPropertySetter(readOperationType)
|
||||
});
|
||||
|
||||
const OPERATIONTYPE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Format': makeObjectPropertyPusher(readString),
|
||||
'DCPType': makeObjectPropertyPusher(readDCPType),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const OPERATIONTYPE_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Format': makeObjectPropertyPusher(readString),
|
||||
'DCPType': makeObjectPropertyPusher(readDCPType)
|
||||
});
|
||||
|
||||
const DCPTYPE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'HTTP': makeObjectPropertySetter(readHTTP),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const DCPTYPE_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'HTTP': makeObjectPropertySetter(readHTTP)
|
||||
});
|
||||
|
||||
const HTTP_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Get': makeObjectPropertySetter(readFormatOnlineresource),
|
||||
'Post': makeObjectPropertySetter(readFormatOnlineresource),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const HTTP_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Get': makeObjectPropertySetter(readFormatOnlineresource),
|
||||
'Post': makeObjectPropertySetter(readFormatOnlineresource)
|
||||
});
|
||||
|
||||
const STYLE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Name': makeObjectPropertySetter(readString),
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'LegendURL': makeObjectPropertyPusher(readSizedFormatOnlineresource),
|
||||
'StyleSheetURL': makeObjectPropertySetter(readFormatOnlineresource),
|
||||
'StyleURL': makeObjectPropertySetter(readFormatOnlineresource),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const STYLE_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Name': makeObjectPropertySetter(readString),
|
||||
'Title': makeObjectPropertySetter(readString),
|
||||
'Abstract': makeObjectPropertySetter(readString),
|
||||
'LegendURL': makeObjectPropertyPusher(readSizedFormatOnlineresource),
|
||||
'StyleSheetURL': makeObjectPropertySetter(readFormatOnlineresource),
|
||||
'StyleURL': makeObjectPropertySetter(readFormatOnlineresource)
|
||||
});
|
||||
|
||||
const FORMAT_ONLINERESOURCE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Format': makeObjectPropertySetter(readString),
|
||||
'OnlineResource': makeObjectPropertySetter(readHref),
|
||||
});
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const FORMAT_ONLINERESOURCE_PARSERS =
|
||||
makeStructureNS(NAMESPACE_URIS, {
|
||||
'Format': makeObjectPropertySetter(readString),
|
||||
'OnlineResource': makeObjectPropertySetter(readHref)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const KEYWORDLIST_PARSERS = makeStructureNS(
|
||||
NAMESPACE_URIS, {
|
||||
'Keyword': makeArrayPusher(readString)
|
||||
});
|
||||
|
||||
const KEYWORDLIST_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
||||
'Keyword': makeArrayPusher(readString),
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
@@ -313,7 +292,6 @@ function readAttribution(node, objectStack) {
|
||||
return pushParseAndPop({}, ATTRIBUTION_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -324,22 +302,21 @@ function readBoundingBox(node, objectStack) {
|
||||
readDecimalString(node.getAttribute('minx')),
|
||||
readDecimalString(node.getAttribute('miny')),
|
||||
readDecimalString(node.getAttribute('maxx')),
|
||||
readDecimalString(node.getAttribute('maxy'))
|
||||
readDecimalString(node.getAttribute('maxy')),
|
||||
];
|
||||
|
||||
const resolutions = [
|
||||
readDecimalString(node.getAttribute('resx')),
|
||||
readDecimalString(node.getAttribute('resy'))
|
||||
readDecimalString(node.getAttribute('resy')),
|
||||
];
|
||||
|
||||
return {
|
||||
'crs': node.getAttribute('CRS'),
|
||||
'extent': extent,
|
||||
'res': resolutions
|
||||
'res': resolutions,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -349,29 +326,40 @@ function readEXGeographicBoundingBox(node, objectStack) {
|
||||
const geographicBoundingBox = pushParseAndPop(
|
||||
{},
|
||||
EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS,
|
||||
node, objectStack);
|
||||
node,
|
||||
objectStack
|
||||
);
|
||||
if (!geographicBoundingBox) {
|
||||
return undefined;
|
||||
}
|
||||
const westBoundLongitude = /** @type {number|undefined} */
|
||||
(geographicBoundingBox['westBoundLongitude']);
|
||||
const southBoundLatitude = /** @type {number|undefined} */
|
||||
(geographicBoundingBox['southBoundLatitude']);
|
||||
const eastBoundLongitude = /** @type {number|undefined} */
|
||||
(geographicBoundingBox['eastBoundLongitude']);
|
||||
const northBoundLatitude = /** @type {number|undefined} */
|
||||
(geographicBoundingBox['northBoundLatitude']);
|
||||
if (westBoundLongitude === undefined || southBoundLatitude === undefined ||
|
||||
eastBoundLongitude === undefined || northBoundLatitude === undefined) {
|
||||
const westBoundLongitude =
|
||||
/** @type {number|undefined} */
|
||||
(geographicBoundingBox['westBoundLongitude']);
|
||||
const southBoundLatitude =
|
||||
/** @type {number|undefined} */
|
||||
(geographicBoundingBox['southBoundLatitude']);
|
||||
const eastBoundLongitude =
|
||||
/** @type {number|undefined} */
|
||||
(geographicBoundingBox['eastBoundLongitude']);
|
||||
const northBoundLatitude =
|
||||
/** @type {number|undefined} */
|
||||
(geographicBoundingBox['northBoundLatitude']);
|
||||
if (
|
||||
westBoundLongitude === undefined ||
|
||||
southBoundLatitude === undefined ||
|
||||
eastBoundLongitude === undefined ||
|
||||
northBoundLatitude === undefined
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return [
|
||||
westBoundLongitude, southBoundLatitude,
|
||||
eastBoundLongitude, northBoundLatitude
|
||||
westBoundLongitude,
|
||||
southBoundLatitude,
|
||||
eastBoundLongitude,
|
||||
northBoundLatitude,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -381,7 +369,6 @@ function readCapability(node, objectStack) {
|
||||
return pushParseAndPop({}, CAPABILITY_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -391,7 +378,6 @@ function readService(node, objectStack) {
|
||||
return pushParseAndPop({}, SERVICE_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -401,7 +387,6 @@ function readContactInformation(node, objectStack) {
|
||||
return pushParseAndPop({}, CONTACT_INFORMATION_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -411,7 +396,6 @@ function readContactPersonPrimary(node, objectStack) {
|
||||
return pushParseAndPop({}, CONTACT_PERSON_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -421,7 +405,6 @@ function readContactAddress(node, objectStack) {
|
||||
return pushParseAndPop({}, CONTACT_ADDRESS_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -431,7 +414,6 @@ function readException(node, objectStack) {
|
||||
return pushParseAndPop([], EXCEPTION_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -441,14 +423,15 @@ function readCapabilityLayer(node, objectStack) {
|
||||
return pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Layer object.
|
||||
*/
|
||||
function readLayer(node, objectStack) {
|
||||
const parentLayerObject = /** @type {!Object<string,*>} */ (objectStack[objectStack.length - 1]);
|
||||
const parentLayerObject = /** @type {!Object<string,*>} */ (objectStack[
|
||||
objectStack.length - 1
|
||||
]);
|
||||
|
||||
const layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
|
||||
|
||||
@@ -461,8 +444,7 @@ function readLayer(node, objectStack) {
|
||||
}
|
||||
layerObject['queryable'] = queryable !== undefined ? queryable : false;
|
||||
|
||||
let cascaded = readNonNegativeIntegerString(
|
||||
node.getAttribute('cascaded'));
|
||||
let cascaded = readNonNegativeIntegerString(node.getAttribute('cascaded'));
|
||||
if (cascaded === undefined) {
|
||||
cascaded = parentLayerObject['cascaded'];
|
||||
}
|
||||
@@ -494,16 +476,22 @@ function readLayer(node, objectStack) {
|
||||
|
||||
// See 7.2.4.8
|
||||
const addKeys = ['Style', 'CRS', 'AuthorityURL'];
|
||||
addKeys.forEach(function(key) {
|
||||
addKeys.forEach(function (key) {
|
||||
if (key in parentLayerObject) {
|
||||
const childValue = layerObject[key] || [];
|
||||
layerObject[key] = childValue.concat(parentLayerObject[key]);
|
||||
}
|
||||
});
|
||||
|
||||
const replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
|
||||
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
|
||||
replaceKeys.forEach(function(key) {
|
||||
const replaceKeys = [
|
||||
'EX_GeographicBoundingBox',
|
||||
'BoundingBox',
|
||||
'Dimension',
|
||||
'Attribution',
|
||||
'MinScaleDenominator',
|
||||
'MaxScaleDenominator',
|
||||
];
|
||||
replaceKeys.forEach(function (key) {
|
||||
if (!(key in layerObject)) {
|
||||
const parentValue = parentLayerObject[key];
|
||||
layerObject[key] = parentValue;
|
||||
@@ -513,7 +501,6 @@ function readLayer(node, objectStack) {
|
||||
return layerObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -528,12 +515,11 @@ function readDimension(node, objectStack) {
|
||||
'multipleValues': readBooleanString(node.getAttribute('multipleValues')),
|
||||
'nearestValue': readBooleanString(node.getAttribute('nearestValue')),
|
||||
'current': readBooleanString(node.getAttribute('current')),
|
||||
'values': readString(node)
|
||||
'values': readString(node),
|
||||
};
|
||||
return dimensionObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -543,7 +529,6 @@ function readFormatOnlineresource(node, objectStack) {
|
||||
return pushParseAndPop({}, FORMAT_ONLINERESOURCE_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -553,7 +538,6 @@ function readRequest(node, objectStack) {
|
||||
return pushParseAndPop({}, REQUEST_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -563,7 +547,6 @@ function readDCPType(node, objectStack) {
|
||||
return pushParseAndPop({}, DCPTYPE_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -573,7 +556,6 @@ function readHTTP(node, objectStack) {
|
||||
return pushParseAndPop({}, HTTP_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -583,7 +565,6 @@ function readOperationType(node, objectStack) {
|
||||
return pushParseAndPop({}, OPERATIONTYPE_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -594,7 +575,7 @@ function readSizedFormatOnlineresource(node, objectStack) {
|
||||
if (formatOnlineresource) {
|
||||
const size = [
|
||||
readNonNegativeIntegerString(node.getAttribute('width')),
|
||||
readNonNegativeIntegerString(node.getAttribute('height'))
|
||||
readNonNegativeIntegerString(node.getAttribute('height')),
|
||||
];
|
||||
formatOnlineresource['size'] = size;
|
||||
return formatOnlineresource;
|
||||
@@ -602,7 +583,6 @@ function readSizedFormatOnlineresource(node, objectStack) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -617,7 +597,6 @@ function readAuthorityURL(node, objectStack) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -632,7 +611,6 @@ function readMetadataURL(node, objectStack) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -642,7 +620,6 @@ function readStyle(node, objectStack) {
|
||||
return pushParseAndPop({}, STYLE_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} node Node.
|
||||
* @param {Array<*>} objectStack Object stack.
|
||||
@@ -652,5 +629,4 @@ function readKeywordList(node, objectStack) {
|
||||
return pushParseAndPop([], KEYWORDLIST_PARSERS, node, objectStack);
|
||||
}
|
||||
|
||||
|
||||
export default WMSCapabilities;
|
||||
|
||||
Reference in New Issue
Block a user