@arcgis/core 5.2.0-next.154 → 5.2.0-next.156

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 (240) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{d994bcf0a65d1c07160f.js → 0320cbd825f9a4222042.js} +1 -1
  3. package/assets/esri/core/workers/chunks/0590857215c547e63b51.js +1 -0
  4. package/assets/esri/core/workers/chunks/08fe248e412bb170210d.js +1 -0
  5. package/assets/esri/core/workers/chunks/0cb50bc2b2125c5fedf2.js +1 -0
  6. package/assets/esri/core/workers/chunks/1201b8c5852830836eac.js +1 -0
  7. package/assets/esri/core/workers/chunks/129e04d24ced77c9bb6d.js +1 -0
  8. package/assets/esri/core/workers/chunks/15e1117a706a98b17ad5.js +1 -0
  9. package/assets/esri/core/workers/chunks/164e74d586297946a717.js +1 -0
  10. package/assets/esri/core/workers/chunks/168a523bdc3653081f8a.js +1 -0
  11. package/assets/esri/core/workers/chunks/{6f4e6022a52de0c54aab.js → 172cfeb5f415e4662432.js} +1 -1
  12. package/assets/esri/core/workers/chunks/1aa4f5394a596e544aeb.js +1 -0
  13. package/assets/esri/core/workers/chunks/22b01fe31bbf0bdc48db.js +1 -0
  14. package/assets/esri/core/workers/chunks/27c2da2e779def2ee08b.js +1 -0
  15. package/assets/esri/core/workers/chunks/28b74bc77f7c13080074.js +1 -0
  16. package/assets/esri/core/workers/chunks/{481589c3eddad6e026ad.js → 369780276b2755361f7d.js} +1 -1
  17. package/assets/esri/core/workers/chunks/3914d96147642a9d4b01.js +1 -0
  18. package/assets/esri/core/workers/chunks/{731018c0deffc41ffc97.js → 3e3e076fa5e8d5d5f33f.js} +1 -1
  19. package/assets/esri/core/workers/chunks/43cf862577bf37344ff4.js +1 -0
  20. package/assets/esri/core/workers/chunks/4932773663469919d10a.js +1 -0
  21. package/assets/esri/core/workers/chunks/4996869b9cbd8c8ddcfa.js +1 -0
  22. package/assets/esri/core/workers/chunks/4c389472b8cdb0c55154.js +1 -0
  23. package/assets/esri/core/workers/chunks/4e4f747de424941a0bfa.js +1 -0
  24. package/assets/esri/core/workers/chunks/{eb815148ae65388dd733.js → 544070198d2ca556103a.js} +1 -1
  25. package/assets/esri/core/workers/chunks/5736feefa261589b6273.js +1 -0
  26. package/assets/esri/core/workers/chunks/{aeaaff7a4b1a99540f52.js → 5cb26bbaa08114aec5ce.js} +1 -1
  27. package/assets/esri/core/workers/chunks/5f4feca26102088ea565.js +1 -0
  28. package/assets/esri/core/workers/chunks/{407f1e8176f3b0af73b4.js → 66867e523cc82f8fe35b.js} +1 -1
  29. package/assets/esri/core/workers/chunks/6f73e41e14817acfaead.js +1 -0
  30. package/assets/esri/core/workers/chunks/{320e5942a098dd104366.js → 74137ffec5265628c33b.js} +1 -1
  31. package/assets/esri/core/workers/chunks/7446d0dfebf93e86c098.js +1 -0
  32. package/assets/esri/core/workers/chunks/{688f2dbf784e66082308.js → 74c866e0b66e61751861.js} +1 -1
  33. package/assets/esri/core/workers/chunks/7711ae5612f685078fc8.js +1 -0
  34. package/assets/esri/core/workers/chunks/{5116b569a8dbda4910c8.js → 784a2fba3e18286958d1.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{693873b3eb99fba58fa9.js → 78c4e43cfa1eda06b4d9.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{f6e62d2d279a328cbed7.js → 7bcedf479b07a4b4a234.js} +1 -1
  37. package/assets/esri/core/workers/chunks/81cad8d2f62a5f671c55.js +1 -0
  38. package/assets/esri/core/workers/chunks/{588e677f33df86a595bf.js → 820c8aaf3632edb0150c.js} +1 -1
  39. package/assets/esri/core/workers/chunks/842893e75696428d536f.js +1 -0
  40. package/assets/esri/core/workers/chunks/8e19629899a5becf8e19.js +1 -0
  41. package/assets/esri/core/workers/chunks/950d4578dc450467404c.js +1 -0
  42. package/assets/esri/core/workers/chunks/{68be3fb88ca61f82fb90.js → 95dbbddac6581b9d671f.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{a4162a8660bf763d542d.js → 967b4992b400517ee712.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{adf25e5ed99615b83c68.js → a62c12925303ff802c3d.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{900181f68449d8f82eeb.js → aa1ac7954e4f0fefe15b.js} +1 -1
  46. package/assets/esri/core/workers/chunks/ac24b4370dc7194a3107.js +1 -0
  47. package/assets/esri/core/workers/chunks/acdfd275dbf8533a67f3.js +1 -0
  48. package/assets/esri/core/workers/chunks/ace2e0a9d9013edd8624.js +1 -0
  49. package/assets/esri/core/workers/chunks/b1d5d236d5268fcbc74b.js +1 -0
  50. package/assets/esri/core/workers/chunks/b3007aedbf731dacaff1.js +1 -0
  51. package/assets/esri/core/workers/chunks/{53e2f2b922116a45fe8f.js → b573df59391ca41ee5a7.js} +1 -1
  52. package/assets/esri/core/workers/chunks/bac8c32665e982896ecc.js +1 -0
  53. package/assets/esri/core/workers/chunks/{f3da30d7300b92bd8bb0.js → befa32b9e7b3fbdd431e.js} +1 -1
  54. package/assets/esri/core/workers/chunks/c19f238b55ff2893f7c2.js +1 -0
  55. package/assets/esri/core/workers/chunks/c5ed67fdf261cbb1624b.js +1 -0
  56. package/assets/esri/core/workers/chunks/c72a904e01dc8c17d992.js +1 -0
  57. package/assets/esri/core/workers/chunks/d9b1aed88b205689cec6.js +1 -0
  58. package/assets/esri/core/workers/chunks/de6081df29183bf80787.js +1 -0
  59. package/assets/esri/core/workers/chunks/{c598b22f78ccc57f9d6d.js → dfd2dc5cdc97ffba8926.js} +1 -1
  60. package/assets/esri/core/workers/chunks/e1b7806ab3e1967b15f0.js +1 -0
  61. package/assets/esri/core/workers/chunks/e653c81ffb3d818645dd.js +1 -0
  62. package/assets/esri/core/workers/chunks/eaddffcc7004101fc230.js +1 -0
  63. package/assets/esri/core/workers/chunks/eb2652ec48faa78de3c5.js +1 -0
  64. package/assets/esri/core/workers/chunks/{c62738f84c914671b143.js → f4a7aa3cdbc0c429c359.js} +1 -1
  65. package/assets/esri/core/workers/chunks/fda83bcb8e40e8044c24.js +1 -0
  66. package/assets/esri/libs/pdfjs/wasm/openjpeg_nowasm_fallback.js +1 -0
  67. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -0
  68. package/assets/esri/themes/dark/main.css +1 -1
  69. package/assets/esri/themes/light/main.css +1 -1
  70. package/assets/esri/themes/light/view.css +1 -1
  71. package/assets/esri/widgets/support/uriUtils/t9n/messages.fr.json +1 -1
  72. package/config.d.ts +2 -0
  73. package/config.js +1 -1
  74. package/core/ObjectPool.js +1 -1
  75. package/core/PooledArray.js +1 -1
  76. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  77. package/geometry/support/buffer/BufferPool.js +1 -1
  78. package/geometry/support/coordsUtils.js +1 -1
  79. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  80. package/geometry/support/curves/mathUtils.js +1 -1
  81. package/interfaces.d.ts +18 -9
  82. package/kernel.js +1 -1
  83. package/layers/AnnotationFeatureLayer.d.ts +2 -2
  84. package/layers/AnnotationFeatureLayer.js +1 -1
  85. package/layers/CatalogLayer.d.ts +2 -2
  86. package/layers/CatalogLayer.js +1 -1
  87. package/layers/DimensionFeatureLayer.d.ts +2 -2
  88. package/layers/DimensionFeatureLayer.js +1 -1
  89. package/layers/FeatureLayer.d.ts +2 -2
  90. package/layers/FeatureLayer.js +1 -1
  91. package/layers/SubtypeGroupLayer.d.ts +2 -2
  92. package/layers/SubtypeGroupLayer.js +1 -1
  93. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  94. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +9 -9
  95. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  96. package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
  97. package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
  98. package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
  99. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  100. package/layers/graphics/sources/GeoJSONSource.js +1 -1
  101. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  102. package/layers/graphics/sources/parquet/FileProvider.js +1 -1
  103. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  104. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  105. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  106. package/layers/mixins/{FeatureLayerReload.d.ts → ReloadableLayer.d.ts} +5 -3
  107. package/layers/mixins/ReloadableLayer.js +2 -0
  108. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  109. package/layers/raster/datasets/BaseRaster.js +1 -1
  110. package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
  111. package/layers/raster/datasets/ImageAuxRaster.js +1 -1
  112. package/layers/raster/datasets/ImageServerRaster.js +1 -1
  113. package/layers/raster/datasets/MRFRaster.js +1 -1
  114. package/layers/raster/datasets/TIFFRaster.js +1 -1
  115. package/layers/raster/datasets/WCSRaster.js +1 -1
  116. package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
  117. package/layers/raster/formats/RasterCodec.js +1 -1
  118. package/layers/raster/formats/TiffDecoder.js +1 -1
  119. package/layers/raster/formats/Zlib.js +1 -1
  120. package/layers/support/RasterWorker.js +1 -1
  121. package/layers/support/fieldUtils.js +1 -1
  122. package/layers/support/vectorTileLayerLoader.js +1 -1
  123. package/package.json +2 -2
  124. package/popup/FeatureModel.js +1 -1
  125. package/popup/FeaturesModel.js +1 -1
  126. package/portal/schemas/definitions.js +1 -1
  127. package/request/process.js +1 -1
  128. package/request/types.d.ts +7 -0
  129. package/symbols/cim/cimAnalyzer.js +1 -1
  130. package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
  131. package/views/2d/engine/vectorTiles/style/GeoJSONVectorTileSource.js +1 -1
  132. package/views/2d/engine/vectorTiles/style/GeoJSONVectorTileSourceWorker.js +1 -1
  133. package/views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js +2 -0
  134. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
  135. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  136. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  137. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  138. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  139. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  140. package/views/3d/analysis/LineOfSight/LineOfSightObserverPlugin.js +1 -1
  141. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  142. package/views/3d/analysis/LineOfSight/{LineOfSightRootPlugin.js → LineOfSightPlacementRootPlugin.js} +1 -1
  143. package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
  144. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  145. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  146. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  147. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  148. package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
  149. package/views/3d/support/MemoryController.js +1 -1
  150. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  151. package/views/3d/webgl-engine/effects/geometry/RenderOccluded.js +1 -1
  152. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  153. package/views/3d/webgl-engine/lib/PathCapBuilder.js +1 -1
  154. package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
  155. package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
  156. package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
  157. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  158. package/views/draw/DrawTool.js +1 -1
  159. package/views/draw/support/PluginContext.js +1 -1
  160. package/views/draw/support/managers/TooltipManager.js +1 -1
  161. package/views/draw/support/types.d.ts +5 -2
  162. package/webdoc/applicationProperties/SearchLayerField.d.ts +7 -1
  163. package/webdoc/applicationProperties/SearchLayerField.js +1 -1
  164. package/webdoc/applicationProperties/SearchTableField.d.ts +7 -1
  165. package/webdoc/applicationProperties/SearchTableField.js +1 -1
  166. package/webdoc/applicationProperties/searchMode.js +2 -0
  167. package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
  168. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  169. package/widgets/BatchAttributeForm.js +1 -1
  170. package/widgets/Editor/EditorViewModel.d.ts +10 -1
  171. package/widgets/Editor.d.ts +10 -1
  172. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  173. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  174. package/widgets/HistogramRangeSlider.d.ts +2 -2
  175. package/widgets/HistogramRangeSlider.js +1 -1
  176. package/widgets/Legend.d.ts +1 -0
  177. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  178. package/widgets/OrientedImageryViewer.js +2 -2
  179. package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
  180. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.d.ts +5 -2
  181. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  182. package/widgets/ScaleRangeSlider.js +1 -1
  183. package/widgets/Search/LayerSearchSource.d.ts +23 -1
  184. package/widgets/Search/LayerSearchSource.js +1 -1
  185. package/widgets/Search/support/layerSearchUtils.js +1 -1
  186. package/widgets/Search/types.d.ts +7 -0
  187. package/widgets/ValuePicker/ValuePickerBaseComponent.d.ts +5 -1
  188. package/widgets/ValuePicker/ValuePickerCollection.d.ts +2 -0
  189. package/widgets/ValuePicker/ValuePickerCombobox.d.ts +7 -1
  190. package/widgets/ValuePicker/ValuePickerLabel.d.ts +7 -1
  191. package/widgets/ValuePicker/ValuePickerSlider.d.ts +2 -0
  192. package/widgets/ValuePicker/ValuePickerSliderVisibleElements.d.ts +5 -1
  193. package/widgets/ValuePicker/ValuePickerVisibleElements.d.ts +5 -1
  194. package/widgets/ValuePicker/types.d.ts +2 -0
  195. package/widgets/support/forms/formUtils.js +1 -1
  196. package/widgets/support/forms/types.d.ts +1 -1
  197. package/assets/esri/core/workers/chunks/03261b9451e293a0fac8.js +0 -1
  198. package/assets/esri/core/workers/chunks/03afeefb9d16b6f1d844.js +0 -1
  199. package/assets/esri/core/workers/chunks/09b9a886363bc1197785.js +0 -1
  200. package/assets/esri/core/workers/chunks/0ad0484ffcbe4ad21bd3.js +0 -1
  201. package/assets/esri/core/workers/chunks/19743dedaa40446259ec.js +0 -1
  202. package/assets/esri/core/workers/chunks/1c65ab9ed611c322ce27.js +0 -1
  203. package/assets/esri/core/workers/chunks/1f339247b68b061ab0a4.js +0 -1
  204. package/assets/esri/core/workers/chunks/251921cd10ecfbc89451.js +0 -1
  205. package/assets/esri/core/workers/chunks/3252b1fae363bb0129a0.js +0 -1
  206. package/assets/esri/core/workers/chunks/408e81c8f1eff8a7b379.js +0 -1
  207. package/assets/esri/core/workers/chunks/4fc337240e7cddd0e988.js +0 -1
  208. package/assets/esri/core/workers/chunks/50036a323c2e7f155311.js +0 -1
  209. package/assets/esri/core/workers/chunks/55dcbf296d8d0092e473.js +0 -1
  210. package/assets/esri/core/workers/chunks/5732fdf6d8b87739aeea.js +0 -1
  211. package/assets/esri/core/workers/chunks/5924ec3167a2941ebb1f.js +0 -1
  212. package/assets/esri/core/workers/chunks/59b216b60464611742d4.js +0 -1
  213. package/assets/esri/core/workers/chunks/5bfea0c55aca826de536.js +0 -1
  214. package/assets/esri/core/workers/chunks/5fa1ec357c3ad1f91bc7.js +0 -1
  215. package/assets/esri/core/workers/chunks/60d3056a31d982c9cad0.js +0 -1
  216. package/assets/esri/core/workers/chunks/6558488ea96620439f34.js +0 -1
  217. package/assets/esri/core/workers/chunks/6aebf7cfd294e88bf926.js +0 -1
  218. package/assets/esri/core/workers/chunks/6b43bb78f9839ed43135.js +0 -1
  219. package/assets/esri/core/workers/chunks/6c83398cf586ecea0eb1.js +0 -1
  220. package/assets/esri/core/workers/chunks/7267b17de212207142c9.js +0 -1
  221. package/assets/esri/core/workers/chunks/7d1fd2df579a4b535e0e.js +0 -1
  222. package/assets/esri/core/workers/chunks/7e0cf70c0eb5a2ddfcec.js +0 -1
  223. package/assets/esri/core/workers/chunks/879b2de825c1dfc8849d.js +0 -1
  224. package/assets/esri/core/workers/chunks/912080c90b5cc2e817cf.js +0 -1
  225. package/assets/esri/core/workers/chunks/917f53833b853898facc.js +0 -1
  226. package/assets/esri/core/workers/chunks/937824bc7948f7bc7845.js +0 -1
  227. package/assets/esri/core/workers/chunks/a97d85774f9a417202df.js +0 -1
  228. package/assets/esri/core/workers/chunks/aff32980d91dab07dfb7.js +0 -1
  229. package/assets/esri/core/workers/chunks/b132ffa7e8bb461b6786.js +0 -1
  230. package/assets/esri/core/workers/chunks/b1b4066e8d1c0c9656e5.js +0 -1
  231. package/assets/esri/core/workers/chunks/b6ba66a05030d3815dfd.js +0 -1
  232. package/assets/esri/core/workers/chunks/bbec9d2e3b75a5c59681.js +0 -1
  233. package/assets/esri/core/workers/chunks/bf69024804ac51c8f733.js +0 -1
  234. package/assets/esri/core/workers/chunks/d938987344bce83cc660.js +0 -1
  235. package/assets/esri/core/workers/chunks/db1ab9b9c8bf5c7635d3.js +0 -1
  236. package/assets/esri/core/workers/chunks/e01aeac34474540f61ee.js +0 -1
  237. package/assets/esri/core/workers/chunks/e15ba90af0faf873b42d.js +0 -1
  238. package/assets/esri/core/workers/chunks/fd9663952d5a94f3a83f.js +0 -1
  239. package/layers/mixins/FeatureLayerReload.js +0 -2
  240. /package/views/3d/analysis/LineOfSight/{lineOfSightPlacementUtils.js → placementUtils.js} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Point.js";import{GeospatialPDFWorkerClient as a}from"../../geospatialPDF/GeospatialPDFWorkerClient.js";import o from"./BaseRaster.js";import s from"../../support/PixelBlock.js";import c from"../../support/RasterInfo.js";let l=class extends o{constructor(){super(...arguments),this._workerClient=new a,this._extent=null,this._ctm=null,this._neatlineRing=[],this._width=0,this._height=0,this._tileSize=512,this.datasetFormat=`PDF`,this.frame=null,this.neatlineExtent=null,this.page=1,this.tileType=`Raster`}destroy(){this._workerClient.destroy(),this.neatlineExtent=null,this._extent=null,this._ctm=null,this._neatlineRing=[]}async fetchRawTile(e,t,n,r={}){let i=this._extent,a=this._ctm,o=this.getTileExtentPDF(e,t,n);return o.intersects(i)?d(await this._workerClient.render(o,this._tileSize,this._tileSize,a,this._neatlineRing,r)):null}async _open(e){if(!this.url)throw new t(`geospatial-pdf-raster:open`,`GeospatialPDFRaster requires a url.`);let n=await this._workerClient.loadPDF({url:this.url,page:this.page},e);this.frame=n.frame;let r=this.frame.outerExtentMediabox;if(!r)throw new t(`geospatial-pdf-raster:open`,`Failed to compute Geospatial PDF extent.`);this.neatlineExtent=n.fullExtent,this._extent=r,this._ctm=this.frame.ctm,this._neatlineRing=this.frame.sourceMediaBoxPolygon.rings[0];let i=f(this.frame.ctm,this._extent);this._width=i[0],this._height=i[1];let a={x:r.width/this._width,y:r.height/this._height},o=new c({width:this._width,height:this._height,pixelType:`u8`,extent:r,pixelSize:a,spatialReference:r.spatialReference,bandCount:3,keyProperties:{DataType:`Processed`}});this.createRemoteDatasetStorageInfo(o,this._tileSize,this._tileSize),this._set(`rasterInfo`,o),this.updateTileInfo()}getTileExtentPDF(e,t,n){let r=this._extent,a=2**e,o=r.width/this._width*a,s=r.height/this._height*a,c=new i({x:r.xmin,y:r.ymax});return this.getTileExtent({x:o,y:s},t,n,c,r.spatialReference,[512,512])}};e([n({type:String,json:{write:!0}})],l.prototype,`datasetFormat`,void 0),e([n({constructOnly:!0})],l.prototype,`page`,void 0),e([n({readOnly:!0})],l.prototype,`tileType`,void 0),l=e([r(`esri.layers.raster.datasets.GeospatialPDFRaster`)],l);const u=l;function d(e){return new s({width:e.width,height:e.height,pixelType:`u8`,pixels:[e.red,e.green,e.blue],mask:e.mask})}function f(e,n){let[r,i,a,o]=e,s=r*o-i*a;if(!Number.isFinite(s)||s===0)throw new t(`geospatial-pdf-raster:open`,`Failed to derive raster dimensions from an invalid PDF CTM.`);let c=10*Math.hypot(o,i)/Math.abs(s),l=10*Math.hypot(a,r)/Math.abs(s),u=Math.max(1,Math.ceil(n.width*c)),d=Math.max(1,Math.ceil(n.height*l));if(!Number.isFinite(u)||!Number.isFinite(d))throw new t(`geospatial-pdf-raster:open`,`PDF CTM produced invalid raster dimensions.`);return[u,d]}export{u as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Point.js";import{GeospatialPDFWorkerClient as a}from"../../geospatialPDF/GeospatialPDFWorkerClient.js";import o from"./BaseRaster.js";import s from"../../support/PixelBlock.js";import c from"../../support/RasterInfo.js";let l=class extends o{constructor(){super(...arguments),this._workerClient=new a,this._extent=null,this._ctm=null,this._neatlineRing=[],this._width=0,this._height=0,this._tileSize=512,this.datasetFormat=`PDF`,this.frame=null,this.neatlineExtent=null,this.page=1,this.tileType=`Raster`}destroy(){this._workerClient.destroy(),this.neatlineExtent=null,this._extent=null,this._ctm=null,this._neatlineRing=[]}async fetchRawTile(e,t,n,r={}){let i=this._extent,a=this._ctm,o=this.getTileExtentPDF(e,t,n);return o.intersects(i)?d(await this._workerClient.render(o,this._tileSize,this._tileSize,a,this._neatlineRing,r)):null}async _open(e){if(!this.url)throw new t(`geospatial-pdf-raster:open`,`GeospatialPDFRaster requires a url.`);let n=await this._workerClient.loadPDF({url:this.url,page:this.page},e);this.frame=n.frame;let r=this.frame.outerExtentMediabox;if(!r)throw new t(`geospatial-pdf-raster:open`,`Failed to compute Geospatial PDF extent.`);this.neatlineExtent=n.neatlineExtent,this._extent=r,this._ctm=this.frame.ctm,this._neatlineRing=this.frame.sourceMediaBoxPolygon.rings[0];let i=f(this.frame.ctm,this._extent);this._width=i[0],this._height=i[1];let a={x:r.width/this._width,y:r.height/this._height},o=new c({width:this._width,height:this._height,pixelType:`u8`,extent:r,pixelSize:a,spatialReference:r.spatialReference,bandCount:3,keyProperties:{DataType:`Processed`}});this.createRemoteDatasetStorageInfo(o,this._tileSize,this._tileSize),this._set(`rasterInfo`,o),this.updateTileInfo()}getTileExtentPDF(e,t,n){let r=this._extent,a=2**e,o=r.width/this._width*a,s=r.height/this._height*a,c=new i({x:r.xmin,y:r.ymax});return this.getTileExtent({x:o,y:s},t,n,c,r.spatialReference,[512,512])}};e([n({type:String,json:{write:!0}})],l.prototype,`datasetFormat`,void 0),e([n({constructOnly:!0})],l.prototype,`page`,void 0),e([n({readOnly:!0})],l.prototype,`tileType`,void 0),l=e([r(`esri.layers.raster.datasets.GeospatialPDFRaster`)],l);const u=l;function d(e){return new s({width:e.width,height:e.height,pixelType:`u8`,pixels:[e.red,e.green,e.blue],mask:e.mask})}function f(e,n){let[r,i,a,o]=e,s=r*o-i*a;if(!Number.isFinite(s)||s===0)throw new t(`geospatial-pdf-raster:open`,`Failed to derive raster dimensions from an invalid PDF CTM.`);let c=10*Math.hypot(o,i)/Math.abs(s),l=10*Math.hypot(a,r)/Math.abs(s),u=Math.max(1,Math.ceil(n.width*c)),d=Math.max(1,Math.ceil(n.height*l));if(!Number.isFinite(u)||!Number.isFinite(d))throw new t(`geospatial-pdf-raster:open`,`PDF CTM produced invalid raster dimensions.`);return[u,d]}export{u as default};
@@ -1,3 +1,3 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{eachAlways as n,createAbortError as r}from"../../../core/promiseUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import l from"./InMemoryRaster.js";import{parsePAMInfo as u}from"./pamParser.js";import{parseHeader as d}from"../formats/JpgPlus.js";import{getFormat as f}from"../formats/RasterCodec.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../transforms/PolynomialTransform.js";import h from"../../support/RasterInfo.js";let g=class extends c{set rasterJobHandler(e){this._set(`rasterJobHandler`,e),this._inMemoryRaster&&(this._inMemoryRaster.rasterJobHandler=e)}fetchRawTile(e,t,n,r={}){if(this._imageBlob){let{blockWidth:r,blockHeight:i}=this.rasterInfo.storageInfo;return this.decodePixelBlock(this._imageBlob,{tileSize:[r,i],tileIndex:[e,t,n],canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0})}return this._inMemoryRaster?this._inMemoryRaster.fetchRawTile(e,t,n,r):Promise.resolve(null)}async _open(e){let n=await this._fetchData(e);if(n==null)throw new t(`image-aux-raster:open`,`the data cannot be decoded`);let{spatialReference:r,statistics:i,histograms:a,transform:c}=await this._fetchAuxiliaryData(e),u=!r;u&&(r=new s({wkid:3857})),a?.length&&i==null&&(i=p(a));let{width:d,height:f,pixelBlock:m}=n,g=new o({xmin:-.5,ymin:.5-f,xmax:d-.5,ymax:.5,spatialReference:r}),_=c?c.forwardTransform(g):g,v=!0;if(c){let e=c.forwardCoefficients;v=e&&e[1]===0&&e[2]===0,v&&(c=null,g=_)}if(!m){let e=new h({width:d,height:f,bandCount:3,pixelType:`u8`,extent:_,nativeExtent:g,transform:c,pixelSize:{x:_.width/d,y:_.height/f},spatialReference:_.spatialReference,keyProperties:{DataType:`Processed`}});this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(e),this.createRemoteDatasetStorageInfo(e,512,512),this._set(`rasterInfo`,e),this.updateTileInfo();return}let{rasterJobHandler:y,ioConfig:b}=this,x=new l({preGenerateTiles:!1,rasterJobHandler:y,source:{extent:_,nativeExtent:g,transform:c,pixelBlocks:[m],statistics:i,histograms:a,keyProperties:{DataType:`Processed`},isPseudoSpatialReference:u},ioConfig:{...b,sampling:`closest`,skipStatistics:!0}});await x.open(),x.source=null,this._set(`rasterInfo`,x.rasterInfo),this._inMemoryRaster=x}async _fetchData(e){let{data:n}=await this.request(this.url,{responseType:`array-buffer`,signal:e?.signal}),r=f(n);if(r===`jpg`||r===`png`||r===`gif`||r===`bmp`)this._set(`datasetFormat`,r.toUpperCase());else throw new t(`image-aux-raster:open`,`the data is not a supported format`);if(r===`jpg`){let e=d(n);if(e==null)throw new t(`image-aux-raster:open`,`the data is not a supported format`);return this._imageBlob=n,e}try{let e=await this.decodePixelBlock(n,{format:r,canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0});return this._imageBlob=n,e?{width:e.width,height:e.height,pixelBlock:e}:null}catch{let e=await this.decodePixelBlock(n,{format:r,canvasUsage:`no-canvas`,skipStatistics:!0});return e?{width:e.width,height:e.height,pixelBlock:e}:null}}async _fetchAuxiliaryData(e){let t=e?.signal,{skipExtensions:i=[],skipMapInfo:a}=this.ioConfig,o=a||i.includes(`aux.xml`)?null:this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:t}),s=this.datasetFormat,c=s===`JPG`?`jgw`:s===`PNG`?`pgw`:s===`BMP`?`bpw`:null,l=c&&i.includes(c)?null:this.request(this.url.slice(0,this.url.lastIndexOf(`.`))+`.`+c,{responseType:`text`,signal:t}),d=await n([o,l]);if(t?.aborted)throw r();let f=u(d[0].value?.data);if(!f.transform){let e=d[1].value?d[1].value.data.split(`
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{eachAlways as n,createAbortError as r}from"../../../core/promiseUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import l from"./InMemoryRaster.js";import{parsePAMInfo as u}from"./pamParser.js";import{parseHeader as d}from"../formats/JpgPlus.js";import{getFormat as f}from"../formats/RasterCodec.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../transforms/PolynomialTransform.js";import h from"../../support/RasterInfo.js";let g=class extends c{set rasterJobHandler(e){this._set(`rasterJobHandler`,e),this._inMemoryRaster&&(this._inMemoryRaster.rasterJobHandler=e)}fetchRawTile(e,t,n,r={}){if(this._imageBlob){let{blockWidth:i,blockHeight:a}=this.rasterInfo.storageInfo;return this.decodePixelBlock(this._imageBlob,{tileSize:[i,a],tileIndex:[e,t,n],canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0},{signal:r.signal})}return this._inMemoryRaster?this._inMemoryRaster.fetchRawTile(e,t,n,r):Promise.resolve(null)}async _open(e){let n=await this._fetchData(e);if(n==null)throw new t(`image-aux-raster:open`,`the data cannot be decoded`);let{spatialReference:r,statistics:i,histograms:a,transform:c}=await this._fetchAuxiliaryData(e),u=!r;u&&(r=new s({wkid:3857})),a?.length&&i==null&&(i=p(a));let{width:d,height:f,pixelBlock:m}=n,g=new o({xmin:-.5,ymin:.5-f,xmax:d-.5,ymax:.5,spatialReference:r}),_=c?c.forwardTransform(g):g,v=!0;if(c){let e=c.forwardCoefficients;v=e&&e[1]===0&&e[2]===0,v&&(c=null,g=_)}if(!m){let e=new h({width:d,height:f,bandCount:3,pixelType:`u8`,extent:_,nativeExtent:g,transform:c,pixelSize:{x:_.width/d,y:_.height/f},spatialReference:_.spatialReference,keyProperties:{DataType:`Processed`}});this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(e),this.createRemoteDatasetStorageInfo(e,512,512),this._set(`rasterInfo`,e),this.updateTileInfo();return}let{rasterJobHandler:y,ioConfig:b}=this,x=new l({preGenerateTiles:!1,rasterJobHandler:y,source:{extent:_,nativeExtent:g,transform:c,pixelBlocks:[m],statistics:i,histograms:a,keyProperties:{DataType:`Processed`},isPseudoSpatialReference:u},ioConfig:{...b,sampling:`closest`,skipStatistics:!0}});await x.open(),x.source=null,this._set(`rasterInfo`,x.rasterInfo),this._inMemoryRaster=x}async _fetchData(e){let{data:n}=await this.request(this.url,{responseType:`array-buffer`,signal:e?.signal}),r=f(n);if(r===`jpg`||r===`png`||r===`gif`||r===`bmp`)this._set(`datasetFormat`,r.toUpperCase());else throw new t(`image-aux-raster:open`,`the data is not a supported format`);if(r===`jpg`){let e=d(n);if(e==null)throw new t(`image-aux-raster:open`,`the data is not a supported format`);return this._imageBlob=n,e}try{let t=await this.decodePixelBlock(n,{format:r,canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0},e);return this._imageBlob=n,t?{width:t.width,height:t.height,pixelBlock:t}:null}catch{let t=await this.decodePixelBlock(n,{format:r,canvasUsage:`no-canvas`,skipStatistics:!0},e);return t?{width:t.width,height:t.height,pixelBlock:t}:null}}async _fetchAuxiliaryData(e){let t=e?.signal,{skipExtensions:i=[],skipMapInfo:a}=this.ioConfig,o=a||i.includes(`aux.xml`)?null:this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:t}),s=this.datasetFormat,c=s===`JPG`?`jgw`:s===`PNG`?`pgw`:s===`BMP`?`bpw`:null,l=c&&i.includes(c)?null:this.request(this.url.slice(0,this.url.lastIndexOf(`.`))+`.`+c,{responseType:`text`,signal:t}),d=await n([o,l]);if(t?.aborted)throw r();let f=u(d[0].value?.data);if(!f.transform){let e=d[1].value?d[1].value.data.split(`
3
3
  `).slice(0,6).map(e=>Number(e)):null;f.transform=e?.length===6?new m({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return f}};e([i({type:String,json:{write:!0}})],g.prototype,`datasetFormat`,void 0),e([i()],g.prototype,`rasterJobHandler`,null),g=e([a(`esri.layers.raster.datasets.ImageAuxRaster`)],g);const _=g;export{_ as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as n}from"../../../core/maybe.js";import{urlToObject as r}from"../../../core/urlUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{setValidBoundary as u}from"../functions/pixelUtils.js";import d from"../transforms/GCSShiftTransform.js";import f from"../../support/RasterInfo.js";import p from"../../support/RasterStorageInfo.js";import m from"../../support/TileInfo.js";import{TilemapCache as h}from"../../support/TilemapCache.js";import{patchServiceInfo as g,fetchServiceRasterInfo as _}from"../../../rest/imageService/fetchRasterInfo.js";let v=class extends l{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat=`RasterTileServer`,this.tileType=null}async fetchRawTile(e,t,n,r={}){let{storageInfo:i,extent:a}=this.rasterInfo,{transposeInfo:o}=i,s=o!=null&&!!r.transposedVariableName;if(this._slices&&!s&&r.sliceId==null)return null;let c=s?0:i.maximumPyramidLevel-e+this._levelOffset,l=`${this.url}/tile/${c}/${t}/${n}`,d={...this._slices?s?{variable:r.transposedVariableName}:{sliceId:r.sliceId||0}:null,...r.refreshParameters},f,p;if(i.isBsqTile){let e=(r.bandIds?.length?r.bandIds:[0,1,2]).map(e=>this.request(l,{query:{...d,bandId:e},responseType:`array-buffer`,signal:r.signal})),t=await Promise.all(e),n=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),i=new Uint8Array(n);p=[];let a=0;for(let{data:e}of t)p.push(a),i.set(new Uint8Array(e),a),a+=e.byteLength;f=i.buffer}else f=(await this.request(l,{query:d,responseType:`array-buffer`,signal:r.signal})).data;if(!f)return null;let{tileInfo:m}=i,h=s?o.tileSize:m.size,g=/^(mixed|jp)/i.test(m.format),_=await this.decodePixelBlock(f,{width:h[0],height:h[1],planes:p?.length,offsets:p,pixelType:null,isPoint:this.tileType===`Elevation`,returnInterleaved:s,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:g});if(_==null)return null;let v=i.blockBoundary[e];if(i.compression!==`jpg`||n>v.minCol&&n<v.maxCol&&t>v.minRow&&t<v.maxRow)return _;let{origin:y,blockWidth:b,blockHeight:x}=i,{x:S,y:C}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-y.x)/S)%b,T=Math.round((a.xmax-y.x)/S)%b||b,E=Math.round((y.y-a.ymax)/C)%x,D=Math.round((y.y-a.ymin)/C)%x||x,O=n===v.minCol?w:0,k=t===v.minRow?E:0,A=n===v.maxCol?T:b,j=t===v.maxRow?D:x;return u(_,{x:O,y:k},{width:A-O,height:j-k}),_}getSliceIndex(e){if(!this._slices||e==null||e.length===0)return null;let t=e;for(let e=0;e<this._slices.length;e++){let n=this._slices[e].multidimensionalDefinition;if(n.length===t.length&&!n.some(e=>{let n=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!n||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(n.values[0])?`${n.values[0][0]}-${n.values[0][1]}`:n.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let n=this.request(this.url+`/statistics`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.statistics),r=this.request(this.url+`/histograms`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.histograms),i=await Promise.all([n,r]);return i[0]&&i[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),i[1]?.[0]?.counts?.length||(i[1]=null),{statistics:i[0]||null,histograms:i[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let n=this.identifyPixelLocation(e,0,t.datumTransformation);if(n===null)return null;let r=0,{maximumPyramidLevel:i}=this.rasterInfo.storageInfo,a=i-r+this._levelOffset,o=n.srcLocation;for(;a>=0;){try{if(await this._tilemapCache.fetchAvailability(a,n.row,n.col,t)===`available`)break}catch{}if(a--,r++,n=this.identifyPixelLocation(o,r,t.datumTransformation),n===null)return null}return a===-1||n==null?null:r}async _open(e){let i=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:`json`},signal:i});a.ssl&&(this.url=this.url.replace(/^http:/i,`https:`));let o=a.data;if(this.sourceJSON=o,!o)throw new t(`imageserverraster:open`,`cannot initialize tiled image service, missing service info`);if(!o.tileInfo)throw new t(`imageserverraster:open`,`use ImageryLayer to open non-tiled image services`);this._fixScaleInServiceInfo();let s=[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`];this.tileType=o.cacheType,this.tileType??=s.includes(o.tileInfo.format.toLowerCase())?`Map`:o.tileInfo.format.toLowerCase()===`lerc`?`Elevation`:`Raster`,this.datasetName=o.name?.slice(o.name.indexOf(`/`)+1)??``;let c=this.rasterInfo??await this._fetchRasterInfo({signal:i});if(c==null)throw new t(`image-server-raster:open`,`cannot initialize image service`);g(c,o);let l=this.tileType===`Map`?y(o.tileInfo,o):m.fromJSON(o.tileInfo);n(l);let[u,d]=this._computeMinMaxLOD(c,l),{extent:f,pixelSize:_}=c,v=Math.min(_.x,_.y)*.001;(_.x!==_.y||Math.abs(u.resolution-_.x)>v)&&(_.x=_.y=u.resolution,c.width=Math.ceil((f.xmax-f.xmin)/_.x-.1),c.height=Math.ceil((f.ymax-f.ymin)/_.y-.1));let x=u.level-d.level,[S,C]=l.size,w=[],T=[],{lods:E}=l;E.forEach((e,t)=>{e.level>=d.level&&e.level<=u.level&&w.push({x:e.resolution,y:e.resolution}),t<E.length-1&&T.push(Math.round(10*e.resolution/E[t+1].resolution)/10)}),w.sort((e,t)=>e.x-t.x);let D=this.computeBlockBoundary(f,S,C,l.origin,w,x),O=w.length>1?w.slice(1):null,k;o.transposeInfo&&(k={tileSize:[o.transposeInfo.rows,o.transposeInfo.cols],packetSize:c.keyProperties?._yxs.PacketSize??0});let A=T.length<=1||T.length>=3&&T.slice(0,-1).every(e=>e===T[0])?T[0]??2:Math.round(10/(d.resolution/u.resolution)**(-1/x))/10,j=!!o.bsq&&this.tileType===`Raster`;if(c.storageInfo=new p({blockWidth:l.size[0],blockHeight:l.size[1],pyramidBlockWidth:l.size[0],pyramidBlockHeight:l.size[1],pyramidResolutions:O,pyramidScalingFactor:A,compression:l.format,origin:l.origin,firstPyramidLevel:1,maximumPyramidLevel:x,tileInfo:l,isBsqTile:j,transposeInfo:k,blockBoundary:D}),b(c),this._set(`rasterInfo`,c),o.capabilities.toLowerCase().includes(`tilemap`)){let e={tileInfo:c.storageInfo.tileInfo,parsedUrl:r(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if(this.tileType===`Map`){let e=t.fullExtent||t.extent,n=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),r=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),i=c.fromJSON(t.spatialReference||e.spatialReference),a=new s({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:i});return new f({width:n,height:r,bandCount:3,extent:o.fromJSON(e),spatialReference:i,pixelSize:a,pixelType:`u8`,statistics:null,keyProperties:{DataType:`processed`}})}let n={...e,query:{...this.ioConfig.customFetchParameters,f:`json`}},r=_(this.url,this.sourceJSON,n),i=t.hasMultidimensions?this.request(`${this.url}/slices`,n).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([r,i]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:n}=e,r=.5/e.width*n.x,{lods:i}=t,a=t.lodAt(Math.max.apply(null,i.map(e=>e.level))),o=t.lodAt(Math.min.apply(null,i.map(e=>e.level))),{tileType:s}=this;if(s===`Map`)return this._levelOffset=i[0].level,[a,o];if(s===`Raster`)return[i.find(e=>e.resolution===n.x)??a,o];let{minScale:c,maxScale:l}=this.sourceJSON,u=a;l>0&&(u=i.find(e=>Math.abs(e.scale-l)<r),u||=i.filter(e=>e.scale>l).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a);let d=o;return c>0&&(d=i.find(e=>Math.abs(e.scale-c)<r)??o,this._levelOffset=d.level-o.level),[u,d]}};e([i({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([i()],v.prototype,`tileType`,void 0),v=e([a(`esri.layers.raster.datasets.ImageServerRaster`)],v);function y(e,t){if(!e)return null;let{minScale:n,maxScale:r,minLOD:i,maxLOD:a}=t;if(i!=null&&a!=null)return m.fromJSON({...e,lods:e.lods.filter(({level:e})=>e!=null&&e>=i&&e<=a)});if(n!==0&&r!==0){let t=e=>Math.round(e*1e4)/1e4,i=n?t(n):1/0,a=r?t(r):-1/0;return m.fromJSON({...e,lods:e.lods.filter(e=>{let n=t(e.scale);return n<=i&&n>=a})})}return m.fromJSON(e)}function b(e){let{extent:t,spatialReference:n}=e;t.xmin>-1&&t.xmax>181&&n?.wkid&&n.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}const x=v;export{x as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as n}from"../../../core/maybe.js";import{urlToObject as r}from"../../../core/urlUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{setValidBoundary as u}from"../functions/pixelUtils.js";import d from"../transforms/GCSShiftTransform.js";import f from"../../support/RasterInfo.js";import p from"../../support/RasterStorageInfo.js";import m from"../../support/TileInfo.js";import{TilemapCache as h}from"../../support/TilemapCache.js";import{patchServiceInfo as g,fetchServiceRasterInfo as _}from"../../../rest/imageService/fetchRasterInfo.js";let v=class extends l{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat=`RasterTileServer`,this.tileType=null}async fetchRawTile(e,t,n,r={}){let{storageInfo:i,extent:a}=this.rasterInfo,{transposeInfo:o}=i,s=o!=null&&!!r.transposedVariableName;if(this._slices&&!s&&r.sliceId==null)return null;let c=s?0:i.maximumPyramidLevel-e+this._levelOffset,l=`${this.url}/tile/${c}/${t}/${n}`,d={...this._slices?s?{variable:r.transposedVariableName}:{sliceId:r.sliceId||0}:null,...r.refreshParameters},f,p;if(i.isBsqTile){let e=(r.bandIds?.length?r.bandIds:[0,1,2]).map(e=>this.request(l,{query:{...d,bandId:e},responseType:`array-buffer`,signal:r.signal})),t=await Promise.all(e),n=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),i=new Uint8Array(n);p=[];let a=0;for(let{data:e}of t)p.push(a),i.set(new Uint8Array(e),a),a+=e.byteLength;f=i.buffer}else f=(await this.request(l,{query:d,responseType:`array-buffer`,signal:r.signal})).data;if(!f)return null;let{tileInfo:m}=i,h=s?o.tileSize:m.size,g=/^(mixed|jp)/i.test(m.format),_=await this.decodePixelBlock(f,{width:h[0],height:h[1],planes:p?.length,offsets:p,pixelType:null,isPoint:this.tileType===`Elevation`,returnInterleaved:s,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:g},{signal:r.signal});if(_==null)return null;let v=i.blockBoundary[e];if(i.compression!==`jpg`||n>v.minCol&&n<v.maxCol&&t>v.minRow&&t<v.maxRow)return _;let{origin:y,blockWidth:b,blockHeight:x}=i,{x:S,y:C}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-y.x)/S)%b,T=Math.round((a.xmax-y.x)/S)%b||b,E=Math.round((y.y-a.ymax)/C)%x,D=Math.round((y.y-a.ymin)/C)%x||x,O=n===v.minCol?w:0,k=t===v.minRow?E:0,A=n===v.maxCol?T:b,j=t===v.maxRow?D:x;return u(_,{x:O,y:k},{width:A-O,height:j-k}),_}getSliceIndex(e){if(!this._slices||e==null||e.length===0)return null;let t=e;for(let e=0;e<this._slices.length;e++){let n=this._slices[e].multidimensionalDefinition;if(n.length===t.length&&!n.some(e=>{let n=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!n||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(n.values[0])?`${n.values[0][0]}-${n.values[0][1]}`:n.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let n=this.request(this.url+`/statistics`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.statistics),r=this.request(this.url+`/histograms`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.histograms),i=await Promise.all([n,r]);return i[0]&&i[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),i[1]?.[0]?.counts?.length||(i[1]=null),{statistics:i[0]||null,histograms:i[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let n=this.identifyPixelLocation(e,0,t.datumTransformation);if(n===null)return null;let r=0,{maximumPyramidLevel:i}=this.rasterInfo.storageInfo,a=i-r+this._levelOffset,o=n.srcLocation;for(;a>=0;){try{if(await this._tilemapCache.fetchAvailability(a,n.row,n.col,t)===`available`)break}catch{}if(a--,r++,n=this.identifyPixelLocation(o,r,t.datumTransformation),n===null)return null}return a===-1||n==null?null:r}async _open(e){let i=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:`json`},signal:i});a.ssl&&(this.url=this.url.replace(/^http:/i,`https:`));let o=a.data;if(this.sourceJSON=o,!o)throw new t(`imageserverraster:open`,`cannot initialize tiled image service, missing service info`);if(!o.tileInfo)throw new t(`imageserverraster:open`,`use ImageryLayer to open non-tiled image services`);this._fixScaleInServiceInfo();let s=[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`];this.tileType=o.cacheType,this.tileType??=s.includes(o.tileInfo.format.toLowerCase())?`Map`:o.tileInfo.format.toLowerCase()===`lerc`?`Elevation`:`Raster`,this.datasetName=o.name?.slice(o.name.indexOf(`/`)+1)??``;let c=this.rasterInfo??await this._fetchRasterInfo({signal:i});if(c==null)throw new t(`image-server-raster:open`,`cannot initialize image service`);g(c,o);let l=this.tileType===`Map`?y(o.tileInfo,o):m.fromJSON(o.tileInfo);n(l);let[u,d]=this._computeMinMaxLOD(c,l),{extent:f,pixelSize:_}=c,v=Math.min(_.x,_.y)*.001;(_.x!==_.y||Math.abs(u.resolution-_.x)>v)&&(_.x=_.y=u.resolution,c.width=Math.ceil((f.xmax-f.xmin)/_.x-.1),c.height=Math.ceil((f.ymax-f.ymin)/_.y-.1));let x=u.level-d.level,[S,C]=l.size,w=[],T=[],{lods:E}=l;E.forEach((e,t)=>{e.level>=d.level&&e.level<=u.level&&w.push({x:e.resolution,y:e.resolution}),t<E.length-1&&T.push(Math.round(10*e.resolution/E[t+1].resolution)/10)}),w.sort((e,t)=>e.x-t.x);let D=this.computeBlockBoundary(f,S,C,l.origin,w,x),O=w.length>1?w.slice(1):null,k;o.transposeInfo&&(k={tileSize:[o.transposeInfo.rows,o.transposeInfo.cols],packetSize:c.keyProperties?._yxs.PacketSize??0});let A=T.length<=1||T.length>=3&&T.slice(0,-1).every(e=>e===T[0])?T[0]??2:Math.round(10/(d.resolution/u.resolution)**(-1/x))/10,j=!!o.bsq&&this.tileType===`Raster`;if(c.storageInfo=new p({blockWidth:l.size[0],blockHeight:l.size[1],pyramidBlockWidth:l.size[0],pyramidBlockHeight:l.size[1],pyramidResolutions:O,pyramidScalingFactor:A,compression:l.format,origin:l.origin,firstPyramidLevel:1,maximumPyramidLevel:x,tileInfo:l,isBsqTile:j,transposeInfo:k,blockBoundary:D}),b(c),this._set(`rasterInfo`,c),o.capabilities.toLowerCase().includes(`tilemap`)){let e={tileInfo:c.storageInfo.tileInfo,parsedUrl:r(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if(this.tileType===`Map`){let e=t.fullExtent||t.extent,n=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),r=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),i=c.fromJSON(t.spatialReference||e.spatialReference),a=new s({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:i});return new f({width:n,height:r,bandCount:3,extent:o.fromJSON(e),spatialReference:i,pixelSize:a,pixelType:`u8`,statistics:null,keyProperties:{DataType:`processed`}})}let n={...e,query:{...this.ioConfig.customFetchParameters,f:`json`}},r=_(this.url,this.sourceJSON,n),i=t.hasMultidimensions?this.request(`${this.url}/slices`,n).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([r,i]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:n}=e,r=.5/e.width*n.x,{lods:i}=t,a=t.lodAt(Math.max.apply(null,i.map(e=>e.level))),o=t.lodAt(Math.min.apply(null,i.map(e=>e.level))),{tileType:s}=this;if(s===`Map`)return this._levelOffset=i[0].level,[a,o];if(s===`Raster`)return[i.find(e=>e.resolution===n.x)??a,o];let{minScale:c,maxScale:l}=this.sourceJSON,u=a;l>0&&(u=i.find(e=>Math.abs(e.scale-l)<r),u||=i.filter(e=>e.scale>l).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a);let d=o;return c>0&&(d=i.find(e=>Math.abs(e.scale-c)<r)??o,this._levelOffset=d.level-o.level),[u,d]}};e([i({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([i()],v.prototype,`tileType`,void 0),v=e([a(`esri.layers.raster.datasets.ImageServerRaster`)],v);function y(e,t){if(!e)return null;let{minScale:n,maxScale:r,minLOD:i,maxLOD:a}=t;if(i!=null&&a!=null)return m.fromJSON({...e,lods:e.lods.filter(({level:e})=>e!=null&&e>=i&&e<=a)});if(n!==0&&r!==0){let t=e=>Math.round(e*1e4)/1e4,i=n?t(n):1/0,a=r?t(r):-1/0;return m.fromJSON({...e,lods:e.lods.filter(e=>{let n=t(e.scale);return n<=i&&n>=a})})}return m.fromJSON(e)}function b(e){let{extent:t,spatialReference:n}=e;t.xmin>-1&&t.xmax>181&&n?.wkid&&n.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}const x=v;export{x as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import a from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{parseSpatialReference as c,parsePAMInfo as l}from"./pamParser.js";import{getElement as u,getElementValue as d}from"./xmlUtilities.js";import{isPlatformLittleEndian as f}from"../formats/utils.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../../support/PixelBlock.js";import h from"../../support/RasterInfo.js";import g from"../../support/RasterStorageInfo.js";const _=new Map([[`byte`,`u8`],[`signedbyte`,`s8`],[`int8`,`s8`],[`uint8`,`u8`],[`int16`,`s16`],[`uint16`,`u16`],[`int32`,`s32`],[`uint32`,`u32`],[`float32`,`f32`],[`float64`,`f64`],[`double64`,`f64`]]),v=new Map;v.set(`none`,{blobExtension:`.til`,isOneSegment:!0,decoderFormat:`bip`}),v.set(`lerc`,{blobExtension:`.lrc`,isOneSegment:!1,decoderFormat:`lerc`}),v.set(`deflate`,{blobExtension:`.pzp`,isOneSegment:!0,decoderFormat:`deflate`}),v.set(`jpeg`,{blobExtension:`.pjg`,isOneSegment:!0,decoderFormat:`jpg`}),v.set(`qb3`,{blobExtension:`.pq3`,isOneSegment:!0,decoderFormat:`qb3`});let y=class extends s{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat=`MRF`}async fetchRawTile(e,t,n,r={}){let{blockWidth:i,blockHeight:a,blockBoundary:o}=this.rasterInfo.storageInfo,s=o[e];if(!s||s.maxRow<t||s.maxCol<n||s.minRow>t||s.minCol>n)return null;let{bandCount:c,pixelType:l}=this.rasterInfo,{ranges:u,actualTileWidth:d,actualTileHeight:f}=this._getTileLocation(e,t,n);if(!u||u.length===0)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(i*a);return new m({width:i,height:a,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,h=this._getBandSegmentCount(),g=[],_=0;for(_=0;_<h;_++)(!p||p.includes(_))&&g.push(this.request(this._files.data,{range:{from:u[_].from,to:u[_].to},responseType:`array-buffer`,signal:r.signal}));let y=await Promise.all(g),b=y.map(e=>e.data.byteLength).reduce((e,t)=>e+t),x=new Uint8Array(b),S=[],C=0;for(_=0;_<h;_++)S.push(C),x.set(new Uint8Array(y[_].data),C),C+=y[_].data.byteLength;let w=v.get(this.rasterInfo.storageInfo.compression).decoderFormat,T=w===`jpg`&&c===4&&S.length===1,E=await this.decodePixelBlock(x.buffer,{width:i,height:a,format:w,planes:p?.length||c,offsets:S,pixelType:l,canvasUsage:T?`no-canvas`:void 0,decodeJpegAsRgb:!1}).catch(()=>null);if(E==null)return null;let{noDataValue:D}=this.rasterInfo;if(D!=null&&w!==`lerc`&&!E.mask&&(D=D[0],D!=null)){let e=E.width*E.height,t=new Uint8Array(e);if(Math.abs(D)>1e24)for(_=0;_<e;_++)Math.abs((E.pixels[0][_]-D)/D)>1e-6&&(t[_]=1);else for(_=0;_<e;_++)E.pixels[0][_]!==D&&(t[_]=1);E.mask=t}let O=0,k=0;if(d!==i||f!==a){let e=E.mask;if(e)for(_=0;_<a;_++)if(k=_*i,_<f)for(O=d;O<i;O++)e[k+O]=0;else for(O=0;O<i;O++)e[k+O]=0;else for(e=new Uint8Array(i*a),E.mask=e,_=0;_<f;_++)for(k=_*i,O=0;O<d;O++)e[k+O]=1}return E}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1);let t=e?e.signal:null,n=await this.request(this.url,{responseType:`xml`,signal:t}),{rasterInfo:r,files:i}=this._parseHeader(n.data),{skipMapInfo:a,skipExtensions:o=[]}=this.ioConfig;if(!o.includes(`aux.xml`)&&!a){let t=await this._fetchAuxiliaryData(e);t!=null&&(r.statistics=t.statistics??r.statistics,r.histograms=t.histograms,t.histograms&&r.statistics==null&&(r.statistics=p(t.histograms)))}a&&this.updateImageSpaceRasterInfo(r),this._set(`rasterInfo`,r),this._files=i;let s=await this.request(i.index,{responseType:`array-buffer`,signal:t});this._storageIndex=b(s.data);let{blockWidth:c,blockHeight:l}=this.rasterInfo.storageInfo,u=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:d,height:f}=this.rasterInfo,m=[],h=this._getBandSegmentCount(),g=0,_=-1;for(;g<this._storageIndex.length;){_++;let e=Math.ceil(d/c/u**_)-1,t=Math.ceil(f/l/u**_)-1;g+=(e+1)*(t+1)*h*4,m.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=m,_>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=_),this.updateTileInfo()}_getBandSegmentCount(){return this._isBsq?this.rasterInfo.bandCount:1}_getTileLocation(e,t,n){let{blockWidth:r,blockHeight:i,pyramidScalingFactor:a}=this.rasterInfo.storageInfo,{width:o,height:s}=this.rasterInfo,c=this._getBandSegmentCount(),l,u,d,f=0,p=0;for(d=0;d<e;d++)p=a**d,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=l*u;p=a**e,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=t*l+n,f*=c*4;let m=this._storageIndex.subarray(f,f+4*c),h=0,g=0,_=[];for(let e=0;e<c;e++)h=m[e*4]*2**32+m[e*4+1],g=h+m[e*4+2]*2**32+m[e*4+3]-1,_.push({from:h,to:g});return{ranges:_,actualTileWidth:n<l-1?r:Math.ceil(o/p)-r*(l-1),actualTileHeight:t<u-1?i:Math.ceil(s/p)-i*(u-1)}}_parseHeader(e){let n=u(e,`MRF_META/Raster`);if(!n)throw new t(`mrf:open`,`not a valid MRF format`);let r=u(n,`Size`),s=parseInt(r.getAttribute(`x`),10),l=parseInt(r.getAttribute(`y`),10),f=parseInt(r.getAttribute(`c`),10),p=(d(n,`Compression`)||`none`).toLowerCase();if(!v.has(p))throw new t(`mrf:open`,`currently does not support compression `+p);let m=d(n,`DataType`)||`UInt8`,y=_.get(m.toLowerCase());if(y==null)throw new t(`mrf:open`,`currently does not support pixel type `+m);let b=u(n,`PageSize`),x=parseInt(b.getAttribute(`x`),10),S=parseInt(b.getAttribute(`y`),10),C=b.getAttribute(`c`),w=C?C===String(f):v.get(p).isOneSegment;this._isBsq=!w;let T=u(n,`DataValues`),E;if(T){let e=T.getAttribute(`NoData`);e!=null&&(E=e.trim().split(` `).map(e=>parseFloat(e)))}if(u(e,`MRF_META/CachedSource`))throw new t(`mrf:open`,`currently does not support MRF referencing other data files`);let D=u(e,`MRF_META/GeoTags`),O=u(D,`BoundingBox`),k=!1,A;if(O!=null){let e=parseFloat(O.getAttribute(`minx`)),t=parseFloat(O.getAttribute(`miny`)),n=parseFloat(O.getAttribute(`maxx`)),r=parseFloat(O.getAttribute(`maxy`)),a=d(D,`Projection`)||``,s=o.WGS84;if(a!==`LOCAL_CS[]`){if(a.toLowerCase().startsWith(`epsg:`)){let e=Number(a.slice(5));!isNaN(e)&&e!==0&&(s=new o({wkid:e}))}else s=c(a)??o.WGS84}else k=!0,s=new o({wkid:3857});A=new i(e,t,n,r),A.spatialReference=s}else k=!0,A=new i({xmin:-.5,ymin:.5-l,xmax:s-.5,ymax:.5,spatialReference:new o({wkid:3857})});let j=u(e,`MRF_META/Rsets`),M=parseInt(j?.getAttribute(`scale`)||`2`,10),N=A.spatialReference,P=new g({origin:new a({x:A.xmin,y:A.ymax,spatialReference:N}),blockWidth:x,blockHeight:S,pyramidBlockWidth:x,pyramidBlockHeight:S,compression:p,pyramidScalingFactor:M}),F=new a({x:A.width/s,y:A.height/l,spatialReference:N}),I=new h({width:s,height:l,extent:A,isPseudoSpatialReference:k,spatialReference:N,bandCount:f,pixelType:y,pixelSize:F,noDataValue:E,storageInfo:P}),L=this._getAuxFullPath(d(n,`DataFile`)),R=this._getAuxFullPath(d(n,`IndexFile`));return{rasterInfo:I,files:{mrf:this.url,index:R||this.url.replace(`.mrf`,`.idx`),data:L||this.url.replace(`.mrf`,v.get(p).blobExtension)}}}_getAuxFullPath(e){return!e||e.includes(`\\`)?null:e.includes(`/`)?e.startsWith(new URL(this.url).origin)?e:null:`${this.url.slice(0,this.url.lastIndexOf(`/`))}/${e}`}async _fetchAuxiliaryData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return l(t)}catch{return null}}};e([n()],y.prototype,`_files`,void 0),e([n()],y.prototype,`_storageIndex`,void 0),e([n()],y.prototype,`_isBsq`,void 0),e([n({type:String,json:{write:!0}})],y.prototype,`datasetFormat`,void 0),y=e([r(`esri.layers.raster.datasets.MRFRaster`)],y);function b(e){if(e.byteLength%16>0)throw Error(`invalid array buffer must be multiples of 16`);let t;if(f){let n=new Uint8Array(e),r=new ArrayBuffer(e.byteLength),i=new Uint8Array(r);for(let t=0;t<e.byteLength/4;t++)for(let e=0;e<4;e++)i[t*4+e]=n[t*4+3-e];t=new Uint32Array(r)}else t=new Uint32Array(e);return t}const x=y;export{x as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import a from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{parseSpatialReference as c,parsePAMInfo as l}from"./pamParser.js";import{getElement as u,getElementValue as d}from"./xmlUtilities.js";import{isPlatformLittleEndian as f}from"../formats/utils.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../../support/PixelBlock.js";import h from"../../support/RasterInfo.js";import g from"../../support/RasterStorageInfo.js";const _=new Map([[`byte`,`u8`],[`signedbyte`,`s8`],[`int8`,`s8`],[`uint8`,`u8`],[`int16`,`s16`],[`uint16`,`u16`],[`int32`,`s32`],[`uint32`,`u32`],[`float32`,`f32`],[`float64`,`f64`],[`double64`,`f64`]]),v=new Map;v.set(`none`,{blobExtension:`.til`,isOneSegment:!0,decoderFormat:`bip`}),v.set(`lerc`,{blobExtension:`.lrc`,isOneSegment:!1,decoderFormat:`lerc`}),v.set(`deflate`,{blobExtension:`.pzp`,isOneSegment:!0,decoderFormat:`deflate`}),v.set(`jpeg`,{blobExtension:`.pjg`,isOneSegment:!0,decoderFormat:`jpg`}),v.set(`qb3`,{blobExtension:`.pq3`,isOneSegment:!0,decoderFormat:`qb3`});let y=class extends s{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat=`MRF`}async fetchRawTile(e,t,n,r={}){let{blockWidth:i,blockHeight:a,blockBoundary:o}=this.rasterInfo.storageInfo,s=o[e];if(!s||s.maxRow<t||s.maxCol<n||s.minRow>t||s.minCol>n)return null;let{bandCount:c,pixelType:l}=this.rasterInfo,{ranges:u,actualTileWidth:d,actualTileHeight:f}=this._getTileLocation(e,t,n);if(!u||u.length===0)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(i*a);return new m({width:i,height:a,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,h=this._getBandSegmentCount(),g=[],_=0;for(_=0;_<h;_++)(!p||p.includes(_))&&g.push(this.request(this._files.data,{range:{from:u[_].from,to:u[_].to},responseType:`array-buffer`,signal:r.signal}));let y=await Promise.all(g),b=y.map(e=>e.data.byteLength).reduce((e,t)=>e+t),x=new Uint8Array(b),S=[],C=0;for(_=0;_<h;_++)S.push(C),x.set(new Uint8Array(y[_].data),C),C+=y[_].data.byteLength;let w=v.get(this.rasterInfo.storageInfo.compression).decoderFormat,T=w===`jpg`&&c===4&&S.length===1,E=await this.decodePixelBlock(x.buffer,{width:i,height:a,format:w,planes:p?.length||c,offsets:S,pixelType:l,canvasUsage:T?`no-canvas`:void 0,decodeJpegAsRgb:!1},{signal:r.signal});if(E==null)return null;let{noDataValue:D}=this.rasterInfo;if(D!=null&&w!==`lerc`&&!E.mask&&(D=D[0],D!=null)){let e=E.width*E.height,t=new Uint8Array(e);if(Math.abs(D)>1e24)for(_=0;_<e;_++)Math.abs((E.pixels[0][_]-D)/D)>1e-6&&(t[_]=1);else for(_=0;_<e;_++)E.pixels[0][_]!==D&&(t[_]=1);E.mask=t}let O=0,k=0;if(d!==i||f!==a){let e=E.mask;if(e)for(_=0;_<a;_++)if(k=_*i,_<f)for(O=d;O<i;O++)e[k+O]=0;else for(O=0;O<i;O++)e[k+O]=0;else for(e=new Uint8Array(i*a),E.mask=e,_=0;_<f;_++)for(k=_*i,O=0;O<d;O++)e[k+O]=1}return E}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1);let t=e?e.signal:null,n=await this.request(this.url,{responseType:`xml`,signal:t}),{rasterInfo:r,files:i}=this._parseHeader(n.data),{skipMapInfo:a,skipExtensions:o=[]}=this.ioConfig;if(!o.includes(`aux.xml`)&&!a){let t=await this._fetchAuxiliaryData(e);t!=null&&(r.statistics=t.statistics??r.statistics,r.histograms=t.histograms,t.histograms&&r.statistics==null&&(r.statistics=p(t.histograms)))}a&&this.updateImageSpaceRasterInfo(r),this._set(`rasterInfo`,r),this._files=i;let s=await this.request(i.index,{responseType:`array-buffer`,signal:t});this._storageIndex=b(s.data);let{blockWidth:c,blockHeight:l}=this.rasterInfo.storageInfo,u=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:d,height:f}=this.rasterInfo,m=[],h=this._getBandSegmentCount(),g=0,_=-1;for(;g<this._storageIndex.length;){_++;let e=Math.ceil(d/c/u**_)-1,t=Math.ceil(f/l/u**_)-1;g+=(e+1)*(t+1)*h*4,m.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=m,_>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=_),this.updateTileInfo()}_getBandSegmentCount(){return this._isBsq?this.rasterInfo.bandCount:1}_getTileLocation(e,t,n){let{blockWidth:r,blockHeight:i,pyramidScalingFactor:a}=this.rasterInfo.storageInfo,{width:o,height:s}=this.rasterInfo,c=this._getBandSegmentCount(),l,u,d,f=0,p=0;for(d=0;d<e;d++)p=a**d,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=l*u;p=a**e,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=t*l+n,f*=c*4;let m=this._storageIndex.subarray(f,f+4*c),h=0,g=0,_=[];for(let e=0;e<c;e++)h=m[e*4]*2**32+m[e*4+1],g=h+m[e*4+2]*2**32+m[e*4+3]-1,_.push({from:h,to:g});return{ranges:_,actualTileWidth:n<l-1?r:Math.ceil(o/p)-r*(l-1),actualTileHeight:t<u-1?i:Math.ceil(s/p)-i*(u-1)}}_parseHeader(e){let n=u(e,`MRF_META/Raster`);if(!n)throw new t(`mrf:open`,`not a valid MRF format`);let r=u(n,`Size`),s=parseInt(r.getAttribute(`x`),10),l=parseInt(r.getAttribute(`y`),10),f=parseInt(r.getAttribute(`c`),10),p=(d(n,`Compression`)||`none`).toLowerCase();if(!v.has(p))throw new t(`mrf:open`,`currently does not support compression `+p);let m=d(n,`DataType`)||`UInt8`,y=_.get(m.toLowerCase());if(y==null)throw new t(`mrf:open`,`currently does not support pixel type `+m);let b=u(n,`PageSize`),x=parseInt(b.getAttribute(`x`),10),S=parseInt(b.getAttribute(`y`),10),C=b.getAttribute(`c`),w=C?C===String(f):v.get(p).isOneSegment;this._isBsq=!w;let T=u(n,`DataValues`),E;if(T){let e=T.getAttribute(`NoData`);e!=null&&(E=e.trim().split(` `).map(e=>parseFloat(e)))}if(u(e,`MRF_META/CachedSource`))throw new t(`mrf:open`,`currently does not support MRF referencing other data files`);let D=u(e,`MRF_META/GeoTags`),O=u(D,`BoundingBox`),k=!1,A;if(O!=null){let e=parseFloat(O.getAttribute(`minx`)),t=parseFloat(O.getAttribute(`miny`)),n=parseFloat(O.getAttribute(`maxx`)),r=parseFloat(O.getAttribute(`maxy`)),a=d(D,`Projection`)||``,s=o.WGS84;if(a!==`LOCAL_CS[]`){if(a.toLowerCase().startsWith(`epsg:`)){let e=Number(a.slice(5));!isNaN(e)&&e!==0&&(s=new o({wkid:e}))}else s=c(a)??o.WGS84}else k=!0,s=new o({wkid:3857});A=new i(e,t,n,r),A.spatialReference=s}else k=!0,A=new i({xmin:-.5,ymin:.5-l,xmax:s-.5,ymax:.5,spatialReference:new o({wkid:3857})});let j=u(e,`MRF_META/Rsets`),M=parseInt(j?.getAttribute(`scale`)||`2`,10),N=A.spatialReference,P=new g({origin:new a({x:A.xmin,y:A.ymax,spatialReference:N}),blockWidth:x,blockHeight:S,pyramidBlockWidth:x,pyramidBlockHeight:S,compression:p,pyramidScalingFactor:M}),F=new a({x:A.width/s,y:A.height/l,spatialReference:N}),I=new h({width:s,height:l,extent:A,isPseudoSpatialReference:k,spatialReference:N,bandCount:f,pixelType:y,pixelSize:F,noDataValue:E,storageInfo:P}),L=this._getAuxFullPath(d(n,`DataFile`)),R=this._getAuxFullPath(d(n,`IndexFile`));return{rasterInfo:I,files:{mrf:this.url,index:R||this.url.replace(`.mrf`,`.idx`),data:L||this.url.replace(`.mrf`,v.get(p).blobExtension)}}}_getAuxFullPath(e){return!e||e.includes(`\\`)?null:e.includes(`/`)?e.startsWith(new URL(this.url).origin)?e:null:`${this.url.slice(0,this.url.lastIndexOf(`/`))}/${e}`}async _fetchAuxiliaryData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return l(t)}catch{return null}}};e([n()],y.prototype,`_files`,void 0),e([n()],y.prototype,`_storageIndex`,void 0),e([n()],y.prototype,`_isBsq`,void 0),e([n({type:String,json:{write:!0}})],y.prototype,`datasetFormat`,void 0),y=e([r(`esri.layers.raster.datasets.MRFRaster`)],y);function b(e){if(e.byteLength%16>0)throw Error(`invalid array buffer must be multiples of 16`);let t;if(f){let n=new Uint8Array(e),r=new ArrayBuffer(e.byteLength),i=new Uint8Array(r);for(let t=0;t<e.byteLength/4;t++)for(let e=0;e<4;e++)i[t*4+e]=n[t*4+3-e];t=new Uint32Array(r)}else t=new Uint32Array(e);return t}const x=y;export{x as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseFieldValues as g,isBSQConfig as _,getTagNumericValues as v,getTagFirstNumericValue as y,getImageInfo as b}from"../formats/tiffParser.js";import{tiffTags as x,geoKeys as S}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as C}from"../functions/stretchUtils.js";import w from"../transforms/PolynomialTransform.js";import T from"../../support/RasterInfo.js";import E from"../../support/RasterStorageInfo.js";import D from"../../../rest/support/FeatureSet.js";const O=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let k=class extends c{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this._chunkSize=10*1024**2,this.datasetFormat=`TIFF`}async fetchRawTile(e,t,n,r={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this._headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){let r=e?e.signal:null,{data:i}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:`array-buffer`,signal:r});if(!i)throw new t(`tiffraster:open`,`failed to open url `+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`));let{littleEndian:a,firstIFDPos:o,isBigTiff:s}=f(i),c=[],l={fileChunk:i,posIFD:o,fileOffset:0};await this._readIFDs(c,l,a,s?8:4,r);let{imageInfo:u,rasterInfo:d}=A(c),h=p(c),g=m(c);if(this._headerInfo={littleEndian:a,isBigTiff:s,ifds:c,pyramidIFDs:h,maskIFDs:g,...u},this._set(`rasterInfo`,d),!u.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+u.message);if(!u.tileWidth||!u.tileHeight)throw new t(`tiffraster:open`,O);d.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let _=c[0].get(`PREDICTOR`)?.values?.[0];if(c[0].get(`SAMPLEFORMAT`)?.values?.[0]===3&&_===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`);let{skipMapInfo:v,skipExtensions:y=[]}=this.ioConfig;if(!y.includes(`aux.xml`)&&!v){let t=await this._fetchAuxiliaryMetaData(e);t!=null&&j(t,d)}!y.includes(`vat.dbf`)&&d.bandCount===1&&d.pixelType===`u8`&&!v&&(d.attributeTable=await this._fetchAuxiliaryTable(e),d.attributeTable!=null&&(d.keyProperties.DataType=`thematic`)),v&&this.updateImageSpaceRasterInfo(d),this.updateTileInfo()}async _validateOrFetchHeaderBuffer(e,t){let{fileChunk:n,fileOffset:r,posIFD:i}=e;return(i+8>=n.byteLength||i<0)&&(r=i+r,n=(await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:`array-buffer`,signal:t})).data,i=0),{fileChunk:n,fileOffset:r,posIFD:i}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,x,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=x,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===x&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,O);let i=[];if(e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),e.has(`GEOKEYDIRECTORY`)){let t=e.get(`GEOKEYDIRECTORY`),r=t?.values;if(r&&r.length>4){let e=r[0]+`.`+r[1]+`.`+r[2];s=t.valueOffset+6-c;let i=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);t.data=(await this._readIFD(i,n,S,2,a))?.ifd,t.data&&t.data.set(`GEOTIFFVersion`,{id:0,type:2,valueCount:1,valueOffset:null,values:[e]})}}return l}return l.requiredBufferSize?(o=(await this.request(this.url,{range:{from:c,to:c+s+l.requiredBufferSize+8},responseType:`array-buffer`,signal:a})).data,o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=await this._fetchOffsets(o,Math.max(s,o+this._bufferSize),r);i.forEach(n=>g(e,t,n,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchOffsets(n[0],n[1]+n[0],r);g(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize,a=Math.ceil((t-e)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(a===1)return s[0].data;let c=new Uint8Array(t-e+1);for(let e=0;e<a;e++)c.set(new Uint8Array(s[e].data),e*i);return c.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{_headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=_(c,s),u=v(c,`TILEOFFSETS`),d=v(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=y(c,`IMAGEWIDTH`),b=y(c,`IMAGELENGTH`),x=y(c,`TILEWIDTH`),S=y(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%x||x,actualTileHeight:t===m&&b%S||S}}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?D.fromJSON(n.recordSet):null}catch{return null}}};e([r()],k.prototype,`_files`,void 0),e([r()],k.prototype,`_headerInfo`,void 0),e([r()],k.prototype,`_bufferSize`,void 0),e([r()],k.prototype,`_chunkSize`,void 0),e([r({type:String,json:{write:!0}})],k.prototype,`datasetFormat`,void 0),k=e([i(`esri.layers.raster.datasets.TIFFRaster`)],k);function A(e){let t=b(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:x,colormap:S}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,D=d(C),O=!!t.isPseudoGeographic;D??=(O=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:D}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:D}):new o({x:0,y:0}),j=new E({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),N=x?{BandProperties:x.bandProperties,DataType:x.dataType}:{},P=new T({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:D,isPseudoSpatialReference:O,keyProperties:N,extent:k,colormap:S,statistics:x?x.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:D}),P.transform=new w({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function j(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=C(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const M=k;export{M as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseFieldValues as g,isBSQConfig as _,getTagNumericValues as v,getTagFirstNumericValue as y,getImageInfo as b}from"../formats/tiffParser.js";import{tiffTags as x,geoKeys as S}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as C}from"../functions/stretchUtils.js";import w from"../transforms/PolynomialTransform.js";import T from"../../support/RasterInfo.js";import E from"../../support/RasterStorageInfo.js";import D from"../../../rest/support/FeatureSet.js";const O=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let k=class extends c{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this._chunkSize=10*1024**2,this.datasetFormat=`TIFF`}async fetchRawTile(e,t,n,r={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this._headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){let r=e?e.signal:null,{data:i}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:`array-buffer`,signal:r});if(!i)throw new t(`tiffraster:open`,`failed to open url `+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`));let{littleEndian:a,firstIFDPos:o,isBigTiff:s}=f(i),c=[],l={fileChunk:i,posIFD:o,fileOffset:0};await this._readIFDs(c,l,a,s?8:4,r);let{imageInfo:u,rasterInfo:d}=A(c),h=p(c),g=m(c);if(this._headerInfo={littleEndian:a,isBigTiff:s,ifds:c,pyramidIFDs:h,maskIFDs:g,...u},this._set(`rasterInfo`,d),!u.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+u.message);if(!u.tileWidth||!u.tileHeight)throw new t(`tiffraster:open`,O);d.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let _=c[0].get(`PREDICTOR`)?.values?.[0];if(c[0].get(`SAMPLEFORMAT`)?.values?.[0]===3&&_===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`);let{skipMapInfo:v,skipExtensions:y=[]}=this.ioConfig;if(!y.includes(`aux.xml`)&&!v){let t=await this._fetchAuxiliaryMetaData(e);t!=null&&j(t,d)}!y.includes(`vat.dbf`)&&d.bandCount===1&&d.pixelType===`u8`&&!v&&(d.attributeTable=await this._fetchAuxiliaryTable(e),d.attributeTable!=null&&(d.keyProperties.DataType=`thematic`)),v&&this.updateImageSpaceRasterInfo(d),this.updateTileInfo()}async _validateOrFetchHeaderBuffer(e,t){let{fileChunk:n,fileOffset:r,posIFD:i}=e;return(i+8>=n.byteLength||i<0)&&(r=i+r,n=(await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:`array-buffer`,signal:t})).data,i=0),{fileChunk:n,fileOffset:r,posIFD:i}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,x,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=x,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===x&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,O);let i=[];if(e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),e.has(`GEOKEYDIRECTORY`)){let t=e.get(`GEOKEYDIRECTORY`),r=t?.values;if(r&&r.length>4){let e=r[0]+`.`+r[1]+`.`+r[2];s=t.valueOffset+6-c;let i=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);t.data=(await this._readIFD(i,n,S,2,a))?.ifd,t.data&&t.data.set(`GEOTIFFVersion`,{id:0,type:2,valueCount:1,valueOffset:null,values:[e]})}}return l}return l.requiredBufferSize?(o=(await this.request(this.url,{range:{from:c,to:c+s+l.requiredBufferSize+8},responseType:`array-buffer`,signal:a})).data,o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=await this._fetchOffsets(o,Math.max(s,o+this._bufferSize),r);i.forEach(n=>g(e,t,n,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchOffsets(n[0],n[1]+n[0],r);g(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize,a=Math.ceil((t-e)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(a===1)return s[0].data;let c=new Uint8Array(t-e+1);for(let e=0;e<a;e++)c.set(new Uint8Array(s[e].data),e*i);return c.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null},{signal:i.signal});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{_headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=_(c,s),u=v(c,`TILEOFFSETS`),d=v(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=y(c,`IMAGEWIDTH`),b=y(c,`IMAGELENGTH`),x=y(c,`TILEWIDTH`),S=y(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%x||x,actualTileHeight:t===m&&b%S||S}}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?D.fromJSON(n.recordSet):null}catch{return null}}};e([r()],k.prototype,`_files`,void 0),e([r()],k.prototype,`_headerInfo`,void 0),e([r()],k.prototype,`_bufferSize`,void 0),e([r()],k.prototype,`_chunkSize`,void 0),e([r({type:String,json:{write:!0}})],k.prototype,`datasetFormat`,void 0),k=e([i(`esri.layers.raster.datasets.TIFFRaster`)],k);function A(e){let t=b(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:x,colormap:S}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,D=d(C),O=!!t.isPseudoGeographic;D??=(O=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:D}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:D}):new o({x:0,y:0}),j=new E({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),N=x?{BandProperties:x.bandProperties,DataType:x.dataType}:{},P=new T({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:D,isPseudoSpatialReference:O,keyProperties:N,extent:k,colormap:S,statistics:x?x.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:D}),P.transform=new w({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function j(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=C(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const M=k;export{M as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as s,describeCoverage as c}from"../../ogc/wcsUtils.js";import l from"./BaseRaster.js";import{convertOleDateTimeToEpoch as u}from"./multidimensionalUtils.js";import{parse as d}from"./multipartParser.js";import{standardizeInterpolations as f}from"./wcsCoverageParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{clip as m}from"../functions/pixelUtils.js";import h from"../../support/DimensionalDefinition.js";const g=[`nearest neighbor`,`bilinear`,`bicubic`],_=[`nearest`,`linear`,`cubic`],v=`response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode`,y=new Set([`1.0.0`,`1.1.0`,`1.1.1`,`1.1.2`,`2.0.1`]);let b=class extends l{constructor(){super(...arguments),this.datasetFormat=`WCSServer`,this.tileType=`Raster`}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,r,i,a={}){if(this.isBlockOutside(e,r,i))return null;let{nativePixelSize:o,spatialReference:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:u},r,i,p,s,[d,f]),g=this.rasterInfo.extent,_=h.xmax>g.xmax,v=h.ymin<g.ymin,y=_||v,b=h,x=d,S=f;if(y&&(b=h.clone().intersection(g),b!=null&&(_&&(x=Math.floor((b.xmax-b.xmin)/l),b.xmax=b.xmin+l*x),v&&(S=Math.floor((b.ymax-b.ymin)/u),b.ymin=b.ymax-u*S))),b==null||x<=1||S<=1)return null;let C=await this._getCoverage(b,x,S,c,a);if(!C)return null;let{coverageDescription:w}=this.coverageInfo,{noDataValue:T,multidimensionalInfo:E}=this.rasterInfo,{multidimensionalDefinition:D}=a,O;if(E!=null&&D!=null&&D.length){let e=D[0].variableName;w.version===`2.0`?O=w.rangeType[0].find(t=>t.name===e)?.nilValue:w.version===`1.1`&&(O=w.range.find(t=>t.identifier===e)?.nullValues)}let k=O??T,A=await this.decodePixelBlock(C,{width:x,height:S,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(k)?k[0]:k,matchAllNoData:!0});if(A==null)return null;if(A&&(A.width!==x||A.height!==S)){let e=`The tiff coverage response has unexpected width: ${A.width}, height: ${A.height}, expecting width: ${x}, height: ${S}`;throw n.getLogger(this).error(`wcsraster-fetch`,e),new t(`wcsraster-fetch`,e)}return y?m(A,{x:0,y:0},{width:f,height:f}):A}async _open(e){let{customFetchParameters:n}=this.ioConfig,r=e?.signal,i=await s(this.url,{version:n?.version??this.version,customParameters:n,signal:r});if(this.capabilities=i,!this.version){let e=i.version.slice(0,3);e===`2.0`||e===`1.1`||e===`1.0`?this.version=i.version:(e=i.supportedVersions.find(e=>e===`2.0.1`)||i.supportedVersions.find(e=>e.startsWith(`2.0`))||i.supportedVersions.find(e=>e.startsWith(`1.1`))||i.supportedVersions.find(e=>e.startsWith(`1.0`))||`1.0.0`,this.version=e)}let{version:a}=this;if(!y.has(a))throw new t(`wcsraster-open`,`unsupported WCS version ${a}`);let{gridCoverages:o}=i;if(!o.length)throw new t(`wcsraster-open`,`cannot find rectified grid coverages`);this.coverageId??=o[0].id;let{coverageId:l}=this,u=o.find(e=>e.id===l);if(u==null)throw new t(`wcsraster-open`,`the coverageId ${l} does not exist in capabilities`);let d=await c(this.url,{coverageIds:[l],version:a,customParameters:n,signal:r});if(this.coverageInfo=d[0],a.startsWith(`2.0`)){let{coverageInfo:e}=this;e.lonLatEnvelope=u.lonLatEnvelope,e.supportedInterpolations=f(i.supportedInterpolations),this._patchDimensionValues201(l,r)}this.datasetName=this.coverageInfo.title;let{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set(`rasterInfo`,p),p.spatialReference==null)throw new t(`wcsraster-open`,`coverage without spatial reference is not supported: ${l}`);let{pixelType:m,bandCount:h}=await this._getPixelTypeAndBandCount(r);p.pixelType=m,p.bandCount===1&&h>1&&(p.bandCount=h),this.updateTileInfo()}async _patchDimensionValues201(e,t){let{coverageInfo:n}=this,r=n.rasterInfo.multidimensionalInfo?.variables,i=y.has(`1.1.2`)?`1.1.2`:y.has(`1.1.1`)?`1.1.1`:y.has(`1.1.0`)?`1.1.0`:null,{customFetchParameters:a}=this.ioConfig;if(r&&i)try{let n=this.url.includes(`/ImageServer/`),o=e.length>8&&e.startsWith(`Coverage`)&&n?e.slice(8):e,s=(await c(this.url,{coverageIds:[o??e],version:i,customParameters:a,signal:t}).catch(()=>{if(o)return c(this.url,{coverageIds:[e],version:i,customParameters:a,signal:t})}))?.[0].rasterInfo.multidimensionalInfo?.variables;if(s)for(let e of r){let t=s.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let r=e.dimensions.length-1;r>=0;r--){let i=e.dimensions[r],a=t.dimensions.find(({name:e})=>e===i.name);if(!a){n&&e.dimensions.splice(r,1);continue}a.values&&a.extent?.join(`,`)===i.extent?.join(`,`)&&(e.dimensions[r]={...i,values:a.values})}}}catch{}}async _getPixelTypeAndBandCount(e){let{pixelSize:r,extent:i,multidimensionalInfo:o}=this.rasterInfo,s=i.center,c=new a({xmin:s.x-r.x,xmax:s.x+r.x,ymin:s.y-r.y,ymax:s.y+r.y,spatialReference:i.spatialReference}),l=[];if(o!=null){let e=o.variables[0];l=[],e.dimensions.forEach(t=>{l.push(new h({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}let{coverageDescription:u}=this.coverageInfo,d={interpolation:`nearest`,multidimensionalDefinition:l,signal:e},{version:f}=u,{ioConfig:p}=this,m=f===`2.0`&&p.allowAnyMediaType==null||f===`1.1`&&p.use2GridOffsets==null,g;try{g=await this._getCoverage(c,2,2,1,d,!0)}catch(e){if(!m)throw e;if(f===`1.1`){if(e.details?.isResolutionMismatch)p.use2GridOffsets=!0;else throw e}}if(!g&&m&&(f===`2.0`&&(p.allowAnyMediaType=!0),g=await this._getCoverage(c,2,2,1,d),g&&n.getLogger(this).warn(`wcsraster:getcoverage`,v)),!g)throw new t(`wcsraster-open`,`unable to determine pixel type`);let _=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(_==null)throw new t(`wcsraster-open`,`unable to determine pixel type`);return{pixelType:_.pixelType,bandCount:_.getPlaneCount()??0}}async _getCoverage(e,r,i,a,o,s=!1){let{coverageDescription:c}=this.coverageInfo,{version:l}=c,u=l===`2.0`?this._getCoverage201Parameters(e,r,i,a,o,c):l===`1.1`?this._getCoverage110Parameters(e,r,i,o,c):this._getCoverage100Parameters(e,r,i,o),f=l===`2.0`?await this.request(this._constructWCS201Url(u),{signal:o.signal,responseType:`array-buffer`}):await this.request(this.url,{query:u,signal:o.signal,responseType:`array-buffer`});if(l===`1.0`)return f.data;if(l===`2.0`&&this.ioConfig.allowAnyMediaType!==!1&&p(f.data)===`tiff`)return s&&(this.ioConfig.allowAnyMediaType=!0,n.getLogger(this).warn(`wcsraster:getcoverage`,v)),f.data;let m=d(f);if(m.isMultipart&&m.data){let e=m.data.find(e=>e.isValidImage);return s&&e?.contentTransferEncoding===`base64`&&n.getLogger(this).warn(`wcsraster:getcoverage`,`response is base64 encoded which may impact layer display performance`),e?.contentData}let h=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,h).toLowerCase().includes(`exception`),_=g&&String.fromCharCode.apply(null,h).includes(`A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided`);throw g?new t(`wcsraster:getcoverage`,`server returns an exception`,{isResolutionMismatch:_}):new t(`wcsraster:getcoverage`,`response is not a supported multipart mediaType with inline tiff`)}_getInterpolationIndex(e){return!e||!this.coverageInfo.supportedInterpolations?.includes(e)||e===`nearest`?0:e===`bilinear`?1:e===`cubic`?2:0}_getCoverage100Parameters(e,t,n,r){let i=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,a=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`GEOTIFF`,{bandIds:s,interpolation:c}=r,l=this._getInterpolationIndex(c),u=s?s.map(e=>this.coverageInfo.bandNames[e]):null,d=g[l],{multidimensionalDefinition:f}=r,p;if(f!=null&&this.rasterInfo.multidimensionalInfo!=null){let e=f.find(e=>e.dimensionName===`StdTime`)?.values;e&&e.length>0&&(Array.isArray(e[0])&&(e=e[0]),p=e.map(e=>x(e)).join(`,`))}return{service:`WCS`,request:`GetCoverage`,version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${a}`,bbox:i,width:t,height:n,time:p,interpolation:d,band:u?.join(`,`)}}_getCoverage110Parameters(e,t,n,r,i){let{multidimensionalDefinition:a,bandIds:s,interpolation:c}=r,l=e.spatialReference.wkid,u=`urn:ogc:def:crs:EPSG::${l}`,d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,f=this._getInterpolationIndex(c),p=_[f],m=c==null||this.coverageInfo.supportedInterpolations?.indexOf(c)===0,h=i.domain.spatialDomain,g=h.origin.x<=h.envelope.xmin&&h.origin.y<=h.envelope.ymin,v=e.width/t,y=e.height/n*(g?1:-1),b=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],S=h.useEPSGAxis&&o(l),C=S?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,w=this.ioConfig.use2GridOffsets,T=S?w?`${y},${v}`:`${y},0,0,${v}`:w?`${v},${y}`:`${v},0,0,${y}`,E=v/2,D=e.xmin+E,O=e.xmax-E,k=Math.abs(y)/2,A=e.ymin+k,j=e.ymax-k,M=S?`${A},${D},${j},${O},${u}`:`${D},${A},${O},${j},${u}`,N=i.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes(`band`))),P=N&&p&&s?m?`${N.identifier}[${N.axis[0].identifier}[${s.join(`,`)}]]`:`${N.identifier}:${p}[${N.axis[0].identifier}[${s.join(`,`)}]]`:null,F;if(a!=null&&a.length)for(let e=0;e<a.length;e++){let t=a[e].values,n=a[e].dimensionName?.toLowerCase(),r=a[e].variableName?.toLowerCase(),o=i.range.find(e=>e.identifier.toLowerCase()===r);if(t.length>0){if(Array.isArray(t[0])&&(t=t[0]),n===`stdtime`)F=t.map(e=>x(e)).join(`,`);else if(o){let e=o.axis.find(e=>e.identifier.toLowerCase()===n);e&&(P=m?o.identifier+`[`+e.identifier+`[`+t.join(`,`)+`]]`:o.identifier+`:`+p+`[`+e.identifier+`[`+t.join(`,`)+`]]`)}}e===a.length-1&&o&&!P&&(P=m?o.identifier:o.identifier+`:`+p)}return{service:`WCS`,request:`GetCoverage`,version:this.version,identifier:this.coverageId,format:d,crs:`EPSG:${l}`,boundingbox:M,gridCS:`urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS`,gridType:`urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs`,gridOrigin:C,gridOffsets:T,gridBaseCRS:u,timeSequence:F,rangeSubset:P}}_getCoverage201Parameters(e,t,n,r,i,a){let{multidimensionalDefinition:o,interpolation:s}=i,c=this._getInterpolationIndex(s),l=null,{supportedInterpolations:u}=this.capabilities;if(u?.length)switch(c){case 0:l=u.find(e=>e.toLowerCase().includes(`nearest`));break;case 1:l=u.find(e=>e.toLowerCase().includes(`linear`));break;case 2:l=u.find(e=>e.toLowerCase().includes(`cubic`)||e.toLowerCase().includes(`quadratic`))}let d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,{bandNames:f}=this.coverageInfo,{boundedBy:p,domainSet:m,rangeType:h}=a,g=+!p.isEastFirst,_=1-g,{axisLabels:v}=p,y=v[g],b=v[_],S=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=S,w=[];w.push(`${y}(${e.xmin},${e.xmax})`),w.push(`${b}(${e.ymin},${e.ymax})`);let T=[];if(v.length>2)for(let e=2;e<v.length;e++){let t=m.origin[e];if(v[e].toLowerCase().includes(`time`)){let n=t.toString();p.uomLabels?.[e].toLowerCase().includes(`ole`)&&(T.push(v[e]),n=x(t,!0)),w.push(v[e]+`,http://www.opengis.net(`+n+`)`)}else w.push(v[e]+`,http://www.opengis.net(`+t+`)`)}let E=null;if(o!=null&&o.length){let e=[];h.forEach(t=>t.forEach(t=>e.push(t.name)));let t=[];for(let n=0;n<o.length;n++){let r=v.find(e=>e===o[n].dimensionName),i=e.find(e=>e===o[n].variableName);if(t.includes(i)||t.push(i),r){let e=o[n].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t=``;t=r.toLowerCase().includes(`time`)?e.map(e=>x(e)).join(`,`):e.join(`,`);let n=w.findIndex(e=>e.startsWith(r+`,http://www.opengis.net`));n===-1&&w.push(r+`,http://www.opengis.net(`+t+`)`),n!==-1&&!w[n].includes(`(`+t+`)`)&&w.splice(n,1,r+`,http://www.opengis.net(`+t+`)`)}}}t.length&&(E=t.join(`,`))}else f?.length>=2&&(E=(i.bandIds?i.bandIds.map(e=>f[e]):f).join(`,`));let D=w.join(`&subset=`),O=!a.domainSet.hasSameAxisLabelsAsBoundedBy&&this.ioConfig.allowScaleFactor!==!1,k=O?null:`${y}(${t}),${b}(${n})`,A=O?1/r:null;return{service:`WCS`,request:`GetCoverage`,version:this.version,coverageId:this.coverageId,rangesubset:E,interpolation:l,scaleSize:k,scaleFactor:A,subset:D,format:d,mediaType:this.ioConfig.allowAnyMediaType?null:`multipart/related`,outputcrs:S,subsettingcrs:C}}_constructWCS201Url(e){let t={...this.ioConfig.customFetchParameters,...e},n=[];return Object.keys(t).forEach(e=>{let r=t[e];if(r!=null){if(e!==`subset`){n.push(`${e}=${encodeURIComponent(r)}`);return}typeof r==`string`&&r.split(`&subset=`).forEach(e=>{e&&n.push(`subset=${encodeURIComponent(e)}`)})}}),`${encodeURI(this.url)}?${n.join(`&`)}`}};e([r({type:String,json:{write:!0}})],b.prototype,`datasetFormat`,void 0),e([r({readOnly:!0})],b.prototype,`tileType`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`version`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`coverageId`,void 0),e([r({readOnly:!0})],b.prototype,`rasterId`,null),b=e([i(`esri.layers.raster.datasets.WCSRaster`)],b);function x(e,t=!1){return(t?new Date(u(e)):new Date(e)).toISOString()}export{b as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as s,describeCoverage as c}from"../../ogc/wcsUtils.js";import l from"./BaseRaster.js";import{convertOleDateTimeToEpoch as u}from"./multidimensionalUtils.js";import{parse as d}from"./multipartParser.js";import{standardizeInterpolations as f}from"./wcsCoverageParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{clip as m}from"../functions/pixelUtils.js";import h from"../../support/DimensionalDefinition.js";const g=[`nearest neighbor`,`bilinear`,`bicubic`],_=[`nearest`,`linear`,`cubic`],v=`response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode`,y=new Set([`1.0.0`,`1.1.0`,`1.1.1`,`1.1.2`,`2.0.1`]);let b=class extends l{constructor(){super(...arguments),this.datasetFormat=`WCSServer`,this.tileType=`Raster`}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,r,i,a={}){if(this.isBlockOutside(e,r,i))return null;let{nativePixelSize:o,spatialReference:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:u},r,i,p,s,[d,f]),g=this.rasterInfo.extent,_=h.xmax>g.xmax,v=h.ymin<g.ymin,y=_||v,b=h,x=d,S=f;if(y&&(b=h.clone().intersection(g),b!=null&&(_&&(x=Math.floor((b.xmax-b.xmin)/l),b.xmax=b.xmin+l*x),v&&(S=Math.floor((b.ymax-b.ymin)/u),b.ymin=b.ymax-u*S))),b==null||x<=1||S<=1)return null;let C=await this._getCoverage(b,x,S,c,a);if(!C)return null;let{coverageDescription:w}=this.coverageInfo,{noDataValue:T,multidimensionalInfo:E}=this.rasterInfo,{multidimensionalDefinition:D}=a,O;if(E!=null&&D!=null&&D.length){let e=D[0].variableName;w.version===`2.0`?O=w.rangeType[0].find(t=>t.name===e)?.nilValue:w.version===`1.1`&&(O=w.range.find(t=>t.identifier===e)?.nullValues)}let k=O??T,A=await this.decodePixelBlock(C,{width:x,height:S,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(k)?k[0]:k,matchAllNoData:!0},{signal:a.signal});if(A==null)return null;if(A&&(A.width!==x||A.height!==S)){let e=`The tiff coverage response has unexpected width: ${A.width}, height: ${A.height}, expecting width: ${x}, height: ${S}`;throw n.getLogger(this).error(`wcsraster-fetch`,e),new t(`wcsraster-fetch`,e)}return y?m(A,{x:0,y:0},{width:f,height:f}):A}async _open(e){let{customFetchParameters:n}=this.ioConfig,r=e?.signal,i=await s(this.url,{version:n?.version??this.version,customParameters:n,signal:r});if(this.capabilities=i,!this.version){let e=i.version.slice(0,3);e===`2.0`||e===`1.1`||e===`1.0`?this.version=i.version:(e=i.supportedVersions.find(e=>e===`2.0.1`)||i.supportedVersions.find(e=>e.startsWith(`2.0`))||i.supportedVersions.find(e=>e.startsWith(`1.1`))||i.supportedVersions.find(e=>e.startsWith(`1.0`))||`1.0.0`,this.version=e)}let{version:a}=this;if(!y.has(a))throw new t(`wcsraster-open`,`unsupported WCS version ${a}`);let{gridCoverages:o}=i;if(!o.length)throw new t(`wcsraster-open`,`cannot find rectified grid coverages`);this.coverageId??=o[0].id;let{coverageId:l}=this,u=o.find(e=>e.id===l);if(u==null)throw new t(`wcsraster-open`,`the coverageId ${l} does not exist in capabilities`);let d=await c(this.url,{coverageIds:[l],version:a,customParameters:n,signal:r});if(this.coverageInfo=d[0],a.startsWith(`2.0`)){let{coverageInfo:e}=this;e.lonLatEnvelope=u.lonLatEnvelope,e.supportedInterpolations=f(i.supportedInterpolations),this._patchDimensionValues201(l,r)}this.datasetName=this.coverageInfo.title;let{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set(`rasterInfo`,p),p.spatialReference==null)throw new t(`wcsraster-open`,`coverage without spatial reference is not supported: ${l}`);let{pixelType:m,bandCount:h}=await this._getPixelTypeAndBandCount(r);p.pixelType=m,p.bandCount===1&&h>1&&(p.bandCount=h),this.updateTileInfo()}async _patchDimensionValues201(e,t){let{coverageInfo:n}=this,r=n.rasterInfo.multidimensionalInfo?.variables,i=y.has(`1.1.2`)?`1.1.2`:y.has(`1.1.1`)?`1.1.1`:y.has(`1.1.0`)?`1.1.0`:null,{customFetchParameters:a}=this.ioConfig;if(r&&i)try{let n=this.url.includes(`/ImageServer/`),o=e.length>8&&e.startsWith(`Coverage`)&&n?e.slice(8):e,s=(await c(this.url,{coverageIds:[o??e],version:i,customParameters:a,signal:t}).catch(()=>{if(o)return c(this.url,{coverageIds:[e],version:i,customParameters:a,signal:t})}))?.[0].rasterInfo.multidimensionalInfo?.variables;if(s)for(let e of r){let t=s.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let r=e.dimensions.length-1;r>=0;r--){let i=e.dimensions[r],a=t.dimensions.find(({name:e})=>e===i.name);if(!a){n&&e.dimensions.splice(r,1);continue}a.values&&a.extent?.join(`,`)===i.extent?.join(`,`)&&(e.dimensions[r]={...i,values:a.values})}}}catch{}}async _getPixelTypeAndBandCount(e){let{pixelSize:r,extent:i,multidimensionalInfo:o}=this.rasterInfo,s=i.center,c=new a({xmin:s.x-r.x,xmax:s.x+r.x,ymin:s.y-r.y,ymax:s.y+r.y,spatialReference:i.spatialReference}),l=[];if(o!=null){let e=o.variables[0];l=[],e.dimensions.forEach(t=>{l.push(new h({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}let{coverageDescription:u}=this.coverageInfo,d={interpolation:`nearest`,multidimensionalDefinition:l,signal:e},{version:f}=u,{ioConfig:p}=this,m=f===`2.0`&&p.allowAnyMediaType==null||f===`1.1`&&p.use2GridOffsets==null,g;try{g=await this._getCoverage(c,2,2,1,d,!0)}catch(e){if(!m)throw e;if(f===`1.1`){if(e.details?.isResolutionMismatch)p.use2GridOffsets=!0;else throw e}}if(!g&&m&&(f===`2.0`&&(p.allowAnyMediaType=!0),g=await this._getCoverage(c,2,2,1,d),g&&n.getLogger(this).warn(`wcsraster:getcoverage`,v)),!g)throw new t(`wcsraster-open`,`unable to determine pixel type`);let _=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null},{signal:d.signal});if(_==null)throw new t(`wcsraster-open`,`unable to determine pixel type`);return{pixelType:_.pixelType,bandCount:_.getPlaneCount()??0}}async _getCoverage(e,r,i,a,o,s=!1){let{coverageDescription:c}=this.coverageInfo,{version:l}=c,u=l===`2.0`?this._getCoverage201Parameters(e,r,i,a,o,c):l===`1.1`?this._getCoverage110Parameters(e,r,i,o,c):this._getCoverage100Parameters(e,r,i,o),f=l===`2.0`?await this.request(this._constructWCS201Url(u),{signal:o.signal,responseType:`array-buffer`}):await this.request(this.url,{query:u,signal:o.signal,responseType:`array-buffer`});if(l===`1.0`)return f.data;if(l===`2.0`&&this.ioConfig.allowAnyMediaType!==!1&&p(f.data)===`tiff`)return s&&(this.ioConfig.allowAnyMediaType=!0,n.getLogger(this).warn(`wcsraster:getcoverage`,v)),f.data;let m=d(f);if(m.isMultipart&&m.data){let e=m.data.find(e=>e.isValidImage);return s&&e?.contentTransferEncoding===`base64`&&n.getLogger(this).warn(`wcsraster:getcoverage`,`response is base64 encoded which may impact layer display performance`),e?.contentData}let h=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,h).toLowerCase().includes(`exception`),_=g&&String.fromCharCode.apply(null,h).includes(`A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided`);throw g?new t(`wcsraster:getcoverage`,`server returns an exception`,{isResolutionMismatch:_}):new t(`wcsraster:getcoverage`,`response is not a supported multipart mediaType with inline tiff`)}_getInterpolationIndex(e){return!e||!this.coverageInfo.supportedInterpolations?.includes(e)||e===`nearest`?0:e===`bilinear`?1:e===`cubic`?2:0}_getCoverage100Parameters(e,t,n,r){let i=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,a=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`GEOTIFF`,{bandIds:s,interpolation:c}=r,l=this._getInterpolationIndex(c),u=s?s.map(e=>this.coverageInfo.bandNames[e]):null,d=g[l],{multidimensionalDefinition:f}=r,p;if(f!=null&&this.rasterInfo.multidimensionalInfo!=null){let e=f.find(e=>e.dimensionName===`StdTime`)?.values;e&&e.length>0&&(Array.isArray(e[0])&&(e=e[0]),p=e.map(e=>x(e)).join(`,`))}return{service:`WCS`,request:`GetCoverage`,version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${a}`,bbox:i,width:t,height:n,time:p,interpolation:d,band:u?.join(`,`)}}_getCoverage110Parameters(e,t,n,r,i){let{multidimensionalDefinition:a,bandIds:s,interpolation:c}=r,l=e.spatialReference.wkid,u=`urn:ogc:def:crs:EPSG::${l}`,d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,f=this._getInterpolationIndex(c),p=_[f],m=c==null||this.coverageInfo.supportedInterpolations?.indexOf(c)===0,h=i.domain.spatialDomain,g=h.origin.x<=h.envelope.xmin&&h.origin.y<=h.envelope.ymin,v=e.width/t,y=e.height/n*(g?1:-1),b=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],S=h.useEPSGAxis&&o(l),C=S?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,w=this.ioConfig.use2GridOffsets,T=S?w?`${y},${v}`:`${y},0,0,${v}`:w?`${v},${y}`:`${v},0,0,${y}`,E=v/2,D=e.xmin+E,O=e.xmax-E,k=Math.abs(y)/2,A=e.ymin+k,j=e.ymax-k,M=S?`${A},${D},${j},${O},${u}`:`${D},${A},${O},${j},${u}`,N=i.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes(`band`))),P=N&&p&&s?m?`${N.identifier}[${N.axis[0].identifier}[${s.join(`,`)}]]`:`${N.identifier}:${p}[${N.axis[0].identifier}[${s.join(`,`)}]]`:null,F;if(a!=null&&a.length)for(let e=0;e<a.length;e++){let t=a[e].values,n=a[e].dimensionName?.toLowerCase(),r=a[e].variableName?.toLowerCase(),o=i.range.find(e=>e.identifier.toLowerCase()===r);if(t.length>0){if(Array.isArray(t[0])&&(t=t[0]),n===`stdtime`)F=t.map(e=>x(e)).join(`,`);else if(o){let e=o.axis.find(e=>e.identifier.toLowerCase()===n);e&&(P=m?o.identifier+`[`+e.identifier+`[`+t.join(`,`)+`]]`:o.identifier+`:`+p+`[`+e.identifier+`[`+t.join(`,`)+`]]`)}}e===a.length-1&&o&&!P&&(P=m?o.identifier:o.identifier+`:`+p)}return{service:`WCS`,request:`GetCoverage`,version:this.version,identifier:this.coverageId,format:d,crs:`EPSG:${l}`,boundingbox:M,gridCS:`urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS`,gridType:`urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs`,gridOrigin:C,gridOffsets:T,gridBaseCRS:u,timeSequence:F,rangeSubset:P}}_getCoverage201Parameters(e,t,n,r,i,a){let{multidimensionalDefinition:o,interpolation:s}=i,c=this._getInterpolationIndex(s),l=null,{supportedInterpolations:u}=this.capabilities;if(u?.length)switch(c){case 0:l=u.find(e=>e.toLowerCase().includes(`nearest`));break;case 1:l=u.find(e=>e.toLowerCase().includes(`linear`));break;case 2:l=u.find(e=>e.toLowerCase().includes(`cubic`)||e.toLowerCase().includes(`quadratic`))}let d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,{bandNames:f}=this.coverageInfo,{boundedBy:p,domainSet:m,rangeType:h}=a,g=+!p.isEastFirst,_=1-g,{axisLabels:v}=p,y=v[g],b=v[_],S=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=S,w=[];w.push(`${y}(${e.xmin},${e.xmax})`),w.push(`${b}(${e.ymin},${e.ymax})`);let T=[];if(v.length>2)for(let e=2;e<v.length;e++){let t=m.origin[e];if(v[e].toLowerCase().includes(`time`)){let n=t.toString();p.uomLabels?.[e].toLowerCase().includes(`ole`)&&(T.push(v[e]),n=x(t,!0)),w.push(v[e]+`,http://www.opengis.net(`+n+`)`)}else w.push(v[e]+`,http://www.opengis.net(`+t+`)`)}let E=null;if(o!=null&&o.length){let e=[];h.forEach(t=>t.forEach(t=>e.push(t.name)));let t=[];for(let n=0;n<o.length;n++){let r=v.find(e=>e===o[n].dimensionName),i=e.find(e=>e===o[n].variableName);if(t.includes(i)||t.push(i),r){let e=o[n].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t=``;t=r.toLowerCase().includes(`time`)?e.map(e=>x(e)).join(`,`):e.join(`,`);let n=w.findIndex(e=>e.startsWith(r+`,http://www.opengis.net`));n===-1&&w.push(r+`,http://www.opengis.net(`+t+`)`),n!==-1&&!w[n].includes(`(`+t+`)`)&&w.splice(n,1,r+`,http://www.opengis.net(`+t+`)`)}}}t.length&&(E=t.join(`,`))}else f?.length>=2&&(E=(i.bandIds?i.bandIds.map(e=>f[e]):f).join(`,`));let D=w.join(`&subset=`),O=!a.domainSet.hasSameAxisLabelsAsBoundedBy&&this.ioConfig.allowScaleFactor!==!1,k=O?null:`${y}(${t}),${b}(${n})`,A=O?1/r:null;return{service:`WCS`,request:`GetCoverage`,version:this.version,coverageId:this.coverageId,rangesubset:E,interpolation:l,scaleSize:k,scaleFactor:A,subset:D,format:d,mediaType:this.ioConfig.allowAnyMediaType?null:`multipart/related`,outputcrs:S,subsettingcrs:C}}_constructWCS201Url(e){let t={...this.ioConfig.customFetchParameters,...e},n=[];return Object.keys(t).forEach(e=>{let r=t[e];if(r!=null){if(e!==`subset`){n.push(`${e}=${encodeURIComponent(r)}`);return}typeof r==`string`&&r.split(`&subset=`).forEach(e=>{e&&n.push(`subset=${encodeURIComponent(e)}`)})}}),`${encodeURI(this.url)}?${n.join(`&`)}`}};e([r({type:String,json:{write:!0}})],b.prototype,`datasetFormat`,void 0),e([r({readOnly:!0})],b.prototype,`tileType`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`version`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`coverageId`,void 0),e([r({readOnly:!0})],b.prototype,`rasterId`,null),b=e([i(`esri.layers.raster.datasets.WCSRaster`)],b);function x(e,t=!1){return(t?new Date(u(e)):new Date(e)).toISOString()}export{b as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../core/Error.js";import{throwIfAborted as t,throwIfAbortError as n}from"../../../core/promiseUtils.js";import{inflate as r}from"./Zlib.js";async function i(r,i,c){if(!r||r.byteLength<10)throw new e(`imagecanvasdecoder: decode`,`required a valid encoded data as input.`);let{width:d,height:f,format:p}=i,{applyJpegMask:m}=i;if(m&&!(d&&f))throw new e(`imagecanvasdecoder: decode`,`image width and height are needed to apply jpeg mask directly to canvas`);let h=null;p===`jpg`&&m&&d&&f&&(h=await u(r,{width:d,height:f}));try{let e=new Blob([new Uint8Array(r)],{type:l(p)}),u=await createImageBitmap(e);t(c);let{useTiledDecoding:d,tileIndex:f,tileSize:m}=i;if(d&&f==null)return o(u,h,m);if(f!=null&&m!=null)return s(u,f,m);try{return a(u,h)}catch(e){if(n(e),u.width>4096||u.height>4096)return o(u,h);throw e}}catch(t){throw n(t),new e(`imagecanvasdecoder: decode`,`cannot load image`)}}function a(t,n){let{width:r,height:i}=t,a=new OffscreenCanvas(r,i),o=a.getContext(`2d`);if(!o)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);o.drawImage(t,0,0,r,i);let s=c(o.getImageData(0,0,r,i),r,i,n);return a.width=0,a.height=0,s}function o(t,n,r=[2048,2048]){let[i,a]=r,o=new OffscreenCanvas(i,a),s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);let{width:c,height:l}=t,u=c*l,d=new Uint8Array(u),f=new Uint8Array(u),p=new Uint8Array(u),m=n==null;n||=new Uint8Array(u);for(let e=0;e<l;e+=a){let r=Math.min(a,l-e);for(let a=0;a<c;a+=i){let o=Math.min(i,c-a);s.clearRect(0,0,o,r),s.drawImage(t,a,e,o,r,0,0,o,r);let{data:l}=s.getImageData(0,0,o,r);for(let t=0;t<r;t++){let r=t*o*4,i=(e+t)*c+a;for(let e=0;e<o;e++,r+=4,i++)d[i]=l[r],f[i]=l[r+1],p[i]=l[r+2],m&&(n[i]=l[r+3])}}}let h={width:c,height:l,pixels:[d,f,p],mask:n,pixelType:`u8`};return o.width=0,o.height=0,console.log(`decodeFullImageTiled: ${c}x${l} using tile ${i}x${a}`,h),h}function s(t,n,r){let[i,a,o]=n,[s,l]=r,u=Math.ceil(t.width/2**i),d=Math.ceil(t.height/2**i),f=Math.ceil(d/l),p=Math.ceil(u/s);if(a>=f||o>=p)return null;let m=new OffscreenCanvas(u,d),h=m.getContext(`2d`);if(!h)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);h.drawImage(t,0,0,u,d);let g=o*s,_=a*l,v=Math.min(s,u-g),y=Math.min(l,d-_),b=c(h.getImageData(g,_,v,y),s,l);return m.width=0,m.height=0,b}function c(e,t,n,r){let i=t*n,a=new Uint8Array(i),o=new Uint8Array(i),s=new Uint8Array(i),c=r==null;r||=new Uint8Array(i);let l={width:t,height:n,pixels:[a,o,s],mask:r,pixelType:`u8`},{width:u,height:d,data:f}=e;if(u===t&&d===n){for(let e=0,t=0;e<i;e++,t+=4)a[e]=f[t],o[e]=f[t+1],s[e]=f[t+2],c&&(r[e]=f[t+3]);return l}for(let e=0;e<d;e++){let n=e*u*4;for(let i=0;i<u;i++){let l=e*t+i;a[l]=f[n+i*4],o[l]=f[n+i*4+1],s[l]=f[n+i*4+2],c&&(r[l]=f[n+i*4+3])}}return l}function l(e){return`image/${e===`jpg`?`jpeg`:e}`}async function u(e,t){try{let n=new Uint8Array(e),r=Math.ceil(n.length/2),i=n.length-2;for(;r<i&&(n[r]!==255||n[r+1]!==217);r++);r+=2;let a=null;return r<n.length-1&&(a=await d(n.subarray(r,-4),t.width*t.height)),a}catch{return null}}async function d(e,t){try{let n=await r(e),i=new Uint8Array(t);for(let e=0,t=0;e<n.length;e++)for(let r=7;r>=0;r--)i[t++]=n[e]>>r&1;return i}catch{return null}}export{i as decode,d as decodeBitMask};
2
+ import e from"../../../core/Error.js";import{throwIfAborted as t,throwIfAbortError as n}from"../../../core/promiseUtils.js";import{inflate as r}from"./Zlib.js";async function i(r,i,c){if(!r||r.byteLength<10)throw new e(`imagecanvasdecoder: decode`,`required a valid encoded data as input.`);let{width:d,height:f,format:p}=i,{applyJpegMask:m}=i;if(m&&!(d&&f))throw new e(`imagecanvasdecoder: decode`,`image width and height are needed to apply jpeg mask directly to canvas`);let h=null;p===`jpg`&&m&&d&&f&&(h=await u(r,{width:d,height:f}));try{let e=new Blob([new Uint8Array(r)],{type:l(p)}),u=await createImageBitmap(e);t(c);let{useTiledDecoding:d,tileIndex:f,tileSize:m}=i;if(d&&f==null)return o(u,h,m);if(f!=null&&m!=null)return s(u,f,m);try{return a(u,h)}catch(e){if(n(e),u.width>4096||u.height>4096)return o(u,h);throw e}}catch(t){throw n(t),new e(`imagecanvasdecoder: decode`,`cannot load image`)}}function a(t,n){let{width:r,height:i}=t,a=new OffscreenCanvas(r,i),o=a.getContext(`2d`);if(!o)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);o.drawImage(t,0,0,r,i);let s=c(o.getImageData(0,0,r,i),r,i,n);return a.width=0,a.height=0,s}function o(t,n,r=[2048,2048]){let[i,a]=r,o=new OffscreenCanvas(i,a),s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);let{width:c,height:l}=t,u=c*l,d=new Uint8Array(u),f=new Uint8Array(u),p=new Uint8Array(u),m=n==null;n||=new Uint8Array(u);for(let e=0;e<l;e+=a){let r=Math.min(a,l-e);for(let a=0;a<c;a+=i){let o=Math.min(i,c-a);s.clearRect(0,0,o,r),s.drawImage(t,a,e,o,r,0,0,o,r);let{data:l}=s.getImageData(0,0,o,r);for(let t=0;t<r;t++){let r=t*o*4,i=(e+t)*c+a;for(let e=0;e<o;e++,r+=4,i++)d[i]=l[r],f[i]=l[r+1],p[i]=l[r+2],m&&(n[i]=l[r+3])}}}let h={width:c,height:l,pixels:[d,f,p],mask:n,pixelType:`u8`};return o.width=0,o.height=0,console.log(`decodeFullImageTiled: ${c}x${l} using tile ${i}x${a}`,h),h}function s(t,n,r){let[i,a,o]=n,[s,l]=r,u=Math.ceil(t.width/2**i),d=Math.ceil(t.height/2**i),f=Math.ceil(d/l),p=Math.ceil(u/s);if(a>=f||o>=p)return null;let m=new OffscreenCanvas(u,d),h=m.getContext(`2d`);if(!h)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);h.drawImage(t,0,0,u,d);let g=o*s,_=a*l,v=Math.min(s,u-g),y=Math.min(l,d-_),b=c(h.getImageData(g,_,v,y),s,l);return m.width=0,m.height=0,b}function c(e,t,n,r){let i=t*n,a=new Uint8Array(i),o=new Uint8Array(i),s=new Uint8Array(i),c=r==null;r||=new Uint8Array(i);let l={width:t,height:n,pixels:[a,o,s],mask:r,pixelType:`u8`},{width:u,height:d,data:f}=e;if(u===t&&d===n){for(let e=0,t=0;e<i;e++,t+=4)a[e]=f[t],o[e]=f[t+1],s[e]=f[t+2],c&&(r[e]=f[t+3]);return l}for(let e=0;e<d;e++){let n=e*u*4;for(let i=0;i<u;i++){let l=e*t+i;a[l]=f[n+i*4],o[l]=f[n+i*4+1],s[l]=f[n+i*4+2],c&&(r[l]=f[n+i*4+3])}}return l}function l(e){return`image/${e===`jpg`?`jpeg`:e}`}async function u(e,t){try{let n=new Uint8Array(e),r=Math.ceil(n.length/2),i=n.length-2;for(;r<i&&(n[r]!==255||n[r+1]!==217);r++);r+=2;let a=null;return r<n.length-1&&(a=await d(n.subarray(r,-4),t.width*t.height)),a}catch{return null}}async function d(e,t,n){try{let i=await r(e,void 0,n),a=new Uint8Array(t);for(let e=0,t=0;e<i.length;e++)for(let n=7;n>=0;n--)a[t++]=i[e]>>n&1;return a}catch{return null}}export{i as decode,d as decodeBitMask};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../core/Error.js";import{assertIsSome as t}from"../../../core/maybe.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{decode as r}from"./ImageCanvasDecoder.js";import{decode as i}from"./JpgPlus.js";import{load as a,decode as o}from"./Lerc.js";import{decode as s}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{load as l,decode as u}from"./Qb3.js";import{decode as d}from"./Raw.js";import{decodeTileOrStrip as f,decode as p}from"./TiffDecoder.js";import{isPlatformLittleEndian as m}from"./utils.js";import{inflate as h}from"./Zlib.js";import g from"../../support/PixelBlock.js";import _ from"../../support/SimpleBandStatistics.js";async function v(t,n){if(!m)throw new e(`rasterCoded:decode`,`lerc decoder is not supported on big endian platform`);await a();let{width:r,height:i,pixelType:s,statistics:c,depthCount:l,noDataValues:u,bandMasks:d,pixels:f,mask:p,validPixelCount:h}=o(t,{inputOffset:n.offset,returnInterleaved:n.returnInterleaved});return new g({width:r,height:i,pixelType:s.toLowerCase(),pixels:f,mask:p,validPixelCount:h,statistics:c.map(({minValue:e,maxValue:t})=>new _(e,t)),bandMasks:d,depthCount:l,noDataValues:u})}async function y(t,n){await l();let r=u(t);if(!r)throw new e(`rasterCodec:decode`,`failed to decode the input data.`);let{width:i,height:a,pixels:o,pixelType:s}=r;return new g({width:i,height:a,pixelType:s,pixels:o})}async function b(e,n){let r=await p(e,{...n,noDataValue:n.tiffNoDataValue,matchAllNoData:n.matchAllNoData});return t(r),new g({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask,bandMasks:r.bandMasks})}async function x(e,t){let n=await f(e,t.customOptions),r=new g({width:n.width,height:n.height,pixels:n.pixels,pixelType:n.pixelType.toLowerCase(),mask:n.mask});return t.skipStatistics||r.updateStatistics(),r}function S(e,t){let n=t.pixelType||`u8`,r=g.getPixelArrayConstructor(n),i=n===`u8`?e:new r(e.buffer),a=[],o=t.planes||1;if(o===1)a.push(i);else for(let n=0;n<o;n++){let s=(t.width||1)*(t.height||e.length),c=new r(s);for(let e=0;e<s;e++)c[e]=i[e*o+n];a.push(c)}return new g({width:t.width||1,height:t.height||e.length,pixels:a,pixelType:n})}async function C(e,t){return S(await h(new Uint8Array(e)),t)}function w(e,t){return S(s(e,t.offset,t.eof,!t.isInputBigEndian),t)}function T(e,t){let n=t.format,{pixelTypeCtor:r}=A(t.pixelType),i=d(e,{width:t.width,height:t.height,pixelType:r,format:n});return new g({width:t.width,height:t.height,pixels:i.pixels,pixelType:t.pixelType,mask:i.mask})}async function E(e,t){let n=await i(e,t);return new g({width:n.width,height:n.height,pixels:n.pixels,pixelType:`u8`,mask:n.mask})}async function D(e,t,n){let i=await r(e,t,n);return new g(i)}async function O(t,r,i){let a=r.format||M(t),o={...r,format:a},{canvasUsage:s}=r;if(s!==`no-canvas`||a===`png`)try{return await D(t,o,i)}catch(t){if(n(t))throw t;if(s===`canvas-only`)throw new e(`rasterCodec:decode`,`failed to decode the input data with canvas for format ${a}`)}return await E(t,o)}function k(t){let n=null;switch(t){case`lerc`:n=v;break;case`jpg`:case`png`:n=O;break;case`bmp`:case`gif`:n=D;break;case`bsq`:case`bip`:n=T;break;case`tiff`:n=b;break;case`deflate`:n=C;break;case`lzw`:n=w;break;case`qb3`:n=y;break;default:n=()=>{throw new e(`rasterCodec:decode`,`unsupported raster format ${t}`)}}return n}function A(e){let t=e?e.toLowerCase():`f32`,n=null,r=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:r=255,n=Uint8Array;break;case`u16`:r||=2**16-1,n=Uint16Array;break;case`u32`:r||=2**32-1,n=Uint32Array;break;case`s8`:r||=-128,n=Int8Array;break;case`s16`:r||=0-2**15,n=Int16Array;break;case`s32`:r||=0-2**31,n=Int32Array;break;default:n=Float32Array}return{pixelTypeCtor:n,noDataValue:r}}function j(e,t=`bilinear`){if(!e)return;let{pixels:n,width:r,height:i,mask:a}=e;if(!n||n.length===0)return;let o=r-1,s=i-1,c=[],l=null,u=g.getPixelArrayConstructor(e.pixelType);if(t===`nearest`){for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let r=0;r<o;r++)t[n*o+r]=e[i+r]}c.push(t)}if(a!=null){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=a[t+n]}}}else{for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let a=0;a<o;a++)t[n*o+a]=(e[i+a]+e[i+a+1]+e[i+r+a]+e[i+r+a+1])/4}c.push(t)}if(a){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=Math.min.apply(null,[a[t+n],a[t+n+1],a[t+r+n],a[t+r+n+1]])}}}e.width=o,e.height=s,e.mask=l,e.pixels=c}function M(e){if(!e)return;let t=new Uint8Array(e,0,10),n;return t[0]===255&&t[1]===216?n=`jpg`:t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?n=`png`:t[0]===67&&t[1]===110&&t[2]===116&&t[3]===90&&t[4]===73&&t[5]===109&&t[6]===97&&t[7]===103&&t[8]===101&&t[9]===32||t[0]===76&&t[1]===101&&t[2]===114&&t[3]===99&&t[4]===50&&t[5]===32?n=`lerc`:t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42||t[0]===73&&t[1]===73&&t[2]===43&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===43?n=`tiff`:t[0]===71&&t[1]===73&&t[2]===70?n=`gif`:t[0]===66&&t[1]===77?n=`bmp`:t[0]===81&&t[1]===66&&t[2]===51&&(n=`qb3`),n}async function N(t,n={},r){if(t==null)throw new e(`rasterCodec:decode`,`missing encodeddata parameter.`);let i=n.format?.toLowerCase();if((i===`bsq`||i===`bip`)&&(n.width==null||n.height==null))throw new e(`rasterCodec:decode`,`requires width and height in options parameter.`);if(i===`tiff`&&n.customOptions)return x(t,n);if(!i||i!==`bsq`&&i!==`bip`&&i!==`deflate`&&i!==`lzw`){if(i=M(t),!i)throw String.fromCharCode.apply(null,[...new Uint8Array(t,0,10)]).toLowerCase().includes(`error`)?new e(`rasterCodec:decode`,`input data contains error`):new e(`rasterCodec:decode`,`unsupported raster format`);n={...n,format:i}}let a=k(i);n.isPoint&&(n={...n},n.width!=null&&n.width++,n.height!=null&&n.height++);let o,{offsets:s}=n;if(s&&s.length>1){let e=s.map((e,i)=>a(t.slice(e,s[i+1]),n,r)),i=await Promise.all(e);o=i[0],o.pixels=i.map(e=>e.pixels[0]);let c=i.map(e=>e.mask);c.some(e=>e!=null)&&(c.forEach((e,t)=>{c[t]??=new Uint8Array(o.width*o.height).fill(255)}),o.bandMasks=c,o.mask=g.combineBandMasks(c))}else o=await a(t,{...n,offset:s?.[0]??n.offset},r);return i!==`jpg`&&n.noDataValue!=null&&o.depthCount===1&&c(o,n.noDataValue,{customFloatTolerance:n.tolerance}),n.isPoint&&j(o),!o.statistics?.length&&!n.skipStatistics&&o.updateStatistics(),o}export{N as decode,M as getFormat};
2
+ import e from"../../../core/Error.js";import{assertIsSome as t}from"../../../core/maybe.js";import{throwIfAborted as n,isAbortError as r}from"../../../core/promiseUtils.js";import{decode as i}from"./ImageCanvasDecoder.js";import{decode as a}from"./JpgPlus.js";import{load as o,decode as s}from"./Lerc.js";import{decode as c}from"./Lzw.js";import{convertNoDataToMask as l}from"./pixelRangeUtils.js";import{load as u,decode as d}from"./Qb3.js";import{decode as f}from"./Raw.js";import{decodeTileOrStrip as p,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as h}from"./utils.js";import{inflate as g}from"./Zlib.js";import _ from"../../support/PixelBlock.js";import v from"../../support/SimpleBandStatistics.js";async function y(t,n){if(!h)throw new e(`rasterCoded:decode`,`lerc decoder is not supported on big endian platform`);await o();let{width:r,height:i,pixelType:a,statistics:c,depthCount:l,noDataValues:u,bandMasks:d,pixels:f,mask:p,validPixelCount:m}=s(t,{inputOffset:n.offset,returnInterleaved:n.returnInterleaved});return new _({width:r,height:i,pixelType:a.toLowerCase(),pixels:f,mask:p,validPixelCount:m,statistics:c.map(({minValue:e,maxValue:t})=>new v(e,t)),bandMasks:d,depthCount:l,noDataValues:u})}async function b(t,n){await u();let r=d(t);if(!r)throw new e(`rasterCodec:decode`,`failed to decode the input data.`);let{width:i,height:a,pixels:o,pixelType:s}=r;return new _({width:i,height:a,pixelType:s,pixels:o})}async function x(e,n,r){let i=await m(e,{...n,noDataValue:n.tiffNoDataValue,matchAllNoData:n.matchAllNoData},r);return t(i),new _({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,bandMasks:i.bandMasks})}async function S(e,t,n){let r=await p(e,t.customOptions,n),i=new _({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask});return t.skipStatistics||i.updateStatistics(),i}function C(e,t){let n=t.pixelType||`u8`,r=_.getPixelArrayConstructor(n),i=n===`u8`?e:new r(e.buffer),a=[],o=t.planes||1;if(o===1)a.push(i);else for(let n=0;n<o;n++){let s=(t.width||1)*(t.height||e.length),c=new r(s);for(let e=0;e<s;e++)c[e]=i[e*o+n];a.push(c)}return new _({width:t.width||1,height:t.height||e.length,pixels:a,pixelType:n})}async function w(e,t,n){return C(await g(new Uint8Array(e),void 0,n),t)}function T(e,t){return C(c(e,t.offset,t.eof,!t.isInputBigEndian),t)}function E(e,t){let n=t.format,{pixelTypeCtor:r}=j(t.pixelType),i=f(e,{width:t.width,height:t.height,pixelType:r,format:n});return new _({width:t.width,height:t.height,pixels:i.pixels,pixelType:t.pixelType,mask:i.mask})}async function D(e,t){let n=await a(e,t);return new _({width:n.width,height:n.height,pixels:n.pixels,pixelType:`u8`,mask:n.mask})}async function O(e,t,n){let r=await i(e,t,n);return new _(r)}async function k(t,n,i){let a=n.format||N(t),o={...n,format:a},{canvasUsage:s}=n;if(s!==`no-canvas`||a===`png`)try{return await O(t,o,i)}catch(t){if(r(t))throw t;if(s===`canvas-only`)throw new e(`rasterCodec:decode`,`failed to decode the input data with canvas for format ${a}`)}return await D(t,o)}function A(t){let n=null;switch(t){case`lerc`:n=y;break;case`jpg`:case`png`:n=k;break;case`bmp`:case`gif`:n=O;break;case`bsq`:case`bip`:n=E;break;case`tiff`:n=x;break;case`deflate`:n=w;break;case`lzw`:n=T;break;case`qb3`:n=b;break;default:n=()=>{throw new e(`rasterCodec:decode`,`unsupported raster format ${t}`)}}return n}function j(e){let t=e?e.toLowerCase():`f32`,n=null,r=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:r=255,n=Uint8Array;break;case`u16`:r||=2**16-1,n=Uint16Array;break;case`u32`:r||=2**32-1,n=Uint32Array;break;case`s8`:r||=-128,n=Int8Array;break;case`s16`:r||=0-2**15,n=Int16Array;break;case`s32`:r||=0-2**31,n=Int32Array;break;default:n=Float32Array}return{pixelTypeCtor:n,noDataValue:r}}function M(e,t=`bilinear`){if(!e)return;let{pixels:n,width:r,height:i,mask:a}=e;if(!n||n.length===0)return;let o=r-1,s=i-1,c=[],l=null,u=_.getPixelArrayConstructor(e.pixelType);if(t===`nearest`){for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let r=0;r<o;r++)t[n*o+r]=e[i+r]}c.push(t)}if(a!=null){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=a[t+n]}}}else{for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let a=0;a<o;a++)t[n*o+a]=(e[i+a]+e[i+a+1]+e[i+r+a]+e[i+r+a+1])/4}c.push(t)}if(a){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=Math.min.apply(null,[a[t+n],a[t+n+1],a[t+r+n],a[t+r+n+1]])}}}e.width=o,e.height=s,e.mask=l,e.pixels=c}function N(e){if(!e)return;let t=new Uint8Array(e,0,10),n;return t[0]===255&&t[1]===216?n=`jpg`:t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?n=`png`:t[0]===67&&t[1]===110&&t[2]===116&&t[3]===90&&t[4]===73&&t[5]===109&&t[6]===97&&t[7]===103&&t[8]===101&&t[9]===32||t[0]===76&&t[1]===101&&t[2]===114&&t[3]===99&&t[4]===50&&t[5]===32?n=`lerc`:t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42||t[0]===73&&t[1]===73&&t[2]===43&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===43?n=`tiff`:t[0]===71&&t[1]===73&&t[2]===70?n=`gif`:t[0]===66&&t[1]===77?n=`bmp`:t[0]===81&&t[1]===66&&t[2]===51&&(n=`qb3`),n}async function P(t,r={},i){if(t==null)throw new e(`rasterCodec:decode`,`missing encodeddata parameter.`);let a=r.format?.toLowerCase();if((a===`bsq`||a===`bip`)&&(r.width==null||r.height==null))throw new e(`rasterCodec:decode`,`requires width and height in options parameter.`);if(a===`tiff`&&r.customOptions)return S(t,r,i);if(!a||a!==`bsq`&&a!==`bip`&&a!==`deflate`&&a!==`lzw`){if(a=N(t),!a)throw String.fromCharCode.apply(null,[...new Uint8Array(t,0,10)]).toLowerCase().includes(`error`)?new e(`rasterCodec:decode`,`input data contains error`):new e(`rasterCodec:decode`,`unsupported raster format`);r={...r,format:a}}let o=A(a);r.isPoint&&(r={...r},r.width!=null&&r.width++,r.height!=null&&r.height++);let s,{offsets:c}=r;if(c&&c.length>1){let e=c.map((e,n)=>o(t.slice(e,c[n+1]),r,i)),n=await Promise.all(e);s=n[0],s.pixels=n.map(e=>e.pixels[0]);let a=n.map(e=>e.mask);a.some(e=>e!=null)&&(a.forEach((e,t)=>{a[t]??=new Uint8Array(s.width*s.height).fill(255)}),s.bandMasks=a,s.mask=_.combineBandMasks(a))}else s=await o(t,{...r,offset:c?.[0]??r.offset},i);return n(i),a!==`jpg`&&r.noDataValue!=null&&s.depthCount===1&&l(s,r.noDataValue,{customFloatTolerance:r.tolerance}),r.isPoint&&M(s),!s.statistics?.length&&!r.skipStatistics&&s.updateStatistics(),s}export{P as decode,N as getFormat};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../core/Error.js";import"../../../core/has.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as r}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as a}from"./pixelRangeUtils.js";import{isBSQConfig as o,getTagFirstNumericValue as s,getCompressionType as c,parseHeader as l,checkRequiredArraySize as u,getTagNumericValues as d,getImageInfo as f}from"./tiffParser.js";import{isPlatformLittleEndian as p}from"./utils.js";import{inflate as m}from"./Zlib.js";function h(e,t){let n=`unknown`;return e===3?n=t===64?`f64`:`f32`:e===1?t===1?n=`u1`:t===2?n=`u2`:t===4?n=`u4`:t<=8?n=`u8`:t<=16?n=`u16`:t<=32&&(n=`u32`):e===2&&(t<=8?n=`s8`:t<=16?n=`s16`:t<=32&&(n=`s32`)),n}function g(e){let t=e?e.toLowerCase():`f32`,n=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:n=Uint8Array;break;case`u16`:n=Uint16Array;break;case`u32`:n=Uint32Array;break;case`s8`:n=Int8Array;break;case`s16`:n=Int16Array;break;case`s32`:n=Int32Array;break;case`f64`:n=Float64Array;break;default:n=Float32Array}return n}async function _(e,t){return await n(),r(e,{inputOffset:t}).pixels[0]}function v(e,t){if(t%8==0)return e;let n=t>16?32:t>8?16:8;n>8&&(e=b(e,n===32?4:2));let r=n===32?Uint32Array:n===16?Uint16Array:Uint8Array,i=new r(e),a=Math.floor(e.byteLength*8/t+1e-6),o=new r(a),s=(1<<t)-1,c=0,l=0,u=0;for(let e=0;e<a;e++)if(l===0&&(u=i[c++],l=n),l>=t)o[e]=u>>>l-t&s,l-=t;else{let r=t-l,a=(u&s)<<r&s;u=i[c++],l=n-r,a+=u>>>l,o[e]=a}return o.buffer}function y(e,n,r){let i=new t;i.parse(e),i.colorTransform=r===6?-1:0;let a=i.getData(i.width,i.height,n!==1&&n!==4);return new Uint8Array(a.buffer)}function b(e,t){let n=new Uint8Array(e),r=new Uint8Array(n.length);if(t===2)for(let e=0;e<n.length;e+=2)r[e]=n[e+1],r[e+1]=n[e];else if(t===4)for(let e=0;e<n.length;e+=4)r[e]=n[e+3],r[e+1]=n[e+2],r[e+2]=n[e+1],r[e+3]=n[e];else for(let e=0;e<n.length;e+=8)r[e]=n[e+7],r[e+1]=n[e+6],r[e+2]=n[e+5],r[e+3]=n[e+4],r[e+4]=n[e+3],r[e+5]=n[e+2],r[e+6]=n[e+1],r[e+7]=n[e];return r.buffer}async function x(t,n,r,a,l){let u=p===n,d=s(r,`BITSPERSAMPLE`),f=s(r,`SAMPLESPERPIXEL`)??1,x=s(r,`PHOTOMETRICINTERPRETATION`),S=s(r,`SAMPLEFORMAT`)??1,C=h(S,d),w=c(r);if(w===34887)return await _(t,a);let E=g(C),D,O;switch(w){case 1:D=t.slice(a,a+l),O=new Uint8Array(D);break;case 8:case 32946:O=await m(new Uint8Array(t,a,l)),D=O.buffer;break;case 6:O=y(new Uint8Array(t,a,l),f,x),D=O.buffer;break;case 7:{let e=r.get(`JPEGTABLES`).values,n=e.length-2,i=new Uint8Array(n+l-2);for(let t=0;t<n;t++)i[t]=e[t];let o=new Uint8Array(t,a+2,l-2);for(let e=0;e<o.length;e++)i[n+e]=o[e];O=y(i,f,x),D=O.buffer}break;case 5:O=i(t,a,l,n),D=O.buffer;break;default:throw new e(`tiff-reader:decode-data`,`unsupported compression `+w)}D=v(D,d);let k;if(u||d<=8)k=new E(D);else{let e=d>32?8:d>16?4:2;k=new E(b(O.buffer,e))}let A=s(r,`PREDICTOR`)??1,j=s(r,`TILEWIDTH`),M=s(r,`TILELENGTH`);if(A>1&&(w===5||w===8||w===32946)&&j&&M){let e=o(r),t=new E(k.length);t.set(k),k=T(t,M,j,S===3&&A===3,e?1:f)}return k}async function S(e,t,n){let r=d(n,`TILEOFFSETS`),i=d(n,`TILEBYTECOUNTS`);if(r==null||i==null)return null;let{width:a,height:l,pixelType:u,tileWidth:p,tileHeight:m}=f([n]),h=o(n,t),_=s(n,`SAMPLESPERPIXEL`)||t.planes,v=a*l,y=s(n,`BITSPERSAMPLE`),b=c(n)===34887,S=g(u),C=[];for(let e=0;e<_;e++)C.push(new S(v));let w=Math.ceil(a/p),T=new Uint8Array(v).fill(255),E=null,D=!1;if(y%8==0){if(b&&h&&_>1){let o=Math.round(r.length/_);for(let s=0;s<o;s++){let o=Math.floor(s/w)*m,c=s%w*p,u=o*a+c;for(let d=0;d<_;d++){let f=s*_+d;i[f]===0?(E=null,D=!0):E=await x(e,t.littleEndian,n,r[f],i[f]);let h=Math.min(p,a-c),g=Math.min(m,l-o),v=C[d];for(let e=0;e<g;e++){let t=u+e*a,n=e*p;for(let e=0;e<h;e++,t++,n++)E?v[t]=E[n]:T[t]=0}}}}else for(let o=0;o<r.length;o++){let s=Math.floor(o/w)*m,c=o%w*p,u=s*a+c;i[o]===0?(E=null,D=!0):E=await x(e,t.littleEndian,n,r[o],i[o]);let d=Math.min(p,a-c),f=Math.min(m,l-s);for(let e=0;e<_;e++){let t=C[e];if(h||b)for(let n=0;n<f;n++){let r=u+n*a,i=p*m*e+n*p;for(let e=0;e<d;e++,r++,i++)E?t[r]=E[i]:T[r]=0}else for(let n=0;n<f;n++){let r=u+n*a,i=n*p*_+e;for(let e=0;e<d;e++,r++,i+=_)E?t[r]=E[i]:T[r]=0}}}}return{width:a,height:l,pixelType:u,pixels:C,mask:D?T:void 0}}async function C(e,t,n){let r=p===t.littleEndian,a=d(n,`STRIPOFFSETS`),o=d(n,`STRIPBYTECOUNTS`);if(a==null||o==null)return null;let{width:l,height:u,pixelType:h}=f([n]),_=s(n,`SAMPLESPERPIXEL`)||t.planes,b=s(n,`PHOTOMETRICINTERPRETATION`),x=l*u,S=s(n,`BITSPERSAMPLE`),C=g(h),w=new C(x*_),T=s(n,`ROWSPERSTRIP`),E=c(n),D,O,k,A;if(S%8==0)for(let n=0;n<a.length;n++){let s=T*l*n*_;if(h===`u8`||h===`s8`||r)E===8||E===32946?(k=new Uint8Array(e,a[n],o[n]),k=await m(k),O=k.buffer):E===6?(k=new Uint8Array(e,a[n],o[n]),k=y(k,_,b),O=k.buffer):E===5?(k=i(e,a[n],o[n],t.littleEndian),O=k.buffer):O=e.slice(a[n],a[n]+o[n]),O=v(O,S),D=new C(O);else{switch(E===6||E===8||E===32946?(k=new Uint8Array(e,a[n],o[n]),A=await m(k),O=A.buffer):(O=new ArrayBuffer(o[n]),k=new Uint8Array(e,a[n],o[n]),A=new Uint8Array(O)),h){case`u16`:case`s16`:for(let e=0;e<k.length;e+=2)A[e]=k[e+1],A[e+1]=k[e];break;case`u32`:case`s32`:case`f32`:for(let e=0;e<k.length;e+=4)A[e]=k[e+3],A[e+1]=k[e+2],A[e+2]=k[e+1],A[e+3]=k[e]}O=v(O,S),D=new C(O)}w.set(D,s)}let j=[];if(_===1)j.push(w);else for(let e=0;e<_;e++){let t=new C(x);for(let n=0;n<x;n++)t[n]=w[n*_+e];j.push(t)}return{width:l,height:u,pixelType:h,pixels:j}}function w(e,t,n){if(!(e&&e.length>0&&t&&n))return null;let r,i,a,o=e[0].length,s=e.length,c=new Uint8Array(o);for(let l=0;l<s;l++)if(r=e[l],i=t[l],a=n[l],l===0)for(let e=0;e<o;e++)c[e]=r[e]<i||r[e]>a?0:1;else for(let e=0;e<o;e++)c[e]&&(c[e]=r[e]<i||r[e]>a?0:1);return c}function T(e,t,n,r,i){let a=r?4:1,o=n*a*i;r&&(e=new Uint8Array(e.buffer));for(let n=0;n<t;n++){let t=n*o;for(let n=i;n<o;n++)e[t+n]+=e[t+n-i]}if(!r)return e;let s=new Uint8Array(e.length),c=n*i;for(let n=0;n<t;n++){let t=n*o;for(let n=0;n<c;n++)for(let r=0;r<a;r++)s[t+n*a+r]=e[t+n+(a-r-1)*c]}return new Float32Array(s.buffer)}async function E(e,t){let{headerInfo:n,ifd:r,offsets:i,sizes:l}=t,u=[];for(let t=0;t<i.length;t++){+(l[t]===0);let a=await x(e,n.littleEndian,r,i[t],l[t]||e.byteLength);u.push(a)}let d=o(r,n),f=s(r,`BITSPERSAMPLE`),p=h(s(r,`SAMPLEFORMAT`)??1,f),m=s(r,`SAMPLESPERPIXEL`)||n.planes,_=g(p),v=s(r,`TILEWIDTH`),y=s(r,`TILELENGTH`),b=c(r)===34887,S=v*y,C,T=[],E=u[0];for(let e=0;e<m;e++){if(C=new _(S),u.length===m)E=u[e],E.length===S&&(C=E);else if(E.length){if(d||b)C=E.length===S?E:E.slice(S*e,S*(e+1));else for(let t=0;t<S;t++)C[t]=E[t*m+e]}T.push(C)}let D=n.noData?n.noData[0]:t.noDataValue,O=n.metadata?n.metadata.statistics:null,k=O?O.map(e=>e.min):null,A=O?O.map(e=>e.max):null,j={pixelType:p,width:v,height:y,pixels:T,noDataValue:D};return D==null?k&&A&&t.applyMinMaxConstraint&&(j.mask=w(T,k,A)):a(j,D,{matchAllNoData:t?.matchAllNoData}),j}async function D(t,n={}){let r=n.pyramidLevel||0,i=n.headerInfo||l(t),{ifds:o,noData:s}=i;if(o.length===0)throw new e(`tiff-reader:decode`,`no valid image file directory`);let c=u(i);if(c)throw new e(`tiff-reader:decode`,c);let d=r===-1?o[o.length-1]:o[r],f=s??n.noDataValue,p=i.tileWidth?await S(t,i,d):await C(t,i,d);if(!p)return p;if(f!=null){let e=s==null&&n?.matchAllNoData;a(p,f,{matchAllNoData:e})}return p}export{D as decode,E as decodeTileOrStrip};
2
+ import e from"../../../core/Error.js";import"../../../core/has.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as r}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as a}from"./pixelRangeUtils.js";import{isBSQConfig as o,getTagFirstNumericValue as s,getCompressionType as c,parseHeader as l,checkRequiredArraySize as u,getTagNumericValues as d,getImageInfo as f}from"./tiffParser.js";import{isPlatformLittleEndian as p}from"./utils.js";import{inflate as m}from"./Zlib.js";function h(e,t){let n=`unknown`;return e===3?n=t===64?`f64`:`f32`:e===1?t===1?n=`u1`:t===2?n=`u2`:t===4?n=`u4`:t<=8?n=`u8`:t<=16?n=`u16`:t<=32&&(n=`u32`):e===2&&(t<=8?n=`s8`:t<=16?n=`s16`:t<=32&&(n=`s32`)),n}function g(e){let t=e?e.toLowerCase():`f32`,n=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:n=Uint8Array;break;case`u16`:n=Uint16Array;break;case`u32`:n=Uint32Array;break;case`s8`:n=Int8Array;break;case`s16`:n=Int16Array;break;case`s32`:n=Int32Array;break;case`f64`:n=Float64Array;break;default:n=Float32Array}return n}async function _(e,t){return await n(),r(e,{inputOffset:t}).pixels[0]}function v(e,t){if(t%8==0)return e;let n=t>16?32:t>8?16:8;n>8&&(e=b(e,n===32?4:2));let r=n===32?Uint32Array:n===16?Uint16Array:Uint8Array,i=new r(e),a=Math.floor(e.byteLength*8/t+1e-6),o=new r(a),s=(1<<t)-1,c=0,l=0,u=0;for(let e=0;e<a;e++)if(l===0&&(u=i[c++],l=n),l>=t)o[e]=u>>>l-t&s,l-=t;else{let r=t-l,a=(u&s)<<r&s;u=i[c++],l=n-r,a+=u>>>l,o[e]=a}return o.buffer}function y(e,n,r){let i=new t;i.parse(e),i.colorTransform=r===6?-1:0;let a=i.getData(i.width,i.height,n!==1&&n!==4);return new Uint8Array(a.buffer)}function b(e,t){let n=new Uint8Array(e),r=new Uint8Array(n.length);if(t===2)for(let e=0;e<n.length;e+=2)r[e]=n[e+1],r[e+1]=n[e];else if(t===4)for(let e=0;e<n.length;e+=4)r[e]=n[e+3],r[e+1]=n[e+2],r[e+2]=n[e+1],r[e+3]=n[e];else for(let e=0;e<n.length;e+=8)r[e]=n[e+7],r[e+1]=n[e+6],r[e+2]=n[e+5],r[e+3]=n[e+4],r[e+4]=n[e+3],r[e+5]=n[e+2],r[e+6]=n[e+1],r[e+7]=n[e];return r.buffer}async function x(t,n){let{input:r,isTiffLittleEndian:a,ifd:l,offset:u,size:d}=t,f=p===a,x=s(l,`BITSPERSAMPLE`),S=s(l,`SAMPLESPERPIXEL`)??1,C=s(l,`PHOTOMETRICINTERPRETATION`),w=s(l,`SAMPLEFORMAT`)??1,E=h(w,x),D=c(l);if(D===34887)return await _(r,u);let O=g(E),k,A;switch(D){case 1:k=r.slice(u,u+d),A=new Uint8Array(k);break;case 8:case 32946:A=await m(new Uint8Array(r,u,d),void 0,n),k=A.buffer;break;case 6:A=y(new Uint8Array(r,u,d),S,C),k=A.buffer;break;case 7:{let e=l.get(`JPEGTABLES`).values,t=e.length-2,n=new Uint8Array(t+d-2);for(let r=0;r<t;r++)n[r]=e[r];let i=new Uint8Array(r,u+2,d-2);for(let e=0;e<i.length;e++)n[t+e]=i[e];A=y(n,S,C),k=A.buffer}break;case 5:A=i(r,u,d,a),k=A.buffer;break;default:throw new e(`tiff-reader:decode-data`,`unsupported compression `+D)}k=v(k,x);let j;if(f||x<=8)j=new O(k);else{let e=x>32?8:x>16?4:2;j=new O(b(A.buffer,e))}let M=s(l,`PREDICTOR`)??1,N=s(l,`TILEWIDTH`),P=s(l,`TILELENGTH`);if(M>1&&(D===5||D===8||D===32946)&&N&&P){let e=o(l),t=new O(j.length);t.set(j),j=T(t,P,N,w===3&&M===3,e?1:S)}return j}async function S(e,t,n,r){let i=d(n,`TILEOFFSETS`),a=d(n,`TILEBYTECOUNTS`);if(i==null||a==null)return null;let{width:l,height:u,pixelType:p,tileWidth:m,tileHeight:h}=f([n]),_=o(n,t),v=s(n,`SAMPLESPERPIXEL`)||t.planes,y=l*u,b=s(n,`BITSPERSAMPLE`),S=c(n)===34887,C=g(p),w=[];for(let e=0;e<v;e++)w.push(new C(y));let T=Math.ceil(l/m),E=new Uint8Array(y).fill(255),D=null,O=!1;if(b%8==0){if(S&&_&&v>1){let o=Math.round(i.length/v);for(let s=0;s<o;s++){let o=Math.floor(s/T)*h,c=s%T*m,d=o*l+c;for(let f=0;f<v;f++){let p=s*v+f;a[p]===0?(D=null,O=!0):D=await x({input:e,isTiffLittleEndian:t.littleEndian,ifd:n,offset:i[p],size:a[p]},r);let g=Math.min(m,l-c),_=Math.min(h,u-o),y=w[f];for(let e=0;e<_;e++){let t=d+e*l,n=e*m;for(let e=0;e<g;e++,t++,n++)D?y[t]=D[n]:E[t]=0}}}}else for(let o=0;o<i.length;o++){let s=Math.floor(o/T)*h,c=o%T*m,d=s*l+c;a[o]===0?(D=null,O=!0):D=await x({input:e,isTiffLittleEndian:t.littleEndian,ifd:n,offset:i[o],size:a[o]},r);let f=Math.min(m,l-c),p=Math.min(h,u-s);for(let e=0;e<v;e++){let t=w[e];if(_||S)for(let n=0;n<p;n++){let r=d+n*l,i=m*h*e+n*m;for(let e=0;e<f;e++,r++,i++)D?t[r]=D[i]:E[r]=0}else for(let n=0;n<p;n++){let r=d+n*l,i=n*m*v+e;for(let e=0;e<f;e++,r++,i+=v)D?t[r]=D[i]:E[r]=0}}}}return{width:l,height:u,pixelType:p,pixels:w,mask:O?E:void 0}}async function C(e,t,n,r){let a=p===t.littleEndian,o=d(n,`STRIPOFFSETS`),l=d(n,`STRIPBYTECOUNTS`);if(o==null||l==null)return null;let{width:u,height:h,pixelType:_}=f([n]),b=s(n,`SAMPLESPERPIXEL`)||t.planes,x=s(n,`PHOTOMETRICINTERPRETATION`),S=u*h,C=s(n,`BITSPERSAMPLE`),w=g(_),T=new w(S*b),E=s(n,`ROWSPERSTRIP`),D=c(n),O,k,A,j;if(C%8==0)for(let n=0;n<o.length;n++){let s=E*u*n*b;if(_===`u8`||_===`s8`||a)D===8||D===32946?(A=new Uint8Array(e,o[n],l[n]),A=await m(A,void 0,r),k=A.buffer):D===6?(A=new Uint8Array(e,o[n],l[n]),A=y(A,b,x),k=A.buffer):D===5?(A=i(e,o[n],l[n],t.littleEndian),k=A.buffer):k=e.slice(o[n],o[n]+l[n]),k=v(k,C),O=new w(k);else{switch(D===6||D===8||D===32946?(A=new Uint8Array(e,o[n],l[n]),j=await m(A,void 0,r),k=j.buffer):(k=new ArrayBuffer(l[n]),A=new Uint8Array(e,o[n],l[n]),j=new Uint8Array(k)),_){case`u16`:case`s16`:for(let e=0;e<A.length;e+=2)j[e]=A[e+1],j[e+1]=A[e];break;case`u32`:case`s32`:case`f32`:for(let e=0;e<A.length;e+=4)j[e]=A[e+3],j[e+1]=A[e+2],j[e+2]=A[e+1],j[e+3]=A[e]}k=v(k,C),O=new w(k)}T.set(O,s)}let M=[];if(b===1)M.push(T);else for(let e=0;e<b;e++){let t=new w(S);for(let n=0;n<S;n++)t[n]=T[n*b+e];M.push(t)}return{width:u,height:h,pixelType:_,pixels:M}}function w(e,t,n){if(!(e&&e.length>0&&t&&n))return null;let r,i,a,o=e[0].length,s=e.length,c=new Uint8Array(o);for(let l=0;l<s;l++)if(r=e[l],i=t[l],a=n[l],l===0)for(let e=0;e<o;e++)c[e]=r[e]<i||r[e]>a?0:1;else for(let e=0;e<o;e++)c[e]&&(c[e]=r[e]<i||r[e]>a?0:1);return c}function T(e,t,n,r,i){let a=r?4:1,o=n*a*i;r&&(e=new Uint8Array(e.buffer));for(let n=0;n<t;n++){let t=n*o;for(let n=i;n<o;n++)e[t+n]+=e[t+n-i]}if(!r)return e;let s=new Uint8Array(e.length),c=n*i;for(let n=0;n<t;n++){let t=n*o;for(let n=0;n<c;n++)for(let r=0;r<a;r++)s[t+n*a+r]=e[t+n+(a-r-1)*c]}return new Float32Array(s.buffer)}async function E(e,t,n){let{headerInfo:r,ifd:i,offsets:l,sizes:u}=t,d=[];for(let t=0;t<l.length;t++){+(u[t]===0);let a=await x({input:e,isTiffLittleEndian:r.littleEndian,ifd:i,offset:l[t],size:u[t]||e.byteLength},n);d.push(a)}let f=o(i,r),p=s(i,`BITSPERSAMPLE`),m=h(s(i,`SAMPLEFORMAT`)??1,p),_=s(i,`SAMPLESPERPIXEL`)||r.planes,v=g(m),y=s(i,`TILEWIDTH`),b=s(i,`TILELENGTH`),S=c(i)===34887,C=y*b,T,E=[],D=d[0];for(let e=0;e<_;e++){if(T=new v(C),d.length===_)D=d[e],D.length===C&&(T=D);else if(D.length){if(f||S)T=D.length===C?D:D.slice(C*e,C*(e+1));else for(let t=0;t<C;t++)T[t]=D[t*_+e]}E.push(T)}let O=r.noData?r.noData[0]:t.noDataValue,k=r.metadata?r.metadata.statistics:null,A=k?k.map(e=>e.min):null,j=k?k.map(e=>e.max):null,M={pixelType:m,width:y,height:b,pixels:E,noDataValue:O};return O==null?A&&j&&t.applyMinMaxConstraint&&(M.mask=w(E,A,j)):a(M,O,{matchAllNoData:t?.matchAllNoData}),M}async function D(t,n={},r){let i=n.pyramidLevel||0,o=n.headerInfo||l(t),{ifds:s,noData:c}=o;if(s.length===0)throw new e(`tiff-reader:decode`,`no valid image file directory`);let d=u(o);if(d)throw new e(`tiff-reader:decode`,d);let f=i===-1?s[s.length-1]:s[i],p=c??n.noDataValue,m=o.tileWidth?await S(t,o,f,r):await C(t,o,f,r);if(!m)return m;if(p!=null){let e=c==null&&n?.matchAllNoData;a(m,p,{matchAllNoData:e})}return m}export{D as decode,E as decodeTileOrStrip};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- function e(e){if(e.length<2)return!1;let[t,n]=e.subarray(0,2),r=t&15,i=t>>4;return r!==8||i>7?!1:((t<<8|n)&65535)%31==0}function t(e){return e.length>=2&&e[0]===31&&e[1]===139}function n(n){return t(n)?`gzip`:e(n)?`deflate`:null}async function r(e,t){t??=n(e)??`deflate-raw`;let r=new Response(e).body.pipeThrough(new DecompressionStream(t)),i=await new Response(r).arrayBuffer();return new Uint8Array(i)}export{r as inflate};
2
+ function e(e){if(e.length<2)return!1;let[t,n]=e.subarray(0,2),r=t&15,i=t>>4;return r!==8||i>7?!1:((t<<8|n)&65535)%31==0}function t(e){return e.length>=2&&e[0]===31&&e[1]===139}function n(n){return t(n)?`gzip`:e(n)?`deflate`:null}async function r(e,t,r){t??=n(e)??`deflate-raw`;let i=new Response(e).body,a={signal:r?.signal??void 0},o=i.pipeThrough(new DecompressionStream(t),a),s=await new Response(o).arrayBuffer();return new Uint8Array(s)}export{r as inflate};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../geometry/Extent.js";import t from"../../geometry/Point.js";import n from"../../geometry/operators/support/GeographicTransformation.js";import{decode as r}from"../raster/formats/RasterCodec.js";import{transformPixels as i}from"../raster/functions/pixelTransformUtils.js";import{convertPixelBlockToFeatures as a,compositeBands as o,highlightPixels as s,split as c,clipTile as l,mosaicPixelData as u,mosaic as d,approximateTransform as f,getLocalArithmeticNorthRotations as p}from"../raster/functions/pixelUtils.js";import{create as m}from"../raster/functions/rasterFunctionHelper.js";import{load as h,getProjectionOffsetGrid as g}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as _,estimateStatisticsHistograms as v}from"../raster/functions/stretchUtils.js";import{convertVectorFieldData as y,sampleVectorField as b,convertToLocalDirections as x}from"../raster/functions/vectorFieldUtils.js";import{readTransform as S}from"../raster/transforms/utils.js";import C from"./PixelBlock.js";import w from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as T}from"../../views/2d/engine/flow/dataUtils.js";function E(e){if(!e)return{result:null,transferList:[]};let{pixelBlock:t,transferList:n}=e.getTransferableObject();return{result:t,transferList:n}}class D{convertVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(y(t,e.type));return Promise.resolve(n)}convertPixelBlockToFeatures(t){let n=a({pixelBlock:C.fromJSON(t.pixelBlock),extent:e.fromJSON(t.extent),fieldNames:t.fieldNames,skipFactor:t.skipFactor,skipSpatialReference:!0,pixelIdOffset:t.pixelIdOffset,imageRowSize:t.imageRowSize});return Promise.resolve(n)}sampleVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(b(t,e.srcDataType,e.tileSize,e.offset,e.maximumVoidPercentage));return Promise.resolve(n)}transformPixels(e){let t=C.fromJSON(e.pixelBlock),n=i(t,e.transformType,e.transformParameters);return Promise.resolve(E(n))}computeStatisticsHistograms(e){let t=C.fromJSON(e.pixelBlock),n=_(t,{histogramSize:e.histogramSize,includeSkewnessKurtosis:e.includeSkewnessKurtosis});return Promise.resolve(n)}compositeBands(e){let t=e.pixelBlocks.map(e=>e&&C.fromJSON(e)),n=E(o(t));return Promise.resolve(n)}async decode(e){return E(await r(e.data,e.options))}symbolize(t){let n=t.pixelBlock?C.fromJSON(t.pixelBlock):null,r=t.extent?e.fromJSON(t.extent):null,i=E(this.symbolizer.symbolize({...t,pixelBlock:n,extent:r}));return Promise.resolve(i)}highlightPixels(e){let t=C.fromJSON(e.pixelBlock),n=C.fromJSON(e.renderedPixelBlock);return s({pixelBlock:t,renderedPixelBlock:n,highlightOptions:e.highlightOptions}),Promise.resolve(n.toJSON())}async updateSymbolizer(e){this.symbolizer=w.fromJSON(e.symbolizerJSON),e.histograms&&this.symbolizer?.rendererJSON.type===`rasterStretch`&&(this.symbolizer.rendererJSON.histograms=e.histograms)}async updateRasterFunction(e){this.rasterFunction=m(e.rasterFunctionJSON)}async process(n){return E(this.rasterFunction.process({extent:e.fromJSON(n.extent),primaryPixelBlocks:n.primaryPixelBlocks.map(e=>e==null?null:C.fromJSON(e)),primaryPixelSizes:n.primaryPixelSizes?.map(e=>e==null?null:t.fromJSON(e)),primaryRasterIds:n.primaryRasterIds},n.parameters))}stretch(e){let t=E(this.symbolizer.simpleStretch(C.fromJSON(e.srcPixelBlock),e.stretchParams));return Promise.resolve(t)}estimateStatisticsHistograms(e){let t=v(C.fromJSON(e.srcPixelBlock));return Promise.resolve(t)}split(e){let t=c(C.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel??0,e.useBilinear===!1),n=[],r;return t&&(r=new Map,t.forEach((e,t)=>{if(e){let{pixelBlock:i,transferList:a}=e.getTransferableObject();r.set(t,i),a.forEach(e=>{n.includes(e)||n.push(e)})}})),Promise.resolve({result:r,transferList:n})}clipTile(e){let t=C.fromJSON(e.pixelBlock),n=E(l({...e,pixelBlock:t}));return Promise.resolve(n)}mosaicPixelData(t){let n=t.pixelData.map(t=>({extent:e.fromJSON(t.extent),pixelBlock:t.pixelBlock?C.fromJSON(t.pixelBlock):null})),r=e.fromJSON(t.destExtent),i=E(u(n,r)?.pixelBlock);return Promise.resolve(i)}async mosaicAndTransform(e){let t=e.srcPixelBlocks.map(e=>e?new C(e):null),n=d(t,e.srcMosaicSize,{blockWidths:e.blockWidths,alignmentInfo:e.alignmentInfo,clipOffset:e.clipOffset,clipSize:e.clipSize}),r=n;e.coefs&&(r=f(n,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation));let i;e.projectDirections&&e.gcsGrid&&(i=p(e.destDimension,e.gcsGrid),r=x(r,e.isUV?`vector-uv`:`vector-magdir`,i));let{result:a,transferList:o}=E(r);return{result:{pixelBlock:a,localNorthDirections:i},transferList:o}}async createFlowMesh(e,t){let n={data:new Float32Array(e.flowData.buffer),mask:new Uint8Array(e.flowData.maskBuffer),width:e.flowData.width,height:e.flowData.height},{vertexData:r,indexData:i,pathData:a}=await T(e.meshType,e.simulationSettings,n,e.startInfo,t.signal);return{result:{vertexBuffer:r.buffer,indexBuffer:i.buffer,pathBuffer:a.buffer},transferList:[r.buffer,i.buffer]}}async getProjectionOffsetGrid(t){let r=e.fromJSON(t.projectedExtent),i=e.fromJSON(t.srcBufferExtent),a=null;t.datumTransformationSteps?.length&&(a=new n({steps:t.datumTransformationSteps})),await h();let o=t.rasterTransform?S(t.rasterTransform):null;return g({...t,projectedExtent:r,srcBufferExtent:i,datumTransformation:a,rasterTransform:o})}}export{D as default};
2
+ import e from"../../geometry/Extent.js";import t from"../../geometry/Point.js";import n from"../../geometry/operators/support/GeographicTransformation.js";import{decode as r}from"../raster/formats/RasterCodec.js";import{transformPixels as i}from"../raster/functions/pixelTransformUtils.js";import{convertPixelBlockToFeatures as a,compositeBands as o,highlightPixels as s,split as c,clipTile as l,mosaicPixelData as u,mosaic as d,approximateTransform as f,getLocalArithmeticNorthRotations as p}from"../raster/functions/pixelUtils.js";import{create as m}from"../raster/functions/rasterFunctionHelper.js";import{load as h,getProjectionOffsetGrid as g}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as _,estimateStatisticsHistograms as v}from"../raster/functions/stretchUtils.js";import{convertVectorFieldData as y,sampleVectorField as b,convertToLocalDirections as x}from"../raster/functions/vectorFieldUtils.js";import{readTransform as S}from"../raster/transforms/utils.js";import C from"./PixelBlock.js";import w from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as T}from"../../views/2d/engine/flow/dataUtils.js";function E(e){if(!e)return{result:null,transferList:[]};let{pixelBlock:t,transferList:n}=e.getTransferableObject();return{result:t,transferList:n}}class D{convertVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(y(t,e.type));return Promise.resolve(n)}convertPixelBlockToFeatures(t){let n=a({pixelBlock:C.fromJSON(t.pixelBlock),extent:e.fromJSON(t.extent),fieldNames:t.fieldNames,skipFactor:t.skipFactor,skipSpatialReference:!0,pixelIdOffset:t.pixelIdOffset,imageRowSize:t.imageRowSize});return Promise.resolve(n)}sampleVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(b(t,e.srcDataType,e.tileSize,e.offset,e.maximumVoidPercentage));return Promise.resolve(n)}transformPixels(e){let t=C.fromJSON(e.pixelBlock),n=i(t,e.transformType,e.transformParameters);return Promise.resolve(E(n))}computeStatisticsHistograms(e){let t=C.fromJSON(e.pixelBlock),n=_(t,{histogramSize:e.histogramSize,includeSkewnessKurtosis:e.includeSkewnessKurtosis});return Promise.resolve(n)}compositeBands(e){let t=e.pixelBlocks.map(e=>e&&C.fromJSON(e)),n=E(o(t));return Promise.resolve(n)}async decode(e,t){return E(await r(e.data,e.options,{signal:t?.signal}))}symbolize(t){let n=t.pixelBlock?C.fromJSON(t.pixelBlock):null,r=t.extent?e.fromJSON(t.extent):null,i=E(this.symbolizer.symbolize({...t,pixelBlock:n,extent:r}));return Promise.resolve(i)}highlightPixels(e){let t=C.fromJSON(e.pixelBlock),n=C.fromJSON(e.renderedPixelBlock);return s({pixelBlock:t,renderedPixelBlock:n,highlightOptions:e.highlightOptions}),Promise.resolve(n.toJSON())}async updateSymbolizer(e){this.symbolizer=w.fromJSON(e.symbolizerJSON),e.histograms&&this.symbolizer?.rendererJSON.type===`rasterStretch`&&(this.symbolizer.rendererJSON.histograms=e.histograms)}async updateRasterFunction(e){this.rasterFunction=m(e.rasterFunctionJSON)}async process(n){return E(this.rasterFunction.process({extent:e.fromJSON(n.extent),primaryPixelBlocks:n.primaryPixelBlocks.map(e=>e==null?null:C.fromJSON(e)),primaryPixelSizes:n.primaryPixelSizes?.map(e=>e==null?null:t.fromJSON(e)),primaryRasterIds:n.primaryRasterIds},n.parameters))}stretch(e){let t=E(this.symbolizer.simpleStretch(C.fromJSON(e.srcPixelBlock),e.stretchParams));return Promise.resolve(t)}estimateStatisticsHistograms(e){let t=v(C.fromJSON(e.srcPixelBlock));return Promise.resolve(t)}split(e){let t=c(C.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel??0,e.useBilinear===!1),n=[],r;return t&&(r=new Map,t.forEach((e,t)=>{if(e){let{pixelBlock:i,transferList:a}=e.getTransferableObject();r.set(t,i),a.forEach(e=>{n.includes(e)||n.push(e)})}})),Promise.resolve({result:r,transferList:n})}clipTile(e){let t=C.fromJSON(e.pixelBlock),n=E(l({...e,pixelBlock:t}));return Promise.resolve(n)}mosaicPixelData(t){let n=t.pixelData.map(t=>({extent:e.fromJSON(t.extent),pixelBlock:t.pixelBlock?C.fromJSON(t.pixelBlock):null})),r=e.fromJSON(t.destExtent),i=E(u(n,r)?.pixelBlock);return Promise.resolve(i)}async mosaicAndTransform(e){let t=e.srcPixelBlocks.map(e=>e?new C(e):null),n=d(t,e.srcMosaicSize,{blockWidths:e.blockWidths,alignmentInfo:e.alignmentInfo,clipOffset:e.clipOffset,clipSize:e.clipSize}),r=n;e.coefs&&(r=f(n,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation));let i;e.projectDirections&&e.gcsGrid&&(i=p(e.destDimension,e.gcsGrid),r=x(r,e.isUV?`vector-uv`:`vector-magdir`,i));let{result:a,transferList:o}=E(r);return{result:{pixelBlock:a,localNorthDirections:i},transferList:o}}async createFlowMesh(e,t){let n={data:new Float32Array(e.flowData.buffer),mask:new Uint8Array(e.flowData.maskBuffer),width:e.flowData.width,height:e.flowData.height},{vertexData:r,indexData:i,pathData:a}=await T(e.meshType,e.simulationSettings,n,e.startInfo,t.signal);return{result:{vertexBuffer:r.buffer,indexBuffer:i.buffer,pathBuffer:a.buffer},transferList:[r.buffer,i.buffer]}}async getProjectionOffsetGrid(t){let r=e.fromJSON(t.projectedExtent),i=e.fromJSON(t.srcBufferExtent),a=null;t.datumTransformationSteps?.length&&(a=new n({steps:t.datumTransformationSteps})),await h();let o=t.rasterTransform?S(t.rasterTransform):null;return g({...t,projectedExtent:r,srcBufferExtent:i,datumTransformation:a,rasterTransform:o})}}export{D as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Error.js";import{getDeepValue as t,setDeepValue as n}from"../../core/object.js";import{union as r}from"../../core/SetUtils.js";import{parseWhereClause as i}from"../../core/sql.js";import{DomainValidationError as a,getDomainRange as o}from"./domainUtils.js";import{getFieldNameFromSimpleExpression as s}from"../../support/arcadeExpressionUtils.js";import{isStringOrNull as ee,isString as te}from"../../support/guards.js";import{loadArcade as ne}from"../../support/loadArcade.js";const re=/^([0-9_])/,ie=/[^a-z0-9_\u0080-\uffff]+/gi;function c(e){return e==null?null:e.trim().replaceAll(ie,`_`).replace(re,`F$1`)||null}const l=[`field`,`field2`,`field3`,`normalizationField`,`rotationInfo.field`,`proportionalSymbolInfo.field`,`proportionalSymbolInfo.normalizationField`,`colorInfo.field`,`colorInfo.normalizationField`],u=[`field`,`normalizationField`];function ae(e,t){if(e!=null&&t!=null){for(let n of Array.isArray(e)?e:[e])if(d(l,n,t),`visualVariables`in n&&n.visualVariables)for(let e of n.visualVariables)d(u,e,t)}}function d(e,r,i){if(e)for(let a of e){let e=t(a,r),o=e&&typeof e!=`function`&&i.get(e);o&&n(a,o.name,r)}}function oe(e,t){if(e!=null&&t?.fields?.length){if(`startField`in e){let n=t.get(e.startField),r=t.get(e.endField);e.startField=n?.name??null,e.endField=r?.name??null}else{let n=t.get(e.startTimeField),r=t.get(e.endTimeField);e.startTimeField=n?.name??null,e.endTimeField=r?.name??null}e.trackIdField=t.get(e.trackIdField)?.name??null}}const f=new Set;function p(e,t){return!e||!t?[]:(f.clear(),m(f,e,t),Array.from(f).sort())}function m(e,t,n){if(n){if(!t?.fields?.length){if(n.includes(`*`)){e.clear(),e.add(`*`);return}for(let t of n)t!=null&&e.add(t);return}if(n.includes(`*`)){for(let{name:n}of t.fields)e.add(n);return}for(let r of n)h(e,t,r)}}function h(e,t,n){if(typeof n==`string`){if(t){let r=t.get(n);r&&e.add(r.name)}else e.add(n)}}function se(e,t){return t==null||e==null?[]:t.includes(`*`)?(e.fields??[]).map(e=>e.name):t}function ce(e,t,n=1){if(!t||!e)return[];if(t.includes(`*`))return[`*`];let r=p(e,t);return r.length/e.fields.length>=n?[`*`]:r}async function g(e,t,n,r){if(!r)return;let i=s(r);if(i)h(e,t,i);else{let{arcadeUtils:i}=await ne(),a=i.extractFieldNames(r,n?.partitions??t?.fields?.map(e=>e.name));for(let r of a)h(e,n?.index??t,r)}}async function _(t,n,r){if(r&&r!==`1=1`){let a=await i(r,n);if(!a.isStandardized)throw new e(`fieldUtils:collectFilterFields`,`Where clause is not standardized`,{where:r});m(t,n,a.fieldNames)}}function le({displayField:e,fields:t}){return e||(t?.length?v(t):null)}function v(e){return y(e,`name-or-title`)||y(e,`unique-identifier`)||y(e,`type-or-category`)||ue(e)}function ue(e){for(let t of e){if(!t?.name)continue;let e=t.name.toLowerCase();if(e.includes(`name`)||e.includes(`title`))return t.name}return null}function y(e,t){for(let n of e)if(n?.valueType&&n.valueType===t)return n.name;return null}async function de(e){if(!e)return[];let t=new Set;return await b(t,e),Array.from(t).sort()}async function b(e,t){if(!t)return;let n=t.elevationInfo?.featureExpressionInfo;if(n)return n.collectRequiredFields(e,t.fieldsIndex)}function fe(e,t,n){n.onStatisticExpression?g(e,t,null,n.onStatisticExpression.expression):e.add(n.onStatisticField)}async function pe(e,t,n){if(!t||!n||!(`fields`in n))return;let r=[],i=n.popupTemplate;r.push(x(e,t,i)),n.fields&&r.push(...n.fields.map(async n=>fe(e,t.fieldsIndex,n))),await Promise.all(r)}async function me(e,t){let{fieldsIndex:n,trackInfo:r}=t;if(!t||!r||!n)return;let i=[r.latestObservations.renderer?.collectRequiredFields(e,n),r.previousObservations.renderer?.collectRequiredFields(e,n),r.trackLines.renderer?.collectRequiredFields(e,n)];r.popupTemplate&&i.push(x(e,t,r.popupTemplate));for(let t of[r.latestObservations.labelingInfo,r.previousObservations.labelingInfo,r.trackLines.labelingInfo])if(t)for(let r of t)i.push(O(e,n,r));await Promise.all(i)}async function x(e,t,n){let r=[];n?.expressionInfos&&r.push(...n.expressionInfos.map(n=>g(e,t.fieldsIndex,null,n.expression)));let i=n?.content;if(Array.isArray(i))for(let n of i)n.type===`expression`&&n.expressionInfo&&r.push(g(e,t.fieldsIndex,null,n.expressionInfo.expression));await Promise.all(r)}async function he(e,t,n){t&&(t.timeInfo&&n?.timeExtent&&m(e,t.fieldsIndex,[t.timeInfo.startField,t.timeInfo.endField]),t.floorInfo&&m(e,t.fieldsIndex,[t.floorInfo.floorField]),n?.where!=null&&await _(e,t.fieldsIndex,n.where))}async function ge(e,t,n){t&&n&&await Promise.all(n.map(n=>_e(e,t,n)))}async function _e(e,t,n){t&&n&&(n.valueExpression?await g(e,t.fieldsIndex,null,n.valueExpression):n.field&&h(e,t.fieldsIndex,n.field))}async function ve(e){if(!e)return[];let t=`timeInfo`in e&&e.timeInfo;return t?p(e.fieldsIndex,[e.trackIdField,t.startField,t.endField]):[]}function ye(e){return e?p(e.fieldsIndex,w(e)):[]}function S(e){if(!e)return[];let t=e.geometryFieldsInfo;return t?p(e.fieldsIndex,[t.shapeAreaField,t.shapeLengthField]):[]}async function be(e,t,n){if(!t||!n)return;let r=t.fieldsIndex;await Promise.all(n.filters.map(t=>_(e,r,t.where)))}const xe=new Set([`oid`,`global-id`,`guid`]),Se=new Set([`oid`,`global-id`]),Ce=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^shape$/i,/^shape_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/objectid/i,/^perimeter_/i,/_perimeter$/i,/_i$/i];function C(e){let t=new Set;T(e).forEach(e=>t.add(e)),S(e).forEach(e=>t.add(e.toLowerCase()));let n=e&&`infoFor3D`in e?e.infoFor3D:void 0;return n&&(Object.values(n.assetMapFieldRoles).forEach(e=>t.add(e.toLowerCase())),Object.values(n.transformFieldRoles).forEach(e=>t.add(e.toLowerCase()))),Array.from(t)}function w(e){if(!e)return[];let t=`editFieldsInfo`in e&&e.editFieldsInfo;if(!t)return[];let{creationDateField:n,creatorField:r,editDateField:i,editorField:a}=t;return[n,r,i,a].filter(Boolean)}function T(e){return w(e).map(e=>e.toLowerCase())}function E(e){return!!e.type}function we(e,t){return!!e.editable&&E(e)&&!xe.has(e.type)&&!T(t).includes(e.name?.toLowerCase()??``)}function Te(e,t){let n=e.name?.toLowerCase()??``;return(t?.objectIdField==null||n!==t.objectIdField.toLowerCase())&&(t?.globalIdField==null||n!==t.globalIdField.toLowerCase())&&!C(t).includes(n)&&!Se.has(e.type)&&!Ce.some(e=>e.test(n))}async function Ee(e){if(!e)return[];let t=new Set;return await D(t,e),Array.from(t).sort()}async function D(e,t){let{labelingInfo:n,fieldsIndex:r}=t;n?.length&&await Promise.all(n.map(t=>O(e,r,t)))}async function O(e,t,n){if(!n)return;let r=n.getLabelExpression(),i=n.where;if(r.type===`arcade`)await g(e,t,null,r.expression);else{let n=r.expression.match(/{[^}]*}/g);n&&n.forEach(n=>{h(e,t,n.slice(1,-1))})}await _(e,t,i)}function De(e){let t=e.defaultValue;if(t!==void 0&&A(e,t))return t;if(e.nullable)return null}function Oe(e){let t=typeof e==`string`?{type:e}:e;if(L(t))return 255;if(t.type===`esriFieldTypeDate`||t.type===`date`)return 8}function k(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function ke(e){return e===null||k(e)}function Ae(e){return e===null||Number.isInteger(e)}function je(){return!0}function A(e,t){let n;switch(e.type){case`date`:case`integer`:case`long`:case`small-integer`:case`big-integer`:case`esriFieldTypeDate`:case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`esriFieldTypeSmallInteger`:case`esriFieldTypeBigInteger`:n=e.nullable?Ae:Number.isInteger;break;case`double`:case`single`:case`esriFieldTypeSingle`:case`esriFieldTypeDouble`:n=e.nullable?ke:k;break;case`string`:case`esriFieldTypeString`:n=e.nullable?ee:te;break;default:n=je}return arguments.length===1?n:n(t)}const j=[`integer`,`small-integer`,`big-integer`,`long`],M=[`single`,`double`],Me=[...j,...M],N=[`esriFieldTypeInteger`,`esriFieldTypeSmallInteger`,`esriFieldTypeLong`,`esriFieldTypeBigInteger`],P=[`esriFieldTypeSingle`,`esriFieldTypeDouble`],F=new Set([...j,...N]),Ne=new Set([...M,...P]),Pe=r(F,Ne);function Fe(e){return e!=null&&F.has(e.type)}function I(e){return e!=null&&Pe.has(e.type)}function L(e){return e!=null&&(e.type===`string`||e.type===`esriFieldTypeString`)}function R(e){return e!=null&&(e.type===`date`||e.type===`esriFieldTypeDate`)}function Ie(e){return e!=null&&(e.type===`date-only`||e.type===`esriFieldTypeDateOnly`)}function Le(e){return e!=null&&(e.type===`timestamp-offset`||e.type===`esriFieldTypeTimestampOffset`)}function Re(e){return e!=null&&(e.type===`time-only`||e.type===`esriFieldTypeTimeOnly`)}function ze(e){return e!=null&&(e.type===`date`||e.type===`date-only`||e.type===`time-only`||e.type===`timestamp-offset`)}function Be(e){return e!=null&&(e.type===`oid`||e.type===`esriFieldTypeOID`)}function Ve(e){return e!=null&&(e.type===`global-id`||e.type===`esriFieldTypeGlobalID`)}function He(e,t){return V(e,t)===null}const z={OUT_OF_RANGE:`numeric-range-validation-error::out-of-range`},B={INVALID_TYPE:`type-validation-error::invalid-type`};function Ue(e){return e==null||typeof e==`number`&&isNaN(e)?null:e}function We(e){return parseFloat(e.replaceAll(`_`,``))}function V(e,t){return e==null||e.nullable&&t===null?null:A(e,t)?I(e)&&!H(e.type,Number(t))?z.OUT_OF_RANGE:null:B.INVALID_TYPE}function H(e,t){let n=typeof e==`string`?U(e):e;if(!n)return!1;let r=n.min,i=n.max;return n.isInteger?Number.isInteger(t)&&t>=r&&t<=i:t>=r&&t<=i}function Ge(e,t){let n=o(e,t);if(n)return n;if(I(e))return U(e.type)}function U(e){switch(e){case`esriFieldTypeSmallInteger`:case`small-integer`:return W;case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`integer`:case`long`:return q;case`esriFieldTypeBigInteger`:case`big-integer`:return J;case`esriFieldTypeSingle`:case`single`:return X;case`esriFieldTypeDouble`:case`double`:return Z}}function Ke(e){if(!k(e))return null;if(Number.isInteger(e)){if(e>=W.min&&e<=W.max)return`esriFieldTypeSmallInteger`;if(e>=q.min&&e<=q.max)return`esriFieldTypeInteger`;if(e>=J.min&&e<=J.max)return`esriFieldTypeBigInteger`}return e>=X.min&&e<=X.max?`esriFieldTypeSingle`:`esriFieldTypeDouble`}const W={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},G=-2147483648,K=2**31-1,q={min:G,max:K,isInteger:!0,rawMin:G,rawMax:K},J={min:-(2**53-1),max:2**53-1,isInteger:!0,rawMin:-(2**53-1),rawMax:2**53-1},Y=(2-2**-23)*2**127,X={min:-Y,max:Y,isInteger:!1,rawMin:-Y,rawMax:Y},Z={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function qe(e,t,n){switch(e){case a.INVALID_CODED_VALUE:return`Value ${n} is not in the coded domain - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case a.VALUE_OUT_OF_RANGE:return`Value ${n} is out of the range of valid values - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case B.INVALID_TYPE:return`Value ${n} is not a valid value for the field type - field: ${t.name}, type: ${t.type}, nullable: ${t.nullable}`;case z.OUT_OF_RANGE:{let{min:e,max:r}=U(t.type);return`Value ${n} is out of range for the number type - field: ${t.name}, type: ${t.type}, value range is ${e} to ${r}`}}}function Je(e,t){return!Q(e,t,null)}function Q(e,t,n){if(!e?.attributes||!t){if(n!=null)for(let e of t??[])n.add(e);return!0}let r=new Set(Object.keys(e.attributes)),i=!1;for(let e of t)if(!r.has(e)){if(i=!0,n!=null)n.add(e);else break}return i}async function Ye(e,t){let n=new Set;for(let r of t)await g(n,e.fieldsIndex,null,r);return Array.from(n).sort()}function Xe(e){return e?[`raster.itempixelvalue`,`raster.servicepixelvalue`].some(t=>e.toLowerCase().startsWith(t)):!1}async function Ze(e,t){let n=new Set;return e?.collectRequiredFields&&await e.collectRequiredFields(n,t),Array.from(n).sort()}function Qe(e){let t=e?.match(/{[^}]+}/g);return t?t.map(e=>e.slice(1,-1).split(`:`)[0].trim()):[]}function $e(e,t){let{statisticType:n,onStatisticField:r,onStatisticExpression:i}=e,a=t.get(r),o=I(a),s=i?.returnType;switch(n){case`avg`:case`avg_angle`:return a?o||R(a)?`double`:null:s&&s===`number`?`double`:null;case`count`:return`integer`;case`min`:case`max`:return a?o||ze(a)?a?.type??null:null:s&&s===`number`?`double`:null;case`sum`:return a?o?a?.type??null:null:s&&s===`number`?`double`:null;case`mode`:return a?a?.type??null:s?s===`number`?`double`:`string`:null;default:return null}}function et(e){let{fieldName:t,fieldsMap:n,normalizedFieldsMap:r}=e;if(!t)return;let i=n.get(t);return i||(i=n.get(tt(t))??r.get($(t)),i&&n.set(t,i),i)}function tt(e){return e.trim().toLowerCase()}function $(e){return c(e)?.toLowerCase()??``}export{z as NumericRangeValidationError,B as TypeValidationError,tt as applyLowerCaseFieldName,J as bigIntegerRange,g as collectArcadeFieldNames,be as collectDisplayFilterFields,b as collectElevationFields,pe as collectFeatureReductionFields,h as collectField,m as collectFields,he as collectFilterFields,D as collectLabelingFields,ge as collectOrderByInfos,x as collectPopupTemplateFields,_ as collectSQLFieldNames,me as collectTrackInfoFields,Z as doubleRange,Qe as extractSubstitutionTemplatesFromString,Je as featureHasFields,p as fixFields,ae as fixRendererFields,oe as fixTimeInfoFields,P as floatJSONTypes,M as floatTypes,$e as getAggregateFieldType,le as getDisplayFieldName,v as getDisplayFieldNameFromFields,w as getEditTrackingFields,de as getElevationFields,Ye as getExpressionFields,ye as getFeatureEditFields,S as getFeatureGeometryFields,Oe as getFieldDefaultLength,De as getFieldDefaultValue,et as getFieldFromIndex,Ge as getFieldRange,Ee as getLabelingFields,C as getLowerCaseDefaultHiddenFields,T as getLowerCaseEditTrackingFields,Ke as getNumericTypeForValue,Ze as getRendererFields,ve as getTimeFields,N as integerJSONTypes,q as integerRange,j as integerTypes,R as isDateField,Ie as isDateOnlyField,we as isFieldEditable,Te as isFieldVisibleByDefault,E as isFieldWithType,Ve as isGlobalIDField,Fe as isIntegerField,H as isNumberInRange,I as isNumericField,Be as isObjectIDField,Xe as isRasterPixelValueField,L as isStringField,Re as isTimeOnlyField,Le as isTimestampOffsetField,He as isValidFieldValue,A as isValueMatchingFieldType,$ as lowerCaseNormalizedFieldName,c as normalizeFieldName,Me as numericTypes,ce as packFields,Q as populateMissingFields,l as rendererFields,Ue as sanitizeNullFieldValue,We as sanitizedParseFloat,X as singleRange,W as smallIntegerRange,se as unpackFieldNames,V as validateFieldValue,qe as validationErrorToString,u as visualVariableFields};
2
+ import e from"../../core/Error.js";import{getDeepValue as t,setDeepValue as n}from"../../core/object.js";import{union as r}from"../../core/SetUtils.js";import{parseWhereClause as i}from"../../core/sql.js";import{DomainValidationError as a,getDomainRange as o}from"./domainUtils.js";import{getFieldNameFromSimpleExpression as s}from"../../support/arcadeExpressionUtils.js";import{isStringOrNull as ee,isString as te}from"../../support/guards.js";import{loadArcade as ne}from"../../support/loadArcade.js";const re=/^([0-9_])/,ie=/[^a-z0-9_\u0080-\uffff]+/gi;function c(e){return e==null?null:e.trim().replaceAll(ie,`_`).replace(re,`F$1`)||null}const l=[`field`,`field2`,`field3`,`normalizationField`,`rotationInfo.field`,`proportionalSymbolInfo.field`,`proportionalSymbolInfo.normalizationField`,`colorInfo.field`,`colorInfo.normalizationField`],u=[`field`,`normalizationField`];function ae(e,t){if(e!=null&&t!=null){for(let n of Array.isArray(e)?e:[e])if(d(l,n,t),`visualVariables`in n&&n.visualVariables)for(let e of n.visualVariables)d(u,e,t)}}function d(e,r,i){if(e)for(let a of e){let e=t(a,r),o=e&&typeof e!=`function`&&i.get(e);o&&n(a,o.name,r)}}function oe(e,t){if(e!=null&&t?.fields?.length){if(`startField`in e){let n=t.get(e.startField),r=t.get(e.endField);e.startField=n?.name??null,e.endField=r?.name??null}else{let n=t.get(e.startTimeField),r=t.get(e.endTimeField);e.startTimeField=n?.name??null,e.endTimeField=r?.name??null}e.trackIdField=t.get(e.trackIdField)?.name??null}}const f=new Set;function p(e,t){return!e||!t?[]:(f.clear(),m(f,e,t),Array.from(f).sort())}function m(e,t,n){if(n){if(!t?.fields?.length){if(n.includes(`*`)){e.clear(),e.add(`*`);return}for(let t of n)t!=null&&e.add(t);return}if(n.includes(`*`)){for(let{name:n}of t.fields)e.add(n);return}for(let r of n)h(e,t,r)}}function h(e,t,n){if(typeof n==`string`){if(t){let r=t.get(n);r&&e.add(r.name)}else e.add(n)}}function se(e,t){return t==null||e==null?[]:t.includes(`*`)?(e.fields??[]).map(e=>e.name):t}function ce(e,t,n=1){if(!t||!e)return[];if(t.includes(`*`))return[`*`];let r=p(e,t);return r.length/e.fields.length>=n?[`*`]:r}async function g(e,t,n,r){if(!r)return;let i=s(r);if(i)h(e,t,i);else{let{arcadeUtils:i}=await ne(),a=i.extractFieldNames(r,n?.partitions??t?.fields?.map(e=>e.name));for(let r of a)h(e,n?.index??t,r)}}async function _(t,n,r){if(r&&r!==`1=1`){let a=await i(r,n);if(!a.isStandardized)throw new e(`fieldUtils:collectFilterFields`,`Where clause is not standardized`,{where:r});m(t,n,a.fieldNames)}}function le({displayField:e,fields:t}){return e||(t?.length?v(t):null)}function v(e){return y(e,`name-or-title`)||y(e,`unique-identifier`)||y(e,`type-or-category`)||ue(e)}function ue(e){for(let t of e){if(!t?.name)continue;let e=t.name.toLowerCase();if(e.includes(`name`)||e.includes(`title`))return t.name}return null}function y(e,t){for(let n of e)if(n?.valueType&&n.valueType===t)return n.name;return null}async function de(e){if(!e)return[];let t=new Set;return await b(t,e),Array.from(t).sort()}async function b(e,t){if(!t)return;let n=t.elevationInfo?.featureExpressionInfo;if(n)return n.collectRequiredFields(e,t.fieldsIndex)}function fe(e,t,n){n.onStatisticExpression?g(e,t,null,n.onStatisticExpression.expression):e.add(n.onStatisticField)}async function pe(e,t,n){if(!t||!n||!(`fields`in n))return;let r=[],i=n.popupTemplate;r.push(x(e,t,i)),n.fields&&r.push(...n.fields.map(async n=>fe(e,t.fieldsIndex,n))),await Promise.all(r)}async function me(e,t){let{fieldsIndex:n,trackInfo:r}=t;if(!t||!r||!n)return;let i=[r.latestObservations.renderer?.collectRequiredFields(e,n),r.previousObservations.renderer?.collectRequiredFields(e,n),r.trackLines.renderer?.collectRequiredFields(e,n)];r.popupTemplate&&i.push(x(e,t,r.popupTemplate));for(let t of[r.latestObservations.labelingInfo,r.previousObservations.labelingInfo,r.trackLines.labelingInfo])if(t)for(let r of t)i.push(O(e,n,r));await Promise.all(i)}async function x(e,t,n){let r=[];n?.expressionInfos&&r.push(...n.expressionInfos.map(n=>g(e,t.fieldsIndex,null,n.expression)));let i=n?.content;if(Array.isArray(i))for(let n of i)n.type===`expression`&&n.expressionInfo&&r.push(g(e,t.fieldsIndex,null,n.expressionInfo.expression));await Promise.all(r)}async function he(e,t,n){t&&(t.timeInfo&&n?.timeExtent&&m(e,t.fieldsIndex,[t.timeInfo.startField,t.timeInfo.endField]),t.floorInfo&&m(e,t.fieldsIndex,[t.floorInfo.floorField]),n?.where!=null&&await _(e,t.fieldsIndex,n.where))}async function ge(e,t,n){t&&n&&await Promise.all(n.map(n=>_e(e,t,n)))}async function _e(e,t,n){t&&n&&(n.valueExpression?await g(e,t.fieldsIndex,null,n.valueExpression):n.field&&h(e,t.fieldsIndex,n.field))}async function ve(e){if(!e)return[];let t=`timeInfo`in e&&e.timeInfo;return t?p(e.fieldsIndex,[e.trackIdField,t.startField,t.endField]):[]}function ye(e){return e?p(e.fieldsIndex,w(e)):[]}function S(e){if(!e)return[];let t=e.geometryFieldsInfo;return t?p(e.fieldsIndex,[t.shapeAreaField,t.shapeLengthField]):[]}async function be(e,t,n){if(!t||!n)return;let r=t.fieldsIndex;await Promise.all(n.filters.map(t=>_(e,r,t.where)))}const xe=new Set([`oid`,`global-id`,`guid`]),Se=new Set([`oid`,`global-id`]),Ce=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^shape$/i,/^shape_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/objectid/i,/^perimeter_/i,/_perimeter$/i,/_i$/i];function C(e){let t=new Set;T(e).forEach(e=>t.add(e)),S(e).forEach(e=>t.add(e.toLowerCase()));let n=e&&`infoFor3D`in e?e.infoFor3D:void 0;return n&&(Object.values(n.assetMapFieldRoles).forEach(e=>t.add(e.toLowerCase())),Object.values(n.transformFieldRoles).forEach(e=>t.add(e.toLowerCase()))),Array.from(t)}function w(e){if(!e)return[];let t=`editFieldsInfo`in e&&e.editFieldsInfo;if(!t)return[];let{creationDateField:n,creatorField:r,editDateField:i,editorField:a}=t;return[n,r,i,a].filter(Boolean)}function T(e){return w(e).map(e=>e.toLowerCase())}function E(e){return!!e.type}function we(e,t){return!!e.editable&&E(e)&&!xe.has(e.type)&&!T(t).includes(e.name?.toLowerCase()??``)}function Te(e,t){let n=e.name?.toLowerCase()??``;return(t?.objectIdField==null||n!==t.objectIdField.toLowerCase())&&(t?.globalIdField==null||n!==t.globalIdField.toLowerCase())&&!C(t).includes(n)&&!Se.has(e.type)&&!Ce.some(e=>e.test(n))}async function Ee(e){if(!e)return[];let t=new Set;return await D(t,e),Array.from(t).sort()}async function D(e,t){let{labelingInfo:n,fieldsIndex:r}=t;n?.length&&await Promise.all(n.map(t=>O(e,r,t)))}async function O(e,t,n){if(!n)return;let r=n.getLabelExpression(),i=n.where;if(r.type===`arcade`)await g(e,t,null,r.expression);else{let n=r.expression.match(/{[^}]*}/g);n&&n.forEach(n=>{h(e,t,n.slice(1,-1))})}await _(e,t,i)}function De(e){let t=e.defaultValue;if(t!==void 0&&A(e,t))return t;if(e.nullable)return null}function Oe(e){let t=typeof e==`string`?{type:e}:e;if(L(t))return 255;if(t.type===`esriFieldTypeDate`||t.type===`date`)return 8}function k(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function ke(e){return e===null||k(e)}function Ae(e){return e===null||Number.isInteger(e)}function je(){return!0}function A(e,t){let n;switch(e.type){case`date`:case`integer`:case`long`:case`small-integer`:case`big-integer`:case`esriFieldTypeDate`:case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`esriFieldTypeSmallInteger`:case`esriFieldTypeBigInteger`:n=e.nullable?Ae:Number.isInteger;break;case`double`:case`single`:case`esriFieldTypeSingle`:case`esriFieldTypeDouble`:n=e.nullable?ke:k;break;case`string`:case`esriFieldTypeString`:n=e.nullable?ee:te;break;default:n=je}return arguments.length===1?n:n(t)}const j=[`integer`,`small-integer`,`big-integer`,`long`],M=[`single`,`double`],Me=[...j,...M],N=[`esriFieldTypeInteger`,`esriFieldTypeSmallInteger`,`esriFieldTypeLong`,`esriFieldTypeBigInteger`],P=[`esriFieldTypeSingle`,`esriFieldTypeDouble`],F=new Set([...j,...N]),Ne=new Set([...M,...P]),Pe=r(F,Ne);function Fe(e){return e!=null&&F.has(e.type)}function I(e){return e!=null&&Pe.has(e.type)}function L(e){return e!=null&&(e.type===`string`||e.type===`esriFieldTypeString`)}function R(e){return e!=null&&(e.type===`date`||e.type===`esriFieldTypeDate`)}function Ie(e){return e!=null&&(e.type===`date-only`||e.type===`esriFieldTypeDateOnly`)}function Le(e){return e!=null&&(e.type===`guid`||e.type===`esriFieldTypeGUID`)}function Re(e){return e!=null&&(e.type===`timestamp-offset`||e.type===`esriFieldTypeTimestampOffset`)}function ze(e){return e!=null&&(e.type===`time-only`||e.type===`esriFieldTypeTimeOnly`)}function Be(e){return e!=null&&(e.type===`date`||e.type===`date-only`||e.type===`time-only`||e.type===`timestamp-offset`)}function Ve(e){return e!=null&&(e.type===`oid`||e.type===`esriFieldTypeOID`)}function He(e){return e!=null&&(e.type===`global-id`||e.type===`esriFieldTypeGlobalID`)}function Ue(e,t){return V(e,t)===null}const z={OUT_OF_RANGE:`numeric-range-validation-error::out-of-range`},B={INVALID_TYPE:`type-validation-error::invalid-type`};function We(e){return e==null||typeof e==`number`&&isNaN(e)?null:e}function Ge(e){return parseFloat(e.replaceAll(`_`,``))}function V(e,t){return e==null||e.nullable&&t===null?null:A(e,t)?I(e)&&!H(e.type,Number(t))?z.OUT_OF_RANGE:null:B.INVALID_TYPE}function H(e,t){let n=typeof e==`string`?U(e):e;if(!n)return!1;let r=n.min,i=n.max;return n.isInteger?Number.isInteger(t)&&t>=r&&t<=i:t>=r&&t<=i}function Ke(e,t){let n=o(e,t);if(n)return n;if(I(e))return U(e.type)}function U(e){switch(e){case`esriFieldTypeSmallInteger`:case`small-integer`:return W;case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`integer`:case`long`:return q;case`esriFieldTypeBigInteger`:case`big-integer`:return J;case`esriFieldTypeSingle`:case`single`:return X;case`esriFieldTypeDouble`:case`double`:return Z}}function qe(e){if(!k(e))return null;if(Number.isInteger(e)){if(e>=W.min&&e<=W.max)return`esriFieldTypeSmallInteger`;if(e>=q.min&&e<=q.max)return`esriFieldTypeInteger`;if(e>=J.min&&e<=J.max)return`esriFieldTypeBigInteger`}return e>=X.min&&e<=X.max?`esriFieldTypeSingle`:`esriFieldTypeDouble`}const W={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},G=-2147483648,K=2**31-1,q={min:G,max:K,isInteger:!0,rawMin:G,rawMax:K},J={min:-(2**53-1),max:2**53-1,isInteger:!0,rawMin:-(2**53-1),rawMax:2**53-1},Y=(2-2**-23)*2**127,X={min:-Y,max:Y,isInteger:!1,rawMin:-Y,rawMax:Y},Z={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Je(e,t,n){switch(e){case a.INVALID_CODED_VALUE:return`Value ${n} is not in the coded domain - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case a.VALUE_OUT_OF_RANGE:return`Value ${n} is out of the range of valid values - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case B.INVALID_TYPE:return`Value ${n} is not a valid value for the field type - field: ${t.name}, type: ${t.type}, nullable: ${t.nullable}`;case z.OUT_OF_RANGE:{let{min:e,max:r}=U(t.type);return`Value ${n} is out of range for the number type - field: ${t.name}, type: ${t.type}, value range is ${e} to ${r}`}}}function Ye(e,t){return!Q(e,t,null)}function Q(e,t,n){if(!e?.attributes||!t){if(n!=null)for(let e of t??[])n.add(e);return!0}let r=new Set(Object.keys(e.attributes)),i=!1;for(let e of t)if(!r.has(e)){if(i=!0,n!=null)n.add(e);else break}return i}async function Xe(e,t){let n=new Set;for(let r of t)await g(n,e.fieldsIndex,null,r);return Array.from(n).sort()}function Ze(e){return e?[`raster.itempixelvalue`,`raster.servicepixelvalue`].some(t=>e.toLowerCase().startsWith(t)):!1}async function Qe(e,t){let n=new Set;return e?.collectRequiredFields&&await e.collectRequiredFields(n,t),Array.from(n).sort()}function $e(e){let t=e?.match(/{[^}]+}/g);return t?t.map(e=>e.slice(1,-1).split(`:`)[0].trim()):[]}function et(e,t){let{statisticType:n,onStatisticField:r,onStatisticExpression:i}=e,a=t.get(r),o=I(a),s=i?.returnType;switch(n){case`avg`:case`avg_angle`:return a?o||R(a)?`double`:null:s&&s===`number`?`double`:null;case`count`:return`integer`;case`min`:case`max`:return a?o||Be(a)?a?.type??null:null:s&&s===`number`?`double`:null;case`sum`:return a?o?a?.type??null:null:s&&s===`number`?`double`:null;case`mode`:return a?a?.type??null:s?s===`number`?`double`:`string`:null;default:return null}}function tt(e){let{fieldName:t,fieldsMap:n,normalizedFieldsMap:r}=e;if(!t)return;let i=n.get(t);return i||(i=n.get($(t))??r.get(nt(t)),i&&n.set(t,i),i)}function $(e){return e.trim().toLowerCase()}function nt(e){return c(e)?.toLowerCase()??``}export{z as NumericRangeValidationError,B as TypeValidationError,$ as applyLowerCaseFieldName,J as bigIntegerRange,g as collectArcadeFieldNames,be as collectDisplayFilterFields,b as collectElevationFields,pe as collectFeatureReductionFields,h as collectField,m as collectFields,he as collectFilterFields,D as collectLabelingFields,ge as collectOrderByInfos,x as collectPopupTemplateFields,_ as collectSQLFieldNames,me as collectTrackInfoFields,Z as doubleRange,$e as extractSubstitutionTemplatesFromString,Ye as featureHasFields,p as fixFields,ae as fixRendererFields,oe as fixTimeInfoFields,P as floatJSONTypes,M as floatTypes,et as getAggregateFieldType,le as getDisplayFieldName,v as getDisplayFieldNameFromFields,w as getEditTrackingFields,de as getElevationFields,Xe as getExpressionFields,ye as getFeatureEditFields,S as getFeatureGeometryFields,Oe as getFieldDefaultLength,De as getFieldDefaultValue,tt as getFieldFromIndex,Ke as getFieldRange,Ee as getLabelingFields,C as getLowerCaseDefaultHiddenFields,T as getLowerCaseEditTrackingFields,qe as getNumericTypeForValue,Qe as getRendererFields,ve as getTimeFields,N as integerJSONTypes,q as integerRange,j as integerTypes,R as isDateField,Ie as isDateOnlyField,we as isFieldEditable,Te as isFieldVisibleByDefault,E as isFieldWithType,He as isGlobalIDField,Le as isGuidField,Fe as isIntegerField,H as isNumberInRange,I as isNumericField,Ve as isObjectIDField,Ze as isRasterPixelValueField,L as isStringField,ze as isTimeOnlyField,Re as isTimestampOffsetField,Ue as isValidFieldValue,A as isValueMatchingFieldType,nt as lowerCaseNormalizedFieldName,c as normalizeFieldName,Me as numericTypes,ce as packFields,Q as populateMissingFields,l as rendererFields,We as sanitizeNullFieldValue,Ge as sanitizedParseFloat,X as singleRange,W as smallIntegerRange,se as unpackFieldNames,V as validateFieldValue,Je as validationErrorToString,u as visualVariableFields};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../request.js";import{clone as t}from"../../core/lang.js";import n from"../../core/Logger.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{normalize as i,removeFile as a,getAppBaseUrl as o,removeTrailingSlash as s,addQueryParameters as c,isProtocolRelative as l,isAbsolute as u,join as d}from"../../core/urlUtils.js";import{wgs84 as f,webMercator as p}from"../../geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import h from"../../views/2d/engine/vectorTiles/style/GeoJSONVectorTileSource.js";import g from"../../views/2d/engine/vectorTiles/style/RemoteVectorTileSource.js";async function _(e,t){let n={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:``,spriteFormat:`png`},[r,i]=typeof e==`string`?[e,null]:[null,e.jsonUrl];return await y(n,`esri`,e,i,t),{layerDefinition:n.validatedSource,url:r,serviceUrl:n.sourceUrl,style:n.style,styleUrl:n.styleUrl,spriteUrl:n.style&&n.style.sprite&&v(n.styleBase,n.style.sprite),spriteFormat:n.spriteFormat,glyphsUrl:n.style&&n.style.glyphs&&v(n.styleBase,n.style.glyphs),sourceNameToSource:n.sourceNameToSource,primarySourceName:n.primarySourceName}}function v(...e){let t;for(let n of e)n!=null&&(l(n)?t&&=t.split(`://`)[0]+`:`+n.trim():t=u(n)?n:d(t,n));return t?s(t):void 0}async function y(t,n,a,o,s){r(s);let c,l,u;if(typeof a==`string`){let t=i(a);u=await e(t,{...s,responseType:`json`,query:{f:`json`,...s?.query}}),u.ssl&&(c&&=c.replace(/^http:/i,`https:`),l&&=l.replace(/^http:/i,`https:`)),c=t,l=t}else a!=null&&(u={data:a},c=a.jsonUrl||null,l=o);let d=u?.data;switch(d?.type){case`Feature`:case`FeatureCollection`:return t.sourceUrl=c||null,C(t,T(d),l,s)}if(x(d))return t.styleUrl=c||null,C(t,d,l,s);if(S(d))return t.primarySourceName?D(t,d,l,!1,n,s):(t.sourceUrl=c||null,b(d)&&t.style==null&&(n=`tilejson`),D(t,d,l,!0,n,s));throw Error(`You must specify the URL or the JSON for a service or for a style.`)}function b(e){return typeof e==`object`&&!!e&&`tilejson`in e&&e.tilejson!=null}function x(e){return!!e&&`sources`in e&&!!e.sources}function S(e){return!!e&&!x(e)}async function C(e,t,n,r){let i=n?a(n):o(),s=t.layers==null||t.layers.length===0,c=s?{...t,layers:[]}:t;e.styleBase=i,e.style=c,c[`sprite-format`]?.toLowerCase()===`webp`&&(e.spriteFormat=`webp`);let l=[];if(c.sources&&c.sources.esri&&c.sources.esri.type!==`geojson`){let t=c.sources.esri;t.url?await y(e,`esri`,v(i,t.url),void 0,r):l.push(y(e,`esri`,t,i,r))}for(let t of Object.keys(c.sources))t!==`esri`&&t!==`tilejson`&&c.sources[t].type===`vector`&&(c.sources[t].url?l.push(y(e,t,v(i,c.sources[t].url),void 0,r)):c.sources[t].tiles&&l.push(y(e,t,c.sources[t],i,r)));await Promise.all(l);for(let t of Object.keys(c.sources)){let n=c.sources[t];if(n.type===`geojson`){let a=await w(e,t,n,i,r);s&&c.layers.push(...E(t,a.geometryTypes))}}}async function w(e,t,n,r,i){if(n.data==null)throw Error(`GeoJSON source '${t}' must define a data property.`);let a={...n,type:`geojson`,data:typeof n.data==`string`?v(r,n.data):n.data},o=k({maxzoom:a.maxzoom,minzoom:a.minzoom},e),s=await h.create(t,r,o,a,i);return O(e,t,n,o,s,!e.primarySourceName,r),s}function T(e){return{version:8,sprite:``,glyphs:``,sources:{geojson:{type:`geojson`,data:e}},layers:[]}}function E(e,t){return t.map(t=>{switch(t){case`polygon`:return{id:`${e}_polygon`,type:`fill`,source:e,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":`#808080`}};case`line`:return{id:`${e}_line`,type:`line`,source:e,filter:[`==`,`$type`,`LineString`],paint:{"line-color":`#808080`,"line-width":1}};case`point`:return{id:`${e}_point`,type:`circle`,source:e,filter:[`==`,`$type`,`Point`],paint:{"circle-color":`#808080`,"circle-radius":3}}}})}async function D(e,t,n,r,i,a){let l=n?s(n)+`/`:o(),u=k(t,e);if(O(e,i,t,u,new g(i,c(l,a?.query??{}),u),r,l),!b(e)&&`defaultStyles`in t&&!e.style){if(t.defaultStyles==null)throw Error();return typeof t.defaultStyles==`string`?y(e,``,v(l,t.defaultStyles,`root.json`),void 0,a):y(e,``,t.defaultStyles,v(l,`root.json`),a)}if(b(t)&&e.style==null&&u.defaultStyles)return y(e,``,u.defaultStyles,v(l,`root.json`),a)}function O(e,t,r,i,a,o,s){if(!o&&e.primarySourceName in e.sourceNameToSource){let r=e.sourceNameToSource[e.primarySourceName];if(!r.isCompatibleWith(a)){n.getLogger(`esri.layers.support.vectorTileLayerLoader`).warn(`Ignoring source '${t}' because its tiling scheme is incompatible with the primary source '${e.primarySourceName}'.`),a.destroy();return}a.fullExtent!=null&&(r.fullExtent==null?r.fullExtent=a.fullExtent.clone():r.fullExtent.union(a.fullExtent)),r.tileInfo&&a.tileInfo&&r.tileInfo.lods.length<a.tileInfo.lods.length&&(r.tileInfo=a.tileInfo)}o&&(e.sourceBase=s,e.source=r,e.validatedSource=i,e.primarySourceName=t),e.sourceNameToSource[t]=a}function k(e,n){if(A(e)){let t=e?.tileInfo;return t!=null&&(t.rows??=512,t.cols??=512),e}let r={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100,latestWkid:3857}},i=null,a;if(b(e)){let{bounds:r,vector_layers:o}=e;if(r){let e=m({x:r[0],y:r[1],spatialReference:t(f)}),n=m({x:r[2],y:r[3],spatialReference:t(f)});i={xmin:e.x,ymin:e.y,xmax:n.x,ymax:n.y,spatialReference:t(p)}}if(o&&o.length>0)a={version:8,sprite:``,glyphs:``,sources:{tilejson:{type:`vector`,url:e.tilejson}},layers:j(o)};else if(n.style==null)throw Error(`The TileJSON source does not contain any vector_layers. This VectorTileLayer cannot be loaded.`)}i===null&&(i=r);let o=78271.51696400007,s=295828763.7957775,c=[],l=e.hasOwnProperty(`maxzoom`)&&e.maxzoom!=null?Math.abs(+e.maxzoom):22;for(let e=0;e<=l;e++)c.push({level:e,scale:s,resolution:o}),o/=2,s/=2;return{capabilities:`TilesOnly`,initialExtent:i,fullExtent:r,minScale:0,maxScale:0,tiles:e.tiles,tileInfo:{rows:512,cols:512,dpi:96,format:`pbf`,origin:{x:-20037508.342787,y:20037508.342787},lods:c,spatialReference:t(p)},defaultStyles:a}}function A(e){return e.hasOwnProperty(`tileInfo`)}function j(e){let t=[];for(let n of e)n.geometry_type?t.push(M(n.geometry_type.toLowerCase(),n,!1)):(t.push(M(`polygon`,n,!0)),t.push(M(`line`,n,!0)),t.push(M(`circle`,n,!0)));return t}function M(e,t,n){let{id:r,minzoom:i,maxzoom:a}=t,o={type:e===`polygon`||e===`polygons`?`fill`:e===`line`||e===`lines`?`line`:`circle`,id:r,source:`tilejson`,"source-layer":r,minzoom:i,maxzoom:a};switch(e){case`fill`:n&&(o.id+=`_polygon`,o.filter=`(["==", "$type", "Polygon"])`),o.paint={"fill-color":`#808080`};break;case`line`:n&&(o.id+=`_line`,o.filter=`(["==", "$type", "LineString"])`);break;case`circle`:n&&(o.id+=`_point`,o.filter=`(["==", "$type", "Point"])`)}return o}export{_ as loadMetadata};
2
+ import e from"../../request.js";import{clone as t}from"../../core/lang.js";import n from"../../core/Logger.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{normalize as i,removeFile as a,getAppBaseUrl as o,removeTrailingSlash as s,addQueryParameters as c,isProtocolRelative as l,isAbsolute as u,join as d}from"../../core/urlUtils.js";import f from"../../geometry/SpatialReference.js";import{wgs84 as p,webMercator as m}from"../../geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as h}from"../../geometry/support/webMercatorUtils.js";import g from"./LOD.js";import _ from"../../views/2d/engine/vectorTiles/style/GeoJSONVectorTileSource.js";import{createTileInfo as v}from"../../views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js";import y from"../../views/2d/engine/vectorTiles/style/RemoteVectorTileSource.js";async function b(e,t){let n={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:``,spriteFormat:`png`},[r,i]=typeof e==`string`?[e,null]:[null,e.jsonUrl];return await S(n,`esri`,e,i,t),{layerDefinition:n.validatedSource,url:r,serviceUrl:n.sourceUrl,style:n.style,styleUrl:n.styleUrl,spriteUrl:n.style&&n.style.sprite&&x(n.styleBase,n.style.sprite),spriteFormat:n.spriteFormat,glyphsUrl:n.style&&n.style.glyphs&&x(n.styleBase,n.style.glyphs),sourceNameToSource:n.sourceNameToSource,primarySourceName:n.primarySourceName}}function x(...e){let t;for(let n of e)n!=null&&(l(n)?t&&=t.split(`://`)[0]+`:`+n.trim():t=u(n)?n:d(t,n));return t?s(t):void 0}async function S(t,n,a,o,s){r(s);let c,l,u;if(typeof a==`string`){let t=i(a);u=await e(t,{...s,responseType:`json`,query:{f:`json`,...s?.query}}),u.ssl&&(c&&=c.replace(/^http:/i,`https:`),l&&=l.replace(/^http:/i,`https:`)),c=t,l=t}else a!=null&&(u={data:a},c=a.jsonUrl||null,l=o);let d=u?.data;switch(d?.type){case`Feature`:case`FeatureCollection`:return t.sourceUrl=c||null,E(t,O(d),l,s)}if(w(d))return t.styleUrl=c||null,E(t,d,l,s);if(T(d))return t.primarySourceName?A(t,d,l,!1,n,s):(t.sourceUrl=c||null,C(d)&&t.style==null&&(n=`tilejson`),A(t,d,l,!0,n,s));throw Error(`You must specify the URL or the JSON for a service or for a style.`)}function C(e){return typeof e==`object`&&!!e&&`tilejson`in e&&e.tilejson!=null}function w(e){return!!e&&`sources`in e&&!!e.sources}function T(e){return!!e&&!w(e)}async function E(e,t,n,r){let i=n?a(n):o(),s=t.layers==null||t.layers.length===0,c=s?{...t,layers:[]}:t;e.styleBase=i,e.style=c,c[`sprite-format`]?.toLowerCase()===`webp`&&(e.spriteFormat=`webp`);let l=[];if(c.sources&&c.sources.esri&&c.sources.esri.type!==`geojson`){let t=c.sources.esri;t.url?await S(e,`esri`,x(i,t.url),void 0,r):l.push(S(e,`esri`,t,i,r))}for(let t of Object.keys(c.sources))t!==`esri`&&t!==`tilejson`&&c.sources[t].type===`vector`&&(c.sources[t].url?l.push(S(e,t,x(i,c.sources[t].url),void 0,r)):c.sources[t].tiles&&l.push(S(e,t,c.sources[t],i,r)));await Promise.all(l);for(let t of Object.keys(c.sources)){let n=c.sources[t];if(n.type===`geojson`){let a=await D(e,t,n,i,r);s&&c.layers.push(...k(t,a.geometryTypes))}}}async function D(e,t,n,r,i){if(n.data==null)throw Error(`GeoJSON source '${t}' must define a data property.`);let a={...n,type:`geojson`,data:typeof n.data==`string`?x(r,n.data):n.data},o=e.sourceNameToSource[e.primarySourceName],s=o?.tileInfo?.spatialReference,c=s?.isWGS84||s?.isWebMercator?o.tileInfo.clone():v(f.WGS84,a.maxzoom),l=a.maxzoom??22;for(let e=c.lods[c.lods.length-1];e.level<l;)e=new g({level:e.level+1,resolution:e.resolution/2,scale:e.scale/2}),c.lods.push(e);let u=c.spatialReference.isWebMercator?{xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:c.spatialReference.toJSON()}:{xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}},d={capabilities:`TilesOnly`,tileInfo:c.toJSON(),fullExtent:u,initialExtent:u,minScale:0,maxScale:0},p=await _.create(t,r,d,a,i);return j(e,t,n,d,p,!e.primarySourceName,r),p}function O(e){return{version:8,sprite:``,glyphs:``,sources:{geojson:{type:`geojson`,data:e}},layers:[]}}function k(e,t){return t.map(t=>{switch(t){case`polygon`:return{id:`${e}_polygon`,type:`fill`,source:e,filter:[`==`,`$type`,`Polygon`],paint:{"fill-color":`#808080`}};case`line`:return{id:`${e}_line`,type:`line`,source:e,filter:[`==`,`$type`,`LineString`],paint:{"line-color":`#808080`,"line-width":1}};case`point`:return{id:`${e}_point`,type:`circle`,source:e,filter:[`==`,`$type`,`Point`],paint:{"circle-color":`#808080`,"circle-radius":3}}}})}async function A(e,t,n,r,i,a){let l=n?s(n)+`/`:o(),u=M(t,e);if(j(e,i,t,u,new y(i,c(l,a?.query??{}),u),r,l),!C(e)&&`defaultStyles`in t&&!e.style){if(t.defaultStyles==null)throw Error();return typeof t.defaultStyles==`string`?S(e,``,x(l,t.defaultStyles,`root.json`),void 0,a):S(e,``,t.defaultStyles,x(l,`root.json`),a)}if(C(t)&&e.style==null&&u.defaultStyles)return S(e,``,u.defaultStyles,x(l,`root.json`),a)}function j(e,t,r,i,a,o,s){if(!o&&e.primarySourceName in e.sourceNameToSource){let r=e.sourceNameToSource[e.primarySourceName];if(!r.isCompatibleWith(a)){n.getLogger(`esri.layers.support.vectorTileLayerLoader`).warn(`Ignoring source '${t}' because its tiling scheme is incompatible with the primary source '${e.primarySourceName}'.`),a.destroy();return}a.fullExtent!=null&&(r.fullExtent==null?r.fullExtent=a.fullExtent.clone():r.fullExtent.union(a.fullExtent)),r.tileInfo&&a.tileInfo&&r.tileInfo.lods.length<a.tileInfo.lods.length&&(r.tileInfo=a.tileInfo)}o&&(e.sourceBase=s,e.source=r,e.validatedSource=i,e.primarySourceName=t),e.sourceNameToSource[t]=a}function M(e,n){if(N(e)){let t=e?.tileInfo;return t!=null&&(t.rows??=512,t.cols??=512),e}let r={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100,latestWkid:3857}},i=null,a;if(C(e)){let{bounds:r,vector_layers:o}=e;if(r){let e=h({x:r[0],y:r[1],spatialReference:t(p)}),n=h({x:r[2],y:r[3],spatialReference:t(p)});i={xmin:e.x,ymin:e.y,xmax:n.x,ymax:n.y,spatialReference:t(m)}}if(o&&o.length>0)a={version:8,sprite:``,glyphs:``,sources:{tilejson:{type:`vector`,url:e.tilejson}},layers:P(o)};else if(n.style==null)throw Error(`The TileJSON source does not contain any vector_layers. This VectorTileLayer cannot be loaded.`)}i===null&&(i=r);let o=78271.51696400007,s=295828763.7957775,c=[],l=e.hasOwnProperty(`maxzoom`)&&e.maxzoom!=null?Math.abs(+e.maxzoom):22;for(let e=0;e<=l;e++)c.push({level:e,scale:s,resolution:o}),o/=2,s/=2;return{capabilities:`TilesOnly`,initialExtent:i,fullExtent:r,minScale:0,maxScale:0,tiles:e.tiles,tileInfo:{rows:512,cols:512,dpi:96,format:`pbf`,origin:{x:-20037508.342787,y:20037508.342787},lods:c,spatialReference:t(m)},defaultStyles:a}}function N(e){return e.hasOwnProperty(`tileInfo`)}function P(e){let t=[];for(let n of e)n.geometry_type?t.push(F(n.geometry_type.toLowerCase(),n,!1)):(t.push(F(`polygon`,n,!0)),t.push(F(`line`,n,!0)),t.push(F(`circle`,n,!0)));return t}function F(e,t,n){let{id:r,minzoom:i,maxzoom:a}=t,o={type:e===`polygon`||e===`polygons`?`fill`:e===`line`||e===`lines`?`line`:`circle`,id:r,source:`tilejson`,"source-layer":r,minzoom:i,maxzoom:a};switch(e){case`fill`:n&&(o.id+=`_polygon`,o.filter=`(["==", "$type", "Polygon"])`),o.paint={"fill-color":`#808080`};break;case`line`:n&&(o.id+=`_line`,o.filter=`(["==", "$type", "LineString"])`);break;case`circle`:n&&(o.id+=`_point`,o.filter=`(["==", "$type", "Point"])`)}return o}export{b as loadMetadata};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.0-next.154",
3
+ "version": "5.2.0-next.156",
4
4
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
5
5
  "keywords": [
6
6
  "ArcGIS",
@@ -20,7 +20,7 @@
20
20
  "license": "SEE LICENSE IN LICENSE.md",
21
21
  "dependencies": {
22
22
  "@amcharts/amcharts5": "~5.20.8",
23
- "@arcgis/toolkit": "5.2.0-next.154",
23
+ "@arcgis/toolkit": "5.2.0-next.156",
24
24
  "@esri/arcgis-html-sanitizer": "~4.2.0-next.2",
25
25
  "@esri/calcite-components": "^5.2.0-next.89",
26
26
  "@vaadin/grid": "~25.3.2",