* @private * @function WebMap.prototype.getWmtsInfo * @description 获取wmts的图层参数。 * @param {Object} layerInfo - 图层信息。 * @param {function} callback - 获得wmts图层参数执行的回调函数
(layerInfo, callback)
| 1661 | * @param {function} callback - 获得wmts图层参数执行的回调函数 |
| 1662 | */ |
| 1663 | getWmtsInfo(layerInfo, callback) { |
| 1664 | let that = this; |
| 1665 | let options = { |
| 1666 | withCredentials: that.isCredentail(layerInfo.url, layerInfo.proxy), |
| 1667 | withoutFormatSuffix: true |
| 1668 | }; |
| 1669 | const isKvp = !layerInfo.requestEncoding || layerInfo.requestEncoding === 'KVP'; |
| 1670 | return FetchRequest.get(that.getWMTSUrl(layerInfo.url, isKvp, layerInfo.proxy), null, options) |
| 1671 | .then(function (response) { |
| 1672 | return response.text(); |
| 1673 | }) |
| 1674 | .then(function (capabilitiesText) { |
| 1675 | const parser = new XMLParser({ |
| 1676 | attributeNamePrefix: '', |
| 1677 | ignoreAttributes: false, |
| 1678 | removeNSPrefix: true, |
| 1679 | isArray: (name, jpath) => { |
| 1680 | return WMTS_ARRAY_NODE_PATHS.includes(jpath); |
| 1681 | } |
| 1682 | }); |
| 1683 | const capabilities = parser.parse(capabilitiesText).Capabilities; |
| 1684 | if (that.isValidResponse(capabilities)) { |
| 1685 | let content = capabilities.Contents; |
| 1686 | let tileMatrixSet = content.TileMatrixSet, |
| 1687 | layers = content.Layer, |
| 1688 | layer, |
| 1689 | idx, |
| 1690 | layerFormat, |
| 1691 | style = 'default'; |
| 1692 | |
| 1693 | for (let n = 0; n < layers.length; n++) { |
| 1694 | if (layers[n].Identifier === layerInfo.layer) { |
| 1695 | idx = n; |
| 1696 | layer = layers[idx]; |
| 1697 | layerFormat = layer.Format[0]; |
| 1698 | var WGS84BoundingBox = layer.WGS84BoundingBox; |
| 1699 | var boundingBox = layer.BoundingBox; |
| 1700 | let bbox = WGS84BoundingBox ? WGS84BoundingBox : boundingBox; |
| 1701 | var layerBounds = that.getBoundsFromConrner(bbox.LowerCorner, bbox.UpperCorner) |
| 1702 | // tileMatrixSetLink = layer.TileMatrixSetLink; |
| 1703 | break; |
| 1704 | } |
| 1705 | } |
| 1706 | layer && |
| 1707 | layer.Style && |
| 1708 | layer.Style.forEach((value) => { |
| 1709 | if (value.isDefault) { |
| 1710 | style = value.Identifier; |
| 1711 | } |
| 1712 | }); |
| 1713 | let scales = [], |
| 1714 | matrixIds = []; |
| 1715 | for (let i = 0; i < tileMatrixSet.length; i++) { |
| 1716 | if (tileMatrixSet[i].Identifier === layerInfo.tileMatrixSet) { |
| 1717 | let wmtsLayerEpsg = `EPSG:${tileMatrixSet[i].SupportedCRS.split('::')[1]}`; |
| 1718 | for (let h = 0; h < tileMatrixSet[i].TileMatrix.length; h++) { |
| 1719 | scales.push(tileMatrixSet[i].TileMatrix[h].ScaleDenominator); |
| 1720 | matrixIds.push(tileMatrixSet[i].TileMatrix[h].Identifier); |
no test coverage detected