@supermapgis/vue-iclient-leaflet 11.2.1 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iclient-leaflet-vue.css +23 -9
- package/dist/iclient-leaflet-vue.js +21689 -44354
- package/dist/iclient-leaflet-vue.min.css +2 -2
- package/dist/iclient-leaflet-vue.min.js +39 -293
- package/lib/_assets/iconfont/icon-sm-components.css +21 -7
- package/lib/_assets/iconfont/icon-sm-components.ttf +0 -0
- package/lib/_assets/iconfont/icon-sm-components.woff +0 -0
- package/lib/_assets/iconfont/icon-sm-components.woff2 +0 -0
- package/lib/_lang/en.js +20 -8
- package/lib/_lang/index.js +18 -18
- package/lib/_lang/zh.js +20 -8
- package/lib/_mixin/AntdRender.js +15 -17
- package/lib/_mixin/Card.js +10 -11
- package/lib/_mixin/GridLayer.js +4 -4
- package/lib/_mixin/Layer.js +4 -4
- package/lib/_mixin/Options.js +2 -2
- package/lib/_mixin/Popper.js +2 -2
- package/lib/_mixin/Theme.js +13 -15
- package/lib/_mixin/ThirdService.js +15 -16
- package/lib/_mixin/TileLayer.js +4 -4
- package/lib/_mixin/Timer.js +8 -9
- package/lib/_mixin/VmUpdater.js +10 -11
- package/lib/_mixin/map-events.js +8 -9
- package/lib/_mixin/map-getter.js +13 -14
- package/lib/_types/AddressMatchParameter.js +2 -2
- package/lib/_types/GeoJSONParamter.js +2 -2
- package/lib/_types/RestDataParameter.js +5 -6
- package/lib/_types/RestMapParameter.js +5 -6
- package/lib/_types/RestParameter.js +2 -2
- package/lib/_types/event/BaseTypes.js +2 -2
- package/lib/_types/event/Event.js +4 -4
- package/lib/_types/event/Events.js +10 -10
- package/lib/_types/event/Pixel.js +2 -2
- package/lib/_types/event/Util.js +2 -2
- package/lib/_types/iPortalDataParameter.js +3 -2
- package/lib/_types/iServerBaseParameter.js +3 -2
- package/lib/_types/iServerDataParameter.js +5 -6
- package/lib/_types/iServerMapParameter.js +5 -6
- package/lib/_types/index.js +18 -18
- package/lib/_types/map-event.js +6 -6
- package/lib/_utils/EchartsDataService.js +24 -24
- package/lib/_utils/RestService.js +1345 -1149
- package/lib/_utils/epsg-define.js +45 -34
- package/lib/_utils/get-features.js +23 -10
- package/lib/_utils/global-event.js +6 -6
- package/lib/_utils/iPortalDataService.js +1368 -1147
- package/lib/_utils/iServerRestService.js +1518 -1269
- package/lib/_utils/props-binder.js +2 -2
- package/lib/_utils/statistics.js +8 -17
- package/lib/_utils/style/color/colorPalette.js +4 -4
- package/lib/_utils/style/color/serialColors.js +8 -8
- package/lib/_utils/style/theme/chart.js +1343 -1146
- package/lib/_utils/style/theme/set-theme.js +10 -10
- package/lib/_utils/style/theme/theme.json +6 -6
- package/lib/_utils/util.js +12 -12
- package/lib/_utils/vue-types/utils.js +2 -2
- package/lib/attribute-panel/style/attribute-panel.css +1 -0
- package/lib/attribute-panel/style/css.js +7 -0
- package/lib/attribute-panel/style/index.js +7 -0
- package/lib/avatar/index.js +25 -25
- package/lib/border/index.js +77 -77
- package/lib/breadcrumb/index.js +47 -41
- package/lib/button/index.js +53 -50
- package/lib/card/index.js +47 -41
- package/lib/chart/index.js +1437 -1238
- package/lib/checkbox/index.js +36 -33
- package/lib/collapse/index.js +39 -36
- package/lib/collapse-card/index.js +71 -76
- package/lib/color-picker/index.js +48 -49
- package/lib/date-picker/index.js +107 -95
- package/lib/dropdown/index.js +27 -27
- package/lib/empty/index.js +27 -27
- package/lib/icon/index.js +25 -25
- package/lib/identify/index.js +58 -59
- package/lib/iframe/index.js +31 -31
- package/lib/image/index.js +226 -42
- package/lib/image/style/image.css +1 -1
- package/lib/index.js +4 -4
- package/lib/indicator/index.js +70 -67
- package/lib/init.js +8 -8
- package/lib/input/index.js +150 -135
- package/lib/input-number/index.js +100 -97
- package/lib/layout/index.js +72 -60
- package/lib/liquid-fill/index.js +73 -73
- package/lib/marker/index.js +43 -44
- package/lib/menu/index.js +47 -41
- package/lib/message/index.js +3 -3
- package/lib/message/style/message.css +1 -1
- package/lib/modal/index.js +67 -67
- package/lib/modal/style/modal.css +1 -1
- package/lib/notification/index.js +6 -6
- package/lib/notification/style/notification.css +1 -1
- package/lib/pagination/index.js +34 -34
- package/lib/popup/index.js +45 -46
- package/lib/progress/index.js +440 -440
- package/lib/radio/index.js +48 -42
- package/lib/select/index.js +47 -41
- package/lib/slider/index.js +27 -27
- package/lib/slideshow/index.js +103 -160
- package/lib/spin/index.js +30 -30
- package/lib/steps/index.js +35 -32
- package/lib/switch/index.js +25 -25
- package/lib/table/index.js +50 -44
- package/lib/table/style/table.css +1 -1
- package/lib/table-popup/index.js +43 -37
- package/lib/table-popup/style/table-popup.css +1 -1
- package/lib/tabs/index.js +35 -32
- package/lib/text/index.js +39 -39
- package/lib/tile-layer/index.js +35 -36
- package/lib/time-line/index.js +41 -43
- package/lib/time-picker/index.js +27 -27
- package/lib/time-range/index.js +53 -55
- package/lib/time-slider/index.js +73 -75
- package/lib/time-text/index.js +31 -31
- package/lib/tooltip/index.js +25 -25
- package/lib/tooltip/style/tooltip.css +1 -0
- package/lib/transfer/index.js +27 -27
- package/lib/tree/index.js +48 -42
- package/lib/tree-select/index.js +37 -34
- package/lib/video-player/index.js +98 -97
- package/lib/video-player/style/video-player.css +1 -1
- package/lib/web-map/index.js +2336 -103
- package/package.json +2 -4
- package/src/common/_assets/iconfont/icon-sm-components.css +21 -7
- package/src/common/_assets/iconfont/icon-sm-components.ttf +0 -0
- package/src/common/_assets/iconfont/icon-sm-components.woff +0 -0
- package/src/common/_assets/iconfont/icon-sm-components.woff2 +0 -0
- package/src/common/_lang/en.js +19 -8
- package/src/common/_lang/zh.js +18 -6
- package/src/common/_mixin/Card.ts +1 -1
- package/src/common/_types/iPortalDataParameter.js +1 -0
- package/src/common/_types/iServerBaseParameter.ts +3 -0
- package/src/common/_utils/epsg-define.js +32 -27
- package/src/common/_utils/get-features.js +13 -2
- package/src/common/_utils/iPortalDataService.js +14 -3
- package/src/common/_utils/iServerRestService.js +144 -78
- package/src/common/_utils/statistics.js +6 -14
- package/src/common/_utils/style/theme/theme.json +6 -6
- package/src/common/attribute-panel/AttributePanel.vue +58 -0
- package/src/common/attribute-panel/__test__/AttributePanel.spec.js +39 -0
- package/src/common/attribute-panel/index.js +9 -0
- package/src/common/attribute-panel/style/attribute-panel.scss +35 -0
- package/src/common/attribute-panel/style/index.js +4 -0
- package/src/common/collapse-card/style/collapse-card.scss +2 -2
- package/src/common/iframe/Iframe.vue +1 -1
- package/src/common/image/Image.vue +68 -6
- package/src/common/image/style/image.scss +32 -0
- package/src/common/message/style/message.scss +1 -0
- package/src/common/modal/style/modal.scss +36 -0
- package/src/common/notification/style/notification.scss +9 -0
- package/src/common/slideshow/Slideshow.vue +42 -95
- package/src/common/slideshow/Swiper.js +1 -1
- package/src/common/table/style/table.scss +36 -0
- package/src/common/table-popup/TablePopup.vue +5 -0
- package/src/common/tooltip/style/tooltip.scss +3 -0
- package/src/common/video-player/style/video-player.scss +1 -1
- package/src/leaflet/entrys.json +0 -2
- package/src/leaflet/package.json +2 -4
- package/src/leaflet/web-map/WebMap.vue +4 -4
- package/src/leaflet/web-map/WebMapViewModel.ts +64 -17
- package/static/libs/iclient-common/iclient-common-webmapv2base.js +2 -0
- package/static/libs/iclient-common/iclient-common.js +1 -1
- package/static/libs/iclient-leaflet/iclient-leaflet.min.js +5 -1738
- package/lib/_assets/iconfont/icon-sm-components.eot +0 -0
- package/lib/_assets/iconfont/icon-sm-components.svg +0 -197
- package/lib/_mixin/WebMapBase.js +0 -3467
- package/lib/_utils/WebMapService.js +0 -1607
- package/src/common/_assets/iconfont/icon-sm-components.eot +0 -0
- package/src/common/_assets/iconfont/icon-sm-components.svg +0 -197
- package/src/common/_utils/WebMapService.ts +0 -1292
- package/src/common/web-map/WebMapBase.ts +0 -1178
- package/src/common/web-map/config/MunicipalCenter.json +0 -1
- package/src/common/web-map/config/ProvinceCenter.json +0 -1
|
@@ -1,1292 +0,0 @@
|
|
|
1
|
-
import { Events } from 'vue-iclient/src/common/_types/event/Events';
|
|
2
|
-
import { isXField, isYField, urlAppend, numberEqual } from 'vue-iclient/src/common/_utils/util';
|
|
3
|
-
import { statisticsFeatures } from 'vue-iclient/src/common/_utils/statistics';
|
|
4
|
-
import * as convert from 'xml-js';
|
|
5
|
-
import max from 'lodash.max';
|
|
6
|
-
import min from 'lodash.min';
|
|
7
|
-
|
|
8
|
-
const DEFAULT_WELLKNOWNSCALESET = [
|
|
9
|
-
'GoogleCRS84Quad',
|
|
10
|
-
'GoogleMapsCompatible',
|
|
11
|
-
'urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible',
|
|
12
|
-
'urn:ogc:def:wkss:OGC:1.0:GoogleCRS84Quad'
|
|
13
|
-
];
|
|
14
|
-
const MB_SCALEDENOMINATOR_3857 = [
|
|
15
|
-
559082264.0287178, 279541132.0143589, 139770566.00717944, 69885283.00358972, 34942641.50179486, 17471320.75089743,
|
|
16
|
-
8735660.375448715, 4367830.1877243575, 2183915.0938621787, 1091957.5469310894, 545978.7734655447, 272989.38673277234,
|
|
17
|
-
136494.69336638617, 68247.34668319309, 34123.67334159654, 17061.83667079827, 8530.918335399136, 4265.459167699568,
|
|
18
|
-
2132.729583849784, 1066.364791924892, 533.182395962446, 266.591197981223, 133.2955989906115
|
|
19
|
-
];
|
|
20
|
-
const MB_SCALEDENOMINATOR_4326 = [
|
|
21
|
-
559082264.0287176, 279541132.0143588, 139770566.0071794, 69885283.0035897, 34942641.50179485, 17471320.750897426,
|
|
22
|
-
8735660.375448713, 4367830.187724357, 2183915.0938621783, 1091957.5469310891, 545978.7734655446, 272989.3867327723,
|
|
23
|
-
136494.69336638614, 68247.34668319307, 34123.673341596535, 17061.836670798268, 8530.918335399134, 4265.459167699567,
|
|
24
|
-
2132.7295838497835, 1066.3647919248917, 533.1823959624459, 266.59119798122293, 133.29559899061147
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
interface webMapOptions {
|
|
28
|
-
serverUrl?: string;
|
|
29
|
-
accessToken?: string;
|
|
30
|
-
accessKey?: string;
|
|
31
|
-
tiandituKey?: string;
|
|
32
|
-
withCredentials?: boolean;
|
|
33
|
-
excludePortalProxyUrl?: boolean;
|
|
34
|
-
proxy?: boolean | string;
|
|
35
|
-
iportalServiceProxyUrlPrefix?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default class WebMapService extends Events {
|
|
39
|
-
mapId: string | number;
|
|
40
|
-
|
|
41
|
-
mapInfo: any;
|
|
42
|
-
|
|
43
|
-
serverUrl: string;
|
|
44
|
-
|
|
45
|
-
accessToken: string;
|
|
46
|
-
|
|
47
|
-
accessKey: string;
|
|
48
|
-
|
|
49
|
-
tiandituKey: string;
|
|
50
|
-
|
|
51
|
-
withCredentials: boolean;
|
|
52
|
-
|
|
53
|
-
target: string;
|
|
54
|
-
|
|
55
|
-
excludePortalProxyUrl: boolean;
|
|
56
|
-
|
|
57
|
-
isSuperMapOnline: boolean;
|
|
58
|
-
|
|
59
|
-
proxy: boolean | string;
|
|
60
|
-
|
|
61
|
-
iportalServiceProxyUrl: string;
|
|
62
|
-
|
|
63
|
-
proxyOptions: Object = {
|
|
64
|
-
data: 'apps/viewer/getUrlResource.json?url=',
|
|
65
|
-
image: 'apps/viewer/getUrlResource.png?url='
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
constructor(mapId: string | number | Object, options: webMapOptions = {}) {
|
|
69
|
-
super();
|
|
70
|
-
if (typeof mapId === 'string' || typeof mapId === 'number') {
|
|
71
|
-
this.mapId = mapId;
|
|
72
|
-
} else if (mapId !== null && typeof mapId === 'object') {
|
|
73
|
-
this.mapInfo = mapId;
|
|
74
|
-
}
|
|
75
|
-
this.serverUrl = options.serverUrl || 'https://www.supermapol.com';
|
|
76
|
-
this.accessToken = options.accessToken;
|
|
77
|
-
this.accessKey = options.accessKey;
|
|
78
|
-
this.tiandituKey = options.tiandituKey || '';
|
|
79
|
-
this.withCredentials = options.withCredentials || false;
|
|
80
|
-
this.excludePortalProxyUrl = options.excludePortalProxyUrl;
|
|
81
|
-
this.iportalServiceProxyUrl = options.iportalServiceProxyUrlPrefix;
|
|
82
|
-
this.proxy = options.proxy;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public setMapId(mapId: string | number | Object): void {
|
|
86
|
-
if (typeof mapId === 'string' || typeof mapId === 'number') {
|
|
87
|
-
this.mapId = mapId;
|
|
88
|
-
this.mapInfo = null;
|
|
89
|
-
} else if (mapId !== null && typeof mapId === 'object') {
|
|
90
|
-
this.mapInfo = mapId;
|
|
91
|
-
this.mapId = '';
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public setServerUrl(serverUrl: string): void {
|
|
96
|
-
this.serverUrl = serverUrl;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public setWithCredentials(withCredentials) {
|
|
100
|
-
this.withCredentials = withCredentials;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public setProxy(proxy) {
|
|
104
|
-
this.proxy = proxy;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public handleServerUrl(serverUrl) {
|
|
108
|
-
let urlArr: string[] = serverUrl.split('');
|
|
109
|
-
if (urlArr[urlArr.length - 1] !== '/') {
|
|
110
|
-
serverUrl += '/';
|
|
111
|
-
}
|
|
112
|
-
this.serverUrl = serverUrl;
|
|
113
|
-
return serverUrl;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public getMapInfo() {
|
|
117
|
-
if (!this.mapId && this.mapInfo) {
|
|
118
|
-
return new Promise(resolve => {
|
|
119
|
-
resolve(this.mapInfo);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
let mapUrl = this._handleMapUrl();
|
|
123
|
-
return new Promise(async (resolve, reject) => {
|
|
124
|
-
try {
|
|
125
|
-
await this.getiPortalServiceProxy();
|
|
126
|
-
SuperMap.FetchRequest.get(mapUrl, null, {
|
|
127
|
-
withCredentials: this.withCredentials
|
|
128
|
-
})
|
|
129
|
-
.then(response => {
|
|
130
|
-
return response.json();
|
|
131
|
-
})
|
|
132
|
-
.then(mapInfo => {
|
|
133
|
-
if (mapInfo && mapInfo.succeed === false) {
|
|
134
|
-
let error = { message: mapInfo && mapInfo.error && mapInfo.error.errorMsg };
|
|
135
|
-
reject(error);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
mapInfo.mapParams = {
|
|
140
|
-
title: mapInfo.title,
|
|
141
|
-
description: mapInfo.description
|
|
142
|
-
};
|
|
143
|
-
resolve(mapInfo);
|
|
144
|
-
})
|
|
145
|
-
.catch(error => {
|
|
146
|
-
reject(error);
|
|
147
|
-
});
|
|
148
|
-
} catch (err) {
|
|
149
|
-
reject(err);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public getiPortalServiceProxy() {
|
|
155
|
-
return new Promise((resolve, reject) => {
|
|
156
|
-
SuperMap.FetchRequest.get(`${this.serverUrl}web/config/portal.json`, { scope: ['serviceProxy'] })
|
|
157
|
-
.then(response => {
|
|
158
|
-
return response.json();
|
|
159
|
-
})
|
|
160
|
-
.then(serviceProxyInfo => {
|
|
161
|
-
if (!serviceProxyInfo || !serviceProxyInfo.serviceProxy) {
|
|
162
|
-
reject('serviceProxyFailed');
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const serviceProxy = serviceProxyInfo.serviceProxy;
|
|
166
|
-
if (serviceProxy.enable) {
|
|
167
|
-
if (serviceProxy.proxyServerRootUrl) {
|
|
168
|
-
this.iportalServiceProxyUrl = serviceProxy.proxyServerRootUrl;
|
|
169
|
-
} else if (serviceProxy.port && serviceProxy.rootUrlPostfix) {
|
|
170
|
-
this.iportalServiceProxyUrl = `${serviceProxy.port}/${serviceProxy.rootUrlPostfix}`;
|
|
171
|
-
}
|
|
172
|
-
if (this.serverUrl.indexOf(this.iportalServiceProxyUrl) > -1) {
|
|
173
|
-
this.iportalServiceProxyUrl = '';
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
resolve(serviceProxy);
|
|
177
|
-
})
|
|
178
|
-
.catch(error => {
|
|
179
|
-
reject(error);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public getLayerFeatures(type, layer, baseProjection?) {
|
|
185
|
-
let pro;
|
|
186
|
-
switch (type) {
|
|
187
|
-
case 'hosted':
|
|
188
|
-
// 数据存储到iportal上了
|
|
189
|
-
pro = this._getFeaturesFromHosted(layer, baseProjection);
|
|
190
|
-
break;
|
|
191
|
-
case 'rest_data':
|
|
192
|
-
pro = this._getFeaturesFromRestData(layer, baseProjection);
|
|
193
|
-
break;
|
|
194
|
-
case 'rest_map':
|
|
195
|
-
pro = this._getFeaturesFromRestMap(layer);
|
|
196
|
-
break;
|
|
197
|
-
case 'dataflow':
|
|
198
|
-
pro = this._getFeaturesFromDataflow(layer);
|
|
199
|
-
break;
|
|
200
|
-
case 'user_data':
|
|
201
|
-
pro = this._getFeaturesFromUserData(layer);
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
return pro;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public getWmsInfo(layerInfo) {
|
|
208
|
-
return new Promise(resolve => {
|
|
209
|
-
const proxy = this.handleProxy();
|
|
210
|
-
const serviceUrl = SuperMap.Util.urlAppend(layerInfo.url, 'REQUEST=GetCapabilities&SERVICE=WMS');
|
|
211
|
-
SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
212
|
-
withCredentials: this.handleWithCredentials(proxy, layerInfo.url, false),
|
|
213
|
-
withoutFormatSuffix: true,
|
|
214
|
-
proxy
|
|
215
|
-
})
|
|
216
|
-
.then(response => {
|
|
217
|
-
return response.text();
|
|
218
|
-
})
|
|
219
|
-
.then(capabilitiesText => {
|
|
220
|
-
let converts = convert || window.convert;
|
|
221
|
-
const capabilities = JSON.parse(
|
|
222
|
-
converts.xml2json(capabilitiesText, {
|
|
223
|
-
compact: true,
|
|
224
|
-
spaces: 4
|
|
225
|
-
})
|
|
226
|
-
);
|
|
227
|
-
const wmsCapabilities = capabilities.WMT_MS_Capabilities || capabilities.WMS_Capabilities;
|
|
228
|
-
resolve({ version: wmsCapabilities['_attributes']['version'] });
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
public getMapBoxStyle(styleURL) {
|
|
234
|
-
return new Promise((resolve, reject) => {
|
|
235
|
-
SuperMap.FetchRequest.get(styleURL)
|
|
236
|
-
.then(response => {
|
|
237
|
-
return response.json();
|
|
238
|
-
})
|
|
239
|
-
.then(styleJSON => {
|
|
240
|
-
resolve(styleJSON);
|
|
241
|
-
})
|
|
242
|
-
.catch(error => {
|
|
243
|
-
reject(error);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public getWmtsInfo(layerInfo, mapCRS) {
|
|
249
|
-
return new Promise((resolve, reject) => {
|
|
250
|
-
let isMatched = false;
|
|
251
|
-
let matchMaxZoom = 22;
|
|
252
|
-
let matchMinZoom = 0;
|
|
253
|
-
let style = '';
|
|
254
|
-
let bounds;
|
|
255
|
-
let restResourceURL = '';
|
|
256
|
-
let kvpResourceUrl = '';
|
|
257
|
-
const proxy = this.handleProxy();
|
|
258
|
-
let serviceUrl = SuperMap.Util.urlAppend(layerInfo.url, 'REQUEST=GetCapabilities&SERVICE=WMTS&VERSION=1.0.0');
|
|
259
|
-
serviceUrl = this.handleParentRes(serviceUrl);
|
|
260
|
-
SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
261
|
-
withCredentials: this.handleWithCredentials(proxy, layerInfo.url, false),
|
|
262
|
-
withoutFormatSuffix: true,
|
|
263
|
-
proxy
|
|
264
|
-
})
|
|
265
|
-
.then(response => {
|
|
266
|
-
return response.text();
|
|
267
|
-
})
|
|
268
|
-
.then(capabilitiesText => {
|
|
269
|
-
let converts = convert || window.convert;
|
|
270
|
-
const capabilities = JSON.parse(
|
|
271
|
-
converts.xml2json(capabilitiesText, {
|
|
272
|
-
compact: true,
|
|
273
|
-
spaces: 4,
|
|
274
|
-
// 用于决定哪些字段必须返回数组格式
|
|
275
|
-
alwaysArray: ['Layer', 'TileMatrixSet', 'ows:Operation', 'ows:Get', 'ResourceURL', 'Style']
|
|
276
|
-
})
|
|
277
|
-
).Capabilities;
|
|
278
|
-
const content = capabilities.Contents;
|
|
279
|
-
const metaData = capabilities['ows:OperationsMetadata'];
|
|
280
|
-
if (metaData) {
|
|
281
|
-
let operations = metaData['ows:Operation'];
|
|
282
|
-
if (!Array.isArray(operations)) {
|
|
283
|
-
operations = [operations];
|
|
284
|
-
}
|
|
285
|
-
const operation = operations.find(item => {
|
|
286
|
-
return item._attributes.name === 'GetTile';
|
|
287
|
-
});
|
|
288
|
-
if (operation) {
|
|
289
|
-
let getConstraints = operation['ows:DCP']['ows:HTTP']['ows:Get'];
|
|
290
|
-
if (!Array.isArray(getConstraints)) {
|
|
291
|
-
getConstraints = [getConstraints];
|
|
292
|
-
}
|
|
293
|
-
const getConstraint = getConstraints.find(item => {
|
|
294
|
-
return item['ows:Constraint']['ows:AllowedValues']['ows:Value']['_text'] === 'KVP';
|
|
295
|
-
});
|
|
296
|
-
if (getConstraint) {
|
|
297
|
-
kvpResourceUrl = getConstraint['_attributes']['xlink:href'];
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
let tileMatrixSet = content.TileMatrixSet;
|
|
302
|
-
for (let i = 0; i < tileMatrixSet.length; i++) {
|
|
303
|
-
if (
|
|
304
|
-
tileMatrixSet[i]['ows:Identifier'] &&
|
|
305
|
-
tileMatrixSet[i]['ows:Identifier']['_text'] === layerInfo.tileMatrixSet
|
|
306
|
-
) {
|
|
307
|
-
if (
|
|
308
|
-
tileMatrixSet[i]['WellKnownScaleSet'] &&
|
|
309
|
-
DEFAULT_WELLKNOWNSCALESET.includes(tileMatrixSet[i]['WellKnownScaleSet']['_text'])
|
|
310
|
-
) {
|
|
311
|
-
isMatched = true;
|
|
312
|
-
} else {
|
|
313
|
-
let matchedScaleDenominator = {};
|
|
314
|
-
// 坐标系判断
|
|
315
|
-
let defaultCRSScaleDenominators =
|
|
316
|
-
// @ts-ignore -------- crs 为 enhance 新加属性
|
|
317
|
-
mapCRS === 'EPSG:3857' ? MB_SCALEDENOMINATOR_3857 : MB_SCALEDENOMINATOR_4326;
|
|
318
|
-
let defaultCRSTopLeftCorner =
|
|
319
|
-
// @ts-ignore -------- crs 为 enhance 新加属性
|
|
320
|
-
mapCRS === 'EPSG:3857' ? [-2.0037508342789248e7, 2.0037508342789087e7] : [-180, 90];
|
|
321
|
-
for (let j = 0; j < tileMatrixSet[i].TileMatrix.length; j++) {
|
|
322
|
-
const tileMatrix = tileMatrixSet[i].TileMatrix[j];
|
|
323
|
-
const identifier = tileMatrix['ows:Identifier']['_text'];
|
|
324
|
-
const topLeftCorner = [...tileMatrix['TopLeftCorner']['_text'].split(' ')];
|
|
325
|
-
if (
|
|
326
|
-
(!numberEqual(topLeftCorner[0], defaultCRSTopLeftCorner[0]) ||
|
|
327
|
-
!numberEqual(topLeftCorner[1], defaultCRSTopLeftCorner[1])) &&
|
|
328
|
-
(!numberEqual(topLeftCorner[0], defaultCRSTopLeftCorner[1]) ||
|
|
329
|
-
!numberEqual(topLeftCorner[1], defaultCRSTopLeftCorner[0]))
|
|
330
|
-
) {
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
const defaultScaleDenominator = defaultCRSScaleDenominators[+identifier];
|
|
334
|
-
if (!defaultScaleDenominator) {
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
const scaleDenominator = parseFloat(tileMatrixSet[i].TileMatrix[j]['ScaleDenominator']['_text']);
|
|
338
|
-
if (numberEqual(defaultScaleDenominator, scaleDenominator)) {
|
|
339
|
-
matchedScaleDenominator[+identifier] = scaleDenominator;
|
|
340
|
-
} else {
|
|
341
|
-
if (Object.keys(matchedScaleDenominator).length > 0) {
|
|
342
|
-
break;
|
|
343
|
-
} else {
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
const zooms = Object.keys(matchedScaleDenominator).map(element => {
|
|
349
|
-
return +element;
|
|
350
|
-
});
|
|
351
|
-
matchMaxZoom = max(zooms);
|
|
352
|
-
matchMinZoom = min(zooms);
|
|
353
|
-
if (zooms.length !== 0) {
|
|
354
|
-
isMatched = true;
|
|
355
|
-
} else {
|
|
356
|
-
throw Error('TileMatrixSetNotSuppport');
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
const layer = content.Layer.find(item => {
|
|
363
|
-
return item['ows:Identifier']['_text'] === layerInfo.layer;
|
|
364
|
-
});
|
|
365
|
-
if (layer) {
|
|
366
|
-
let styles = layer.Style;
|
|
367
|
-
if (Array.isArray(layer.Style)) {
|
|
368
|
-
style = styles[0]['ows:Identifier'] ? styles[0]['ows:Identifier']['_text'] : '';
|
|
369
|
-
} else {
|
|
370
|
-
style = styles['ows:Identifier'] ? styles['ows:Identifier']['_text'] : '';
|
|
371
|
-
}
|
|
372
|
-
if (layer['ows:WGS84BoundingBox']) {
|
|
373
|
-
const lowerCorner = layer['ows:WGS84BoundingBox']['ows:LowerCorner']['_text'].split(' ');
|
|
374
|
-
const upperCorner = layer['ows:WGS84BoundingBox']['ows:UpperCorner']['_text'].split(' ');
|
|
375
|
-
bounds = [
|
|
376
|
-
parseFloat(lowerCorner[0]),
|
|
377
|
-
parseFloat(lowerCorner[1]),
|
|
378
|
-
parseFloat(upperCorner[0]),
|
|
379
|
-
parseFloat(upperCorner[1])
|
|
380
|
-
];
|
|
381
|
-
}
|
|
382
|
-
let resourceUrls = layer.ResourceURL;
|
|
383
|
-
if (!Array.isArray(resourceUrls)) {
|
|
384
|
-
resourceUrls = [resourceUrls];
|
|
385
|
-
}
|
|
386
|
-
const resourceUrl = resourceUrls.find(item => {
|
|
387
|
-
return item._attributes.resourceType === 'tile';
|
|
388
|
-
});
|
|
389
|
-
if (resourceUrl) {
|
|
390
|
-
restResourceURL = resourceUrl._attributes.template;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
resolve({ isMatched, matchMaxZoom, matchMinZoom, style, bounds, restResourceURL, kvpResourceUrl });
|
|
394
|
-
})
|
|
395
|
-
.catch(error => {
|
|
396
|
-
reject(error);
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
private _getFeaturesFromHosted(layer, baseProjection?) {
|
|
402
|
-
let { dataSource, layerType } = layer;
|
|
403
|
-
let serverId = dataSource ? dataSource.serverId : layer.serverId;
|
|
404
|
-
|
|
405
|
-
if (!serverId) {
|
|
406
|
-
return new Promise(resolve => {
|
|
407
|
-
resolve({ type: 'noServerId' });
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
let getDataFromIportal =
|
|
411
|
-
layerType === 'MARKER' || (dataSource && (!dataSource.accessType || dataSource.accessType === 'DIRECT'));
|
|
412
|
-
|
|
413
|
-
if (getDataFromIportal) {
|
|
414
|
-
return this._getDataFromIportal(serverId, layer);
|
|
415
|
-
} else {
|
|
416
|
-
return this._getDataFromHosted({ layer, serverId, baseProjection });
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
private _getFeaturesFromRestData(layer, baseProjection?) {
|
|
421
|
-
// 从restData获取数据
|
|
422
|
-
let features;
|
|
423
|
-
let dataSource = layer.dataSource;
|
|
424
|
-
return new Promise((resolve, reject) => {
|
|
425
|
-
this._getFeatureBySQL(
|
|
426
|
-
dataSource.url,
|
|
427
|
-
[decodeURIComponent(dataSource.dataSourceName) || layer.name],
|
|
428
|
-
result => {
|
|
429
|
-
features = this.parseGeoJsonData2Feature({
|
|
430
|
-
allDatas: {
|
|
431
|
-
features: result.result.features.features
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
resolve({ type: 'feature', features });
|
|
435
|
-
},
|
|
436
|
-
err => {
|
|
437
|
-
reject(err);
|
|
438
|
-
},
|
|
439
|
-
baseProjection
|
|
440
|
-
);
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
private _getFeaturesFromRestMap(layer) {
|
|
445
|
-
return new Promise((resolve, reject) => {
|
|
446
|
-
this._queryFeatureBySQL(
|
|
447
|
-
layer.dataSource.url,
|
|
448
|
-
layer.dataSource.layerName,
|
|
449
|
-
result => {
|
|
450
|
-
let recordsets = result && result.result.recordsets;
|
|
451
|
-
let recordset = recordsets && recordsets[0];
|
|
452
|
-
let attributes = recordset.fields;
|
|
453
|
-
if (recordset && attributes) {
|
|
454
|
-
let fileterAttrs: string[] = [];
|
|
455
|
-
for (let i in attributes) {
|
|
456
|
-
let value = attributes[i];
|
|
457
|
-
if (value.indexOf('Sm') !== 0 || value === 'SmID') {
|
|
458
|
-
fileterAttrs.push(value);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
this._getFeatures(
|
|
462
|
-
fileterAttrs,
|
|
463
|
-
layer,
|
|
464
|
-
features => {
|
|
465
|
-
resolve({ type: 'feature', features });
|
|
466
|
-
},
|
|
467
|
-
err => {
|
|
468
|
-
reject(err);
|
|
469
|
-
}
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
err => {
|
|
474
|
-
reject(err);
|
|
475
|
-
},
|
|
476
|
-
'smid=1'
|
|
477
|
-
);
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
private _getFeaturesFromUserData(layer) {
|
|
482
|
-
let dataSource = layer.dataSource;
|
|
483
|
-
return new Promise((resolve, reject) => {
|
|
484
|
-
const proxy = this.handleProxy();
|
|
485
|
-
let serviceUrl = this.handleParentRes(dataSource.url);
|
|
486
|
-
SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
487
|
-
withCredentials: this.handleWithCredentials(proxy, serviceUrl, this.withCredentials),
|
|
488
|
-
proxy,
|
|
489
|
-
withoutFormatSuffix: true
|
|
490
|
-
})
|
|
491
|
-
.then(response => {
|
|
492
|
-
return response.json();
|
|
493
|
-
})
|
|
494
|
-
.then(data => {
|
|
495
|
-
let features;
|
|
496
|
-
if (data && data instanceof Object && data.type === 'FeatureCollection') {
|
|
497
|
-
features = data.features;
|
|
498
|
-
} else {
|
|
499
|
-
features = data;
|
|
500
|
-
}
|
|
501
|
-
features = this.parseGeoJsonData2Feature({
|
|
502
|
-
allDatas: {
|
|
503
|
-
features
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
resolve({ type: 'feature', features });
|
|
507
|
-
})
|
|
508
|
-
.catch(err => {
|
|
509
|
-
reject(err);
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
private _queryFeatureBySQL(
|
|
515
|
-
url: string,
|
|
516
|
-
layerName: string,
|
|
517
|
-
processCompleted: Function,
|
|
518
|
-
processFaild: Function,
|
|
519
|
-
attributeFilter?: string,
|
|
520
|
-
fields?: Array<string>,
|
|
521
|
-
epsgCode?: string,
|
|
522
|
-
startRecord?,
|
|
523
|
-
recordLength?,
|
|
524
|
-
onlyAttribute?
|
|
525
|
-
): void {
|
|
526
|
-
let queryBySQLParams = this._getQueryFeaturesParam(
|
|
527
|
-
layerName,
|
|
528
|
-
attributeFilter,
|
|
529
|
-
fields,
|
|
530
|
-
epsgCode,
|
|
531
|
-
startRecord,
|
|
532
|
-
recordLength,
|
|
533
|
-
onlyAttribute
|
|
534
|
-
);
|
|
535
|
-
const proxy = this.handleProxy();
|
|
536
|
-
let serviceUrl = this.handleParentRes(url);
|
|
537
|
-
// @ts-ignore
|
|
538
|
-
let queryBySQLService = new SuperMap.QueryBySQLService(serviceUrl, {
|
|
539
|
-
proxy,
|
|
540
|
-
withCredentials: this.handleWithCredentials(proxy, url, false),
|
|
541
|
-
eventListeners: {
|
|
542
|
-
processCompleted: data => {
|
|
543
|
-
processCompleted && processCompleted(data);
|
|
544
|
-
},
|
|
545
|
-
processFailed: data => {
|
|
546
|
-
processFaild && processFaild(data);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
queryBySQLService.processAsync(queryBySQLParams);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
private _getFeatures(fields: string[], layerInfo: any, resolve: Function, reject: Function): void {
|
|
554
|
-
let source = layerInfo.dataSource;
|
|
555
|
-
// 示例数据
|
|
556
|
-
this._queryFeatureBySQL(
|
|
557
|
-
source.url,
|
|
558
|
-
source.layerName,
|
|
559
|
-
result => {
|
|
560
|
-
let recordsets = result.result.recordsets[0];
|
|
561
|
-
let features = recordsets.features.features;
|
|
562
|
-
|
|
563
|
-
let featuresObj = this.parseGeoJsonData2Feature({
|
|
564
|
-
allDatas: { features }
|
|
565
|
-
});
|
|
566
|
-
resolve(featuresObj);
|
|
567
|
-
},
|
|
568
|
-
err => {
|
|
569
|
-
reject(err);
|
|
570
|
-
},
|
|
571
|
-
null,
|
|
572
|
-
fields
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
private _getQueryFeaturesParam(
|
|
577
|
-
layerName: string,
|
|
578
|
-
attributeFilter?: string,
|
|
579
|
-
fields?: Array<string>,
|
|
580
|
-
epsgCode?: string,
|
|
581
|
-
startRecord?,
|
|
582
|
-
recordLength?,
|
|
583
|
-
onlyAttribute?
|
|
584
|
-
) {
|
|
585
|
-
let queryParam = new SuperMap.FilterParameter({
|
|
586
|
-
name: layerName,
|
|
587
|
-
attributeFilter: attributeFilter
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
if (fields) {
|
|
591
|
-
queryParam.fields = fields;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
let params: any = {
|
|
595
|
-
queryParams: [queryParam]
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
if (onlyAttribute) {
|
|
599
|
-
params.queryOption = SuperMap.QueryOption.ATTRIBUTE;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
startRecord && (params.startRecord = startRecord);
|
|
603
|
-
recordLength && (params.expectCount = recordLength);
|
|
604
|
-
|
|
605
|
-
if (epsgCode) {
|
|
606
|
-
params.prjCoordSys = {
|
|
607
|
-
epsgCode: epsgCode
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
let queryBySQLParams = new SuperMap.QueryBySQLParameters(params);
|
|
612
|
-
|
|
613
|
-
return queryBySQLParams;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
private _getFeaturesFromDataflow(layer) {
|
|
617
|
-
return new Promise((resolve, reject) => {
|
|
618
|
-
this._getDataflowInfo(
|
|
619
|
-
layer,
|
|
620
|
-
() => {
|
|
621
|
-
resolve({ type: 'dataflow' });
|
|
622
|
-
},
|
|
623
|
-
e => {
|
|
624
|
-
reject(e);
|
|
625
|
-
}
|
|
626
|
-
);
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
private _getDataflowInfo(layerInfo, success, faild?) {
|
|
631
|
-
let url = layerInfo.url;
|
|
632
|
-
let token;
|
|
633
|
-
let requestUrl = `${url}.json`;
|
|
634
|
-
if (layerInfo.credential && layerInfo.credential.token) {
|
|
635
|
-
token = layerInfo.credential.token;
|
|
636
|
-
requestUrl += `?token=${token}`;
|
|
637
|
-
}
|
|
638
|
-
const proxy = this.handleProxy();
|
|
639
|
-
requestUrl = this.handleParentRes(requestUrl);
|
|
640
|
-
SuperMap.FetchRequest.get(requestUrl, null, {
|
|
641
|
-
proxy,
|
|
642
|
-
withCredentials: this.handleWithCredentials(proxy, requestUrl, false)
|
|
643
|
-
})
|
|
644
|
-
.then(function (response) {
|
|
645
|
-
return response.json();
|
|
646
|
-
})
|
|
647
|
-
.then(function (result) {
|
|
648
|
-
if (!result) {
|
|
649
|
-
faild();
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
if (result.featureMetaData) {
|
|
653
|
-
layerInfo.featureType = result.featureMetaData.featureType.toUpperCase();
|
|
654
|
-
layerInfo.dataSource = { dataTypes: {} };
|
|
655
|
-
if (result.featureMetaData.fieldInfos && result.featureMetaData.fieldInfos.length > 0) {
|
|
656
|
-
result.featureMetaData.fieldInfos.forEach(function (data) {
|
|
657
|
-
let name = data.name.trim();
|
|
658
|
-
if (data.type === 'TEXT') {
|
|
659
|
-
layerInfo.dataSource.dataTypes[name] = 'STRING';
|
|
660
|
-
} else if (['DOUBLE', 'INT', 'FLOAT', 'LONG', 'SHORT'].includes(data.type)) {
|
|
661
|
-
layerInfo.dataSource.dataTypes[name] = 'NUMBER';
|
|
662
|
-
} else {
|
|
663
|
-
layerInfo.dataSource.dataTypes[name] = 'UNKNOWN';
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
layerInfo.wsUrl = result.urls[0].url;
|
|
669
|
-
layerInfo.name = result.urls[0].url.split('iserver/services/')[1].split('/dataflow')[0];
|
|
670
|
-
success();
|
|
671
|
-
})
|
|
672
|
-
.catch(function () {
|
|
673
|
-
faild();
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
public getDatasourceType(layer) {
|
|
678
|
-
let { dataSource, layerType } = layer;
|
|
679
|
-
if (dataSource && dataSource.type === 'SAMPLE_DATA') {
|
|
680
|
-
return dataSource.type;
|
|
681
|
-
}
|
|
682
|
-
let type;
|
|
683
|
-
let isHosted = (dataSource && dataSource.serverId) || layerType === 'MARKER' || layerType === 'HOSTED_TILE';
|
|
684
|
-
let isTile =
|
|
685
|
-
layerType === 'SUPERMAP_REST' ||
|
|
686
|
-
layerType === 'TILE' ||
|
|
687
|
-
layerType === 'WMS' ||
|
|
688
|
-
layerType === 'WMTS' ||
|
|
689
|
-
layerType === 'MAPBOXSTYLE';
|
|
690
|
-
if (isHosted) {
|
|
691
|
-
type = 'hosted';
|
|
692
|
-
} else if (isTile) {
|
|
693
|
-
type = 'tile';
|
|
694
|
-
} else if (dataSource && dataSource.type === 'REST_DATA') {
|
|
695
|
-
type = 'rest_data';
|
|
696
|
-
} else if (dataSource && dataSource.type === 'REST_MAP' && dataSource.url) {
|
|
697
|
-
type = 'rest_map';
|
|
698
|
-
} else if (layerType === 'DATAFLOW_POINT_TRACK' || layerType === 'DATAFLOW_HEAT') {
|
|
699
|
-
type = 'dataflow';
|
|
700
|
-
} else if (dataSource && dataSource.type === 'USER_DATA') {
|
|
701
|
-
type = 'user_data';
|
|
702
|
-
}
|
|
703
|
-
return type;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
public getFeatureProperties(features) {
|
|
707
|
-
let properties = [];
|
|
708
|
-
if (features && features.length) {
|
|
709
|
-
features.forEach(feature => {
|
|
710
|
-
let property = feature.properties;
|
|
711
|
-
property && properties.push(property);
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
return properties;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
public parseGeoJsonData2Feature(metaData: any) {
|
|
718
|
-
let allFeatures = metaData.allDatas.features;
|
|
719
|
-
let features = [];
|
|
720
|
-
for (let i = 0, len = allFeatures.length; i < len; i++) {
|
|
721
|
-
let feature = allFeatures[i];
|
|
722
|
-
let coordinate = feature.geometry.coordinates;
|
|
723
|
-
if (allFeatures[i].geometry.type === 'Point') {
|
|
724
|
-
// 标注图层 还没有属性值时候不加
|
|
725
|
-
if (allFeatures[i].properties) {
|
|
726
|
-
allFeatures[i].properties.lon = coordinate[0];
|
|
727
|
-
allFeatures[i].properties.lat = coordinate[1];
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
feature.properties['index'] = i + '';
|
|
731
|
-
features.push(feature);
|
|
732
|
-
}
|
|
733
|
-
return features;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
private _getDataFromIportal(serverId, layerInfo) {
|
|
737
|
-
let features;
|
|
738
|
-
// 原来二进制文件
|
|
739
|
-
let url = `${this.serverUrl}web/datas/${serverId}/content.json?pageSize=9999999¤tPage=1`;
|
|
740
|
-
if (this.accessToken) {
|
|
741
|
-
url = `${url}&${this.accessKey}=${this.accessToken}`;
|
|
742
|
-
}
|
|
743
|
-
return new Promise((resolve, reject) => {
|
|
744
|
-
url = this.handleParentRes(url);
|
|
745
|
-
const proxy = this.handleProxy();
|
|
746
|
-
SuperMap.FetchRequest.get(url, null, {
|
|
747
|
-
withCredentials: this.handleWithCredentials(proxy, url, this.withCredentials),
|
|
748
|
-
proxy
|
|
749
|
-
})
|
|
750
|
-
.then(response => {
|
|
751
|
-
return response.json();
|
|
752
|
-
})
|
|
753
|
-
.then(async data => {
|
|
754
|
-
if (data.succeed === false) {
|
|
755
|
-
reject(data.error);
|
|
756
|
-
}
|
|
757
|
-
if (data && data.type) {
|
|
758
|
-
if (data.type === 'JSON' || data.type === 'GEOJSON') {
|
|
759
|
-
data.content = JSON.parse(data.content.trim());
|
|
760
|
-
features = this._formatGeoJSON(data.content);
|
|
761
|
-
} else if (data.type === 'EXCEL' || data.type === 'CSV') {
|
|
762
|
-
if (layerInfo.dataSource && layerInfo.dataSource.administrativeInfo) {
|
|
763
|
-
// 行政规划信息
|
|
764
|
-
data.content.rows.unshift(data.content.colTitles);
|
|
765
|
-
const { divisionType, divisionField } = layerInfo.dataSource.administrativeInfo;
|
|
766
|
-
const geojson = await this._excelData2FeatureByDivision(data.content, divisionType, divisionField);
|
|
767
|
-
features = this._formatGeoJSON(geojson);
|
|
768
|
-
} else {
|
|
769
|
-
features = this._excelData2Feature(data.content, (layerInfo && layerInfo.xyField) || {});
|
|
770
|
-
}
|
|
771
|
-
} else if (data.type === 'SHP') {
|
|
772
|
-
data.content = JSON.parse(data.content.trim());
|
|
773
|
-
features = this._formatGeoJSON(data.content.layers[0]);
|
|
774
|
-
}
|
|
775
|
-
resolve({ type: 'feature', features });
|
|
776
|
-
}
|
|
777
|
-
})
|
|
778
|
-
.catch(error => {
|
|
779
|
-
reject(error);
|
|
780
|
-
});
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
private _getDataFromHosted({ layer, serverId, baseProjection }) {
|
|
785
|
-
// 关系型文件
|
|
786
|
-
let isMapService = layer.layerType === 'HOSTED_TILE';
|
|
787
|
-
return new Promise((resolve, reject) => {
|
|
788
|
-
this._checkUploadToRelationship(serverId)
|
|
789
|
-
.then(result => {
|
|
790
|
-
if (result && result.length > 0) {
|
|
791
|
-
let datasetName = result[0].name;
|
|
792
|
-
let featureType = result[0].type.toUpperCase();
|
|
793
|
-
this._getDataService(serverId, datasetName).then(data => {
|
|
794
|
-
let dataItemServices = data.dataItemServices;
|
|
795
|
-
if (dataItemServices.length === 0) {
|
|
796
|
-
reject('noDataServices');
|
|
797
|
-
}
|
|
798
|
-
let param = { layer, dataItemServices, datasetName, featureType, resolve, reject, baseProjection };
|
|
799
|
-
if (isMapService) {
|
|
800
|
-
let dataService = dataItemServices.filter(info => {
|
|
801
|
-
return info && info.serviceType === 'RESTDATA';
|
|
802
|
-
})[0];
|
|
803
|
-
this._isMvt(dataService.address, datasetName, baseProjection)
|
|
804
|
-
.then(info => {
|
|
805
|
-
this._getServiceInfoFromLayer(param, info);
|
|
806
|
-
})
|
|
807
|
-
.catch(() => {
|
|
808
|
-
// 判断失败就走之前逻辑,>数据量用tile
|
|
809
|
-
this._getServiceInfoFromLayer(param);
|
|
810
|
-
});
|
|
811
|
-
} else {
|
|
812
|
-
this._getServiceInfoFromLayer(param);
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
} else {
|
|
816
|
-
reject('resultIsEmpty');
|
|
817
|
-
}
|
|
818
|
-
})
|
|
819
|
-
.catch(error => {
|
|
820
|
-
reject(error);
|
|
821
|
-
});
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
private _isMvt(serviceUrl, datasetName, baseProjection) {
|
|
826
|
-
return this._getDatasetsInfo(serviceUrl, datasetName).then(info => {
|
|
827
|
-
// 判断是否和底图坐标系一直
|
|
828
|
-
/* eslint-disable */
|
|
829
|
-
if (info.epsgCode == baseProjection.split('EPSG:')[1]) {
|
|
830
|
-
return SuperMap.FetchRequest.get(`${info.url}/tilefeature.mvt`)
|
|
831
|
-
.then(function (response) {
|
|
832
|
-
return response.json();
|
|
833
|
-
})
|
|
834
|
-
.then(function (result) {
|
|
835
|
-
info.isMvt = result.error && result.error.code === 400;
|
|
836
|
-
return info;
|
|
837
|
-
})
|
|
838
|
-
.catch(() => {
|
|
839
|
-
return info;
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
return info;
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
private _getServiceInfoFromLayer(
|
|
847
|
-
{ layer, dataItemServices, datasetName, featureType, resolve, reject, baseProjection },
|
|
848
|
-
info?: any
|
|
849
|
-
) {
|
|
850
|
-
let isMapService = info ? !info.isMvt : layer.layerType === 'HOSTED_TILE';
|
|
851
|
-
let isAdded = false;
|
|
852
|
-
dataItemServices.forEach(service => {
|
|
853
|
-
if (isAdded) {
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
// TODO 对接 MVT
|
|
857
|
-
// 有服务了,就不需要循环
|
|
858
|
-
if (service && isMapService && service.serviceType === 'RESTMAP') {
|
|
859
|
-
isAdded = true;
|
|
860
|
-
// 地图服务,判断使用mvt还是tile
|
|
861
|
-
this._getTileLayerInfo(service.address, baseProjection).then(restMaps => {
|
|
862
|
-
resolve({ type: 'restMap', restMaps });
|
|
863
|
-
});
|
|
864
|
-
} else if (service && !isMapService && service.serviceType === 'RESTDATA') {
|
|
865
|
-
if (info && info.isMvt) {
|
|
866
|
-
// this._addVectorLayer(info, layer, featureType);
|
|
867
|
-
resolve({ type: 'mvt', info, featureType });
|
|
868
|
-
} else {
|
|
869
|
-
// 数据服务
|
|
870
|
-
isAdded = true;
|
|
871
|
-
// 关系型文件发布的数据服务
|
|
872
|
-
this._getDatasources(service.address).then(
|
|
873
|
-
datasourceName => {
|
|
874
|
-
layer.dataSource.dataSourceName = datasourceName + ':' + datasetName;
|
|
875
|
-
layer.dataSource.url = `${service.address}/data`;
|
|
876
|
-
this._getFeatureBySQL(
|
|
877
|
-
layer.dataSource.url,
|
|
878
|
-
[layer.dataSource.dataSourceName || layer.name],
|
|
879
|
-
result => {
|
|
880
|
-
let features = this.parseGeoJsonData2Feature({
|
|
881
|
-
allDatas: {
|
|
882
|
-
features: result.result.features.features
|
|
883
|
-
}
|
|
884
|
-
});
|
|
885
|
-
resolve({ type: 'feature', features });
|
|
886
|
-
},
|
|
887
|
-
err => {
|
|
888
|
-
reject(err);
|
|
889
|
-
}
|
|
890
|
-
);
|
|
891
|
-
},
|
|
892
|
-
err => {
|
|
893
|
-
reject(err);
|
|
894
|
-
}
|
|
895
|
-
);
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
}, this);
|
|
899
|
-
if (!isAdded) {
|
|
900
|
-
// 循环完成了,也没有找到合适的服务。有可能服务被删除
|
|
901
|
-
reject('noService');
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
private _getDatasetsInfo(serviceUrl, datasetName) {
|
|
906
|
-
return this._getDatasources(serviceUrl).then(datasourceName => {
|
|
907
|
-
// 判断mvt服务是否可用
|
|
908
|
-
let url = `${serviceUrl}/data/datasources/${datasourceName}/datasets/${datasetName}`;
|
|
909
|
-
const proxy = this.handleProxy();
|
|
910
|
-
url = this.handleParentRes(url);
|
|
911
|
-
return SuperMap.FetchRequest.get(url, null, {
|
|
912
|
-
withCredentials: this.handleWithCredentials(proxy, url, false),
|
|
913
|
-
proxy
|
|
914
|
-
})
|
|
915
|
-
.then(response => {
|
|
916
|
-
return response.json();
|
|
917
|
-
})
|
|
918
|
-
.then(datasetsInfo => {
|
|
919
|
-
return {
|
|
920
|
-
epsgCode: datasetsInfo.datasetInfo.prjCoordSys.epsgCode,
|
|
921
|
-
bounds: datasetsInfo.datasetInfo.bounds,
|
|
922
|
-
datasourceName,
|
|
923
|
-
datasetName,
|
|
924
|
-
url // 返回的是原始url,没有代理。因为用于请求mvt
|
|
925
|
-
};
|
|
926
|
-
});
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
private _getDatasources(url) {
|
|
931
|
-
const proxy = this.handleProxy();
|
|
932
|
-
let serviceUrl = `${url}/data/datasources.json`;
|
|
933
|
-
serviceUrl = this.handleParentRes(serviceUrl);
|
|
934
|
-
return SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
935
|
-
withCredentials: this.handleWithCredentials(proxy, serviceUrl, false),
|
|
936
|
-
proxy
|
|
937
|
-
})
|
|
938
|
-
.then(response => {
|
|
939
|
-
return response.json();
|
|
940
|
-
})
|
|
941
|
-
.then(datasource => {
|
|
942
|
-
if (datasource.code === 401) {
|
|
943
|
-
throw Error(datasource.errorMsg);
|
|
944
|
-
}
|
|
945
|
-
let datasourceNames = datasource.datasourceNames;
|
|
946
|
-
return datasourceNames[0];
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
private _getDataService(fileId, datasetName) {
|
|
951
|
-
const proxy = this.handleProxy();
|
|
952
|
-
let serviceUrl = `${this.serverUrl}web/datas/${fileId}.json`;
|
|
953
|
-
serviceUrl = this.handleParentRes(serviceUrl);
|
|
954
|
-
return SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
955
|
-
withCredentials: this.handleWithCredentials(proxy, serviceUrl, this.withCredentials),
|
|
956
|
-
proxy
|
|
957
|
-
})
|
|
958
|
-
.then(response => {
|
|
959
|
-
return response.json();
|
|
960
|
-
})
|
|
961
|
-
.then(result => {
|
|
962
|
-
result.fileId = fileId;
|
|
963
|
-
result.datasetName = datasetName;
|
|
964
|
-
return result;
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
private _checkUploadToRelationship(fileId) {
|
|
969
|
-
const proxy = this.handleProxy();
|
|
970
|
-
let serviceUrl = `${this.serverUrl}web/datas/${fileId}/datasets.json`;
|
|
971
|
-
serviceUrl = this.handleParentRes(serviceUrl);
|
|
972
|
-
return SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
973
|
-
withCredentials: this.handleWithCredentials(proxy, serviceUrl, this.withCredentials),
|
|
974
|
-
proxy
|
|
975
|
-
})
|
|
976
|
-
.then(response => {
|
|
977
|
-
return response.json();
|
|
978
|
-
})
|
|
979
|
-
.then(result => {
|
|
980
|
-
return result;
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
private _handleMapUrl() {
|
|
985
|
-
let mapUrl = this.serverUrl + 'web/maps/' + this.mapId + '/map';
|
|
986
|
-
if (this.accessToken || this.accessKey) {
|
|
987
|
-
mapUrl += '?' + (this.accessToken && !this.accessKey) ? 'token=' + this.accessToken : 'key=' + this.accessKey;
|
|
988
|
-
}
|
|
989
|
-
let filter = 'getUrlResource.json?url=';
|
|
990
|
-
if (this.excludePortalProxyUrl && this.serverUrl.indexOf(filter) > -1) {
|
|
991
|
-
// 大屏需求,或者有加上代理的
|
|
992
|
-
let urlArray = this.serverUrl.split(filter);
|
|
993
|
-
if (urlArray.length > 1) {
|
|
994
|
-
mapUrl = urlArray[0] + filter + this.serverUrl + 'web/maps/' + this.mapId + '/map.json';
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
mapUrl = mapUrl.indexOf('.json') === -1 ? `${mapUrl}.json` : mapUrl;
|
|
998
|
-
return mapUrl;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
public handleProxy(type?: string): string {
|
|
1002
|
-
if (!this.proxy) {
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
const proxySuffix: string = this.proxyOptions[type || 'data'];
|
|
1006
|
-
let proxy: string = this.serverUrl + proxySuffix;
|
|
1007
|
-
if (typeof this.proxy === 'string') {
|
|
1008
|
-
proxy = this.proxy;
|
|
1009
|
-
}
|
|
1010
|
-
return proxy;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
public handleWithCredentials(proxyUrl?: string, serviceUrl?: string, defaultValue = this.withCredentials): boolean | string {
|
|
1014
|
-
if (serviceUrl?.includes('https://www.supermapol.com')) {
|
|
1015
|
-
return '';
|
|
1016
|
-
}
|
|
1017
|
-
if (proxyUrl && proxyUrl.startsWith(this.serverUrl) && (!serviceUrl || serviceUrl.startsWith(proxyUrl))) {
|
|
1018
|
-
return true;
|
|
1019
|
-
}
|
|
1020
|
-
if (serviceUrl && this.iportalServiceProxyUrl && serviceUrl.indexOf(this.iportalServiceProxyUrl) >= 0) {
|
|
1021
|
-
return true;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
return defaultValue;
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
public isIportalResourceUrl(serviceUrl) {
|
|
1028
|
-
return (
|
|
1029
|
-
serviceUrl.startsWith(this.serverUrl) ||
|
|
1030
|
-
(this.iportalServiceProxyUrl && serviceUrl.indexOf(this.iportalServiceProxyUrl) >= 0)
|
|
1031
|
-
);
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
public handleParentRes(url, parentResId = this.mapId, parentResType = 'MAP'): string {
|
|
1035
|
-
if (!this.isIportalResourceUrl(url)) {
|
|
1036
|
-
return url;
|
|
1037
|
-
}
|
|
1038
|
-
return urlAppend(url, `parentResType=${parentResType}&parentResId=${parentResId}`);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
private _formatGeoJSON(data): any {
|
|
1042
|
-
let features = data.features;
|
|
1043
|
-
features.forEach((row, index) => {
|
|
1044
|
-
row.properties['index'] = index;
|
|
1045
|
-
});
|
|
1046
|
-
return features;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
private _excelData2Feature(dataContent: any, xyField: any = {}): any {
|
|
1050
|
-
let fieldCaptions = dataContent.colTitles;
|
|
1051
|
-
// 位置属性处理
|
|
1052
|
-
let xfieldIndex = fieldCaptions.indexOf(xyField.xField);
|
|
1053
|
-
let yfieldIndex = fieldCaptions.indexOf(xyField.yField);
|
|
1054
|
-
if (yfieldIndex < 0 || xfieldIndex < 0) {
|
|
1055
|
-
for (let i = 0, len = fieldCaptions.length; i < len; i++) {
|
|
1056
|
-
if (isXField(fieldCaptions[i])) {
|
|
1057
|
-
xfieldIndex = i;
|
|
1058
|
-
}
|
|
1059
|
-
if (isYField(fieldCaptions[i])) {
|
|
1060
|
-
yfieldIndex = i;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
// feature 构建后期支持坐标系 4326/3857
|
|
1066
|
-
let features = [];
|
|
1067
|
-
|
|
1068
|
-
for (let i = 0, len = dataContent.rows.length; i < len; i++) {
|
|
1069
|
-
let row = dataContent.rows[i];
|
|
1070
|
-
|
|
1071
|
-
let x = Number(row[xfieldIndex]);
|
|
1072
|
-
let y = Number(row[yfieldIndex]);
|
|
1073
|
-
|
|
1074
|
-
if (isNaN(x) || isNaN(y)) {
|
|
1075
|
-
continue;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
// 属性信息
|
|
1079
|
-
let attributes = {};
|
|
1080
|
-
for (let index = 0; index < dataContent.colTitles.length; index++) {
|
|
1081
|
-
const element = dataContent.colTitles[index].trim();
|
|
1082
|
-
attributes[element] = dataContent.rows[i][index];
|
|
1083
|
-
}
|
|
1084
|
-
attributes['index'] = i + '';
|
|
1085
|
-
// 目前csv 只支持处理点,所以先生成点类型的 geojson
|
|
1086
|
-
let feature = {
|
|
1087
|
-
type: 'Feature',
|
|
1088
|
-
geometry: {
|
|
1089
|
-
type: 'Point',
|
|
1090
|
-
coordinates: [x, y]
|
|
1091
|
-
},
|
|
1092
|
-
properties: attributes
|
|
1093
|
-
};
|
|
1094
|
-
features.push(feature);
|
|
1095
|
-
}
|
|
1096
|
-
return features;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
private _excelData2FeatureByDivision(content: any, divisionType: string, divisionField: string): Promise<Object> {
|
|
1100
|
-
const dataName = ['城市', 'City'].includes(divisionType) ? 'MunicipalData' : 'ProvinceData';
|
|
1101
|
-
if (window[dataName] && window[dataName].features) {
|
|
1102
|
-
return new Promise(resolve => {
|
|
1103
|
-
resolve(this._combineFeature(content, window[dataName], divisionField));
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
const dataFileName = ['城市', 'City'].includes(divisionType) ? 'MunicipalData.js' : 'ProvincialData.js';
|
|
1107
|
-
const proxy = this.handleProxy();
|
|
1108
|
-
const dataUrl = `${this.serverUrl}apps/dataviz/libs/administrative_data/${dataFileName}`;
|
|
1109
|
-
return SuperMap.FetchRequest.get(dataUrl, null, {
|
|
1110
|
-
withCredentials: false,
|
|
1111
|
-
proxy,
|
|
1112
|
-
withoutFormatSuffix: true
|
|
1113
|
-
})
|
|
1114
|
-
.then(response => {
|
|
1115
|
-
return response.text();
|
|
1116
|
-
})
|
|
1117
|
-
.then(result => {
|
|
1118
|
-
new Function(result)();
|
|
1119
|
-
return this._combineFeature(content, window[dataName], divisionField);
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
private _combineFeature(
|
|
1124
|
-
properties: any,
|
|
1125
|
-
geoData: GeoJSON.FeatureCollection,
|
|
1126
|
-
divisionField: string
|
|
1127
|
-
): GeoJSON.FeatureCollection {
|
|
1128
|
-
let geojson: GeoJSON.FeatureCollection = {
|
|
1129
|
-
type: 'FeatureCollection',
|
|
1130
|
-
features: []
|
|
1131
|
-
};
|
|
1132
|
-
if (properties.length < 2) {
|
|
1133
|
-
return geojson;
|
|
1134
|
-
} // 只有一行数据时为标题
|
|
1135
|
-
let titles = properties.colTitles;
|
|
1136
|
-
let rows = properties.rows;
|
|
1137
|
-
let fieldIndex = titles.findIndex(title => title === divisionField);
|
|
1138
|
-
rows.forEach(row => {
|
|
1139
|
-
let feature = geoData.features.find(item => {
|
|
1140
|
-
return this._isMatchAdministrativeName(item.properties.Name, row[fieldIndex]);
|
|
1141
|
-
});
|
|
1142
|
-
// todo 需提示忽略无效数据
|
|
1143
|
-
if (feature) {
|
|
1144
|
-
const province = feature.properties.Province;
|
|
1145
|
-
const combineFeature: GeoJSON.Feature = { properties: {}, geometry: feature.geometry, type: 'Feature' };
|
|
1146
|
-
row.forEach((item, idx) => {
|
|
1147
|
-
combineFeature.properties[titles[idx]] = item;
|
|
1148
|
-
});
|
|
1149
|
-
if (province) {
|
|
1150
|
-
combineFeature.properties.Province = province;
|
|
1151
|
-
}
|
|
1152
|
-
geojson.features.push(combineFeature);
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
return geojson;
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
* @description 行政区划原始数据和当前数据是否匹配
|
|
1160
|
-
*/
|
|
1161
|
-
private _isMatchAdministrativeName(featureName: string, fieldName: string): boolean {
|
|
1162
|
-
if (featureName && typeof fieldName === 'string' && fieldName.constructor === String) {
|
|
1163
|
-
let shortName = featureName.trim().substr(0, 2);
|
|
1164
|
-
// 张家口市和张家界市
|
|
1165
|
-
if (shortName === '张家') {
|
|
1166
|
-
shortName = featureName.trim().substr(0, 3);
|
|
1167
|
-
}
|
|
1168
|
-
// 阿拉善盟 阿拉尔市
|
|
1169
|
-
if (shortName === '阿拉') {
|
|
1170
|
-
shortName = featureName.trim().substr(0, 3);
|
|
1171
|
-
}
|
|
1172
|
-
return !!fieldName.match(new RegExp(shortName));
|
|
1173
|
-
}
|
|
1174
|
-
return false;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
private _getTileLayerInfo(url, baseProjection) {
|
|
1178
|
-
const proxy = this.handleProxy();
|
|
1179
|
-
let epsgCode = baseProjection.split('EPSG:')[1];
|
|
1180
|
-
let serviceUrl = `${url}/maps.json`;
|
|
1181
|
-
serviceUrl = this.handleParentRes(serviceUrl);
|
|
1182
|
-
return SuperMap.FetchRequest.get(serviceUrl, null, {
|
|
1183
|
-
withCredentials: this.handleWithCredentials(proxy, serviceUrl, this.withCredentials),
|
|
1184
|
-
proxy
|
|
1185
|
-
})
|
|
1186
|
-
.then(response => {
|
|
1187
|
-
return response.json();
|
|
1188
|
-
})
|
|
1189
|
-
.then(mapInfo => {
|
|
1190
|
-
let promises = [];
|
|
1191
|
-
if (mapInfo) {
|
|
1192
|
-
mapInfo.forEach(info => {
|
|
1193
|
-
let promise = SuperMap.FetchRequest.get(
|
|
1194
|
-
`${info.path}.json?prjCoordSys=${JSON.stringify({ epsgCode: epsgCode })}`,
|
|
1195
|
-
null,
|
|
1196
|
-
{
|
|
1197
|
-
withCredentials: this.withCredentials,
|
|
1198
|
-
proxy
|
|
1199
|
-
}
|
|
1200
|
-
)
|
|
1201
|
-
.then(response => {
|
|
1202
|
-
return response.json();
|
|
1203
|
-
})
|
|
1204
|
-
.then(restMapInfo => {
|
|
1205
|
-
restMapInfo.url = info.path;
|
|
1206
|
-
return restMapInfo;
|
|
1207
|
-
});
|
|
1208
|
-
promises.push(promise);
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
return Promise.all(promises).then(allRestMaps => {
|
|
1212
|
-
return allRestMaps;
|
|
1213
|
-
});
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
private _getFeatureBySQL(
|
|
1218
|
-
url: string,
|
|
1219
|
-
datasetNames: Array<string>,
|
|
1220
|
-
processCompleted: Function,
|
|
1221
|
-
processFaild: Function,
|
|
1222
|
-
baseProjection?
|
|
1223
|
-
): void {
|
|
1224
|
-
let getFeatureParam, getFeatureBySQLService, getFeatureBySQLParams;
|
|
1225
|
-
getFeatureParam = new SuperMap.FilterParameter({
|
|
1226
|
-
name: datasetNames.join().replace(':', '@'),
|
|
1227
|
-
attributeFilter: null
|
|
1228
|
-
});
|
|
1229
|
-
getFeatureBySQLParams = new SuperMap.GetFeaturesBySQLParameters({
|
|
1230
|
-
queryParameter: getFeatureParam,
|
|
1231
|
-
datasetNames: datasetNames,
|
|
1232
|
-
fromIndex: 0,
|
|
1233
|
-
toIndex: -1,
|
|
1234
|
-
maxFeatures: -1,
|
|
1235
|
-
returnContent: true
|
|
1236
|
-
});
|
|
1237
|
-
if (baseProjection) {
|
|
1238
|
-
if (baseProjection === 'EPSG:3857' || baseProjection === 'EPSG:-1000') {
|
|
1239
|
-
getFeatureBySQLParams.targetEpsgCode = 4326;
|
|
1240
|
-
} else {
|
|
1241
|
-
getFeatureBySQLParams.targetEpsgCode = +baseProjection.split(':')[1];
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
const proxy = this.handleProxy();
|
|
1245
|
-
let options = {
|
|
1246
|
-
proxy,
|
|
1247
|
-
withCredentials: this.handleWithCredentials(proxy, url, false),
|
|
1248
|
-
eventListeners: {
|
|
1249
|
-
processCompleted: getFeaturesEventArgs => {
|
|
1250
|
-
let result = getFeaturesEventArgs.result;
|
|
1251
|
-
if(result && result.datasetInfos) {
|
|
1252
|
-
let fields = []; let fieldCaptions = []; let fieldTypes = [];
|
|
1253
|
-
const fieldInfos = result.datasetInfos[0].fieldInfos;
|
|
1254
|
-
fieldInfos.forEach(fieldInfo => {
|
|
1255
|
-
if(fieldInfo.name) {
|
|
1256
|
-
fields.push(fieldInfo.name.toUpperCase());
|
|
1257
|
-
fieldCaptions.push(fieldInfo.caption.toUpperCase());
|
|
1258
|
-
fieldTypes.push(fieldInfo.type);
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
let data = statisticsFeatures(result.features.features, fields, fieldCaptions, fieldTypes);
|
|
1262
|
-
getFeaturesEventArgs.result.features.features = data.features;
|
|
1263
|
-
}
|
|
1264
|
-
processCompleted && processCompleted(getFeaturesEventArgs);
|
|
1265
|
-
},
|
|
1266
|
-
processFailed: e => {
|
|
1267
|
-
processFaild && processFaild(e);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
};
|
|
1271
|
-
const serviceUrl = this.handleParentRes(url);
|
|
1272
|
-
getFeatureBySQLService = new SuperMap.GetFeaturesBySQLService(serviceUrl, options);
|
|
1273
|
-
getFeatureBySQLService.processAsync(getFeatureBySQLParams);
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
public async getEpsgCodeInfo(epsgCode, iPortalUrl) {
|
|
1277
|
-
const url = iPortalUrl.slice(-1) === '/' ? iPortalUrl : `${iPortalUrl}/`;
|
|
1278
|
-
let codeUrl = `${url}epsgcodes/${epsgCode}.json`;
|
|
1279
|
-
const wkt = await SuperMap.FetchRequest.get(codeUrl, null)
|
|
1280
|
-
.then(response => {
|
|
1281
|
-
return response.json();
|
|
1282
|
-
})
|
|
1283
|
-
.then(epsgcodeInfo => {
|
|
1284
|
-
return epsgcodeInfo.wkt;
|
|
1285
|
-
})
|
|
1286
|
-
.catch(err => {
|
|
1287
|
-
console.error(err);
|
|
1288
|
-
return undefined;
|
|
1289
|
-
});
|
|
1290
|
-
return wkt;
|
|
1291
|
-
}
|
|
1292
|
-
}
|