@geoscene/core 4.34.8 → 4.34.10

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.
Files changed (95) hide show
  1. package/analysis/ViewshedVideo.js +5 -0
  2. package/analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js +5 -0
  3. package/analysis/viewshedVideo/ViewshedComputedDataVideo.js +5 -0
  4. package/analysis/viewshedVideo/ViewshedSubVisualizationVideo.js +5 -0
  5. package/analysis/viewshedVideo/ViewshedVisualizationVideo.js +5 -0
  6. package/analysis/viewshedVideo/render/ViewshedTechniqueVideo.js +5 -0
  7. package/analysis/viewshedVideo/render/ViewshedVideo.glsl.js +243 -0
  8. package/analysis/viewshedVideo/render/ViewshedVideo.js +5 -0
  9. package/assets/geoscene/core/workers/chunks/0f4e9846d074864b39c2.js +1 -1
  10. package/assets/geoscene/core/workers/chunks/38b9ec5f73f2467262dc.js +1 -1
  11. package/assets/geoscene/core/workers/chunks/50e1c63d0b6196dd365e.js +1 -1
  12. package/assets/geoscene/core/workers/chunks/bc3df7ef6d001bb8192e.js +1 -1
  13. package/assets/geoscene/core/workers/chunks/db8d4a12a67a62ec3704.js +1 -1
  14. package/assets/geoscene/core/workers/chunks/dfbf2e17058aa876f96a.js +1 -1
  15. package/bundle/lib/fflate.js +12 -0
  16. package/interfaces.d.ts +15 -0
  17. package/layers/MapImageTileLayer.js +355 -0
  18. package/layers/mixins/SceneService.js +1 -1
  19. package/layers/mixins/SublayersOwner.js +1 -1
  20. package/layers/mixins/operationalLayers.js +1 -1
  21. package/layers/support/LercWorker.js +1 -5
  22. package/layers/support/layersCreator.js +1 -1
  23. package/layers/support/lazyLayerLoader.js +1 -1
  24. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  25. package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
  26. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  27. package/layers/voxel/drill/VoxelContinuousDrill.js +5 -0
  28. package/layers/voxel/drill/VoxelDiscreteDrill.js +5 -0
  29. package/layers/voxel/drill/common.js +5 -0
  30. package/package.json +1 -1
  31. package/portal/support/portalLayers.js +1 -1
  32. package/rest/query/executeQueryFGB.js +1 -0
  33. package/rest/query/operations/flatgeobufGeojson.js +3 -0
  34. package/rest/query/operations/flatgeobufGeojson.min.js +15 -0
  35. package/rest/query/operations/query.js +1 -1
  36. package/rest/query.d.ts +1 -0
  37. package/rest/query.js +1 -1
  38. package/views/3d/analysis/analysisViewModuleImportUtils.js +1 -1
  39. package/views/3d/layers/I3SMeshView3D.js +1 -1
  40. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  41. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  42. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  43. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  44. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  45. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  46. package/views/3d/layers/support/LayerViewAnalysisViewManager.js +1 -1
  47. package/views/draw/expert/AttackArrowDrawer.js +5 -0
  48. package/views/draw/expert/AttackTailedArrowDrawer.js +5 -0
  49. package/views/draw/expert/BaseDrawer.js +5 -0
  50. package/views/draw/expert/Constant.js +5 -0
  51. package/views/draw/expert/CurveDrawer.js +5 -0
  52. package/views/draw/expert/CurveFlagDrawer.js +5 -0
  53. package/views/draw/expert/CurvedArrowDrawer.js +5 -0
  54. package/views/draw/expert/EllipseDrawer.js +5 -0
  55. package/views/draw/expert/ExpertDraw.js +5 -0
  56. package/views/draw/expert/GatheringPlaceDrawer.js +5 -0
  57. package/views/draw/expert/LuneDrawer.js +5 -0
  58. package/views/draw/expert/PincerArrowDrawer.js +5 -0
  59. package/views/draw/expert/SectorDrawer.js +5 -0
  60. package/views/draw/expert/SquadCombatDrawer.js +5 -0
  61. package/views/draw/expert/StraightArrowDrawer.js +5 -0
  62. package/views/draw/expert/TailedSquadCombatDrawer.js +5 -0
  63. package/views/draw/expert/plot/Constants.js +5 -0
  64. package/views/draw/expert/plot/PlotTypes.js +5 -0
  65. package/views/draw/expert/plot/plots/Arc.js +41 -0
  66. package/views/draw/expert/plot/plots/AssaultDirection.js +15 -0
  67. package/views/draw/expert/plot/plots/AttackArrow.js +5 -0
  68. package/views/draw/expert/plot/plots/Circle.js +5 -0
  69. package/views/draw/expert/plot/plots/ClosedCurve.js +5 -0
  70. package/views/draw/expert/plot/plots/Curve.js +5 -0
  71. package/views/draw/expert/plot/plots/CurveFlag.js +5 -0
  72. package/views/draw/expert/plot/plots/CurvedArrow.js +5 -0
  73. package/views/draw/expert/plot/plots/DoubleArrow.js +5 -0
  74. package/views/draw/expert/plot/plots/Ellipse.js +5 -0
  75. package/views/draw/expert/plot/plots/FineArrow.js +5 -0
  76. package/views/draw/expert/plot/plots/FreehandLine.js +19 -0
  77. package/views/draw/expert/plot/plots/FreehandPolygon.js +19 -0
  78. package/views/draw/expert/plot/plots/GatheringPlace.js +5 -0
  79. package/views/draw/expert/plot/plots/Lune.js +5 -0
  80. package/views/draw/expert/plot/plots/Marker.js +16 -0
  81. package/views/draw/expert/plot/plots/Plot.js +5 -0
  82. package/views/draw/expert/plot/plots/Polygon.js +18 -0
  83. package/views/draw/expert/plot/plots/Polyline.js +19 -0
  84. package/views/draw/expert/plot/plots/Rectangle.js +28 -0
  85. package/views/draw/expert/plot/plots/Sector.js +5 -0
  86. package/views/draw/expert/plot/plots/SquadCombat.js +5 -0
  87. package/views/draw/expert/plot/plots/StraightArrow.js +5 -0
  88. package/views/draw/expert/plot/plots/TailedAttackArrow.js +5 -0
  89. package/views/draw/expert/plot/plots/TailedSquadCombat.js +5 -0
  90. package/views/draw/expert/plot/utils/plot_util.js +5 -0
  91. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  92. package/widgets/Features/FeaturesViewModel.js +1 -1
  93. package/widgets/LayerList/LayerListItem.js +1 -1
  94. package/widgets/Legend/LegendViewModel.js +1 -1
  95. 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 t from"../../request.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{updateOrigins as l}from"../../core/accessorSupport/originUtils.js";import p from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import d from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as m,parse as u,cleanTitle as h}from"../support/arcgisLayerUrl.js";import{id as y}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";const _=_=>{const A=_;let E=class extends A{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=i(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return L(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:L(t)}:e;return p.fromJSON(o,r)}const o=t.store,i=L(t);return null==i||null==o?.extent||!Array.isArray(o.extent)||o.extent.some(e=>e<R)?null:new p({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?m(this.url,t.name):t.name;let o=t.name;if(!o&&this.url){const e=u(this.url);null!=e&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),h(o)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,o.getLogger(this),t);const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,o=t.rootPage?.nodes?.[r];O(e,o?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<R)return;const o=r[2],i=r[3];e.zmin=o-i,e.zmax=o+i}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const o={...P,...t};let i=x.from(e);if(!i)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");i.id&&(i=i.clone(),i.id=null);const s=i.portal||w.getDefault();await this._ensureLoadBeforeSave(),i.type=U,i.portal=s;const a=I(i,"portal-item",!0),n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),this.url&&(i.url=this.url),i.title||(i.title=this.title),T(i,o,1),await s.signIn(),await s.user.addItem({item:i,folder:o?.folder,data:n}),await j(this.resourceReferences,a),this.portalItem=i,l(a),a.portalItem=i,i}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type "${U}"`);await this._ensureLoadBeforeSave();const o=I(this.portalItem,"portal-item",!0),i={layers:[this.write({},o)]};return await Promise.all(o.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(i,o,t),this.url&&(this.portalItem.url=this.url),this.portalItem.title||(this.portalItem.title=this.title),T(this.portalItem,t,0),await b(this.portalItem,i,this.resourceReferences,o),l(o),this.portalItem}async _validateAgainstJSONSchema(e,t,i){const s=i?.validationOptions;N(t,{errorName:"sceneservice:save"},{ignoreUnsupported:s?.ignoreUnsupported,supplementalUnsupportedErrors:["scenemodification:unsupported"]});const a=s?.enabled,n=g();if(a&&n){const t=(await n()).validate(e,i.portalItemLayerType);if(!t.length)return;const a=`Layer item did not validate:\n${t.join("\n")}`;if(o.getLogger(this).error(`_validateAgainstJSONSchema(): ${a}`),"throw"===s.failPolicy){const e=t.map(e=>new r("sceneservice:schema-validation",e));throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{validationErrors:e})}}}};return e([s(y)],E.prototype,"id",void 0),e([s({type:d})],E.prototype,"spatialReference",void 0),e([a("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readSpatialReference",null),e([s({type:p})],E.prototype,"fullExtent",void 0),e([a("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readFullExtent",null),e([s({readOnly:!0,type:c})],E.prototype,"heightModelInfo",void 0),e([s({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],E.prototype,"minScale",void 0),e([s({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],E.prototype,"maxScale",void 0),e([s({readOnly:!0})],E.prototype,"version",void 0),e([a("version",["store.version"])],E.prototype,"readVersion",null),e([s({type:String,json:{read:{source:"copyrightText"}}})],E.prototype,"copyright",void 0),e([s({type:String,json:{read:!1}})],E.prototype,"sublayerTitleMode",void 0),e([s({type:String})],E.prototype,"title",void 0),e([a("portal-item","title")],E.prototype,"readTitlePortalItem",null),e([a("service","title",["name"])],E.prototype,"readTitleService",null),e([s({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],E.prototype,"layerId",void 0),e([s(v({separator:"layers"}))],E.prototype,"url",void 0),e([s({readOnly:!0})],E.prototype,"parsedUrl",null),e([s({readOnly:!0})],E.prototype,"store",void 0),e([s({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],E.prototype,"rootNode",void 0),E=e([n("geoscene.layers.mixins.SceneService")],E),E},R=-1e38;function L(e){if(null!=e.spatialReference)return d.fromJSON(e.spatialReference);const t=e.store,r=t.indexCRS||t.geographicCRS,o=r&&parseInt(r.slice(r.lastIndexOf("/")+1),10);return null!=o?new d(o):null}function O(e,t){if(null==t?.center||null==t.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(t.center[0]<R)return;const o=t.halfSize,i=t.center[2],s=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]);e.zmin=i-s,e.zmax=i+s}function T(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const o=t.getTypeKeywords();for(const i of o)e.typeKeywords.push(i);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t),1===r&&(e.typeKeywords=e.typeKeywords.filter(e=>"Hosted Service"!==e)))}const U="Scene Service",P={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}};export{_ as SceneService,U as sceneServiceItemType,O as updateExtentFromPageObb};
5
+ import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{updateOrigins as l}from"../../core/accessorSupport/originUtils.js";import p from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import d from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as m,parse as u,cleanTitle as h}from"../support/arcgisLayerUrl.js";import{id as y}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";const _=_=>{const A=_;let E=class extends A{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=i(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return L(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:L(t)}:e;return p.fromJSON(o,r)}const o=t.store,i=L(t);return null==i||null==o?.extent||!Array.isArray(o.extent)||o.extent.some(e=>e<R)?null:new p({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?m(this.url,t.name):t.name;let o=t.name;if(!o&&this.url){const e=u(this.url);null!=e&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),h(o)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,o.getLogger(this),t);const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,o=t.rootPage?.nodes?.[r];O(e,o?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<R)return;const o=r[2],i=r[3];e.zmin=o-i,e.zmax=o+i}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});try{const decryptEnabled=this.decrypt?.enabled??true;if(decryptEnabled&&this.decrypt?.url){this._decodeData=await t(this.decrypt?.url,{query:{},responseType:"json"})}}catch(error){console.log(error)}if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const o={...P,...t};let i=x.from(e);if(!i)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");i.id&&(i=i.clone(),i.id=null);const s=i.portal||w.getDefault();await this._ensureLoadBeforeSave(),i.type=U,i.portal=s;const a=I(i,"portal-item",!0),n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),this.url&&(i.url=this.url),i.title||(i.title=this.title),T(i,o,1),await s.signIn(),await s.user.addItem({item:i,folder:o?.folder,data:n}),await j(this.resourceReferences,a),this.portalItem=i,l(a),a.portalItem=i,i}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type"${U}"`);await this._ensureLoadBeforeSave();const o=I(this.portalItem,"portal-item",!0),i={layers:[this.write({},o)]};return await Promise.all(o.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(i,o,t),this.url&&(this.portalItem.url=this.url),this.portalItem.title||(this.portalItem.title=this.title),T(this.portalItem,t,0),await b(this.portalItem,i,this.resourceReferences,o),l(o),this.portalItem}async _validateAgainstJSONSchema(e,t,i){const s=i?.validationOptions;N(t,{errorName:"sceneservice:save"},{ignoreUnsupported:s?.ignoreUnsupported,supplementalUnsupportedErrors:["scenemodification:unsupported"]});const a=s?.enabled,n=g();if(a&&n){const t=(await n()).validate(e,i.portalItemLayerType);if(!t.length)return;const a=`Layer item did not validate:\n${t.join("\n")}`;if(o.getLogger(this).error(`_validateAgainstJSONSchema():${a}`),"throw"===s.failPolicy){const e=t.map(e=>new r("sceneservice:schema-validation",e));throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{validationErrors:e})}}}};return e([s(y)],E.prototype,"id",void 0),e([s({type:d})],E.prototype,"spatialReference",void 0),e([a("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readSpatialReference",null),e([s({type:p})],E.prototype,"fullExtent",void 0),e([a("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readFullExtent",null),e([s({readOnly:!0,type:c})],E.prototype,"heightModelInfo",void 0),e([s({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],E.prototype,"minScale",void 0),e([s({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],E.prototype,"maxScale",void 0),e([s({readOnly:!0})],E.prototype,"version",void 0),e([a("version",["store.version"])],E.prototype,"readVersion",null),e([s({type:String,json:{read:{source:"copyrightText"}}})],E.prototype,"copyright",void 0),e([s({type:String,json:{read:!1}})],E.prototype,"sublayerTitleMode",void 0),e([s({type:String})],E.prototype,"title",void 0),e([a("portal-item","title")],E.prototype,"readTitlePortalItem",null),e([a("service","title",["name"])],E.prototype,"readTitleService",null),e([s({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],E.prototype,"layerId",void 0),e([s(v({separator:"layers"}))],E.prototype,"url",void 0),e([s({readOnly:!0})],E.prototype,"parsedUrl",null),e([s({readOnly:!0})],E.prototype,"store",void 0),e([s({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],E.prototype,"rootNode",void 0),E=e([n("geoscene.layers.mixins.SceneService")],E),E},R=-1e38;function L(e){if(null!=e.spatialReference)return d.fromJSON(e.spatialReference);const t=e.store,r=t.indexCRS||t.geographicCRS,o=r&&parseInt(r.slice(r.lastIndexOf("/")+1),10);return null!=o?new d(o):null}function O(e,t){if(null==t?.center||null==t.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(t.center[0]<R)return;const o=t.halfSize,i=t.center[2],s=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]);e.zmin=i-s,e.zmax=i+s}function T(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const o=t.getTypeKeywords();for(const i of o)e.typeKeywords.push(i);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t),1===r&&(e.typeKeywords=e.typeKeywords.filter(e=>"Hosted Service"!==e)))}const U="Scene Service",P={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}};export{_ as SceneService,U as sceneServiceItemType,O as updateExtentFromPageObb};
@@ -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,useCanvas: r.tileInfo?.format === "TerrainDEM"});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};
@@ -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 t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;let _;m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h);let i;if(_=n.data,s.renderOnCanvas){if(g)for(i=0;i<g.length;i++)g[i]?_[4*i+3]=255:_[4*i+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),p=new Uint8Array(o);if(g)for(i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2];else for(g=new Uint8Array(o),i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2],g[i]=_[4*i+3];t({width:c,height:h,pixels:[l,w,p],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
5
+ import t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;let _;o==="webp"&&(m.width=c,m.height=h),m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h);let i;if(_=n.data,s.renderOnCanvas){if(g)for(i=0;i<g.length;i++)g[i]?_[4*i+3]=255:_[4*i+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),p=new Uint8Array(o);if(g)for(i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2];else for(g=new Uint8Array(o),i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2],g[i]=_[4*i+3];t({width:c,height:h,pixels:[l,w,p],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};