@geoscene/core 4.34.8 → 4.34.9
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/assets/geoscene/core/workers/chunks/0f4e9846d074864b39c2.js +1 -1
- package/assets/geoscene/core/workers/chunks/38b9ec5f73f2467262dc.js +1 -1
- package/assets/geoscene/core/workers/chunks/50e1c63d0b6196dd365e.js +1 -1
- package/assets/geoscene/core/workers/chunks/bc3df7ef6d001bb8192e.js +1 -1
- package/assets/geoscene/core/workers/chunks/db8d4a12a67a62ec3704.js +1 -1
- package/assets/geoscene/core/workers/chunks/dfbf2e17058aa876f96a.js +1 -1
- package/interfaces.d.ts +15 -0
- package/layers/MapImageTileLayer.js +355 -0
- package/layers/mixins/SublayersOwner.js +1 -1
- package/layers/mixins/operationalLayers.js +1 -1
- package/layers/support/LercWorker.js +1 -5
- package/layers/support/layersCreator.js +1 -1
- package/layers/support/lazyLayerLoader.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/package.json +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/rest/query/executeQueryFGB.js +1 -0
- package/rest/query/operations/flatgeobufGeojson.js +3 -0
- package/rest/query/operations/flatgeobufGeojson.min.js +15 -0
- package/rest/query/operations/query.js +1 -1
- package/rest/query.d.ts +1 -0
- package/rest/query.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LayerList/LayerListItem.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import {__decorate as e} from "tslib";
|
|
6
|
+
import r from "../request.js";
|
|
7
|
+
import t from "../core/Error.js";
|
|
8
|
+
import {loadAll as s} from "../core/loadAll.js";
|
|
9
|
+
import {MultiOriginJSONMixin as i} from "../core/MultiOriginJSONSupport.js";
|
|
10
|
+
import {throwIfAbortError as o} from "../core/promiseUtils.js";
|
|
11
|
+
import {urlToObject as a, objectToQuery as l, makeAbsolute as n} from "../core/urlUtils.js";
|
|
12
|
+
import {property as p} from "../core/accessorSupport/decorators/property.js";
|
|
13
|
+
import {cast as c} from "../core/accessorSupport/decorators/cast.js";
|
|
14
|
+
import "../core/has.js";
|
|
15
|
+
import "../core/RandomLCG.js";
|
|
16
|
+
import {reader as u} from "../core/accessorSupport/decorators/reader.js";
|
|
17
|
+
import {subclass as m} from "../core/accessorSupport/decorators/subclass.js";
|
|
18
|
+
import {writer as h} from "../core/accessorSupport/decorators/writer.js";
|
|
19
|
+
import d from "../geometry/SpatialReference.js";
|
|
20
|
+
import y from "./Layer.js";
|
|
21
|
+
import {APIKeyMixin as f} from "./mixins/APIKeyMixin.js";
|
|
22
|
+
import {ArcGISCachedService as v} from "./mixins/ArcGISCachedService.js";
|
|
23
|
+
import {ArcGISMapService as g} from "./mixins/ArcGISMapService.js";
|
|
24
|
+
import {ArcGISService as S} from "./mixins/ArcGISService.js";
|
|
25
|
+
import {BlendLayer as _} from "./mixins/BlendLayer.js";
|
|
26
|
+
import {CustomParametersMixin as j} from "./mixins/CustomParametersMixin.js";
|
|
27
|
+
import {OperationalLayer as b} from "./mixins/OperationalLayer.js";
|
|
28
|
+
import {PortalLayer as T} from "./mixins/PortalLayer.js";
|
|
29
|
+
import {RefreshableLayer as w} from "./mixins/RefreshableLayer.js";
|
|
30
|
+
import {ScaleRangeLayer as O} from "./mixins/ScaleRangeLayer.js";
|
|
31
|
+
import {SublayersOwner as L} from "./mixins/SublayersOwner.js";
|
|
32
|
+
import {parse as R, isHostedAgolService as A, isArcGISUrl as U} from "./support/arcgisLayerUrl.js";
|
|
33
|
+
import {url as P} from "./support/commonProperties.js";
|
|
34
|
+
import {createTileBitmap as x} from "./support/imageBitmapUtils.js";
|
|
35
|
+
import I from "./support/Sublayer.js";
|
|
36
|
+
import M from "../symbols/support/ElevationInfo.js";
|
|
37
|
+
import Z from "../layers/MapImageLayer.js";
|
|
38
|
+
import Y from "../geometry/Extent.js";
|
|
39
|
+
import * as Q from "../core/reactiveUtils.js";
|
|
40
|
+
var W;
|
|
41
|
+
const B = ["Canvas/World_Dark_Gray_Base", "Canvas/World_Dark_Gray_Reference", "Canvas/World_Light_Gray_Base", "Canvas/World_Light_Gray_Reference", "Elevation/World_Hillshade", "Elevation/World_Hillshade_Dark", "Ocean/World_Ocean_Base", "Ocean/World_Ocean_Reference", "Ocean_Basemap", "Reference/World_Boundaries_and_Places", "Reference/World_Boundaries_and_Places_Alternate", "Reference/World_Transportation", "World_Imagery", "World_Street_Map", "World_Topo_Map"];
|
|
42
|
+
let C = W = class extends (_(O(L(v(g(b(T(S(i(w(f(j(y))))))))))))) {
|
|
43
|
+
constructor(...e) {
|
|
44
|
+
super(...e),
|
|
45
|
+
this.listMode = "show",
|
|
46
|
+
this.elevationInfo = new M({
|
|
47
|
+
mode: "on-the-ground"
|
|
48
|
+
}),
|
|
49
|
+
this.isReference = null,
|
|
50
|
+
this.operationalLayerType = "ArcGISMapServiceTileLayer",
|
|
51
|
+
this.resampling = !0,
|
|
52
|
+
this.sourceJSON = null,
|
|
53
|
+
this.spatialReference = null,
|
|
54
|
+
this.path = null,
|
|
55
|
+
this.sublayers = null,
|
|
56
|
+
this.type = "base-tile",
|
|
57
|
+
this.__init_error_info = {
|
|
58
|
+
title: "Failed to create layerview for layer title:" + `'${this.title}'` + ", id: " + `'${this.id}'` + " of type " + `'${this.type}'.`,
|
|
59
|
+
name: "tilingscheme:tile-info-missing_or_invalid",
|
|
60
|
+
message: "Tiling scheme must have valid tiling information",
|
|
61
|
+
details: ["方法一:先在 Map 组件上加载一个 TileLayer 类型的地图服务图层,从而获取到这个图层的 spatialReference,fullExtent 和 tileInfo 属性值", "方法二:直接对这个" + ` ${this.declaredClass} ` + "类型的图层的 spatialReference,fullExtent 和 tileInfo 属性进行赋值"]
|
|
62
|
+
},
|
|
63
|
+
this.url = e[0]?.url;
|
|
64
|
+
if (this.url) {
|
|
65
|
+
this._coreLayer = new Z({
|
|
66
|
+
"url": this.url
|
|
67
|
+
});
|
|
68
|
+
this._coreLayer.load();
|
|
69
|
+
} else {
|
|
70
|
+
this._coreLayer = new Z;
|
|
71
|
+
}
|
|
72
|
+
e[0] && Object.keys(e[0]).forEach(key=>{
|
|
73
|
+
this._coreLayer[key] = e[0][key];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
normalizeCtorArgs(e, r) {
|
|
77
|
+
return "string" == typeof e ? {
|
|
78
|
+
url: e,
|
|
79
|
+
...r
|
|
80
|
+
} : e
|
|
81
|
+
}
|
|
82
|
+
load(e) {
|
|
83
|
+
const r = null != e ? e.signal : null;
|
|
84
|
+
this.addResolvingPromise(this.loadFromPortal({
|
|
85
|
+
supportedTypes: ["Map Service"]
|
|
86
|
+
}, e).catch(o).then((()=>this._fetchService(r))));
|
|
87
|
+
|
|
88
|
+
if (!this._coreLayer.url) {
|
|
89
|
+
this._coreLayer.url = this.url;
|
|
90
|
+
this._coreLayer.load();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Q.whenOnce(()=>this.parent.allLayers.find((_layer)=>{
|
|
94
|
+
const preconditionsReady = (_layer.type != "base-tile" && _layer.loaded == true);
|
|
95
|
+
preconditionsReady && (this.firstLayer = _layer);
|
|
96
|
+
return preconditionsReady;
|
|
97
|
+
}
|
|
98
|
+
)).then(()=>{
|
|
99
|
+
try {
|
|
100
|
+
if (!this.firstLayer?.spatialReference || !this.firstLayer?.fullExtent || !this.firstLayer?.tileInfo) {
|
|
101
|
+
this._throwMapLoadError();
|
|
102
|
+
} else {
|
|
103
|
+
this.spatialReference = this.firstLayer.spatialReference;
|
|
104
|
+
this.fullExtent = this.firstLayer.fullExtent;
|
|
105
|
+
this.tileInfo = this.firstLayer.tileInfo;
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
this._showMapLoadError(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
Q.whenOnce(()=>this._coreLayer.loaded).then(()=>{
|
|
113
|
+
this.sublayers = this._coreLayer.sublayers;
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
return Promise.resolve(this)
|
|
117
|
+
}
|
|
118
|
+
get attributionDataUrl() {
|
|
119
|
+
const e = this.parsedUrl?.path.toLowerCase();
|
|
120
|
+
return e ? this._getDefaultAttribution(this._getMapName(e)) : null
|
|
121
|
+
}
|
|
122
|
+
get hasAttributionData() {
|
|
123
|
+
return super.hasAttributionData
|
|
124
|
+
}
|
|
125
|
+
readSpatialReference(e, r) {
|
|
126
|
+
return (e = e || r.tileInfo?.spatialReference) && d.fromJSON(e)
|
|
127
|
+
}
|
|
128
|
+
writeSublayers(e, r, t, s) {
|
|
129
|
+
if (!this.loaded || !e)
|
|
130
|
+
return;
|
|
131
|
+
const i = e.slice().reverse().flatten( ({sublayers: e}) => e && e.toArray().reverse()).toArray()
|
|
132
|
+
, o = []
|
|
133
|
+
, a = {
|
|
134
|
+
writeSublayerStructure: !1,
|
|
135
|
+
...s
|
|
136
|
+
};
|
|
137
|
+
i.forEach(e => {
|
|
138
|
+
const r = e.write({}, a);
|
|
139
|
+
o.push(r)
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
o.some(e => Object.keys(e).length > 1) && (r.layers = o)
|
|
143
|
+
}
|
|
144
|
+
get tileServers() {
|
|
145
|
+
return this._getDefaultTileServers(this.parsedUrl?.path)
|
|
146
|
+
}
|
|
147
|
+
castTileServers(e) {
|
|
148
|
+
return Array.isArray(e) ? e.map(e => a(e).path) : null
|
|
149
|
+
}
|
|
150
|
+
fetchTile(e, r, t, i={}) {
|
|
151
|
+
return this.getTileImage(e, r, t, i)
|
|
152
|
+
}
|
|
153
|
+
async fetchImageBitmapTile(e, r, t, i={}) {
|
|
154
|
+
const {signal: s} = i
|
|
155
|
+
, o = await this.getTileImage(e, r, t, i);
|
|
156
|
+
return x(o, e, r, t, s)
|
|
157
|
+
}
|
|
158
|
+
getTileImage(e, r, t, i={}) {
|
|
159
|
+
const s = this.tileInfo.origin.x + t * this.tileInfo.lods[e].resolution * this.tileInfo.size[0]
|
|
160
|
+
, o = this.tileInfo.origin.y - r * this.tileInfo.lods[e].resolution * this.tileInfo.size[1]
|
|
161
|
+
, a = this.tileInfo.origin.x + (t + 1) * this.tileInfo.lods[e].resolution * this.tileInfo.size[0]
|
|
162
|
+
, l = this.tileInfo.origin.y - (r + 1) * this.tileInfo.lods[e].resolution * this.tileInfo.size[1]
|
|
163
|
+
, n = new Y({
|
|
164
|
+
xmin: s,
|
|
165
|
+
ymin: l,
|
|
166
|
+
xmax: a,
|
|
167
|
+
ymax: o,
|
|
168
|
+
spatialReference: this.spatialReference
|
|
169
|
+
});
|
|
170
|
+
return this._coreLayer.fetchImage(n, this.tileInfo.size[0], this.tileInfo.size[1], i)
|
|
171
|
+
}
|
|
172
|
+
getTileUrl(e, r, t) {
|
|
173
|
+
const s = !this.capabilities.operations.supportsTileMap && this.supportsBlankTile
|
|
174
|
+
, i = l({
|
|
175
|
+
...this.parsedUrl?.query,
|
|
176
|
+
blankTile: !s && null,
|
|
177
|
+
...this.customParameters,
|
|
178
|
+
token: this.apiKey
|
|
179
|
+
})
|
|
180
|
+
, o = this.tileServers;
|
|
181
|
+
return `${o && o.length ? o[r % o.length] : this.parsedUrl?.path}/tile/${e}/${r}/${t}${i ? "?" + i : ""}`
|
|
182
|
+
}
|
|
183
|
+
loadAll() {
|
|
184
|
+
return s(this, e => {
|
|
185
|
+
e(this.allSublayers)
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
_fetchService(e) {
|
|
190
|
+
return new Promise( (s, i) => {
|
|
191
|
+
if (this.sourceJSON) {
|
|
192
|
+
if (null != this.sourceJSON.bandCount && null != this.sourceJSON.pixelSizeX)
|
|
193
|
+
throw new t("tile-layer:unsupported-url","use ImageryTileLayer to open a tiled image service");
|
|
194
|
+
return void s({
|
|
195
|
+
data: this.sourceJSON
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
if (!this.parsedUrl)
|
|
199
|
+
throw new t("tile-layer:undefined-url","layer's url is not defined");
|
|
200
|
+
const o = R(this.parsedUrl.path);
|
|
201
|
+
if (null != o && "ImageServer" === o.serverType)
|
|
202
|
+
throw new t("tile-layer:unsupported-url","use ImageryTileLayer to open a tiled image service");
|
|
203
|
+
r(this.parsedUrl.path, {
|
|
204
|
+
query: {
|
|
205
|
+
f: "json",
|
|
206
|
+
...this.parsedUrl.query,
|
|
207
|
+
...this.customParameters,
|
|
208
|
+
token: this.apiKey
|
|
209
|
+
},
|
|
210
|
+
responseType: "json",
|
|
211
|
+
signal: e
|
|
212
|
+
}).then(s, i)
|
|
213
|
+
}
|
|
214
|
+
).then(r => {
|
|
215
|
+
let t = this.url;
|
|
216
|
+
if (r.ssl && (t = this.url = t.replace(/^http:/i, "https:")),
|
|
217
|
+
this.sourceJSON = r.data,
|
|
218
|
+
this.read(r.data, {
|
|
219
|
+
origin: "service",
|
|
220
|
+
url: this.parsedUrl
|
|
221
|
+
}),
|
|
222
|
+
10.1 === this.version && !A(t))
|
|
223
|
+
return this._fetchServerVersion(t, e).then(e => {
|
|
224
|
+
this.read({
|
|
225
|
+
currentVersion: e
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
).catch( () => {}
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
_fetchServerVersion(e, s) {
|
|
234
|
+
if (!U(e))
|
|
235
|
+
return Promise.reject();
|
|
236
|
+
const i = e.replace(/(.*\/rest)\/.*/i, "$1") + "/info";
|
|
237
|
+
return r(i, {
|
|
238
|
+
query: {
|
|
239
|
+
f: "json",
|
|
240
|
+
...this.customParameters,
|
|
241
|
+
token: this.apiKey
|
|
242
|
+
},
|
|
243
|
+
responseType: "json",
|
|
244
|
+
signal: s
|
|
245
|
+
}).then(e => {
|
|
246
|
+
if (e.data?.currentVersion)
|
|
247
|
+
return e.data.currentVersion;
|
|
248
|
+
throw new t("tile-layer:version-not-available","Server did not provide a version")
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
_getMapName(e) {
|
|
253
|
+
return void 0
|
|
254
|
+
}
|
|
255
|
+
_getDefaultAttribution(e) {
|
|
256
|
+
return null
|
|
257
|
+
}
|
|
258
|
+
_getDefaultTileServers(e) {
|
|
259
|
+
return []
|
|
260
|
+
}
|
|
261
|
+
get hasOverriddenFetchTile() {
|
|
262
|
+
return !this.fetchTile[D]
|
|
263
|
+
}
|
|
264
|
+
_throwMapLoadError() {
|
|
265
|
+
throw new t(this.__init_error_info.name,this.__init_error_info.message,this.__init_error_info.details);
|
|
266
|
+
}
|
|
267
|
+
_showMapLoadError(error) {
|
|
268
|
+
console.error(`[${this.declaredClass}] ` + this.__init_error_info.title, error);
|
|
269
|
+
}
|
|
270
|
+
findSublayerById(id) {
|
|
271
|
+
return this._coreLayer?.findSublayerById(id);
|
|
272
|
+
}
|
|
273
|
+
createExportImageParameters(e, r, t, o) {
|
|
274
|
+
return this._coreLayer?.createExportImageParameters(e, r, t, o);
|
|
275
|
+
}
|
|
276
|
+
findSublayerByTitle(t) {
|
|
277
|
+
return this._coreLayer?.allSublayers.items.find((l=>l.title === t));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
;
|
|
281
|
+
e([p({
|
|
282
|
+
readOnly: !0
|
|
283
|
+
})], C.prototype, "attributionDataUrl", null),
|
|
284
|
+
e([p({
|
|
285
|
+
type: ["show", "hide", "hide-children"]
|
|
286
|
+
})], C.prototype, "listMode", void 0),
|
|
287
|
+
e([p({
|
|
288
|
+
json: {
|
|
289
|
+
read: !0,
|
|
290
|
+
write: !0
|
|
291
|
+
}
|
|
292
|
+
})], C.prototype, "blendMode", void 0),
|
|
293
|
+
e([p()], C.prototype, "elevationInfo", void 0),
|
|
294
|
+
e([p({
|
|
295
|
+
type: Boolean,
|
|
296
|
+
json: {
|
|
297
|
+
read: !1,
|
|
298
|
+
write: {
|
|
299
|
+
enabled: !0,
|
|
300
|
+
overridePolicy: () => ({
|
|
301
|
+
enabled: !1
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
})], C.prototype, "isReference", void 0),
|
|
306
|
+
e([p({
|
|
307
|
+
readOnly: !0,
|
|
308
|
+
type: ["ArcGISMapServiceTileLayer"]
|
|
309
|
+
})], C.prototype, "operationalLayerType", void 0),
|
|
310
|
+
e([p({
|
|
311
|
+
type: Boolean
|
|
312
|
+
})], C.prototype, "resampling", void 0),
|
|
313
|
+
e([p()], C.prototype, "sourceJSON", void 0),
|
|
314
|
+
e([p({
|
|
315
|
+
type: d
|
|
316
|
+
})], C.prototype, "spatialReference", void 0),
|
|
317
|
+
e([u("spatialReference", ["spatialReference", "tileInfo"])], C.prototype, "readSpatialReference", null),
|
|
318
|
+
e([p({
|
|
319
|
+
type: String,
|
|
320
|
+
json: {
|
|
321
|
+
origins: {
|
|
322
|
+
"web-scene": {
|
|
323
|
+
read: !0,
|
|
324
|
+
write: !0
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
read: !1
|
|
328
|
+
}
|
|
329
|
+
})], C.prototype, "path", void 0),
|
|
330
|
+
e([p()], C.prototype, "sublayers", void 0),
|
|
331
|
+
e([h("sublayers", {
|
|
332
|
+
layers: {
|
|
333
|
+
type: [I]
|
|
334
|
+
}
|
|
335
|
+
})], C.prototype, "writeSublayers", null),
|
|
336
|
+
e([p({
|
|
337
|
+
json: {
|
|
338
|
+
read: !1,
|
|
339
|
+
write: !1
|
|
340
|
+
}
|
|
341
|
+
})], C.prototype, "popupEnabled", void 0),
|
|
342
|
+
e([p()], C.prototype, "tileServers", null),
|
|
343
|
+
e([c("tileServers")], C.prototype, "castTileServers", null),
|
|
344
|
+
e([p({
|
|
345
|
+
readOnly: !0,
|
|
346
|
+
json: {
|
|
347
|
+
read: !1
|
|
348
|
+
}
|
|
349
|
+
})], C.prototype, "type", void 0),
|
|
350
|
+
e([p(P)], C.prototype, "url", void 0),
|
|
351
|
+
C = W = e([m("geoscene.layers.MapImageTileLayer")], C);
|
|
352
|
+
const D = Symbol("default-fetch-tile");
|
|
353
|
+
C.prototype.fetchTile[D] = !1;
|
|
354
|
+
const N = C;
|
|
355
|
+
export {N as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import r from"../../core/Collection.js";import s from"../../core/CollectionFlattener.js";import t from"../../core/Error.js";import o from"../../core/Logger.js";import{watch as a,sync as l}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{getProperties as n}from"../../core/accessorSupport/utils.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{nameToId as y,idToName as c}from"../../core/accessorSupport/PropertyOrigin.js";import b from"../support/Sublayer.js";import{isSublayerOverhaul as d}from"../support/sublayerUtils.js";function p(e,r){const s=[],t={};return e?(e.forEach(e=>{const o=new b;if(o.read(e,r),t[o.id]=o,null!=e.parentLayerId&&-1!==e.parentLayerId){const r=t[e.parentLayerId];r.sublayers||(r.sublayers=[]),r.sublayers.unshift(o)}else s.unshift(o)}),s):s}const h=r.ofType(b);function f(e,r){e&&e.forEach(e=>{r(e),e.sublayers&&e.sublayers.length&&f(e.sublayers,r)})}const m=m=>{const S=m;let v=class extends S{constructor(...e){super(...e),this.allSublayers=new s({getCollections:()=>[this.sublayers],getChildrenFunction:e=>e.sublayers}),this.sublayersSourceJSON={2:{},3:{},4:{},5:{},6:{}},this.subtables=null,this.addHandles([a(()=>this.sublayers,(e,r)=>this._handleSublayersChange(e,r),l),a(()=>this.subtables,(e,r)=>this._handleSublayersChange(e,r),l)])}destroy(){this.allSublayers.destroy()}readSublayers(e,r){if(!r||!e)return;const{sublayersSourceJSON:s}=this,t=y(r.origin);if(t<2)return;if(s[t]={context:r,visibleLayers:e.visibleLayers||s[t].visibleLayers,layers:e.layers||s[t].layers},t>2)return;this._set("serviceSublayers",this.createSublayersForOrigin("service").sublayers);const{sublayers:o,origin:a}=this.createSublayersForOrigin("web-document"),l=n(this);l.setDefaultOrigin(a),this._set("sublayers",new h(o)),l.setDefaultOrigin("user")}findSublayerById(e){return this.allSublayers.find(r=>r.id===e)}createServiceSublayers(){return this.createSublayersForOrigin("service").sublayers}createSublayersForOrigin(e){let r;const s=y("web-document"===e?"web-map":e);let t=2,o=this.sublayersSourceJSON[2].layers,a=this.sublayersSourceJSON[2].context,l=null;const i=[3,4,5].filter(e=>e<=s);for(const y of i){const e=this.sublayersSourceJSON[y];d(e.layers)&&(t=y,o=e.layers,a=e.context,e.visibleLayers&&(l={visibleLayers:e.visibleLayers,context:e.context}))}const n=[3,4,5].filter(e=>e>t&&e<=s);let u=null;for(const y of n){const{layers:e,visibleLayers:s,context:t}=this.sublayersSourceJSON[y];e&&(u={layers:e,context:t},r??=y),s&&(l={visibleLayers:s,context:t})}const b=p(o,a),m=new Map,S=new Set;if(u)for(const y of u.layers)m.set(y.id,y);if(l?.visibleLayers)for(const y of l.visibleLayers)S.add(y);return f(b,e=>{u&&e.read(m.get(e.id),u.context),l&&e.read({defaultVisibility:S.has(e.id)},l.context)}),{origin:c(t),originWithPartialOverrides:r?c(r):null,sublayers:new h({items:b})}}read(e,r){super.read(e,r),this.readSublayers(e,r)}_handleSublayersChange(e,r){r&&(r.forEach(e=>{e.parent=null,e.layer=null}),this.removeHandles("sublayers-owner")),e&&(e.forEach(e=>{e.parent=this,e.layer=this}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this,e.layer=this}),e.on("after-remove",({item:e})=>{e.parent=null,e.layer=null})],"sublayers-owner"),"tile"===this.type&&this.addHandles(e.on("before-changes",e=>{o.getLogger("geoscene.layers.TileLayer").error(new t("tilelayer:sublayers-non-modifiable","Sublayer can't be added, moved, or removed from the layer's sublayers",{layer:this})),e.preventDefault()}),"sublayers-owner"))}};return e([i({readOnly:!0})],v.prototype,"allSublayers",void 0),e([i({readOnly:!0,type:r.ofType(b)})],v.prototype,"serviceSublayers",void 0),e([i({value:null,type:h,json:{read:!1,write:{allowNull:!0,ignoreOrigin:!0}}})],v.prototype,"sublayers",void 0),e([i({readOnly:!0})],v.prototype,"sublayersSourceJSON",void 0),e([i({type:h,json:{read:{source:"tables"}}})],v.prototype,"subtables",void 0),v=e([u("geoscene.layers.mixins.SublayersOwner")],v),v};export{m as SublayersOwner,f as forEachSublayer};
|
|
5
|
+
import{__decorate as e}from"tslib";import r from"../../core/Collection.js";import s from"../../core/CollectionFlattener.js";import t from"../../core/Error.js";import o from"../../core/Logger.js";import{watch as a,sync as l}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{getProperties as n}from"../../core/accessorSupport/utils.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{nameToId as y,idToName as c}from"../../core/accessorSupport/PropertyOrigin.js";import b from"../support/Sublayer.js";import{isSublayerOverhaul as d}from"../support/sublayerUtils.js";function p(e,r){const s=[],t={};return e?(e.forEach(e=>{const o=new b;if(o.read(e,r),t[o.id]=o,null!=e.parentLayerId&&-1!==e.parentLayerId){const r=t[e.parentLayerId];r.sublayers||(r.sublayers=[]),r.sublayers.unshift(o)}else s.unshift(o)}),s):s}const h=r.ofType(b);function f(e,r){e&&e.forEach(e=>{r(e),e.sublayers&&e.sublayers.length&&f(e.sublayers,r)})}const m=m=>{const S=m;let v=class extends S{constructor(...e){super(...e),this.allSublayers=new s({getCollections:()=>[this.sublayers],getChildrenFunction:e=>e.sublayers}),this.sublayersSourceJSON={2:{},3:{},4:{},5:{},6:{}},this.subtables=null,this.addHandles([a(()=>this.sublayers,(e,r)=>this._handleSublayersChange(e,r),l),a(()=>this.subtables,(e,r)=>this._handleSublayersChange(e,r),l)])}destroy(){this.allSublayers.destroy()}readSublayers(e,r){if(!r||!e)return;const{sublayersSourceJSON:s}=this,t=y(r.origin);if(t<2)return;if(s[t]={context:r,visibleLayers:e.visibleLayers||s[t].visibleLayers,layers:e.layers||s[t].layers},t>2)return;this._set("serviceSublayers",this.createSublayersForOrigin("service").sublayers);const{sublayers:o,origin:a}=this.createSublayersForOrigin("web-document"),l=n(this);l.setDefaultOrigin(a),this._set("sublayers",new h(o)),l.setDefaultOrigin("user")}findSublayerById(e){return this.allSublayers.find(r=>r.id===e)}createServiceSublayers(){return this.createSublayersForOrigin("service").sublayers}createSublayersForOrigin(e){let r;const s=y("web-document"===e?"web-map":e);let t=2,o=this.sublayersSourceJSON[2].layers,a=this.sublayersSourceJSON[2].context,l=null;const i=[3,4,5].filter(e=>e<=s);for(const y of i){const e=this.sublayersSourceJSON[y];d(e.layers)&&(t=y,o=e.layers,a=e.context,e.visibleLayers&&(l={visibleLayers:e.visibleLayers,context:e.context}))}const n=[3,4,5].filter(e=>e>t&&e<=s);let u=null;for(const y of n){const{layers:e,visibleLayers:s,context:t}=this.sublayersSourceJSON[y];e&&(u={layers:e,context:t},r??=y),s&&(l={visibleLayers:s,context:t})}const b=p(o,a),m=new Map,S=new Set;if(u)for(const y of u.layers)m.set(y.id,y);if(l?.visibleLayers)for(const y of l.visibleLayers)S.add(y);return f(b,e=>{u&&e.read(m.get(e.id),u.context),l&&e.read({defaultVisibility:S.has(e.id)},l.context)}),{origin:c(t),originWithPartialOverrides:r?c(r):null,sublayers:new h({items:b})}}read(e,r){super.read(e,r),e.tileInfo && (this.tileInfo = e.tileInfo),this.readSublayers(e,r)}_handleSublayersChange(e,r){r&&(r.forEach(e=>{e.parent=null,e.layer=null}),this.removeHandles("sublayers-owner")),e&&(e.forEach(e=>{e.parent=this,e.layer=this}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this,e.layer=this}),e.on("after-remove",({item:e})=>{e.parent=null,e.layer=null})],"sublayers-owner"),"tile"===this.type&&this.addHandles(e.on("before-changes",e=>{o.getLogger("geoscene.layers.TileLayer").error(new t("tilelayer:sublayers-non-modifiable","Sublayer can't be added, moved, or removed from the layer's sublayers",{layer:this})),e.preventDefault()}),"sublayers-owner"))}};return e([i({readOnly:!0})],v.prototype,"allSublayers",void 0),e([i({readOnly:!0,type:r.ofType(b)})],v.prototype,"serviceSublayers",void 0),e([i({value:null,type:h,json:{read:!1,write:{allowNull:!0,ignoreOrigin:!0}}})],v.prototype,"sublayers",void 0),e([i({readOnly:!0})],v.prototype,"sublayersSourceJSON",void 0),e([i({type:h,json:{read:{source:"tables"}}})],v.prototype,"subtables",void 0),v=e([u("geoscene.layers.mixins.SublayersOwner")],v),v};export{m as SublayersOwner,f as forEachSublayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e={ArcGISAnnotationLayer:!0,ArcGISDimensionLayer:!0,ArcGISFeatureLayer:!0,ArcGISImageServiceLayer:!0,ArcGISImageServiceVectorLayer:!0,ArcGISMapServiceLayer:!0,ArcGISStreamLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,ArcGISVideoLayer:!0,BingMapsAerial:!0,BingMapsHybrid:!0,BingMapsRoad:!0,CatalogLayer:!0,CSV:!0,GeoJSON:!0,GeoRSS:!0,GroupLayer:!0,KML:!0,KnowledgeGraphLayer:!0,MediaLayer:!0,OGCFeatureLayer:!0,OrientedImageryLayer:!0,ParquetLayer:!0,SubtypeGroupLayer:!0,VectorTileLayer:!0,WCS:!0,WFS:!0,WMS:!0,WebTiledLayer:!0},r={ArcGISImageServiceLayer:!0,ArcGISImageServiceVectorLayer:!0,ArcGISMapServiceLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,BingMapsAerial:!0,BingMapsHybrid:!0,BingMapsRoad:!0,OpenStreetMap:!0,VectorTileLayer:!0,WCS:!0,WMS:!0,WebTiledLayer:!0},a={ArcGISFeatureLayer:!0,SubtypeGroupTable:!0},S={"web-scene/operational-layers":{ArcGISDimensionLayer:!0,ArcGISFeatureLayer:!0,ArcGISImageServiceLayer:!0,ArcGISMapServiceLayer:!0,ArcGISSceneServiceLayer:!0,ArcGISTiledElevationServiceLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,BuildingSceneLayer:!0,CatalogLayer:!0,CSV:!0,GaussianSplatLayer:!0,GeoJSON:!0,GroupLayer:!0,IntegratedMesh3DTilesLayer:!0,Object3DTilesLayer:!0,IntegratedMeshLayer:!0,KML:!0,LineOfSightLayer:!0,MediaLayer:!0,OGCFeatureLayer:!0,OrientedImageryLayer:!0,PointCloudLayer:!0,RasterDataLayer:!0,VectorTileLayer:!0,ViewshedLayer:!0,Voxel:!0,WCS:!0,WFS:!0,WMS:!0,WebTiledLayer:!0},"web-scene/basemap-base-layers":{ArcGISImageServiceLayer:!0,ArcGISMapServiceLayer:!0,ArcGISSceneServiceLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,OpenStreetMap:!0,VectorTileLayer:!0,WCS:!0,WMS:!0,WebTiledLayer:!0},"web-scene/basemap-ground-layers":{IntegratedMesh3DTilesLayer:!0},"web-scene/ground":{ArcGISTiledElevationServiceLayer:!0,RasterDataElevationLayer:!0},"web-scene/tables":{ArcGISFeatureLayer:!0},"web-map/operational-layers":e,"web-map/basemap-base-layers":r,"web-map/tables":a,"link-chart/operational-layers":{...e,LinkChartLayer:!0},"link-chart/basemap-base-layers":r,"link-chart/tables":a,"portal-item/operational-layers":{ArcGISFeatureLayer:!0,ArcGISImageServiceLayer:!0,ArcGISMapServiceLayer:!0,ArcGISSceneServiceLayer:!0,ArcGISStreamLayer:!0,ArcGISTiledImageServiceLayer:!0,BuildingSceneLayer:!0,IntegratedMesh3DTilesLayer:!0,IntegratedMeshLayer:!0,MediaLayer:!0,OrientedImageryLayer:!0,PointCloudLayer:!0,SubtypeGroupLayer:!0,WCS:!0},"portal-item/tables":{ArcGISFeatureLayer:!0,SubtypeGroupTable:!0}};export{S as supportedTypes};
|
|
5
|
+
const e={ArcGISAnnotationLayer:!0,ArcGISDimensionLayer:!0,ArcGISFeatureLayer:!0,ArcGISImageServiceLayer:!0,ArcGISImageServiceVectorLayer:!0,ArcGISMapServiceLayer:!0,ArcGISMapServiceTileLayer:!0,ArcGISStreamLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,ArcGISVideoLayer:!0,BingMapsAerial:!0,BingMapsHybrid:!0,BingMapsRoad:!0,CatalogLayer:!0,CSV:!0,GeoJSON:!0,GeoRSS:!0,GroupLayer:!0,KML:!0,KnowledgeGraphLayer:!0,MediaLayer:!0,OGCFeatureLayer:!0,OrientedImageryLayer:!0,ParquetLayer:!0,SubtypeGroupLayer:!0,VectorTileLayer:!0,WCS:!0,WFS:!0,WMS:!0,WebTiledLayer:!0},r={ArcGISImageServiceLayer:!0,ArcGISImageServiceVectorLayer:!0,ArcGISMapServiceLayer:!0,ArcGISMapServiceTileLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,BingMapsAerial:!0,BingMapsHybrid:!0,BingMapsRoad:!0,OpenStreetMap:!0,VectorTileLayer:!0,WCS:!0,WMS:!0,WebTiledLayer:!0},a={ArcGISFeatureLayer:!0,SubtypeGroupTable:!0},S={"web-scene/operational-layers":{ArcGISDimensionLayer:!0,ArcGISFeatureLayer:!0,ArcGISImageServiceLayer:!0,ArcGISMapServiceLayer:!0,ArcGISMapServiceTileLayer:!0,ArcGISSceneServiceLayer:!0,ArcGISTiledElevationServiceLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,BuildingSceneLayer:!0,CatalogLayer:!0,CSV:!0,GaussianSplatLayer:!0,GeoJSON:!0,GroupLayer:!0,IntegratedMesh3DTilesLayer:!0,Object3DTilesLayer:!0,IntegratedMeshLayer:!0,KML:!0,LineOfSightLayer:!0,MediaLayer:!0,OGCFeatureLayer:!0,OrientedImageryLayer:!0,PointCloudLayer:!0,RasterDataLayer:!0,VectorTileLayer:!0,ViewshedLayer:!0,Voxel:!0,WCS:!0,WFS:!0,WMS:!0,WebTiledLayer:!0},"web-scene/basemap-base-layers":{ArcGISImageServiceLayer:!0,ArcGISMapServiceLayer:!0,ArcGISMapServiceTileLayer:!0,ArcGISSceneServiceLayer:!0,ArcGISTiledImageServiceLayer:!0,ArcGISTiledMapServiceLayer:!0,OpenStreetMap:!0,VectorTileLayer:!0,WCS:!0,WMS:!0,WebTiledLayer:!0},"web-scene/basemap-ground-layers":{IntegratedMesh3DTilesLayer:!0},"web-scene/ground":{ArcGISTiledElevationServiceLayer:!0,RasterDataElevationLayer:!0},"web-scene/tables":{ArcGISFeatureLayer:!0},"web-map/operational-layers":e,"web-map/basemap-base-layers":r,"web-map/tables":a,"link-chart/operational-layers":{...e,LinkChartLayer:!0},"link-chart/basemap-base-layers":r,"link-chart/tables":a,"portal-item/operational-layers":{ArcGISFeatureLayer:!0,ArcGISImageServiceLayer:!0,ArcGISMapServiceLayer:!0,ArcGISMapServiceTileLayer:!0,ArcGISSceneServiceLayer:!0,ArcGISStreamLayer:!0,ArcGISTiledImageServiceLayer:!0,BuildingSceneLayer:!0,IntegratedMesh3DTilesLayer:!0,IntegratedMeshLayer:!0,MediaLayer:!0,OrientedImageryLayer:!0,PointCloudLayer:!0,SubtypeGroupLayer:!0,WCS:!0},"portal-item/tables":{ArcGISFeatureLayer:!0,SubtypeGroupTable:!0}};export{S as supportedTypes};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
-
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
|
-
*/
|
|
5
|
-
import{clampFloat32 as e}from"../../core/mathUtils.js";var t={};t.defaultNoDataValue=e(-1/0),t.decode=function(s,r){var o=(r=r||{}).encodedMaskData||null===r.encodedMaskData,f=l(s,r.inputOffset||0,o),u=null!=r.noDataValue?e(r.noDataValue):t.defaultNoDataValue,m=i(f,r.pixelType||Float32Array,r.encodedMaskData,u,r.returnMask),d={width:f.width,height:f.height,pixelData:m.resultPixels,minValue:f.pixels.minValue,maxValue:f.pixels.maxValue,noDataValue:u};return m.resultMask&&(d.maskData=m.resultMask),r.returnEncodedMask&&f.mask&&(d.encodedMaskData=f.mask.bitset?f.mask.bitset:null),r.returnFileInfo&&(d.fileInfo=n(f,u),r.computeUsedBitDepths&&(d.fileInfo.bitDepths=a(f))),d};var i=function(e,t,i,n,a){var l,r,o=0,f=e.pixels.numBlocksX,u=e.pixels.numBlocksY,m=Math.floor(e.width/f),d=Math.floor(e.height/u),c=2*e.maxZError;i=i||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),a&&i&&(r=new Uint8Array(e.width*e.height));for(var g,h,k=new Float32Array(m*d),x=0;x<=u;x++){var p=x!==u?d:e.height%u;if(0!==p)for(var w=0;w<=f;w++){var y=w!==f?m:e.width%f;if(0!==y){var V,B,v,U,D=x*e.width*d+w*m,M=e.width-y,b=e.pixels.blocks[o];if(b.encoding<2?(0===b.encoding?V=b.rawData:(s(b.stuffedData,b.bitsPerPixel,b.numValidPixels,b.offset,c,k,e.pixels.maxValue),V=k),B=0):v=2===b.encoding?0:b.offset,i)for(h=0;h<p;h++){for(7&D&&(U=i[D>>3],U<<=7&D),g=0;g<y;g++)7&D||(U=i[D>>3]),128&U?(r&&(r[D]=1),l[D++]=b.encoding<2?V[B++]:v):(r&&(r[D]=0),l[D++]=n),U<<=1;D+=M}else if(b.encoding<2)for(h=0;h<p;h++){for(g=0;g<y;g++)l[D++]=V[B++];D+=M}else for(h=0;h<p;h++)if(l.fill)l.fill(v,D,D+y),D+=y+M;else{for(g=0;g<y;g++)l[D++]=v;D+=M}if(1===b.encoding&&B!==b.numValidPixels)throw"Block and Mask do not match";o++}}}return{resultPixels:l,resultMask:r}},n=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},a=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},n=0;n<t;n++){var a=e.pixels.blocks[n];0===a.encoding?i.float32=!0:1===a.encoding?i[a.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},l=function(e,t,i){var n={},a=new Uint8Array(e,t,10);if(n.fileIdentifierString=String.fromCharCode.apply(null,a),"CntZImage"!=n.fileIdentifierString.trim())throw"Unexpected file identifier string: "+n.fileIdentifierString;t+=10;var l=new DataView(e,t,24);if(n.fileVersion=l.getInt32(0,!0),n.imageType=l.getInt32(4,!0),n.height=l.getUint32(8,!0),n.width=l.getUint32(12,!0),n.maxZError=l.getFloat64(16,!0),t+=24,!i)if(l=new DataView(e,t,16),n.mask={},n.mask.numBlocksY=l.getUint32(0,!0),n.mask.numBlocksX=l.getUint32(4,!0),n.mask.numBytes=l.getUint32(8,!0),n.mask.maxValue=l.getFloat32(12,!0),t+=16,n.mask.numBytes>0){var s=new Uint8Array(Math.ceil(n.width*n.height/8)),r=(l=new DataView(e,t,n.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(r>0)for(;r--;)s[f++]=l.getUint8(o++);else{var u=l.getUint8(o++);for(r=-r;r--;)s[f++]=u}r=l.getInt16(o,!0),o+=2}while(o<n.mask.numBytes);if(-32768!==r||f<s.length)throw"Unexpected end of mask RLE encoding";n.mask.bitset=s,t+=n.mask.numBytes}else if(0===(n.mask.numBytes|n.mask.numBlocksY|n.mask.maxValue)){s=new Uint8Array(Math.ceil(n.width*n.height/8));n.mask.bitset=s}l=new DataView(e,t,16),n.pixels={},n.pixels.numBlocksY=l.getUint32(0,!0),n.pixels.numBlocksX=l.getUint32(4,!0),n.pixels.numBytes=l.getUint32(8,!0),n.pixels.maxValue=l.getFloat32(12,!0),t+=16;var m=n.pixels.numBlocksX,d=n.pixels.numBlocksY,c=m+(n.width%m>0?1:0),g=d+(n.height%d>0?1:0);n.pixels.blocks=new Array(c*g);for(var h=1e9,k=0,x=0;x<g;x++)for(var p=0;p<c;p++){var w=0,y=e.byteLength-t;l=new DataView(e,t,Math.min(10,y));var V={};n.pixels.blocks[k++]=V;var B=l.getUint8(0);if(w++,V.encoding=63&B,V.encoding>3)throw"Invalid block encoding ("+V.encoding+")";if(2!==V.encoding){if(0!==B&&2!==B){if(B>>=6,V.offsetType=B,2===B)V.offset=l.getInt8(1),w++;else if(1===B)V.offset=l.getInt16(1,!0),w+=2;else{if(0!==B)throw"Invalid block offset type";V.offset=l.getFloat32(1,!0),w+=4}if(h=Math.min(V.offset,h),1===V.encoding)if(B=l.getUint8(w),w++,V.bitsPerPixel=63&B,B>>=6,V.numValidPixelsType=B,2===B)V.numValidPixels=l.getUint8(w),w++;else if(1===B)V.numValidPixels=l.getUint16(w,!0),w+=2;else{if(0!==B)throw"Invalid valid pixel count type";V.numValidPixels=l.getUint32(w,!0),w+=4}}var v;if(t+=w,3!=V.encoding)if(0===V.encoding){var U=(n.pixels.numBytes-1)/4;if(U!==Math.floor(U))throw"uncompressed block has invalid length";v=new ArrayBuffer(4*U),new Uint8Array(v).set(new Uint8Array(e,t,4*U));for(var D=new Float32Array(v),M=0;M<D.length;M++)h=Math.min(h,D[M]);V.rawData=D,t+=4*U}else if(1===V.encoding){var b=Math.ceil(V.numValidPixels*V.bitsPerPixel/8),I=Math.ceil(b/4);v=new ArrayBuffer(4*I),new Uint8Array(v).set(new Uint8Array(e,t,b)),V.stuffedData=new Uint32Array(v),t+=b}}else t++,h=Math.min(h,0)}return n.pixels.minValue=h,n.eofOffset=t,n},s=function(e,t,i,n,a,l,s){var r,o,f,u=(1<<t)-1,m=0,d=0,c=Math.ceil((s-n)/a),g=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*g,r=0;r<i;r++){if(0===d&&(f=e[m++],d=32),d>=t)o=f>>>d-t&u,d-=t;else{var h=t-d;o=(f&u)<<h&u,o+=(f=e[m++])>>>(d=32-h)}l[r]=o<c?n+o*a:s}return l};const r=t.decode;class o{_decode(e){const t=r(e.buffer,e.options);return Promise.resolve({result:t,transferList:[t.pixelData.buffer]})}}function f(){return new o}export{f as default};
|
|
1
|
+
import{clampFloat32 as e}from"../../core/mathUtils.js";var t={};t.defaultNoDataValue=e(-1/0),t.decode=async(r,s)=>{if(-1!==String.fromCharCode.apply(null,new Uint8Array(r,s.inputOffset||0,20)).indexOf("PNG")||-1!==String.fromCharCode.apply(null,new Uint8Array(r,s.inputOffset||0,20)).indexOf("WEBP"))d=await decodeTerrainRGB(r,s);else{var o=(s=s||{}).encodedMaskData||null===s.encodedMaskData,f=l(r,s.inputOffset||0,o),u=null!=s.noDataValue?e(s.noDataValue):t.defaultNoDataValue,m=i(f,s.pixelType||Float32Array,s.encodedMaskData,u,s.returnMask),d={width:f.width,height:f.height,pixelData:m.resultPixels,minValue:f.pixels.minValue,maxValue:f.pixels.maxValue,noDataValue:u};m.resultMask&&(d.maskData=m.resultMask),s.returnEncodedMask&&f.mask&&(d.encodedMaskData=f.mask.bitset?f.mask.bitset:null),s.returnFileInfo&&(d.fileInfo=n(f,u),s.computeUsedBitDepths&&(d.fileInfo.bitDepths=a(f)))}return d};var i=function(e,t,i,a,n){var l,r,o=0,f=e.pixels.numBlocksX,u=e.pixels.numBlocksY,m=Math.floor(e.width/f),d=Math.floor(e.height/u),h=2*e.maxZError;i=i||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),n&&i&&(r=new Uint8Array(e.width*e.height));for(var c,g,w=new Float32Array(m*d),x=0;x<=u;x++){var k=x!==u?d:e.height%u;if(0!==k)for(var p=0;p<=f;p++){var y=p!==f?m:e.width%f;if(0!==y){var V,B,v,D,U=x*e.width*d+p*m,M=e.width-y,b=e.pixels.blocks[o];if(b.encoding<2?(0===b.encoding?V=b.rawData:(s(b.stuffedData,b.bitsPerPixel,b.numValidPixels,b.offset,h,w,e.pixels.maxValue),V=w),B=0):v=2===b.encoding?0:b.offset,i)for(g=0;g<k;g++){for(7&U&&(D=i[U>>3],D<<=7&U),c=0;c<y;c++)7&U||(D=i[U>>3]),128&D?(r&&(r[U]=1),l[U++]=b.encoding<2?V[B++]:v):(r&&(r[U]=0),l[U++]=a),D<<=1;U+=M}else if(b.encoding<2)for(g=0;g<k;g++){for(c=0;c<y;c++)l[U++]=V[B++];U+=M}else for(g=0;g<k;g++)if(l.fill)l.fill(v,U,U+y),U+=y+M;else{for(c=0;c<y;c++)l[U++]=v;U+=M}if(1===b.encoding&&B!==b.numValidPixels)throw"Block and Mask do not match";o++}}}return{resultPixels:l,resultMask:r}},n=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},a=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},a=0;a<t;a++){var n=e.pixels.blocks[a];0===n.encoding?i.float32=!0:1===n.encoding?i[n.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},l=function(e,t,i){var a={},n=new Uint8Array(e,t,10);if(a.fileIdentifierString=String.fromCharCode.apply(null,n),"CntZImage"!=a.fileIdentifierString.trim())throw"Unexpected file identifier string: "+a.fileIdentifierString;t+=10;var l=new DataView(e,t,24);if(a.fileVersion=l.getInt32(0,!0),a.imageType=l.getInt32(4,!0),a.height=l.getUint32(8,!0),a.width=l.getUint32(12,!0),a.maxZError=l.getFloat64(16,!0),t+=24,!i)if(l=new DataView(e,t,16),a.mask={},a.mask.numBlocksY=l.getUint32(0,!0),a.mask.numBlocksX=l.getUint32(4,!0),a.mask.numBytes=l.getUint32(8,!0),a.mask.maxValue=l.getFloat32(12,!0),t+=16,a.mask.numBytes>0){var r=new Uint8Array(Math.ceil(a.width*a.height/8)),s=(l=new DataView(e,t,a.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(s>0)for(;s--;)r[f++]=l.getUint8(o++);else{var u=l.getUint8(o++);for(s=-s;s--;)r[f++]=u}s=l.getInt16(o,!0),o+=2}while(o<a.mask.numBytes);if(-32768!==s||f<r.length)throw"Unexpected end of mask RLE encoding";a.mask.bitset=r,t+=a.mask.numBytes}else 0==(a.mask.numBytes|a.mask.numBlocksY|a.mask.maxValue)&&(r=new Uint8Array(Math.ceil(a.width*a.height/8)),a.mask.bitset=r);l=new DataView(e,t,16),a.pixels={},a.pixels.numBlocksY=l.getUint32(0,!0),a.pixels.numBlocksX=l.getUint32(4,!0),a.pixels.numBytes=l.getUint32(8,!0),a.pixels.maxValue=l.getFloat32(12,!0),t+=16;var m=a.pixels.numBlocksX,d=a.pixels.numBlocksY,h=m+(a.width%m>0?1:0),c=d+(a.height%d>0?1:0);a.pixels.blocks=new Array(h*c);for(var g=1e9,w=0,x=0;x<c;x++)for(var k=0;k<h;k++){var p=0,y=e.byteLength-t;l=new DataView(e,t,Math.min(10,y));var V={};a.pixels.blocks[w++]=V;var B=l.getUint8(0);if(p++,V.encoding=63&B,V.encoding>3)throw"Invalid block encoding ("+V.encoding+")";if(2!==V.encoding){if(0!==B&&2!==B){if(B>>=6,V.offsetType=B,2===B)V.offset=l.getInt8(1),p++;else if(1===B)V.offset=l.getInt16(1,!0),p+=2;else{if(0!==B)throw"Invalid block offset type";V.offset=l.getFloat32(1,!0),p+=4}if(g=Math.min(V.offset,g),1===V.encoding)if(B=l.getUint8(p),p++,V.bitsPerPixel=63&B,B>>=6,V.numValidPixelsType=B,2===B)V.numValidPixels=l.getUint8(p),p++;else if(1===B)V.numValidPixels=l.getUint16(p,!0),p+=2;else{if(0!==B)throw"Invalid valid pixel count type";V.numValidPixels=l.getUint32(p,!0),p+=4}}var v;if(t+=p,3!=V.encoding)if(0===V.encoding){var D=(a.pixels.numBytes-1)/4;if(D!==Math.floor(D))throw"uncompressed block has invalid length";v=new ArrayBuffer(4*D),new Uint8Array(v).set(new Uint8Array(e,t,4*D));for(var U=new Float32Array(v),M=0;M<U.length;M++)g=Math.min(g,U[M]);V.rawData=U,t+=4*D}else if(1===V.encoding){var b=Math.ceil(V.numValidPixels*V.bitsPerPixel/8),I=Math.ceil(b/4);v=new ArrayBuffer(4*I),new Uint8Array(v).set(new Uint8Array(e,t,b)),V.stuffedData=new Uint32Array(v),t+=b}}else t++,g=Math.min(g,0)}return a.pixels.minValue=g,a.eofOffset=t,a},s=function(e,t,i,a,n,l,r){var s,o,f,u=(1<<t)-1,m=0,d=0,h=Math.ceil((r-a)/n),c=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*c,s=0;s<i;s++){if(0===d&&(f=e[m++],d=32),d>=t)o=f>>>d-t&u,d-=t;else{var g=t-d;o=(f&u)<<g&u,o+=(f=e[m++])>>>(d=32-g)}l[s]=o<h?a+o*n:r}return l},decodeTerrainRGB=async(e,t)=>{const i=new Blob([e]),a=await createImageBitmap(i),n=new OffscreenCanvas(a.width,a.height),l=n.width=a.width,r=n.height=a.height,s=n.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("无法获取2D上下文");s.drawImage(a,0,0);const o=s.getImageData(0,0,n.width,n.height).data;for(var f=new(t.pixelType||Float32Array)(l*r),u=1/0,m=-1/0,d=0;d<r;d++)for(var h=0;h<l;h++){var c=d*l+h,g=4*c,w=.1*(256*(t=o[g])*256+256*o[g+1]+o[g+2])-1e4;f[c]=w,w<u&&(u=w),w>m&&(m=w)}return u===1/0&&(u=0),m===-1/0&&(m=0),{width:l,height:r,pixelData:f,minValue:u,maxValue:m,noDataValue:t.noDataValue||t.defaultNoDataValue}};const r=t.decode;class o{_decode(e){return r(e.buffer,e.options).then((e=>Promise.resolve({result:e,transferList:[e.pixelData.buffer]})))}}function f(){return new o}export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Collection.js";import has from"../../core/has.js";import{LayerLoadContext as r}from"./LayerLoadContext.js";import{layerLookupMap as a}from"./lazyLayerLoader.js";import y from"../../portal/PortalItem.js";import{isMapNotesLayer as t,isMarkupLayer as i,isRouteLayer as L}from"../../portal/support/featureCollectionUtils.js";import{selectLayerClassPath as n}from"../../portal/support/portalLayers.js";import{loadStyleRenderer as o}from"../../renderers/support/styleUtils.js";async function l(e,r,a){if(!r)return;const y=r.map(e=>f(e,a)),t=await Promise.allSettled(y);for(const i of t)"rejected"===i.status||i.value&&e.add(i.value)}const s={ArcGISDimensionLayer:"DimensionLayer",ArcGISFeatureLayer:"FeatureLayer",ArcGISImageServiceLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISSceneServiceLayer:"SceneLayer",ArcGISTiledElevationServiceLayer:"ElevationLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",BuildingSceneLayer:"BuildingSceneLayer",CatalogLayer:"CatalogLayer",CSV:"CSVLayer",DefaultTileLayer:"TileLayer",GaussianSplatLayer:"GaussianSplatLayer",GeoJSON:"GeoJSONLayer",GroupLayer:"GroupLayer",IntegratedMesh3DTilesLayer:"IntegratedMesh3DTilesLayer",Object3DTilesLayer:"UnsupportedLayer",IntegratedMeshLayer:"IntegratedMeshLayer",KML:"KMLLayer",LineOfSightLayer:"LineOfSightLayer",MediaLayer:"MediaLayer",OGCFeatureLayer:"OGCFeatureLayer",OrientedImageryLayer:"OrientedImageryLayer",PointCloudLayer:"PointCloudLayer",RasterDataLayer:"UnsupportedLayer",VectorTileLayer:"VectorTileLayer",ViewshedLayer:"ViewshedLayer",Voxel:"VoxelLayer",WCS:"WCSLayer",WFS:"WFSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},c={ArcGISTiledElevationServiceLayer:"ElevationLayer",DefaultTileLayer:"ElevationLayer",RasterDataElevationLayer:"UnsupportedLayer"},p={ArcGISFeatureLayer:"FeatureLayer"},S={ArcGISImageServiceLayer:"UnsupportedLayer",ArcGISMapServiceLayer:"UnsupportedLayer",ArcGISSceneServiceLayer:"SceneLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",DefaultTileLayer:"TileLayer",OpenStreetMap:"OpenStreetMapLayer",VectorTileLayer:"VectorTileLayer",WCS:"UnsupportedLayer",WMS:"UnsupportedLayer",WebTiledLayer:"WebTileLayer"},u={IntegratedMesh3DTilesLayer:"IntegratedMesh3DTilesLayer"},d={ArcGISAnnotationLayer:"UnsupportedLayer",ArcGISDimensionLayer:"UnsupportedLayer",ArcGISFeatureLayer:"FeatureLayer",ArcGISImageServiceLayer:"ImageryLayer",ArcGISImageServiceVectorLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISStreamLayer:"StreamLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",ArcGISVideoLayer:"VideoLayer",BingMapsAerial:"BingMapsLayer",BingMapsHybrid:"BingMapsLayer",BingMapsRoad:"BingMapsLayer",CatalogLayer:"CatalogLayer",CSV:"CSVLayer",DefaultTileLayer:"TileLayer",GeoJSON:"GeoJSONLayer",GeoRSS:"GeoRSSLayer",GroupLayer:"GroupLayer",KML:"KMLLayer",KnowledgeGraphLayer:"KnowledgeGraphLayer",MediaLayer:"MediaLayer",OGCFeatureLayer:"OGCFeatureLayer",OrientedImageryLayer:"OrientedImageryLayer",get ParquetLayer(){return has("parquetlayer-persistence-enabled")?"ParquetLayer":"UnsupportedLayer"},SubtypeGroupLayer:"SubtypeGroupLayer",VectorTileLayer:"VectorTileLayer",WCS:"WCSLayer",WFS:"WFSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},I={ArcGISFeatureLayer:"FeatureLayer",SubtypeGroupTable:"SubtypeGroupLayer"},g={ArcGISImageServiceLayer:"ImageryLayer",ArcGISImageServiceVectorLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",BingMapsAerial:"BingMapsLayer",BingMapsHybrid:"BingMapsLayer",BingMapsRoad:"BingMapsLayer",DefaultTileLayer:"TileLayer",OpenStreetMap:"OpenStreetMapLayer",VectorTileLayer:"VectorTileLayer",WCS:"WCSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},m={...d,LinkChartLayer:"LinkChartLayer"},T={...I},G={...g};async function f(e,r){return M(await b(e,r),e,r)}async function M(e,r,a){const y=new e;return y.read(r,a.context),"group"===y.type&&("GroupLayer"===r.layerType?await C(y,r,a):w(r)?h(y,r,a.context):A(r)&&await W(y,r,a.context)),await o(y,a.context),y}async function b(e,o){const l=o.context,s=v(l);let c=e.layerType||e.type;!c&&o?.defaultLayerType&&(c=o.defaultLayerType);const p=s[c];let S=p?a[p]:a.UnknownLayer;if(w(e)){const t=l?.portal;if(e.itemId){const i=new y({id:e.itemId,portal:t});await i.load();const L=(await n(i,new r)).className||"UnknownLayer";S=a[L]}}else"ArcGISFeatureLayer"===c?t(e)||i(e)?S=a.MapNotesLayer:L(e)?S=a.RouteLayer:A(e)&&(S=a.GroupLayer):e.wmtsInfo?.url&&e.wmtsInfo.layerIdentifier?S=a.WMTSLayer:"WFS"===c&&"2.0.0"!==e.wfsInfo?.version&&(S=a.UnsupportedLayer);return S()}function A(e){if("ArcGISFeatureLayer"!==e.layerType||w(e))return!1;return(e.featureCollection?.layers?.length??0)>1}function w(e){return"Feature Collection"===e.type}function v(e){let r;switch(e.origin){case"web-scene":switch(e.layerContainerType){case"basemap-base-layers":r=S;break;case"basemap-ground-layers":r=u;break;case"ground":r=c;break;case"tables":r=p;break;default:r=s}break;case"link-chart":switch(e.layerContainerType){case"basemap-base-layers":r=G;break;case"tables":r=T;break;default:r=m}break;default:switch(e.layerContainerType){case"basemap-base-layers":r=g;break;case"tables":r=I;break;default:r=d}}return r}async function C(r,a,y){const t=new e,i=l(t,Array.isArray(a.layers)?a.layers:[],y);try{try{if(await i,"group"===r.type)return r.layers.addMany(t),r}catch(L){r.destroy();for(const e of t)e.destroy();throw L}}catch(L){throw L}}function h(e,r,a){r.itemId&&(e.portalItem=new y({id:r.itemId,portal:a?.portal}),e.when(()=>{const y=y=>{const t=y.layerId;F(y,e,r,t,a);const i=r.featureCollection?.layers?.[t];i&&y.read(i,a)};e.layers?.forEach(y),e.tables?.forEach(y)}))}async function W(e,r,y){const t=a.FeatureLayer,i=await t(),L=r.featureCollection,n=L?.showLegend,o=L?.layers?.map((a,t)=>{const L=new i;L.read(a,y);const o={...y,ignoreDefaults:!0};return F(L,e,r,t,o),null!=n&&L.read({showLegend:n},o),L});e.layers.addMany(o??[])}function F(e,r,a,y,t){e.read({id:`${r.id}-sublayer-${y}`,visibility:a.visibleLayers?.includes(y)??!0},t)}export{C as populateGroupLayer,l as populateOperationalLayers};
|
|
5
|
+
import e from"../../core/Collection.js";import has from"../../core/has.js";import{LayerLoadContext as r}from"./LayerLoadContext.js";import{layerLookupMap as a}from"./lazyLayerLoader.js";import y from"../../portal/PortalItem.js";import{isMapNotesLayer as t,isMarkupLayer as i,isRouteLayer as L}from"../../portal/support/featureCollectionUtils.js";import{selectLayerClassPath as n}from"../../portal/support/portalLayers.js";import{loadStyleRenderer as o}from"../../renderers/support/styleUtils.js";async function l(e,r,a){if(!r)return;const y=r.map(e=>f(e,a)),t=await Promise.allSettled(y);for(const i of t)"rejected"===i.status||i.value&&e.add(i.value)}const s={ArcGISDimensionLayer:"DimensionLayer",ArcGISFeatureLayer:"FeatureLayer",ArcGISImageServiceLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISMapServiceTileLayer:"MapImageTileLayer",ArcGISSceneServiceLayer:"SceneLayer",ArcGISTiledElevationServiceLayer:"ElevationLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",BuildingSceneLayer:"BuildingSceneLayer",CatalogLayer:"CatalogLayer",CSV:"CSVLayer",DefaultTileLayer:"TileLayer",GaussianSplatLayer:"GaussianSplatLayer",GeoJSON:"GeoJSONLayer",GroupLayer:"GroupLayer",IntegratedMesh3DTilesLayer:"IntegratedMesh3DTilesLayer",Object3DTilesLayer:"UnsupportedLayer",IntegratedMeshLayer:"IntegratedMeshLayer",KML:"KMLLayer",LineOfSightLayer:"LineOfSightLayer",MediaLayer:"MediaLayer",OGCFeatureLayer:"OGCFeatureLayer",OrientedImageryLayer:"OrientedImageryLayer",PointCloudLayer:"PointCloudLayer",RasterDataLayer:"UnsupportedLayer",VectorTileLayer:"VectorTileLayer",ViewshedLayer:"ViewshedLayer",Voxel:"VoxelLayer",WCS:"WCSLayer",WFS:"WFSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},c={ArcGISTiledElevationServiceLayer:"ElevationLayer",DefaultTileLayer:"ElevationLayer",RasterDataElevationLayer:"UnsupportedLayer"},p={ArcGISFeatureLayer:"FeatureLayer"},S={ArcGISImageServiceLayer:"UnsupportedLayer",ArcGISMapServiceLayer:"UnsupportedLayer",ArcGISSceneServiceLayer:"SceneLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",DefaultTileLayer:"TileLayer",OpenStreetMap:"OpenStreetMapLayer",VectorTileLayer:"VectorTileLayer",WCS:"UnsupportedLayer",WMS:"UnsupportedLayer",WebTiledLayer:"WebTileLayer"},u={IntegratedMesh3DTilesLayer:"IntegratedMesh3DTilesLayer"},d={ArcGISAnnotationLayer:"UnsupportedLayer",ArcGISDimensionLayer:"UnsupportedLayer",ArcGISFeatureLayer:"FeatureLayer",ArcGISImageServiceLayer:"ImageryLayer",ArcGISImageServiceVectorLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISMapServiceTileLayer:"MapImageTileLayer",ArcGISStreamLayer:"StreamLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",ArcGISVideoLayer:"VideoLayer",BingMapsAerial:"BingMapsLayer",BingMapsHybrid:"BingMapsLayer",BingMapsRoad:"BingMapsLayer",CatalogLayer:"CatalogLayer",CSV:"CSVLayer",DefaultTileLayer:"TileLayer",GeoJSON:"GeoJSONLayer",GeoRSS:"GeoRSSLayer",GroupLayer:"GroupLayer",KML:"KMLLayer",KnowledgeGraphLayer:"KnowledgeGraphLayer",MediaLayer:"MediaLayer",OGCFeatureLayer:"OGCFeatureLayer",OrientedImageryLayer:"OrientedImageryLayer",get ParquetLayer(){return has("parquetlayer-persistence-enabled")?"ParquetLayer":"UnsupportedLayer"},SubtypeGroupLayer:"SubtypeGroupLayer",VectorTileLayer:"VectorTileLayer",WCS:"WCSLayer",WFS:"WFSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},I={ArcGISFeatureLayer:"FeatureLayer",SubtypeGroupTable:"SubtypeGroupLayer"},g={ArcGISImageServiceLayer:"ImageryLayer",ArcGISImageServiceVectorLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISMapServiceTileLayer:"MapImageTileLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",BingMapsAerial:"BingMapsLayer",BingMapsHybrid:"BingMapsLayer",BingMapsRoad:"BingMapsLayer",DefaultTileLayer:"TileLayer",OpenStreetMap:"OpenStreetMapLayer",VectorTileLayer:"VectorTileLayer",WCS:"WCSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},m={...d,LinkChartLayer:"LinkChartLayer"},T={...I},G={...g};async function f(e,r){return M(await b(e,r),e,r)}async function M(e,r,a){const y=new e;return y.read(r,a.context),"group"===y.type&&("GroupLayer"===r.layerType?await C(y,r,a):w(r)?h(y,r,a.context):A(r)&&await W(y,r,a.context)),await o(y,a.context),y}async function b(e,o){const l=o.context,s=v(l);let c=e.layerType||e.type;!c&&o?.defaultLayerType&&(c=o.defaultLayerType);const p=s[c];let S=p?a[p]:a.UnknownLayer;if(w(e)){const t=l?.portal;if(e.itemId){const i=new y({id:e.itemId,portal:t});await i.load();const L=(await n(i,new r)).className||"UnknownLayer";S=a[L]}}else"ArcGISFeatureLayer"===c?t(e)||i(e)?S=a.MapNotesLayer:L(e)?S=a.RouteLayer:A(e)&&(S=a.GroupLayer):e.wmtsInfo?.url&&e.wmtsInfo.layerIdentifier?S=a.WMTSLayer:"WFS"===c&&"2.0.0"!==e.wfsInfo?.version&&(S=a.UnsupportedLayer);return S()}function A(e){if("ArcGISFeatureLayer"!==e.layerType||w(e))return!1;return(e.featureCollection?.layers?.length??0)>1}function w(e){return"Feature Collection"===e.type}function v(e){let r;switch(e.origin){case"web-scene":switch(e.layerContainerType){case"basemap-base-layers":r=S;break;case"basemap-ground-layers":r=u;break;case"ground":r=c;break;case"tables":r=p;break;default:r=s}break;case"link-chart":switch(e.layerContainerType){case"basemap-base-layers":r=G;break;case"tables":r=T;break;default:r=m}break;default:switch(e.layerContainerType){case"basemap-base-layers":r=g;break;case"tables":r=I;break;default:r=d}}return r}async function C(r,a,y){const t=new e,i=l(t,Array.isArray(a.layers)?a.layers:[],y);try{try{if(await i,"group"===r.type)return r.layers.addMany(t),r}catch(L){r.destroy();for(const e of t)e.destroy();throw L}}catch(L){throw L}}function h(e,r,a){r.itemId&&(e.portalItem=new y({id:r.itemId,portal:a?.portal}),e.when(()=>{const y=y=>{const t=y.layerId;F(y,e,r,t,a);const i=r.featureCollection?.layers?.[t];i&&y.read(i,a)};e.layers?.forEach(y),e.tables?.forEach(y)}))}async function W(e,r,y){const t=a.FeatureLayer,i=await t(),L=r.featureCollection,n=L?.showLegend,o=L?.layers?.map((a,t)=>{const L=new i;L.read(a,y);const o={...y,ignoreDefaults:!0};return F(L,e,r,t,o),null!=n&&L.read({showLegend:n},o),L});e.layers.addMany(o??[])}function F(e,r,a,y,t){e.read({id:`${r.id}-sublayer-${y}`,visibility:a.visibleLayers?.includes(y)??!0},t)}export{C as populateGroupLayer,l as populateOperationalLayers};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const a={BingMapsLayer:async()=>(await import("../BingMapsLayer.js")).default,BuildingSceneLayer:async()=>(await import("../BuildingSceneLayer.js")).default,CSVLayer:async()=>(await import("../CSVLayer.js")).default,CatalogLayer:async()=>(await import("../CatalogLayer.js")).default,DimensionLayer:async()=>(await import("../DimensionLayer.js")).default,ElevationLayer:async()=>(await import("../ElevationLayer.js")).default,FeatureLayer:async()=>(await import("../FeatureLayer.js")).default,GaussianSplatLayer:async()=>(await import("../GaussianSplatLayer.js")).default,GeoJSONLayer:async()=>(await import("../GeoJSONLayer.js")).default,GeoRSSLayer:async()=>(await import("../GeoRSSLayer.js")).default,GroupLayer:async()=>(await import("../GroupLayer.js")).default,ImageryLayer:async()=>(await import("../ImageryLayer.js")).default,ImageryTileLayer:async()=>(await import("../ImageryTileLayer.js")).default,IntegratedMesh3DTilesLayer:async()=>(await import("../IntegratedMesh3DTilesLayer.js")).default,IntegratedMeshLayer:async()=>(await import("../IntegratedMeshLayer.js")).default,KMLLayer:async()=>(await import("../KMLLayer.js")).default,KnowledgeGraphLayer:async()=>(await import("../KnowledgeGraphLayer.js")).default,LineOfSightLayer:async()=>(await import("../LineOfSightLayer.js")).default,LinkChartLayer:async()=>(await import("../LinkChartLayer.js")).default,MapImageLayer:async()=>(await import("../MapImageLayer.js")).default,MapNotesLayer:async()=>(await import("../MapNotesLayer.js")).default,MediaLayer:async()=>(await import("../MediaLayer.js")).default,OGCFeatureLayer:async()=>(await import("../OGCFeatureLayer.js")).default,OpenStreetMapLayer:async()=>(await import("../OpenStreetMapLayer.js")).default,OrientedImageryLayer:async()=>(await import("../OrientedImageryLayer.js")).default,ParquetLayer:async()=>(await import("../ParquetLayer.js")).default,PointCloudLayer:async()=>(await import("../PointCloudLayer.js")).default,RouteLayer:async()=>(await import("../RouteLayer.js")).default,SceneLayer:async()=>(await import("../SceneLayer.js")).default,StreamLayer:async()=>(await import("../StreamLayer.js")).default,SubtypeGroupLayer:async()=>(await import("../SubtypeGroupLayer.js")).default,TileLayer:async()=>(await import("../TileLayer.js")).default,UnknownLayer:async()=>(await import("../UnknownLayer.js")).default,UnsupportedLayer:async()=>(await import("../UnsupportedLayer.js")).default,VectorTileLayer:async()=>(await import("../VectorTileLayer.js")).default,VideoLayer:async()=>(await import("../VideoLayer.js")).default,ViewshedLayer:async()=>(await import("../ViewshedLayer.js")).default,VoxelLayer:async()=>(await import("../VoxelLayer.js")).default,WCSLayer:async()=>(await import("../WCSLayer.js")).default,WFSLayer:async()=>(await import("../WFSLayer.js")).default,WMSLayer:async()=>(await import("../WMSLayer.js")).default,WMTSLayer:async()=>(await import("../WMTSLayer.js")).default,WebTileLayer:async()=>(await import("../WebTileLayer.js")).default};export{a as layerLookupMap};
|
|
5
|
+
const a={BingMapsLayer:async()=>(await import("../BingMapsLayer.js")).default,BuildingSceneLayer:async()=>(await import("../BuildingSceneLayer.js")).default,CSVLayer:async()=>(await import("../CSVLayer.js")).default,CatalogLayer:async()=>(await import("../CatalogLayer.js")).default,DimensionLayer:async()=>(await import("../DimensionLayer.js")).default,ElevationLayer:async()=>(await import("../ElevationLayer.js")).default,FeatureLayer:async()=>(await import("../FeatureLayer.js")).default,GaussianSplatLayer:async()=>(await import("../GaussianSplatLayer.js")).default,GeoJSONLayer:async()=>(await import("../GeoJSONLayer.js")).default,GeoRSSLayer:async()=>(await import("../GeoRSSLayer.js")).default,GroupLayer:async()=>(await import("../GroupLayer.js")).default,ImageryLayer:async()=>(await import("../ImageryLayer.js")).default,ImageryTileLayer:async()=>(await import("../ImageryTileLayer.js")).default,IntegratedMesh3DTilesLayer:async()=>(await import("../IntegratedMesh3DTilesLayer.js")).default,IntegratedMeshLayer:async()=>(await import("../IntegratedMeshLayer.js")).default,KMLLayer:async()=>(await import("../KMLLayer.js")).default,KnowledgeGraphLayer:async()=>(await import("../KnowledgeGraphLayer.js")).default,LineOfSightLayer:async()=>(await import("../LineOfSightLayer.js")).default,LinkChartLayer:async()=>(await import("../LinkChartLayer.js")).default,MapImageLayer:async()=>(await import("../MapImageLayer.js")).default,MapImageTileLayer:async()=>(await import("../MapImageTileLayer.js")).default,MapNotesLayer:async()=>(await import("../MapNotesLayer.js")).default,MediaLayer:async()=>(await import("../MediaLayer.js")).default,OGCFeatureLayer:async()=>(await import("../OGCFeatureLayer.js")).default,OpenStreetMapLayer:async()=>(await import("../OpenStreetMapLayer.js")).default,OrientedImageryLayer:async()=>(await import("../OrientedImageryLayer.js")).default,ParquetLayer:async()=>(await import("../ParquetLayer.js")).default,PointCloudLayer:async()=>(await import("../PointCloudLayer.js")).default,RouteLayer:async()=>(await import("../RouteLayer.js")).default,SceneLayer:async()=>(await import("../SceneLayer.js")).default,StreamLayer:async()=>(await import("../StreamLayer.js")).default,SubtypeGroupLayer:async()=>(await import("../SubtypeGroupLayer.js")).default,TileLayer:async()=>(await import("../TileLayer.js")).default,UnknownLayer:async()=>(await import("../UnknownLayer.js")).default,UnsupportedLayer:async()=>(await import("../UnsupportedLayer.js")).default,VectorTileLayer:async()=>(await import("../VectorTileLayer.js")).default,VideoLayer:async()=>(await import("../VideoLayer.js")).default,ViewshedLayer:async()=>(await import("../ViewshedLayer.js")).default,VoxelLayer:async()=>(await import("../VoxelLayer.js")).default,WCSLayer:async()=>(await import("../WCSLayer.js")).default,WFSLayer:async()=>(await import("../WFSLayer.js")).default,WMSLayer:async()=>(await import("../WMSLayer.js")).default,WMTSLayer:async()=>(await import("../WMTSLayer.js")).default,WebTileLayer:async()=>(await import("../WebTileLayer.js")).default};export{a as layerLookupMap};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);h=[];let a=0;for(const{data:s}of t)h.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;u=r.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,j=i===y.minCol?w:0,_=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(d,{x:j,y:_},{width:O-j,height:R-_}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,j=[],_=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.level&&j.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),j.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(d,T,M,c.origin,j,b),R=j.length>1?j.slice(1):null;let L;l.transposeInfo&&(L={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const z=_.length<=1||_.length>=3&&_.slice(0,-1).every(e=>e===_[0])?_[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:z,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:L,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new c({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return u.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return u.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("geoscene.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);h=[];let a=0;for(const{data:s}of t)h.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;u=r.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,j=i===y.minCol?w:0,_=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(d,{x:j,y:_},{width:O-j,height:R-_}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,j=[],_=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.level&&j.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),j.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(d,T,M,c.origin,j,b),R=j.length>1?j.slice(1):null;let L;l.transposeInfo&&(L={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const z=_.length<=1||_.length>=3&&_.slice(0,-1).every(e=>e===_[0])?_[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:z,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:L,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new c({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return u.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return u.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("geoscene.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
package/package.json
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{findAssociatedFeatureService as a}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleType as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as t}from"../../layers/support/LayerLoadContext.js";import{sceneServiceLayerTypeToClassName as s,applyPreferredHostToPortalItem as n,getPreferredHost as c}from"../../layers/support/layerUtils.js";import{layerLookupMap as o}from"../../layers/support/lazyLayerLoader.js";import i from"../PortalItem.js";import{getFirstLayerOrTable as u,getNumLayersAndTables as l,preprocessFSItemData as y,getLayerOrTable as m,layerTypeToLayerModuleType as f,populateSceneServiceItemData as p}from"./loadUtils.js";import{hasTypeKeyword as d}from"./portalItemUtils.js";async function L(e){let{portalItem:a}=e;!a||a instanceof i||(a=new i(a));const r=await w(a);return new(0,r.constructor)({portalItem:a,...r.properties})}async function w(e){await e.load();const a=new t;return N(await S(e,a))}async function S(a,r){switch(a.type){case"3DTiles Service":return a.typeKeywords.includes("3DObject")?F():a.typeKeywords.includes("GaussianSplat")?b():P();case"CSV":return K();case"Feature Collection":return M(a);case"Feature Service":return h(a,r);case"Feed":return J();case"GeoJson":return G();case"Group Layer":return k();case"Image Service":return g(a,r);case"KML":return V();case"Knowledge Graph Layer":return W();case"Map Service":return v(a,r);case"Media Layer":return $();case"Scene Service":return I(a,r);case"Stream Service":return j();case"Video Service":return T(a,r);case"Vector Tile Service":return C();case"WCS":return U();case"WFS":return D();case"WMS":return O();case"WMTS":return x();default:throw new e("portal:unknown-item-type","Unknown item type '${type}'",{type:a.type})}}async function N(e){const a=e.className,r=o[a];return{constructor:await r(),properties:e.properties}}async function v(e,a){return await A(e,a)?{className:"TileLayer"}:{className:"MapImageLayer"}}async function h(e,a){const r=await E(e,a);if("object"==typeof r){const{sourceJSON:e,className:a}=r,t={sourceJSON:e};return null!=r.id&&(t.layerId=r.id),{className:a||"FeatureLayer",properties:t}}return{className:"GroupLayer"}}async function I(e,r){const t=await E(e,r,async()=>{try{if(!e.url)return[];const{serverUrl:t}=await a(e.url,{sceneLayerItem:e}),s=await r.fetchServiceMetadata(t);return s?.tables??[]}catch{return[]}});if("object"==typeof t){const a={};let n;if(null!=t.id?(a.layerId=t.id,n=`${e.url}/layers/${t.id}`):n=e.url,e.typeKeywords?.length)for(const r of Object.keys(s))if(e.typeKeywords.includes(r))return{className:s[r]};const c=await r.fetchServiceMetadata(n,{customParameters:await r.fetchCustomParameters(e,e=>u(e)?.customParameters)});return{className:s[c?.layerType]||"SceneLayer",properties:a}}if(!1===t){const a=await r.fetchServiceMetadata(e.url);if("Voxel"===a?.layerType)return{className:"VoxelLayer"}}return{className:"GroupLayer"}}async function M(e){await e.load();const a=d(e,"Map Notes"),r=d(e,"Markup");if(a||r)return{className:"MapNotesLayer"};if(d(e,"Route Layer"))return{className:"RouteLayer"};const t=await e.fetchData();return 1===l(t)?{className:"FeatureLayer"}:{className:"GroupLayer"}}async function g(e,a){await e.load();const r=e.typeKeywords?.map(e=>e.toLowerCase())??[];if(r.includes("elevation 3d layer"))return{className:"ElevationLayer"};if(r.includes("tiled imagery"))return{className:"ImageryTileLayer"};const t=await a.fetchItemData(e),s=t?.layerType;if("ArcGISTiledImageServiceLayer"===s)return{className:"ImageryTileLayer"};if("ArcGISImageServiceLayer"===s)return{className:"ImageryLayer"};const n=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)}),c=n.cacheType?.toLowerCase(),o=n.capabilities?.toLowerCase().includes("tilesonly"),i=n.tileInfo?.format?.toLowerCase()??"",u=null==c&&["jpg","jpeg","png","png8","png24","png32","mixed"].includes(i);return"map"===c||u||o?{className:"ImageryTileLayer"}:{className:"ImageryLayer"}}function j(){return{className:"StreamLayer"}}async function T(e,a){return"object"==typeof await E(e,a)?{className:"VideoLayer"}:{className:"GroupLayer"}}function C(){return{className:"VectorTileLayer"}}function G(){return{className:"GeoJSONLayer"}}function P(){return{className:"IntegratedMesh3DTilesLayer"}}function b(){return{className:"GaussianSplatLayer"}}function F(){return{className:"UnsupportedLayer"}}function K(){return{className:"CSVLayer"}}function V(){return{className:"KMLLayer"}}function W(){return{className:"KnowledgeGraphLayer"}}function U(){return{className:"WCSLayer"}}function D(){return{className:"WFSLayer"}}function O(){return{className:"WMSLayer"}}function x(){return{className:"WMTSLayer"}}function J(){return{className:"StreamLayer"}}function k(){return{className:"GroupLayer"}}function $(){return{className:"MediaLayer"}}async function A(e,a){const{tileInfo:r}=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)});return r}async function E(e,a,t){const{url:s,type:o}=e,i="Feature Service"===o;if(!s)return{};if(/\/\d+$/.test(s)){if(i){const t=await a.fetchServiceMetadata(s,{customParameters:await a.fetchCustomParameters(e,e=>u(e)?.customParameters)});return n(e,c()),{id:t.id,className:r(t.type),sourceJSON:t}}return{}}if("Video Service"===o){const e=await a.fetchServiceMetadata(s);return!((e.layers?.length??0)>1)&&{}}await e.load();let d=await a.fetchItemData(e);if(i){const{data:r,preferredHost:t}=await y(d,s,a);n(e,t);const c=R(r);if("object"==typeof c){const e=m(r,c.id);c.className=f(e?.layerType)}return c}"Scene Service"===o&&(d=await p(e,d,a));if(l(d)>0)return R(d);const L=await a.fetchServiceMetadata(s);return t&&(L.tables=await t()),R(L)}function R(e){return 1===l(e)&&{id:u(e)?.id}}export{L as fromItem,S as selectLayerClassPath};
|
|
5
|
+
import e from"../../core/Error.js";import{findAssociatedFeatureService as a}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleType as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as t}from"../../layers/support/LayerLoadContext.js";import{sceneServiceLayerTypeToClassName as s,applyPreferredHostToPortalItem as n,getPreferredHost as c}from"../../layers/support/layerUtils.js";import{layerLookupMap as o}from"../../layers/support/lazyLayerLoader.js";import i from"../PortalItem.js";import{getFirstLayerOrTable as u,getNumLayersAndTables as l,preprocessFSItemData as y,getLayerOrTable as m,layerTypeToLayerModuleType as f,populateSceneServiceItemData as p}from"./loadUtils.js";import{hasTypeKeyword as d}from"./portalItemUtils.js";async function L(e){let{portalItem:a}=e;!a||a instanceof i||(a=new i(a));const r=await w(a);return new(0,r.constructor)({portalItem:a,...r.properties})}async function w(e){await e.load();const a=new t;return N(await S(e,a))}async function S(a,r){switch(a.type){case"3DTiles Service":return a.typeKeywords.includes("3DObject")?F():a.typeKeywords.includes("GaussianSplat")?b():P();case"CSV":return K();case"Feature Collection":return M(a);case"Feature Service":return h(a,r);case"Feed":return J();case"GeoJson":return G();case"Group Layer":return k();case"Image Service":return g(a,r);case"KML":return V();case"Knowledge Graph Layer":return W();case"Map Service":return v(a,r);case"Media Layer":return $();case"Scene Service":return I(a,r);case"Stream Service":return j();case"Video Service":return T(a,r);case"Vector Tile Service":return C();case"WCS":return U();case"WFS":return D();case"WMS":return O();case"WMTS":return x();default:throw new e("portal:unknown-item-type","Unknown item type '${type}'",{type:a.type})}}async function N(e){const a=e.className,r=o[a];return{constructor:await r(),properties:e.properties}}async function v(e,a){return await A(e,a)?{className:"TileLayer"}:{className:"MapImageLayer"}}async function h(e,a){const r=await E(e,a);if("object"==typeof r){const{sourceJSON:e,className:a}=r,t={sourceJSON:e};return null!=r.id&&(t.layerId=r.id),{className:a||"FeatureLayer",properties:t}}return{className:"GroupLayer"}}async function I(e,r){const t=await E(e,r,async()=>{try{if(!e.url)return[];const{serverUrl:t}=await a(e.url,{sceneLayerItem:e}),s=await r.fetchServiceMetadata(t);return s?.tables??[]}catch{return[]}});if("object"==typeof t){const a={};let n;if(null!=t.id?(a.layerId=t.id,n=`${e.url}/layers/${t.id}`):n=e.url,e.typeKeywords?.length)for(const r of Object.keys(s))if(e.typeKeywords.includes(r))return{className:s[r]};const c=await r.fetchServiceMetadata(n,{customParameters:await r.fetchCustomParameters(e,e=>u(e)?.customParameters)});return{className:s[c?.layerType]||"SceneLayer",properties:a}}if(!1===t){const a=await r.fetchServiceMetadata(e.url);if("Voxel"===a?.layerType)return{className:"VoxelLayer"}}return{className:"GroupLayer"}}async function M(e){await e.load();const a=d(e,"Map Notes"),r=d(e,"Markup");if(a||r)return{className:"MapNotesLayer"};if(d(e,"Route Layer"))return{className:"RouteLayer"};const t=await e.fetchData();return 1===l(t)?{className:"FeatureLayer"}:{className:"GroupLayer"}}async function g(e,a){await e.load();const r=e.typeKeywords?.map(e=>e.toLowerCase())??[];if(r.includes("elevation 3d layer"))return{className:"ElevationLayer"};if(r.includes("tiled imagery"))return{className:"ImageryTileLayer"};const t=await a.fetchItemData(e),s=t?.layerType;if("ArcGISTiledImageServiceLayer"===s)return{className:"ImageryTileLayer"};if("ArcGISImageServiceLayer"===s)return{className:"ImageryLayer"};const n=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)}),c=n.cacheType?.toLowerCase(),o=n.capabilities?.toLowerCase().includes("tilesonly"),i=n.tileInfo?.format?.toLowerCase()??"",u=null==c&&["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"].includes(i);return"map"===c||u||o?{className:"ImageryTileLayer"}:{className:"ImageryLayer"}}function j(){return{className:"StreamLayer"}}async function T(e,a){return"object"==typeof await E(e,a)?{className:"VideoLayer"}:{className:"GroupLayer"}}function C(){return{className:"VectorTileLayer"}}function G(){return{className:"GeoJSONLayer"}}function P(){return{className:"IntegratedMesh3DTilesLayer"}}function b(){return{className:"GaussianSplatLayer"}}function F(){return{className:"UnsupportedLayer"}}function K(){return{className:"CSVLayer"}}function V(){return{className:"KMLLayer"}}function W(){return{className:"KnowledgeGraphLayer"}}function U(){return{className:"WCSLayer"}}function D(){return{className:"WFSLayer"}}function O(){return{className:"WMSLayer"}}function x(){return{className:"WMTSLayer"}}function J(){return{className:"StreamLayer"}}function k(){return{className:"GroupLayer"}}function $(){return{className:"MediaLayer"}}async function A(e,a){const{tileInfo:r}=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)});return r}async function E(e,a,t){const{url:s,type:o}=e,i="Feature Service"===o;if(!s)return{};if(/\/\d+$/.test(s)){if(i){const t=await a.fetchServiceMetadata(s,{customParameters:await a.fetchCustomParameters(e,e=>u(e)?.customParameters)});return n(e,c()),{id:t.id,className:r(t.type),sourceJSON:t}}return{}}if("Video Service"===o){const e=await a.fetchServiceMetadata(s);return!((e.layers?.length??0)>1)&&{}}await e.load();let d=await a.fetchItemData(e);if(i){const{data:r,preferredHost:t}=await y(d,s,a);n(e,t);const c=R(r);if("object"==typeof c){const e=m(r,c.id);c.className=f(e?.layerType)}return c}"Scene Service"===o&&(d=await p(e,d,a));if(l(d)>0)return R(d);const L=await a.fetchServiceMetadata(s);return t&&(L.tables=await t()),R(L)}function R(e){return 1===l(e)&&{id:u(e)?.id}}export{L as fromItem,S as selectLayerClassPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseUrl as r}from"../utils.js";import{JSONFeatureSetParserContext as e}from"./operations/pbfJSONFeatureSet.js";import{executeQueryFGB as t}from"./operations/query.js";import o from"../support/FeatureSet.js";import a from"../support/Query.js";import*as flatgeobufGeojson from"./operations/flatgeobufGeojson.js";function detectSpatialReferenceFromGeoJSON(geojson){if(geojson.crs&&geojson.crs.properties&&"string"==typeof geojson.crs.properties.name){var name,match=geojson.crs.properties.name.match(/EPSG::?(\d+)/i);if(match)return{wkid:parseInt(match[1],10)}}return{wkid:4326}}function convertGeometry(geometry,spatialReference){if(!geometry)return null;const type=geometry.type,coords=geometry.coordinates,base={spatialReference:spatialReference};let data={};if("Point"===type)data={type:"point",x:coords[0],y:coords[1]};else if("LineString"===type)data={type:"polyline",paths:[coords]};else if("Polygon"===type)data={type:"polygon",rings:coords};else if("MultiPoint"===type)data={type:"multipoint",points:coords};else if("MultiLineString"===type)data={type:"polyline",paths:coords};else{if("MultiPolygon"!==type)throw new Error("Unsupported geometry type: "+type);{let rings=[];for(let i=0;i<coords.length;i++)rings=rings.concat(coords[i]);data={type:"polygon",rings:rings}}}return{...data,...base}}function extractFieldsFromProperties(properties){const fields=[];if(!properties)return fields;for(let key in properties)properties.hasOwnProperty(key)&&fields.push({name:key,alias:key,type:inferFieldType(properties[key])});return fields}function inferFieldType(value){const t=typeof value;if("number"===t)return Number.isInteger(value)?"integer":"double";if("string"===t){const date=Date.parse(value);return isNaN(date)||-1===value.indexOf("T")?"string":"date"}return"boolean"===t?"small-integer":"string"}function detectGeometryType(features){if(!features||0===features.length)return null;const firstGeometry=features[0].geometry;if(!firstGeometry||!firstGeometry.type)return null;const type=firstGeometry.type;return"Point"===type||"MultiPoint"===type?"point":"LineString"===type||"MultiLineString"===type?"polyline":"Polygon"===type||"MultiPolygon"===type?"polygon":null}function geojsonToFeatureSet(geojson){if(!geojson||"FeatureCollection"!==geojson.type)throw new Error("Invalid GeoJSON");const reference=detectSpatialReferenceFromGeoJSON(geojson),features=[];for(let i=0;i<geojson.features.length;i++){const feature=geojson.features[i],geometry=convertGeometry(feature.geometry,reference);features.push({geometry:geometry,attributes:feature.properties||{}})}const fields=extractFieldsFromProperties(geojson.features.length>0?geojson.features[0].properties:null),featureSet=new o({features:features,fields:fields,geometryType:detectGeometryType(geojson.features),spatialReference:reference});return featureSet}async function turnToGeoJSON(arraybuffer){const uint8Array=new Uint8Array(arraybuffer);let header=null;const geojson=await flatgeobufGeojson.default.deserialize(uint8Array,()=>{},some=>{header=some});return header&&header.crs&&(geojson.crs={type:"name",properties:{name:header.crs.org+":"+header.crs.code}}),geojson}async function s(r,e,t,s){const p=await n(r,a.from(e),t,s),geojson=await turnToGeoJSON(p);return geojsonToFeatureSet(geojson)}async function n(o,s,n,p){const i=r(o),u={...n},m=a.from(s),f=!m.quantizationParameters,{data:c}=await t(i,m,new e({sourceSpatialReference:m.sourceSpatialReference,applyTransform:f}),u,p);return c}export{s as executeQueryFGB,n as executeRawQueryFGB};
|