@arcgis/core 4.30.0-next.20240210 → 4.30.0-next.20240213

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 (81) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +1 -0
  3. package/assets/esri/core/workers/chunks/0d54451c740f54a59f49.js +1 -0
  4. package/assets/esri/core/workers/chunks/{2b7513fe57eca6cff7c3.js → 0f30059c4e7a9cb85d1d.js} +1 -1
  5. package/assets/esri/core/workers/chunks/18551a7eb5a9b88aa0dc.js +1 -0
  6. package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +1 -0
  7. package/assets/esri/core/workers/chunks/{3f4d63436c3de04a6ebb.js → 254b4ee3621bbe345bb1.js} +1 -1
  8. package/assets/esri/core/workers/chunks/2d682ee6e5d66f2ea5cd.js +1 -0
  9. package/assets/esri/core/workers/chunks/{d5484d470121de2b403b.js → 36d091be859bbb1a149b.js} +1 -1
  10. package/assets/esri/core/workers/chunks/50b41f91be903a0977f9.js +1 -0
  11. package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +1 -0
  12. package/assets/esri/core/workers/chunks/784b6a8216b97440b180.js +1 -0
  13. package/assets/esri/core/workers/chunks/{7f7a4de2cd4ab71b9aee.js → 8d119dc0a92ad3612daa.js} +1 -1
  14. package/assets/esri/core/workers/chunks/966cc0b54008c7348678.js +1 -0
  15. package/assets/esri/core/workers/chunks/{2853221e88ed7077a447.js → 9850b0e04cce8c1bdddf.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{0014635097a32ad38895.js → a854611d1a86b838c6ad.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{cf6970b490b98aa0a117.js → be562536212360943388.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{50a5abd75fa7dbb571a5.js → ccd53b81c2688dd11584.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{b2b8e6a0b3f70ada2799.js → e4da908079417cc2f495.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{af0314c2b5b7dc4f5bbd.js → e6dbf0a7b7b1cf64f23f.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{eba72ff1726ff6998204.js → f03d62ab7806b68d0b62.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{5fcda75ed02b8aee3a3c.js → f89278782ddfb154aa9f.js} +1 -1
  23. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  24. package/geometry/Mesh.js +1 -1
  25. package/geometry/support/meshVertexSpaceUtils.js +1 -1
  26. package/interfaces.d.ts +174 -16
  27. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  28. package/layers/SceneLayer.js +1 -1
  29. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  30. package/layers/support/PixelBlock.js +1 -1
  31. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  32. package/layers/support/rasterDatasets/MRFRaster.js +1 -1
  33. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  34. package/layers/support/rasterFunctions/surfaceUtils.js +1 -1
  35. package/package.json +2 -2
  36. package/portal/support/resourceUtils.js +1 -1
  37. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  38. package/rest/support/meshFeatureSet.js +1 -1
  39. package/support/revision.js +1 -1
  40. package/symbols/cim/constants.js +1 -1
  41. package/symbols/support/previewSymbol2D.js +1 -1
  42. package/versionManagement/support/versionManagementUtils.js +1 -1
  43. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  44. package/views/2d/engine/webgl/collisions/CollisionGrid.js +1 -1
  45. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  46. package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
  47. package/views/2d/engine/webgl/shaderGraph/GLSLShaderModule.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  49. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
  52. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  53. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  54. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  55. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  56. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  57. package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
  58. package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
  59. package/views/3d/layers/I3SMeshView3D.js +1 -1
  60. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  61. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  62. package/views/SceneView.js +1 -1
  63. package/views/draw/DrawOperation.js +1 -1
  64. package/views/draw/support/Box.js +1 -1
  65. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  66. package/views/support/automaticLengthMeasurementUtils.js +1 -1
  67. package/views/support/extentUtils.js +5 -0
  68. package/widgets/BasemapLayerList.js +1 -1
  69. package/widgets/Editor/EditorViewModel.js +1 -1
  70. package/widgets/FeatureForm.js +1 -1
  71. package/widgets/LayerList.js +1 -1
  72. package/widgets/TableList.js +1 -1
  73. package/assets/esri/core/workers/chunks/062629a9b4695dea8bf8.js +0 -1
  74. package/assets/esri/core/workers/chunks/3401157faaa8619aaa47.js +0 -1
  75. package/assets/esri/core/workers/chunks/37803888bd9a537481a7.js +0 -1
  76. package/assets/esri/core/workers/chunks/560f677a356c7ebde5d3.js +0 -1
  77. package/assets/esri/core/workers/chunks/5bfc5ffad705aaaafcd4.js +0 -1
  78. package/assets/esri/core/workers/chunks/655f4560fb36a0d9ff0b.js +0 -1
  79. package/assets/esri/core/workers/chunks/b927b655e955abe00d48.js +0 -1
  80. package/assets/esri/core/workers/chunks/d2417d179d015f1193a1.js +0 -1
  81. package/assets/esri/core/workers/chunks/f75ec599f53c66cab194.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import"../renderers/support/jsonUtils.js";import{webSceneRendererTypes as i}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import a from"../core/Collection.js";import n from"../core/Error.js";import l from"../core/Logger.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,isAbortError as y}from"../core/promiseUtils.js";import{whenOnce as u}from"../core/reactiveUtils.js";import{join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as v}from"../core/accessorSupport/PropertyOrigin.js";import b from"../geometry/Mesh.js";import w from"../geometry/Point.js";import I from"./Layer.js";import{NoModelError as L,MultipleModelsError as j}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as F}from"./mixins/APIKeyMixin.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{CustomParametersMixin as _}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as E}from"./mixins/EditBusLayer.js";import{OperationalLayer as P}from"./mixins/OperationalLayer.js";import{PortalLayer as A}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{SceneService as x,SaveOperationType as D}from"./mixins/SceneService.js";import{TemporalSceneLayer as T}from"./mixins/TemporalSceneLayer.js";import{isHostedAgolService as U}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as R}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as q}from"./support/capabilities.js";import{elevationInfo as C,labelsVisible as G,legendEnabled as Q,popupEnabled as N,screenSizePerspectiveEnabled as k}from"./support/commonProperties.js";import{computeEffectiveEditingEnabled as V,getGlobalIdToObjectIdMap as M}from"./support/featureLayerUtils.js";import{FeatureReduction as K}from"./support/FeatureReduction.js";import $ from"./support/FeatureReductionSelection.js";import{defineFieldProperties as H}from"./support/fieldProperties.js";import z from"./support/FieldsIndex.js";import{fixRendererFields as W,unpackFieldNames as B}from"./support/fieldUtils.js";import{I3SNodePageDefinition as Z,I3SMaterialDefinition as J,I3STextureSetDefinition as X,I3SGeometryDefinition as Y}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as ee,isFileSupported as te}from"./support/infoFor3D.js";import re from"./support/LabelClass.js";import{reader as ie}from"./support/labelingInfo.js";import se from"./support/LayerFloorInfo.js";import{layerLookupMap as oe}from"./support/lazyLayerLoader.js";import{RangeInfo as ae}from"./support/RangeInfo.js";import ne from"./support/SceneFilter.js";import{loadStyleRenderer as le}from"../renderers/support/styleUtils.js";import pe from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as de,elevationModeUnsupportedMessage as ye,featureExpressionUnsupportedMessage as ue}from"../support/elevationInfoUtils.js";import{sceneLayerEditingEnabled as ce}from"../support/featureFlags.js";import{createPopupTemplate as he}from"../support/popupUtils.js";import{extractZipFiles as fe}from"../support/zipUtils.js";import{queryAttributesFromCachedAttributesId as me}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as ge,getFetchPopupTemplate as ve}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as be}from"../webdoc/support/opacityUtils.js";const we=new Set(["3DObject","Point"]),Ie=H();let Le=class extends(T(E(x(S(P(A(O(p(_(F(o(I)))))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new a,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new z(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:Z.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&V(this.associatedLayer)}get geometryType(){return Fe[this.profile]||"mesh"}set renderer(e){W(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:q;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,w=!!this.associatedLayer?.infoFor3D&&ce();return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:w&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:w&&c&&b,supportsDelete:w&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&je[r]?je[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=null!=e?e.signal:null;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await le(this,{origin:"service"},t),W(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new pe;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryExtent(e||this.createQuery(),t)))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatureCount(e||this.createQuery(),t)))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatures(e||this.createQuery(),t))).then((e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this;return e}))}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=B(this.fieldsIndex,await ge(this,ve(this)));return me(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new n("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return he(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new n("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new n("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new n("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const i of this.statisticsInfo)if(i.name===r.name){const e=c(this.parsedUrl.path,i.href);return s(e,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new n("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(D.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(D.SAVE,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:o}=s,a=!!s.infoFor3D,l=i?.globalIdUsed??!0;if(a&&null==o)throw new n(`${this.type}-layer:not-editable`,"Valid globalIdField expected on editable SceneLayer");if(a&&!l)throw new n(`${this.type}-layer:globalid-required`,"globalIdUsed must not be false for SceneLayer editing as globalIds are required.");return U(s.url)&&a&&null!=e.deleteFeatures&&null!=o&&(i={...i,globalIdToObjectId:await M(s,e.deleteFeatures,o)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}async convertMesh(e,t){const r=e=>{throw l.getLogger(this).error(".convertMesh()",e.message),e};await this.load(),this.infoFor3D||r(new n("invalid:layer","SceneLayer has no capability for mesh conversion"));const i=await this.extractAndFilterFiles(e),s=i.reduce(((e,t)=>ee(this.infoFor3D,t)?e+1:e),0);0===s&&r(new L),s>1&&r(new j);const o=t?.location??new w({x:0,y:0,z:0,spatialReference:this.spatialReference}),a=b.createWithExternalSource(o,i),[p]=await this.uploadAssets([a],t);return p}async extractAndFilterFiles(e){await this.load();const t=this.infoFor3D;if(!t)return e;return(await fe(e)).filter((e=>te(t,e)))}validateLayer(e){if(e.layerType&&!we.has(e.layerType))throw new n("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new n("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new n("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new n("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new n("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new n("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=f(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===v.SERVICE||o===v.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.editingInfo?.lastEditDate,t=this.associatedLayer?.serverGens,r=this.associatedLayer?.getAtOrigin("fullExtent","service");if(!ce()||null==this.associatedLayer?.infoFor3D||!r||!U(this.associatedLayer?.url)||!e||this.serviceUpdateTimeStamp?.lastUpdate===e.getTime()||!this.serviceUpdateTimeStamp&&t?.minServerGen===t?.serverGen)return;f(this).setAtOrigin("fullExtent",r.clone(),v.SERVICE)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await R(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),s=await oe.FeatureLayer();this.associatedLayer=new s({url:t,customParameters:this.customParameters,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await u((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&de(l.getLogger(this),ye("Mesh scene layers","relative-to-scene",e)),de(l.getLogger(this),ue("Scene layers",e))}};e([h({types:{key:"type",base:K,typeMap:{selection:$}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],Le.prototype,"featureReduction",void 0),e([h({type:[ae],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],Le.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],Le.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],Le.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],Le.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],Le.prototype,"type",void 0),e([h({...Ie.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"fields",void 0),e([h()],Le.prototype,"types",null),e([h()],Le.prototype,"typeIdField",null),e([h()],Le.prototype,"templates",null),e([h()],Le.prototype,"formTemplate",null),e([h({readOnly:!0,clonable:!1})],Le.prototype,"fieldsIndex",null),e([h({type:se,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],Le.prototype,"floorInfo",void 0),e([h(Ie.outFields)],Le.prototype,"outFields",void 0),e([h({type:Z,readOnly:!0,json:{read:!1}})],Le.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],Le.prototype,"readNodePages",null),e([h({type:[J],readOnly:!0})],Le.prototype,"materialDefinitions",void 0),e([h({type:[X],readOnly:!0})],Le.prototype,"textureSetDefinitions",void 0),e([h({type:[Y],readOnly:!0})],Le.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],Le.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],Le.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],Le.prototype,"statisticsInfo",void 0),e([h({type:a.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],Le.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Le.prototype,"definitionExpression",void 0),e([h({type:ne,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Le.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Le.prototype,"path",void 0),e([h(C)],Le.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],Le.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],Le.prototype,"effectiveEditingEnabled",null),e([h({type:String})],Le.prototype,"geometryType",null),e([h(G)],Le.prototype,"labelsVisible",void 0),e([h({type:[re],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:ie},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:ie},write:!0}})],Le.prototype,"labelingInfo",void 0),e([h(Q)],Le.prototype,"legendEnabled",void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?be(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],Le.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"semantic",void 0),e([h({types:i,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Le.prototype,"renderer",null),e([h({json:{read:!1}})],Le.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],Le.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],Le.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],Le.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Le.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Le.prototype,"relationships",null),e([h(N)],Le.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],Le.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],Le.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],Le.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],Le.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],Le.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],Le.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],Le.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],Le.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],Le.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Le.prototype,"normalReferenceFrame",void 0),e([h(k)],Le.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"serviceItemId",void 0),Le=e([g("esri.layers.SceneLayer")],Le);const je={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},Fe={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},Se=Le;export{Se as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import"../renderers/support/jsonUtils.js";import{webSceneRendererTypes as i}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import a from"../core/Collection.js";import n from"../core/Error.js";import l from"../core/Logger.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,isAbortError as y}from"../core/promiseUtils.js";import{whenOnce as u}from"../core/reactiveUtils.js";import{join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as v}from"../core/accessorSupport/PropertyOrigin.js";import b from"../geometry/Mesh.js";import w from"../geometry/Point.js";import I from"./Layer.js";import{NoModelError as L,MultipleModelsError as j}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as F}from"./mixins/APIKeyMixin.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{CustomParametersMixin as _}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as E}from"./mixins/EditBusLayer.js";import{OperationalLayer as P}from"./mixins/OperationalLayer.js";import{PortalLayer as A}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{SceneService as x,SaveOperationType as D}from"./mixins/SceneService.js";import{TemporalSceneLayer as T}from"./mixins/TemporalSceneLayer.js";import{isHostedAgolService as U}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as R}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as q}from"./support/capabilities.js";import{elevationInfo as C,labelsVisible as G,legendEnabled as Q,popupEnabled as N,screenSizePerspectiveEnabled as k}from"./support/commonProperties.js";import{computeEffectiveEditingEnabled as V,getGlobalIdToObjectIdMap as M}from"./support/featureLayerUtils.js";import{FeatureReduction as K}from"./support/FeatureReduction.js";import $ from"./support/FeatureReductionSelection.js";import{defineFieldProperties as H}from"./support/fieldProperties.js";import z from"./support/FieldsIndex.js";import{fixRendererFields as W,unpackFieldNames as B}from"./support/fieldUtils.js";import{I3SNodePageDefinition as Z,I3SMaterialDefinition as J,I3STextureSetDefinition as X,I3SGeometryDefinition as Y}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as ee,isFileSupported as te}from"./support/infoFor3D.js";import re from"./support/LabelClass.js";import{reader as ie}from"./support/labelingInfo.js";import se from"./support/LayerFloorInfo.js";import{layerLookupMap as oe}from"./support/lazyLayerLoader.js";import{RangeInfo as ae}from"./support/RangeInfo.js";import ne from"./support/SceneFilter.js";import{loadStyleRenderer as le}from"../renderers/support/styleUtils.js";import pe from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as de,elevationModeUnsupportedMessage as ye,featureExpressionUnsupportedMessage as ue}from"../support/elevationInfoUtils.js";import{sceneLayerEditingEnabled as ce}from"../support/featureFlags.js";import{createPopupTemplate as he}from"../support/popupUtils.js";import{extractZipFiles as fe}from"../support/zipUtils.js";import{queryAttributesFromCachedAttributesId as me}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as ge,getFetchPopupTemplate as ve}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as be}from"../webdoc/support/opacityUtils.js";const we=new Set(["3DObject","Point"]),Ie=H();let Le=class extends(T(E(x(S(P(A(O(p(_(F(o(I)))))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new a,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new z(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:Z.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&V(this.associatedLayer)}get geometryType(){return Fe[this.profile]||"mesh"}set renderer(e){W(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:q;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,w=!!this.associatedLayer?.infoFor3D&&ce();return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:w&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:w&&c&&b,supportsDelete:w&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&je[r]?je[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=null!=e?e.signal:null;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await le(this,{origin:"service"},t),W(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new pe;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryExtent(e||this.createQuery(),t)))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatureCount(e||this.createQuery(),t)))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatures(e||this.createQuery(),t))).then((e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this;return e}))}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=B(this.fieldsIndex,await ge(this,ve(this)));return me(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new n("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return he(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new n("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new n("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new n("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const i of this.statisticsInfo)if(i.name===r.name){const e=c(this.parsedUrl.path,i.href);return s(e,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new n("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(D.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(D.SAVE,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:o}=s,a=!!s.infoFor3D,l=i?.globalIdUsed??!0;if(a&&null==o)throw new n(`${this.type}-layer:not-editable`,"Valid globalIdField expected on editable SceneLayer");if(a&&!l)throw new n(`${this.type}-layer:globalid-required`,"globalIdUsed must not be false for SceneLayer editing as globalIds are required.");return U(s.url)&&a&&null!=e.deleteFeatures&&null!=o&&(i={...i,globalIdToObjectId:await M(s,e.deleteFeatures,o)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}async convertMesh(e,t){const r=e=>{throw l.getLogger(this).error(".convertMesh()",e.message),e};await this.load(),this.infoFor3D||r(new n("invalid:layer","SceneLayer has no capability for mesh conversion"));const i=await this.extractAndFilterFiles(e),s=i.reduce(((e,t)=>ee(this.infoFor3D,t)?e+1:e),0);0===s&&r(new L),s>1&&r(new j);const o=this.spatialReference,a=t?.location??new w({x:0,y:0,z:0,spatialReference:o}),p=t?.vertexSpace,d=b.createWithExternalSource(a,i,{vertexSpace:p}),[y]=await this.uploadAssets([d],t);return y}async extractAndFilterFiles(e){await this.load();const t=this.infoFor3D;if(!t)return e;return(await fe(e)).filter((e=>te(t,e)))}validateLayer(e){if(e.layerType&&!we.has(e.layerType))throw new n("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new n("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new n("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new n("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new n("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new n("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=f(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===v.SERVICE||o===v.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.editingInfo?.lastEditDate,t=this.associatedLayer?.serverGens,r=this.associatedLayer?.getAtOrigin("fullExtent","service");if(!ce()||null==this.associatedLayer?.infoFor3D||!r||!U(this.associatedLayer?.url)||!e||this.serviceUpdateTimeStamp?.lastUpdate===e.getTime()||!this.serviceUpdateTimeStamp&&t?.minServerGen===t?.serverGen)return;f(this).setAtOrigin("fullExtent",r.clone(),v.SERVICE)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await R(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),s=await oe.FeatureLayer();this.associatedLayer=new s({url:t,customParameters:this.customParameters,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await u((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&de(l.getLogger(this),ye("Mesh scene layers","relative-to-scene",e)),de(l.getLogger(this),ue("Scene layers",e))}};e([h({types:{key:"type",base:K,typeMap:{selection:$}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],Le.prototype,"featureReduction",void 0),e([h({type:[ae],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],Le.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],Le.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],Le.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],Le.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],Le.prototype,"type",void 0),e([h({...Ie.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"fields",void 0),e([h()],Le.prototype,"types",null),e([h()],Le.prototype,"typeIdField",null),e([h()],Le.prototype,"templates",null),e([h()],Le.prototype,"formTemplate",null),e([h({readOnly:!0,clonable:!1})],Le.prototype,"fieldsIndex",null),e([h({type:se,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],Le.prototype,"floorInfo",void 0),e([h(Ie.outFields)],Le.prototype,"outFields",void 0),e([h({type:Z,readOnly:!0,json:{read:!1}})],Le.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],Le.prototype,"readNodePages",null),e([h({type:[J],readOnly:!0})],Le.prototype,"materialDefinitions",void 0),e([h({type:[X],readOnly:!0})],Le.prototype,"textureSetDefinitions",void 0),e([h({type:[Y],readOnly:!0})],Le.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],Le.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],Le.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],Le.prototype,"statisticsInfo",void 0),e([h({type:a.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],Le.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Le.prototype,"definitionExpression",void 0),e([h({type:ne,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Le.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Le.prototype,"path",void 0),e([h(C)],Le.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],Le.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],Le.prototype,"effectiveEditingEnabled",null),e([h({type:String})],Le.prototype,"geometryType",null),e([h(G)],Le.prototype,"labelsVisible",void 0),e([h({type:[re],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:ie},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:ie},write:!0}})],Le.prototype,"labelingInfo",void 0),e([h(Q)],Le.prototype,"legendEnabled",void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?be(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],Le.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"semantic",void 0),e([h({types:i,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Le.prototype,"renderer",null),e([h({json:{read:!1}})],Le.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],Le.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],Le.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],Le.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Le.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Le.prototype,"relationships",null),e([h(N)],Le.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],Le.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],Le.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],Le.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],Le.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],Le.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],Le.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],Le.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],Le.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],Le.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Le.prototype,"normalReferenceFrame",void 0),e([h(k)],Le.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],Le.prototype,"serviceItemId",void 0),Le=e([g("esri.layers.SceneLayer")],Le);const je={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},Fe={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},Se=Le;export{Se as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{id as t}from"../../../kernel.js";import s from"../../../request.js";import r from"../../../TimeExtent.js";import{isSome as a}from"../../../core/arrayUtils.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as o}from"../../../core/jsonMap.js";import n from"../../../core/Loadable.js";import u from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as c,after as d,throwIfAbortError as p}from"../../../core/promiseUtils.js";import{join as y}from"../../../core/urlUtils.js";import{generateBracedUUID as h}from"../../../core/uuid.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Extent.js";import{isRelativeVertexSpace as w,toRelativeVertexSpace as S}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as q}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as E,getFeatureJSON as O,getFeatureIds as R,getAttachmentEditsJSON as b,isProtectedOrPrivateVersionError as A,unpackEditResultData as F,createEditedFeatures as _}from"../applyEditsUtils.js";import{createDrawingInfo as x}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as I}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as v}from"../../support/featureLayerUtils.js";import{getAssetMapTable as T}from"../../support/infoFor3D.js";import{executeQueryJSON as N}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as M}from"../../../rest/query/operations/editsZScale.js";import U from"../../../rest/support/Query.js";import{isSafeToEditVersion as J,isVersionInEditSession as k,currentSessionId as C}from"../../../versionManagement/support/versionManagementUtils.js";import L from"../../../geometry/SpatialReference.js";const Q=new o({originalAndCurrentFeatures:"original-and-current-features",none:"none"}),D=new Set(["Feature Layer","Oriented Imagery Layer","Table","Catalog Layer"]),P=new o({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let V=class extends n{constructor(){super(...arguments),this.type="feature-layer",this.refresh=c((async()=>{await this.load();const e=this.sourceJSON.editingInfo?.lastEditDate;if(null==e)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}const t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}})),this._ongoingAssetUploads=new Map}load(e){const t=this.layer.sourceJSON,s=this._fetchService(t,{...e}).then((()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e))).then((()=>this._ensureLatestMetadata(e)));return this.addResolvingPromise(s),Promise.resolve(this)}get queryTask(){const{capabilities:e,parsedUrl:t,dynamicDataSource:s,infoFor3D:r,gdbVersion:a,spatialReference:i,fieldsIndex:o}=this.layer,n=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&null==r,u=e?.operations?.supportsQueryAttachments??!1;return new j({url:t.path,pbfSupported:n,fieldsIndex:o,infoFor3D:r,dynamicDataSource:s,gdbVersion:a,sourceSpatialReference:i,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const{layer:r}=this;await v(r,"editing");const a=e.attributes[r.objectIdField],i=r.parsedUrl.path+"/"+a+"/addAttachment",o=this._getLayerRequestOptions(),n=this._getFormDataForAttachment(t,o.query);try{const e=await s(i,{body:n});return E(e.data.addAttachmentResult)}catch(u){throw this._createAttachmentErrorResult(a,u)}}async updateAttachment(e,t,r){await this.load();const{layer:a}=this;await v(a,"editing");const i=e.attributes[a.objectIdField],o=a.parsedUrl.path+"/"+i+"/updateAttachment",n=this._getLayerRequestOptions({query:{attachmentId:t}}),u=this._getFormDataForAttachment(r,n.query);try{const e=await s(o,{body:u});return E(e.data.updateAttachmentResult)}catch(l){throw this._createAttachmentErrorResult(i,l)}}async applyEdits(e,r){await this.load();const{layer:i}=this;await v(i,"editing");const o=i.infoFor3D,n=null!=o,u=n||(r?.globalIdUsed??!1),l=n?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,c=e.addFeatures?.map((e=>O(this.layer,e,o)))??[],d=(await Promise.all(c)).filter(a),p=e.updateFeatures?.map((e=>O(this.layer,e,o)))??[],y=(await Promise.all(p)).filter(a),h=R(this.layer,e.deleteFeatures,u);M(d,y,i.spatialReference);const m=await b(this.layer,e),f=i.capabilities.editing.supportsAsyncApplyEdits&&n,g=r?.gdbVersion||i.gdbVersion,w={gdbVersion:g,rollbackOnFailure:r?.rollbackOnFailureEnabled,useGlobalIds:u,returnEditMoment:r?.returnEditMoment,usePreviousEditMoment:r?.usePreviousEditMoment,async:f};await J(this.layer.url,g,!0);const S=k(this.layer.url,g||null);r?.returnServiceEditsOption?(w.edits=JSON.stringify([{id:i.layerId,adds:d,updates:y,deletes:h,attachments:m,assetMaps:l}]),w.returnServiceEditsOption=Q.toJSON(r?.returnServiceEditsOption),w.returnServiceEditsInSourceSR=r?.returnServiceEditsInSourceSR):(w.adds=d.length?JSON.stringify(d):null,w.updates=y.length?JSON.stringify(y):null,w.deletes=h.length?u?JSON.stringify(h):h.join(","):null,w.attachments=m&&JSON.stringify(m),w.assetMaps=null!=l?JSON.stringify(l):void 0);const q=this._getLayerRequestOptions({method:"post",query:w});S&&(q.authMode="immediate",q.query.returnEditMoment=!0,q.query.sessionId=C);const E=r?.returnServiceEditsOption?i.url:i.parsedUrl.path;let F;try{F=f?await this._asyncApplyEdits(E+"/applyEdits",q):await s(E+"/applyEdits",q)}catch(_){if(!A(_))throw _;q.authMode="immediate",F=f?await this._asyncApplyEdits(E+"/applyEdits",q):await s(E+"/applyEdits",q)}if(!i.capabilities.operations?.supportsEditing&&i.effectiveCapabilities?.operations?.supportsEditing){const e=t?.findCredential(i.url);await(e?.refreshToken())}return this._createEditsResult(F)}async deleteAttachments(e,t){await this.load();const{layer:r}=this;await v(r,"editing");const a=e.attributes[r.objectIdField],i=r.parsedUrl.path+"/"+a+"/deleteAttachments";try{return(await s(i,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(E)}catch(o){throw this._createAttachmentErrorResult(a,o)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:a,url:i}=this.layer,{data:o}=await s(`${i}/${a}`,t),{id:n,extent:u,fullExtent:l,timeExtent:c}=o,d=u||l;return{id:n,fullExtent:d&&g.fromJSON(d),timeExtent:c&&r.fromJSON({start:c[0],end:c[1]})}}))}async queryAttachments(e,t={}){await this.load();const s=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,s)}async queryFeatures(e,t){await this.load();const s=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});return e.outStatistics?.length&&s.features.length&&s.features.forEach((t=>{const s=t.attributes;e.outStatistics?.forEach((({outStatisticFieldName:e})=>{if(e){const t=e.toLowerCase();t&&t in s&&e!==t&&(s[e]=s[t],delete s[t])}}))})),s}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!I(this.layer.url))return"unavailable";const e=y(this.layer.url,"status"),t=await s(e,{query:{f:"json"}});return P.fromJSON(t.data.status)}async uploadAssets(e,t){const{uploadAssets:s}=await import("./support/uploadAssets.js");return s(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}async _asyncApplyEdits(e,t){const r=(await s(e,t)).data.statusUrl;for(;;){const e=(await s(r,{query:{f:"json"},responseType:"json"})).data;switch(e.status){case"Completed":return s(e.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new i("async-applyEdits-failed","asynchronous applyEdits call failed.");case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new i("async-applyEdits-failed","asynchronous applyEdits call failed (undefined response status)")}await d($)}}_createRequestQueryOptions(e){const t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){const r={};has("featurelayer-advanced-symbols")&&(r.returnAdvancedSymbols=!0),t?.cacheBust&&(r._ts=Date.now());const{data:a}=await s(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:r,signal:t?.signal}));e=a}this.sourceJSON=await this._patchServiceJSON(e,t?.signal);const r=e.type;if(!D.has(r))throw new i("feature-layer-source:unsupported-type",`Source type "${r}" is not supported`)}async _patchServiceJSON(e,t){if("Table"!==e.type&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){const t=x(e.geometryType).renderer;l("drawingInfo.renderer",t,e)}if("esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),null==e.extent)try{const{data:r}=await s(this.layer.url,this._getLayerRequestOptions({signal:t}));r.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:r.spatialReference})}catch(r){p(r)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){const{addAssetFeatures:t}=e;if(!t?.length)return null;const s=await this._filterRedundantAssetMaps(t);if(!t?.length)return null;const r=new Array,a=new Map;for(const i of s){const{geometry:e}=i,{vertexSpace:t}=e;if(w(t))r.push(e);else{const t=S(e);a.set(t,e),i.geometry=t,r.push(t)}}await this.uploadAssets(r);for(const[i,o]of a)o.addExternalSources(i.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(s),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){const t=new Array,s=this.layer.globalIdField,r=this.layer.parsedUrl;for(const a of e){const e=a.geometry,{metadata:i}=e,o=i.getExternalSourcesOnService(r),n=a.getAttribute(s);if(0===o.length){u.getLogger(this).error(`Skipping feature ${n}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}const{source:l}=o.find(q)??o[0],{vertexSpace:c}=e,d="georeferenced"===c.type?["PROJECT_VERTICES"]:[];for(const s of l)1===s.parts.length?t.push({globalId:h(),parentGlobalId:n,assetName:s.assetName,assetHash:s.parts[0].partHash,flags:d}):u.getLogger(this).error(`Skipping asset ${s.assetName}. It does not have exactly one part, so we cannot map it to a feature.`)}return t}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,r=[];let a=null;if(Array.isArray(t))for(const o of t)r.push({id:o.id,editedFeatures:o.editedFeatures}),o.id===s&&(a={addResults:o.addResults??[],updateResults:o.updateResults??[],deleteResults:o.deleteResults??[],attachments:o.attachments,editMoment:o.editMoment});else a=t;const i=F(a);if(r.length>0){i.editedFeatureResults=[];for(const e of r){const{editedFeatures:t}=e,s=t?.spatialReference?new L(t.spatialReference):null;i.editedFeatureResults.push({layerId:e.id,editedFeatures:_(t,s)})}}return i}_createAttachmentErrorResult(e,t){const s=t.details.messages?.[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new i("feature-layer-source:attachment-failure",s,{code:r})}}_getFormDataForAttachment(e,t){const s=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(s)for(const r in t){const e=t[r];null!=e&&(s.set?s.set(r,e):s.append(r,e))}return s}_getLayerRequestOptions(e={}){const{parsedUrl:t,gdbVersion:s,dynamicDataSource:r}=this.layer;return{...e,query:{gdbVersion:s,layer:r?JSON.stringify({source:r}):void 0,...t.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}async _filterRedundantAssetMaps(e){const{layer:t}=this,{globalIdField:s,infoFor3D:r,parsedUrl:i}=t;if(null==r||null==s)return e;const o=T(r);if(null==o)return e;const n=y(i.path,`../${o.id}`),u=new Array,l=new Array;for(const a of e)a.geometry.metadata.getExternalSourcesOnService(i).length>0?l.push(a):u.push(a);const c=l.map((e=>e.getAttribute(s))).filter(a);if(0===c.length)return e;const{assetMapFieldRoles:{parentGlobalId:d,assetHash:p}}=r,h=new U;h.where=`${d} IN (${c.map((e=>`'${e}'`))})`,h.outFields=[p,d],h.returnGeometry=!1;const m=await N(n,h),{features:f}=m;return 0===f.length?e:[...u,...l.filter((e=>{const t=e.getAttribute(s);if(!t)return!0;const{metadata:r}=e.geometry,a=f.filter((e=>e.getAttribute(d)===t));if(0===a.length)return!0;const o=a.map((e=>e.getAttribute(p)));return r.getExternalSourcesOnService(i).flatMap((({source:e})=>e.flatMap((e=>e.parts.map((e=>e.partHash)))))).some((e=>o.every((t=>e!==t))))}))]}};e([m()],V.prototype,"type",void 0),e([m({constructOnly:!0})],V.prototype,"layer",void 0),e([m({readOnly:!0})],V.prototype,"queryTask",null),V=e([f("esri.layers.graphics.sources.FeatureLayerSource")],V);const $=1e3,G=V;export{G as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{id as t}from"../../../kernel.js";import s from"../../../request.js";import r from"../../../TimeExtent.js";import{isSome as a}from"../../../core/arrayUtils.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as o}from"../../../core/jsonMap.js";import n from"../../../core/Loadable.js";import u from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as c,after as d,throwIfAbortError as p}from"../../../core/promiseUtils.js";import{join as y}from"../../../core/urlUtils.js";import{generateBracedUUID as h}from"../../../core/uuid.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Extent.js";import{isRelativeVertexSpace as w,toRelativeVertexSpace as S}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as q}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as E,getFeatureJSON as O,getFeatureIds as R,getAttachmentEditsJSON as b,isProtectedOrPrivateVersionError as A,unpackEditResultData as F,createEditedFeatures as _}from"../applyEditsUtils.js";import{createDrawingInfo as x}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as I}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as v}from"../../support/featureLayerUtils.js";import{getAssetMapTable as T}from"../../support/infoFor3D.js";import{executeQueryJSON as N}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as M}from"../../../rest/query/operations/editsZScale.js";import U from"../../../rest/support/Query.js";import{isSafeToEditVersion as J,isVersionInEditSession as k,isHistoricVersion as C,currentSessionId as L}from"../../../versionManagement/support/versionManagementUtils.js";import Q from"../../../geometry/SpatialReference.js";const D=new o({originalAndCurrentFeatures:"original-and-current-features",none:"none"}),P=new Set(["Feature Layer","Oriented Imagery Layer","Table","Catalog Layer"]),V=new o({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let $=class extends n{constructor(){super(...arguments),this.type="feature-layer",this.refresh=c((async()=>{await this.load();const e=this.sourceJSON.editingInfo?.lastEditDate;if(null==e)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}const t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}})),this._ongoingAssetUploads=new Map}load(e){const t=this.layer.sourceJSON,s=this._fetchService(t,{...e}).then((()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e))).then((()=>this._ensureLatestMetadata(e)));return this.addResolvingPromise(s),Promise.resolve(this)}get queryTask(){const{capabilities:e,parsedUrl:t,dynamicDataSource:s,infoFor3D:r,gdbVersion:a,spatialReference:i,fieldsIndex:o}=this.layer,n=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&null==r,u=e?.operations?.supportsQueryAttachments??!1;return new j({url:t.path,pbfSupported:n,fieldsIndex:o,infoFor3D:r,dynamicDataSource:s,gdbVersion:a,sourceSpatialReference:i,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const{layer:r}=this;await v(r,"editing");const a=e.attributes[r.objectIdField],i=r.parsedUrl.path+"/"+a+"/addAttachment",o=this._getLayerRequestOptions(),n=this._getFormDataForAttachment(t,o.query);try{const e=await s(i,{body:n});return E(e.data.addAttachmentResult)}catch(u){throw this._createAttachmentErrorResult(a,u)}}async updateAttachment(e,t,r){await this.load();const{layer:a}=this;await v(a,"editing");const i=e.attributes[a.objectIdField],o=a.parsedUrl.path+"/"+i+"/updateAttachment",n=this._getLayerRequestOptions({query:{attachmentId:t}}),u=this._getFormDataForAttachment(r,n.query);try{const e=await s(o,{body:u});return E(e.data.updateAttachmentResult)}catch(l){throw this._createAttachmentErrorResult(i,l)}}async applyEdits(e,r){await this.load();const{layer:o}=this;await v(o,"editing");const n=o.infoFor3D,u=null!=n,l=u||(r?.globalIdUsed??!1),c=u?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,d=e.addFeatures?.map((e=>O(this.layer,e,n)))??[],p=(await Promise.all(d)).filter(a),y=e.updateFeatures?.map((e=>O(this.layer,e,n)))??[],h=(await Promise.all(y)).filter(a),m=R(this.layer,e.deleteFeatures,l);M(p,h,o.spatialReference);const f=await b(this.layer,e),g=o.capabilities.editing.supportsAsyncApplyEdits&&u,w=r?.gdbVersion||o.gdbVersion,S={gdbVersion:w,rollbackOnFailure:r?.rollbackOnFailureEnabled,useGlobalIds:l,returnEditMoment:r?.returnEditMoment,usePreviousEditMoment:r?.usePreviousEditMoment,async:g};await J(this.layer.url,w,!0);const q=k(this.layer.url,w||null);if(await C(o.url,w,o.historicMoment))throw new i("feature-layer-source:historic-version","Editing a historic version is not allowed");r?.returnServiceEditsOption?(S.edits=JSON.stringify([{id:o.layerId,adds:p,updates:h,deletes:m,attachments:f,assetMaps:c}]),S.returnServiceEditsOption=D.toJSON(r?.returnServiceEditsOption),S.returnServiceEditsInSourceSR=r?.returnServiceEditsInSourceSR):(S.adds=p.length?JSON.stringify(p):null,S.updates=h.length?JSON.stringify(h):null,S.deletes=m.length?l?JSON.stringify(m):m.join(","):null,S.attachments=f&&JSON.stringify(f),S.assetMaps=null!=c?JSON.stringify(c):void 0);const E=this._getLayerRequestOptions({method:"post",query:S});q&&(E.authMode="immediate",E.query.returnEditMoment=!0,E.query.sessionId=L);const F=r?.returnServiceEditsOption?o.url:o.parsedUrl.path;let _;try{_=g?await this._asyncApplyEdits(F+"/applyEdits",E):await s(F+"/applyEdits",E)}catch(x){if(!A(x))throw x;E.authMode="immediate",_=g?await this._asyncApplyEdits(F+"/applyEdits",E):await s(F+"/applyEdits",E)}if(!o.capabilities.operations?.supportsEditing&&o.effectiveCapabilities?.operations?.supportsEditing){const e=t?.findCredential(o.url);await(e?.refreshToken())}return this._createEditsResult(_)}async deleteAttachments(e,t){await this.load();const{layer:r}=this;await v(r,"editing");const a=e.attributes[r.objectIdField],i=r.parsedUrl.path+"/"+a+"/deleteAttachments";try{return(await s(i,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(E)}catch(o){throw this._createAttachmentErrorResult(a,o)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:a,url:i}=this.layer,{data:o}=await s(`${i}/${a}`,t),{id:n,extent:u,fullExtent:l,timeExtent:c}=o,d=u||l;return{id:n,fullExtent:d&&g.fromJSON(d),timeExtent:c&&r.fromJSON({start:c[0],end:c[1]})}}))}async queryAttachments(e,t={}){await this.load();const s=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,s)}async queryFeatures(e,t){await this.load();const s=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});return e.outStatistics?.length&&s.features.length&&s.features.forEach((t=>{const s=t.attributes;e.outStatistics?.forEach((({outStatisticFieldName:e})=>{if(e){const t=e.toLowerCase();t&&t in s&&e!==t&&(s[e]=s[t],delete s[t])}}))})),s}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!I(this.layer.url))return"unavailable";const e=y(this.layer.url,"status"),t=await s(e,{query:{f:"json"}});return V.fromJSON(t.data.status)}async uploadAssets(e,t){const{uploadAssets:s}=await import("./support/uploadAssets.js");return s(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}async _asyncApplyEdits(e,t){const r=(await s(e,t)).data.statusUrl;for(;;){const e=(await s(r,{query:{f:"json"},responseType:"json"})).data;switch(e.status){case"Completed":return s(e.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new i("async-applyEdits-failed","asynchronous applyEdits call failed.");case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new i("async-applyEdits-failed","asynchronous applyEdits call failed (undefined response status)")}await d(G)}}_createRequestQueryOptions(e){const t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){const r={};has("featurelayer-advanced-symbols")&&(r.returnAdvancedSymbols=!0),t?.cacheBust&&(r._ts=Date.now());const{data:a}=await s(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:r,signal:t?.signal}));e=a}this.sourceJSON=await this._patchServiceJSON(e,t?.signal);const r=e.type;if(!P.has(r))throw new i("feature-layer-source:unsupported-type",`Source type "${r}" is not supported`)}async _patchServiceJSON(e,t){if("Table"!==e.type&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){const t=x(e.geometryType).renderer;l("drawingInfo.renderer",t,e)}if("esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),null==e.extent)try{const{data:r}=await s(this.layer.url,this._getLayerRequestOptions({signal:t}));r.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:r.spatialReference})}catch(r){p(r)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){const{addAssetFeatures:t}=e;if(!t?.length)return null;const s=await this._filterRedundantAssetMaps(t);if(!t?.length)return null;const r=new Array,a=new Map;for(const i of s){const{geometry:e}=i,{vertexSpace:t}=e;if(w(t))r.push(e);else{const t=S(e);a.set(t,e),i.geometry=t,r.push(t)}}await this.uploadAssets(r);for(const[i,o]of a)o.addExternalSources(i.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(s),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){const t=new Array,s=this.layer.globalIdField,r=this.layer.parsedUrl;for(const a of e){const e=a.geometry,{metadata:i}=e,o=i.getExternalSourcesOnService(r),n=a.getAttribute(s);if(0===o.length){u.getLogger(this).error(`Skipping feature ${n}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}const{source:l}=o.find(q)??o[0],{vertexSpace:c}=e,d="georeferenced"===c.type?["PROJECT_VERTICES"]:[];for(const s of l)1===s.parts.length?t.push({globalId:h(),parentGlobalId:n,assetName:s.assetName,assetHash:s.parts[0].partHash,flags:d}):u.getLogger(this).error(`Skipping asset ${s.assetName}. It does not have exactly one part, so we cannot map it to a feature.`)}return t}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,r=[];let a=null;if(Array.isArray(t))for(const o of t)r.push({id:o.id,editedFeatures:o.editedFeatures}),o.id===s&&(a={addResults:o.addResults??[],updateResults:o.updateResults??[],deleteResults:o.deleteResults??[],attachments:o.attachments,editMoment:o.editMoment});else a=t;const i=F(a);if(r.length>0){i.editedFeatureResults=[];for(const e of r){const{editedFeatures:t}=e,s=t?.spatialReference?new Q(t.spatialReference):null;i.editedFeatureResults.push({layerId:e.id,editedFeatures:_(t,s)})}}return i}_createAttachmentErrorResult(e,t){const s=t.details.messages?.[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new i("feature-layer-source:attachment-failure",s,{code:r})}}_getFormDataForAttachment(e,t){const s=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(s)for(const r in t){const e=t[r];null!=e&&(s.set?s.set(r,e):s.append(r,e))}return s}_getLayerRequestOptions(e={}){const{parsedUrl:t,gdbVersion:s,dynamicDataSource:r}=this.layer;return{...e,query:{gdbVersion:s,layer:r?JSON.stringify({source:r}):void 0,...t.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}async _filterRedundantAssetMaps(e){const{layer:t}=this,{globalIdField:s,infoFor3D:r,parsedUrl:i}=t;if(null==r||null==s)return e;const o=T(r);if(null==o)return e;const n=y(i.path,`../${o.id}`),u=new Array,l=new Array;for(const a of e)a.geometry.metadata.getExternalSourcesOnService(i).length>0?l.push(a):u.push(a);const c=l.map((e=>e.getAttribute(s))).filter(a);if(0===c.length)return e;const{assetMapFieldRoles:{parentGlobalId:d,assetHash:p}}=r,h=new U;h.where=`${d} IN (${c.map((e=>`'${e}'`))})`,h.outFields=[p,d],h.returnGeometry=!1;const m=await N(n,h),{features:f}=m;return 0===f.length?e:[...u,...l.filter((e=>{const t=e.getAttribute(s);if(!t)return!0;const{metadata:r}=e.geometry,a=f.filter((e=>e.getAttribute(d)===t));if(0===a.length)return!0;const o=a.map((e=>e.getAttribute(p)));return r.getExternalSourcesOnService(i).flatMap((({source:e})=>e.flatMap((e=>e.parts.map((e=>e.partHash)))))).some((e=>o.every((t=>e!==t))))}))]}};e([m()],$.prototype,"type",void 0),e([m({constructOnly:!0})],$.prototype,"layer",void 0),e([m({readOnly:!0})],$.prototype,"queryTask",null),$=e([f("esri.layers.graphics.sources.FeatureLayerSource")],$);const G=1e3,H=$;export{H as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as i}from"../../core/lang.js";import l from"../../core/Logger.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as o}from"../../core/accessorSupport/decorators/cast.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{SimpleBandStatistics as a}from"./SimpleBandStatistics.js";import{getPixelValueRange as h}from"./rasterFormats/pixelRangeUtils.js";var p;let c=p=class extends s{static createEmptyBand(t,e){return new(p.getPixelArrayConstructor(t))(e)}static combineBandMasks(t){if(t.length<2)return t[0];const e=t[0].length,s=new Uint8Array(e).fill(255);for(let i=0;i<t.length;i++){const l=t[i];for(let t=0;t<e;t++)l[t]||(s[t]=0)}return s}static getPixelArrayConstructor(t){let e;switch(t){case"u1":case"u2":case"u4":case"u8":e=Uint8Array;break;case"u16":e=Uint16Array;break;case"u32":e=Uint32Array;break;case"s8":e=Int8Array;break;case"s16":e=Int16Array;break;case"s32":e=Int32Array;break;case"f32":case"c64":case"c128":case"unknown":e=Float32Array;break;case"f64":e=Float64Array}return e}constructor(t){super(t),this.width=null,this.height=null,this.pixelType="f32",this.validPixelCount=null,this.mask=null,this.maskIsAlpha=!1,this.premultiplyAlpha=!1,this.statistics=null,this.depthCount=1}castPixelType(t){if(!t)return"f32";let e=t.toLowerCase();return["u1","u2","u4"].includes(e)?e="u8":["unknown","u8","s8","u16","s16","u32","s32","f32","f64"].includes(e)||(e="f32"),e}getPlaneCount(){return this.pixels?.length}addData(t){if(!t.pixels||t.pixels.length!==this.width*this.height)throw new e("pixelblock:invalid-or-missing-pixels","add data requires valid pixels array that has same length defined by pixel block width * height");this.pixels||(this.pixels=[]),this.statistics||(this.statistics=[]),this.pixels.push(t.pixels),this.statistics.push(t.statistics??new a)}getAsRGBA(){const t=new ArrayBuffer(this.width*this.height*4);switch(this.pixelType){case"s8":case"s16":case"u16":case"s32":case"u32":case"f32":case"f64":this._fillFromNon8Bit(t);break;default:this._fillFrom8Bit(t)}return new Uint8ClampedArray(t)}getAsRGBAFloat(){const t=new Float32Array(this.width*this.height*4);return this._fillFrom32Bit(t),t}updateStatistics(){if(!this.pixels)return;this.statistics=this.pixels.map((t=>this._calculateBandStatistics(t,this.mask)));const t=this.mask;let e=0;if(null!=t)for(let s=0;s<t.length;s++)t[s]&&e++;else e=this.width*this.height;this.validPixelCount=e}clamp(t){if(!t||"f64"===t||"f32"===t||!this.pixels)return;const[e,s]=h(t),i=this.pixels,l=this.width*this.height,r=i.length;let o,n,a;const c=[];for(let h=0;h<r;h++){a=p.createEmptyBand(t,l),o=i[h];for(let t=0;t<l;t++)n=o[t],a[t]=n>s?s:n<e?e:n;c.push(a)}this.pixels=c,this.pixelType=t}extractBands(t){const{pixels:e,statistics:s}=this;if(null==t||0===t.length||!e||0===e.length)return this;const i=e.length,l=t.some((t=>t>=e.length)),r=i===t.length&&!t.some(((t,e)=>t!==e));if(l||r)return this;const o=this.bandMasks?.length===i?t.map((t=>this.bandMasks[t])):void 0;let{mask:n,validPixelCount:a}=this;const{width:h,height:c}=this;return o?.length&&(n=p.combineBandMasks(o),a=n.filter((t=>!!t)).length),new p({pixelType:this.pixelType,width:h,height:c,mask:n,bandMasks:o,validPixelCount:a,maskIsAlpha:this.maskIsAlpha,pixels:t.map((t=>e[t])),statistics:s&&t.map((t=>s[t]))})}clone(){const t=new p({width:this.width,height:this.height,pixelType:this.pixelType,maskIsAlpha:this.maskIsAlpha,validPixelCount:this.validPixelCount});let e;null!=this.mask&&(this.mask instanceof Uint8Array?t.mask=new Uint8Array(this.mask):t.mask=this.mask.slice(0)),this.bandMasks&&(t.bandMasks=this.bandMasks.map((t=>new Uint8Array(t))));const s=p.getPixelArrayConstructor(this.pixelType);if(this.pixels&&this.pixels.length>0){t.pixels=[];const i=!!this.pixels[0].slice;for(e=0;e<this.pixels.length;e++)t.pixels[e]=i?this.pixels[e].slice(0,this.pixels[e].length):new s(this.pixels[e])}if(this.statistics)for(t.statistics=[],e=0;e<this.statistics.length;e++)t.statistics[e]=i(this.statistics[e]);return t.premultiplyAlpha=this.premultiplyAlpha,t}_fillFrom8Bit(t){const{mask:e,maskIsAlpha:s,premultiplyAlpha:i,pixels:r}=this;if(!t||!r?.length)return void l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");let o,n,a,h;o=n=a=r[0],r.length>=3?(n=r[1],a=r[2]):2===r.length&&(n=r[1]);const p=new Uint32Array(t),c=this.width*this.height;if(o.length===c)if(null!=e&&e.length===c)if(s)for(h=0;h<c;h++){const t=e[h];if(t){const e=t/255;p[h]=i?t<<24|a[h]*e<<16|n[h]*e<<8|o[h]*e:t<<24|a[h]<<16|n[h]<<8|o[h]}}else for(h=0;h<c;h++)e[h]&&(p[h]=255<<24|a[h]<<16|n[h]<<8|o[h]);else for(h=0;h<c;h++)p[h]=255<<24|a[h]<<16|n[h]<<8|o[h];else l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.")}_fillFromNon8Bit(t){const{pixels:e,mask:s,statistics:i}=this;if(!t||!e?.length)return void l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");const r=this.pixelType;let o=1,n=0,a=1;if(i&&i.length>0){for(const t of i)if(null!=t.minValue&&(n=Math.min(n,t.minValue)),null!=t.maxValue&&null!=t.minValue){const e=t.maxValue-t.minValue;a=Math.max(a,e)}o=255/a}else{let t=255;"s8"===r?(n=-128,t=127):"u16"===r?t=65535:"s16"===r?(n=-32768,t=32767):"u32"===r?t=4294967295:"s32"===r?(n=-2147483648,t=2147483647):"f32"===r?(n=-34e38,t=34e38):"f64"===r&&(n=-Number.MAX_VALUE,t=Number.MAX_VALUE),o=255/(t-n)}const h=new Uint32Array(t),p=this.width*this.height;let c,u,g,f,m;if(c=u=g=e[0],c.length!==p)return l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.");if(e.length>=2)if(u=e[1],e.length>=3&&(g=e[2]),null!=s&&s.length===p)for(f=0;f<p;f++)s[f]&&(h[f]=255<<24|(g[f]-n)*o<<16|(u[f]-n)*o<<8|(c[f]-n)*o);else for(f=0;f<p;f++)h[f]=255<<24|(g[f]-n)*o<<16|(u[f]-n)*o<<8|(c[f]-n)*o;else if(null!=s&&s.length===p)for(f=0;f<p;f++)m=(c[f]-n)*o,s[f]&&(h[f]=255<<24|m<<16|m<<8|m);else for(f=0;f<p;f++)m=(c[f]-n)*o,h[f]=255<<24|m<<16|m<<8|m}_fillFrom32Bit(t){const{pixels:e,mask:s}=this;if(!t||!e?.length)return l.getLogger(this).error("getAsRGBAFloat()","Unable to convert to RGBA. The input pixel block is empty.");let i,r,o,n;i=r=o=e[0],e.length>=3?(r=e[1],o=e[2]):2===e.length&&(r=e[1]);const a=this.width*this.height;if(i.length!==a)return l.getLogger(this).error("getAsRGBAFloat()","Unable to convert to RGBA. The pixelblock is invalid.");let h=0;if(null!=s&&s.length===a)for(n=0;n<a;n++)t[h++]=i[n],t[h++]=r[n],t[h++]=o[n],t[h++]=1&s[n];else for(n=0;n<a;n++)t[h++]=i[n],t[h++]=r[n],t[h++]=o[n],t[h++]=1}_calculateBandStatistics(t,e){let s=1/0,i=-1/0;const l=t.length;let r,o=0;if(null!=e)for(r=0;r<l;r++)e[r]&&(o=t[r],s=o<s?o:s,i=o>i?o:i);else for(r=0;r<l;r++)o=t[r],s=o<s?o:s,i=o>i?o:i;return new a(s,i)}};t([r({json:{write:!0}})],c.prototype,"width",void 0),t([r({json:{write:!0}})],c.prototype,"height",void 0),t([r({json:{write:!0}})],c.prototype,"pixelType",void 0),t([o("pixelType")],c.prototype,"castPixelType",null),t([r({json:{write:!0}})],c.prototype,"validPixelCount",void 0),t([r({json:{write:!0}})],c.prototype,"mask",void 0),t([r({json:{write:!0}})],c.prototype,"maskIsAlpha",void 0),t([r({json:{write:!0}})],c.prototype,"pixels",void 0),t([r()],c.prototype,"premultiplyAlpha",void 0),t([r({json:{write:!0}})],c.prototype,"statistics",void 0),t([r({json:{write:!0}})],c.prototype,"depthCount",void 0),t([r({json:{write:!0}})],c.prototype,"noDataValues",void 0),t([r({json:{write:!0}})],c.prototype,"bandMasks",void 0),c=p=t([n("esri.layers.support.PixelBlock")],c);const u=c;export{u as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as i}from"../../core/lang.js";import l from"../../core/Logger.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as o}from"../../core/accessorSupport/decorators/cast.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{SimpleBandStatistics as a}from"./SimpleBandStatistics.js";import{getPixelValueRange as h}from"./rasterFormats/pixelRangeUtils.js";var p;let c=p=class extends s{static createEmptyBand(t,e){return new(p.getPixelArrayConstructor(t))(e)}static combineBandMasks(t){if(t.length<2)return t[0];const e=t[0].length,s=new Uint8Array(e).fill(255);for(let i=0;i<t.length;i++){const l=t[i];for(let t=0;t<e;t++)l[t]||(s[t]=0)}return s}static getPixelArrayConstructor(t){let e;switch(t){case"u1":case"u2":case"u4":case"u8":e=Uint8Array;break;case"u16":e=Uint16Array;break;case"u32":e=Uint32Array;break;case"s8":e=Int8Array;break;case"s16":e=Int16Array;break;case"s32":e=Int32Array;break;case"f32":case"c64":case"c128":case"unknown":e=Float32Array;break;case"f64":e=Float64Array}return e}constructor(t){super(t),this.width=null,this.height=null,this.pixelType="f32",this.validPixelCount=null,this.mask=null,this.maskIsAlpha=!1,this.premultiplyAlpha=!1,this.statistics=null,this.depthCount=1}castPixelType(t){if(!t)return"f32";let e=t.toLowerCase();return["u1","u2","u4"].includes(e)?e="u8":["unknown","u8","s8","u16","s16","u32","s32","f32","f64"].includes(e)||(e="f32"),e}getPlaneCount(){return this.pixels?.length}addData(t){if(!t.pixels||t.pixels.length!==this.width*this.height)throw new e("pixelblock:invalid-or-missing-pixels","add data requires valid pixels array that has same length defined by pixel block width * height");this.pixels||(this.pixels=[]),this.statistics||(this.statistics=[]),this.pixels.push(t.pixels),this.statistics.push(t.statistics??new a)}getAsRGBA(){const t=new ArrayBuffer(this.width*this.height*4);switch(this.pixelType){case"s8":case"s16":case"u16":case"s32":case"u32":case"f32":case"f64":this._fillFromNon8Bit(t);break;default:this._fillFrom8Bit(t)}return new Uint8ClampedArray(t)}getAsRGBAFloat(){const t=new Float32Array(this.width*this.height*4);return this._fillFrom32Bit(t),t}updateStatistics(){if(!this.pixels)return;this.statistics=this.pixels.map((t=>this._calculateBandStatistics(t,this.mask)));const t=this.mask;let e=0;if(null!=t)for(let s=0;s<t.length;s++)t[s]&&e++;else e=this.width*this.height;this.validPixelCount=e}clamp(t){if(!t||"f64"===t||"f32"===t||!this.pixels)return;const[e,s]=h(t),i=this.pixels,l=this.width*this.height,r=i.length;let o,n,a;const c=[];for(let h=0;h<r;h++){a=p.createEmptyBand(t,l),o=i[h];for(let t=0;t<l;t++)n=o[t],a[t]=n>s?s:n<e?e:n;c.push(a)}this.pixels=c,this.pixelType=t}extractBands(t){const{pixels:e,statistics:s}=this;if(null==t||0===t.length||!e||0===e.length)return this;const i=e.length,l=t.some((t=>t>=e.length)),r=i===t.length&&!t.some(((t,e)=>t!==e));if(l||r)return this;const o=this.bandMasks?.length===i?t.map((t=>this.bandMasks[t])):void 0;let{mask:n,validPixelCount:a}=this;const{width:h,height:c}=this;return o?.length&&(n=p.combineBandMasks(o),a=n.filter((t=>!!t)).length),new p({pixelType:this.pixelType,width:h,height:c,mask:n,bandMasks:o,validPixelCount:a,maskIsAlpha:this.maskIsAlpha,pixels:t.map((t=>e[t])),statistics:s&&t.map((t=>s[t]))})}clone(){const t=new p({width:this.width,height:this.height,pixelType:this.pixelType,maskIsAlpha:this.maskIsAlpha,validPixelCount:this.validPixelCount});let e;null!=this.mask&&(t.mask=new Uint8Array(this.mask)),this.bandMasks&&(t.bandMasks=this.bandMasks.map((t=>new Uint8Array(t))));const s=p.getPixelArrayConstructor(this.pixelType);if(this.pixels&&this.pixels.length>0){t.pixels=[];const i=!!this.pixels[0].slice;for(e=0;e<this.pixels.length;e++)t.pixels[e]=i?this.pixels[e].slice(0,this.pixels[e].length):new s(this.pixels[e])}if(this.statistics)for(t.statistics=[],e=0;e<this.statistics.length;e++)t.statistics[e]=i(this.statistics[e]);return t.premultiplyAlpha=this.premultiplyAlpha,t}_fillFrom8Bit(t){const{mask:e,maskIsAlpha:s,premultiplyAlpha:i,pixels:r}=this;if(!t||!r?.length)return void l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");let o,n,a,h;o=n=a=r[0],r.length>=3?(n=r[1],a=r[2]):2===r.length&&(n=r[1]);const p=new Uint32Array(t),c=this.width*this.height;if(o.length===c)if(null!=e&&e.length===c)if(s)for(h=0;h<c;h++){const t=e[h];if(t){const e=t/255;p[h]=i?t<<24|a[h]*e<<16|n[h]*e<<8|o[h]*e:t<<24|a[h]<<16|n[h]<<8|o[h]}}else for(h=0;h<c;h++)e[h]&&(p[h]=255<<24|a[h]<<16|n[h]<<8|o[h]);else for(h=0;h<c;h++)p[h]=255<<24|a[h]<<16|n[h]<<8|o[h];else l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.")}_fillFromNon8Bit(t){const{pixels:e,mask:s,statistics:i}=this;if(!t||!e?.length)return void l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");const r=this.pixelType;let o=1,n=0,a=1;if(i&&i.length>0){for(const t of i)if(null!=t.minValue&&(n=Math.min(n,t.minValue)),null!=t.maxValue&&null!=t.minValue){const e=t.maxValue-t.minValue;a=Math.max(a,e)}o=255/a}else{let t=255;"s8"===r?(n=-128,t=127):"u16"===r?t=65535:"s16"===r?(n=-32768,t=32767):"u32"===r?t=4294967295:"s32"===r?(n=-2147483648,t=2147483647):"f32"===r?(n=-34e38,t=34e38):"f64"===r&&(n=-Number.MAX_VALUE,t=Number.MAX_VALUE),o=255/(t-n)}const h=new Uint32Array(t),p=this.width*this.height;let c,u,g,f,m;if(c=u=g=e[0],c.length!==p)return l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.");if(e.length>=2)if(u=e[1],e.length>=3&&(g=e[2]),null!=s&&s.length===p)for(f=0;f<p;f++)s[f]&&(h[f]=255<<24|(g[f]-n)*o<<16|(u[f]-n)*o<<8|(c[f]-n)*o);else for(f=0;f<p;f++)h[f]=255<<24|(g[f]-n)*o<<16|(u[f]-n)*o<<8|(c[f]-n)*o;else if(null!=s&&s.length===p)for(f=0;f<p;f++)m=(c[f]-n)*o,s[f]&&(h[f]=255<<24|m<<16|m<<8|m);else for(f=0;f<p;f++)m=(c[f]-n)*o,h[f]=255<<24|m<<16|m<<8|m}_fillFrom32Bit(t){const{pixels:e,mask:s}=this;if(!t||!e?.length)return l.getLogger(this).error("getAsRGBAFloat()","Unable to convert to RGBA. The input pixel block is empty.");let i,r,o,n;i=r=o=e[0],e.length>=3?(r=e[1],o=e[2]):2===e.length&&(r=e[1]);const a=this.width*this.height;if(i.length!==a)return l.getLogger(this).error("getAsRGBAFloat()","Unable to convert to RGBA. The pixelblock is invalid.");let h=0;if(null!=s&&s.length===a)for(n=0;n<a;n++)t[h++]=i[n],t[h++]=r[n],t[h++]=o[n],t[h++]=1&s[n];else for(n=0;n<a;n++)t[h++]=i[n],t[h++]=r[n],t[h++]=o[n],t[h++]=1}_calculateBandStatistics(t,e){let s=1/0,i=-1/0;const l=t.length;let r,o=0;if(null!=e)for(r=0;r<l;r++)e[r]&&(o=t[r],s=o<s?o:s,i=o>i?o:i);else for(r=0;r<l;r++)o=t[r],s=o<s?o:s,i=o>i?o:i;return new a(s,i)}};t([r({json:{write:!0}})],c.prototype,"width",void 0),t([r({json:{write:!0}})],c.prototype,"height",void 0),t([r({json:{write:!0}})],c.prototype,"pixelType",void 0),t([o("pixelType")],c.prototype,"castPixelType",null),t([r({json:{write:!0}})],c.prototype,"validPixelCount",void 0),t([r({json:{write:!0}})],c.prototype,"mask",void 0),t([r({json:{write:!0}})],c.prototype,"maskIsAlpha",void 0),t([r({json:{write:!0}})],c.prototype,"pixels",void 0),t([r()],c.prototype,"premultiplyAlpha",void 0),t([r({json:{write:!0}})],c.prototype,"statistics",void 0),t([r({json:{write:!0}})],c.prototype,"depthCount",void 0),t([r({json:{write:!0}})],c.prototype,"noDataValues",void 0),t([r({json:{write:!0}})],c.prototype,"bandMasks",void 0),c=p=t([n("esri.layers.support.PixelBlock")],c);const u=c;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{onAbort as s}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import{ensureClass as a}from"../../../core/accessorSupport/ensureType.js";import"../../../core/RandomLCG.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as m}from"../arcgisLayerUrl.js";import{url as f}from"../commonProperties.js";import u from"../DimensionalDefinition.js";import h from"../LOD.js";import p from"../RasterStorageInfo.js";import d from"../TileInfo.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{getRasterId as R,getBlock as w,putBlock as S,deleteBlock as k,decreaseRefCount as v}from"./RawBlockCache.js";import{convertNoDataToMask as T}from"../rasterFormats/pixelRangeUtils.js";import{decode as b}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as C,projectPoint as W,snapPyramid as j,shiftExtent as z,getWorldWrapCount as H,projectExtent as L,getProjectionOffsetGrid as E,getRasterDatasetAlignmentInfo as D,projectResolution as F}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as O,uvComponentToVector as A}from"../rasterFunctions/vectorFieldUtils.js";import{QueueProcessor as G}from"../../../views/support/QueueProcessor.js";import q from"../../../geometry/Extent.js";import J from"../../../geometry/Point.js";import N from"../../../geometry/SpatialReference.js";const V=8,U=256;let $=0,Q=class extends(n(r)){constructor(){super(...arguments),this._tileFetchQueue=new G({concurrency:32,process:(e,t)=>this._fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=_();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+$++}set url(e){this._set("url",m(e,o.getLogger(this)))}async open(e){throw new i("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,r={}){const o=r.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,o);return r={noClip:!0,...r},this.fetchPixels(n,o.size[0],o.size[1],r)}async identify(e,t={}){e=a(J,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:r}=t,{rasterInfo:o}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=o;let{transposedVariableName:l}=t;const c=null!=s&&n&&(null!=r||x(i));if(c&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:f}=o,{datumTransformation:u}=t;let h=W(e,m,u);if(!f.intersects(h))return{location:h,value:null};if(null!=o.transform){const e=o.transform.inverseTransform(h);if(!o.nativeExtent.intersects(e))return{location:e,value:null};h=e}let p=0;const d=null!=l&&null!=s&&o.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(d)return e.identify(h,t);const{pixelSize:i}=o,r=3,n=i.x*r/2,s=i.y*r/2,l=new q({xmin:h.x-n,xmax:h.x+n,ymin:h.y-s,ymax:h.y+s,spatialReference:m}),a={interpolation:"nearest"},{pixelBlock:c}=await e.fetchPixels(l,r,r,a),{pixelBlock:f}=await this.fetchPixels(l,r,r,a);if(null==c)return{location:h,value:null};const u=Math.floor(r*r*.5),p=!c.mask||c.mask[u]?c.pixels.map((e=>e[u])):null;let x;return null!=f&&(x=!f.mask||f.mask[u]?f.pixels.map((e=>e[u])):void 0),{location:h,value:p,processedValue:x,pyramidLevel:0}}if(!d)if(t.srcResolution){p=j(t.srcResolution,o,this.ioConfig.sampling).pyramidLevel}else if(p=await this.computeBestPyramidLevelForLocation(e,t),null==p)return{location:h,value:null};const y=this.identifyPixelLocation(h,p,null,d);if(null===y)return{location:h,value:null};const{row:g,col:I,rowOffset:k,colOffset:v,blockWidth:T}=y,b=l??t.sliceId,P=R(this.rasterId,b),B=`${p}/${g}/${I}`;let M=w(P,null,B);null==M&&(M=this.fetchRawTile(p,g,I,t),S(P,null,B,M));const _=await M;if(!_?.pixels?.length)return{location:h,value:null};const C=k*T+v;return this._processIdentifyResult(_,{srcLocation:h,position:C,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,r={}){e=z(e),r=this._getRequestOptionsWithSliceId(r);const{_hasNoneOrGCSShiftTransform:o}=this;if(r.requestRawData&&o)return this._fetchPixels(e,t,i,r);const n=C(e.spatialReference),s=H(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&o)return this._fetchPixels(e,t,i,r);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,m=Math.round(n/(c-a)*t),f=m-Math.round((n/2-a)/(c-a)*t);let u=0;const h=[];for(let y=0;y<=s;y++){const o=new q({xmin:0===y?a:-n/2,xmax:y===s?c-n*y:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===y?m-f:y===s?t-u:m;u+=p,h.push(p);const d=r.disableWrapAround&&y>0?null:this._fetchPixels(o,p,i,r);l.push(d)}const p=(await Promise.all(l)).map((e=>e?.pixelBlock));let d=null;const x={width:t,height:i};if(this.rasterJobHandler){d=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:h},r)).pixelBlock}else d=P(p,x,{blockWidths:h});return{extent:e,srcExtent:L(e,this.rasterInfo.spatialReference,r.datumTransformation),pixelBlock:d}}async fetchRawPixels(e,t,i,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,i,r),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,m=s.y*a,f=new q({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-m*(t.y+i.height-1),ymax:n.ymax-m*t.y,spatialReference:n.spatialReference});if(!o)return{extent:f,srcExtent:f,pixelBlock:null};const{pixelBlocks:u,mosaicSize:h}=o;if(1===u.length&&null!=u[0]&&u[0].width===i.width&&u[0].height===i.height)return{extent:f,srcExtent:f,pixelBlock:o.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,d=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%d};let y;if(this.rasterJobHandler){y=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:u,srcMosaicSize:h,destDimension:i,clipOffset:x,clipSize:i,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock}else y=P(u,h,{clipOffset:x,clipSize:i});return{extent:f,srcExtent:f,pixelBlock:y}}fetchRawTile(e,t,r,o){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return L(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?b(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,r=0){const{customFetchParameters:o}=this.ioConfig,{range:n,query:s,headers:l}=i;r=r??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...o},headers:{...l,...a}})}catch(c){if(r>0)return r--,this.request(e,i,r);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,r){const o=r.lodAt(e);return this.getTileExtent({x:o.resolution,y:o.resolution},t,i,r.origin,r.spatialReference,r.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:r}=this.rasterInfo;if(!e.tileInfo){const o=[],n=e.maximumPyramidLevel||0;let s=Math.max(r.x,r.y),l=1/.0254*96*s;for(let e=0;e<=n;e++)o.unshift(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new J({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new d({origin:a,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:o}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,r){const{width:o,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new J({x:s.xmin,y:s.ymax,spatialReference:a});null==r&&(r=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const m=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],r);e.storageInfo=new p({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:m})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,r,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let i=0;i<n;i++)e*=s,t*=s,o.push({x:e,y:t})}const l=[],{x:a,y:c}=r;for(let m=0;m<o.length;m++){const{x:r,y:n}=o[m];l.push({minCol:Math.floor((e.xmin-a+.1*r)/t/r),maxCol:Math.floor((e.xmax-a-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const o=r**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,i,r){const{spatialReference:o,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,m=r&&null!=c?c.tileSize[0]:s.blockWidth,f=r&&null!=c?c.tileSize[1]:s.blockHeight,u=W(e,o,i);if(!n.intersects(u))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-u.y)/d/f,y=(u.x-a.x)/p/m,g=Math.min(f-1,Math.floor((x-Math.floor(x))*f)),I=Math.min(m-1,Math.floor((y-Math.floor(y))*m));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:m,srcLocation:u}}getTileExtent(e,t,i,r,o,n){const[s,l]=n,a=r.x+i*s*e.x,c=a+s*e.x,m=r.y-t*l*e.y,f=m-l*e.y;return new q({xmin:a,xmax:c,ymin:f,ymax:m,spatialReference:o})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<i||r.minRow>t||r.minCol>i}updateImageSpaceRasterInfo(e){const{extent:t,pixelSize:i}=e;if(-.5===t.xmin&&.5===t.ymax&&1===i.x&&1===i.y&&null==e.transform)return;const{width:r,height:o}=e,n=N.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new q({xmin:-.5,ymax:.5,xmax:r-.5,ymin:.5-o,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new J({x:1,y:1,spatialReference:n});const{extent:s,storageInfo:l}=e;if(l){l.origin=new J({x:s.xmin,y:s.ymax,spatialReference:n});const{tileInfo:t}=l;if(t){t.origin=l.origin;const i=(e.nativePixelSize.x+e.nativePixelSize.y)/2;t.lods.forEach(((e,t)=>{e.resolution=i*2**t,e.scale=96*e.resolution/.0254}))}}}async _fetchPixels(e,t,i,r={}){let o=H(e);if(o>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,r),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:m,ul:f}=n;if(0===c||0===m)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:u}=this,h=u.transform,p="gcs-shift"===h?.type,d=null!=C(e.spatialReference);!p&&d||(o=H(n.srcExtent,p));const x=await this._fetchRawTiles(s,f,{width:c,height:m,wrapCount:o},r);if(!x)return{extent:e,srcExtent:a,pixelBlock:null};const y=u.storageInfo,g=s>0?y.pyramidBlockWidth:y.blockWidth,I=s>0?y.pyramidBlockHeight:y.blockHeight;let{x:R,y:w}=u.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=y;if(null!=e&&e[s-1])({x:R,y:w}=e[s-1]);else{const e=t**s;R*=e,w*=e}}const S=u.spatialReference,k=new J({x:R,y:w,spatialReference:S}),v=g===c&&I===m&&f.x%g==0&&f.y%I==0,T=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),b=!e.spatialReference.equals(S),W=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=r;if(!b&&v&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,T,W))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const z=d&&null!=C(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,L=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");L&&!this.rasterJobHandler&&await _();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||z,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:L},r):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T,datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||z,isAdaptive:!1,includeGCSGrid:L});let F;const A=!r.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,x.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=x;let $=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:A?{width:t,height:i}:null,coefs:A?D.coefficients:null,sampleSpacing:A?G:null,projectDirections:L,gcsGrid:L?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:r.interpolation,alignmentInfo:q,blockWidths:null},r);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:q});F=A?B(e,{width:t,height:i},D.coefficients,G,r.interpolation):e,L&&D.gcsGrid&&($=M({width:t,height:i},D.gcsGrid),F=O(F,this.rasterInfo.dataType,$))}return r.requestRawData||L?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F,transformGrid:D,localNorthDirections:$,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F}}async _fetchRawTiles(e,t,i,r){const{origin:o,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:m,height:f,wrapCount:u}=i;const h=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(a-=r.buffer.cols,c-=r.buffer.rows,m+=2*r.buffer.cols,f+=2*r.buffer.rows);let p=0,d=0,x=0;if(u&&null!=h){({worldColumnCountFromOrigin:d,originColumnOffset:x,rightPadding:p}=h);d*h.blockWidth-p>=a+m&&(p=0)}const y=Math.floor(a/s),g=Math.floor(c/l),I=Math.floor((a+m+p-1)/s),R=Math.floor((c+f+p-1)/l),w=n[e];if(!w)return null;const{minRow:S,minCol:k,maxCol:v,maxRow:T}=w;if(0===u&&(R<S||I<k||g>T||y>v))return null;const b=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let H=g;H<=R;H++)for(let t=y;t<=I;t++){let i=t;if(!r.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),H>=S&&i>=k&&T>=H&&v>=i){const t=this._tileFetchQueue.push({pyramidLevel:e,row:H,col:i,options:r},{signal:r.signal});B?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):b.push(t)}else b.push(Promise.resolve(null))}if(0===b.length)return null;const M=await Promise.all(b),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:C}=this.rasterInfo,W=this.getPyramidPixelSize(e),{x:j,y:z}=W;return{extent:new q({xmin:o.x+y*s*j,xmax:o.x+(I+1)*s*j,ymin:o.y-(R+1)*l*z,ymax:o.y-g*l*z,spatialReference:C}),pixelBlocks:M,mosaicSize:_,isPartiallyFilled:P}}_isSameResolution(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}_fetchRawTile(e,t,i,r){const o=this.rasterInfo.storageInfo.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:l,maxCol:a,maxRow:c}=o;if(t<n||i<l||t>c||i>a)return Promise.resolve(null);const m=R(this.rasterId,r.sliceId),f=`${e}/${t}/${i}`;let u=w(m,r.registryId,f);if(null==u){const o=new AbortController;u=this.fetchRawTile(e,t,i,{...r,signal:o.signal}),S(m,r.registryId,f,u,o),u.catch((()=>k(m,r.registryId,f)))}return r.signal&&s(r,(()=>{v(m,r.registryId,f)})),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const r=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[o,n]=e,s=[],l=[];for(let a=0;a<r;a++){const[e,t]=A([o[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=D(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,r={}){const o={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(o.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=o,c=s/t,m=l/i,f=a<n&&c*m>=16,u=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(f||u||(0===s||0===l)){const s=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=F(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const u=!l||r.srcResolution&&l.x+l.y<r.srcResolution.x+r.srcResolution.y;if(f&&r.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,m))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}l&&(o.srcResolution=l,this._updateSourceDataInfo(e,o))}return this._requireTooManySrcTiles(o.srcWidth,o.srcHeight,t,i)&&(o.srcWidth=0,o.srcHeight=0),o}_requireTooManySrcTiles(e,t,i,r){const{tileInfo:o}=this.rasterInfo.storageInfo,n=Math.ceil(e/o.size[0])*Math.ceil(t/o.size[1]),s=e/i,l=t/r,a=Math.max(1,(i+r)/1024);return n>=U*a||s>V||l>V}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,r=i.spatialReference,{srcResolution:o,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(o,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||L(e,r,n);if(null==c)return;const m=i.transform;m&&(c=m.inverseTransform(c)),t.srcExtent=c;const{x:f,y:u}=i.storageInfo.origin,h=Math.floor((c.xmin-f)/l.x+.1),p=Math.floor((u-c.ymax)/l.y+.1),d=Math.floor((c.xmax-f)/l.x-.1),x=Math.floor((u-c.ymin)/l.y-.1),y=c.width<.1*l.x?0:d-h+1,g=c.height<.1*l.y?0:x-p+1;t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=y,t.srcHeight=g,t.ul={x:h,y:p}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:r,pyramidLevel:o,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[r]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map((e=>e[r])),n={location:i,value:t,pyramidLevel:o},s=this._computeMagDirValues(t.map((e=>[e])));return s?.length&&(n.magdirValue=s.map((e=>e[0]))),n}let a=e.pixels.map((e=>e.slice(r*s,r*s+s))),c=this._computeMagDirValues(a);const{requestSomeSlices:m,identifyOptions:f}=t;let h=g(l,f.transposedVariableName);if(m){const e=I(h,f.multidimensionalDefinition,f.timeExtent);a=a.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),h=e.map((e=>h[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let x;null!=p&&(T(d,p),x=d.mask);return{location:i,value:null,dataSeries:h.map(((e,t)=>{const i={value:0===x?.[t]?null:a.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new u({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:o}}};e([l()],Q.prototype,"_rasterTileAlignmentInfo",void 0),e([l()],Q.prototype,"_tileFetchQueue",void 0),e([l({readOnly:!0})],Q.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],Q.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],Q.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],Q.prototype,"rasterId",null),e([l(f)],Q.prototype,"url",null),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetFormat",void 0),e([l()],Q.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],Q.prototype,"rasterInfo",void 0),e([l()],Q.prototype,"ioConfig",void 0),e([l()],Q.prototype,"sourceJSON",void 0),Q=e([c("esri.layers.support.rasterDatasets.BaseRaster")],Q);const X=Q;export{X as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import r from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{onAbort as s}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import{ensureClass as a}from"../../../core/accessorSupport/ensureType.js";import"../../../core/RandomLCG.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as m}from"../arcgisLayerUrl.js";import{url as f}from"../commonProperties.js";import u from"../DimensionalDefinition.js";import h from"../LOD.js";import p from"../RasterStorageInfo.js";import d from"../TileInfo.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{getRasterId as R,getBlock as w,putBlock as S,deleteBlock as k,decreaseRefCount as v}from"./RawBlockCache.js";import{convertNoDataToMask as T}from"../rasterFormats/pixelRangeUtils.js";import{decode as b}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as C,projectPoint as W,snapPyramid as j,shiftExtent as z,getWorldWrapCount as H,projectExtent as L,getProjectionOffsetGrid as E,getRasterDatasetAlignmentInfo as D,projectResolution as F}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as O,uvComponentToVector as A}from"../rasterFunctions/vectorFieldUtils.js";import{QueueProcessor as G}from"../../../views/support/QueueProcessor.js";import q from"../../../geometry/Extent.js";import J from"../../../geometry/Point.js";import N from"../../../geometry/SpatialReference.js";const V=8,U=256;let $=0,Q=class extends(n(o)){constructor(){super(...arguments),this._tileFetchQueue=new G({concurrency:32,process:(e,t)=>this._fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=_();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+$++}set url(e){this._set("url",m(e,r.getLogger(this)))}async open(e){throw new i("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,o={}){const r=o.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,r);return o={noClip:!0,...o},this.fetchPixels(n,r.size[0],r.size[1],o)}async identify(e,t={}){e=a(J,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:o}=t,{rasterInfo:r}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=r;let{transposedVariableName:l}=t;const c=null!=s&&n&&(null!=o||x(i));if(c&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:f}=r,{datumTransformation:u}=t;let h=W(e,m,u);if(!f.intersects(h))return{location:h,value:null};if(null!=r.transform){const e=r.transform.inverseTransform(h);if(!r.nativeExtent.intersects(e))return{location:e,value:null};h=e}let p=0;const d=null!=l&&null!=s&&r.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(d)return e.identify(h,t);const{pixelSize:o}=r,n=3,s=o.x*n/2,l=o.y*n/2,a=new q({xmin:h.x-s,xmax:h.x+s,ymin:h.y-l,ymax:h.y+l,spatialReference:m}),c={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId},{pixelBlock:f}=await e.fetchPixels(a,n,n,c),{pixelBlock:u}=await this.fetchPixels(a,n,n,c);if(null==f)return{location:h,value:null};const p=Math.floor(n*n*.5),x=!f.mask||f.mask[p]?f.pixels.map((e=>e[p])):null;let y;return null!=u&&(y=!u.mask||u.mask[p]?u.pixels.map((e=>e[p])):void 0),{location:h,value:x,processedValue:y,pyramidLevel:0}}if(!d)if(t.srcResolution){p=j(t.srcResolution,r,this.ioConfig.sampling).pyramidLevel}else if(p=await this.computeBestPyramidLevelForLocation(e,t),null==p)return{location:h,value:null};const y=this.identifyPixelLocation(h,p,null,d);if(null===y)return{location:h,value:null};const{row:g,col:I,rowOffset:k,colOffset:v,blockWidth:T}=y,b=l??t.sliceId,P=R(this.rasterId,b),B=`${p}/${g}/${I}`;let M=w(P,null,B);null==M&&(M=this.fetchRawTile(p,g,I,t),S(P,null,B,M));const _=await M;if(!_?.pixels?.length)return{location:h,value:null};const C=k*T+v;return this._processIdentifyResult(_,{srcLocation:h,position:C,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=z(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:r}=this;if(o.requestRawData&&r)return this._fetchPixels(e,t,i,o);const n=C(e.spatialReference),s=H(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&r)return this._fetchPixels(e,t,i,o);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,m=Math.round(n/(c-a)*t),f=m-Math.round((n/2-a)/(c-a)*t);let u=0;const h=[];for(let y=0;y<=s;y++){const r=new q({xmin:0===y?a:-n/2,xmax:y===s?c-n*y:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===y?m-f:y===s?t-u:m;u+=p,h.push(p);const d=o.disableWrapAround&&y>0?null:this._fetchPixels(r,p,i,o);l.push(d)}const p=(await Promise.all(l)).map((e=>e?.pixelBlock));let d=null;const x={width:t,height:i};if(this.rasterJobHandler){d=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:h},o)).pixelBlock}else d=P(p,x,{blockWidths:h});return{extent:e,srcExtent:L(e,this.rasterInfo.spatialReference,o.datumTransformation),pixelBlock:d}}async fetchRawPixels(e,t,i,o={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const r=await this._fetchRawTiles(e,t,i,o),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,m=s.y*a,f=new q({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-m*(t.y+i.height-1),ymax:n.ymax-m*t.y,spatialReference:n.spatialReference});if(!r)return{extent:f,srcExtent:f,pixelBlock:null};const{pixelBlocks:u,mosaicSize:h}=r;if(1===u.length&&null!=u[0]&&u[0].width===i.width&&u[0].height===i.height)return{extent:f,srcExtent:f,pixelBlock:r.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,d=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%d};let y;if(this.rasterJobHandler){y=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:u,srcMosaicSize:h,destDimension:i,clipOffset:x,clipSize:i,coefs:null,sampleSpacing:null,interpolation:o.interpolation,alignmentInfo:null,blockWidths:null},o)).pixelBlock}else y=P(u,h,{clipOffset:x,clipSize:i});return{extent:f,srcExtent:f,pixelBlock:y}}fetchRawTile(e,t,o,r){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return L(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?b(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,o=0){const{customFetchParameters:r}=this.ioConfig,{range:n,query:s,headers:l}=i;o=o??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...r},headers:{...l,...a}})}catch(c){if(o>0)return o--,this.request(e,i,o);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,o){const r=o.lodAt(e);return this.getTileExtent({x:r.resolution,y:r.resolution},t,i,o.origin,o.spatialReference,o.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:o}=this.rasterInfo;if(!e.tileInfo){const r=[],n=e.maximumPyramidLevel||0;let s=Math.max(o.x,o.y),l=1/.0254*96*s;for(let e=0;e<=n;e++)r.unshift(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new J({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new d({origin:a,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:r}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,o){const{width:r,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new J({x:s.xmin,y:s.ymax,spatialReference:a});null==o&&(o=Math.max(0,Math.round(Math.log(Math.max(r,n))/Math.LN2-8)));const m=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],o);e.storageInfo=new p({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:o,blockBoundary:m})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,o,r,n=0,s=2){if(1===r.length&&n>0){r=[...r];let{x:e,y:t}=r[0];for(let i=0;i<n;i++)e*=s,t*=s,r.push({x:e,y:t})}const l=[],{x:a,y:c}=o;for(let m=0;m<r.length;m++){const{x:o,y:n}=r[m];l.push({minCol:Math.floor((e.xmin-a+.1*o)/t/o),maxCol:Math.floor((e.xmax-a-.1*o)/t/o),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:o}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const r=o**e;return{x:t.x*r,y:t.y*r}}identifyPixelLocation(e,t,i,o){const{spatialReference:r,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,m=o&&null!=c?c.tileSize[0]:s.blockWidth,f=o&&null!=c?c.tileSize[1]:s.blockHeight,u=W(e,r,i);if(!n.intersects(u))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-u.y)/d/f,y=(u.x-a.x)/p/m,g=Math.min(f-1,Math.floor((x-Math.floor(x))*f)),I=Math.min(m-1,Math.floor((y-Math.floor(y))*m));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:m,srcLocation:u}}getTileExtent(e,t,i,o,r,n){const[s,l]=n,a=o.x+i*s*e.x,c=a+s*e.x,m=o.y-t*l*e.y,f=m-l*e.y;return new q({xmin:a,xmax:c,ymin:f,ymax:m,spatialReference:r})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const o=this.rasterInfo.storageInfo.blockBoundary[e];return!o||o.maxRow<t||o.maxCol<i||o.minRow>t||o.minCol>i}updateImageSpaceRasterInfo(e){const{extent:t,pixelSize:i}=e;if(-.5===t.xmin&&.5===t.ymax&&1===i.x&&1===i.y&&null==e.transform)return;const{width:o,height:r}=e,n=N.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new q({xmin:-.5,ymax:.5,xmax:o-.5,ymin:.5-r,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new J({x:1,y:1,spatialReference:n});const{extent:s,storageInfo:l}=e;if(l){l.origin=new J({x:s.xmin,y:s.ymax,spatialReference:n});const{tileInfo:t}=l;if(t){t.origin=l.origin;const i=(e.nativePixelSize.x+e.nativePixelSize.y)/2;t.lods.forEach(((e,t)=>{e.resolution=i*2**t,e.scale=96*e.resolution/.0254}))}}}async _fetchPixels(e,t,i,o={}){let r=H(e);if(r>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,o),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:m,ul:f}=n;if(0===c||0===m)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:u}=this,h=u.transform,p="gcs-shift"===h?.type,d=null!=C(e.spatialReference);!p&&d||(r=H(n.srcExtent,p));const x=await this._fetchRawTiles(s,f,{width:c,height:m,wrapCount:r},o);if(!x)return{extent:e,srcExtent:a,pixelBlock:null};const y=u.storageInfo,g=s>0?y.pyramidBlockWidth:y.blockWidth,I=s>0?y.pyramidBlockHeight:y.blockHeight;let{x:R,y:w}=u.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=y;if(null!=e&&e[s-1])({x:R,y:w}=e[s-1]);else{const e=t**s;R*=e,w*=e}}const S=u.spatialReference,k=new J({x:R,y:w,spatialReference:S}),v=g===c&&I===m&&f.x%g==0&&f.y%I==0,T=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),b=!e.spatialReference.equals(S),W=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=o;if(!b&&v&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,T,W))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const z=d&&null!=C(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,L=o.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");L&&!this.rasterJobHandler&&await _();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||z,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:L},o):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T,datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||z,isAdaptive:!1,includeGCSGrid:L});let F;const A=!o.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,x.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=x;let $=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:A?{width:t,height:i}:null,coefs:A?D.coefficients:null,sampleSpacing:A?G:null,projectDirections:L,gcsGrid:L?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:o.interpolation,alignmentInfo:q,blockWidths:null},o);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:q});F=A?B(e,{width:t,height:i},D.coefficients,G,o.interpolation):e,L&&D.gcsGrid&&($=M({width:t,height:i},D.gcsGrid),F=O(F,this.rasterInfo.dataType,$))}return o.requestRawData||L?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F,transformGrid:D,localNorthDirections:$,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F}}async _fetchRawTiles(e,t,i,o){const{origin:r,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:m,height:f,wrapCount:u}=i;const h=this._getRasterTileAlignmentInfo(e,0);o.buffer&&(a-=o.buffer.cols,c-=o.buffer.rows,m+=2*o.buffer.cols,f+=2*o.buffer.rows);let p=0,d=0,x=0;if(u&&null!=h){({worldColumnCountFromOrigin:d,originColumnOffset:x,rightPadding:p}=h);d*h.blockWidth-p>=a+m&&(p=0)}const y=Math.floor(a/s),g=Math.floor(c/l),I=Math.floor((a+m+p-1)/s),R=Math.floor((c+f+p-1)/l),w=n[e];if(!w)return null;const{minRow:S,minCol:k,maxCol:v,maxRow:T}=w;if(0===u&&(R<S||I<k||g>T||y>v))return null;const b=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let H=g;H<=R;H++)for(let t=y;t<=I;t++){let i=t;if(!o.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),H>=S&&i>=k&&T>=H&&v>=i){const t=this._tileFetchQueue.push({pyramidLevel:e,row:H,col:i,options:o},{signal:o.signal});B?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):b.push(t)}else b.push(Promise.resolve(null))}if(0===b.length)return null;const M=await Promise.all(b),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:C}=this.rasterInfo,W=this.getPyramidPixelSize(e),{x:j,y:z}=W;return{extent:new q({xmin:r.x+y*s*j,xmax:r.x+(I+1)*s*j,ymin:r.y-(R+1)*l*z,ymax:r.y-g*l*z,spatialReference:C}),pixelBlocks:M,mosaicSize:_,isPartiallyFilled:P}}_isSameResolution(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}_fetchRawTile(e,t,i,o){const r=this.rasterInfo.storageInfo.blockBoundary[e];if(!r)return Promise.resolve(null);const{minRow:n,minCol:l,maxCol:a,maxRow:c}=r;if(t<n||i<l||t>c||i>a)return Promise.resolve(null);const m=R(this.rasterId,o.sliceId),f=`${e}/${t}/${i}`;let u=w(m,o.registryId,f);if(null==u){const r=new AbortController;u=this.fetchRawTile(e,t,i,{...o,signal:r.signal}),S(m,o.registryId,f,u,r),u.catch((()=>k(m,o.registryId,f)))}return o.signal&&s(o,(()=>{v(m,o.registryId,f)})),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const o=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[r,n]=e,s=[],l=[];for(let a=0;a<o;a++){const[e,t]=A([r[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=D(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,o={}){const r={datumTransformation:o.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};o.srcResolution&&(r.srcResolution=o.srcResolution,this._updateSourceDataInfo(e,r));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=r,c=s/t,m=l/i,f=a<n&&c*m>=16,u=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(f||u||(0===s||0===l)){const s=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=F(s,this.rasterInfo.spatialReference,e,r.datumTransformation);const u=!l||o.srcResolution&&l.x+l.y<o.srcResolution.x+o.srcResolution.y;if(f&&o.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,m))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:o.srcResolution.x*t,y:o.srcResolution.y*t}}}l&&(r.srcResolution=l,this._updateSourceDataInfo(e,r))}return this._requireTooManySrcTiles(r.srcWidth,r.srcHeight,t,i)&&(r.srcWidth=0,r.srcHeight=0),r}_requireTooManySrcTiles(e,t,i,o){const{tileInfo:r}=this.rasterInfo.storageInfo,n=Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1]),s=e/i,l=t/o,a=Math.max(1,(i+o)/1024);return n>=U*a||s>V||l>V}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,o=i.spatialReference,{srcResolution:r,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(r,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||L(e,o,n);if(null==c)return;const m=i.transform;m&&(c=m.inverseTransform(c)),t.srcExtent=c;const{x:f,y:u}=i.storageInfo.origin,h=Math.floor((c.xmin-f)/l.x+.1),p=Math.floor((u-c.ymax)/l.y+.1),d=Math.floor((c.xmax-f)/l.x-.1),x=Math.floor((u-c.ymin)/l.y-.1),y=c.width<.1*l.x?0:d-h+1,g=c.height<.1*l.y?0:x-p+1;t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=y,t.srcHeight=g,t.ul={x:h,y:p}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:o,pyramidLevel:r,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[o]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map((e=>e[o])),n={location:i,value:t,pyramidLevel:r},s=this._computeMagDirValues(t.map((e=>[e])));return s?.length&&(n.magdirValue=s.map((e=>e[0]))),n}let a=e.pixels.map((e=>e.slice(o*s,o*s+s))),c=this._computeMagDirValues(a);const{requestSomeSlices:m,identifyOptions:f}=t;let h=g(l,f.transposedVariableName);if(m){const e=I(h,f.multidimensionalDefinition,f.timeExtent);a=a.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),h=e.map((e=>h[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let x;null!=p&&(T(d,p),x=d.mask);return{location:i,value:null,dataSeries:h.map(((e,t)=>{const i={value:0===x?.[t]?null:a.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new u({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:r}}};e([l()],Q.prototype,"_rasterTileAlignmentInfo",void 0),e([l()],Q.prototype,"_tileFetchQueue",void 0),e([l({readOnly:!0})],Q.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],Q.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],Q.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],Q.prototype,"rasterId",null),e([l(f)],Q.prototype,"url",null),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetFormat",void 0),e([l()],Q.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],Q.prototype,"rasterInfo",void 0),e([l()],Q.prototype,"ioConfig",void 0),e([l()],Q.prototype,"sourceJSON",void 0),Q=e([c("esri.layers.support.rasterDatasets.BaseRaster")],Q);const X=Q;export{X as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../core/Error.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 s}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../PixelBlock.js";import i from"../RasterInfo.js";import a from"../RasterStorageInfo.js";import n from"./BaseRaster.js";import{parseSpatialReference as l,parsePAMInfo as f}from"./pamParser.js";import{getElement as c,getElementValue as p}from"./xmlUtilities.js";import{isPlatformLittleEndian as m}from"../rasterFormats/utils.js";import{estimateStatisticsFromHistograms as h}from"../rasterFunctions/stretchUtils.js";import u from"../../../geometry/SpatialReference.js";import g from"../../../geometry/Extent.js";import d from"../../../geometry/Point.js";const y=new Map;y.set("Int8","s8"),y.set("UInt8","u8"),y.set("Int16","s16"),y.set("UInt16","u16"),y.set("Int32","s32"),y.set("UInt32","u32"),y.set("Float32","f32"),y.set("Float64","f32"),y.set("Double64","f32");const x=new Map;x.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),x.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),x.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),x.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"});let w=class extends n{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this.datasetFormat="MRF"}async open(t){await this.init(),this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const e=t?t.signal:null,r=await this.request(this.url,{responseType:"xml",signal:e}),{rasterInfo:s,files:o}=this._parseHeader(r.data),{skipMapInfo:i,skipExtensions:a=[]}=this.ioConfig;if(!a.includes("aux.xml")&&!i){const e=await this._fetchAuxiliaryData(t);null!=e&&(s.statistics=e.statistics??s.statistics,s.histograms=e.histograms,e.histograms&&null==s.statistics&&(s.statistics=h(e.histograms)))}i&&this.updateImageSpaceRasterInfo(s),this._set("rasterInfo",s),this._files=o;const n=await this.request(o.index,{responseType:"array-buffer",signal:e});this._storageIndex=this._parseIndex(n.data);const{blockWidth:l,blockHeight:f}=this.rasterInfo.storageInfo,c=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:p,height:m}=this.rasterInfo,u=[],g=this._getBandSegmentCount();let d=0,y=-1;for(;d<this._storageIndex.length;){y++;const t=Math.ceil(p/l/c**y)-1,e=Math.ceil(m/f/c**y)-1;d+=(t+1)*(e+1)*g*4,u.push({maxRow:e,maxCol:t,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=u,y>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=y),this.updateTileInfo()}async fetchRawTile(t,e,r,s={}){const{blockWidth:i,blockHeight:a,blockBoundary:n}=this.rasterInfo.storageInfo,l=n[t];if(!l||l.maxRow<e||l.maxCol<r||l.minRow>e||l.minCol>r)return null;const{bandCount:f,pixelType:c}=this.rasterInfo,{ranges:p,actualTileWidth:m,actualTileHeight:h}=this._getTileLocation(t,e,r);if(!p||0===p.length)return null;if(0===p[0].from&&0===p[0].to){const t=new Uint8Array(i*a);return new o({width:i,height:a,pixels:null,mask:t,validPixelCount:0})}const{bandIds:u}=this.ioConfig,g=this._getBandSegmentCount(),d=[];let y=0;for(y=0;y<g;y++)u&&!u.includes(y)||d.push(this.request(this._files.data,{range:{from:p[y].from,to:p[y].to},responseType:"array-buffer",signal:s.signal}));const w=await Promise.all(d),I=w.map((t=>t.data.byteLength)).reduce(((t,e)=>t+e)),b=new Uint8Array(I),R=[];let A=0;for(y=0;y<g;y++)R.push(A),b.set(new Uint8Array(w[y].data),A),A+=w[y].data.byteLength;const F=x.get(this.rasterInfo.storageInfo.compression).decoderFormat,_=await this.decodePixelBlock(b.buffer,{width:i,height:a,format:F,planes:u?.length||f,offsets:R,pixelType:c});if(null==_)return null;let{noDataValue:S}=this.rasterInfo;if(null!=S&&"lerc"!==F&&!_.mask&&(S=S[0],null!=S)){const t=_.width*_.height,e=new Uint8Array(t);if(Math.abs(S)>1e24)for(y=0;y<t;y++)Math.abs((_.pixels[0][y]-S)/S)>1e-6&&(e[y]=1);else for(y=0;y<t;y++)_.pixels[0][y]!==S&&(e[y]=1);_.mask=e}let k=0,M=0;if(m!==i||h!==a){let t=_.mask;if(t)for(y=0;y<a;y++)if(M=y*i,y<h)for(k=m;k<i;k++)t[M+k]=0;else for(k=0;k<i;k++)t[M+k]=0;else for(t=new Uint8Array(i*a),_.mask=t,y=0;y<h;y++)for(M=y*i,k=0;k<m;k++)t[M+k]=1}return _}_parseIndex(t){if(t.byteLength%16>0)throw new Error("invalid array buffer must be multiples of 16");let e,r,s,o,i,a;if(m){for(r=new Uint8Array(t),o=new ArrayBuffer(t.byteLength),s=new Uint8Array(o),i=0;i<t.byteLength/4;i++)for(a=0;a<4;a++)s[4*i+a]=r[4*i+3-a];e=new Uint32Array(o)}else e=new Uint32Array(t);return e}_getBandSegmentCount(){return x.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(t,e,r){const{blockWidth:s,blockHeight:o,pyramidScalingFactor:i}=this.rasterInfo.storageInfo,{width:a,height:n}=this.rasterInfo,l=this._getBandSegmentCount();let f,c,p,m=0,h=0;for(p=0;p<t;p++)h=i**p,f=Math.ceil(a/s/h),c=Math.ceil(n/o/h),m+=f*c;h=i**t,f=Math.ceil(a/s/h),c=Math.ceil(n/o/h),m+=e*f+r,m*=4*l;const u=this._storageIndex.subarray(m,m+4*l);let g=0,d=0;const y=[];for(let x=0;x<l;x++)g=u[4*x]*2**32+u[4*x+1],d=g+u[4*x+2]*2**32+u[4*x+3],y.push({from:g,to:d});return{ranges:y,actualTileWidth:r<f-1?s:Math.ceil(a/h)-s*(f-1),actualTileHeight:e<c-1?o:Math.ceil(n/h)-o*(c-1)}}_parseHeader(t){const r=c(t,"MRF_META/Raster");if(!r)throw new e("mrf:open","not a valid MRF format");const s=c(r,"Size"),o=parseInt(s.getAttribute("x"),10),n=parseInt(s.getAttribute("y"),10),f=parseInt(s.getAttribute("c"),10),m=(p(r,"Compression")||"none").toLowerCase();if(!x.has(m))throw new e("mrf:open","currently does not support compression "+m);const h=p(r,"DataType")||"UInt8",w=y.get(h);if(null==w)throw new e("mrf:open","currently does not support pixel type "+h);const I=c(r,"PageSize"),b=parseInt(I.getAttribute("x"),10),R=parseInt(I.getAttribute("y"),10),A=c(r,"DataValues");let F,_;A&&(_=A.getAttribute("NoData"),null!=_&&(F=_.trim().split(" ").map((t=>parseFloat(t)))));if(c(t,"MRF_META/CachedSource"))throw new e("mrf:open","currently does not support MRF referencing other data files");const S=c(t,"MRF_META/GeoTags"),k=c(S,"BoundingBox");let M,j=!1;if(null!=k){const t=parseFloat(k.getAttribute("minx")),e=parseFloat(k.getAttribute("miny")),r=parseFloat(k.getAttribute("maxx")),s=parseFloat(k.getAttribute("maxy")),o=p(S,"Projection")||"";let i=u.WGS84;if("LOCAL_CS[]"!==o)if(o.toLowerCase().startsWith("epsg:")){const t=Number(o.slice(5));isNaN(t)||0===t||(i=new u({wkid:t}))}else i=l(o)??u.WGS84;else j=!0,i=new u({wkid:3857});M=new g(t,e,r,s),M.spatialReference=i}else j=!0,M=new g({xmin:-.5,ymin:.5-n,xmax:o-.5,ymax:.5,spatialReference:new u({wkid:3857})});const C=c(t,"MRF_META/Rsets"),T=parseInt(C?.getAttribute("scale")||"2",10),L=M.spatialReference,U=new a({origin:new d({x:M.xmin,y:M.ymax,spatialReference:L}),blockWidth:b,blockHeight:R,pyramidBlockWidth:b,pyramidBlockHeight:R,compression:m,pyramidScalingFactor:T}),B=new d({x:M.width/o,y:M.height/n,spatialReference:L}),E=new i({width:o,height:n,extent:M,isPseudoSpatialReference:j,spatialReference:L,bandCount:f,pixelType:w,pixelSize:B,noDataValue:F,storageInfo:U}),P=p(t,"datafile"),W=p(t,"IndexFile");return{rasterInfo:E,files:{mrf:this.url,index:W||this.url.replace(".mrf",".idx"),data:P||this.url.replace(".mrf",x.get(m).blobExtension)}}}async _fetchAuxiliaryData(t){try{const{data:e}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:t?.signal});return f(e)}catch{return null}}};t([r()],w.prototype,"_files",void 0),t([r()],w.prototype,"_storageIndex",void 0),t([r({type:String,json:{write:!0}})],w.prototype,"datasetFormat",void 0),w=t([s("esri.layers.support.rasterIO.MRFRaster")],w);const I=w;export{I as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../core/Error.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 s}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../PixelBlock.js";import i from"../RasterInfo.js";import a from"../RasterStorageInfo.js";import n from"./BaseRaster.js";import{parseSpatialReference as l,parsePAMInfo as f}from"./pamParser.js";import{getElement as c,getElementValue as p}from"./xmlUtilities.js";import{isPlatformLittleEndian as m}from"../rasterFormats/utils.js";import{estimateStatisticsFromHistograms as h}from"../rasterFunctions/stretchUtils.js";import u from"../../../geometry/SpatialReference.js";import g from"../../../geometry/Extent.js";import d from"../../../geometry/Point.js";const y=new Map;y.set("Int8","s8"),y.set("UInt8","u8"),y.set("Int16","s16"),y.set("UInt16","u16"),y.set("Int32","s32"),y.set("UInt32","u32"),y.set("Float32","f32"),y.set("Float64","f32"),y.set("Double64","f32");const x=new Map;x.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),x.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),x.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),x.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"});let w=class extends n{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this.datasetFormat="MRF"}async open(t){await this.init(),this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const e=t?t.signal:null,r=await this.request(this.url,{responseType:"xml",signal:e}),{rasterInfo:s,files:o}=this._parseHeader(r.data),{skipMapInfo:i,skipExtensions:a=[]}=this.ioConfig;if(!a.includes("aux.xml")&&!i){const e=await this._fetchAuxiliaryData(t);null!=e&&(s.statistics=e.statistics??s.statistics,s.histograms=e.histograms,e.histograms&&null==s.statistics&&(s.statistics=h(e.histograms)))}i&&this.updateImageSpaceRasterInfo(s),this._set("rasterInfo",s),this._files=o;const n=await this.request(o.index,{responseType:"array-buffer",signal:e});this._storageIndex=this._parseIndex(n.data);const{blockWidth:l,blockHeight:f}=this.rasterInfo.storageInfo,c=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:p,height:m}=this.rasterInfo,u=[],g=this._getBandSegmentCount();let d=0,y=-1;for(;d<this._storageIndex.length;){y++;const t=Math.ceil(p/l/c**y)-1,e=Math.ceil(m/f/c**y)-1;d+=(t+1)*(e+1)*g*4,u.push({maxRow:e,maxCol:t,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=u,y>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=y),this.updateTileInfo()}async fetchRawTile(t,e,r,s={}){const{blockWidth:i,blockHeight:a,blockBoundary:n}=this.rasterInfo.storageInfo,l=n[t];if(!l||l.maxRow<e||l.maxCol<r||l.minRow>e||l.minCol>r)return null;const{bandCount:f,pixelType:c}=this.rasterInfo,{ranges:p,actualTileWidth:m,actualTileHeight:h}=this._getTileLocation(t,e,r);if(!p||0===p.length)return null;if(0===p[0].from&&0===p[0].to){const t=new Uint8Array(i*a);return new o({width:i,height:a,pixels:void 0,mask:t,validPixelCount:0})}const{bandIds:u}=this.ioConfig,g=this._getBandSegmentCount(),d=[];let y=0;for(y=0;y<g;y++)u&&!u.includes(y)||d.push(this.request(this._files.data,{range:{from:p[y].from,to:p[y].to},responseType:"array-buffer",signal:s.signal}));const w=await Promise.all(d),I=w.map((t=>t.data.byteLength)).reduce(((t,e)=>t+e)),b=new Uint8Array(I),R=[];let A=0;for(y=0;y<g;y++)R.push(A),b.set(new Uint8Array(w[y].data),A),A+=w[y].data.byteLength;const F=x.get(this.rasterInfo.storageInfo.compression).decoderFormat,_=await this.decodePixelBlock(b.buffer,{width:i,height:a,format:F,planes:u?.length||f,offsets:R,pixelType:c});if(null==_)return null;let{noDataValue:S}=this.rasterInfo;if(null!=S&&"lerc"!==F&&!_.mask&&(S=S[0],null!=S)){const t=_.width*_.height,e=new Uint8Array(t);if(Math.abs(S)>1e24)for(y=0;y<t;y++)Math.abs((_.pixels[0][y]-S)/S)>1e-6&&(e[y]=1);else for(y=0;y<t;y++)_.pixels[0][y]!==S&&(e[y]=1);_.mask=e}let k=0,M=0;if(m!==i||h!==a){let t=_.mask;if(t)for(y=0;y<a;y++)if(M=y*i,y<h)for(k=m;k<i;k++)t[M+k]=0;else for(k=0;k<i;k++)t[M+k]=0;else for(t=new Uint8Array(i*a),_.mask=t,y=0;y<h;y++)for(M=y*i,k=0;k<m;k++)t[M+k]=1}return _}_parseIndex(t){if(t.byteLength%16>0)throw new Error("invalid array buffer must be multiples of 16");let e,r,s,o,i,a;if(m){for(r=new Uint8Array(t),o=new ArrayBuffer(t.byteLength),s=new Uint8Array(o),i=0;i<t.byteLength/4;i++)for(a=0;a<4;a++)s[4*i+a]=r[4*i+3-a];e=new Uint32Array(o)}else e=new Uint32Array(t);return e}_getBandSegmentCount(){return x.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(t,e,r){const{blockWidth:s,blockHeight:o,pyramidScalingFactor:i}=this.rasterInfo.storageInfo,{width:a,height:n}=this.rasterInfo,l=this._getBandSegmentCount();let f,c,p,m=0,h=0;for(p=0;p<t;p++)h=i**p,f=Math.ceil(a/s/h),c=Math.ceil(n/o/h),m+=f*c;h=i**t,f=Math.ceil(a/s/h),c=Math.ceil(n/o/h),m+=e*f+r,m*=4*l;const u=this._storageIndex.subarray(m,m+4*l);let g=0,d=0;const y=[];for(let x=0;x<l;x++)g=u[4*x]*2**32+u[4*x+1],d=g+u[4*x+2]*2**32+u[4*x+3],y.push({from:g,to:d});return{ranges:y,actualTileWidth:r<f-1?s:Math.ceil(a/h)-s*(f-1),actualTileHeight:e<c-1?o:Math.ceil(n/h)-o*(c-1)}}_parseHeader(t){const r=c(t,"MRF_META/Raster");if(!r)throw new e("mrf:open","not a valid MRF format");const s=c(r,"Size"),o=parseInt(s.getAttribute("x"),10),n=parseInt(s.getAttribute("y"),10),f=parseInt(s.getAttribute("c"),10),m=(p(r,"Compression")||"none").toLowerCase();if(!x.has(m))throw new e("mrf:open","currently does not support compression "+m);const h=p(r,"DataType")||"UInt8",w=y.get(h);if(null==w)throw new e("mrf:open","currently does not support pixel type "+h);const I=c(r,"PageSize"),b=parseInt(I.getAttribute("x"),10),R=parseInt(I.getAttribute("y"),10),A=c(r,"DataValues");let F,_;A&&(_=A.getAttribute("NoData"),null!=_&&(F=_.trim().split(" ").map((t=>parseFloat(t)))));if(c(t,"MRF_META/CachedSource"))throw new e("mrf:open","currently does not support MRF referencing other data files");const S=c(t,"MRF_META/GeoTags"),k=c(S,"BoundingBox");let M,j=!1;if(null!=k){const t=parseFloat(k.getAttribute("minx")),e=parseFloat(k.getAttribute("miny")),r=parseFloat(k.getAttribute("maxx")),s=parseFloat(k.getAttribute("maxy")),o=p(S,"Projection")||"";let i=u.WGS84;if("LOCAL_CS[]"!==o)if(o.toLowerCase().startsWith("epsg:")){const t=Number(o.slice(5));isNaN(t)||0===t||(i=new u({wkid:t}))}else i=l(o)??u.WGS84;else j=!0,i=new u({wkid:3857});M=new g(t,e,r,s),M.spatialReference=i}else j=!0,M=new g({xmin:-.5,ymin:.5-n,xmax:o-.5,ymax:.5,spatialReference:new u({wkid:3857})});const C=c(t,"MRF_META/Rsets"),T=parseInt(C?.getAttribute("scale")||"2",10),L=M.spatialReference,U=new a({origin:new d({x:M.xmin,y:M.ymax,spatialReference:L}),blockWidth:b,blockHeight:R,pyramidBlockWidth:b,pyramidBlockHeight:R,compression:m,pyramidScalingFactor:T}),B=new d({x:M.width/o,y:M.height/n,spatialReference:L}),E=new i({width:o,height:n,extent:M,isPseudoSpatialReference:j,spatialReference:L,bandCount:f,pixelType:w,pixelSize:B,noDataValue:F,storageInfo:U}),P=p(t,"datafile"),W=p(t,"IndexFile");return{rasterInfo:E,files:{mrf:this.url,index:W||this.url.replace(".mrf",".idx"),data:P||this.url.replace(".mrf",x.get(m).blobExtension)}}}async _fetchAuxiliaryData(t){try{const{data:e}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:t?.signal});return f(e)}catch{return null}}};t([r()],w.prototype,"_files",void 0),t([r()],w.prototype,"_storageIndex",void 0),t([r({type:String,json:{write:!0}})],w.prototype,"datasetFormat",void 0),w=t([s("esri.layers.support.rasterIO.MRFRaster")],w);const I=w;export{I as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import i from"./ImageCanvasDecoder.js";import s from"./JpgPlus.js";import{load as r,decode as n}from"./Lerc.js";import{decode as o}from"./Lzw.js";import{convertNoDataToMask as h}from"./pixelRangeUtils.js";import{Z as c}from"../../../chunks/Zlib.js";import l from"./Raw.js";import{decodeTileOrStrip as p,decode as d}from"./TiffDecoder.js";import{isPlatformLittleEndian as u}from"./utils.js";var f=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,l,p,d,u,f,m,g,w,y,b,x,k,T,I,C;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new c(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=x=0;x<w;s=x+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=b=0:(y=f[(g-1)*w+i*u+s%u],b=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-b,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-b),l=h<=p&&h<=d?r:p<=d?y:b,f[a++]=(e+l)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const m=new Set(["jpg","png","bmp","gif"]);async function g(e,i){if(!u)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await r();const{offset:s}=i,{width:o,height:h,pixelType:c,statistics:l,depthCount:p,noDataValues:d,bandMasks:f,pixels:m,mask:g}=n(e,{inputOffset:s,returnInterleaved:i.returnInterleaved}),w=new a({width:o,height:h,pixelType:c.toLowerCase(),pixels:m,mask:g,statistics:l,bandMasks:f,depthCount:p,noDataValues:d});return l?.length||w.updateStatistics(),w}async function w(t,i){const s=await d(t,{...i,noDataValue:null});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function y(t,e){const i=await p(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function b(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function x(t,e){return b(new c(new Uint8Array(t)).getBytes(),e)}function k(t,e){return b(o(t,e.offset,e.eof,!e.isInputBigEndian),e)}function T(t,e,i){const{pixelTypeCtor:s}=D(e.pixelType),r=(0,l.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function I(t,e){const i=s.decode(t,e.hasNoZlibMask??void 0),r=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"U8",mask:i.mask,statistics:null});return r.updateStatistics(),r}function C(t,e){const i=new Uint8Array(t),s=new f(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"U8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function U(t,e,s,r){const n=new i,o={applyJpegMask:!1,format:e,...s},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function v(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function A(e){let a=null;switch(e){case"lerc":case"lerc2":a=g;break;case"jpg":a=I;break;case"png":a=C;break;case"bsq":case"bip":a=(t,a)=>T(t,a,e);break;case"tiff":a=w;break;case"deflate":a=x;break;case"lzw":a=k;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function D(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function O(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function P(t){let e=v(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function S(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return y(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=v(e)),i.useCanvas&&m.has(r))return U(e,r,i,s);const n=A(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:c}=i;if(c&&c.length>1){const t=c.map(((t,a)=>n(e.slice(t,c[a+1]),i))),s=await Promise.all(t);o=s[0],o.pixels=s.map((t=>t.pixels[0]));const r=s.map((t=>t.mask));s.some((t=>null!=t))&&(r.forEach(((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))})),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:c?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&h(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&O(o),o}export{S as decode,P as getFormat};
5
+ import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import{SimpleBandStatistics as i}from"../SimpleBandStatistics.js";import s from"./ImageCanvasDecoder.js";import r from"./JpgPlus.js";import{load as n,decode as o}from"./Lerc.js";import{decode as h}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{Z as l}from"../../../chunks/Zlib.js";import p from"./Raw.js";import{decodeTileOrStrip as d,decode as u}from"./TiffDecoder.js";import{isPlatformLittleEndian as f}from"./utils.js";var m=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,c,p,d,u,f,m,g,w,y,x,b,k,T,I,C;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new l(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<w;s=b+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=x=0:(y=f[(g-1)*w+i*u+s%u],x=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-x,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-x),c=h<=p&&h<=d?r:p<=d?y:x,f[a++]=(e+c)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const g=new Set(["jpg","png","bmp","gif"]);async function w(e,s){if(!f)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await n();const{offset:r}=s,{width:h,height:c,pixelType:l,statistics:p,depthCount:d,noDataValues:u,bandMasks:m,pixels:g,mask:w}=o(e,{inputOffset:r,returnInterleaved:s.returnInterleaved}),y=new a({width:h,height:c,pixelType:l.toLowerCase(),pixels:g,mask:w,statistics:p.map((({minValue:t,maxValue:e})=>new i(t,e))),bandMasks:m,depthCount:d,noDataValues:u});return p?.length||y.updateStatistics(),y}async function y(t,i){const s=await u(t,{...i,noDataValue:null});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function x(t,e){const i=await d(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function b(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function k(t,e){return b(new l(new Uint8Array(t)).getBytes(),e)}function T(t,e){return b(h(t,e.offset,e.eof,!e.isInputBigEndian),e)}function I(t,e,i){const{pixelTypeCtor:s}=S(e.pixelType),r=(0,p.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function C(t,e){const i=r.decode(t,e.hasNoZlibMask??void 0),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"u8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function v(t,e){const i=new Uint8Array(t),s=new m(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"u8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function A(t,e,i,r){const n=new s,o={applyJpegMask:!1,format:e,...i},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function U(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function D(e){let a=null;switch(e){case"lerc":case"lerc2":a=w;break;case"jpg":a=C;break;case"png":a=v;break;case"bsq":case"bip":a=(t,a)=>I(t,a,e);break;case"tiff":a=y;break;case"deflate":a=k;break;case"lzw":a=T;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function S(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function O(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function P(t){let e=U(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function j(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return x(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=U(e)),i.useCanvas&&g.has(r))return A(e,r,i,s);const n=D(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:h}=i;if(h&&h.length>1){const t=h.map(((t,a)=>n(e.slice(t,h[a+1]),i))),s=await Promise.all(t);o=s[0],o.pixels=s.map((t=>t.pixels[0]));const r=s.map((t=>t.mask));s.some((t=>null!=t))&&(r.forEach(((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))})),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:h?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&c(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&O(o),o}export{j as decode,P as getFormat};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import t from"../PixelBlock.js";import{isValidPixelBlock as e}from"./pixelUtils.js";const i=1,s=1/111e3;function n(t){let{altitude:e,azimuth:i}=t;const{hillshadeType:n,pixelSizePower:a=1,pixelSizeFactor:l=1,scalingType:o,isGCS:r,resolution:c}=t,h="multi-directional"===n?2*t.zFactor:t.zFactor,{x:u,y:f}=c;let d=h/(8*u),p=h/(8*f);if(r&&h>.001&&(d/=s,p/=s),"adjusted"===o)if(r){const t=u*s,e=f*s;d=(h+t**a*l)/(8*t),p=(h+e**a*l)/(8*e)}else d=(h+u**a*l)/(8*u),p=(h+f**a*l)/(8*f);let x=(90-e)*Math.PI/180,w=Math.cos(x),y=(360-i+90)*Math.PI/180,M=Math.sin(x)*Math.cos(y),m=Math.sin(x)*Math.sin(y);const A=[315,270,225,360,180,0],g=[60,60,60,60,60,90],k=new Float32Array([3,5,3,2,1,4]),z=k.reduce(((t,e)=>t+e)),F=k.map((t=>t/z)),P="multi-directional"===n?A.length:1,C=new Float32Array(6),Z=new Float32Array(6),v=new Float32Array(6);if("multi-directional"===n)for(let s=0;s<P;s++)e=g[s],i=A[s],x=(90-e)*Math.PI/180,w=Math.cos(x),y=(360-i+90)*Math.PI/180,M=Math.sin(x)*Math.cos(y),m=Math.sin(x)*Math.sin(y),C[s]=w,Z[s]=M,v[s]=m;else C.fill(w),Z.fill(M),v.fill(m);return{resolution:c,factor:[d,p],sinZcosA:M,sinZsinA:m,cosZ:w,sinZcosAs:Z,sinZsinAs:v,cosZs:C,weights:F,hillshadeType:["traditional","multi-directional"].indexOf(n)}}function a(t,e){const{width:s,height:n}=t,a=s*n,l=new Uint8Array(a),o=null!=t.mask;let r;if(o){r=new Uint8Array(t.mask);for(let t=0;t<r.length;t++)r[t]&&(l[t]=1,r[t]=1)}const c=t.pixels[0],h=new Float32Array(a),u=new Float32Array(a);let f,d=0;if(e){const{resolution:t}=e,i=t?(t.x+t.y)/2:1;d=200*e.zFactor/(i*i),f=new Float32Array(a)}const p=e?.curvatureType;let x,w,y,M,m,A,g,k;for(let z=i;z<n-i;z++){const t=z*s;for(let e=i;e<s-i;e++){const i=t+e;if(!r||0!==r[i]){if(r){if(r[i-s-1]+r[i-s]+r[i-s+1]+r[i-1]+r[i+1]+r[i+s-1]+r[i+s]+r[i+s+1]<7){l[i]=0;continue}x=r[i-s-1]?c[i-s-1]:c[i],w=r[i-s]?c[i-s]:c[i],y=r[i-s+1]?c[i-s+1]:c[i],M=r[i-1]?c[i-1]:c[i],m=r[i+1]?c[i+1]:c[i],A=r[i+s-1]?c[i+s-1]:c[i],g=r[i+s]?c[i+s]:c[i],k=r[i+s+1]?c[i+s+1]:c[i]}else x=c[i-s-1],w=c[i-s],y=c[i-s+1],M=c[i-1],m=c[i+1],A=c[i+s-1],g=c[i+s],k=c[i+s+1];if(h[i]=y+m+m+k-(x+M+M+A),u[i]=A+g+g+k-(x+w+w+y),null!=f){const t=c[i],e=.5*(M+m)-t,s=.5*(w+g)-t;if("standard"===p)f[i]=-d*(e+s);else{const t=(-x+y+A-k)/4,n=(-M+m)/2,a=(w-g)/2,l=n*n,o=a*a,r=l+o;r&&(f[i]="profile"===p?d*(e*l+s*o+t*n*a)/r:-d*(e*o+s*l-t*n*a)/r)}}}}}return{outMask:o?l:null,dzxs:h,dzys:u,curvatures:f}}function l(t,e,i){for(let s=0;s<i;s++)t[s*e]=t[s*e+1],t[(s+1)*e-1]=t[(s+1)*e-2];for(let s=1;s<e-1;s++)t[s]=t[s+e],t[s+(i-1)*e]=t[s+(i-2)*e]}function o(s,o){if(!e(s))return s;const{factor:r,sinZcosA:c,sinZsinA:h,cosZ:u,sinZcosAs:f,sinZsinAs:d,cosZs:p,weights:x}=n(o),[w,y]=r,M="traditional"===o.hillshadeType,{width:m,height:A}=s,g=new Uint8Array(m*A),{dzxs:k,dzys:z,outMask:F}=a(s);for(let t=i;t<A-i;t++){const e=t*m;for(let t=i;t<m-i;t++){const i=e+t;if(!F||F[i]){const t=k[i]*w,e=z[i]*y,s=Math.sqrt(1+t*t+e*e);let n=0;if(M){let i=255*(u+h*e-c*t)/s;i<0&&(i=0),n=i}else{const i=d.length;for(let a=0;a<i;a++){let i=255*(p[a]+d[a]*e-f[a]*t)/s;i<0&&(i=0),n+=i*x[a]}}g[i]=255&n}}}l(g,m,A);return new t({width:m,height:A,pixels:[g],mask:F,pixelType:"u8",validPixelCount:s.validPixelCount,statistics:[{minValue:0,maxValue:255}]})}function r(t,i,s,n){if(!e(t)||!e(i))return;const{min:a,max:l}=n,o=t.pixels[0],{pixels:r,mask:c}=i,h=r[0],u=255.00001/(l-a),f=new Uint8ClampedArray(h.length),d=new Uint8ClampedArray(h.length),p=new Uint8ClampedArray(h.length),x=s.length-1;for(let e=0;e<h.length;e++){if(c&&0===c[e])continue;const t=Math.floor((h[e]-a)*u),[i,n]=s[t<0?0:t>x?x:t],l=o[e],r=l*n,w=r*(1-Math.abs(i%2-1)),y=l-r;switch(Math.floor(i)){case 0:f[e]=r+y,d[e]=w+y,p[e]=y;break;case 1:f[e]=w+y,d[e]=r+y,p[e]=y;break;case 2:f[e]=y,d[e]=r+y,p[e]=w+y;break;case 3:f[e]=y,d[e]=w+y,p[e]=r+y;break;case 4:f[e]=w+y,d[e]=y,p[e]=r+y;break;case 5:case 6:f[e]=r+y,d[e]=y,p[e]=w+y}}t.pixels=[f,d,p],t.updateStatistics()}function c(n,o){if(!e(n))return n;const r=o.zFactor,c=o.pixelSizePower??1,h=o.pixelSizeFactor??1,u=o.slopeType,f=o.isGCS,{x:d,y:p}=o.resolution;let x=r/(8*d),w=r/(8*p);f&&Math.abs(r-1)<1e-4&&(x/=s,w/=s),"adjusted"===u&&(x=(r+d**c*h)/(8*d),w=(r+p**c*h)/(8*p));const{dzxs:y,dzys:M,outMask:m}=a(n),{width:A,height:g}=n,k=new Float32Array(A*g);for(let t=i;t<g-i;t++){const e=t*A;for(let t=i;t<A-i;t++){const i=e+t;if(!m||m[i]){const s=y[i]*x,n=M[i]*w,a=Math.sqrt(s*s+n*n);k[e+t]="percent-rise"===u?100*a:57.2957795*Math.atan(a)}}}l(k,A,g);const z=new t({width:A,height:g,pixels:[k],mask:m,pixelType:"f32",validPixelCount:n.validPixelCount});return z.updateStatistics(),z}function h(s,n={}){if(!e(s))return s;const{resolution:o}=n,r=o?1/o.x:1,c=o?1/o.y:1,{dzxs:h,dzys:u,outMask:f}=a(s),{width:d,height:p}=s,x=new Float32Array(d*p);for(let t=i;t<p-i;t++){const e=t*d;for(let t=i;t<d-i;t++){const i=e+t;if(!f||f[i]){const s=h[i]*r,n=u[i]*c;let a=-1;0===s&&0===n||(a=90-57.29578*Math.atan2(n,-s),a<0&&(a+=360),360===a?a=0:a>360&&(a%=360)),x[e+t]=a}}}l(x,d,p);return new t({width:d,height:p,pixels:[x],mask:f,pixelType:"f32",validPixelCount:s.validPixelCount,statistics:[{minValue:-1,maxValue:360}]})}function u(i,s){if(!e(i))return i;const{curvatures:n,outMask:o}=a(i,s),{width:r,height:c}=i;l(n,r,c);const h=new t({width:r,height:c,pixels:[n],mask:o,pixelType:"f32",validPixelCount:i.validPixelCount});return h.updateStatistics(),h}export{h as aspect,n as calculateHillshadeParams,u as curvature,s as gcsFactor,o as hillshade,c as slope,r as tintHillshade};
5
+ import t from"../PixelBlock.js";import{SimpleBandStatistics as e}from"../SimpleBandStatistics.js";import{isValidPixelBlock as i}from"./pixelUtils.js";const s=1,n=1/111e3;function o(t){let{altitude:e,azimuth:i}=t;const{hillshadeType:s,pixelSizePower:o=1,pixelSizeFactor:a=1,scalingType:l,isGCS:r,resolution:c}=t,h="multi-directional"===s?2*t.zFactor:t.zFactor,{x:u,y:f}=c;let d=h/(8*u),p=h/(8*f);if(r&&h>.001&&(d/=n,p/=n),"adjusted"===l)if(r){const t=u*n,e=f*n;d=(h+t**o*a)/(8*t),p=(h+e**o*a)/(8*e)}else d=(h+u**o*a)/(8*u),p=(h+f**o*a)/(8*f);let x=(90-e)*Math.PI/180,w=Math.cos(x),y=(360-i+90)*Math.PI/180,M=Math.sin(x)*Math.cos(y),m=Math.sin(x)*Math.sin(y);const A=[315,270,225,360,180,0],g=[60,60,60,60,60,90],k=new Float32Array([3,5,3,2,1,4]),z=k.reduce(((t,e)=>t+e)),F=k.map((t=>t/z)),P="multi-directional"===s?A.length:1,C=new Float32Array(6),Z=new Float32Array(6),v=new Float32Array(6);if("multi-directional"===s)for(let n=0;n<P;n++)e=g[n],i=A[n],x=(90-e)*Math.PI/180,w=Math.cos(x),y=(360-i+90)*Math.PI/180,M=Math.sin(x)*Math.cos(y),m=Math.sin(x)*Math.sin(y),C[n]=w,Z[n]=M,v[n]=m;else C.fill(w),Z.fill(M),v.fill(m);return{resolution:c,factor:[d,p],sinZcosA:M,sinZsinA:m,cosZ:w,sinZcosAs:Z,sinZsinAs:v,cosZs:C,weights:F,hillshadeType:["traditional","multi-directional"].indexOf(s)}}function a(t,e){const{width:i,height:n}=t,o=i*n,a=new Uint8Array(o),l=null!=t.mask;let r;if(l){r=new Uint8Array(t.mask);for(let t=0;t<r.length;t++)r[t]&&(a[t]=1,r[t]=1)}const c=t.pixels[0],h=new Float32Array(o),u=new Float32Array(o);let f,d=0;if(e){const{resolution:t}=e,i=t?(t.x+t.y)/2:1;d=200*e.zFactor/(i*i),f=new Float32Array(o)}const p=e?.curvatureType;let x,w,y,M,m,A,g,k;for(let z=s;z<n-s;z++){const t=z*i;for(let e=s;e<i-s;e++){const s=t+e;if(!r||0!==r[s]){if(r){if(r[s-i-1]+r[s-i]+r[s-i+1]+r[s-1]+r[s+1]+r[s+i-1]+r[s+i]+r[s+i+1]<7){a[s]=0;continue}x=r[s-i-1]?c[s-i-1]:c[s],w=r[s-i]?c[s-i]:c[s],y=r[s-i+1]?c[s-i+1]:c[s],M=r[s-1]?c[s-1]:c[s],m=r[s+1]?c[s+1]:c[s],A=r[s+i-1]?c[s+i-1]:c[s],g=r[s+i]?c[s+i]:c[s],k=r[s+i+1]?c[s+i+1]:c[s]}else x=c[s-i-1],w=c[s-i],y=c[s-i+1],M=c[s-1],m=c[s+1],A=c[s+i-1],g=c[s+i],k=c[s+i+1];if(h[s]=y+m+m+k-(x+M+M+A),u[s]=A+g+g+k-(x+w+w+y),null!=f){const t=c[s],e=.5*(M+m)-t,i=.5*(w+g)-t;if("standard"===p)f[s]=-d*(e+i);else{const t=(-x+y+A-k)/4,n=(-M+m)/2,o=(w-g)/2,a=n*n,l=o*o,r=a+l;r&&(f[s]="profile"===p?d*(e*a+i*l+t*n*o)/r:-d*(e*l+i*a-t*n*o)/r)}}}}}return{outMask:l?a:null,dzxs:h,dzys:u,curvatures:f}}function l(t,e,i){for(let s=0;s<i;s++)t[s*e]=t[s*e+1],t[(s+1)*e-1]=t[(s+1)*e-2];for(let s=1;s<e-1;s++)t[s]=t[s+e],t[s+(i-1)*e]=t[s+(i-2)*e]}function r(n,r){if(!i(n))return n;const{factor:c,sinZcosA:h,sinZsinA:u,cosZ:f,sinZcosAs:d,sinZsinAs:p,cosZs:x,weights:w}=o(r),[y,M]=c,m="traditional"===r.hillshadeType,{width:A,height:g}=n,k=new Uint8Array(A*g),{dzxs:z,dzys:F,outMask:P}=a(n);for(let t=s;t<g-s;t++){const e=t*A;for(let t=s;t<A-s;t++){const i=e+t;if(!P||P[i]){const t=z[i]*y,e=F[i]*M,s=Math.sqrt(1+t*t+e*e);let n=0;if(m){let i=255*(f+u*e-h*t)/s;i<0&&(i=0),n=i}else{const i=p.length;for(let o=0;o<i;o++){let i=255*(x[o]+p[o]*e-d[o]*t)/s;i<0&&(i=0),n+=i*w[o]}}k[i]=255&n}}}l(k,A,g);return new t({width:A,height:g,pixels:[k],mask:P,pixelType:"u8",validPixelCount:n.validPixelCount,statistics:[new e(0,255)]})}function c(t,e,s,n){if(!i(t)||!i(e))return;const{min:o,max:a}=n,l=t.pixels[0],{pixels:r,mask:c}=e,h=r[0],u=255.00001/(a-o),f=new Uint8ClampedArray(h.length),d=new Uint8ClampedArray(h.length),p=new Uint8ClampedArray(h.length),x=s.length-1;for(let i=0;i<h.length;i++){if(c&&0===c[i])continue;const t=Math.floor((h[i]-o)*u),[e,n]=s[t<0?0:t>x?x:t],a=l[i],r=a*n,w=r*(1-Math.abs(e%2-1)),y=a-r;switch(Math.floor(e)){case 0:f[i]=r+y,d[i]=w+y,p[i]=y;break;case 1:f[i]=w+y,d[i]=r+y,p[i]=y;break;case 2:f[i]=y,d[i]=r+y,p[i]=w+y;break;case 3:f[i]=y,d[i]=w+y,p[i]=r+y;break;case 4:f[i]=w+y,d[i]=y,p[i]=r+y;break;case 5:case 6:f[i]=r+y,d[i]=y,p[i]=w+y}}t.pixels=[f,d,p],t.updateStatistics()}function h(e,o){if(!i(e))return e;const r=o.zFactor,c=o.pixelSizePower??1,h=o.pixelSizeFactor??1,u=o.slopeType,f=o.isGCS,{x:d,y:p}=o.resolution;let x=r/(8*d),w=r/(8*p);f&&Math.abs(r-1)<1e-4&&(x/=n,w/=n),"adjusted"===u&&(x=(r+d**c*h)/(8*d),w=(r+p**c*h)/(8*p));const{dzxs:y,dzys:M,outMask:m}=a(e),{width:A,height:g}=e,k=new Float32Array(A*g);for(let t=s;t<g-s;t++){const e=t*A;for(let t=s;t<A-s;t++){const i=e+t;if(!m||m[i]){const s=y[i]*x,n=M[i]*w,o=Math.sqrt(s*s+n*n);k[e+t]="percent-rise"===u?100*o:57.2957795*Math.atan(o)}}}l(k,A,g);const z=new t({width:A,height:g,pixels:[k],mask:m,pixelType:"f32",validPixelCount:e.validPixelCount});return z.updateStatistics(),z}function u(n,o={}){if(!i(n))return n;const{resolution:r}=o,c=r?1/r.x:1,h=r?1/r.y:1,{dzxs:u,dzys:f,outMask:d}=a(n),{width:p,height:x}=n,w=new Float32Array(p*x);for(let t=s;t<x-s;t++){const e=t*p;for(let t=s;t<p-s;t++){const i=e+t;if(!d||d[i]){const s=u[i]*c,n=f[i]*h;let o=-1;0===s&&0===n||(o=90-57.29578*Math.atan2(n,-s),o<0&&(o+=360),360===o?o=0:o>360&&(o%=360)),w[e+t]=o}}}l(w,p,x);return new t({width:p,height:x,pixels:[w],mask:d,pixelType:"f32",validPixelCount:n.validPixelCount,statistics:[new e(-1,360)]})}function f(e,s){if(!i(e))return e;const{curvatures:n,outMask:o}=a(e,s),{width:r,height:c}=e;l(n,r,c);const h=new t({width:r,height:c,pixels:[n],mask:o,pixelType:"f32",validPixelCount:e.validPixelCount});return h.updateStatistics(),h}export{u as aspect,o as calculateHillshadeParams,f as curvature,n as gcsFactor,r as hillshade,h as slope,c as tintHillshade};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.30.0-next.20240210",
3
+ "version": "4.30.0-next.20240213",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "@esri/calcite-colors": "~6.1.0",
30
30
  "@esri/calcite-components": "^2.4.0",
31
31
  "@popperjs/core": "~2.11.8",
32
- "@vaadin/grid": "~24.3.5",
32
+ "@vaadin/grid": "~24.3.6",
33
33
  "@zip.js/zip.js": "~2.7.34",
34
34
  "luxon": "~3.4.4",
35
35
  "sortablejs": "~1.15.2"
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import t from"../../core/Error.js";import{join as r,getPathExtension as s}from"../../core/urlUtils.js";async function o(e,t={},s){await e.load(s);const o=r(e.itemUrl,"resources"),{start:a=1,num:n=10,sortOrder:c="asc",sortField:l="created"}=t,i={query:{start:a,num:n,sortOrder:c,sortField:l,token:e.apiKey},signal:s?.signal},u=await e.portal.request(o,i);return{total:u.total,nextStart:u.nextStart,resources:u.resources.map((({created:t,size:r,resource:s})=>({created:new Date(t),size:r,resource:e.resourceFromPath(s)})))}}async function a(e,s,o,a){const n=new Map;for(const{resource:r,content:i,compress:u,access:p}of s){if(!r.hasPath())throw new t(`portal-item-resource-${o}:invalid-path`,"Resource does not have a valid path");const[e,s]=l(r.path),a=`${e}/${u??""}/${p??""}`;n.has(a)||n.set(a,{prefix:e,compress:u,access:p,files:[]});n.get(a).files.push({fileName:s,content:i})}await e.load(a);const c=r(e.userItemUrl,"add"===o?"addResources":"updateResources");for(const{prefix:t,compress:r,access:l,files:i}of n.values()){const s=25;for(let o=0;o<i.length;o+=s){const n=i.slice(o,o+s),u=new FormData;t&&"."!==t&&u.append("resourcesPrefix",t),r&&u.append("compress","true"),l&&u.append("access",l);let p=0;for(const{fileName:e,content:t}of n)u.append("file"+ ++p,t,e);u.append("f","json"),await e.portal.request(c,{method:"post",body:u,signal:a?.signal})}}}async function n(e,s,o){if(!s.hasPath())throw new t("portal-item-resources-remove:invalid-path","Resource does not have a valid path");await e.load(o);const a=r(e.userItemUrl,"removeResources");await e.portal.request(a,{method:"post",query:{resource:s.path},signal:o?.signal}),s.portalItem=null}async function c(e,t){await e.load(t);const s=r(e.userItemUrl,"removeResources");return e.portal.request(s,{method:"post",query:{deleteAll:!0},signal:t?.signal})}function l(e){const t=e.lastIndexOf("/");return-1===t?[".",e]:[e.slice(0,t),e.slice(t+1)]}function i(e){const[t,r]=u(e),[s,o]=l(t);return[s,o,r]}function u(e){const t=s(e);return null==t?[e,""]:[e.slice(0,e.length-t.length-1),`.${t}`]}async function p(t){if("blob"===t.type)return t.blob;if("json"===t.type)return new Blob([t.jsonString],{type:"application/json"});return(await e(t.url,{responseType:"blob"})).data}function f(e,t){if(!e.hasPath())return null;const[s,,o]=i(e.path);return e.portalItem.resourceFromPath(r(s,t+o))}function d(e,t){if(!e.hasPath())return null;const[s,,o]=i(e.path);return e.portalItem.resourceFromPath(r(s,t+o))}export{a as addOrUpdateResources,p as contentToBlob,o as fetchResources,f as getSiblingOfSameType,d as getSiblingOfSameTypeI,c as removeAllResources,n as removeResource,i as splitPrefixFileNameAndExtension};
5
+ import e from"../../request.js";import t from"../../core/Error.js";import{join as r,getPathExtension as s}from"../../core/urlUtils.js";async function o(e,t={},s){await e.load(s);const o=r(e.itemUrl,"resources"),{start:a=1,num:n=10,sortOrder:c="asc",sortField:l="resource"}=t,i={query:{start:a,num:n,sortOrder:c,sortField:l,token:e.apiKey},signal:s?.signal},u=await e.portal.request(o,i);return{total:u.total,nextStart:u.nextStart,resources:u.resources.map((({created:t,size:r,resource:s})=>({created:new Date(t),size:r,resource:e.resourceFromPath(s)})))}}async function a(e,s,o,a){const n=new Map;for(const{resource:r,content:i,compress:u,access:p}of s){if(!r.hasPath())throw new t(`portal-item-resource-${o}:invalid-path`,"Resource does not have a valid path");const[e,s]=l(r.path),a=`${e}/${u??""}/${p??""}`;n.has(a)||n.set(a,{prefix:e,compress:u,access:p,files:[]});n.get(a).files.push({fileName:s,content:i})}await e.load(a);const c=r(e.userItemUrl,"add"===o?"addResources":"updateResources");for(const{prefix:t,compress:r,access:l,files:i}of n.values()){const s=25;for(let o=0;o<i.length;o+=s){const n=i.slice(o,o+s),u=new FormData;t&&"."!==t&&u.append("resourcesPrefix",t),r&&u.append("compress","true"),l&&u.append("access",l);let p=0;for(const{fileName:e,content:t}of n)u.append("file"+ ++p,t,e);u.append("f","json"),await e.portal.request(c,{method:"post",body:u,signal:a?.signal})}}}async function n(e,s,o){if(!s.hasPath())throw new t("portal-item-resources-remove:invalid-path","Resource does not have a valid path");await e.load(o);const a=r(e.userItemUrl,"removeResources");await e.portal.request(a,{method:"post",query:{resource:s.path},signal:o?.signal}),s.portalItem=null}async function c(e,t){await e.load(t);const s=r(e.userItemUrl,"removeResources");return e.portal.request(s,{method:"post",query:{deleteAll:!0},signal:t?.signal})}function l(e){const t=e.lastIndexOf("/");return-1===t?[".",e]:[e.slice(0,t),e.slice(t+1)]}function i(e){const[t,r]=u(e),[s,o]=l(t);return[s,o,r]}function u(e){const t=s(e);return null==t?[e,""]:[e.slice(0,e.length-t.length-1),`.${t}`]}async function p(t){if("blob"===t.type)return t.blob;if("json"===t.type)return new Blob([t.jsonString],{type:"application/json"});return(await e(t.url,{responseType:"blob"})).data}function f(e,t){if(!e.hasPath())return null;const[s,,o]=i(e.path);return e.portalItem.resourceFromPath(r(s,t+o))}function m(e,t){if(!e.hasPath())return null;const[s,,o]=i(e.path);return e.portalItem.resourceFromPath(r(s,t+o))}export{a as addOrUpdateResources,p as contentToBlob,o as fetchResources,f as getSiblingOfSameType,m as getSiblingOfSameTypeI,c as removeAllResources,n as removeResource,i as splitPrefixFileNameAndExtension};