Skip to content

Commit

Permalink
【fix】 修改isvj-5475 解析wmts字段格式错误 review by luox
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Feb 28, 2023
1 parent 93e5037 commit b3c1d63
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/common/_utils/WebMapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ export default class WebMapService extends Events {
const capabilities = JSON.parse(
converts.xml2json(capabilitiesText, {
compact: true,
spaces: 4
spaces: 4,
// 用于决定哪些字段必须返回数组格式
alwaysArray: ['Layer', 'TileMatrixSet', 'ows:Operation', 'ows:Get', 'ResourceURL', 'Style']
})
).Capabilities;
const content = capabilities.Contents;
Expand Down
24 changes: 23 additions & 1 deletion src/common/_utils/__tests__/WebMapService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import iportal_serviceProxy from '../../../../test/unit/mocks/data/iportal_servi
import layerData from '../../../../test/unit/mocks/data/layerData.json';
import uniqueLayer_polygon from '../../../../test/unit/mocks/data/WebMap/uniqueLayer_polygon.json';
import epsgCode_wkt from '../../../../test/unit/mocks/data/epsgCode_wkt.json';
import { wmsCapabilitiesText, wmtsCapabilitiesText } from 'vue-iclient/test/unit/mocks/data/CapabilitiesText.js';
import { wmsCapabilitiesText, wmtsCapabilitiesText, wmtsCapabilitiesTextWithSingleProperty } from 'vue-iclient/test/unit/mocks/data/CapabilitiesText.js';
import mockFetch from 'vue-iclient/test/unit/mocks/FetchRequest';

const SuperMap = require('../../../../test/unit/mocks/supermap');
Expand Down Expand Up @@ -603,6 +603,28 @@ describe('WebMapService.spec', () => {
done();
});

it('getWmtsInfo_single_property', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal?REQUEST=GetCapabilities&SERVICE=WMTS&VERSION=1.0.0&parentResType=MAP&parentResId=123': wmtsCapabilitiesTextWithSingleProperty
};
mockFetch(fetchResource);
const layerInfo = {
layer: 'ChinaDark',
layerID: 'China',
layerType: 'WMS',
layers: ['0'],
name: 'China',
url: 'https://fakeiportal.supermap.io/iportal?',
visible: true
};
const mapCRS = {};
const service = new WebMapService(mapId, options);
expect.assertions(1);
const data = await service.getWmtsInfo(layerInfo, mapCRS);
expect(data.kvpResourceUrl).toBe('http://fakeiserver.supermap.io/iserver/services/map-china400/wmts-china?');
done();
});

it('get datasource on rest_data type', () => {
const layer = {
dataSource: { accessType: 'DIRECT', type: 'REST_DATA' }
Expand Down
Loading

0 comments on commit b3c1d63

Please sign in to comment.