@arcgis/core 5.0.0-next.120 → 5.0.0-next.122

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 (153) hide show
  1. package/WebScene.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/09cf8aed89a1ea1f8b28.js +1 -0
  4. package/assets/esri/core/workers/chunks/{4cb702d574c100483226.js → 0fe47bf45428100cc808.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{8c5e834c2d243fc369fe.js → 18b0776aef1536867ab8.js} +1 -1
  6. package/assets/esri/core/workers/chunks/22d12c309af9c19a1a48.js +1 -0
  7. package/assets/esri/core/workers/chunks/{aefc089928ada18bc4d4.js → 2762149a922275136171.js} +2 -2
  8. package/assets/esri/core/workers/chunks/{5aab1db039b2b61c6c6b.js → 2bb7bb7901bd343201fc.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{a990650a83e971444838.js → 2d1a772abd730b61854f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/2d67ab4927a968d5c8d4.js +1 -0
  11. package/assets/esri/core/workers/chunks/{ee2ae61fc747b5f9827b.js → 2e7d4a437717606bc39c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/360b3499e2a671c309ce.js +1 -0
  13. package/assets/esri/core/workers/chunks/3b0cfe3db8d90e02d6c6.js +1 -0
  14. package/assets/esri/core/workers/chunks/3d78e9b3c97c0ce21d16.js +1 -0
  15. package/assets/esri/core/workers/chunks/4550b7620932cd6de20e.js +1 -0
  16. package/assets/esri/core/workers/chunks/{618832e86ba9ec13ffcb.js → 455fbddd814e4681f0c0.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{3db4938b3f89b9b8234e.js → 4742a8c19b86a5f859f0.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{904ad26ad7c3bde63d33.js → 5062ed46edb88c0d343c.js} +1 -1
  19. package/assets/esri/core/workers/chunks/58cf3d35771b87bd74e5.js +1 -0
  20. package/assets/esri/core/workers/chunks/{d84af069f1057044c879.js → 5c12a9b0db317620dce2.js} +1 -1
  21. package/assets/esri/core/workers/chunks/65ad8838911a6d71816b.js +1 -0
  22. package/assets/esri/core/workers/chunks/6a043be736f096d70070.js +1 -0
  23. package/assets/esri/core/workers/chunks/{7a85e08cb968586f8d74.js → 72acfb74fd9ab9bae923.js} +2 -2
  24. package/assets/esri/core/workers/chunks/79ee97609f72e4cf989c.js +1 -0
  25. package/assets/esri/core/workers/chunks/7e6309bfed6692e8d2d7.js +2 -0
  26. package/assets/esri/core/workers/chunks/804c31973f7d116523cb.js +1 -0
  27. package/assets/esri/core/workers/chunks/{dc65843654dc25bd8f97.js → 8177e95596b71bf020aa.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{ca767f0e3aa559b13699.js → 90aeef17af12cfbecb36.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{4bd98d025bcd713eddca.js → 91858b02da40ff251ab2.js} +2 -2
  30. package/assets/esri/core/workers/chunks/{c064025d0dc69bb44f0d.js → a115984b794a7f90b2c0.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{723c5286771704b864ab.js → a32b274404dfd2fb70ee.js} +9 -9
  32. package/assets/esri/core/workers/chunks/a3e8b7185d63a0f85931.js +1 -0
  33. package/assets/esri/core/workers/chunks/{6be2dc8331ecf944efdc.js → a5af20f3d484d2d3bafe.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{29b30526ddac8d3ee997.js → a6006718fe22d9f2fa87.js} +1 -1
  35. package/assets/esri/core/workers/chunks/b0b24fb60a21b995b348.js +1 -0
  36. package/assets/esri/core/workers/chunks/b6e155b42a4a423139e7.js +1 -0
  37. package/assets/esri/core/workers/chunks/{8f4626f06b8ec1053469.js → bc9997d15ec0a86793c6.js} +1 -1
  38. package/assets/esri/core/workers/chunks/bf9b2aa2e67ca746ec7c.js +1 -0
  39. package/assets/esri/core/workers/chunks/c9babe86c00ae69e63ee.js +2 -0
  40. package/assets/esri/core/workers/chunks/{da40c63408affee86ac4.js → d0d1378e714ff0e43e26.js} +1 -1
  41. package/assets/esri/core/workers/chunks/d9c1e1ec5c56f09fb82f.js +1 -0
  42. package/assets/esri/core/workers/chunks/e8a7ff6210cd11d3a828.js +1 -0
  43. package/assets/esri/core/workers/chunks/eaf5d55060ffc55aac39.js +1 -0
  44. package/assets/esri/core/workers/chunks/f0b8de5b3cfbe9223df6.js +1 -0
  45. package/assets/esri/core/workers/chunks/fd5a5b05a1551cdb8c87.js +1 -0
  46. package/assets/esri/themes/base/widgets/_FeatureTable.scss +1 -0
  47. package/assets/esri/themes/base/widgets/_Grid.scss +8 -1
  48. package/assets/esri/themes/dark/main.css +1 -1
  49. package/assets/esri/themes/light/main.css +1 -1
  50. package/assets/esri/themes/light/view.css +1 -1
  51. package/config.js +1 -1
  52. package/core/Logger.js +1 -1
  53. package/core/Version.js +1 -1
  54. package/core/deprecate.js +1 -1
  55. package/kernel.js +1 -1
  56. package/layers/ImageryLayer.d.ts +1 -1
  57. package/layers/MapImageLayer.d.ts +1 -1
  58. package/layers/TileLayer.d.ts +1 -1
  59. package/layers/WebTileLayer.d.ts +1 -1
  60. package/layers/graphics/data/QueryEngineResult.js +1 -1
  61. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  62. package/layers/orientedImagery/transformations/utils.js +1 -1
  63. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  64. package/layers/raster/datasets/ImageServerRaster.js +1 -1
  65. package/layers/support/relativeTimeQueryUtils.js +1 -1
  66. package/networks/support/jsonTypes.d.ts +2 -2
  67. package/package.json +2 -2
  68. package/renderers/support/rasterRendererHelper.js +1 -1
  69. package/rest/print.js +1 -1
  70. package/support/basemapUtils.js +1 -1
  71. package/support/revision.js +1 -1
  72. package/symbols/support/Symbol3DEmissive.d.ts +9 -9
  73. package/symbols/support/Symbol3DMaterial.d.ts +8 -8
  74. package/time/TimeExtent.d.ts +1 -1
  75. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  76. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  77. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  78. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  79. package/views/3d/analysis/ShadowCast/ShadowCastTooltip.js +1 -1
  80. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  81. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  82. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  83. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  84. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  85. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  86. package/views/Attribution.js +1 -1
  87. package/views/DOMContainer.js +1 -1
  88. package/views/LinkChartView.d.ts +1 -1
  89. package/views/MapView.d.ts +1 -1
  90. package/views/SceneView.d.ts +1 -1
  91. package/views/SelectionManager.d.ts +242 -0
  92. package/views/View.d.ts +1 -1
  93. package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
  94. package/views/draw/plugins/CircularArcSegmentPlugin.js +2 -0
  95. package/views/input/types.d.ts +1 -1
  96. package/views/selection/types.d.ts +140 -0
  97. package/views/support/selectionUtils.js +1 -1
  98. package/views/ui/DefaultUI.d.ts +5 -12
  99. package/views/ui/DefaultUI.js +1 -1
  100. package/views/ui/types.d.ts +1 -1
  101. package/webscene/SunLighting.d.ts +20 -2
  102. package/webscene/VirtualLighting.d.ts +20 -2
  103. package/webscene/support/schemaValidator.js +1 -1
  104. package/webscene/support/versionUtils.js +1 -1
  105. package/widgets/Attribution/AttributionViewModel.d.ts +1 -1
  106. package/widgets/Attribution.d.ts +1 -1
  107. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -1
  108. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  109. package/widgets/FeatureTable.d.ts +9 -3
  110. package/widgets/FeatureTable.js +1 -1
  111. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  112. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  113. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  114. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  115. package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
  116. package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +1 -1
  117. package/widgets/OrientedImageryViewer/support/geometryUtils.js +1 -1
  118. package/widgets/OrientedImageryViewer/support/urlUtils.js +1 -1
  119. package/widgets/OrientedImageryViewer/utils.js +1 -1
  120. package/widgets/OrientedImageryViewer.js +1 -1
  121. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  122. package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
  123. package/widgets/Sketch/support/PluginManager.js +1 -1
  124. package/widgets/TimeSlider/TimeSliderViewModel.d.ts +1 -2
  125. package/widgets/TimeSlider.d.ts +3 -4
  126. package/assets/esri/core/workers/chunks/00112f984698b31909d3.js +0 -1
  127. package/assets/esri/core/workers/chunks/012992dc3910466ed207.js +0 -1
  128. package/assets/esri/core/workers/chunks/0485ae33a8b327974751.js +0 -1
  129. package/assets/esri/core/workers/chunks/0f5d033babc5c8440785.js +0 -1
  130. package/assets/esri/core/workers/chunks/127b1ff5c50d10a4e288.js +0 -1
  131. package/assets/esri/core/workers/chunks/147d0f7a2e471442c95c.js +0 -2
  132. package/assets/esri/core/workers/chunks/18c63f79c8ec398bc501.js +0 -1
  133. package/assets/esri/core/workers/chunks/1f613c599eff3b16c1d2.js +0 -1
  134. package/assets/esri/core/workers/chunks/2431a5480f0d22f00e00.js +0 -1
  135. package/assets/esri/core/workers/chunks/360dd5cd63d132b5c7d5.js +0 -2
  136. package/assets/esri/core/workers/chunks/3e4c5cc24bdc1c807125.js +0 -1
  137. package/assets/esri/core/workers/chunks/495e00c2a4ed45a0d00b.js +0 -1
  138. package/assets/esri/core/workers/chunks/545d801c4ba6f49df726.js +0 -1
  139. package/assets/esri/core/workers/chunks/8556d06f522914e71bb8.js +0 -1
  140. package/assets/esri/core/workers/chunks/8ac7a552189143ab4f91.js +0 -1
  141. package/assets/esri/core/workers/chunks/98c3b7d8db53f0b12642.js +0 -1
  142. package/assets/esri/core/workers/chunks/a37a003da59bdaf7ec0e.js +0 -1
  143. package/assets/esri/core/workers/chunks/ad688eee6a9f2be6df4a.js +0 -1
  144. package/assets/esri/core/workers/chunks/c88101cb8301f095d037.js +0 -1
  145. package/assets/esri/core/workers/chunks/cc245eb1c5aaaac5916e.js +0 -1
  146. package/assets/esri/core/workers/chunks/dee14ddc753eec27a9bf.js +0 -1
  147. package/assets/esri/core/workers/chunks/f27c32f0fac5cf635bab.js +0 -1
  148. package/assets/esri/core/workers/chunks/fb4bcf366ba1b51668f6.js +0 -1
  149. /package/assets/esri/core/workers/chunks/{aefc089928ada18bc4d4.js.LICENSE.txt → 2762149a922275136171.js.LICENSE.txt} +0 -0
  150. /package/assets/esri/core/workers/chunks/{7a85e08cb968586f8d74.js.LICENSE.txt → 72acfb74fd9ab9bae923.js.LICENSE.txt} +0 -0
  151. /package/assets/esri/core/workers/chunks/{360dd5cd63d132b5c7d5.js.LICENSE.txt → 7e6309bfed6692e8d2d7.js.LICENSE.txt} +0 -0
  152. /package/assets/esri/core/workers/chunks/{4bd98d025bcd713eddca.js.LICENSE.txt → 91858b02da40ff251ab2.js.LICENSE.txt} +0 -0
  153. /package/assets/esri/core/workers/chunks/{147d0f7a2e471442c95c.js.LICENSE.txt → c9babe86c00ae69e63ee.js.LICENSE.txt} +0 -0
package/config.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="5.0.0-next.120";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
2
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="5.0.0-next.122";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
package/core/Logger.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import e from"../config.js";import"./has.js";import{numericHash as t}from"./string.js";const r={info:0,warn:1,error:2,none:3};class i{constructor(e){this.level=null,this._module="",this._parent=null,this.writer=null,this._loggedMessages={error:new Map,warn:new Map,info:new Map},null!=e.level&&(this.level=e.level),null!=e.writer&&(this.writer=e.writer),this._module=e.module,i._loggers.set(this.module,this);const t=this.module.lastIndexOf(".");-1!==t&&(this._parent=i.getLogger(this.module.slice(0,t)))}get module(){return this._module}get parent(){return this._parent}error(...e){this._log("error","always",...e)}warn(...e){this._log("warn","always",...e)}info(...e){this._log("info","always",...e)}errorOnce(...e){this._log("error","once",...e)}warnOnce(...e){this._log("warn","once",...e)}infoOnce(...e){this._log("info","once",...e)}errorOncePerTick(...e){this._log("error","oncePerTick",...e)}warnOncePerTick(...e){this._log("warn","oncePerTick",...e)}infoOncePerTick(...e){this._log("info","oncePerTick",...e)}get test(){}static get test(){}static getLogger(e){return e="string"!=typeof e?e.declaredClass:e,i._loggers.get(e)||new i({module:e})}static{this._loggers=new Map}static{this._tickCounter=0}static{this._tickCounterScheduled=!1}static{this._throttlingDisabled=!1}_log(t,r,...n){if(!this._matchLevel(t))return;if("always"!==r&&!i._throttlingDisabled){const e=o(n),s=this._loggedMessages[t].get(e);if("once"===r&&null!=s||"oncePerTick"===r&&s&&s>=i._tickCounter)return;this._loggedMessages[t].set(e,i._tickCounter),i._scheduleTickCounterIncrement()}for(const i of e.log.interceptors)if(i(t,this.module,...n))return;this._inheritedWriter()(t,this.module,...n)}_parentWithMember(e,t){let r=this;for(;null!=r;){const t=r[e];if(null!=t)return t;r=r.parent}return t}_inheritedWriter(){return this._parentWithMember("writer",n)}_matchLevel(t){const i=e.log.level||"warn";return r[this._parentWithMember("level",i)]<=r[t]}static _scheduleTickCounterIncrement(){i._tickCounterScheduled||(i._tickCounterScheduled=!0,Promise.resolve().then(()=>{i._tickCounter++,i._tickCounterScheduled=!1}))}}function n(e,t,...r){console[e](`[${t}]`,...r)}function o(...e){const r=(e,t)=>"object"!=typeof t||Array.isArray(t)?t:"[Object]";return t(JSON.stringify(e,r))}export{i as default};
2
+ import e from"../config.js";import{esriToCore as t}from"./deprecate.js";import"./has.js";import{numericHash as r}from"./string.js";const i={info:0,warn:1,error:2,none:3};class n{constructor(e){this.level=null,this._module="",this._parent=null,this.writer=null,this._loggedMessages={error:new Map,warn:new Map,info:new Map},null!=e.level&&(this.level=e.level),null!=e.writer&&(this.writer=e.writer),this._module=e.module,n._loggers.set(this.module,this);const t=this.module.lastIndexOf(".");-1!==t&&(this._parent=n.getLogger(this.module.slice(0,t)))}get module(){return this._module}get parent(){return this._parent}error(...e){this._log("error","always",...e)}warn(...e){this._log("warn","always",...e)}info(...e){this._log("info","always",...e)}errorOnce(...e){this._log("error","once",...e)}warnOnce(...e){this._log("warn","once",...e)}infoOnce(...e){this._log("info","once",...e)}errorOncePerTick(...e){this._log("error","oncePerTick",...e)}warnOncePerTick(...e){this._log("warn","oncePerTick",...e)}infoOncePerTick(...e){this._log("info","oncePerTick",...e)}get test(){}static get test(){}static getLogger(e){return e="string"!=typeof e?e.declaredClass:e,n._loggers.get(e)||new n({module:e})}static{this._loggers=new Map}static{this._tickCounter=0}static{this._tickCounterScheduled=!1}static{this._throttlingDisabled=!1}_log(t,r,...i){if(!this._matchLevel(t))return;if("always"!==r&&!n._throttlingDisabled){const e=s(i),o=this._loggedMessages[t].get(e);if("once"===r&&null!=o||"oncePerTick"===r&&o&&o>=n._tickCounter)return;this._loggedMessages[t].set(e,n._tickCounter),n._scheduleTickCounterIncrement()}for(const n of e.log.interceptors)if(n(t,this.module,...i))return;this._inheritedWriter()(t,this.module,...i)}_parentWithMember(e,t){let r=this;for(;null!=r;){const t=r[e];if(null!=t)return t;r=r.parent}return t}_inheritedWriter(){return this._parentWithMember("writer",o)}_matchLevel(t){const r=e.log.level||"warn";return i[this._parentWithMember("level",r)]<=i[t]}static _scheduleTickCounterIncrement(){n._tickCounterScheduled||(n._tickCounterScheduled=!0,Promise.resolve().then(()=>{n._tickCounter++,n._tickCounterScheduled=!1}))}}function o(e,r,...i){console[e](`[${t(r)}]`,...i)}function s(...e){const t=(e,t)=>"object"!=typeof t||Array.isArray(t)?t:"[Object]";return r(JSON.stringify(e,t))}export{n as default};
package/core/Version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import t from"./Error.js";class r{constructor(t,r,o=""){this.major=t,this.minor=r,this._context=o}lessThan(t,r){return this.major<t||t===this.major&&this.minor<r}greaterEqual(t,r){return!this.lessThan(t,r)}validate(r){if(this.major!==r.major){const o=this._context&&this._context+":",e=this._context&&this._context+" ";throw new t(o+"unsupported-version",`Required major ${e}version is '${this.major}', but got '\${version.major}.\${version.minor}'`,{version:r})}}clone(){return new r(this.major,this.minor,this._context)}static parse(o,e=""){const[s,i]=o.split("."),n=/^\s*\d+\s*$/;if(!s?.match||!n.test(s)){throw new t((e&&e+":")+"invalid-version","Expected major version to be a number, but got '${version}'",{version:o})}if(!i?.match||!n.test(i)){throw new t((e&&e+":")+"invalid-version","Expected minor version to be a number, but got '${version}'",{version:o})}const a=parseInt(s,10),h=parseInt(i,10);return new r(a,h,e)}}export{r as default};
2
+ import t from"./Error.js";class r{constructor(t,r,o=""){this.major=t,this.minor=r,this._context=o}lessThan(t,r){return this.major<t||t===this.major&&this.minor<r}greaterEqual(t,r){return!this.lessThan(t,r)}toString(){return`${this.major}.${this.minor}`}validate(r){if(this.major!==r.major){const o=this._context&&this._context+":",s=this._context&&this._context+" ";throw new t(o+"unsupported-version",`Required major ${s}version is '${this.major}', but got '\${version.major}.\${version.minor}'`,{version:r})}}clone(){return new r(this.major,this.minor,this._context)}static parse(o,s=""){const[e,i]=o.split("."),n=/^\s*\d+\s*$/;if(!e?.match||!n.test(e)){throw new t((s&&s+":")+"invalid-version","Expected major version to be a number, but got '${version}'",{version:o})}if(!i?.match||!n.test(i)){throw new t((s&&s+":")+"invalid-version","Expected minor version to be a number, but got '${version}'",{version:o})}const a=parseInt(e,10),h=parseInt(i,10);return new r(a,h,s)}}export{r as default};
package/core/deprecate.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import has from"./has.js";const e=new WeakMap;function n(n,t,r=!1){const o=`🛑 DEPRECATED - ${t}`;if(!r)return void n.warn(o);let i=e.get(n);i||(i=new Set,e.set(n,i)),i.has(t)||(i.add(t),n.warn(o))}const t="https://www.esriurl.com/";function r(e,n,r,o={}){has("esri-deprecation-warnings")&&m(e,`This widget is deprecated. Use the ${n} component instead.`,{see:[`${n} component reference: ${t}${r}/`,`Esri's move to web components: ${t}components-transition-plan/`],replacement:`<${r}></${r}>`,warnOnce:!0,...o})}function o(e,n,r,o={}){has("esri-deprecation-warnings")&&m(e,`This class is deprecated. Use the ${n} component instead.`,{see:[`${n} component reference: ${t}${r}/`,`Esri's move to web components: ${t}components-transition-plan/`],replacement:`<${r}></${r}>`,warnOnce:!0,...o})}function i(e,n,t={}){has("esri-deprecation-warnings")&&m(e,`Module: ${n}`,t)}function s(e,n,t={}){if(has("esri-deprecation-warnings")){const{moduleName:r}=t;m(e,`Function: ${(r?r+"::":"")+n+"()"}`,t)}}function c(e,n,t={}){if(has("esri-deprecation-warnings")){const{moduleName:r}=t;m(e,`Property: ${(r?r+"::":"")+n}`,t)}}function a(e,n,t,r={}){if(has("esri-deprecation-warnings")){const{moduleName:o}=r;m(e,`'${(o?o+"::":"")+n}' value: ${t}`,r)}}function p(e,n,t={}){has("esri-deprecation-warnings")&&m(e,`Multiple argument constructor: ${n}`,{warnOnce:!0,replacement:`new ${n}({ <your properties here> })`,...t})}function m(e,t,r={}){if(has("esri-deprecation-warnings")){const{replacement:o,version:i,see:s,warnOnce:c}=r;let a=t;if(o&&(a+=`\n\t🛠️ Replacement: ${o}`),i&&(a+=`\n\t⚙️ Version: ${i}`),s)if(Array.isArray(s)){a+="\n\t🔗 See for more details:";for(const e of s)a+=`\n\t\t${e}`}else a+=`\n\t🔗 See ${s} for more details.`;n(e,a,c)}}export{o as deprecateUnnecessaryViewModel,r as deprecateWidget,m as deprecated,p as deprecatedConstructorSignature,s as deprecatedFunction,i as deprecatedModule,c as deprecatedProperty,a as deprecatedPropertyValue,t as esriurl};
2
+ import has from"./has.js";const e=new WeakMap;function n(n,t,r=!1){const o=`🛑 DEPRECATED - ${t}`;if(!r)return void n.warn(o);let i=e.get(n);i||(i=new Set,e.set(n,i)),i.has(t)||(i.add(t),n.warn(o))}const t="https://www.esriurl.com/";function r(e,n,r,o={}){has("esri-deprecation-warnings")&&m(e,`This widget is deprecated. Use the ${n} component instead.`,{see:[`${n} component reference: ${t}${r}/`,`Esri's move to web components: ${t}components-transition-plan/`],replacement:`<${r}></${r}>`,warnOnce:!0,...o})}function o(e,n,r,o={}){has("esri-deprecation-warnings")&&m(e,`This class is deprecated. Use the ${n} component instead.`,{see:[`${n} component reference: ${t}${r}/`,`Esri's move to web components: ${t}components-transition-plan/`],replacement:`<${r}></${r}>`,warnOnce:!0,...o})}function i(e,n,t={}){has("esri-deprecation-warnings")&&m(e,`Module: ${$(n)}`,t)}function s(e,n,t={}){if(has("esri-deprecation-warnings")){const{moduleName:r}=t;m(e,`Function: ${(r?$(r)+"::":"")+n+"()"}`,t)}}function c(e,n,t={}){if(has("esri-deprecation-warnings")){const{moduleName:r}=t;m(e,`Property: ${(r?$(r)+"::":"")+n}`,t)}}function a(e,n,t,r={}){if(has("esri-deprecation-warnings")){const{moduleName:o}=r;m(e,`'${(o?$(o)+"::":"")+n}' value: ${t}`,r)}}function p(e,n,t={}){has("esri-deprecation-warnings")&&m(e,`Multiple argument constructor: ${n=$(n)}`,{warnOnce:!0,replacement:`new ${n}({ <your properties here> })`,...t})}function m(e,t,r={}){if(has("esri-deprecation-warnings")){const{replacement:o,version:i,see:s,warnOnce:c}=r;let a=t;if(o&&(a+=`\n\t🛠️ Replacement: ${o}`),i&&(a+=`\n\t⚙️ Version: ${i}`),s)if(Array.isArray(s)){a+="\n\t🔗 See for more details:";for(const e of s)a+=`\n\t\t${e}`}else a+=`\n\t🔗 See ${s} for more details.`;n(e,a,c)}}function $(e){return e.startsWith("esri.")?e.replace("esri.","@arcgis/core/").replaceAll(".","/"):e}export{o as deprecateUnnecessaryViewModel,r as deprecateWidget,m as deprecated,p as deprecatedConstructorSignature,s as deprecatedFunction,i as deprecatedModule,c as deprecatedProperty,a as deprecatedPropertyValue,$ as esriToCore,t as esriurl};
package/kernel.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.0";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.0.0-next.120",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
2
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.0";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.0.0-next.122",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
@@ -79,7 +79,7 @@ export interface ImageryLayerEvents extends RefreshableLayerEvents, LayerEvents
79
79
  * >
80
80
  * > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content.
81
81
  * > For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/terms/attribution/) documentation.
82
- * > For information on terms of use, see the [Terms of Use FAQ](https://developers.arcgis.com/terms/faq/).
82
+ * > For information, see the [Terms of Use documentation](https://developers.arcgis.com/documentation/terms-of-use/).
83
83
  *
84
84
  * <span id="rendering"></span>
85
85
  * ### ImageryLayer rendering
@@ -264,7 +264,7 @@ export interface MapImageLayerEvents extends RefreshableLayerEvents, LayerEvents
264
264
  * >
265
265
  * > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content.
266
266
  * > For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/terms/attribution/) documentation.
267
- * > For information on terms of use, see the [Terms of Use FAQ](https://developers.arcgis.com/terms/faq/).
267
+ * > For information, see the [Terms of Use documentation](https://developers.arcgis.com/documentation/terms-of-use/).
268
268
  *
269
269
  * @since 4.0
270
270
  * @see [Sublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/)
@@ -81,7 +81,7 @@ export interface TileLayerEvents extends MapImageLayerEvents {}
81
81
  * >
82
82
  * > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content.
83
83
  * > For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/terms/attribution/) documentation.
84
- * > For information on terms of use, see the [Terms of Use FAQ](https://developers.arcgis.com/terms/faq/).
84
+ * > For information, see the [Terms of Use documentation](https://developers.arcgis.com/documentation/terms-of-use/).
85
85
  *
86
86
  * @since 4.0
87
87
  * @see [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/)
@@ -42,7 +42,7 @@ export interface WebTileLayerProperties extends LayerProperties, PortalLayerProp
42
42
  * >
43
43
  * > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content.
44
44
  * > For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/documentation/mapping-and-location-services/reference/basemap-attribution/) documentation.
45
- * > For information on terms of use, see the [Terms of Use](https://developers.arcgis.com/documentation/terms-of-use/).
45
+ * > For information, see the [Terms of Use documentation](https://developers.arcgis.com/documentation/terms-of-use/).
46
46
  *
47
47
  * @since 4.0
48
48
  * @see [Sample - WebTileLayer (3D)](https://developers.arcgis.com/javascript/latest/sample-code/layers-webtile-3d/)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as l}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as u}from"../../../geometry/support/curves/curveUtils.js";import c from"./AttributesBuilder.js";import{cleanFromGeometryEngine as m,getGeometry as d,transformCentroid as p}from"./geometryUtils.js";import{project as f}from"./projectionSupport.js";import{getDateInNumber as h}from"./queryUtils.js";import{SnappingCandidateEdge as y,SnappingCandidateVertex as g}from"./SnappingCandidate.js";import{isDateField as x,isDateOnlyField as T,isTimestampOffsetField as F,isStringField as I,isTimeOnlyField as _}from"../../support/fieldUtils.js";import v from"../../../rest/support/AutoIntervalBinParameters.js";import V from"../../../rest/support/DateBinParameters.js";import{unitsDict as S}from"../../../rest/support/DateBinUtils.js";import b from"../../../rest/support/FixedBoundariesBinParameters.js";import z from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as R,calculateStringStatistics as B,calculateStatistics as M,processSummaryStatisticsResult as A,calculateUniqueValuesCount as w,createUVResult as N,calculateClassBreaks as D,resolveCBResult as P,calculateHistogram as q,getAttributeComparator as j,calculatePercentile as C,binIndex as O,getBinParams as Z}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as E}from"luxon";const H="bin";class U{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new c(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const n=new Map,r=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!r.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,this.items,n);s.push(t)}r.set(a,this._calculateUniqueValues(s,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:i,items:a}=u[t],n=i.join(",");s&&!e.validateItems(a,s)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=m({spatialReference:this.query.outSR,...f(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=m({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,s){const i=this.featureAdapter,a=J(this.hasZ,this.hasM),{point:n}=e,r="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y;function c(e,t){const s=(e-n.x)/r,i=(t-n.y)/o;return s*s+i*i}const m={candidates:[]},d="esriGeometryPolygon"===this.geometryType,p="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,f=this._getPointCreator(t,this.spatialReference,s),h=new Q(null,0),x=new Q(null,0),T={x:0,y:0,z:0};for(const l of this.items){const e=i.getObjectId(l),t=i.getGeometryWithCurves?.(l);if(null!=t){I(t,e);continue}const s=i.getGeometry(l);null==s||F(s,e)}return m.candidates.sort((e,t)=>e.distance-t.distance),m;function F(t,s){const{coords:i}=t,r=t.isPoint?Y:t.lengths;if(h.coords=i,x.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],o=e;for(let t=0;t<i;t++,e+=a){if(!d&&t===i-1)continue;if(h.coordsIndex=e,x.coordsIndex=t===i-1?o:e+a,!k(T,n,h,x))continue;const r=c(T.x,T.y);r<=1&&m.candidates.push(new y(s,f(T),Math.sqrt(r),f(h),f(x)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],n=e,o=x;o.coordsIndex=n;for(let t=0;t<i;t++,e+=a){if(h.coordsIndex=e,d&&t===i-1&&h.x===o.x&&h.y===o.y)continue;const a=c(h.x,h.y);a<=1&&m.candidates.push(new g(s,f(h),Math.sqrt(a)))}}}else if(p&&"ends"===e.vertexMode){let e=0;const t=[];for(let s=0;s<r.length;s++){t.push(e);const i=r[s];e+=i*a,i>1&&t.push(e-a)}for(const i of t){h.coordsIndex=i;const e=c(h.x,h.y);e<=1&&m.candidates.push(new g(s,f(h),Math.sqrt(e)))}}}function I(t,s){const{candidates:i}=m,a={x:0,y:0,z:0};if(e.returnEdge){const e=[n.x,n.y],r=new Q(e,0),o=new Q(e,0);for(const{segments:n}of t.parts)for(const{start:t,curve:m}of n){const{curvePoint:n}=l(t,m,e),d=c(...n);d>1||([a.x,a.y]=n,r.coords=t,o.coords=u(m),i.push(new y(s,f(a),Math.sqrt(d),f(r),f(o))))}}function r(e){a.x=t.vertexXY[2*e],a.y=t.vertexXY[2*e+1];const n=c(a.x,a.y);n>1||(a.z=t.vertexZ?.[e]??0,i.push(new g(s,f(a),Math.sqrt(n))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)r(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":r(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const s=t.partOffsets[e],i=t.partOffsets[e+1];r(s),i!==s&&r(i)}}}}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>f(e,t,s),{hasZ:a}=this,n=0;return a&&e?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:n})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=x(m)||T(m)||F(m),p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),f=R({normalizationType:a,normalizationField:i,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},y=I(m)?B({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):M({values:p,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return A(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:n,timeZone:r},this.items,!1),l=w(o);return N(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),f=D(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return P(f,r)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return q(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.slice().reverse()){const t=i.split(" "),a=t[0],n=this.fieldsIndex.get(a),r=!!t[1]&&"desc"===t[1].toLowerCase(),o=j(n?.type,r,"case-sensitive");e.sort((e,t)=>{const i=s(e,a,n),r=s(t,a,n);return o(i,r)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:s,hasM:i,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:d,resultOffset:p,returnZ:f,returnM:h}=e,y=null!=d&&t.length>(p||0)+d,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:s,hasM:i&&h,hasZ:a&&f,objectIdFieldName:r,spatialReference:m(u||o),transform:c&&n(c)||null}}_createFeatures(e,t){const s=new c(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:l,returnCentroid:u,maxAllowableOffset:m,resultOffset:f,resultRecordCount:h,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=i&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,r,(e,t,i)=>s.getFieldValue(e,t,i)),this.geometryType&&(l||u)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const i of _){const a=this.featureAdapter.getGeometry(i),n=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),geometry:d(this.geometryType,a,m,e,x,T)});t&&a&&!n.geometry&&(n.centroid=p(this,this.featureAdapter.getCentroid(i,this),e)),F[I++]=n}else if(!l&&u)for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:p(this,this.featureAdapter.getCentroid(i,this),e)});else for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:p(this,this.featureAdapter.getCentroid(i,this),e),geometry:d(this.geometryType,this.featureAdapter.getGeometry(i),m,e,x,T)})}else for(const n of _){const e=s.getAttributes(n);e&&(F[I++]=this._addFeatureJSONMetadata(n,{attributes:e}))}const v=f||0;if(null!=h){const e=v+h;F=F.slice(v,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const s=this.featureAdapter.getMetadata?.(e);return void 0!==s&&(t.metadata=s),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,s=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,i=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>s)e=!0;else{const t=J(this.hasZ,this.hasM),s=this.featureAdapter;e=this.items.reduce((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)},0)/t>i}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,s={attributes:{}}){const i=[],a=new Map,n=new Map,r=new Map,o=new Map,l=new c(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:p,resultRecordCount:f}=e,h=m?.length,y=!!h,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const c of u??[]){const{outStatisticFieldName:e,statisticType:u}=c,p=c,f="exceedslimit"!==u?c.onStatisticField:void 0,T="percentile_disc"===u||"percentile_cont"===u,F="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,_=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!r.has(f)){const e=[];for(const s of m){const i=this._getAttributeValues(l,s,t,a);e.push(i)}r.set(f,this._calculateUniqueValues(e,t,!F&&l.returnDistinctValues))}const s=r.get(f);if(!s)continue;const i=Object.keys(s);for(const n of i){const{count:i,data:r,items:u,itemPositions:c}=s[n],h=r.join(",");if(!d||l.validateItems(u,d)){const s=o.get(h)||{attributes:{}};if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(p,u);s.aggregateGeometries[t]=e}else{let n=null;if(_)n=i;else{const e=this._getAttributeValues(l,f,t,a),s=c.map(t=>e[t]);n=T&&"statisticParameters"in p?this._getPercentileValue(p,s):this._getStatisticValue(p,s,null,l.returnDistinctValues)}s.attributes[e]=n}let n=0;m.forEach((e,t)=>s.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,s)}}}else if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(p,t);s.aggregateGeometries[i]=e}else{const i=this._getAttributeValues(l,f,t,a);s.attributes[e]=T&&"statisticParameters"in p?this._getPercentileValue(p,i):this._getStatisticValue(p,i,n,l.returnDistinctValues)}const v="min"!==u&&"max"!==u||!I(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;i.push({name:e,alias:e,type:v||"esriFieldTypeDouble"})}const T=y?Array.from(o.values()):[s];return this._sortFeatures(T,p,(e,t)=>e.attributes[t]),f&&(T.length=Math.min(f,T.length)),{fields:i,features:T}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return x(t)||T(t)||F(t)||_(t)}async _getAggregateGeometry(e,n){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:p}=this,f=n.map(e=>d(p,c.getGeometry(e))),h=r(m,f,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?i(h):a(o(m,f));y.aggregateGeometries={...e,spatialReference:m},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):s(a(o(m,f)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:n}=e;let r=null;r=s?.has(a)?s.get(a):I(this.fieldsIndex.get(a))||this._isAnyDateField(a)?B({values:t,returnDistinct:i}):M({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:n,orderBy:r}=i,o=this.fieldsIndex.get(s);return C(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s,i){if(i.has(t))return i.get(t);const a=this.fieldsIndex.get(t),n=s.map(s=>e.getFieldValue(s,t,a));return i.set(t,n),n}_calculateUniqueValues(e,t,s){const i={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==i[o]?i[o]={count:1,data:r,items:[a],itemPositions:[n]}:(s||i[o].count++,i[o].items.push(a),i[o].itemPositions.push(n))}return i}async _getDataValues(t,s,i=!0){const a=new c(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=t;return n?a.getExpressionValues(s,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(s,e(t),i)}_calculateHistogramBins(e,t,s){if(null==t.min&&null==t.max)return[];const i=t.intervals,a=t.min??0,n=t.max??0,r=i.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=s[o];if(null!=t&&t>=a&&t<=n){const e=O(i,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:s,outAlias:i,valueType:a}=t,n=[],r=[{name:i??s,alias:i??s,type:a??"esriFieldTypeString"},{name:H,alias:H,type:"esriFieldTypeInteger"}],o=new c(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[s],(e,t,s)=>o.getFieldValue(e,t,s));const m=this._getAttributeValues(o,s,u,l),d=this._calculateUniqueValues([m],u,o.returnDistinctValues);for(const c in d){const{items:t}=d[c],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[i??s]:c}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const s=e.bin;switch(t=t??this.items,s.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(v.fromJSON(s),e,t);case"dateBin":return this._createDateBinsResponse(V.fromJSON(s),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(b.fromJSON(s),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(z.fromJSON(s),e,t)}}async _createAutoIntervalBinsResponse(e,t,s){const{field:i,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),m=Z(c,{field:i,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:h(r?e.normalizationMinValue:l,!1),maxValue:h(r?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,s);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,s){const{field:i,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:e.field,timeZone:t.outTimeReference?.ianaTimeZone},s),p=_(this.fieldsIndex.get(i)),f=S.toJSON(m),y=d.filter(Boolean).sort((e,t)=>e-t),g=null!=n?h(n,p):y[0],x=null!=r?h(r,p):y[y.length-1],T=[];if(null!=g&&null!=x){const e={zone:t.outTimeReference?.ianaTimeZone??G},s=u?.unit?S.toJSON(u.unit):"milliseconds",i={[s]:u?.value||0},n=E.fromMillis(g,e).minus(i),r=E.fromMillis(x,e).minus(i),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const s=(e.weekday-t+7)%7;return e.minus({days:s}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(r,m):r;for(;e>n;){const t=e.minus({[f]:a.value});if(t<n){T.unshift([l?t.plus(i).toMillis():n.plus(i).toMillis(),e.plus(i).toMillis()]);break}T.unshift([t.plus(i).toMillis(),e.plus(i).toMillis()]),e=t}}else{let e="first"===o?n:"week"===f?d(n,m):n.startOf(f);for(;e<=r;){const t=e.plus({[f]:a.value});if(t>r){T.push([e.plus(i).toMillis(),l?t.plus(i).toMillis():r.plus(i).toMillis()]);break}T.push([e.plus(i).toMillis(),t.plus(i).toMillis()]),e=t}}}const F=this._calculateHistogramBins(d,{intervals:T,min:g,max:x},s);return this._createFeaturesFromHistogramBins(F,t)}async _createFixedBoundariesBinsResponse(e,t,s){const{field:i}=e,a=await this._getDataValues({field:i,timeZone:t.outTimeReference?.ianaTimeZone},s),n=_(this.fieldsIndex.get(i)),r=e.boundaries.map(e=>h(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,s);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,s){const{field:i,interval:a,normalizationType:n,start:r,end:o}=e,l=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:n,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),u=_(this.fieldsIndex.get(i)),c=Z(l,{field:i,classificationMethod:"defined-interval",definedInterval:a,minValue:h(n?e.normalizationMinValue:r,u),maxValue:h(n?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,s);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:s,lowerBoundaryAlias:i}=t,a=i||"lowerBoundary",n=s||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:H,alias:H,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:s,items:i}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?E.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[n]=m&&d&&null!=s?E.fromMillis(s,{zone:d}).toISO():s),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},i),f.attributes[H]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...s})=>({...s,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(f))):(t.bin?.splitBy&&(f.attributes[H]=++c),h=await this._createStatisticsQueryResponse(t,i,f),r.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function k(e,t,s,i){const a=i.x-s.x,n=i.y-s.y,r=t.x-s.x,o=t.y-s.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=s.x+a*c,e.y=s.y+n*c,!0}function J(e,t){return e?t?4:3:t?3:2}class Q{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const Y=[1];export{U as QueryEngineResult};
2
+ import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as l}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as u}from"../../../geometry/support/curves/curveUtils.js";import c from"./AttributesBuilder.js";import{cleanFromGeometryEngine as m,getGeometry as d,transformCentroid as p}from"./geometryUtils.js";import{project as f}from"./projectionSupport.js";import{getDateInNumber as h}from"./queryUtils.js";import{SnappingCandidateEdge as y,SnappingCandidateVertex as g}from"./SnappingCandidate.js";import{isDateField as x,isDateOnlyField as T,isTimestampOffsetField as F,isStringField as I,isTimeOnlyField as _}from"../../support/fieldUtils.js";import v from"../../../rest/support/AutoIntervalBinParameters.js";import V from"../../../rest/support/DateBinParameters.js";import{unitsDict as S}from"../../../rest/support/DateBinUtils.js";import b from"../../../rest/support/FixedBoundariesBinParameters.js";import z from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as R,calculateStringStatistics as B,calculateStatistics as M,processSummaryStatisticsResult as A,calculateUniqueValuesCount as w,createUVResult as N,calculateClassBreaks as D,resolveCBResult as P,calculateHistogram as q,getAttributeComparator as j,calculatePercentile as C,binIndex as O,getBinParams as Z}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as E}from"luxon";const H="bin";class U{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new c(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const n=new Map,r=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!r.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,this.items,n);s.push(t)}r.set(a,this._calculateUniqueValues(s,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:i,items:a}=u[t],n=i.join(",");s&&!e.validateItems(a,s)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=m({spatialReference:this.query.outSR,...f(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=m({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,s){const i=this.featureAdapter,a=J(this.hasZ,this.hasM),{point:n}=e,r="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y;function c(e,t){const s=(e-n.x)/r,i=(t-n.y)/o;return s*s+i*i}const m={candidates:[]},d="esriGeometryPolygon"===this.geometryType,p="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,f=this._getPointCreator(t,this.spatialReference,s),h=new Q(null,0),x=new Q(null,0),T={x:0,y:0,z:0};for(const l of this.items){const e=i.getObjectId(l),t=i.getGeometryWithCurves?.(l);if(null!=t){I(t,e);continue}const s=i.getGeometry(l);null==s||F(s,e)}return m.candidates.sort((e,t)=>e.distance-t.distance),m;function F(t,s){const{coords:i}=t,r=t.isPoint?Y:t.lengths;if(h.coords=i,x.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],o=e;for(let t=0;t<i;t++,e+=a){if(!d&&t===i-1)continue;if(h.coordsIndex=e,x.coordsIndex=t===i-1?o:e+a,!k(T,n,h,x))continue;const r=c(T.x,T.y);r<=1&&m.candidates.push(new y(s,f(T),Math.sqrt(r),f(h),f(x)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],n=e,o=x;o.coordsIndex=n;for(let t=0;t<i;t++,e+=a){if(h.coordsIndex=e,d&&t===i-1&&h.x===o.x&&h.y===o.y)continue;const a=c(h.x,h.y);a<=1&&m.candidates.push(new g(s,f(h),Math.sqrt(a)))}}}else if(p&&"ends"===e.vertexMode){let e=0;const t=[];for(let s=0;s<r.length;s++){t.push(e);const i=r[s];e+=i*a,i>1&&t.push(e-a)}for(const i of t){h.coordsIndex=i;const e=c(h.x,h.y);e<=1&&m.candidates.push(new g(s,f(h),Math.sqrt(e)))}}}function I(t,s){const{candidates:i}=m,a={x:0,y:0,z:0};if(e.returnEdge){const e=[n.x,n.y],r=new Q(e,0),o=new Q(e,0);for(const{segments:n}of t.parts)for(const{start:t,curve:m}of n){const{curvePoint:n}=l(t,m,e),d=c(...n);d>1||([a.x,a.y]=n,r.coords=t,o.coords=u(m),i.push(new y(s,f(a),Math.sqrt(d),f(r),f(o))))}}function r(e){a.x=t.vertexXY[2*e],a.y=t.vertexXY[2*e+1];const n=c(a.x,a.y);n>1||(a.z=t.vertexZ?.[e]??0,i.push(new g(s,f(a),Math.sqrt(n))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)r(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":r(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const s=t.partOffsets[e],i=t.partOffsets[e+1];r(s),i!==s&&r(i)}}}}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>f(e,t,s),{hasZ:a}=this,n=0;return a&&e?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:n})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=x(m)||T(m)||F(m),p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),f=R({normalizationType:a,normalizationField:i,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},y=I(m)?B({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):M({values:p,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return A(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:n,timeZone:r},this.items,!1),l=w(o);return N(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),f=D(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return P(f,r)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return q(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.slice().reverse()){const t=i.split(" "),a=t[0],n=this.fieldsIndex.get(a),r=!!t[1]&&"desc"===t[1].toLowerCase(),o=j(n?.type,r,"case-sensitive");e.sort((e,t)=>{const i=s(e,a,n),r=s(t,a,n);return o(i,r)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:s,hasM:i,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:d,resultOffset:p,returnZ:f,returnM:h}=e,y=null!=d&&t.length>(p||0)+d,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:s,hasM:i&&h,hasZ:a&&f,objectIdFieldName:r,spatialReference:m(u||o),transform:c&&n(c)||null}}_createFeatures(e,t){const s=new c(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:l,returnCentroid:u,maxAllowableOffset:m,resultOffset:f,resultRecordCount:h,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=i&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,r,(e,t,i)=>s.getFieldValue(e,t,i)),this.geometryType&&(l||u)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const i of _){const a=this.featureAdapter.getGeometry(i),n=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),geometry:d(this.geometryType,a,m,e,x,T)});t&&a&&!n.geometry&&(n.centroid=p(this,this.featureAdapter.getCentroid(i,this),e)),F[I++]=n}else if(!l&&u)for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:p(this,this.featureAdapter.getCentroid(i,this),e)});else for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:p(this,this.featureAdapter.getCentroid(i,this),e),geometry:d(this.geometryType,this.featureAdapter.getGeometry(i),m,e,x,T)})}else for(const n of _){const e=s.getAttributes(n);e&&(F[I++]=this._addFeatureJSONMetadata(n,{attributes:e}))}const v=f||0;if(null!=h){const e=v+h;F=F.slice(v,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const s=this.featureAdapter.getMetadata?.(e);return void 0!==s&&(t.metadata=s),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,s=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,i=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>s)e=!0;else{const t=J(this.hasZ,this.hasM),s=this.featureAdapter;e=this.items.reduce((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)},0)/t>i}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,s={attributes:{}}){const i=[],a=new Map,n=new Map,r=new Map,o=new Map,l=new c(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:p,resultRecordCount:f}=e,h=m?.length,y=!!h,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const c of u??[]){const{outStatisticFieldName:e,statisticType:u}=c,p=c,f="exceedslimit"!==u?c.onStatisticField:void 0,T="percentile_disc"===u||"percentile_cont"===u,F="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,_=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!r.has(f)){const e=[];for(const s of m){const i=this._getAttributeValues(l,s,t,a);e.push(i)}r.set(f,this._calculateUniqueValues(e,t,!F&&l.returnDistinctValues))}const s=r.get(f);if(!s)continue;const i=Object.keys(s);for(const n of i){const{count:i,data:r,items:u,itemPositions:c}=s[n],h=r.join(",");if(!d||l.validateItems(u,d)){const s=o.get(h)||{attributes:{}};if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(p,u);s.aggregateGeometries[t]=e}else{let n=null;if(_)n=i;else{const e=this._getAttributeValues(l,f,t,a),s=c.map(t=>e[t]);n=T&&"statisticParameters"in p?this._getPercentileValue(p,s):this._getStatisticValue(p,s,null,l.returnDistinctValues)}s.attributes[e]=n}let n=0;m.forEach((e,t)=>s.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,s)}}}else if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(p,t);s.aggregateGeometries[i]=e}else{const i=this._getAttributeValues(l,f,t,a);s.attributes[e]=T&&"statisticParameters"in p?this._getPercentileValue(p,i):this._getStatisticValue(p,i,n,l.returnDistinctValues)}const v="min"!==u&&"max"!==u||!I(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;i.push({name:e,alias:e,type:v||"esriFieldTypeDouble"})}const T=y?Array.from(o.values()):[s];return this._sortFeatures(T,p,(e,t)=>e.attributes[t]),f&&(T.length=Math.min(f,T.length)),{fields:i,features:T}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return x(t)||T(t)||F(t)||_(t)}async _getAggregateGeometry(e,n){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:p}=this,f=n.map(e=>d(p,c.getGeometry(e))),h=r(m,f,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?i(h):a(o(m,f));y.aggregateGeometries={...e,spatialReference:m},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):s(a(o(m,f)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:n}=e;let r=null;r=s?.has(a)?s.get(a):I(this.fieldsIndex.get(a))||this._isAnyDateField(a)?B({values:t,returnDistinct:i}):M({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:n,orderBy:r}=i,o=this.fieldsIndex.get(s);return C(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s,i){if(i.has(t))return i.get(t);const a=this.fieldsIndex.get(t),n=s.map(s=>e.getFieldValue(s,t,a));return i.set(t,n),n}_calculateUniqueValues(e,t,s){const i={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==i[o]?i[o]={count:1,data:r,items:[a],itemPositions:[n]}:(s||i[o].count++,i[o].items.push(a),i[o].itemPositions.push(n))}return i}async _getDataValues(t,s,i=!0){const a=new c(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=t;return n?a.getExpressionValues(s,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(s,e(t),i)}_calculateHistogramBins(e,t,s){if(null==t.min&&null==t.max)return[];const i=t.intervals,a=t.min??0,n=t.max??0,r=i.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=s[o];if(null!=t&&t>=a&&t<=n){const e=O(i,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:s,outAlias:i,valueType:a}=t,n=[],r=[{name:i??s,alias:i??s,type:a??"esriFieldTypeString"},{name:H,alias:H,type:"esriFieldTypeInteger"}],o=new c(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[s],(e,t,s)=>o.getFieldValue(e,t,s));const m=this._getAttributeValues(o,s,u,l),d=this._calculateUniqueValues([m],u,o.returnDistinctValues);for(const c in d){const{items:t}=d[c],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[i??s]:c}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const s=e.bin;switch(t=t??this.items,s.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(v.fromJSON(s),e,t);case"dateBin":return this._createDateBinsResponse(V.fromJSON(s),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(b.fromJSON(s),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(z.fromJSON(s),e,t)}}async _createAutoIntervalBinsResponse(e,t,s){const{field:i,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),m=Z(c,{field:i,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:h(r?e.normalizationMinValue:l,!1),maxValue:h(r?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,s);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,s){const{field:i,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),p=_(this.fieldsIndex.get(i)),f=S.toJSON(m),y=d.filter(Boolean).sort((e,t)=>e-t),g=null!=n?h(n,p):y[0],x=null!=r?h(r,p):y[y.length-1],T=[];if(null!=g&&null!=x){const e={zone:t.outTimeReference?.ianaTimeZone??G},s=u?.unit?S.toJSON(u.unit):"milliseconds",i={[s]:u?.value||0},n=E.fromMillis(g,e).minus(i),r=E.fromMillis(x,e).minus(i),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const s=(e.weekday-t+7)%7;return e.minus({days:s}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(r,m):r;for(;e>n;){const t=e.minus({[f]:a.value});if(t<n){T.unshift([l?t.plus(i).toMillis():n.plus(i).toMillis(),e.plus(i).toMillis()]);break}T.unshift([t.plus(i).toMillis(),e.plus(i).toMillis()]),e=t}}else{let e="first"===o?n:"week"===f?d(n,m):n.startOf(f);for(;e<=r;){const t=e.plus({[f]:a.value});if(t>r){T.push([e.plus(i).toMillis(),l?t.plus(i).toMillis():r.plus(i).toMillis()]);break}T.push([e.plus(i).toMillis(),t.plus(i).toMillis()]),e=t}}}const F=this._calculateHistogramBins(d,{intervals:T,min:g,max:x},s);return this._createFeaturesFromHistogramBins(F,t)}async _createFixedBoundariesBinsResponse(e,t,s){const{field:i}=e,a=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),n=_(this.fieldsIndex.get(i)),r=e.boundaries.map(e=>h(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,s);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,s){const{field:i,interval:a,normalizationType:n,start:r,end:o}=e,l=await this._getDataValues({field:i||e.expression,normalizationField:e.normalizationField,normalizationType:n,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),u=_(this.fieldsIndex.get(i)),c=Z(l,{field:i,classificationMethod:"defined-interval",definedInterval:a,minValue:h(n?e.normalizationMinValue:r,u),maxValue:h(n?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,s);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:s,lowerBoundaryAlias:i}=t,a=i||"lowerBoundary",n=s||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:H,alias:H,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:s,items:i}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?E.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[n]=m&&d&&null!=s?E.fromMillis(s,{zone:d}).toISO():s),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},i),f.attributes[H]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...s})=>({...s,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(f))):(t.bin?.splitBy&&(f.attributes[H]=++c),h=await this._createStatisticsQueryResponse(t,i,f),r.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function k(e,t,s,i){const a=i.x-s.x,n=i.y-s.y,r=t.x-s.x,o=t.y-s.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=s.x+a*c,e.y=s.y+n*c,!0}function J(e,t){return e?t?4:3:t?3:2}class Q{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const Y=[1];export{U as QueryEngineResult};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{isArrayLike as e}from"../../../core/arrayUtils.js";import{deg2rad as t}from"../../../core/mathUtils.js";import{clone as a,zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../geometry/Point.js";import{isElevationSource as n}from"../core/ElevationSourceDefinitions.js";import{rectifyMapPointPanoramic as o,rectifyMapPoint as c}from"./rectifyMapPoint.js";import{getWebMercatorScalingFactor as s,hasAngles as f,convertPixelToHeadingPitch as l,isElevationSampler as m,reducerFn as p,validatePixelsToTransform as h,validateRotationMatrix as u,computeFarplaneVertices as y,computeHFOVAndVFOV as d,vecToPoint as w,or as g,isUpdateElevationWithElevationSource as v,scaleAndAddWithFactor as x,computeNewReferenceCoordinates as M,projectiveTransform as R}from"./utils.js";import{worldToImage as A}from"./worldToImage.js";import{viewingLimit as P}from"../../../widgets/OrientedImageryViewer/constants.js";async function V(e,t,a){const{verticalFieldOfView:r,imageBoundaries:i,scalingFactor:n,farPlaneVertices:o,cameraLocation:c,pixelsToTransform:s,vecToPoint:f,pixelDepths:l}=S(e,t),m=new Array;return await j(s,o,i,f,t,m,c,n,r,a,l),Array.isArray(e)?m:m[0]}async function j(e,t,a,r,n,o,s,f,l,m,p){let h=n.averageElevation;const u=e.length;for(let y=0;y<u;y+=1){const u=e.at(y),d=L(t,a,u,r,n),w=p?.at(y);if("number"==typeof w){const e=F(d,s,f),t=w*f,a=[s[0]+e[0]*t,s[1]+e[1]*t,s[2]+e[2]*w];o.push(new i(a,n.cameraLocation.spatialReference));continue}if(m&&g("elevationSample"in m,v(m))){h=(await c(r(d),{x:u[0],y:u[1]},{...n,...m,farPlaneVertices:t.map(r)}))[2]}o.push(r(b(d,s,f,h,n.cameraPitch,l)))}}function F(e,t,a){const i=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2],c=Math.hypot(i,n)/a,s=Math.hypot(o,c)*a,f=r();return f[0]=i/s,f[1]=n/s,f[2]=o/s,f[2]=f[2]*a,f}function b(e,t,r,i,n,o){let c=a(e);const s=F(e,t,r);if(T(e[2],i,n,o)){const e=Math.abs((t[2]-i)/-s[2])*r;c=x(t,s,e,r)}else c[2]=i;return c}function T(e,t,a,r){return e<t||a+r/2<P}function L(e,t,a,r,i){let n=null;const o=9;let c,s=0,f=e,l=t;for(;s<=o;){const e=D(a,l,f,i);if(c=e.error,n=e.transformedPoint,g(c<=1,s===o))break;f=M(f,c,a,t),l=O(f,r,i),s++}return n}function O(e,t,a){return A(e.map(t),a).map(({x:e,y:t})=>[e,t,1])}function D(e,t,a,r){const{cameraLocation:n}=r,o=R(e,t,a),{x:c,y:s}=A(new i(o,n.spatialReference),r);return{transformedPoint:o,error:E(e,[c,s,1])}}function E(e,t){return Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1])}function S(t,a){const r=e(t)||"items"in t?t:[t],{cameraLocation:n,rotationMatrix:o}=a;if(h(r,n),u(o),9!==o?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix");const c=s(n.y,n.spatialReference),f=y({...a,scalingFactor:c}),l=A(f.map(e=>new i(e,n.spatialReference)),a),{vfov:m}=d(a.horizontalFieldOfView,a.verticalFieldOfView,a.cameraRoll);return{cameraLocation:n.toArray(),imageBoundaries:l.map(({x:e,y:t})=>[e,t,1]),verticalFieldOfView:m,farPlaneVertices:f,scalingFactor:c,pixelsToTransform:r.map(e=>[e.x,e.y,1]),vecToPoint:w(n.spatialReference),pixelDepths:r.map(e=>B(e)?e.depth:void 0)}}function B(e){return"depth"in e&&"number"==typeof e.depth}async function H(e,a,r){const{cameraHeading:c,cameraLocation:h,farDistance:u,imageHeight:y,imageWidth:d,verticalFieldOfView:w}=a,g=s(h.y,h.spatialReference),v=u*g,x=new Array,[M,R,A]=h.toArray(),P=Array.isArray(e)?e:[e];for(const s of P){let e,P;const V=B(s),j=V?s.depth*g:v;if(f(s))e=s.heading,P=s.pitch;else{const t=l({x:s.x,y:s.y},d,y);e=t.heading,P=t.pitch}e=(e+c)%360;const F=[M+Math.sin(t(e))*Math.sin(t(P))*j,R+Math.cos(t(e))*Math.sin(t(P))*j,A+-Math.cos(t(P))*(V?s.depth:u)];if(V){x.push(new i(F,h.spatialReference));continue}let T=a.averageElevation;if(r&&(n(r)||m(r.elevationSample))){T=(await o(new i(F,h.spatialReference),{heading:e,pitch:P},{...a,...r,farPlaneVertices:p(u,u).map(([e,t])=>new i([h.x+e,h.y+t],h.spatialReference))}))[2]}x.push(new i(b(F,h.toArray(),g,T,P,w),h.spatialReference))}return Array.isArray(e)?x:x[0]}export{V as imageToWorld,H as imageToWorldPanoramic};
2
+ import{isArrayLike as e}from"../../../core/arrayUtils.js";import{deg2rad as t}from"../../../core/mathUtils.js";import{clone as r,zeros as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../geometry/Point.js";import{isElevationSource as n}from"../core/ElevationSourceDefinitions.js";import{rectifyMapPointPanoramic as o,rectifyMapPoint as c}from"./rectifyMapPoint.js";import{getWebMercatorScalingFactor as s,hasAngles as f,convertPixelToHeadingPitch as l,adjustHorizonAngles as m,isElevationSampler as p,reducerFn as h,validatePixelsToTransform as u,validateRotationMatrix as y,computeFarplaneVertices as d,computeHFOVAndVFOV as w,vecToPoint as g,or as v,isUpdateElevationWithElevationSource as x,scaleAndAddWithFactor as R,computeNewReferenceCoordinates as M,projectiveTransform as P}from"./utils.js";import{worldToImage as A}from"./worldToImage.js";import{viewingLimit as V}from"../../../widgets/OrientedImageryViewer/constants.js";async function j(e,t,r){const{verticalFieldOfView:a,imageBoundaries:i,scalingFactor:n,farPlaneVertices:o,cameraLocation:c,pixelsToTransform:s,vecToPoint:f,pixelDepths:l}=S(e,t),m=new Array;return await F(s,o,i,f,t,m,c,n,a,r,l),Array.isArray(e)?m:m[0]}async function F(e,t,r,a,n,o,s,f,l,m,p){let h=n.averageElevation;const u=e.length;for(let y=0;y<u;y+=1){const u=e.at(y),d=O(t,r,u,a,n),w=p?.at(y);if("number"==typeof w){const e=b(d,s,f),t=w*f,r=[s[0]+e[0]*t,s[1]+e[1]*t,s[2]+e[2]*w];o.push(new i(r,n.cameraLocation.spatialReference));continue}if(m&&v("elevationSample"in m,x(m))){h=(await c(a(d),{x:u[0],y:u[1]},{...n,...m,farPlaneVertices:t.map(a)}))[2]}o.push(a(T(d,s,f,h,n.cameraPitch,l)))}}function b(e,t,r){const i=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2],c=Math.hypot(i,n)/r,s=Math.hypot(o,c)*r,f=a();return f[0]=i/s,f[1]=n/s,f[2]=o/s,f[2]=f[2]*r,f}function T(e,t,a,i,n,o){let c=r(e);const s=b(e,t,a);if(L(e[2],i,n,o)){const e=Math.abs((t[2]-i)/-s[2])*a;c=R(t,s,e,a)}else c[2]=i;return c}function L(e,t,r,a){return e<t||r+a/2<V}function O(e,t,r,a,i){let n=null;const o=9;let c,s=0,f=e,l=t;for(;s<=o;){const e=D(r,l,f,i);if(c=e.error,n=e.transformedPoint,v(c<=1,s===o))break;f=M(f,c,r,t),l=z(f,a,i),s++}return n}function z(e,t,r){return A(e.map(t),r).map(({x:e,y:t})=>[e,t,1])}function D(e,t,r,a){const{cameraLocation:n}=a,o=P(e,t,r),{x:c,y:s}=A(new i(o,n.spatialReference),a);return{transformedPoint:o,error:E(e,[c,s,1])}}function E(e,t){return Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1])}function S(t,r){const a=e(t)||"items"in t?t:[t],{cameraLocation:n,rotationMatrix:o}=r;if(u(a,n),y(o),9!==o?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix");const c=s(n.y,n.spatialReference),f=d({...r,scalingFactor:c}),l=A(f.map(e=>new i(e,n.spatialReference)),r),{vfov:m}=w(r.horizontalFieldOfView,r.verticalFieldOfView,r.cameraRoll);return{cameraLocation:n.toArray(),imageBoundaries:l.map(({x:e,y:t})=>[e,t,1]),verticalFieldOfView:m,farPlaneVertices:f,scalingFactor:c,pixelsToTransform:a.map(e=>[e.x,e.y,1]),vecToPoint:g(n.spatialReference),pixelDepths:a.map(e=>B(e)?e.depth:void 0)}}function B(e){return"depth"in e&&"number"==typeof e.depth}async function I(e,r,a){const{cameraLocation:c,farDistance:u,imageHeight:y,imageWidth:d,verticalFieldOfView:w,horizonPitch:g,horizonRoll:v,horizonYaw:x}=r,R=s(c.y,c.spatialReference),M=u*R,P=new Array,[A,V,j]=c.toArray(),F=Array.isArray(e)?e:[e];for(const s of F){let e,F;const b=B(s),L=b?s.depth*R:M;if(f(s))e=s.heading,F=s.pitch;else{const t=l({x:s.x,y:s.y},d,y),r=m(t.heading,t.pitch,[g,v,x],!0);e=r[0],F=r[1]}const O=[A+Math.sin(t(e))*Math.sin(t(F))*L,V+Math.cos(t(e))*Math.sin(t(F))*L,j+-Math.cos(t(F))*(b?s.depth:u)];if(b){P.push(new i(O,c.spatialReference));continue}let z=r.averageElevation;if(a&&(n(a)||p(a.elevationSample))){z=(await o(new i(O,c.spatialReference),{heading:e,pitch:F},{...r,...a,farPlaneVertices:h(u,u).map(([e,t])=>new i([c.x+e,c.y+t],c.spatialReference))}))[2]}P.push(new i(T(O,c.toArray(),R,z,F,w),c.spatialReference))}return Array.isArray(e)?P:P[0]}export{j as imageToWorld,I as imageToWorldPanoramic};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import t from"../../../core/Error.js";import{rad2deg as n,deg2rad as a}from"../../../core/mathUtils.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as i,fromValues as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as r}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as s,multiply as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as f,mul as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{sub as m,add as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{isSerializable as p}from"../../../core/support/jsonUtils.js";import g from"../../../geometry/Point.js";import{projectAsync as v}from"../../../geometry/projectionUtils.js";import{earth as M}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{ConstantElevation as w,isConstantElevation as y,isElevationSource as b}from"../core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as j}from"../core/utils.js";import{getElevationSampler as O}from"./updateElevationUtils.js";import{isNumber as F}from"../../../support/guards.js";import{defaultImageSphereSize as E}from"../../../widgets/PanoramicViewer/constants.js";function z(t,n,a){const[e,o,r,c]=n,[s,l,m,h]=a;P(e,o,r,c);const p=P(s,l,m,h),g=R(e,o,r,c),v=R(s,l,m,h),M=f(i(),g),d=u(i(),M,v),[x,w,y,b]=V(t,d);return[x/b,w/b,p?0:y/b]}function P(t,n,a,e){return 0===t[2]&&0===n[2]&&0===a[2]&&0===e[2]&&(t[2]=n[2]=a[2]=e[2]=1,!0)}function S(t){return 0===t?1:t}function V(t,n){const[a,e,i]=t,o=[0,0,0,0];return o[0]=a*n[0]+e*n[1]+i*n[2]+n[3],o[1]=a*n[4]+e*n[5]+i*n[6]+n[7],o[2]=a*n[8]+e*n[9]+i*n[10]+n[11],o[3]=S(a*n[12]+e*n[13]+i*n[14]+n[15]),o}function R(t,n,a,e){const c=N(r([...e,1]),f(new Array(16),o(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=c[0],l=c[1],u=c[2],m=i();return m[0]=s*t[0],m[1]=l*n[0],m[2]=u*a[0],m[3]=0,m[4]=s*t[1],m[5]=l*n[1],m[6]=u*a[1],m[7]=0,m[8]=s*t[2],m[9]=l*n[2],m[10]=u*a[2],m[11]=0,m[12]=s,m[13]=l,m[14]=u,m[15]=1,m}function D(t,n,a,e,i=c()){return i[0]=t[0]+n[0]*a,i[1]=t[1]+n[1]*a,i[2]=t[2]+n[2]*(a/e),i}function H(t,n,a){const e=c();return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*(n/a),e}function L(t,n){const[a,e,i]=t,o=c();return o[0]=a*n[0]+e*n[3]+i*n[6],o[1]=a*n[1]+e*n[4]+i*n[7],o[2]=a*n[2]+e*n[5]+i*n[8],o}function N(t,n){const[a,e,i,o]=t,r=new Array(4);return r[0]=a*n[0]+e*n[1]+i*n[2]+o*n[3],r[1]=a*n[4]+e*n[5]+i*n[6]+o*n[7],r[2]=a*n[8]+e*n[9]+i*n[10]+o*n[11],r[3]=a*n[12]+e*n[13]+i*n[14]+o*n[15],r}function A(n,i,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=e();switch(i){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const I={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function k(n,a,i=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=e();for(let t=0;t<3;t++){const[e,r]=a[t],c=A(n[t],e,r,i);l(o,c,o)}return o}function q(t,n=!0){return k(t,I.OPK,n)}function U(t,n=!0){return k(t,I.HPR,n)}function C(t,n,e){const i=Math.sin(a(e)),o=Math.cos(a(e)),r=[[t,0],[t,n],[0,n]];r.forEach((t,n)=>{r[n]=[o*t[0]-i*t[1],i*t[0]+o*t[1]]});const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function K(t,e){const i=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=e,u=a(c),m=a(s),h=l/Math.sqrt(1-f*Math.sin(u)**2),p=i/h,g=o/h,v=r/h,M=Math.cos(u)-Math.sin(u)*g+Math.cos(u)*v,d=Math.sin(u)+Math.cos(u)*g+Math.sin(u)*v,x=Math.sqrt(M**2+p**2),w=f*h*Math.sin(u),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(h*x))},b=y(u),j=Math.atan(i/(h*M))+m,O=n(b);return[n(j),O,i/(Math.cos(b)*Math.sin(j-m))-l/Math.sqrt(1-f*Math.sin(b)**2)]}function T(t,n,a){const e=360/n,i=180/a;return{heading:(t.x-n/2)*e,pitch:90-(t.y-a/2)*i}}function W(t,n,a,e=E/2){const{heading:i,pitch:o}=Y(t,e);return X(i,o,n,a)}function X(t,n,a,e){const i=t%360;return{x:a/2+(i<-180?i+360:i>180?i-360:i)/(360/a),y:e-n/(180/e),heading:t,pitch:n}}function Y(t,a){const e=n(Math.acos(-t.z/a));return{heading:n(Math.atan2(t.x,t.y)),pitch:e}}function Z(t,n,e=E/2){return[e*(Math.sin(a(t))*Math.sin(a(n))),e*(Math.cos(a(t))*Math.sin(a(n))),e*Math.cos(a(180-n))]}function G(t,n,a,e=E/2){const{heading:i,pitch:o}=T(t,n,a);return Z(i,o,e)}async function J(t,a,e){const i=await v(a,t.spatialReference,e);let o=n(Math.atan2(i.y-t.y,i.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function $(t,n,a){const e=Math.cos(a),i=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*e+o[2]*i,c=o[1]*e+o[3]*i,s=-o[0]*i+o[2]*e,l=-o[1]*i+o[3]*e;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const B=t=>t.toArray(),Q=(...t)=>t.some(t=>t);function _(t,n){if(Q(0===t.length,t.some(({x:t,y:n})=>Q(null==t,null==n)),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function tt(t,n){if(t.some(t=>null==t.z)||null==n.z)throw new Error("Input points and camera location must have z value")}function nt(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function at(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/M.radius))):1}const et=t=>n=>new g(n,t),it=t=>null!=t&&"queryExtent"in t;function ot(t,n,a,e){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map(([n,i])=>z(x(c(),a,[n,i,0]),e,t))}function rt({a0:t,a1:n,a2:a,b0:e,b1:i,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,e??c/2-.5,i??0,o].map(ct);return null!=s&&st(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function ct(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function st(t){return null!=t[1]&&null!=t[5]}function lt(t,n,a){const{cameraHeight:e,cameraPitch:i,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=bt(t,t.location.spatialReference),u=r??(l.z??0)-e;return{...mt(t,n,a),averageElevation:u,cameraPitch:i,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function ft(t,n,a,e){return wt(e)?q([e.omega,e.phi,e.kappa]):yt(e)?U([e.heading,e.pitch,e.roll]):U([t,n,a??0])}function ut(t,n,a){const{cameraHeading:e,cameraHeight:i,farDistance:o,horizontalFieldOfView:r,location:c,verticalFieldOfView:s}=bt(t,t.location.spatialReference);return{averageElevation:(c.z??0)-i,cameraLocation:c,cameraHeading:e,farDistance:o,horizontalFieldOfView:r,imageHeight:a,imageWidth:n,verticalFieldOfView:s}}function mt(t,n,a){const{a0:e,a1:i,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:u,cameraRoll:m,focalLength:h,horizontalFieldOfView:p,location:g,matrix:v,principalX:M,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:b,focalLength:j}=rt({a0:e,a1:i,a2:o,b0:r,b1:c,b2:s},n,a,h),O=v??ft(l,u,m,f),F=null!=M&&null!=d?[M,d]:void 0;return{affineTransformations:f?.affineTransformations??b,cameraLocation:g.clone(),focalLength:f?.focalLength??j,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??F,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:O,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const ht=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,pt=t=>b(t?.elevationSource)&&null!=t?.extent,gt=t=>y(t?.elevationSource),vt=async(t,n,a,e,i)=>{const o=j(t),r=n-a/o;return gt(e)?(e.elevationSource=new w({constantElevation:e.elevationSource.constantElevation/o}),e):ht(e)?e:pt(e)?{elevationSample:await O({...p(e.elevationSource)?e.elevationSource.toJSON():e.elevationSource,extent:e.extent},i),elevationSource:new w({constantElevation:r})}:{averageGroundElevation:r,spatialReference:t}},Mt=t=>F(t?.heading)&&F(t?.pitch),dt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function xt(t){const{cameraLocation:n,farDistance:i,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:l,verticalFieldOfView:f}=t,u=e();s(u,r);const p=2*Math.tan(a(f)/2)*i*l,g=2*Math.tan(a(o)/2)*i*l,v=L([0,0,-1],u),M=D([n.x,n.y,n.z],v,t.farDistance*l,l),d=L([0,1,0],u),x=L([1,0,0],u),w=H(d,p/2,l),y=H(x,g/2,l),b=m(c(),w,y),j=h(c(),w,y);return[h(c(),M,b),h(c(),M,j),m(c(),M,b),m(c(),M,j)]}const wt=t=>2===t?.type,yt=t=>1===t?.type;function bt(t,n,a=!0){const e=j(n),i=a?t.clone():t;return i.cameraHeight/=e,i.farDistance/=e,i.nearDistance/=e,y(i.elevationSource)&&(i.elevationSource.constantElevation/=e),i}export{xt as computeFarplaneVertices,C as computeHFOVAndVFOV,ot as computeNewReferenceCoordinates,Z as convertHeadingPitchToSphereVertex,X as convertOrientationToPixelLocation,G as convertPixelLocationToSphereVertex,T as convertPixelToHeadingPitch,Y as convertSphereVertexToOrientation,W as convertSphereVertexToPixelLocation,bt as convertToSRUnits,k as createRotationMatrix,U as createRotationMatrixFromHPR,q as createRotationMatrixFromOPK,rt as getAffinesAndFocalLength,ut as getImageToWorldPanoramicProperties,lt as getImageToWorldProperties,J as getInitialAngle,vt as getUpdateElevationProps,at as getWebMercatorScalingFactor,mt as getWorldToImageProperties,Mt as hasAngles,yt as hasHeadingPitchRoll,wt as hasOmegaPhiKappa,it as isElevationSampler,ht as isUpdateElevationWithElevationSampler,pt as isUpdateElevationWithElevationSource,gt as isUpdateUsingConstantElevation,st as isValidAffines,R as linearEquationSolve,K as ltpToGeographic,Q as or,B as pointToArray,z as projectiveTransform,dt as reducerFn,$ as rotatePixel,D as scaleAndAddWithFactor,H as scaleWithFactor,L as transformMat3,N as transformMat4,_ as validatePixelsToTransform,tt as validatePointsToTransform,nt as validateRotationMatrix,et as vecToPoint};
2
+ import t from"../../../core/Error.js";import{rad2deg as n,deg2rad as a}from"../../../core/mathUtils.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as i,fromValues as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as r,zeros as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as s}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{transpose as l,multiply as f}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as u,mul as h}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{scale as m,sub as p,add as g}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{isSerializable as v}from"../../../core/support/jsonUtils.js";import M from"../../../geometry/Point.js";import{projectAsync as d}from"../../../geometry/projectionUtils.js";import{earth as x}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as w}from"../../../geometry/support/spatialReferenceUtils.js";import{a as y}from"../../../chunks/vec3.js";import{ConstantElevation as b,isConstantElevation as j,isElevationSource as O}from"../core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as P}from"../core/utils.js";import{getElevationSampler as z}from"./updateElevationUtils.js";import{isNumber as R}from"../../../support/guards.js";import{defaultImageSphereSize as F}from"../../../widgets/PanoramicViewer/constants.js";function E(t,n,a){const[e,o,r,c]=n,[s,l,f,m]=a;S(e,o,r,c);const p=S(s,l,f,m),g=H(e,o,r,c),v=H(s,l,f,m),M=u(i(),g),d=h(i(),M,v),[x,w,y,b]=D(t,d);return[x/b,w/b,p?0:y/b]}function S(t,n,a,e){return 0===t[2]&&0===n[2]&&0===a[2]&&0===e[2]&&(t[2]=n[2]=a[2]=e[2]=1,!0)}function V(t){return 0===t?1:t}function D(t,n){const[a,e,i]=t,o=[0,0,0,0];return o[0]=a*n[0]+e*n[1]+i*n[2]+n[3],o[1]=a*n[4]+e*n[5]+i*n[6]+n[7],o[2]=a*n[8]+e*n[9]+i*n[10]+n[11],o[3]=V(a*n[12]+e*n[13]+i*n[14]+n[15]),o}function H(t,n,a,e){const r=I(s([...e,1]),u(new Array(16),o(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),c=r[0],l=r[1],f=r[2],h=i();return h[0]=c*t[0],h[1]=l*n[0],h[2]=f*a[0],h[3]=0,h[4]=c*t[1],h[5]=l*n[1],h[6]=f*a[1],h[7]=0,h[8]=c*t[2],h[9]=l*n[2],h[10]=f*a[2],h[11]=0,h[12]=c,h[13]=l,h[14]=f,h[15]=1,h}function L(t,n,a,e,i=c()){return i[0]=t[0]+n[0]*a,i[1]=t[1]+n[1]*a,i[2]=t[2]+n[2]*(a/e),i}function N(t,n,a){const e=c();return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*(n/a),e}function A(t,n){const[a,e,i]=t,o=c();return o[0]=a*n[0]+e*n[3]+i*n[6],o[1]=a*n[1]+e*n[4]+i*n[7],o[2]=a*n[2]+e*n[5]+i*n[8],o}function I(t,n){const[a,e,i,o]=t,r=new Array(4);return r[0]=a*n[0]+e*n[1]+i*n[2]+o*n[3],r[1]=a*n[4]+e*n[5]+i*n[6]+o*n[7],r[2]=a*n[8]+e*n[9]+i*n[10]+o*n[11],r[3]=a*n[12]+e*n[13]+i*n[14]+o*n[15],r}function Y(n,i,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=e();switch(i){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const k={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]],YPR:[[0,-1],[1,-1],[2,-1]]};function q(n,a,i=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=e();for(let t=0;t<3;t++){const[e,r]=a[t],c=Y(n[t],e,r,i);f(o,c,o)}return o}function U(t,n=!0){return q(t,k.OPK,n)}function C(t,n=!0){return q(t,k.HPR,n)}function K(t,n,e){const i=Math.sin(a(e)),o=Math.cos(a(e)),r=[[t,0],[t,n],[0,n]];r.forEach((t,n)=>{r[n]=[o*t[0]-i*t[1],i*t[0]+o*t[1]]});const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function T(t,e){const i=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=e,u=a(c),h=a(s),m=l/Math.sqrt(1-f*Math.sin(u)**2),p=i/m,g=o/m,v=r/m,M=Math.cos(u)-Math.sin(u)*g+Math.cos(u)*v,d=Math.sin(u)+Math.cos(u)*g+Math.sin(u)*v,x=Math.sqrt(M**2+p**2),w=f*m*Math.sin(u),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},b=y(u),j=Math.atan(i/(m*M))+h,O=n(b);return[n(j),O,i/(Math.cos(b)*Math.sin(j-h))-l/Math.sqrt(1-f*Math.sin(b)**2)]}function W(t,n,a){const e=360/n,i=180/a;return{heading:(t.x-n/2)*e,pitch:90-(t.y-a/2)*i}}function X(t,n,a,e,i=F/2){const{heading:o,pitch:r}=G(t,i),c=e?Rt(o,r,e):[o,r];return{heading:o,pitch:r,...Z(c[0],c[1],n,a)}}function Z(t,n,a,e){const i=t%360;return{x:a/2+(i<-180?i+360:i>180?i-360:i)/(360/a),y:e-n/(180/e)}}function G(t,a){const e=n(Math.acos(-t.z/a));return{heading:n(Math.atan2(t.x,t.y)),pitch:e}}function J(t,n){return[Math.sin(a(t))*Math.sin(a(n)),Math.cos(a(t))*Math.sin(a(n)),Math.cos(a(180-n))]}function $(t,n,a,e=F/2){const i=a?Rt(t,n,a,!0):[t,n];return m(r(),J(i[0],i[1]),e)}function B(t,n,a,e,i=F/2){const{heading:o,pitch:r}=W(t,n,a);return $(o,r,e,i)}async function Q(t,a,e){const i=await d(a,t.spatialReference,e);let o=n(Math.atan2(i.y-t.y,i.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function _(t,n,a){const e=Math.cos(a),i=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*e+o[2]*i,c=o[1]*e+o[3]*i,s=-o[0]*i+o[2]*e,l=-o[1]*i+o[3]*e;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const tt=t=>t.toArray(),nt=(...t)=>t.some(t=>t);function at(t,n){if(nt(0===t.length,t.some(({x:t,y:n})=>nt(null==t,null==n)),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function et(t,n){if(t.some(t=>null==t.z)||null==n.z)throw new Error("Input points and camera location must have z value")}function it(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function ot(t,n){return w(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/x.radius))):1}const rt=t=>n=>new M(n,t),ct=t=>null!=t&&"queryExtent"in t;function st(t,n,a,e){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map(([n,i])=>E(y(c(),a,[n,i,0]),e,t))}function lt({a0:t,a1:n,a2:a,b0:e,b1:i,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,e??c/2-.5,i??0,o].map(ft);return null!=s&&ut(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function ft(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function ut(t){return null!=t[1]&&null!=t[5]}function ht(t,n,a){const{cameraHeight:e,cameraPitch:i,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=Pt(t,t.location.spatialReference),u=r??(l.z??0)-e;return{...gt(t,n,a),averageElevation:u,cameraPitch:i,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function mt(t,n,a,e){return jt(e)?U([e.omega,e.phi,e.kappa]):Ot(e)?C([e.heading,e.pitch,e.roll]):C([t,n,a??0])}function pt(t,n,a){const{cameraHeading:e,cameraHeight:i,farDistance:o,horizontalFieldOfView:r,location:c,verticalFieldOfView:s}=Pt(t,t.location.spatialReference),l=(c.z??0)-i;let f=-e,u=0,h=0;if(t?.matrix){const{matrix:n}=t;[u,h,f]=zt(n)}return{averageElevation:l,cameraLocation:c,cameraHeading:e,farDistance:o,horizontalFieldOfView:r,imageHeight:a,imageWidth:n,verticalFieldOfView:s,horizonYaw:f,horizonPitch:u,horizonRoll:h}}function gt(t,n,a){const{a0:e,a1:i,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:u,cameraRoll:h,focalLength:m,horizontalFieldOfView:p,location:g,matrix:v,principalX:M,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:b,focalLength:j}=lt({a0:e,a1:i,a2:o,b0:r,b1:c,b2:s},n,a,m),O=v??mt(l,u,h,f),P=null!=M&&null!=d?[M,d]:void 0;return{affineTransformations:f?.affineTransformations??b,cameraLocation:g.clone(),focalLength:f?.focalLength??j,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??P,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:O,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const vt=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,Mt=t=>O(t?.elevationSource)&&null!=t?.extent,dt=t=>j(t?.elevationSource),xt=async(t,n,a,e,i)=>{const o=P(t),r=n-a/o;return dt(e)?(e.elevationSource=new b({constantElevation:e.elevationSource.constantElevation/o}),e):vt(e)?e:Mt(e)?{elevationSample:await z({...v(e.elevationSource)?e.elevationSource.toJSON():e.elevationSource,extent:e.extent},i),elevationSource:new b({constantElevation:r})}:{averageGroundElevation:r,spatialReference:t}},wt=t=>R(t?.heading)&&R(t?.pitch),yt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function bt(t){const{cameraLocation:n,farDistance:i,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:s,verticalFieldOfView:f}=t,u=e();l(u,r);const h=2*Math.tan(a(f)/2)*i*s,m=2*Math.tan(a(o)/2)*i*s,v=A([0,0,-1],u),M=L([n.x,n.y,n.z],v,t.farDistance*s,s),d=A([0,1,0],u),x=A([1,0,0],u),w=N(d,h/2,s),y=N(x,m/2,s),b=p(c(),w,y),j=g(c(),w,y);return[g(c(),M,b),g(c(),M,j),p(c(),M,b),p(c(),M,j)]}const jt=t=>2===t?.type,Ot=t=>1===t?.type;function Pt(t,n,a=!0){const e=P(n),i=a?t.clone():t;return i.cameraHeight/=e,i.farDistance/=e,i.nearDistance/=e,j(i.elevationSource)&&(i.elevationSource.constantElevation/=e),i}function zt(t){return[n(Math.asin(-t[6])),n(Math.atan(t[7]/t[8])),n(Math.atan2(t[3],t[0]))]}function Rt(t,n,a,e=!1){return Ft(J(t,n),a,e)}function Ft(t,a,i=!1){const o=i?l(e(),q(a,k.YPR)):q(a,k.YPR),r=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],c=t[0]*o[3]+t[1]*o[4]+t[2]*o[5],s=t[0]*o[6]+t[1]*o[7]+t[2]*o[8],f=n(Math.acos(-s));return[n(Math.atan2(r,c)),f]}export{Rt as adjustHorizonAngles,Ft as adjustHorizonAnglesVec3,bt as computeFarplaneVertices,K as computeHFOVAndVFOV,st as computeNewReferenceCoordinates,$ as convertHeadingPitchToSphereVertex,Z as convertOrientationToPixelLocation,B as convertPixelLocationToSphereVertex,W as convertPixelToHeadingPitch,G as convertSphereVertexToOrientation,X as convertSphereVertexToPixelLocation,Pt as convertToSRUnits,J as createMeshSpaceVector,q as createRotationMatrix,C as createRotationMatrixFromHPR,U as createRotationMatrixFromOPK,zt as extractHorizonAngles,lt as getAffinesAndFocalLength,pt as getImageToWorldPanoramicProperties,ht as getImageToWorldProperties,Q as getInitialAngle,xt as getUpdateElevationProps,ot as getWebMercatorScalingFactor,gt as getWorldToImageProperties,wt as hasAngles,Ot as hasHeadingPitchRoll,jt as hasOmegaPhiKappa,ct as isElevationSampler,vt as isUpdateElevationWithElevationSampler,Mt as isUpdateElevationWithElevationSource,dt as isUpdateUsingConstantElevation,ut as isValidAffines,H as linearEquationSolve,T as ltpToGeographic,nt as or,tt as pointToArray,E as projectiveTransform,yt as reducerFn,_ as rotatePixel,L as scaleAndAddWithFactor,N as scaleWithFactor,A as transformMat3,I as transformMat4,at as validatePixelsToTransform,et as validatePointsToTransform,it as validateRotationMatrix,rt as vecToPoint};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as o,sub as n}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{webMercatorToGeographic as e}from"../../../geometry/support/webMercatorUtils.js";import{getWebMercatorScalingFactor as i,convertOrientationToPixelLocation as c,validatePointsToTransform as s,validateRotationMatrix as m}from"./utils.js";import{normalizeDegrees as f}from"../../../widgets/OrientedImageryViewer/components/imageNavigationUtils.js";function l(t,a){const{cameraLocation:r,pointsToTransform:o,scalingFactor:n}=h(t,a.cameraLocation,a.rotationMatrix),e=new Array;return p(o,e,{...a,cameraLocation:r,scalingFactor:n,...b(a)}),Array.isArray(t)?e:e[0]}function u(t,a,r){return l(t?a.map(t=>e(t)):a,r).map(t=>({...t,z:1}))}function p(t,a,o){const{affineTransformations:e,cameraLocation:i,focalLengthX:c,focalLengthY:s,principalOffsetPoint:m,radialDistortionCoefficients:f,rotationMatrix:l,scalingFactor:u,tangentialDistortionCoefficients:p}=o;for(const g of t){const t=r();n(t,g,i),t[0]=t[0]/u,t[1]=t[1]/u;const o=-c*((l[0]*t[0]+l[3]*t[1]+l[6]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),h=-s*((l[1]*t[0]+l[4]*t[1]+l[7]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),y=o*o+h*h;let L=0,A=0,b=0,d=0,w=0,T=0,M=0;f&&(L=f[0]??0,A=f[1]??0,b=f[2]??0),p&&(d=p[0],w=p[1]),m&&(T=m[0]??0,M=m[1]??0);const N=1+L*y+A*y*y+b*y*y*y;let j=o*N+d*(y+2*o**2)+2*w*o*h,x=h*N+w*(y+2*h**2)+2*d*o*h;j+=T,x+=M;const F=Number(e[0])+Number(e[1])*j+Number(e[2])*x,v=Number(e[3])+Number(e[4])*j+Number(e[5])*x;a.push({x:F,y:v})}}function g(a,r){const{cameraHeading:n,imageHeight:e,imageWidth:s}=r,{cameraLocation:m,pointsToTransform:l}=y(a,r.cameraLocation),u=new Array,p=i(m[1],r.cameraLocation.spatialReference);for(const i of l){const a=o([m[0],m[1],m[2]*p],[i[0],i[1],i[2]*p]),r=[(i[0]-m[0])/a,(i[1]-m[1])/a,(i[2]-m[2])*p/a],l=0!==r[0]&&0!==r[1]?f(t(Math.atan2(r[0],r[1]))-n):0,g=t(Math.acos(-r[2]));u.push(c(l,g,s,e))}return Array.isArray(a)?u:u[0]}function h(t,a,r){const o=Array.isArray(t)||"items"in t?t:[t];s(o,a),L(o,a),m(r);const n=i(a.y,a.spatialReference);return{pointsToTransform:o.map(t=>t.toArray()),scalingFactor:n,cameraLocation:a.toArray()}}function y(t,a){const r=Array.isArray(t)||"items"in t?t:[t];return s(r,a),L(r,a),{pointsToTransform:r.map(t=>t.toArray()),cameraLocation:a.toArray()}}function L(t,a){if(t.some(t=>!t.spatialReference.equals(a.spatialReference)))throw new Error("Input points and camera location must have the same spatial reference")}function A(t){return null!=t?.focalLength}function b(t){if(A(t))return{focalLengthX:t.focalLength,focalLengthY:t.focalLength};const{imageWidth:r,imageHeight:o,horizontalFieldOfView:n,verticalFieldOfView:e}=t;return{focalLengthX:r/(2*Math.tan(a(n)/2)),focalLengthY:o/(2*Math.tan(a(e)/2))}}export{l as worldToImage,g as worldToImagePanoramic,u as worldToImageWithLTPFlag};
2
+ import{deg2rad as t}from"../../../core/mathUtils.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as r,sub as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{webMercatorToGeographic as n}from"../../../geometry/support/webMercatorUtils.js";import{getWebMercatorScalingFactor as e,adjustHorizonAnglesVec3 as i,convertOrientationToPixelLocation as c,convertSphereVertexToOrientation as s,validatePointsToTransform as f,validateRotationMatrix as m}from"./utils.js";function l(t,o){const{cameraLocation:r,pointsToTransform:a,scalingFactor:n}=g(t,o.cameraLocation,o.rotationMatrix),e=new Array;return h(a,e,{...o,cameraLocation:r,scalingFactor:n,...b(o)}),Array.isArray(t)?e:e[0]}function u(t,o,r){return l(t?o.map(t=>n(t)):o,r).map(t=>({...t,z:1}))}function h(t,r,n){const{affineTransformations:e,cameraLocation:i,focalLengthX:c,focalLengthY:s,principalOffsetPoint:f,radialDistortionCoefficients:m,rotationMatrix:l,scalingFactor:u,tangentialDistortionCoefficients:h}=n;for(const p of t){const t=o();a(t,p,i),t[0]=t[0]/u,t[1]=t[1]/u;const n=-c*((l[0]*t[0]+l[3]*t[1]+l[6]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),g=-s*((l[1]*t[0]+l[4]*t[1]+l[7]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),y=n*n+g*g;let L=0,A=0,b=0,T=0,w=0,x=0,d=0;m&&(L=m[0]??0,A=m[1]??0,b=m[2]??0),h&&(T=h[0],w=h[1]),f&&(x=f[0]??0,d=f[1]??0);const z=1+L*y+A*y*y+b*y*y*y;let F=n*z+T*(y+2*n**2)+2*w*n*g,N=g*z+w*(y+2*g**2)+2*T*n*g;F+=x,N+=d;const j=Number(e[0])+Number(e[1])*F+Number(e[2])*N,M=Number(e[3])+Number(e[4])*F+Number(e[5])*N;r.push({x:j,y:M})}}function p(t,o){const{imageHeight:a,imageWidth:n,horizonPitch:f,horizonRoll:m,horizonYaw:l}=o,{cameraLocation:u,pointsToTransform:h}=y(t,o.cameraLocation),p=new Array,g=e(u[1],o.cameraLocation.spatialReference);for(const e of h){const t=r([u[0],u[1],u[2]*g],[e[0],e[1],e[2]*g]),o=[(e[0]-u[0])/t,(e[1]-u[1])/t,(e[2]-u[2])*g/t],h=i(o,[f,m,l]);p.push({...s({x:o[0],y:o[1],z:o[2]},1),...c(h[0],h[1],n,a)})}return Array.isArray(t)?p:p[0]}function g(t,o,r){const a=Array.isArray(t)||"items"in t?t:[t];f(a,o),L(a,o),m(r);const n=e(o.y,o.spatialReference);return{pointsToTransform:a.map(t=>t.toArray()),scalingFactor:n,cameraLocation:o.toArray()}}function y(t,o){const r=Array.isArray(t)||"items"in t?t:[t];return f(r,o),L(r,o),{pointsToTransform:r.map(t=>t.toArray()),cameraLocation:o.toArray()}}function L(t,o){if(t.some(t=>!t.spatialReference.equals(o.spatialReference)))throw new Error("Input points and camera location must have the same spatial reference")}function A(t){return null!=t?.focalLength}function b(o){if(A(o))return{focalLengthX:o.focalLength,focalLengthY:o.focalLength};const{imageWidth:r,imageHeight:a,horizontalFieldOfView:n,verticalFieldOfView:e}=o;return{focalLengthX:r/(2*Math.tan(t(n)/2)),focalLengthY:a/(2*Math.tan(t(e)/2))}}export{l as worldToImage,p as worldToImagePanoramic,u as worldToImageWithLTPFlag};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r,subclass as a}from"../../../core/accessorSupport/decorators.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{setValidBoundary as m}from"../functions/pixelUtils.js";import u from"../transforms/GCSShiftTransform.js";import h from"../../support/RasterInfo.js";import f from"../../support/RasterStorageInfo.js";import p from"../../support/TileInfo.js";import{TilemapCache as d}from"../../support/TilemapCache.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends c{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,u={...this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null,...s.refreshParameters};let h,f;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...u,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);f=[];let a=0;for(const{data:s}of t)f.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;h=r.buffer}else{h=(await this.request(c,{query:u,responseType:"array-buffer",signal:s.signal})).data}if(!h)return null;const p=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(h,{width:p[0],height:p[1],planes:f?.length,offsets:f,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,M=Math.round((x.y-a.ymax)/I)%v,T=Math.round((x.y-a.ymin)/I)%v||v,_=i===y.minCol?w:0,j=t===y.minRow?M:0,O=i===y.maxCol?b:g,R=t===y.maxRow?T:v;return m(d,{x:_,y:j},{width:O-_,height:R-j}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):p.fromJSON(l.tileInfo);i(c);const[m,u]=this._computeMinMaxLOD(o,c),{extent:h,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=m.resolution,o.width=Math.ceil((h.xmax-h.xmin)/x.x-.1),o.height=Math.ceil((h.ymax-h.ymin)/x.y-.1));const b=m.level-u.level,[M,T]=c.size,_=[],j=[];w.forEach((e,t)=>{e.level>=u.level&&e.level<=m.level&&_.push({x:e.resolution,y:e.resolution}),t<w.length-1&&j.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),_.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(h,M,T,c.origin,_,b),R=_.length>1?_.slice(1):null;let z;l.transposeInfo&&(z={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const N=j.length<=1||j.length>=3&&j.slice(0,-1).every(e=>e===j[0])?j[0]??2:Math.round(10/(u.resolution/m.resolution)**(-1/b))/10;if(o.storageInfo=new f({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:N,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:z,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new d({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new h({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const i={...e,query:{...this.ioConfig.customFetchParameters,f:"json"}},s=x(this.url,this.sourceJSON,i),r=t.hasMultidimensions?this.request(`${this.url}/slices`,i).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return p.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return p.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return p.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new u,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("esri.layers.raster.datasets.ImageServerRaster")],g);const I=g;export{I as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r,subclass as a}from"../../../core/accessorSupport/decorators.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{setValidBoundary as m}from"../functions/pixelUtils.js";import u from"../transforms/GCSShiftTransform.js";import h from"../../support/RasterInfo.js";import f from"../../support/RasterStorageInfo.js";import p from"../../support/TileInfo.js";import{TilemapCache as d}from"../../support/TilemapCache.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends c{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,u={...this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null,...s.refreshParameters};let h,f;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...u,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);f=[];let a=0;for(const{data:s}of t)f.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;h=r.buffer}else{h=(await this.request(c,{query:u,responseType:"array-buffer",signal:s.signal})).data}if(!h)return null;const p=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(h,{width:p[0],height:p[1],planes:f?.length,offsets:f,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,_=i===y.minCol?w:0,j=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return m(d,{x:_,y:j},{width:O-_,height:R-j}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):p.fromJSON(l.tileInfo);i(c);const[m,u]=this._computeMinMaxLOD(o,c),{extent:h,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=m.resolution,o.width=Math.ceil((h.xmax-h.xmin)/x.x-.1),o.height=Math.ceil((h.ymax-h.ymin)/x.y-.1));const b=m.level-u.level,[T,M]=c.size,_=[],j=[];w.forEach((e,t)=>{e.level>=u.level&&e.level<=m.level&&_.push({x:e.resolution,y:e.resolution}),t<w.length-1&&j.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),_.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(h,T,M,c.origin,_,b),R=_.length>1?_.slice(1):null;let z;l.transposeInfo&&(z={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const N=j.length<=1||j.length>=3&&j.slice(0,-1).every(e=>e===j[0])?j[0]??2:Math.round(10/(u.resolution/m.resolution)**(-1/b))/10,P=!!l.bsq&&"Raster"===this.tileType;if(o.storageInfo=new f({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:N,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:P,transposeInfo:z,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new d({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new h({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const i={...e,query:{...this.ioConfig.customFetchParameters,f:"json"}},s=x(this.url,this.sourceJSON,i),r=t.hasMultidimensions?this.request(`${this.url}/slices`,i).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return p.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return p.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return p.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new u,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("esri.layers.raster.datasets.ImageServerRaster")],g);const I=g;export{I as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import has from"../../core/has.js";import{parseWhereClause as e,sqlTimestampOffsetLiteral as t}from"../../core/sql.js";import{visitSqlNode as r}from"../../core/sql/sqlVisitor.js";import{isAgolSecuredProxyService as n,isHostedAgolService as i}from"./arcgisLayerUrl.js";function o(e,t){if(!e||!has("featurelayer-relative-time-queries-enabled"))return 0;const r=n(e);return i(e)||r?(t??0)>0||r?has("featurelayer-relative-time-queries-bin-window-public")??1:has("featurelayer-relative-time-queries-bin-window-private")??60:0}function a(e){return(has("featurelayer-relative-time-queries-enabled")??!0)&&l(e)}const s=/(\w+)\s+(NOT\s+)?BETWEEN\s+CURRENT_TIMESTAMP\s*-\s*(?:INTERVAL\s*'([\d.]+)'\s*(SECOND|MINUTE|HOUR|DAY|MONTH|YEAR)|([0-9]*\.?[0-9]+))\s+AND\s+CURRENT_TIMESTAMP\b/gi;function l(e){return null!=e&&(s.lastIndex=0,s.test(e))}async function u(t,r,n=Date.now()){if(!t||!r||!l(t))return t;const i=await e(t);if(!i.isStandardized)return t;const[o,a]=f(n,r),s=c(i.parseTree).flatMap(e=>[{replacement:"BETWEEN"===e.operator?o:a,start:e.right.value[0].left.location.start.offset,end:e.right.value[0].left.location.end.offset},{replacement:"BETWEEN"===e.operator?a:o,start:e.right.value[1].location.start.offset,end:e.right.value[1].location.end.offset}]).sort((e,t)=>t.start-e.start);let u=t;for(const{replacement:e,start:l,end:f}of s)u=u.slice(0,l)+e+u.slice(f);return u}function f(e,r){const n=60*r*1e3,i=e-e%n,o=i+n;return[t(new Date(i),"date"),t(new Date(o),"date")]}function c(e){const t=[],n={"binary-expression":e=>{"AND"===e.operator||"OR"===e.operator?(r(e.left,n),r(e.right,n)):p(e)&&t.push(e)}};return r(e,n),t}function p(e){return"binary-expression"===e.type&&("BETWEEN"===e.operator||"NOTBETWEEN"===e.operator)&&"column-reference"===e.left.type&&E(e.right)}function E(e){if("expression-list"!==e.type||2!==e.value.length)return!1;const[t,r]=e.value;return m(t)&&d(r)}function m(e){return"binary-expression"===e.type&&d(e.left)&&y(e.right)}function d(e){return"current-time"===e.type&&"timestamp"===e.mode}function y(e){return"interval"===e.type&&"interval-period"===e.qualifier.type&&"string"===e.value.type}export{a as canConvertSqlRelativeTime,o as getRelativeTimeQueryBinWindowSize,l as hasSqlRelativeTime,u as sqlRelativeTimeToAbsolute};
2
+ import has from"../../core/has.js";import{getOrCreateMapValue as e}from"../../core/MapUtils.js";import{parseWhereClause as t,sqlTimestampOffsetLiteral as r}from"../../core/sql.js";import{visitSqlNode as n}from"../../core/sql/sqlVisitor.js";import{isAgolSecuredProxyService as i,isHostedAgolService as o}from"./arcgisLayerUrl.js";function a(e,t){if(!e||!has("featurelayer-relative-time-queries-enabled"))return 0;const r=i(e);return o(e)||r?(t??0)>0||r?has("featurelayer-relative-time-queries-bin-window-public")??1:has("featurelayer-relative-time-queries-bin-window-private")??60:0}function s(e){return(has("featurelayer-relative-time-queries-enabled")??!0)&&u(e)}function u(e){return null!=e&&/CURRENT_TIMESTAMP/gi.test(e)}const l=new WeakMap;async function f(r,n,i=Date.now()){if(!r||!n||!u(r))return r;const o=await t(r);if(!o.isStandardized)return r;const[a,s]=c(i,n),f=e(l,o,()=>p(o.parseTree)).flatMap(e=>[{replacement:"BETWEEN"===e.operator?a:s,start:e.right.value[0].left.location.start.offset,end:e.right.value[0].left.location.end.offset},{replacement:"BETWEEN"===e.operator?s:a,start:e.right.value[1].location.start.offset,end:e.right.value[1].location.end.offset}]).sort((e,t)=>t.start-e.start);let m=r;for(const{replacement:e,start:t,end:u}of f)m=m.slice(0,t)+e+m.slice(u);return m}function c(e,t){const n=60*t*1e3,i=e-e%n,o=i+n;return[r(new Date(i),"date"),r(new Date(o),"date")]}function p(e){const t=[],r={"binary-expression":e=>{"AND"===e.operator||"OR"===e.operator?(n(e.left,r),n(e.right,r)):m(e)&&t.push(e)}};return n(e,r),t}function m(e){return"binary-expression"===e.type&&("BETWEEN"===e.operator||"NOTBETWEEN"===e.operator)&&"column-reference"===e.left.type&&y(e.right)}function y(e){if("expression-list"!==e.type||2!==e.value.length)return!1;const[t,r]=e.value;return(d(t)||E(t))&&v(r)}function d(e){return"binary-expression"===e.type&&v(e.left)&&g(e.right)}function E(e){return"binary-expression"===e.type&&v(e.left)&&h(e.right)}function v(e){return"current-time"===e.type&&"timestamp"===e.mode}function g(e){return"interval"===e.type}function h(e){return"number"===e.type}export{s as canConvertSqlRelativeTime,a as getRelativeTimeQueryBinWindowSize,u as hasSqlRelativeTime,f as sqlRelativeTimeToAbsolute};
@@ -558,7 +558,7 @@ export interface ResultType {
558
558
  *
559
559
  * @since 5.0
560
560
  * @example
561
- * const exportCircuitProps = {
561
+ * const exportCircuitProperties = {
562
562
  * circuitNames: ["TESTCIRCUIT"],
563
563
  * exportAcknowledgement: false,
564
564
  * resultTypes: [
@@ -576,7 +576,7 @@ export interface ResultType {
576
576
  * ],
577
577
  * };
578
578
  *
579
- * const exportResult = await circuitManager.export(exportCircuitProps);
579
+ * const exportResult = await circuitManager.export(exportCircuitProperties);
580
580
  */
581
581
  export interface ExportCircuitsResultType {
582
582
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.0.0-next.120",
3
+ "version": "5.0.0-next.122",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -19,7 +19,7 @@
19
19
  "license": "SEE LICENSE IN LICENSE.md",
20
20
  "dependencies": {
21
21
  "@amcharts/amcharts5": "~5.15.5",
22
- "@arcgis/toolkit": "^5.0.0-next.157",
22
+ "@arcgis/toolkit": "^5.0.0-next.161",
23
23
  "@esri/arcgis-html-sanitizer": "~4.1.0",
24
24
  "@esri/calcite-components": "^5.0.0",
25
25
  "@vaadin/grid": "~25.0.3",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import e from"../../Color.js";import{getMetersPerUnitForSR as t}from"../../core/units.js";import{isFunctionRaster as n}from"../../layers/raster/datasets/datasetUtils.js";import a from"../../layers/support/Field.js";import r from"../ClassBreaksRenderer.js";import l from"../FlowRenderer.js";import s from"../RasterColormapRenderer.js";import o from"../RasterShadedReliefRenderer.js";import i from"../RasterStretchRenderer.js";import u from"../UniqueValueRenderer.js";import m from"../VectorFieldRenderer.js";import c from"./AuthoringInfo.js";import f from"./ClassBreakInfo.js";import{convertColorRampToColormap as p,predefinedJsonColorRamps as d}from"./colorRampUtils.js";import{isVectorFieldRendererSupported as b,isColormapRendererSupported as h,isUVRendererSupported as g,isClassBreaksSupported as v,isShadedReliefRendererSupported as y,isFlowRendererSupported as w}from"./rasterRendererChecks.js";import C from"./UniqueValueInfo.js";import x from"../visualVariables/ColorVariable.js";import M from"../visualVariables/SizeVariable.js";import R from"../visualVariables/support/ColorStop.js";import j from"../../rest/support/ClassBreaksDefinition.js";import{createGenerateRendererClassBreaks as V}from"../../rest/support/generateRendererUtils.js";import T from"../../rest/support/MultipartColorRamp.js";import S from"../../symbols/SimpleFillSymbol.js";const I=.25,k=T.fromJSON({type:"multipart",colorRamps:[{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]}),F=T.fromJSON(d[0]),L=new Set(["scientific","standard-time","vector-uv","vector-magdir","vector-u","vector-v","vector-magnitude","vector-direction"]);function q(e){return e.presetRenderers?.find(({method:t,value:n})=>"raster-function-template"===t?n===e.rasterFunctionName:"variable"===t&&n===e.variableName)}function B(e,t){const{attributeTable:n,colormap:a}=e;if(b(e)){const t=te(e);if(null!=t)return t}if(t?.rasterFunctionColorRamp){const n=U(e,t);return n.colorRamp=t.rasterFunctionColorRamp,n}if(null!=a){const t=X(e);if(null!=t)return t}if(null!=n){const t=_(e);if(null!=t)return t}return U(e,t)}function E(e,t=!1){const n=["raster-stretch"];return h(e,t)&&n.push("raster-colormap"),g(e)&&n.push("unique-value"),v(e,t)&&n.push("class-breaks"),y(e)&&n.push("raster-shaded-relief"),b(e)&&n.push("vector-field"),w(e)&&n.push("flow"),n}function z(e){return n(e)&&"Colormap"===e.rasterFunction.functionName?e.rasterFunction.colorRamp:void 0}function N(e,t,n){const a=["nearest","bilinear","cubic","majority"],r=n?.toLowerCase().replace("bicubic","cubic"),l=a.find(e=>e===r);if("Map"===t)return l??"bilinear";if("standard-time"===e.dataType)return l??"nearest";return"thematic"===e.dataType||e.attributeTable||e.colormap?"nearest"===l||"majority"===l?l:"nearest":l??"bilinear"}function U(e,t){e=W(e,t?.variableName);const{bandCount:n}=e;let{bandIds:a,stretchType:r}=t||{};a?.some(e=>e>=n)&&(a=null);let l=e.statistics,s=e.histograms;n>1?(a=a?.length?a:D(e),l=null==l?null:a?.map(e=>l[e]),s=null==s?null:a?.map(e=>s[e])):a=[0],null==r&&(r=G(e)),t?.includeStatisticsInStretch&&("percent-clip"===r||"histogram-equalization"===r)&&e.statistics?.length&&(r="min-max");let o=!1;switch(r){case"none":o=!1;break;case"percent-clip":o=!s?.length;break;default:o=!l?.length}const{dataType:u}=e,m=1===a?.length&&L.has(u)?k:null,c=new i({stretchType:r,dynamicRangeAdjustment:o,colorRamp:m,outputMin:0,outputMax:255,gamma:1===a?.length?[1]:[1,1,1],useGamma:!1});return"percent-clip"===r?c.maxPercent=c.minPercent=I:"standard-deviation"===r&&(c.numberOfStandardDeviations=2),o||null==e.multidimensionalInfo&&!t?.includeStatisticsInStretch||("percent-clip"===r?c.histograms=s:"min-max"!==r&&"standard-deviation"!==r||(c.customStatistics=l?.map(e=>({...e})))),c}function W(e,t){const{multidimensionalInfo:n}=e;if(!t||!n)return e;const a=n.variables.find(e=>e.name===t);if(!a)return e;if(e=e.clone(),a){const{statistics:t,histograms:n}=a;t?.length&&(e.statistics=t.map(e=>({min:e.min,max:e.max,avg:e.avg,stddev:e.stddev}))),n?.length&&(e.histograms=n)}return e}function D(e){const t=e.bandCount;if(1===t)return null;if(2===t)return[0];const{bandInfos:n}=e;let a;if(n.length===t){const{red:e,green:t,blue:r,nir:l}=A(n);null!=e&&null!=t&&null!=r?a=[e,t,r]:null!=l&&null!=e&&null!=t&&(a=[l,e,t])}return!a&&t>=3&&(a=[0,1,2]),a}function O(e,t){const n=e.bandInfos.map(({name:e})=>e);return t?.length?t.map(e=>n[e]):n}function A(e){const t={};for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();"red"===a?t.red=n:"green"===a?t.green=n:"blue"===a?t.blue=n:"nearinfrared"!==a&&"nearinfrared_1"!==a&&"nir"!==a||(t.nir=n)}if(null==t.blue||null==t.green||null==t.red||null==t.nir){const n=P(e);if(t.blue??=J(n,480),t.green??=J(n,550),t.red??=J(n,660),null==t.nir){const a=P(e,800);t.nir=J(a,810)??J(n,810)}}return t}function J(e,t,n=60){let a,r=n;for(const l of e){const e=Math.abs(l.wavelength-t);e<=r&&(r=e,a=l.index)}return a}function P(e,t){return e.map(({name:e,minWavelength:n,maxWavelength:a},r)=>{if(/thermal/i.test(e)||/pan/i.test(e))return null;if(null!=t&&null!=a&&a<t)return null;return{wavelength:null!=n&&null!=a?(n+a)/2:n??a??0,index:r}}).filter(e=>null!=e)}function G(e){let t="percent-clip";const{pixelType:n,dataType:a,histograms:r,statistics:l,multidimensionalInfo:s}=e,o=L.has(a)||"generic"===a&&null!=s;return"u8"!==n||"processed"!==a&&null!=r&&null!=l?"u8"===n||"elevation"===a||o?t="min-max":null!=r?t="percent-clip":null!=l&&(t="min-max"):t="none",t}function _(t,n,a,r){if(!g(t,n))return null;const{attributeTable:l,statistics:s}=t,o=H(l,n),i=Q(l,"red"),m=Q(l,"green"),f=Q(l,"blue"),d=new c,b=[],h=new Set,v=!!(i&&m&&f);if(null!=l)l.features.forEach(t=>{const n=t.attributes[o.name];if(!h.has(t.attributes[o.name])&&null!=n){h.add(n);const a=v&&("single"===i.type||"double"===i.type)&&("single"===m.type||"double"===m.type)&&("single"===f.type||"double"===f.type)&&!l.features.some(e=>e.attributes[i.name]>1||e.attributes[m.name]>1||e.attributes[f.name]>1),r=a?255:1;b.push(new C({value:t.attributes[o.name],label:t.attributes[o.name]+"",symbol:new S({style:"solid",outline:null,color:new e(v?[t.attributes[i.name]*r,t.attributes[m.name]*r,t.attributes[f.name]*r,1]:[0,0,0,0])})}))}});else if(s?.[0])for(let u=s[0].min;u<=s[0].max;u++)b.push(new C({value:u,label:u.toString(),symbol:new S({style:"solid",outline:null,color:new e([0,0,0,0])})}));if(b.sort((e,t)=>e.value&&"string"==typeof e.value.valueOf()?0:e.value>t.value?1:-1),!v){const t=p(F,{numColors:b.length});b.forEach((n,a)=>n.symbol.color=new e(t[a].slice(1,4))),d.colorRamp=F}if(a||r){const t=a||p(r,{numColors:b.length}).map(e=>e.slice(1));b.forEach((n,a)=>n.symbol.color=new e(t[a])),d.colorRamp=r}return new u({field:o.name,uniqueValueInfos:b,authoringInfo:d})}function H(e,t,n){let r;return null!=e?(r=t?e.fields.find(e=>t.toLowerCase()===e.name.toLowerCase()):K(e.fields),r||(n||(r=e.fields.find(e=>"string"===e.type)),r||(r=Q(e,"value")))):r=new a({name:"value"}),r}function K(e){let t;for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();if("string"===e[n].type){if(a.startsWith("class")){t=e[n];break}null==t&&(a.endsWith("name")||a.endsWith("type"))&&(t=e[n])}}return t}function Q(e,t){return null==e?null:e.fields.find(e=>e.name.toLowerCase()===t)}function X(e){if(!h(e))return null;let t;const{attributeTable:n,colormap:a}=e;if(null!=n){const e=Q(n,"value"),a=H(n,null,!0);"string"===a.type&&(t={},n.features.forEach(n=>{const r=n.attributes;t[r[e.name]]=a?r[a.name]:r[e.name]}))}return s.createFromColormap(a,t)}function Y(e,n="traditional"){if(!y(e))return null;const{extent:a}=e,r=a.width*t(a.spatialReference);return new o({hillshadeType:n,scalingType:r>5e6?"adjusted":"none"})}function Z(e,t){e=W(e,t?.variableName);const{attributeTable:n}=e;if(!v(e))return null;const a=null!=e.histograms?e.histograms[0]:null,l=null!=t?.numClasses&&isFinite(t?.numClasses)?t.numClasses:5,s=new c({classificationMethod:t?.classificationMethod,colorRamp:t?.colorRamp});let o=t?.field||"value";const i=[],u=[],m=1e3,d=null!=n,b=d&&n.fields.find(e=>"count"===e.name.toLowerCase()),h=d?n.fields.find(e=>e.name.toLowerCase()===o.toLowerCase()):void 0;if(h&&d){o=h.name;const e=n.features.length;let t=0;n.features.forEach(n=>t+=(b?n.attributes[b.name]:50)/e),n.features.forEach(n=>{const a=n.attributes[h.name],r=b?n.attributes[b.name]:50;if(r>0){u.push(r);const n=Math.max(1,Math.round(r/e/t*m));for(let e=0;e<n;e++)i.push(a)}})}else{const{pixelType:t}=e,r=(a.max-a.min)/a.size,l=t.includes("s")||t.includes("u"),s=l&&1===r?Math.floor(a.min+.5):a.min,o=l&&1===r?Math.floor(a.max-.5):a.max,c=a.size;let f,p=0;a.counts.forEach(e=>p+=e/c),a.counts.forEach((e,t)=>{if(e>0){u.push(e);const l=Math.max(1,Math.round(e/c/p*m));f=d?n.features[t].attributes[h.name]:0===t?s:t===c-1?o:a.min+r*(t+.5);for(let e=0;e<l;e++)i.push(f)}})}const g=t?.classificationMethod||"natural-breaks";let y=t?.definedInterval;"defined-interval"!==g||y||(y=$(e,h,l));const w=V({values:i,valueFrequency:u,normalizationTotal:null,definition:new j({classificationMethod:g,breakCount:l,definedInterval:y})});let C=t?.colors;if(!C){const e=t?.colorRamp||k;s.colorRamp=e;const n=p(e,{numColors:w.classBreaks.length,interpolateAlpha:!0});C=n.map(e=>e.slice(1))}const x=w.classBreaks.map((e,t)=>new f({minValue:e.minValue,maxValue:e.maxValue,label:e.label,symbol:new S({color:C[t]})}));return new r({field:o,classBreakInfos:x,authoringInfo:s})}function $(e,t,n){let a=0,r=0;if(null!=e.attributeTable){const n=e.attributeTable;a=r=n.features[0].attributes[t.name],n.features.forEach(e=>{const n=e.attributes[t.name];n<a&&(a=n),n>r&&(r=n)})}else if(null!=e.histograms){const t=e.histograms;a=t[0].min,r=t[0].max}return(r-a)/n}const ee=new Map([["m/s","meter-per-second"],["km/h","kilometer-per-hour"],["knots","knots"],["ft/s","feet-per-second"],["mph","mile-per-hour"]]);function te(e){if(!b(e))return null;let t;if(null!=e.statistics&&e.statistics.length&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=le(e.dataType,e.statistics);t=[new M({field:"Magnitude",minSize:10,maxSize:40,minDataValue:n,maxDataValue:a})]}const n=null!=e.multidimensionalInfo?ee.get(e.multidimensionalInfo.variables[0].unit):void 0,a=new m({visualVariables:t,inputUnit:n,rotationType:"geographic"});return a.visualVariables=[...a.sizeVariables,...a.rotationVariables],a}function ne(e){return{color:e.symbolLayers[0].material?.color,type:"esriSFS",style:"esriSFSSolid"}}function ae(e){if("uniqueValue"===e.type){const t=e.uniqueValueInfos,n=t?.[0].symbol;return n?.symbolLayers?.length&&(e.uniqueValueInfos=t?.map(e=>({value:e.value,label:e.label,symbol:e.symbol?ne(e.symbol):null}))),e}if("classBreaks"===e.type){const t=e.classBreakInfos,n=t[0].symbol;return n?.symbolLayers?.length&&(e.classBreakInfos=t.map(e=>({classMinValue:e.classMinValue,classMaxValue:e.classMaxValue,label:e.label,symbol:e.symbol?ne(e.symbol):null}))),e}return e}function re(t){if(!w(t))return null;let n;if(null!=t.statistics&&t.statistics.length>0&&("vector-magdir"===t.dataType||"vector-uv"===t.dataType)){const{minMagnitude:a,maxMagnitude:r}=le(t.dataType,t.statistics);n=[new x({field:"Magnitude",stops:[new R({value:a,color:new e("#1020c0")}),new R({value:r,color:new e("#c02010")})]})]}return new l({visualVariables:n})}function le(e,t){let n,a;if("vector-magdir"===e)n=t[0].min,a=t[0].max;else{const e=t[0].min,r=t[0].max,l=t[1].min,s=t[1].max;n=0,a=Math.max(Math.abs(e),Math.abs(l),Math.abs(r),Math.abs(s))}return{minMagnitude:n,maxMagnitude:a}}export{Z as createClassBreaksRenderer,X as createColormapRenderer,B as createDefaultRenderer,re as createFlowRenderer,Y as createShadedReliefRenderer,U as createStretchRenderer,_ as createUVRenderer,te as createVectorFieldRenderer,le as estimateMagnitudeRange,O as getBandNames,H as getClassField,D as getDefaultBandCombination,N as getDefaultInterpolation,$ as getDefinedInterval,Q as getField,z as getFunctionColorRamp,E as getSupportedRendererTypes,W as getVariableRasterInfo,A as getWellKnownBandIndexes,q as matchPresetRenderer,ae as normalizeRendererJSON};
2
+ import e from"../../Color.js";import{getMetersPerUnitForSR as t}from"../../core/units.js";import{isFunctionRaster as n}from"../../layers/raster/datasets/datasetUtils.js";import a from"../../layers/support/Field.js";import r from"../ClassBreaksRenderer.js";import l from"../FlowRenderer.js";import s from"../RasterColormapRenderer.js";import i from"../RasterShadedReliefRenderer.js";import o from"../RasterStretchRenderer.js";import u from"../UniqueValueRenderer.js";import m from"../VectorFieldRenderer.js";import c from"./AuthoringInfo.js";import f from"./ClassBreakInfo.js";import{convertColorRampToColormap as p,predefinedJsonColorRamps as d}from"./colorRampUtils.js";import{isVectorFieldRendererSupported as b,isColormapRendererSupported as h,isUVRendererSupported as g,isClassBreaksSupported as v,isShadedReliefRendererSupported as y,isFlowRendererSupported as w}from"./rasterRendererChecks.js";import C from"./UniqueValueInfo.js";import x from"../visualVariables/ColorVariable.js";import M from"../visualVariables/SizeVariable.js";import R from"../visualVariables/support/ColorStop.js";import j from"../../rest/support/ClassBreaksDefinition.js";import{createGenerateRendererClassBreaks as V}from"../../rest/support/generateRendererUtils.js";import I from"../../rest/support/MultipartColorRamp.js";import T from"../../symbols/SimpleFillSymbol.js";const S=.25,k=I.fromJSON({type:"multipart",colorRamps:[{algorithm:"esriCIELabAlgorithm",fromColor:[0,0,255],toColor:[0,255,255]},{algorithm:"esriCIELabAlgorithm",fromColor:[0,255,255],toColor:[255,255,0]},{algorithm:"esriCIELabAlgorithm",fromColor:[255,255,0],toColor:[255,0,0]}]}),L=I.fromJSON(d[0]),F=new Set(["scientific","standard-time","vector-uv","vector-magdir","vector-u","vector-v","vector-magnitude","vector-direction"]);function E(e){return e.presetRenderers?.find(({method:t,value:n})=>"raster-function-template"===t?n===e.rasterFunctionName:"variable"===t&&n===e.variableName)}function q(e,t){const{attributeTable:n,colormap:a}=e;if(b(e)){const t=te(e);if(null!=t)return t}if(t?.rasterFunctionColorRamp){const n=A(e,t);return n.colorRamp=t.rasterFunctionColorRamp,n}if(null!=a){const t=X(e);if(null!=t)return t}if(null!=n){const t=_(e);if(null!=t)return t}return A(e,t)}function B(e,t=!1){const n=["raster-stretch"];return h(e,t)&&n.push("raster-colormap"),g(e)&&n.push("unique-value"),v(e,t)&&n.push("class-breaks"),y(e)&&n.push("raster-shaded-relief"),b(e)&&n.push("vector-field"),w(e)&&n.push("flow"),n}function z(e){return n(e)&&"Colormap"===e.rasterFunction.functionName?e.rasterFunction.colorRamp:void 0}function N(e,t,n){const a=["nearest","bilinear","cubic","majority"],r=n?.toLowerCase().replace("bicubic","cubic"),l=a.find(e=>e===r);if("Map"===t)return l??"bilinear";if("standard-time"===e.dataType)return l??"nearest";return"thematic"===e.dataType||e.attributeTable||e.colormap?"nearest"===l||"majority"===l?l:"nearest":l??"bilinear"}function A(e,t){e=U(e,t?.variableName);const{bandCount:n}=e;let{bandIds:a,stretchType:r}=t||{};a?.some(e=>e>=n)&&(a=null);let l=e.statistics,s=e.histograms;n>1?(a=a?.length?a:W(e),l=null==l?null:a?.map(e=>l[e]),s=null==s?null:a?.map(e=>s[e])):a=[0],null==r&&(r=G(e)),t?.includeStatisticsInStretch&&("percent-clip"===r||"histogram-equalization"===r)&&e.statistics?.length&&(r="min-max");let i=!1;switch(r){case"none":i=!1;break;case"percent-clip":i=!s?.length;break;default:i=!l?.length}const{dataType:u}=e,m=1===a?.length&&F.has(u)?k:null,c=new o({stretchType:r,dynamicRangeAdjustment:i,colorRamp:m,outputMin:0,outputMax:255,gamma:1===a?.length?[1]:[1,1,1],useGamma:!1});return"percent-clip"===r?c.maxPercent=c.minPercent=S:"standard-deviation"===r&&(c.numberOfStandardDeviations=2),i||null==e.multidimensionalInfo&&!t?.includeStatisticsInStretch||("percent-clip"===r?c.histograms=s:"min-max"!==r&&"standard-deviation"!==r||(c.customStatistics=l?.map(e=>({...e})))),c}function U(e,t){const{multidimensionalInfo:n}=e;if(!t||!n)return e;const a=n.variables.find(e=>e.name===t);if(!a)return e;if(e=e.clone(),a){const{statistics:t,histograms:n}=a;t?.length&&(e.statistics=t.map(e=>({min:e.min,max:e.max,avg:e.avg,stddev:e.stddev}))),n?.length&&(e.histograms=n)}return e}function W(e){const t=e.bandCount;if(1===t)return null;if(2===t)return[0];const{bandInfos:n}=e;let a;if(n.length===t){const{red:e,green:t,blue:r,nir:l}=O(n);null!=e&&null!=t&&null!=r?a=[e,t,r]:null!=l&&null!=e&&null!=t&&(a=[l,e,t])}return!a&&t>=3&&(a=[0,1,2]),a}function D(e,t){const n=e.bandInfos.map(({name:e})=>e);return t?.length?t.map(e=>n[e]):n}function O(e){const t={};for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();"red"===a?t.red=n:"green"===a?t.green=n:"blue"===a?t.blue=n:"nearinfrared"!==a&&"nearinfrared_1"!==a&&"nir"!==a||(t.nir=n)}if(null==t.blue||null==t.green||null==t.red||null==t.nir){const n=P(e);if(t.blue??=J(n,480),t.green??=J(n,550),t.red??=J(n,660),null==t.nir){const a=P(e,800);t.nir=J(a,810)??J(n,810)}}return t}function J(e,t,n=60){let a,r=n;for(const l of e){const e=Math.abs(l.wavelength-t);e<=r&&(r=e,a=l.index)}return a}function P(e,t){return e.map(({name:e,minWavelength:n,maxWavelength:a},r)=>{if(/thermal/i.test(e)||/pan/i.test(e))return null;if(null!=t&&null!=a&&a<t)return null;return{wavelength:null!=n&&null!=a?(n+a)/2:n??a??0,index:r}}).filter(e=>null!=e)}function G(e){let t="percent-clip";const{pixelType:n,dataType:a,histograms:r,statistics:l,multidimensionalInfo:s}=e,i=F.has(a)||"generic"===a&&null!=s;return"u8"!==n||"processed"!==a&&null!=r&&null!=l?"u8"===n||"elevation"===a||i?t="min-max":null!=r?t="percent-clip":null!=l&&(t="min-max"):t="none",t}function _(t,n,a,r){if(!g(t,n))return null;const{attributeTable:l,statistics:s}=t,i=H(l,n),o=Q(l,"red"),m=Q(l,"green"),f=Q(l,"blue"),d=new c,b=[],h=new Set,v=!!(o&&m&&f);if(null!=l)l.features.forEach(t=>{const n=t.attributes[i.name];if(!h.has(t.attributes[i.name])&&null!=n){h.add(n);const a=v&&("single"===o.type||"double"===o.type)&&("single"===m.type||"double"===m.type)&&("single"===f.type||"double"===f.type)&&!l.features.some(e=>e.attributes[o.name]>1||e.attributes[m.name]>1||e.attributes[f.name]>1),r=a?255:1;b.push(new C({value:t.attributes[i.name],label:t.attributes[i.name]+"",symbol:new T({style:"solid",outline:null,color:new e(v?[t.attributes[o.name]*r,t.attributes[m.name]*r,t.attributes[f.name]*r,1]:[0,0,0,0])})}))}});else if(s?.[0])for(let u=s[0].min;u<=s[0].max;u++)b.push(new C({value:u,label:u.toString(),symbol:new T({style:"solid",outline:null,color:new e([0,0,0,0])})}));if(b.sort((e,t)=>e.value&&"string"==typeof e.value.valueOf()?0:e.value>t.value?1:-1),!v){const t=p(L,{numColors:b.length});b.forEach((n,a)=>n.symbol.color=new e(t[a].slice(1,4))),d.colorRamp=L}if(a||r){const t=a||p(r,{numColors:b.length}).map(e=>e.slice(1));b.forEach((n,a)=>n.symbol.color=new e(t[a])),d.colorRamp=r}return new u({field:i.name,uniqueValueInfos:b,authoringInfo:d})}function H(e,t,n){let r;return null!=e?(r=t?e.fields.find(e=>t.toLowerCase()===e.name.toLowerCase()):K(e.fields),r||(n||(r=e.fields.find(e=>"string"===e.type)),r||(r=Q(e,"value")))):r=new a({name:"value"}),r}function K(e){let t;for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();if("string"===e[n].type){if(a.startsWith("class")){t=e[n];break}null==t&&(a.endsWith("name")||a.endsWith("type"))&&(t=e[n])}}return t}function Q(e,t){return null==e?null:e.fields.find(e=>e.name.toLowerCase()===t)}function X(e){if(!h(e))return null;let t;const{attributeTable:n,colormap:a}=e;if(null!=n){const e=Q(n,"value"),a=H(n,null,!0);"string"===a.type&&(t={},n.features.forEach(n=>{const r=n.attributes;t[r[e.name]]=a?r[a.name]:r[e.name]}))}return s.createFromColormap(a,t)}function Y(e,n="traditional"){if(!y(e))return null;const{extent:a}=e,r=a.width*t(a.spatialReference);return new i({hillshadeType:n,scalingType:r>5e6?"adjusted":"none"})}function Z(e,t){e=U(e,t?.variableName);const{attributeTable:n}=e;if(!v(e))return null;const a=null!=e.histograms?e.histograms[0]:null,l=null!=t?.numClasses&&isFinite(t?.numClasses)?t.numClasses:5,s=new c({classificationMethod:t?.classificationMethod,colorRamp:t?.colorRamp});let i=t?.field||"value";const o=[],u=[],m=1e3,d=null!=n,b=d&&n.fields.find(e=>"count"===e.name.toLowerCase()),h=d?n.fields.find(e=>e.name.toLowerCase()===i.toLowerCase()):void 0;if(h&&d){i=h.name;const e=n.features.length;let t=0;n.features.forEach(n=>t+=(b?n.attributes[b.name]:50)/e),n.features.forEach(n=>{const a=n.attributes[h.name],r=b?n.attributes[b.name]:50;if(r>0){u.push(r);const n=Math.max(1,Math.round(r/e/t*m));for(let e=0;e<n;e++)o.push(a)}})}else{const{pixelType:t}=e,r=(a.max-a.min)/a.size,l=t.includes("s")||t.includes("u"),s=l&&1===r?Math.floor(a.min+.5):a.min,i=l&&1===r?Math.floor(a.max-.5):a.max,c=a.size;let f,p=0;a.counts.forEach(e=>p+=e/c),a.counts.forEach((e,t)=>{if(e>0){u.push(e);const l=Math.max(1,Math.round(e/c/p*m));f=d?n.features[t].attributes[h.name]:0===t?s:t===c-1?i:a.min+r*(t+.5);for(let e=0;e<l;e++)o.push(f)}})}const g=t?.classificationMethod||"natural-breaks";let y=t?.definedInterval;"defined-interval"!==g||y||(y=$(e,h,l));const w=V({values:o,valueFrequency:u,normalizationTotal:null,definition:new j({classificationMethod:g,breakCount:l,definedInterval:y})});let C=t?.colors;if(!C){const e=t?.colorRamp||k;s.colorRamp=e;const n=p(e,{numColors:w.classBreaks.length,interpolateAlpha:!0});C=n.map(e=>e.slice(1))}const x=w.classBreaks.map((e,t)=>new f({minValue:e.minValue,maxValue:e.maxValue,label:e.label,symbol:new T({color:C[t]})}));return new r({field:i,classBreakInfos:x,authoringInfo:s})}function $(e,t,n){let a=0,r=0;if(null!=e.attributeTable){const n=e.attributeTable;a=r=n.features[0].attributes[t.name],n.features.forEach(e=>{const n=e.attributes[t.name];n<a&&(a=n),n>r&&(r=n)})}else if(null!=e.histograms){const t=e.histograms;a=t[0].min,r=t[0].max}return(r-a)/n}const ee=new Map([["m/s","meter-per-second"],["km/h","kilometer-per-hour"],["knots","knots"],["ft/s","feet-per-second"],["mph","mile-per-hour"]]);function te(e){if(!b(e))return null;let t;if(null!=e.statistics&&e.statistics.length&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=le(e.dataType,e.statistics);t=[new M({field:"Magnitude",minSize:10,maxSize:40,minDataValue:n,maxDataValue:a})]}const n=null!=e.multidimensionalInfo?ee.get(e.multidimensionalInfo.variables[0].unit):void 0,a=new m({visualVariables:t,inputUnit:n,rotationType:"geographic"});return a.visualVariables=[...a.sizeVariables,...a.rotationVariables],a}function ne(e){return{color:e.symbolLayers[0].material?.color,type:"esriSFS",style:"esriSFSSolid"}}function ae(e){if("uniqueValue"===e.type){const t=e.uniqueValueInfos,n=t?.[0].symbol;return n?.symbolLayers?.length&&(e.uniqueValueInfos=t?.map(e=>({value:e.value,label:e.label,symbol:e.symbol?ne(e.symbol):null}))),e}if("classBreaks"===e.type){const t=e.classBreakInfos,n=t[0].symbol;return n?.symbolLayers?.length&&(e.classBreakInfos=t.map(e=>({classMinValue:e.classMinValue,classMaxValue:e.classMaxValue,label:e.label,symbol:e.symbol?ne(e.symbol):null}))),e}return e}function re(t){if(!w(t))return null;let n;if(null!=t.statistics&&t.statistics.length>0&&("vector-magdir"===t.dataType||"vector-uv"===t.dataType)){const{minMagnitude:a,maxMagnitude:r}=le(t.dataType,t.statistics);n=[new x({field:"Magnitude",stops:[new R({value:a,color:new e("#1020c0")}),new R({value:r,color:new e("#c02010")})]})]}return new l({visualVariables:n})}function le(e,t){let n,a;if("vector-magdir"===e)n=t[0].min,a=t[0].max;else{const e=t[0].min,r=t[0].max,l=t[1].min,s=t[1].max;n=0,a=Math.max(Math.abs(e),Math.abs(l),Math.abs(r),Math.abs(s))}return{minMagnitude:n,maxMagnitude:a}}export{Z as createClassBreaksRenderer,X as createColormapRenderer,q as createDefaultRenderer,re as createFlowRenderer,Y as createShadedReliefRenderer,A as createStretchRenderer,_ as createUVRenderer,te as createVectorFieldRenderer,le as estimateMagnitudeRange,D as getBandNames,H as getClassField,W as getDefaultBandCombination,N as getDefaultInterpolation,$ as getDefinedInterval,Q as getField,z as getFunctionColorRamp,B as getSupportedRendererTypes,U as getVariableRasterInfo,O as getWellKnownBandIndexes,E as matchPresetRenderer,ae as normalizeRendererJSON};