Skip to content

Commit

Permalink
优化webmap3 结构,实现结构化数据,修改图例组件
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Mar 21, 2024
1 parent 2afd12f commit 8bf963b
Show file tree
Hide file tree
Showing 6 changed files with 3,390 additions and 2,769 deletions.
72 changes: 72 additions & 0 deletions src/common/_utils/iPortalDataService.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default class iPortalDataService extends Events {
this.url = url;
this.withCredentials = withCredentials || false;
this.epsgCode = options.epsgCode;
this.dataType = options.dataType;
this.dataId = options.dataId;
this.iportalServiceProxyUrl = options.iportalServiceProxyUrl;
this.eventTypes = ['getdatasucceeded', 'getdatafailed', 'featureisempty'];
this.resourceId = options.resourceId;
Expand Down Expand Up @@ -72,6 +74,11 @@ export default class iPortalDataService extends Events {
return;
}
let datasetUrl = this.url;
if (this.dataType === 'STRUCTUREDDATA') {
this._getStructureDatafromContent(datasetUrl, queryInfo);
return;
}

if (preferContent) {
this._getDatafromContent(datasetUrl, queryInfo);
return;
Expand Down Expand Up @@ -120,6 +127,71 @@ export default class iPortalDataService extends Events {
});
}

_getStructureDatafromContent() {
let featureResults = [];
let dataId = this.dataId;
let url = '/iportal/web/datas/{dataId}/structureddata/ogc-features/collections/all/items.json';
url = url.replace('{dataId}', dataId);
let maxFeatures = 5000;
let allRequest = [];
this._getStructureData(url, maxFeatures, 0).then((data) => {
if (data) {
featureResults = data.features;
if (data.numberMatched < maxFeatures) {
this.iserverService._getFeaturesSucceed({ result: {
features: {
type: 'FeatureCollection',
features: featureResults
}
}});
return;
}

for (let i = maxFeatures; i < data.numberMatched;) {
allRequest.push(
this._getStructureData(url, maxFeatures, i)
);
i += maxFeatures;
}
// 所有请求结束
Promise.all(allRequest).then((results) =>{
// 结果合并
results.map((result) =>{
featureResults = featureResults.concat(result.features);
});
this.iserverService._getFeaturesSucceed({ result: {
features: {
type: 'FeatureCollection',
features: featureResults
}
}});
})
}
});
}

_getStructureData(url, count, offset) {
url = `${url}?limit=${count}`;
if (offset) {
url = url + '&offset=' + offset;
}
return SuperMap.FetchRequest.get(url, null, {
withCredentials: this.withCredentials
})
.then(response => {
return response.json();
})
.then(data => {
return data
})
.catch(error => {
console.log(error);
this.triggerEvent('getdatafailed', {
error
});
});
}

_getDatafromRest(serviceType, address, queryInfo) {
if (serviceType === 'RESTDATA') {
let url = SuperMap.Util.urlPathAppend(address, 'data/datasources');
Expand Down
Loading

0 comments on commit 8bf963b

Please sign in to comment.