* @private * @function WebMap.prototype.getWmsInfo * @description 获取wms的图层参数。 * @param {Object} layerInfo - 图层信息。
(layerInfo)
| 1778 | * @param {Object} layerInfo - 图层信息。 |
| 1779 | */ |
| 1780 | getWmsInfo(layerInfo) { |
| 1781 | let that = this; |
| 1782 | let url = layerInfo.url.trim(); |
| 1783 | url += url.indexOf('?') > -1 ? '&SERVICE=WMS&REQUEST=GetCapabilities' : '?SERVICE=WMS&REQUEST=GetCapabilities'; |
| 1784 | let options = { |
| 1785 | withCredentials: that.isCredentail(url, layerInfo.proxy), |
| 1786 | withoutFormatSuffix: true |
| 1787 | }; |
| 1788 | |
| 1789 | let promise = new Promise(function (resolve) { |
| 1790 | return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options) |
| 1791 | .then(function (response) { |
| 1792 | return response.text(); |
| 1793 | }) |
| 1794 | .then(async function (capabilitiesText) { |
| 1795 | const format = new WMSCapabilities(); |
| 1796 | let capabilities = format.read(capabilitiesText); |
| 1797 | if (capabilities) { |
| 1798 | let layers = capabilities.Capability.Layer.Layer, |
| 1799 | proj = layerInfo.projection; |
| 1800 | layerInfo.subLayers = layerInfo.layers[0]; |
| 1801 | layerInfo.version = capabilities.version; |
| 1802 | for (let i = 0; i < layers.length; i++) { |
| 1803 | // 图层名比对 |
| 1804 | if (layerInfo.layers[0] === layers[i].name) { |
| 1805 | let layer = layers[i]; |
| 1806 | if (layer.bbox[proj]) { |
| 1807 | let bbox = layer.bbox[proj].bbox; |
| 1808 | // wmts 130 坐标轴是否反向,目前还无法判断 |
| 1809 | // 后续还需继续完善WKT 增加坐标轴方向值 |
| 1810 | // 目前wkt信息 来自https://epsg.io/ |
| 1811 | // 提供坐标方向值的网站 如:https://www.epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::4490 |
| 1812 | if ( |
| 1813 | (layerInfo.version === '1.3.0' && layerInfo.projection === 'EPSG:4326') || |
| 1814 | (layerInfo.version === '1.3.0' && layerInfo.projection === 'EPSG:4490') |
| 1815 | ) { |
| 1816 | layerInfo.extent = [bbox[1], bbox[0], bbox[3], bbox[2]]; |
| 1817 | } else { |
| 1818 | layerInfo.extent = bbox; |
| 1819 | } |
| 1820 | break; |
| 1821 | } |
| 1822 | } |
| 1823 | } |
| 1824 | } |
| 1825 | resolve(); |
| 1826 | }) |
| 1827 | .catch(function (error) { |
| 1828 | that.errorCallback && that.errorCallback(error, 'getWMSFaild', that.map); |
| 1829 | resolve(); |
| 1830 | }); |
| 1831 | }); |
| 1832 | return promise; |
| 1833 | } |
| 1834 | /** |
| 1835 | * @private |
| 1836 | * @function WebMap.prototype.getTileUrl |
no test coverage detected