@arcgis/core 4.28.0-next.20230911 → 4.28.0-next.20230913

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 (136) hide show
  1. package/arcade/Feature.js +1 -1
  2. package/arcade/arcadeTimeUtils.js +1 -1
  3. package/arcade/executionError.js +1 -1
  4. package/arcade/featureSetUtils.js +1 -1
  5. package/arcade/featureset/actions/Adapted.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/support/FeatureSet.js +1 -1
  8. package/arcade/featureset/support/errorsupport.js +1 -1
  9. package/arcade/functions/featuresetbase.js +1 -1
  10. package/arcade/functions/featuresetstats.js +1 -1
  11. package/arcade/functions/string.js +1 -1
  12. package/arcade.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/0920312e3c7b63c2e253.js +1 -0
  15. package/assets/esri/core/workers/chunks/0cb007ab5db0a2a598ec.js +1 -0
  16. package/assets/esri/core/workers/chunks/0cc61f1b2c0473ded5c2.js +1 -0
  17. package/assets/esri/core/workers/chunks/0f804e3f888cb4998f46.js +1 -0
  18. package/assets/esri/core/workers/chunks/189dd81cf95bd8417ee3.js +1 -0
  19. package/assets/esri/core/workers/chunks/1a723bb4a341f645e5fe.js +1 -0
  20. package/assets/esri/core/workers/chunks/24c717492ea1b35310d8.js +1 -0
  21. package/assets/esri/core/workers/chunks/{3ce73dd4113dbc7d11de.js → 2eb58dc339b2bb03d9e3.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{38c07a8574352a7f2f6d.js → 2ff0dbd5eb7ca57bb7fc.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{768f3db2705fa9e57641.js → 49dfdc0463450491df9d.js} +1 -1
  24. package/assets/esri/core/workers/chunks/650a317b6dc245a7060f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{56ed099745360888604e.js → 67f01c71280fa0759742.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{f62842807744bdfaced7.js → 67fab13f56b340076763.js} +1 -1
  27. package/assets/esri/core/workers/chunks/6d94b358e8d1cf79bba3.js +1 -0
  28. package/assets/esri/core/workers/chunks/718607d7a3b33fc33b0a.js +1 -0
  29. package/assets/esri/core/workers/chunks/{4c63d6b9460aa6ae9843.js → 860417f4138f53d315ba.js} +2 -2
  30. package/assets/esri/core/workers/chunks/8aa7e994b74f66522c37.js +1 -0
  31. package/assets/esri/core/workers/chunks/9fa485b04b997b0a5509.js +1 -0
  32. package/assets/esri/core/workers/chunks/a047fcf3c7307a69b63c.js +1 -0
  33. package/assets/esri/core/workers/chunks/a753d9874801cd448946.js +1 -0
  34. package/assets/esri/core/workers/chunks/c51233ad51823cb98c35.js +1 -0
  35. package/assets/esri/core/workers/chunks/c61f20d91a5c432b07dc.js +1 -0
  36. package/assets/esri/core/workers/chunks/d3d11242e5af57ba77f4.js +1 -0
  37. package/assets/esri/core/workers/chunks/dbf343d1fb746f99bb6e.js +1 -0
  38. package/assets/esri/core/workers/chunks/{271ec1d1666bf6dc3dda.js → dc74b4ec85e8e3de5b27.js} +1 -1
  39. package/assets/esri/core/workers/chunks/e8a8791d765ab6c450dd.js +1 -0
  40. package/assets/esri/core/workers/chunks/{5fe7b5665710ec6d3046.js → eb0d1c5c96f735c162d3.js} +1 -1
  41. package/assets/esri/themes/base/widgets/_Sketch.scss +0 -5
  42. package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +0 -5
  43. package/assets/esri/themes/dark/main.css +1 -1
  44. package/assets/esri/themes/light/main.css +1 -1
  45. package/assets/esri/themes/light/view.css +1 -1
  46. package/chunks/HUDMaterial.glsl.js +38 -45
  47. package/chunks/languageUtils.js +1 -1
  48. package/core/promiseUtils.js +1 -1
  49. package/core/sql/AggregateFunctions.js +1 -1
  50. package/core/sql/DateOnly.js +1 -1
  51. package/core/sql/SqlTimestampOffset.js +1 -1
  52. package/core/sql/TimeOnly.js +1 -1
  53. package/core/sql/WhereClause.js +1 -1
  54. package/core/sql/WhereGrammar.js +1 -1
  55. package/core/sql/sqlCompareUtils.js +1 -1
  56. package/geometry/GeometryCursor.js +1 -1
  57. package/geometry/Mesh.js +1 -1
  58. package/geometry/support/labelPoint.js +1 -1
  59. package/geometry/support/meshUtils/bounds.js +1 -1
  60. package/geometry/support/meshUtils/georeference.js +1 -1
  61. package/interfaces.d.ts +190 -144
  62. package/layers/ImageryLayer.js +1 -1
  63. package/layers/SceneLayer.js +1 -1
  64. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  65. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  66. package/layers/graphics/sources/csv/csv.js +1 -1
  67. package/layers/support/FetchAssociatedFeatureLayer.js +1 -1
  68. package/layers/support/TilemapCache.js +1 -1
  69. package/layers/support/fieldUtils.js +1 -1
  70. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  71. package/layers/support/wmsUtils.js +1 -1
  72. package/layers/video/VideoController.js +1 -1
  73. package/package.json +3 -3
  74. package/smartMapping/heuristics/sizeRange.js +1 -1
  75. package/smartMapping/labels/bins.js +1 -1
  76. package/smartMapping/labels/clusters.js +1 -1
  77. package/smartMapping/labels/support/utils.js +1 -1
  78. package/smartMapping/popup/support/clusterUtils.js +1 -1
  79. package/smartMapping/support/clusterUtils.js +1 -1
  80. package/support/revision.js +1 -1
  81. package/views/2d/engine/webgl/DisplayId.js +1 -1
  82. package/views/2d/engine/webgl/Utils.js +1 -1
  83. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  84. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  85. package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
  86. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  87. package/views/3d/analysis/Dimension/LengthDimensionVisualization.js +1 -1
  88. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  89. package/views/3d/analysis/Dimension/settings.js +1 -1
  90. package/views/3d/interactive/Manipulator3D.js +1 -1
  91. package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +1 -1
  92. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  93. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  94. package/views/3d/layers/I3SMeshView3D.js +1 -1
  95. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  96. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  97. package/views/3d/layers/SceneLayerWorker.js +1 -1
  98. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  99. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  100. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  101. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  102. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  103. package/views/ToolViewManager.js +1 -1
  104. package/views/View.js +1 -1
  105. package/views/animation/easing.js +1 -1
  106. package/views/webgl/FramebufferObject.js +1 -1
  107. package/views/webgl/RenderingContext.js +1 -1
  108. package/views/webgl/enums.js +1 -1
  109. package/views/webgl/renderState.js +1 -1
  110. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  111. package/widgets/Feature/FeatureMedia.js +1 -1
  112. package/widgets/FeatureForm.js +1 -1
  113. package/widgets/Features.js +1 -1
  114. package/widgets/Search/SearchViewModel.js +1 -1
  115. package/widgets/support/SketchTooltipControls/SketchTooltipControlsViewModel.js +1 -1
  116. package/widgets/support/SketchTooltipControls.js +1 -1
  117. package/widgets/support/SnappingControls.js +1 -1
  118. package/assets/esri/core/workers/chunks/055575ed2ab78be0bdb2.js +0 -1
  119. package/assets/esri/core/workers/chunks/0ee90a0b4d09a56c0d48.js +0 -1
  120. package/assets/esri/core/workers/chunks/15056f91d87f11b00bcc.js +0 -1
  121. package/assets/esri/core/workers/chunks/344e40934c98d6fe66ae.js +0 -1
  122. package/assets/esri/core/workers/chunks/558049fcac3a82a093fc.js +0 -1
  123. package/assets/esri/core/workers/chunks/5c41eb67d19b8710118a.js +0 -1
  124. package/assets/esri/core/workers/chunks/5d183ac1a8b68ba9c656.js +0 -1
  125. package/assets/esri/core/workers/chunks/610d4a5d2511fa81460e.js +0 -1
  126. package/assets/esri/core/workers/chunks/6755bb1f2a6575a8e082.js +0 -1
  127. package/assets/esri/core/workers/chunks/84173936b309712ba9b3.js +0 -1
  128. package/assets/esri/core/workers/chunks/877302d6e39a0d530aab.js +0 -1
  129. package/assets/esri/core/workers/chunks/a07dc782e69111e2eeaf.js +0 -1
  130. package/assets/esri/core/workers/chunks/b825019841247d173072.js +0 -1
  131. package/assets/esri/core/workers/chunks/bed1bc13b168fae46404.js +0 -1
  132. package/assets/esri/core/workers/chunks/c8dd21a332559c99815c.js +0 -1
  133. package/assets/esri/core/workers/chunks/ccc3564e76c0ec5c0228.js +0 -1
  134. package/assets/esri/core/workers/chunks/d0a81c7ec8a84eeadd31.js +0 -1
  135. package/assets/esri/core/workers/chunks/e7a852b319c1d89eddc5.js +0 -1
  136. package/assets/esri/core/workers/chunks/ebde11fdccb437954ce7.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.28/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 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/arrayUtils.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 T}from"./RawBlockCache.js";import{convertNoDataToMask as b}from"../rasterFormats/pixelRangeUtils.js";import{decode as v}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as W,projectPoint as C,snapPyramid as j,shiftExtent as H,getWorldWrapCount as z,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 G from"../../../geometry/Extent.js";import q from"../../../geometry/Point.js";const J=8,N=256;let V=class extends(n(o)){constructor(){super(...arguments),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&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=W(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))}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 this.fetchPixels(n,r.size[0],r.size[1],o)}async identify(e,t={}){e=a(q,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=C(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:i}=r,o=3,n=i.x*o/2,s=i.y*o/2,l=new G({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,o,o,a),{pixelBlock:f}=await this.fetchPixels(l,o,o,a);if(null==c)return{location:h,value:null};const u=Math.floor(o*o*.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,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:T,blockWidth:b}=y,v=l??t.sliceId,P=R(this.url,v),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(null==_||!_.pixels?.length)return{location:h,value:null};const W=k*b+T;return this._processIdentifyResult(_,{srcLocation:h,position:W,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=H(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:r}=this;if(o.requestRawData&&r)return this._fetchPixels(e,t,i,o);const n=W(e.spatialReference),s=z(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 G({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 G({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?v(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.push(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new q({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 q({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=C(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 G({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}async _fetchPixels(e,t,i,o={}){let r=z(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!=W(e.spatialReference);!p&&d||(r=z(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 q({x:R,y:w,spatialReference:S}),T=g===c&&I===m&&f.x%g==0&&f.y%I==0,b=new q({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),v=!e.spatialReference.equals(S),C=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=o;if(!v&&T&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,b,C))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const H=d&&null!=W(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:b.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||H,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:L},o):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:b,datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||H,isAdaptive:!1,includeGCSGrid:L});let F;const A=!o.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},J=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:J,blockWidths:null},o);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:J});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:T,maxRow:b}=w;if(0===u&&(R<S||I<k||g>b||y>T))return null;const v=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let z=g;z<=R;z++)for(let t=y;t<=I;t++){let i=t;if(!o.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),z>=S&&i>=k&&b>=z&&T>=i){const t=this._fetchRawTile(e,z,i,o);B?v.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):v.push(t)}else v.push(Promise.resolve(null))}if(0===v.length)return null;const M=await Promise.all(v),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:W}=this.rasterInfo,C=this.getPyramidPixelSize(e),{x:j,y:H}=C;return{extent:new G({xmin:r.x+y*s*j,xmax:r.x+(I+1)*s*j,ymin:r.y-(R+1)*l*H,ymax:r.y-g*l*H,spatialReference:W}),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.url,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,(()=>{T(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._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=D(this.rasterInfo)),null==this._rasterTileAlighmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.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 q({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;return Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1])>=N||e/i>J||t/o>J}_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&&(b(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()],V.prototype,"_rasterTileAlighmentInfo",void 0),e([l({readOnly:!0})],V.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],V.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],V.prototype,"rasterJobHandler",null),e([l(f)],V.prototype,"url",null),e([l({type:String,json:{write:!0}})],V.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],V.prototype,"datasetFormat",void 0),e([l()],V.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],V.prototype,"rasterInfo",void 0),e([l()],V.prototype,"ioConfig",void 0),e([l()],V.prototype,"sourceJSON",void 0),V=e([c("esri.layers.support.rasterDatasets.BaseRaster")],V);const U=V;export{U 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/arrayUtils.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 T}from"./RawBlockCache.js";import{convertNoDataToMask as b}from"../rasterFormats/pixelRangeUtils.js";import{decode as v}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as W,projectPoint as C,snapPyramid as j,shiftExtent as H,getWorldWrapCount as z,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 G from"../../../geometry/Extent.js";import q from"../../../geometry/Point.js";const J=8,N=256;let V=class extends(n(o)){constructor(){super(...arguments),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&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=W(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))}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 this.fetchPixels(n,r.size[0],r.size[1],o)}async identify(e,t={}){e=a(q,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=C(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:i}=r,o=3,n=i.x*o/2,s=i.y*o/2,l=new G({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,o,o,a),{pixelBlock:f}=await this.fetchPixels(l,o,o,a);if(null==c)return{location:h,value:null};const u=Math.floor(o*o*.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,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:T,blockWidth:b}=y,v=l??t.sliceId,P=R(this.url,v),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(null==_||!_.pixels?.length)return{location:h,value:null};const W=k*b+T;return this._processIdentifyResult(_,{srcLocation:h,position:W,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=H(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:r}=this;if(o.requestRawData&&r)return this._fetchPixels(e,t,i,o);const n=W(e.spatialReference),s=z(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 G({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 G({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?v(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 q({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 q({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=C(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 G({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}async _fetchPixels(e,t,i,o={}){let r=z(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!=W(e.spatialReference);!p&&d||(r=z(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 q({x:R,y:w,spatialReference:S}),T=g===c&&I===m&&f.x%g==0&&f.y%I==0,b=new q({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),v=!e.spatialReference.equals(S),C=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=o;if(!v&&T&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,b,C))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const H=d&&null!=W(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:b.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||H,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:L},o):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:b,datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||H,isAdaptive:!1,includeGCSGrid:L});let F;const A=!o.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},J=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:J,blockWidths:null},o);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:J});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:T,maxRow:b}=w;if(0===u&&(R<S||I<k||g>b||y>T))return null;const v=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let z=g;z<=R;z++)for(let t=y;t<=I;t++){let i=t;if(!o.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),z>=S&&i>=k&&b>=z&&T>=i){const t=this._fetchRawTile(e,z,i,o);B?v.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):v.push(t)}else v.push(Promise.resolve(null))}if(0===v.length)return null;const M=await Promise.all(v),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:W}=this.rasterInfo,C=this.getPyramidPixelSize(e),{x:j,y:H}=C;return{extent:new G({xmin:r.x+y*s*j,xmax:r.x+(I+1)*s*j,ymin:r.y-(R+1)*l*H,ymax:r.y-g*l*H,spatialReference:W}),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.url,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,(()=>{T(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._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=D(this.rasterInfo)),null==this._rasterTileAlighmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.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 q({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;return Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1])>=N||e/i>J||t/o>J}_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&&(b(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()],V.prototype,"_rasterTileAlighmentInfo",void 0),e([l({readOnly:!0})],V.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],V.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],V.prototype,"rasterJobHandler",null),e([l(f)],V.prototype,"url",null),e([l({type:String,json:{write:!0}})],V.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],V.prototype,"datasetFormat",void 0),e([l()],V.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],V.prototype,"rasterInfo",void 0),e([l()],V.prototype,"ioConfig",void 0),e([l()],V.prototype,"sourceJSON",void 0),V=e([c("esri.layers.support.rasterDatasets.BaseRaster")],V);const U=V;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.28/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{urlToObject as n}from"../../core/urlUtils.js";import r from"../../geometry/Extent.js";import i from"../../geometry/SpatialReference.js";import{isAxesOrderReversedForWkid as s}from"../ogc/crsUtils.js";const o={84:4326,83:4269,27:4267};function l(n){if(!n)return null;const i={idCounter:-1};if("string"==typeof n){n=(new DOMParser).parseFromString(n,"text/xml")}const s=n.documentElement;if("ServiceExceptionReport"===s.nodeName){const e=Array.prototype.slice.call(s.childNodes).map((e=>e.textContent)).join("\r\n");throw new t("wmslayer:wms-capabilities-xml-is-not-valid","The server returned errors when the WMS capabilities were requested.",e)}const o=d("Capability",s),l=d("Service",s),a=o&&d("Request",o);if(!o||!l||!a)return null;const m=d("Layer",o);if(!m)return null;const f="WMS_Capabilities"===s.nodeName||"WMT_MS_Capabilities"===s.nodeName?s.getAttribute("version"):"1.3.0",p=h("Title",l,"")||h("Name",l,""),x=h("AccessConstraints",l,""),y=/^none$/i.test(x)?"":x,S=h("Abstract",l,""),E=parseInt(h("MaxWidth",l,"5000"),10),w=parseInt(h("MaxHeight",l,"5000"),10),L=N(a,"GetMap"),M=g(a,"GetMap"),C=b(m,f,i);if(!C)return null;let v,I=0;const R=Array.prototype.slice.call(o.childNodes),U=C.sublayers??[],T=e=>{null!=e&&U.push(e)};R.forEach((e=>{"Layer"===e.nodeName&&(0===I?v=e:1===I?(C.name&&(C.name="",T(b(v,f,i))),T(b(e,f,i))):T(b(e,f,i)),I++)}));let V=C.sublayers,O=C.extent;const _=C.fullExtents??[];if(V||(V=[]),0===V.length&&V.push(C),!O){const e=new r(V[0].extent);C.extent=e.toJSON(),O=C.extent}const B=C.spatialReferences.length>0?C.spatialReferences:u(C),D=g(a,"GetFeatureInfo"),j=D?N(a,"GetFeatureInfo"):null,k=c(V),q=C.minScale||0,X=C.maxScale||0,G=C.dimensions??[],W=k.reduce(((e,t)=>e.concat(t.dimensions??[])),[]),P=G.concat(W).filter(F);let $=null;if(P.length){const t=P.map((e=>{const{extent:t}=e;return A(t)?t.map((e=>e.getTime())):t?.map((e=>[e.min.getTime(),e.max.getTime()]))})).flat(2).filter(e);$={startTimeField:null,endTimeField:null,trackIdField:void 0,timeExtent:[Math.min(...t),Math.max(...t)]}}return{copyright:y,description:S,dimensions:G,extent:O,fullExtents:_,featureInfoFormats:j,featureInfoUrl:D,mapUrl:M,maxWidth:E,maxHeight:w,maxScale:X,minScale:q,layers:k,spatialReferences:B,supportedImageFormatTypes:L,timeInfo:$,title:p,version:f}}function a(e){const t=e.filter((e=>e.popupEnabled&&e.name&&e.queryable));return t.length?t.map((({name:e})=>e)).join():null}function u(e){if(e.spatialReferences.length>0)return e.spatialReferences;if(e.sublayers)for(const t of e.sublayers){const e=u(t);if(e.length>0)return e}return[]}function c(e){let t=[];for(const n of e)t.push(n),n.sublayers?.length&&(t=t.concat(c(n.sublayers)),delete n.sublayers);return t}function m(e,t,n){return t.getAttribute(e)??n}function f(e,t,n,r){const i=d(e,n);return i?m(t,i,r):r}function d(e,t){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(S(r)&&r.nodeName===e)return r}return null}function p(e,t){if(null==t)return[];const n=[];for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes[r];S(i)&&i.nodeName===e&&n.push(i)}return n}function h(e,t,n){return d(e,t)?.textContent??n}function x(e,t,n){if(!e)return null;const s=parseFloat(e.getAttribute("minx")),o=parseFloat(e.getAttribute("miny")),l=parseFloat(e.getAttribute("maxx")),a=parseFloat(e.getAttribute("maxy"));let u,c,m,f;n?(u=isNaN(o)?-Number.MAX_VALUE:o,c=isNaN(s)?-Number.MAX_VALUE:s,m=isNaN(a)?Number.MAX_VALUE:a,f=isNaN(l)?Number.MAX_VALUE:l):(u=isNaN(s)?-Number.MAX_VALUE:s,c=isNaN(o)?-Number.MAX_VALUE:o,m=isNaN(l)?Number.MAX_VALUE:l,f=isNaN(a)?Number.MAX_VALUE:a);const d=new i({wkid:t});return new r({xmin:u,ymin:c,xmax:m,ymax:f,spatialReference:d})}function g(e,t){const n=d(t,e);if(n){const e=d("DCPType",n);if(e){const t=d("HTTP",e);if(t){const e=d("Get",t);if(e){let t=f("OnlineResource","xlink:href",e,null);if(t)return t.indexOf("&")===t.length-1&&(t=t.substring(0,t.length-1)),M(t,["service","request"])}}}}return null}function N(t,n){const r=p("Operation",t);if(!r.length){return p("Format",d(n,t)).map((({textContent:e})=>e)).filter(e)}const i=[];for(const e of r)if(e.getAttribute("name")===n){const t=p("Format",e);for(const{textContent:e}of t)null!=e&&i.push(e)}return i}function y(e,t,n){const r=d(t,e);if(!r)return n;const{textContent:i}=r;if(null==i||""===i)return n;const s=Number(i);return isNaN(s)?n:s}function b(e,t,n){if(!e)return null;const l={id:n.idCounter++,fullExtents:[],parentLayerId:null,queryable:"1"===e.getAttribute("queryable"),spatialReferences:[],sublayers:null},a=d("LatLonBoundingBox",e),u=d("EX_GeographicBoundingBox",e);let c=null;a&&(c=x(a,4326)),u&&(c=new r(0,0,0,0,new i({wkid:4326})),c.xmin=parseFloat(h("westBoundLongitude",u,"0")),c.ymin=parseFloat(h("southBoundLatitude",u,"0")),c.xmax=parseFloat(h("eastBoundLongitude",u,"0")),c.ymax=parseFloat(h("northBoundLatitude",u,"0"))),a||u||(c=new r(-180,-90,180,90,new i({wkid:4326}))),l.minScale=y(e,"MaxScaleDenominator",0),l.maxScale=y(e,"MinScaleDenominator",0);const f=["1.0.0","1.1.0","1.1.1"].includes(t)?"SRS":"CRS";return Array.prototype.slice.call(e.childNodes).forEach((e=>{if("Name"===e.nodeName)l.name=e.textContent||"";else if("Title"===e.nodeName)l.title=e.textContent||"";else if("Abstract"===e.nodeName)l.description=e.textContent||"";else if("BoundingBox"===e.nodeName){const n=e.getAttribute(f);if(n&&0===n.indexOf("EPSG:")){const r=parseInt(n.substring(5),10);0===r||isNaN(r)||c||(c="1.3.0"===t?x(e,r,s(r)):x(e,r))}const r=n&&n.indexOf(":");if(r&&r>-1){let i=parseInt(n.substring(r+1,n.length),10);0===i||isNaN(i)||(i=o[i]??i);const a="1.3.0"===t?x(e,i,s(i)):x(e,i);a&&l.fullExtents&&l.fullExtents.push(a)}}else if(e.nodeName===f){(e.textContent?.split(" ")??[]).forEach((e=>{const t=e.includes(":")?parseInt(e.split(":")[1],10):parseInt(e,10);if(0!==t&&!isNaN(t)){const e=o[t]??t;l.spatialReferences.includes(e)||l.spatialReferences.push(e)}}))}else if("Style"!==e.nodeName||l.legendUrl){if("Layer"===e.nodeName){const r=b(e,t,n);r&&(r.parentLayerId=l.id,l.sublayers||(l.sublayers=[]),l.sublayers.push(r))}}else{const t=d("LegendURL",e);if(t){const e=d("OnlineResource",t);e&&(l.legendUrl=e.getAttribute("xlink:href"))}}})),l.extent=c?.toJSON(),l.dimensions=p("Dimension",e).filter((e=>e.getAttribute("name")&&e.getAttribute("units")&&e.textContent)).map((e=>{const t=e.getAttribute("name"),n=e.getAttribute("units"),r=e.textContent,i=e.getAttribute("unitSymbol")??void 0,s=e.getAttribute("default")??void 0,o="0"!==m("default",e,"0"),l="0"!==m("nearestValue",e,"0"),a="0"!==m("current",e,"0");if(F({name:t,units:n})){return{name:"time",units:"ISO8601",extent:I(r),default:I(s),multipleValues:o,nearestValue:l,current:a}}if(w({name:t,units:n})){return{name:"elevation",units:n,extent:C(r),unitSymbol:i,default:C(s),multipleValues:o,nearestValue:l}}return{name:t,units:n,extent:v(r),unitSymbol:i,default:v(s),multipleValues:o,nearestValue:l}})),l}function A(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof Date}function S(e){return e.nodeType===Node.ELEMENT_NODE}function E(e){return void 0!==e.min&&void 0!==e.max}function w(e){return/^elevation$/i.test(e.name)&&/^(epsg|crs):\d+$/i.test(e.units)}function L(e){return!F(e)&&!w(e)}function F(e){return/^time$/i.test(e.name)&&/^iso8601$/i.test(e.units)}function M(e,t){const r=[],i=n(e);for(const n in i.query)i.query.hasOwnProperty(n)&&(t.includes(n.toLowerCase())||r.push(n+"="+i.query[n]));return i.path+(r.length?"?"+r.join("&"):"")}function C(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:parseFloat(t[0]),max:parseFloat(t[1]),resolution:t.length>=3&&"0"!==t[2]?parseFloat(t[2]):void 0}})).filter(e):r.map((e=>parseFloat(e)))}function v(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:t[0],max:t[1],resolution:t.length>=3&&"0"!==t[2]?t[2]:void 0}})).filter(e):r}function I(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:new Date(t[0]),max:new Date(t[1]),resolution:t.length>=3&&"0"!==t[2]?R(t[2]):void 0}})).filter(e):r.map((e=>new Date(e)))}function R(e){const t=/(?:p(\d+y|\d+(?:.|,)\d+y)?(\d+m|\d+(?:.|,)\d+m)?(\d+d|\d+(?:.|,)\d+d)?)?(?:t(\d+h|\d+(?:.|,)\d+h)?(\d+m|\d+(?:.|,)\d+m)?(\d+s|\d+(?:.|,)\d+s)?)?/i,n=e.match(t);if(!n)return null;return{years:U(n[1]),months:U(n[2]),days:U(n[3]),hours:U(n[4]),minutes:U(n[5]),seconds:U(n[6])}}function U(e){if(!e)return 0;const t=/(?:\d+(?:.|,)\d+|\d+)/,n=e.match(t);if(!n)return 0;const r=n[0].replace(",",".");return Number(r)}function T(e){return e.toISOString().replace(/\.[0-9]{3}/,"")}const V=new Set([102100,3857,102113,900913]),O=new Set([3395,54004]);function _(e,t){let n=e.wkid;return null==t?n:(null!=n&&t.includes(n)||!e.latestWkid||(n=e.latestWkid),null!=n&&V.has(n)?t.find((e=>V.has(e)))||t.find((e=>O.has(e)))||102100:n)}export{R as fromISODuration,a as getPopupLayers,E as isDimensionInterval,w as isElevationDimension,L as isGenericDimension,F as isTimeDimension,_ as normalizeWKID,l as parseCapabilities,T as toISOString};
