Skip to content

Commit 2b6896c

Browse files
[update] SourceListModelV3 Webmap获取layers新增wfs信息
(review by xjj)
1 parent 09e22a4 commit 2b6896c

File tree

2 files changed

+153
-1
lines changed

2 files changed

+153
-1
lines changed

src/common/mapping/utils/SourceListModelV3.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class SourceListModelV3 extends AppreciableLayerBase {
133133
reused: layer.metadata && layer.metadata.reused
134134
};
135135
const matchProjectCatalog = projectCataglogs.find((item) => item.id === layerCatalog.id) || {};
136-
const { msDatasetId } = matchProjectCatalog;
136+
const { msDatasetId, relationMsDatasetId } = matchProjectCatalog;
137137
let dataSource = {};
138138
if (msDatasetId) {
139139
for (const data of datas) {
@@ -153,6 +153,18 @@ export class SourceListModelV3 extends AppreciableLayerBase {
153153
}
154154
}
155155
}
156+
if (relationMsDatasetId) {
157+
const currentData = datas.find(data => data.datasets.find(dataset => dataset.msDatasetId === relationMsDatasetId));
158+
const sourceType = currentData && currentData.sourceType;
159+
if (sourceType === 'WFS') {
160+
const dataset = currentData.datasets.find(dataset => dataset.msDatasetId === relationMsDatasetId);
161+
Object.assign(dataSource, {
162+
type: 'WFS',
163+
datasetName: dataset.datasetName,
164+
url: currentData.url
165+
});
166+
}
167+
}
156168
const sourceOnMap = this.map.getSource(layer.source);
157169
if (!Object.keys(dataSource).length && sourceOnMap && sourceOnMap.type === 'vector') {
158170
const matchSource = this._mapInfo.sources[layer.source] || sourceOnMap;

test/common/mapping/utils/SourceListModelV3Spec.js

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,146 @@ describe('SourceListV3', () => {
451451
done();
452452
});
453453

454+
it('getLayers - wfs', (done) => {
455+
const mapInfo = {
456+
"metadata": {
457+
"layerCatalog": [{
458+
"visible": true,
459+
"children": [{
460+
"visible": true,
461+
"parts": [
462+
"ProvinceCapital_P@Population#1_0.8"
463+
],
464+
"id": "layer_ProvinceCapital_P@Population#1_1755679838482_95",
465+
"title": "ProvinceCapital_P@Population#1",
466+
"type": "composite"
467+
}],
468+
"id": "group_PopulationDistribution_wms111_1755679838482_96",
469+
"title": "PopulationDistribution_wms111",
470+
"type": "group"
471+
},
472+
{
473+
"visible": true,
474+
"children": [{
475+
"visible": true,
476+
"parts": [
477+
"Province_L@Population_0.3"
478+
],
479+
"id": "layer_Province_L@Population_1755679795075_67",
480+
"title": "Province_L@Population",
481+
"type": "composite"
482+
}],
483+
"id": "group_PopulationDistribution_wms111_1755679795075_68",
484+
"title": "PopulationDistribution_wms111",
485+
"type": "group"
486+
},
487+
{
488+
"visible": true,
489+
"id": "CHINA_DARK",
490+
"title": "中国暗色地图",
491+
"type": "basic"
492+
}
493+
]
494+
},
495+
"sources": {
496+
"CHINA_DARK": {
497+
"tiles": [
498+
"https://maptiles.supermapol.com/iserver/services/map_China/rest/maps/China_Dark/tileimage.png?scale={scale}&x={x}&y={y}&width={width}&height={height}&transparent=true&redirect=false&cacheEnabled=true"
499+
],
500+
"tileSize": 256,
501+
"attribution": "",
502+
"bounds": [
503+
-180,
504+
-90,
505+
180,
506+
90
507+
],
508+
"type": "raster"
509+
},
510+
"ms_wms_1755679795073_58": {
511+
"tiles": [
512+
"http://172.16.14.77:8090/iserver/services/map-Population/wms111/PopulationDistribution?service=WMS&request=GetMap&layers=0.3&styles=&format=image/png&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG:3857&bbox={bbox-epsg-3857}"
513+
],
514+
"tileSize": 256,
515+
"bounds": [
516+
79.00794462500004,
517+
20.0992050343981,
518+
131.29906509500006,
519+
53.333658559101075
520+
],
521+
"type": "raster"
522+
},
523+
"ms_wms_1755679838481_90": {
524+
"tiles": [
525+
"http://172.16.14.77:8090/iserver/services/map-Population/wms111/PopulationDistribution?service=WMS&request=GetMap&layers=0.8&styles=&format=image/png&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG:3857&bbox={bbox-epsg-3857}"
526+
],
527+
"tileSize": 256,
528+
"bounds": [
529+
87.61425523000014,
530+
19.997037504400623,
531+
126.53037681500007,
532+
45.803316189065896
533+
],
534+
"type": "raster"
535+
}
536+
},
537+
"crs": "EPSG:3857",
538+
"center": [
539+
99.85865648224853,
540+
31.86438306758635
541+
],
542+
"zoom": 3.826097678440538,
543+
"glyphs": {},
544+
"version": "3.3.0",
545+
"rootUrl": "http://172.16.15.206:8190/iportal/",
546+
"maxzoom": 12,
547+
"name": "无标题地图",
548+
"viewExtent": [
549+
68.52728177830532,
550+
12.16261318538571,
551+
131.1900311861916,
552+
48.1198896120401
553+
],
554+
"layers": [{
555+
"maxzoom": 12,
556+
"id": "CHINA_DARK",
557+
"source": "CHINA_DARK",
558+
"type": "raster",
559+
"minzoom": 0
560+
},
561+
{
562+
"metadata": {},
563+
"id": "Province_L@Population_0.3",
564+
"source": "ms_wms_1755679795073_58",
565+
"type": "raster"
566+
},
567+
{
568+
"metadata": {},
569+
"id": "ProvinceCapital_P@Population#1_0.8",
570+
"source": "ms_wms_1755679838481_90",
571+
"type": "raster"
572+
}
573+
],
574+
"pitch": 0,
575+
"minzoom": 0
576+
};
577+
const projInfo = {"catalogs":[{"visible":true,"catalogType":"group","children":[{"catalogType":"layer","relationMsDatasetId":"ms_Population:ProvinceCapital_P_1755679835391_71","serviceLayerId":"0.8","id":"layer_ProvinceCapital_P@Population#1_1755679838482_95","popupInfo":{"elements":[{"fieldName":"SmID","type":"FIELD"},{"fieldName":"SmX","type":"FIELD"},{"fieldName":"SmY","type":"FIELD"},{"fieldName":"SmLibTileID","type":"FIELD"},{"fieldName":"SmUserID","type":"FIELD"},{"fieldName":"SmGeometrySize","type":"FIELD"},{"fieldName":"SmGeoPosition","type":"FIELD"},{"fieldName":"Name","type":"FIELD"}],"title":"ProvinceCapital_P@Population#1"},"title":"ProvinceCapital_P@Population#1","layerSourceType":"WMSService","zoomRange":[0,24],"layersContent":["ProvinceCapital_P@Population#1_0.8"]}],"name":"PopulationDistribution_wms111","id":"group_PopulationDistribution_wms111_1755679838482_96"},{"visible":true,"catalogType":"group","children":[{"catalogType":"layer","relationMsDatasetId":"ms_Population:Province_L_1755679787206_46","serviceLayerId":"0.3","id":"layer_Province_L@Population_1755679795075_67","popupInfo":{"elements":[{"fieldName":"SmID","type":"FIELD"},{"fieldName":"SmLength","type":"FIELD"},{"fieldName":"SmSdriW","type":"FIELD"},{"fieldName":"SmSdriN","type":"FIELD"},{"fieldName":"SmSdriE","type":"FIELD"},{"fieldName":"SmSdriS","type":"FIELD"},{"fieldName":"SmUserID","type":"FIELD"},{"fieldName":"SmTopoError","type":"FIELD"},{"fieldName":"SmGeometrySize","type":"FIELD"},{"fieldName":"SmGeoPosition","type":"FIELD"},{"fieldName":"GB","type":"FIELD"}],"title":"Province_L@Population"},"title":"Province_L@Population","layerSourceType":"WMSService","zoomRange":[0,24],"layersContent":["Province_L@Population_0.3"]}],"name":"PopulationDistribution_wms111","id":"group_PopulationDistribution_wms111_1755679795075_68"}],"datas":[{"sourceType":"WFS","datasets":[{"datasetTitle":"Country_R","msDatasetId":"ms_Population:Country_R_1755679787206_42","datasetName":"Population:Country_R"},{"datasetTitle":"HeiHeTengChong_P","msDatasetId":"ms_Population:HeiHeTengChong_P_1755679787206_43","datasetName":"Population:HeiHeTengChong_P"},{"datasetTitle":"ProvinceCapital_P","msDatasetId":"ms_Population:ProvinceCapital_P_1755679787206_44","datasetName":"Population:ProvinceCapital_P"},{"datasetTitle":"BorderTest_L","msDatasetId":"ms_Population:BorderTest_L_1755679787206_45","datasetName":"Population:BorderTest_L"},{"datasetTitle":"Province_L","msDatasetId":"ms_Population:Province_L_1755679787206_46","datasetName":"Population:Province_L"},{"datasetTitle":"Island_R","msDatasetId":"ms_Population:Island_R_1755679787206_47","datasetName":"Population:Island_R"},{"datasetTitle":"PopDensity_R","msDatasetId":"ms_Population:PopDensity_R_1755679787206_48","datasetName":"Population:PopDensity_R"},{"datasetTitle":"Coastline_L","msDatasetId":"ms_Population:Coastline_L_1755679787206_49","datasetName":"Population:Coastline_L"},{"datasetTitle":"Buffer20000","msDatasetId":"ms_Population:Buffer20000_1755679787206_50","datasetName":"Population:Buffer20000"},{"datasetTitle":"Buffer35000","msDatasetId":"ms_Population:Buffer35000_1755679787206_51","datasetName":"Population:Buffer35000"},{"datasetTitle":"County_R","msDatasetId":"ms_Population:County_R_1755679787206_52","datasetName":"Population:County_R"},{"datasetTitle":"County_P","msDatasetId":"ms_Population:County_P_1755679787206_53","datasetName":"Population:County_P"}],"title":"示例 WFS 服务","url":"http://172.16.14.77:8090/iserver/services/data-Population-2/wfs200/gb18030"},{"sourceType":"WFS","datasets":[{"datasetTitle":"Country_R","msDatasetId":"ms_Population:Country_R_1755679835391_69","datasetName":"Population:Country_R"},{"datasetTitle":"HeiHeTengChong_P","msDatasetId":"ms_Population:HeiHeTengChong_P_1755679835391_70","datasetName":"Population:HeiHeTengChong_P"},{"datasetTitle":"ProvinceCapital_P","msDatasetId":"ms_Population:ProvinceCapital_P_1755679835391_71","datasetName":"Population:ProvinceCapital_P"},{"datasetTitle":"BorderTest_L","msDatasetId":"ms_Population:BorderTest_L_1755679835391_72","datasetName":"Population:BorderTest_L"},{"datasetTitle":"Province_L","msDatasetId":"ms_Population:Province_L_1755679835391_73","datasetName":"Population:Province_L"},{"datasetTitle":"Island_R","msDatasetId":"ms_Population:Island_R_1755679835391_74","datasetName":"Population:Island_R"},{"datasetTitle":"PopDensity_R","msDatasetId":"ms_Population:PopDensity_R_1755679835391_75","datasetName":"Population:PopDensity_R"},{"datasetTitle":"Coastline_L","msDatasetId":"ms_Population:Coastline_L_1755679835391_76","datasetName":"Population:Coastline_L"},{"datasetTitle":"Buffer20000","msDatasetId":"ms_Population:Buffer20000_1755679835391_77","datasetName":"Population:Buffer20000"},{"datasetTitle":"Buffer35000","msDatasetId":"ms_Population:Buffer35000_1755679835391_78","datasetName":"Population:Buffer35000"},{"datasetTitle":"County_R","msDatasetId":"ms_Population:County_R_1755679835391_79","datasetName":"Population:County_R"},{"datasetTitle":"County_P","msDatasetId":"ms_Population:County_P_1755679835391_80","datasetName":"Population:County_P"}],"title":"示例 WFS 服务","url":"http://172.16.14.77:8090/iserver/services/data-Population-2/wfs200/gb18030"}],"baseLayer":{"internetMapName":"CHINA_DARK","type":"INTERNET_MAP"},"version":"3.1.2"};
578+
579+
const sourceListModel = new SourceListModelV3({
580+
map,
581+
mapInfo,
582+
mapResourceInfo: projInfo,
583+
legendList: [],
584+
l7LayerUtil: {
585+
isL7Layer,
586+
getL7MarkerLayers: () => ({})
587+
}
588+
});
589+
const appreciableLayers = sourceListModel.getLayers();
590+
expect(appreciableLayers.find(l=>l.dataSource.type === 'WFS')).toBeTruthy();
591+
done();
592+
});
593+
454594
it('getLayerCatalog without group', (done) => {
455595
const mapInfo = JSON.parse(apstudioWebMap_layerData);
456596
const sourceListModel = new SourceListModelV3({

0 commit comments

Comments
 (0)