5
+ import{isSome as e}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{urlToObject as n}from"../../core/urlUtils.js";import r from"../../geometry/Extent.js";import i from"../../geometry/SpatialReference.js";import{isAxesOrderReversedForWkid as s}from"../ogc/crsUtils.js";const o={84:4326,83:4269,27:4267};function l(n){if(!n)return null;const i={idCounter:-1};if("string"==typeof n){n=(new DOMParser).parseFromString(n,"text/xml")}const s=n.documentElement;if("ServiceExceptionReport"===s.nodeName){const e=Array.prototype.slice.call(s.childNodes).map((e=>e.textContent)).join("\r\n");throw new t("wmslayer:wms-capabilities-xml-is-not-valid","The server returned errors when the WMS capabilities were requested.",e)}const o=d("Capability",s),l=d("Service",s),a=o&&d("Request",o);if(!o||!l||!a)return null;const m=d("Layer",o);if(!m)return null;const f="WMS_Capabilities"===s.nodeName||"WMT_MS_Capabilities"===s.nodeName?s.getAttribute("version"):"1.3.0",p=h("Title",l,"")||h("Name",l,""),x=h("AccessConstraints",l,""),y=/^none$/i.test(x)?"":x,S=h("Abstract",l,""),E=parseInt(h("MaxWidth",l,"5000"),10),w=parseInt(h("MaxHeight",l,"5000"),10),L=N(a,"GetMap"),M=g(a,"GetMap"),C=b(m,f,i);if(!C)return null;let v,I=0;const R=Array.prototype.slice.call(o.childNodes),U=C.sublayers??[],T=e=>{null!=e&&U.push(e)};R.forEach((e=>{"Layer"===e.nodeName&&(0===I?v=e:1===I?(C.name&&(C.name="",T(b(v,f,i))),T(b(e,f,i))):T(b(e,f,i)),I++)}));let V=C.sublayers,O=C.extent;const _=C.fullExtents??[];if(V||(V=[]),0===V.length&&V.push(C),!O){const e=new r(V[0].extent);C.extent=e.toJSON(),O=C.extent}const B=C.spatialReferences.length>0?C.spatialReferences:u(C),D=g(a,"GetFeatureInfo"),j=D?N(a,"GetFeatureInfo"):null,k=c(V),q=C.minScale||0,X=C.maxScale||0,G=C.dimensions??[],W=k.reduce(((e,t)=>e.concat(t.dimensions??[])),[]),P=G.concat(W).filter(F);let $=null;if(P.length){const t=P.map((e=>{const{extent:t}=e;return A(t)?t.map((e=>e.getTime())):t?.map((e=>[e.min.getTime(),e.max.getTime()]))})).flat(2).filter(e);$={startTimeField:null,endTimeField:null,trackIdField:void 0,timeExtent:[Math.min(...t),Math.max(...t)]}}return{copyright:y,description:S,dimensions:G,extent:O,fullExtents:_,featureInfoFormats:j,featureInfoUrl:D,mapUrl:M,maxWidth:E,maxHeight:w,maxScale:X,minScale:q,layers:k,spatialReferences:B,supportedImageFormatTypes:L,timeInfo:$,title:p,version:f}}function a(e){const t=e.filter((e=>e.popupEnabled&&e.name&&e.queryable));return t.length?t.map((({name:e})=>e)).join():null}function u(e){if(e.spatialReferences.length>0)return e.spatialReferences;if(e.sublayers)for(const t of e.sublayers){const e=u(t);if(e.length>0)return e}return[]}function c(e){let t=[];for(const n of e)t.push(n),n.sublayers?.length&&(t=t.concat(c(n.sublayers)),delete n.sublayers);return t}function m(e,t,n){return t.getAttribute(e)??n}function f(e,t,n,r){const i=d(e,n);return i?m(t,i,r):r}function d(e,t){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(S(r)&&r.nodeName===e)return r}return null}function p(e,t){if(null==t)return[];const n=[];for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes[r];S(i)&&i.nodeName===e&&n.push(i)}return n}function h(e,t,n){return d(e,t)?.textContent??n}function x(e,t,n){if(!e)return null;const s=parseFloat(e.getAttribute("minx")),o=parseFloat(e.getAttribute("miny")),l=parseFloat(e.getAttribute("maxx")),a=parseFloat(e.getAttribute("maxy"));let u,c,m,f;n?(u=isNaN(o)?-Number.MAX_VALUE:o,c=isNaN(s)?-Number.MAX_VALUE:s,m=isNaN(a)?Number.MAX_VALUE:a,f=isNaN(l)?Number.MAX_VALUE:l):(u=isNaN(s)?-Number.MAX_VALUE:s,c=isNaN(o)?-Number.MAX_VALUE:o,m=isNaN(l)?Number.MAX_VALUE:l,f=isNaN(a)?Number.MAX_VALUE:a);const d=new i({wkid:t});return new r({xmin:u,ymin:c,xmax:m,ymax:f,spatialReference:d})}function g(e,t){const n=d(t,e);if(n){const e=d("DCPType",n);if(e){const t=d("HTTP",e);if(t){const e=d("Get",t);if(e){let t=f("OnlineResource","xlink:href",e,null);if(t)return t.indexOf("&")===t.length-1&&(t=t.substring(0,t.length-1)),M(t,["service","request"])}}}}return null}function N(t,n){const r=p("Operation",t);if(!r.length){return p("Format",d(n,t)).map((({textContent:e})=>e)).filter(e)}const i=[];for(const e of r)if(e.getAttribute("name")===n){const t=p("Format",e);for(const{textContent:e}of t)null!=e&&i.push(e)}return i}function y(e,t,n){const r=d(t,e);if(!r)return n;const{textContent:i}=r;if(null==i||""===i)return n;const s=Number(i);return isNaN(s)?n:s}function b(e,t,n){if(!e)return null;const l={id:n.idCounter++,fullExtents:[],parentLayerId:null,queryable:"1"===e.getAttribute("queryable"),spatialReferences:[],sublayers:null},a=d("LatLonBoundingBox",e),u=d("EX_GeographicBoundingBox",e);let c=null;a&&(c=x(a,4326)),u&&(c=new r(0,0,0,0,new i({wkid:4326})),c.xmin=parseFloat(h("westBoundLongitude",u,"0")),c.ymin=parseFloat(h("southBoundLatitude",u,"0")),c.xmax=parseFloat(h("eastBoundLongitude",u,"0")),c.ymax=parseFloat(h("northBoundLatitude",u,"0"))),a||u||(c=new r(-180,-90,180,90,new i({wkid:4326}))),l.minScale=y(e,"MaxScaleDenominator",0),l.maxScale=y(e,"MinScaleDenominator",0);const f=["1.0.0","1.1.0","1.1.1"].includes(t)?"SRS":"CRS";return Array.prototype.slice.call(e.childNodes).forEach((e=>{if("Name"===e.nodeName)l.name=e.textContent||"";else if("Title"===e.nodeName)l.title=e.textContent||"";else if("Abstract"===e.nodeName)l.description=e.textContent||"";else if("BoundingBox"===e.nodeName){const n=e.getAttribute(f);if(n&&0===n.indexOf("EPSG:")){const r=parseInt(n.substring(5),10);0===r||isNaN(r)||c||(c="1.3.0"===t?x(e,r,s(r)):x(e,r))}const r=n&&n.indexOf(":");if(r&&r>-1){let i=parseInt(n.substring(r+1,n.length),10);0===i||isNaN(i)||(i=o[i]??i);const a="1.3.0"===t?x(e,i,s(i)):x(e,i);a&&l.fullExtents&&l.fullExtents.push(a)}}else if(e.nodeName===f){(e.textContent?.split(" ")??[]).forEach((e=>{const t=e.includes(":")?parseInt(e.split(":")[1],10):parseInt(e,10);if(0!==t&&!isNaN(t)){const e=o[t]??t;l.spatialReferences.includes(e)||l.spatialReferences.push(e)}}))}else if("Style"!==e.nodeName||l.legendUrl){if("Layer"===e.nodeName){const r=b(e,t,n);r&&(r.parentLayerId=l.id,l.sublayers||(l.sublayers=[]),l.sublayers.push(r))}}else{const t=d("LegendURL",e);if(t){const e=d("OnlineResource",t);e&&(l.legendUrl=e.getAttribute("xlink:href"))}}})),l.extent=c?.toJSON(),l.dimensions=p("Dimension",e).filter((e=>e.getAttribute("name")&&e.getAttribute("units")&&e.textContent)).map((e=>{const t=e.getAttribute("name"),n=e.getAttribute("units"),r=e.textContent,i=e.getAttribute("unitSymbol")??void 0,s=e.getAttribute("default")??void 0,o="0"!==m("default",e,"0"),l="0"!==m("nearestValue",e,"0"),a="0"!==m("current",e,"0");if(F({name:t,units:n})){return{name:"time",units:"ISO8601",extent:I(r),default:I(s),multipleValues:o,nearestValue:l,current:a}}if(w({name:t,units:n})){return{name:"elevation",units:n,extent:C(r),unitSymbol:i,default:C(s),multipleValues:o,nearestValue:l}}return{name:t,units:n,extent:v(r),unitSymbol:i,default:v(s),multipleValues:o,nearestValue:l}})),l}function A(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof Date}function S(e){return e.nodeType===Node.ELEMENT_NODE}function E(e){return void 0!==e.min&&void 0!==e.max}function w(e){return/^elevation$/i.test(e.name)&&/^(epsg|crs):\d+$/i.test(e.units)}function L(e){return!F(e)&&!w(e)}function F(e){return/^time$/i.test(e.name)&&/^iso8601$/i.test(e.units)}function M(e,t){const r=[],i=n(e);for(const n in i.query)i.query.hasOwnProperty(n)&&(t.includes(n.toLowerCase())||r.push(n+"="+i.query[n]));return i.path+(r.length?"?"+r.join("&"):"")}function C(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:parseFloat(t[0]),max:parseFloat(t[1]),resolution:t.length>=3&&"0"!==t[2]?parseFloat(t[2]):void 0}})).filter(e):r.map((e=>parseFloat(e)))}function v(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:t[0],max:t[1],resolution:t.length>=3&&"0"!==t[2]?t[2]:void 0}})).filter(e):r}function I(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:new Date(t[0]),max:new Date(t[1]),resolution:t.length>=3&&"0"!==t[2]?R(t[2]):void 0}})).filter(e):r.map((e=>new Date(e)))}function R(e){const t=/(?:p(\d+y|\d+(?:\.|,)\d+y)?(\d+m|\d+(?:\.|,)\d+m)?(\d+d|\d+(?:\.|,)\d+d)?)?(?:t(\d+h|\d+(?:\.|,)\d+h)?(\d+m|\d+(?:\.|,)\d+m)?(\d+s|\d+(?:\.|,)\d+s)?)?/i,n=e.match(t);if(!n)return null;return{years:U(n[1]),months:U(n[2]),days:U(n[3]),hours:U(n[4]),minutes:U(n[5]),seconds:U(n[6])}}function U(e){if(!e)return 0;const t=/(?:\d+(?:\.|,)\d+|\d+)/,n=e.match(t);if(!n)return 0;const r=n[0].replace(",",".");return Number(r)}function T(e){return e.toISOString().replace(/\.[0-9]{3}/,"")}const V=new Set([102100,3857,102113,900913]),O=new Set([3395,54004]);function _(e,t){let n=e.wkid;return null==t?n:(null!=n&&t.includes(n)||!e.latestWkid||(n=e.latestWkid),null!=n&&V.has(n)?t.find((e=>V.has(e)))||t.find((e=>O.has(e)))||102100:n)}export{R as fromISODuration,a as getPopupLayers,E as isDimensionInterval,w as isElevationDimension,L as isGenericDimension,F as isTimeDimension,_ as normalizeWKID,l as parseCapabilities,T as toISOString};