@arcgis/core 4.34.0-next.86 → 4.34.0-next.87

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 (170) hide show
  1. package/Basemap.js +1 -1
  2. package/Ground.js +1 -1
  3. package/Map.js +1 -1
  4. package/analysis/ElevationProfile/ElevationProfileLineGround.d.ts +4 -0
  5. package/analysis/ElevationProfile/{ElevationProfileGroundLine.js → ElevationProfileLineGround.js} +1 -1
  6. package/analysis/ElevationProfile/ElevationProfileLineInput.d.ts +4 -0
  7. package/analysis/ElevationProfile/{ElevationProfileInputLine.js → ElevationProfileLineInput.js} +1 -1
  8. package/analysis/ElevationProfile/ElevationProfileLineQuery.d.ts +4 -0
  9. package/analysis/ElevationProfile/{ElevationProfileQueryLine.js → ElevationProfileLineQuery.js} +1 -1
  10. package/analysis/ElevationProfile/ElevationProfileLineScene.d.ts +4 -0
  11. package/analysis/ElevationProfile/{ElevationProfileSceneLine.js → ElevationProfileLineScene.js} +1 -1
  12. package/analysis/ElevationProfile/elevationProfileLineTypes.js +1 -1
  13. package/analysis/ElevationProfileAnalysis.js +1 -1
  14. package/assets/esri/core/workers/RemoteClient.js +1 -1
  15. package/assets/esri/core/workers/chunks/0074f1836d7ff69ff6ec.js +1 -0
  16. package/assets/esri/core/workers/chunks/03ef19f0753d68770444.js +1 -0
  17. package/assets/esri/core/workers/chunks/{4a06ab00d095f63598b5.js → 09c2004126f4a5242b85.js} +1 -1
  18. package/assets/esri/core/workers/chunks/0f05425954578ac796ec.js +1 -0
  19. package/assets/esri/core/workers/chunks/109149c378aa4c5f8526.js +1 -0
  20. package/assets/esri/core/workers/chunks/{8307f635a5c0c4a95825.js → 143503f6eb270c4683f8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{6c36cef0b58b87a1f17f.js → 177840d5f0076c0de46b.js} +4 -4
  22. package/assets/esri/core/workers/chunks/1c1b0cc91fe9cb3fec61.js +1 -0
  23. package/assets/esri/core/workers/chunks/1fc6311d4f0d27e88737.js +1 -0
  24. package/assets/esri/core/workers/chunks/257fd65786feb5951b90.js +1 -0
  25. package/assets/esri/core/workers/chunks/2dc88379ee94fabdaf52.js +1 -0
  26. package/assets/esri/core/workers/chunks/366db86914a63e6d0c68.js +1 -0
  27. package/assets/esri/core/workers/chunks/481c2b01e2fe92249698.js +1 -0
  28. package/assets/esri/core/workers/chunks/639d856cd217914dfe1f.js +1 -0
  29. package/assets/esri/core/workers/chunks/7540b34e743a23e67729.js +1 -0
  30. package/assets/esri/core/workers/chunks/7be11a3ef1f49245089f.js +1 -0
  31. package/assets/esri/core/workers/chunks/819a8bc1f0a694017ee6.js +1 -0
  32. package/assets/esri/core/workers/chunks/{1537b02e674f8ef77f4a.js → 8d63b42aea32ce2e5d09.js} +1 -1
  33. package/assets/esri/core/workers/chunks/8de11aab65d91e7f1a4d.js +1 -0
  34. package/assets/esri/core/workers/chunks/9386a0ebff78b6303ed2.js +1 -0
  35. package/assets/esri/core/workers/chunks/{4d47187bc0821413492d.js → 95bae3c275f1483eb7ed.js} +1 -1
  36. package/assets/esri/core/workers/chunks/b09b34f64a6bc2b49e0a.js +1 -0
  37. package/assets/esri/core/workers/chunks/b0a03b6edbcf6e933431.js +1 -0
  38. package/assets/esri/core/workers/chunks/b8997ae5893afa0298d1.js +1 -0
  39. package/assets/esri/core/workers/chunks/c0ae186620b68d43b338.js +1 -0
  40. package/assets/esri/core/workers/chunks/{9d7a22746dae1451deaf.js → c6cae8471c5d4ae40c65.js} +1 -1
  41. package/assets/esri/core/workers/chunks/db5a985ccc6b7d0ad855.js +1 -0
  42. package/assets/esri/core/workers/chunks/f3ee035fa7bf638c8e60.js +1 -0
  43. package/assets/esri/core/workers/chunks/fc5ac54aab66562c8463.js +1 -0
  44. package/assets/esri/themes/dark/main.css +1 -1
  45. package/assets/esri/themes/light/main.css +1 -1
  46. package/assets/esri/themes/light/view.css +1 -1
  47. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis.json +1 -0
  48. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  50. package/config.js +1 -1
  51. package/identity/IdentityManagerBase.js +1 -1
  52. package/interfaces.d.ts +133 -127
  53. package/kernel.js +1 -1
  54. package/layers/GaussianSplatLayer.js +1 -1
  55. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  56. package/layers/IntegratedMeshLayer.js +1 -1
  57. package/layers/ParquetLayer.js +1 -1
  58. package/layers/VectorTileLayer.js +1 -1
  59. package/layers/graphics/sources/ParquetSource.js +1 -1
  60. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  61. package/layers/support/FieldConfiguration.js +1 -1
  62. package/layers/support/fieldConfigUtils.js +1 -1
  63. package/layers/support/vectorTileLayerLoader.js +1 -1
  64. package/package.json +2 -2
  65. package/portal/schemas/definitions.js +1 -1
  66. package/support/basemapEnsureType.js +1 -1
  67. package/support/revision.js +1 -1
  68. package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
  69. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  70. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  71. package/views/2d/layers/features/Processor.js +1 -1
  72. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  73. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  74. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  75. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  76. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  77. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  78. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  79. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  80. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  81. package/views/2d/layers/features/layerAdapters/featureServiceUtils.js +1 -1
  82. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  83. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  84. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  85. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +5 -0
  86. package/views/2d/layers/features/sources/strategies/AFeatureTileLoadStrategy.js +5 -0
  87. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  88. package/views/2d/layers/features/sources/strategies/FeatureDrillDownTileLoadStrategy.js +5 -0
  89. package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +5 -0
  90. package/views/2d/layers/features/sources/strategies/FeatureSnapshotLoadStrategy.js +5 -0
  91. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  92. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  93. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  94. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  95. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  96. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  97. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  98. package/views/3d/GroundView3D.js +5 -0
  99. package/views/3d/analysis/ElevationProfile/{ElevationProfileSceneLineComputation.js → ElevationProfileLineSceneComputation.js} +1 -1
  100. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  101. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementConfiguration.js +1 -1
  102. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  103. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  104. package/views/3d/glTF/internal/Resource.js +1 -1
  105. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  106. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  107. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  108. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  109. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  110. package/views/3d/layers/DrapedSubView3D.js +1 -1
  111. package/views/3d/layers/FlowSubView3D.js +1 -1
  112. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  113. package/views/3d/layers/I3SMeshView3D.js +1 -1
  114. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  115. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  116. package/views/3d/layers/MediaLayerView3D.js +1 -1
  117. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  118. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  119. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  120. package/views/3d/support/MemoryController.js +1 -1
  121. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  122. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  123. package/views/3d/support/popupHitTest.js +1 -1
  124. package/views/3d/terrain/OverlayManager.js +1 -1
  125. package/views/3d/terrain/OverlayRenderer.js +1 -1
  126. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  127. package/views/SceneView.js +1 -1
  128. package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
  129. package/views/analysis/ElevationProfile/{ElevationProfileGroundLineComputation.js → ElevationProfileLineGroundComputation.js} +1 -1
  130. package/views/analysis/ElevationProfile/{ElevationProfileInputLineComputation.js → ElevationProfileLineInputComputation.js} +1 -1
  131. package/views/analysis/ElevationProfile/{ElevationProfileQueryLineComputation.js → ElevationProfileLineQueryComputation.js} +1 -1
  132. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  133. package/widgets/Editor/Upload.js +1 -1
  134. package/widgets/Editor/components/Notices.js +1 -1
  135. package/widgets/Editor/modelUploadUtils.js +1 -1
  136. package/widgets/ElevationProfile/ElevationProfileLineGround.d.ts +2 -2
  137. package/widgets/ElevationProfile/ElevationProfileLineInput.d.ts +2 -2
  138. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +2 -2
  139. package/analysis/ElevationProfile/ElevationProfileGroundLine.d.ts +0 -4
  140. package/analysis/ElevationProfile/ElevationProfileInputLine.d.ts +0 -4
  141. package/analysis/ElevationProfile/ElevationProfileQueryLine.d.ts +0 -4
  142. package/analysis/ElevationProfile/ElevationProfileSceneLine.d.ts +0 -4
  143. package/assets/esri/core/workers/chunks/03e5d1a00d85e4d16bff.js +0 -1
  144. package/assets/esri/core/workers/chunks/0914a52fb33af5d77fab.js +0 -1
  145. package/assets/esri/core/workers/chunks/1d491447b13f2f2b4399.js +0 -1
  146. package/assets/esri/core/workers/chunks/20850b0fdb55fb17bc90.js +0 -1
  147. package/assets/esri/core/workers/chunks/42bc1e981624ce9844a4.js +0 -1
  148. package/assets/esri/core/workers/chunks/436bbe99bedd7b331edb.js +0 -1
  149. package/assets/esri/core/workers/chunks/486ea51306c619238e41.js +0 -1
  150. package/assets/esri/core/workers/chunks/49cb78c85de0102e5f02.js +0 -1
  151. package/assets/esri/core/workers/chunks/5610dfde4e636e2333a9.js +0 -1
  152. package/assets/esri/core/workers/chunks/655a878ddea4907d830e.js +0 -1
  153. package/assets/esri/core/workers/chunks/72fe4f1f789abb5b4035.js +0 -1
  154. package/assets/esri/core/workers/chunks/7402c2853f6aed8d1bc7.js +0 -1
  155. package/assets/esri/core/workers/chunks/79a9f47dfa9ebabb5dbd.js +0 -1
  156. package/assets/esri/core/workers/chunks/86378d4f4d7f9a370c22.js +0 -1
  157. package/assets/esri/core/workers/chunks/b19d723d09f5bea9ca27.js +0 -1
  158. package/assets/esri/core/workers/chunks/b78ea9cc4d5f2fd3d871.js +0 -1
  159. package/assets/esri/core/workers/chunks/bd4125d163f372a7e978.js +0 -1
  160. package/assets/esri/core/workers/chunks/d0a149050f7f1c1ada09.js +0 -1
  161. package/assets/esri/core/workers/chunks/da42cc4f6142846cb745.js +0 -1
  162. package/assets/esri/core/workers/chunks/dd84f630466a26722d57.js +0 -1
  163. package/assets/esri/core/workers/chunks/e17df11c98dbd869302b.js +0 -1
  164. package/assets/esri/core/workers/chunks/e1b3ae6426886e2fab07.js +0 -1
  165. package/assets/esri/core/workers/chunks/f6513ec888a7d927d948.js +0 -1
  166. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +0 -5
  167. package/views/2d/layers/features/sources/strategies/ATileLoadStrategy.js +0 -5
  168. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +0 -5
  169. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +0 -5
  170. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{OptimizedFeature as n}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as o}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQuery as c,executeQueryForCount as d}from"../../../../../rest/query/operations/query.js";import u from"../../../../../rest/support/StatisticDefinition.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as m}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as p}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as l}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as y}from"./strategies/PagedTileLoadStrategy.js";import{ParquetSnapshotLoadStrategy as _}from"./strategies/ParquetSnapshotLoadStrategy.js";import{ParquetTileLoadStrategy as g}from"./strategies/ParquetTileLoadStrategy.js";import{SnapshotLoadStrategy as f}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as S}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as v}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as b}from"../support/FeatureMetadata.js";import{UpdateTracking2D as E}from"../../support/UpdateTracking2D.js";class F{constructor(e,t,s,r,a){this.service=e,this._aggregateAdapter=t,this._subscriptions=s,this._connection=r,this._cachedObjectIds=a,this._updateTracking=new E({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._metadata=b.createFeature(e.metadata),this._store=new v(this._metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),this._updateTracking?.destroy(),"memory"===this.service.type&&this.service.source.map(e=>e.close())}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get usedMemory(){return this._store.usedMemory}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new o({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,featureIdInfo:s.featureIdInfo,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}get hasDisplayFilter(){return!!this._schema&&("displayFilterInfo"in this._schema.mutable&&null!=this._schema.mutable.displayFilterInfo)}chunks(){return Array.from(this._store.chunks())}prepareCacheUpdate(e,t){const s=new Set,r=new Set;for(const a of e)this._cachedObjectIds.has(a)||(this._cachedObjectIds.add(a),s.add(a));for(const a of t)this._cachedObjectIds.delete(a),r.add(a);this.hasDisplayFilter&&this._strategy.prepareCacheUpdate(s,r)}async applyCacheUpdate(){this.hasDisplayFilter&&await this._updateTracking.addPromise(this._strategy.applyCacheUpdate())}cleanup(){return this._store.cleanup()}onSubscribe(e){if(this._connection.onEvent({type:"subscribe",tile:e.tile.id}),!this._strategy)return;const t=this._strategy.load(e);t.then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t})),this._updateTracking.addPromise(t)}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}applyOverride(e){this._didInvalidateData=!0,this._store.applyOverride(e)}takeOverrideUpdate(){return this._store.takeOverrideUpdate()}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return this._strategy.refresh();if(("feature"===s.type||"parquet"===s.type)&&a(n,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(t);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(o){this._connection.onEvent({type:"updateFieldsError",error:o})}}return!1}return!!(i(n,"dataFilter")||i(n,"sourceRefreshVersion")||this._strategy.about.supportsDisplayFilter&&i(n,"displayFilterInfo"))&&(await this._updateStrategy(t),!0)}async addParquetFile(e){await this._strategy.addParquetFile(e)}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new p(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(n.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(n.fromJSON),remove:e.commands.remove,release:e.commands.release}},s=e.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(s);return t.commands.updateWeak.push(...r),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],s=(await this._strategy.queryByObjectId(e)).getCursor();for(;s.next();)t.push(s.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=this.metadata.globalIdField;if(null==t)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const s=this._store.mapObjectIdsFromGlobalIds(e,t).values();return Array.from(s)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e="isSourceHosted"in this.service&&this.service.isSourceHosted,t=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=e||t||s;if("stream"===this._schema.type){const e=new S(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}if("parquet"===this._schema.type){const e=this.service;return null!=e.geometryInfo.displayOptimization?new g(e,this._metadata,this._schema,this._store):new _(e,this._metadata,this._schema,this._store)}const a=this.service,i=m.fromSchema(a,this._schema,this._metadata),n=await this._supportSnapshotMode(a,i);return n?new f(a,i,this._store,n,this.metadata,this._connection):r?new y(a,i,this._store,this.metadata,this._connection):new l(a,i,this._store,this.metadata,this._connection)}async _updateStrategy(e){const t=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map(e=>this._strategy.load(e).then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))));this._updateTracking.addPromise(i),this._strategy.prepareCacheUpdate(this._cachedObjectIds);try{r&&await i}catch(n){s(n)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e,r=s.snapshotInfo;if(!r)return null;return await this._executeExceedsLimitQuery(e,t,r)?null:r}async _executeExceedsLimitQuery(e,t,s){if(!s.supportsExceedsLimit)return this._executeExceedsLimitFallbackQuery(e,t,s);try{const r=e.source,a=t.createQuery();a.inner.orderByFields=[],a.inner.returnGeometry=!1;const i=new u;i.statisticType="exceedslimit",i.maxPointCount=s.maxFeatureCount,i.maxRecordCount=s.maxFeatureCount,i.outStatisticFieldName="exceedslimit",s.maxVertexCount&&(i.maxVertexCount=s.maxVertexCount),a.inner.outStatistics=[i],a.inner.cacheHint=!0;const n=await c(r,a.inner,void 0,{query:a.customParameters}),o=n.data.features[0]?.attributes.exceedslimit;return!(0===o)}catch(r){return!0}}async _executeExceedsLimitFallbackQuery(e,t,s){if(s.maxVertexCount)return!0;const r=e.source,a=t.createQuery();a.inner.orderByFields=[],a.inner.returnGeometry=!1,a.inner.cacheHint=!0;try{return(await d(r,a.inner,{query:a.customParameters})).data.count>s.maxFeatureCount}catch(i){return!0}}}export{F as FeatureSource};
5
+ import has from"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../../core/object.js";import{ignoreAbortErrors as r,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{OptimizedFeature as a}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as i}from"../../../../../layers/graphics/data/QueryEngine.js";import{FeatureStoreStatistics as n}from"../FeatureStoreStatistics.js";import{StreamMessenger as o}from"./StreamMessenger.js";import{UpdateStatus as c}from"./strategies/ALoadStrategy.js";import{FeatureDrillDownTileLoadStrategy as d}from"./strategies/FeatureDrillDownTileLoadStrategy.js";import{FeaturePagedTileLoadStrategy as h}from"./strategies/FeaturePagedTileLoadStrategy.js";import{FeatureSnapshotLoadStrategy as u}from"./strategies/FeatureSnapshotLoadStrategy.js";import{ParquetSnapshotLoadStrategy as p}from"./strategies/ParquetSnapshotLoadStrategy.js";import{ParquetTileLoadStrategy as y}from"./strategies/ParquetTileLoadStrategy.js";import{StreamLoadStrategy as g}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as m}from"./strategies/chunks/SourceChunkStore.js";import{UpdateTracking2D as l}from"../../support/UpdateTracking2D.js";class _{constructor(e,t,r,s){this._aggregateAdapter=e,this._subscriptions=t,this._connection=r,this._cachedObjectIds=s,this._updateTracking=new l({debugName:"FeatureSource"}),this.store=new m(()=>this.metadata)}destroy(){this._strategy?.destroy(),this._streamMessenger?.destroy(),this._updateTracking?.destroy(),this.store.destroy()}get metadata(){return this._strategy.metadata}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return n.from(this.store)}get updateTracking(){return this._updateTracking}get usedMemory(){return this.store.usedMemory}get queryEngine(){if(!this._queryEngine){if(!this.store||!this._strategy)return null;this._queryEngine=new i({featureStore:this.store,fieldsIndex:this.metadata.fieldsIndex,geometryType:this.metadata.geometryType,featureIdInfo:this.metadata.featureIdInfo,hasM:!1,hasZ:!1,spatialReference:this.metadata.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:this.metadata.timeInfo,definitionExpression:this._strategy?.definitionExpression,availableFields:this._strategy?.availableFields})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}get hasQueryDisplayFilter(){if(!this._schema)return!1;switch(this._schema.type){case"feature":return null!=this._schema.strategy.full.displayFilterInfo;case"parquet":case"stream":return!1}}chunks(){return Array.from(this.store.chunks())}prepareCacheUpdate(e,t){const r=new Set,s=new Set;for(const a of e)this._cachedObjectIds.has(a)||(this._cachedObjectIds.add(a),r.add(a));for(const a of t)this._cachedObjectIds.delete(a),s.add(a);this.hasQueryDisplayFilter&&this._strategy.prepareCacheUpdate(r,s)}async applyCacheUpdate(){this.hasQueryDisplayFilter&&await this._updateTracking.addPromise(this._strategy.applyCacheUpdate())}cleanup(){return this.store.cleanup()}onSubscribe(e){if(this._connection.onEvent({type:"subscribe",tile:e.tile.id}),!this._strategy)return;const t=this._strategy.load(e);t.then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t})),this._updateTracking.addPromise(t)}onResume(e){this._updateTracking.addPromise(r(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}applyOverride(e){this._strategy?.applyOverride(e)}takeOverrideUpdate(){return this._strategy?.takeOverrideUpdate()}async update(r,s){const a=this._schema;if(this._schema=r,this._queryEngine=e(this._queryEngine),a&&a.type!==r.type)throw new Error("InternalError: Reconfiguring source types is not supported.");const i=new c;return!a||t(a.service,r.service)||a.strategy.type!==r.strategy.type||t(r.strategy.full,a.strategy.full)||!await this._strategy.tryUpdate(i,r.strategy.partial)?(await this._updateStrategyType(this._schema.service,r,s),!0):i.requiresInvalidation}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.strategy.full.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new o(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(a.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(a.fromJSON),remove:e.commands.remove,release:e.commands.release}},r=e.commands.updateByIdWeak,s=await this._queryOptimizedFeatures(r);return t.commands.updateWeak.push(...s),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],r=(await this._strategy.queryByObjectId(e)).getCursor();for(;r.next();)t.push(r.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=this.metadata.globalIdField;if(null==t)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=this.store.mapObjectIdsFromGlobalIds(e,t).values();return Array.from(r)}async _updateStrategyType(e,t,r){const a=this._createStrategy(e,t);this._connection.onEvent({type:"updateStrategyStart",about:a.about});const i=!!this._strategy;this.store.clear(),this._strategy?.destroy(),this._strategy=a,has("esri-2d-update-debug")&&console.debug(`Version[${r}] FeatureSource.updateStrategy`,{strategy:a});const n=Array.from(this._subscriptions.values());if(!n.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const o=Promise.all(n.map(e=>this._strategy.load(e).then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))));this._updateTracking.addPromise(o),this._strategy.prepareCacheUpdate(this._cachedObjectIds);try{i&&await o}catch(c){s(c)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${r}] FeatureSource.updateStrategyEnd`,{strategy:a})}_createStrategy(e,t){const r={connection:this._connection,store:this.store};switch(t.type){case"feature":return this._createFeatureLoadStrategy(e,t.strategy,r);case"parquet":return this._createParquetLoadStrategy(e,t.strategy,r);case"stream":return this._createStreamLoadStrategy(e,t.strategy,r)}}_createFeatureLoadStrategy(e,t,r){switch(t.type){case"drill-down":return new d(e,t,r);case"paged-tile":return new h(e,t,r);case"snapshot":return new u(e,t,r)}}_createParquetLoadStrategy(e,t,r){switch(t.type){case"xz":return new y(e,t,r);case"snapshot":return new p(e,t,r)}}_createStreamLoadStrategy(e,t,r){const s=new g(e,t,r);return this.streamMessenger.strategy=s,s}}export{_ as FeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import{sqlAnd as e}from"../../../../../core/sql.js";import t from"../../../../../geometry/SpatialReference.js";import{getClauseForScaleRange as r}from"../../../../../layers/support/displayFilterUtils.js";import a from"../../../../../rest/support/Query.js";import i from"../../../../../time/TimeExtent.js";const s=4;function o(e){switch(e.type){case"object-id":case"unique-id-simple":return`${e.fieldName} ASC`;case"unique-id-composite":return`${e.fieldNames.join(",")} ASC`}}function n(e,r,a){const s=o(a.featureIdInfo),n={returnCentroid:"esriGeometryPolygon"===a.serviceGeometryType&&!e.queryMetadata.supportsCentroidOnDegeneratedQuantizedGeometry&&!e.queryMetadata.supportsDegeneratedQuantizedGeometry,returnGeometry:!0,timeReferenceUnknownClient:a.timeReferenceUnknownClient??void 0,outSpatialReference:t.fromJSON(e.outSpatialReference),orderByFields:"memory"===e.type?[]:[s],where:r.mutable.dataFilter.definitionExpression??"1=1",outFields:r.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===a.serviceGeometryType?"xyFootprint":null};if("feature"===r.type){const{gdbVersion:e,historicMoment:t,timeExtent:a}=r.mutable.dataFilter;return{...n,gdbVersion:e,historicMoment:t?new Date(t):null,timeExtent:a?i.fromJSON(a):null,outFields:r.mutable.availableFields}}return n}class u{static fromSchema(e,t,r){const a="feature"===t.type?t.mutable.dataFilter.queryScaleRanges:[],i=t.mutable.displayFilterInfo;return new u(n(e,t,r),i,a,r.subtypeField,t.mutable.dataFilter.customParameters,r.geometryType,e.queryMetadata)}constructor(e,t,r,a,i,s,o){this._queryParams=e,this._displayFilter=t,this._queryScaleRanges=r,this._subtypeField=a,this._customParameters=i,this._geometryType=s,this._queryMetadata=o}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const e=this._queryMetadata.supportsMaxRecordCountFactor?s:null,t=(this._queryMetadata.maxRecordCount??8e3)*(e??1);return Math.min(8e3,t)}get objectIdsQueryPageSize(){return this._queryMetadata?.maxRecordCount??2e3}updateHistoricMoment(e){this._queryParams.historicMoment=e}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t,r){if(!t.getSize())return null;const a=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(a.outFields??[])[0])return null;a.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),r=[];for(const a of e)t.hasField(a)||r.push(a);if(0===r.length)return null;a.outFields=r}a.returnGeometry=!1,a.returnCentroid=!1,a.quantizationParameters=null,a.cacheHint=!0;const i={inner:a,customParameters:this._customParameters};if(has("esri-tiles-debug")&&null!=r){const e=r.chunkId.toString().replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,chunkId:e}:{chunkId:e}}return i}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new a({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(t,a){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const i=this.createQuery(a),o=i.inner;if(this._queryScaleRanges.length){const r=this._queryScaleRanges.filter(e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale)).map(e=>e.subtypeCode);if(r.length){const t=`${this._subtypeField} IN (${r})`;o.where=e(o.where,t)}}if(this._displayFilter&&(o.where=e(o.where,r(this._displayFilter,t.minScale,t.maxScale))),o.quantizationParameters=a.quantizationParameters??t.getQuantizationParameters(),o.resultType="tile",o.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(o.maxAllowableOffset=t.resolution*has("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(o.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(o.maxAllowableOffset*=has("feature-polyline-generalization-factor"))),o.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,o.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(o.maxRecordCountFactor=s),has("esri-tiles-debug")){const e=t.id.replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,tileId:e}:{tileId:e}}return i}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e,t){const r=this.pageSize;return this.createQuery({start:r*e,num:r,returnExceededLimitFeatures:!0,maxRecordCountFactor:s,quantizationParameters:t,cacheHint:!0})}createObjectIdsQuery(e){return this.createQuery({objectIds:e,outFields:["*"]})}}export{u as FeatureSourceQueryInfo};
5
+ import has from"../../../../../core/has.js";import{sqlAnd as e}from"../../../../../core/sql.js";import t from"../../../../../geometry/SpatialReference.js";import{getClauseForScaleRange as r}from"../../../../../layers/support/displayFilterUtils.js";import a from"../../../../../rest/support/Query.js";import i from"../../../../../time/TimeExtent.js";const s=4;function o(e){switch(e.type){case"object-id":case"unique-id-simple":return`${e.fieldName} ASC`;case"unique-id-composite":return`${e.fieldNames.join(",")} ASC`}}function n(e,r,a){const s=o(a.featureIdInfo);return{returnCentroid:"esriGeometryPolygon"===a.serviceGeometryType&&!e.queryMetadata.supportsCentroidOnDegeneratedQuantizedGeometry&&!e.queryMetadata.supportsDegeneratedQuantizedGeometry,returnGeometry:!0,timeReferenceUnknownClient:a.timeReferenceUnknownClient??void 0,outSpatialReference:t.fromJSON(e.outSpatialReference),orderByFields:"memory"===e.type?[]:[s],where:r.definitionExpression??"1=1",outFields:r.availableFields,multipatchOption:"esriGeometryMultiPatch"===a.serviceGeometryType?"xyFootprint":null,gdbVersion:r.gdbVersion,historicMoment:r.historicMoment?new Date(r.historicMoment):null,timeExtent:r.timeExtent?i.fromJSON(r.timeExtent):null}}class u{static create(e,t,r){const a=t.queryScaleRanges,i=t.displayFilterInfo;return new u(n(e,t,r),i,a,r.subtypeField,t.customParameters,r.geometryType,e.queryMetadata)}constructor(e,t,r,a,i,s,o){this._queryParams=e,this._displayFilter=t,this._queryScaleRanges=r,this._subtypeField=a,this._customParameters=i,this._geometryType=s,this._queryMetadata=o}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const e=this._queryMetadata.supportsMaxRecordCountFactor?s:null,t=(this._queryMetadata.maxRecordCount??8e3)*(e??1);return Math.min(8e3,t)}get objectIdsQueryPageSize(){return this._queryMetadata?.maxRecordCount??2e3}updateHistoricMoment(e){this._queryParams.historicMoment=e}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t,r){if(!t.getSize())return null;const a=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(a.outFields??[])[0])return null;a.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),r=[];for(const a of e)t.hasField(a)||r.push(a);if(0===r.length)return null;a.outFields=r}a.returnGeometry=!1,a.returnCentroid=!1,a.quantizationParameters=null,a.cacheHint=!0;const i={inner:a,customParameters:this._customParameters};if(has("esri-tiles-debug")&&null!=r){const e=r.chunkId.toString().replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,chunkId:e}:{chunkId:e}}return i}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new a({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(t,a){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const i=this.createQuery(a),o=i.inner;if(this._queryScaleRanges?.length){const r=this._queryScaleRanges.filter(e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale)).map(e=>e.subtypeCode);if(r.length){const t=`${this._subtypeField} IN (${r})`;o.where=e(o.where,t)}}if(this._displayFilter&&(o.where=e(o.where,r(this._displayFilter,t.minScale,t.maxScale))),o.quantizationParameters=a.quantizationParameters??t.getQuantizationParameters(),o.resultType="tile",o.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(o.maxAllowableOffset=t.resolution*has("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(o.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(o.maxAllowableOffset*=has("feature-polyline-generalization-factor"))),o.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,o.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(o.maxRecordCountFactor=s),has("esri-tiles-debug")){const e=t.id.replaceAll("/",".");i.customParameters=i.customParameters?{...i.customParameters,tileId:e}:{tileId:e}}return i}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e,t){const r=this.pageSize;return this.createQuery({start:r*e,num:r,returnExceededLimitFeatures:!0,maxRecordCountFactor:s,quantizationParameters:t,cacheHint:!0})}createObjectIdsQuery(e){return this.createQuery({objectIds:e,outFields:["*"]})}}export{u as FeatureSourceQueryInfo};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import e from"../../../../../../request.js";import t from"../../../../../../core/Error.js";import r from"../../../../../../core/Logger.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{QueueProcessor as i}from"../../../../../../core/QueueProcessor.js";import a from"../../../../../../rest/support/Query.js";import{FeatureSourceQueryInfo as n}from"../FeatureSourceQueryInfo.js";import{ALoadStrategy as o}from"./ALoadStrategy.js";import{createQueryAdapter as u}from"./support/queryAdapters.js";import{FeatureSetReaderJSON as d}from"../../support/FeatureSetReaderJSON.js";class c extends o{constructor(e,t,r){super(e.metadata,t,r),this._service=e,this._didApplyOverride=!1,this._queue=new i({concurrency:32,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters,useRequestQueue:!0};return this._adapter.executeQuery(e.query.inner,t)}}),this._queryInfo=n.create(e,{...t.full,...t.partial},this.metadata),this._adapter=u(e,this.metadata,r.connection),this._lastEditDate=e.queryMetadata.lastEditDate}destroy(){super.destroy(),this._adapter.destroy()}unsafeSetQueryHistoricMoment(e){this._queryInfo.updateHistoricMoment(e)}async tryUpdate(e,t){if(s(this.availableFields,t.availableFields)){if(this._didApplyOverride||await this._queryLastEditDateChanged())return!1;await this._updateFields(t.availableFields)}return this._schema.partial=t,!0}async queryByObjectId(e){if(0===e.length)return d.empty(this.metadata);const t=this._queryInfo.createQuery({objectIds:e});return this._fetch(t,null,null)}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}_onOverride(){this._didApplyOverride=!0}async _updateFields(e){this._queryInfo.updateFields(e);const r=Array.from(this.store.chunks()).map(async e=>{const t=a.fromJSON(e.queryInfo.queryJSON);if(t)try{return await this._tryUpdateFields(e.reader,t,{chunkId:e.chunkId}),null}catch(r){return r}}),s=(await Promise.all(r)).filter(e=>e);if(s.length)throw new t("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async _fetch(e,t,r){const s=await this._enqueue(e,t);return await this._tryUpdateFields(s,e.inner,r),s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;if(!("source"in this._service))return!1;const t=this._service.source,r={...t.query,f:"json"},s=(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _tryUpdateFields(e,s,i){const a=this._queryInfo.createPatchFieldsQuery(s,e,i);if(!a)return;const n=await this._enqueue(a,this._options);n.getSize()===e.getSize()?e.joinAttributes(n):r.getLogger("esri.views.2d.layers.features.sources.strategies.AFetchLoadStrategy").error(new t("featurelayer-query",`Failed to join features. Expected a count of ${e.getSize()} features, but got ${n.getSize()}`,{query:a.inner.toJSON(),debugInfo:i}))}async _enqueue(e,t){return this._connection.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally(()=>{this._connection.onEvent({type:"fetchEnd",done:0===this._queue.length})})}}export{c as AFeatureLoadStrategy};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import has from"../../../../../../core/has.js";import{FeatureCache as e}from"../FeatureCache.js";import{AFeatureLoadStrategy as t}from"./AFeatureLoadStrategy.js";class s extends t{constructor(t,s,h){super(t,s,h),this._chunksById=new Map,this._featureCache=new e(this.store,this._queryInfo,this._options,this._fetch.bind(this))}prepareCacheUpdate(e,t){return this._featureCache.prepareCacheUpdate(e,t)}applyCacheUpdate(){return this._featureCache.applyCacheUpdate()}unload(e){this._removeChunks(e.tile)}_addChunk(e){const t=e.tile.id;this._chunksById.has(t)||this._chunksById.set(t,[]);const s=e.size();(s||e.first||e.end)&&(has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] ATileLoadStrategy.addChunk [count=${s}]`),this._chunksById.get(t).push(e),this.store.insert(e))}_removeChunks(e){const t=this._chunksById.get(e.key.id)??[];for(const s of t)has("esri-2d-update-debug")&&console.debug(`Tile[${e.key.id}] Chunk[${s.chunkId}] ATileLoadStrategy.removeChunk`),this.store.remove(s);this._chunksById.delete(e.key.id)}}export{s as AFeatureTileLoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- class r{constructor(r){this._store=r,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}get _signal(){return this._controller.signal}unsafeSetQueryHistoricMoment(r){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(r){throw new Error("InternalError: LoadStrategy does not support fetching")}async addParquetFile(r){throw new Error("InternalError: LoadStrategy does not support loading blobs")}prepareCacheUpdate(r,t){}applyCacheUpdate(){return null}}export{r as ALoadStrategy};
5
+ import{FeatureMetadata as t}from"../../support/FeatureMetadata.js";class r{constructor(){this._requiresInvalidation=!1}get requiresInvalidation(){return this._requiresInvalidation}requireInvalidation(){this._requiresInvalidation=!0}}class e{constructor(r,e,o){this._context=o,this._controller=new AbortController,this.metadata=t.createFeature(r),this._schema=e}destroy(){this._controller.abort(),this.store.destroy()}get store(){return this._context.store}get _connection(){return this._context.connection}get _options(){return{signal:this._controller.signal}}get _signal(){return this._controller.signal}applyOverride(t){this._onOverride(),this.store.applyOverride(t)}takeOverrideUpdate(){return this.store.takeOverrideUpdate()}unsafeSetQueryHistoricMoment(t){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(t){throw new Error("InternalError: LoadStrategy does not support fetching")}prepareCacheUpdate(t,r){}applyCacheUpdate(){return null}}export{e as ALoadStrategy,r as UpdateStatus};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import has from"../../../../../../core/has.js";import{throwIfAborted as e,onAbort as s}from"../../../../../../core/promiseUtils.js";import{AFeatureTileLoadStrategy as o}from"./AFeatureTileLoadStrategy.js";import{DrillDownTileSourceChunk as r}from"./chunks/DrillDownTileSourceChunk.js";import{FeatureSetReaderJSON as i}from"../../support/FeatureSetReaderJSON.js";class l{constructor(e,o){this.subscription=e,this._tileIdToResult=new Map,this._controller=new AbortController,this._handles=t([s(e.signal,()=>this._controller.abort()),s(o,()=>this._controller.abort())])}destroy(){this._controller.abort(),this._handles.remove()}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class a extends o{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new l(t,this._options));const s=this._loadStates.get(t.key.id);let o;try{for await(const o of this._fetchChunkInfos(s,t.tile,0)){const{queryJSON:t,reader:i,sourceTile:l,sourceTileDepth:a,tile:n}=o,h=new r(i,t,n,l,a,!1);e(s.options),this._addChunk(h)}}catch(n){o=n}const a=new r(i.empty(this.metadata),null,t.tile,null,-1,!0);if(this._addChunk(a),o)throw o}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let o=t.get(e.id);const r=!!o;if(o||(o=await this._fetchChunkInfo(t,e,s),t.set(e.id,o)),o.reader.exceededTransferLimit&&s<has("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield o)}async _fetchChunkInfo(t,e,s){const o=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:o});return{reader:await this._fetch(r,t.options,{chunkId:e.id}),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}export{a as FeatureDrillDownTileLoadStrategy};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{handlesGroup as e}from"../../../../../../core/handleUtils.js";import has from"../../../../../../core/has.js";import{getOrCreateMapValue as t}from"../../../../../../core/MapUtils.js";import{throwIfAborted as o,isAbortError as s,onAbort as r}from"../../../../../../core/promiseUtils.js";import{AFeatureTileLoadStrategy as a}from"./AFeatureTileLoadStrategy.js";import{PagedTileSourceChunk as i}from"./chunks/PagedTileSourceChunk.js";import{FeatureSetReaderJSON as n}from"../../support/FeatureSetReaderJSON.js";class l{constructor(t,o){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,this._handles=e([r(t.signal,()=>this._controller.abort()),r(o,()=>this._controller.abort())])}destroy(){this._controller.abort(),this._handles.remove()}get pageStart(){let e=-1;for(const t of this._pages.values())e=Math.max(e,t);return e+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(e,t){this._pages.add(e),this._done=this._done||t}}class c extends a{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const e of this._loadStates.values())e.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(e){const o=t(this._loadStates,e.key.id,()=>new l(e,this._options));for await(const t of this._fetchPages(o))this._addChunk(t)}unload(e){super.unload(e),this._loadStates.get(e.key.id)?.destroy(),this._loadStates.delete(e.key.id)}async*_fetchPages(e){let t;try{for await(const t of this._concurrentPageStream(e))o(e.options),0!==t.size()&&(yield t)}catch(r){t=r}if(t&&s(t)||(yield new i(n.empty(this.metadata),null,e.subscription.tile,-1,!0)),t)throw t}async*_concurrentPageStream(e){const t=has("featurelayer-query-tile-concurrency"),o=this._pageStreamAll(e),s=[];let r=!1,a=1;for(;!r;){const e=[];for(;!r&&s.length<a;){const t=o.next();if(!t.value){r=!0;break}const a=t.value;a.then(e=>{e.reader.exceededTransferLimit||(r=!0)}).catch(e=>{r=!0}).finally(()=>{s.splice(s.indexOf(a),1)}),s.push(a),e.push(a)}for(const t of e)yield t;s.length&&await Promise.race(s),a<t&&(a+=1)}}*_pageStreamAll(e){const t=Math.ceil(has("featurelayer-query-tile-max-features")/this._queryInfo.pageSize);for(let o=0;o<t;o++)yield this._downloadPage(o,e)}async _downloadPage(e,t){o(t.options);const s=t.subscription.tile,r=this._queryInfo.createPagedTileQuery(s,e),a=await this._fetch(r,t.options,{chunkId:`${s.id}-${e}`});return o(t.options),new i(a,r.inner.toJSON(),s,e,!1)}}export{c as FeaturePagedTileLoadStrategy};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import e from"../../../../../../core/Error.js";import has from"../../../../../../core/has.js";import{isAbortError as t,throwIfAborted as r}from"../../../../../../core/promiseUtils.js";import o from"../../../../../../rest/support/QuantizationParameters.js";import{AFeatureLoadStrategy as a}from"./AFeatureLoadStrategy.js";import{FeatureSnapshotSourceChunk as s}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as n}from"../../support/FeatureSetReaderJSON.js";class i extends a{constructor(e,t,r){super(e,t,r)}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(e){return null==this._promise&&(this._promise=this._download()),this._promise}unload(e){}async _download(){const e=this._schema.snapshotInfo.initialTolerance,t=e?new o({mode:"view",originPosition:"upper-left",tolerance:e}):null;await this._downloadStreaming(t),null!=t&&await this._downloadRefresh()}async _downloadStreaming(t){try{for await(const e of this._fetchPages(t))this.store.insert(e)}catch(r){throw new e("featurelayer-query","Encountered error when downloading data",{error:r})}}async _downloadRefresh(){try{const e=[];for await(const t of this._fetchPages(null))e.push(t);this.store.clear();for(const t of e)this.store.insert(t);this.store.refresh()}catch(t){throw new e("featurelayer-query","Encountered error when downloading data",{error:t})}}async*_fetchPages(e){let r;try{for await(const t of this._concurrentPageStream(e))0!==t.size()&&(yield t)}catch(o){r=o}if(r&&t(r)||(yield new s(n.empty(this.metadata),null,-1,!0)),r)throw r}async*_concurrentPageStream(e){const t=has("featurelayer-snapshot-concurrency"),r=this._pageStreamAll(e),o=[];let a=!1,s=1;for(;!a;){const e=[];for(;!a&&o.length<s;){const t=r.next();if(!t.value){a=!0;break}const s=t.value;s.then(e=>{e.reader.exceededTransferLimit||(a=!0)}).catch(e=>{a=!0}).finally(()=>{o.splice(o.indexOf(s),1)}),o.push(s),e.push(s)}for(const t of e)yield t;o.length&&await Promise.race(o),s<t&&(s+=1)}}*_pageStreamAll(e){const t=Math.ceil(this._schema.snapshotInfo.maxFeatureCount/this._queryInfo.pageSize);for(let r=0;r<t;r++)yield this._downloadPage(r,e)}async _downloadPage(e,t){r(this._options);const o=this._queryInfo.createPagedQuery(e,t),a=await this._fetch(o,this._options,{chunkId:e.toString()}),n=new s(a,o.inner.toJSON(),e,!1);return r(this._options),n}}export{i as FeatureSnapshotLoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e}from"../../../../../../core/promiseUtils.js";import{difference as t,union as s}from"../../../../../../core/SetUtils.js";import i from"../../../../../../layers/support/FieldsIndex.js";import{createParquetFile as r}from"../../../../../../libs/parquet/parquet.js";import{ALoadStrategy as a}from"./ALoadStrategy.js";import{FeatureSnapshotSourceChunk as o}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as l}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderParquet as n}from"../../support/FeatureSetReaderParquet.js";class m extends a{constructor(e,t,s,i){super(i),this._service=e,this._metadata=t,this._schema=s,this._chunkId=0,this._files=[],this._availableFields=new Set(s.mutable.availableFields)}destroy(){super.destroy();for(const e of this._files)e.free()}get about(){return{supportsDisplayFilter:!1,willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}async updateFields(e){await this._promise;const i=new Set(e),r=t(i,this._availableFields);this._availableFields=s(r,this._availableFields);const a=this._fieldsIndex;if(null==a)return;const o=Array.from(r).map(e=>a.get(e)?.column);if(r.size)for(const t of this._files)await t.ensureFields(new Uint32Array(o))}async load(e){return null==this._promise&&(this._promise=this._download()),this._promise}unload(e){}async addParquetFile(e){this._insert(e)}async _insert(t){const s=await r(t,{geometryInfo:this._service.geometryInfo,outSpatialReference:this._service.outSpatialReference,getCustomParameters:()=>this._schema.mutable.dataFilter.customParameters});this._files.push(s),e(this._options);const a=s.fields().map(e=>({name:e.name,alias:e.name,type:e.type,column:s.columnForFieldName(e.name)})),{timeZoneByFieldName:l}=this._service.metadata.fieldsIndex,m=i.fromJSON({fields:a,timeZoneByFieldName:l});this._fieldsIndex=m;const u=new Uint32Array(Array.from(this._availableFields.values()).map(e=>m.get(e)?.column).filter(e=>null!=e));await s.readAllChunks(u,this._signal,e=>{if(this._signal.aborted)return;const t=this._chunkId++,s=new n(this._metadata,m,e,t),i=new o(s,null,t,!1);this._store.insert(i)})}async _download(){try{await Promise.all(this._service.source.urls.map(e=>this._insert(e)));const e=new o(l.empty(this._metadata),null,-1,!0);this._store.insert(e)}catch(e){throw console.error(e),e}}}export{m as ParquetSnapshotLoadStrategy};
5
+ import e from"../../../../../../core/Error.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{throwIfAborted as t}from"../../../../../../core/promiseUtils.js";import{difference as i}from"../../../../../../core/SetUtils.js";import r from"../../../../../../layers/support/FieldsIndex.js";import{createParquetFile as a}from"../../../../../../libs/parquet/parquet.js";import{ALoadStrategy as o}from"./ALoadStrategy.js";import{FeatureSnapshotSourceChunk as l}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as n}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderParquet as m}from"../../support/FeatureSetReaderParquet.js";class u extends o{constructor(e,s,t){super(e.metadata,s,t),this._service=e,this._chunkId=0,this._files=new Map}destroy(){super.destroy();for(const e of this._files.values())e.free();this._files.clear()}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}async tryUpdate(t,i){if(s(this.availableFields,i.availableFields)&&await this._updateFields(i.availableFields),s(this._schema.partial.urls,i.urls)){for(const e of i.urls)this._files.has(e)||await this._insert(e);for(const s of this._files.keys())if(!i.urls.includes(s))throw new e("unsupported","Removing parquet files is not supported",{previous:this._schema.partial.urls,next:i.urls})}return this._schema.partial=i,!1}async load(e){return null==this._promise&&(this._promise=this._download()),this._promise}unload(e){}_onOverride(){}async _updateFields(e){await this._promise;const s=new Set(e),t=i(s,new Set(this.availableFields)),r=this._fieldsIndex;if(null==r)return;const a=Array.from(t).map(e=>r.get(e)?.column);if(t.size)for(const i of this._files.values())await i.ensureFields(new Uint32Array(a))}async _insert(e){const s=await a(e,{geometryInfo:this._service.geometryInfo,outSpatialReference:this._service.outSpatialReference,getCustomParameters:()=>this._schema.full.customParameters}),i=this._files.size;this._files.set(e,s),t(this._options);const o=s.fields().map(e=>({name:e.name,alias:e.name,type:e.type,column:s.columnForFieldName(e.name)})),{timeZoneByFieldName:n}=this._service.metadata.fieldsIndex,u=r.fromJSON({fields:o,timeZoneByFieldName:n});this._fieldsIndex=u;const h=new Uint32Array(Array.from(this.availableFields.values()).map(e=>u.get(e)?.column).filter(e=>null!=e));await s.readAllChunks(h,this._signal,e=>{if(this._signal.aborted)return;const s=this._chunkId++,t=new m(this.metadata,u,e,s,i),r=new l(t,null,s,!1);this.store.insert(r)})}async _download(){try{await Promise.all(this._schema.partial.urls.map(e=>this._insert(e)));const e=new l(n.empty(this.metadata),null,-1,!0);this.store.insert(e)}catch(e){throw console.error(e),e}}}export{u as ParquetSnapshotLoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{QueueProcessor as e}from"../../../../../../core/QueueProcessor.js";import{difference as t,union as i}from"../../../../../../core/SetUtils.js";import s from"../../../../../../geometry/Polygon.js";import a from"../../../../../../geometry/SpatialReference.js";import{toExtent as r}from"../../../../../../geometry/support/aaBoundingRect.js";import{convertFromPolygon as n}from"../../../../../../layers/graphics/featureConversionUtils.js";import o from"../../../../../../layers/graphics/OptimizedGeometry.js";import{project as l}from"../../../../../../layers/graphics/data/projectionSupport.js";import m from"../../../../../../layers/support/FieldsIndex.js";import{createParquetFile as d}from"../../../../../../libs/parquet/parquet.js";import{ALoadStrategy as u}from"./ALoadStrategy.js";import{ParquetSourceChunk as h}from"./chunks/ParquetSourceChunk.js";import{FeatureSetReaderParquet as p}from"../../support/FeatureSetReaderParquet.js";class c extends u{constructor(e,t,i,s){super(s),this._metadata=t,this._schema=i,this._files=[];const a=new Set(i.mutable.availableFields);if(!e.geometryInfo.displayOptimization)throw new Error("InternalError: ParquetTileLoadStrategy only supports XZ-enabled parquet files");this._index=f.create(t,e,a,s,()=>this._schema.mutable.dataFilter.customParameters)}destroy(){super.destroy();for(const e of this._files)e.free()}get about(){return{supportsDisplayFilter:!1,willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}async load(e){const t=await this._index;await t.ensureLoaded(e)}unload(e){this._index.then(t=>t.unload(e.tile))}async updateFields(e){return(await this._index).updateFields(e)}async addParquetFile(e){throw new Error("Impl!")}}class f{static async create(e,t,i,s,a){const r=await Promise.all(t.source.urls.map(e=>d(e,{geometryInfo:t.geometryInfo,outSpatialReference:t.outSpatialReference,getCustomParameters:a}))),[n]=r,o=n.fields().map(e=>({name:e.name,alias:e.name,type:e.type,column:n.columnForFieldName(e.name)})),{timeZoneByFieldName:l}=t.metadata.fieldsIndex,u=m.fromJSON({fields:o,timeZoneByFieldName:l}),h=new Uint32Array(Array.from(i.values()).map(e=>u.get(e)?.column).filter(e=>null!=e)),p=t.geometryInfo.displayOptimization;if(!p)throw new Error("InternalError: tiled parquet load requires display optimization");return new f(e,await Promise.all(r),u,h,s,i,p)}constructor(t,i,s,a,r,n,o){this._metadata=t,this._files=i,this._fieldsIndex=s,this._fieldIndices=a,this._store=r,this._availableFields=n,this._displayOptimization=o,this._queue=new e({concurrency:1,process:e=>this._ensureLoaded(e)}),this._tileIdToChunkId=new Map}get file(){return this._files[0]}async ensureLoaded(e){return this._queue.push(e)}unload(e){const t=this._tileIdToChunkId.get(e.id);if(null!=t){for(const e of t)this._store.removeById(e);this._tileIdToChunkId.delete(e.id)}}async _ensureLoaded(e){const t=this._metadata.outSpatialReference,i=e.tile,{xmin:s,ymin:a,xmax:r,ymax:n}=y(i.extent,t);let o=0;const l={extent:i.extent,extent_lat_lng:{xmin:s,ymin:a,xmax:r,ymax:n},tile_level:i.level,attributes:this._fieldIndices};if("z"===this._displayOptimization.mode?await this.file.queryZChunks(l.extent_lat_lng,this._fieldIndices,e.signal,t=>{if(e.signal.aborted)return;const s=new p(this._metadata,this._fieldsIndex,t,o),a=new h(this._metadata,s,i,o++,!1);this._insertChunk(i,a)}):await this.file.queryXZChunks(l,e.signal,t=>{if(e.signal.aborted)return;const s=new p(this._metadata,this._fieldsIndex,t,o),a=new h(this._metadata,s,i,o++,!1);this._insertChunk(i,a)}),e.signal.aborted)return;const m=new h(this._metadata,null,i,o++,!0);this._insertChunk(i,m)}_insertChunk(e,t){let i=this._tileIdToChunkId.get(e.id);null==i&&(i=[],this._tileIdToChunkId.set(e.id,i)),i.push(t.chunkId),this._store.insert(t)}async updateFields(e){const s=new Set(e),a=t(s,this._availableFields);if(this._availableFields=i(a,this._availableFields),a.size)for(const t of this._files){const e=Array.from(a).map(e=>this._fieldsIndex.get(e)?.column);await t.ensureFields(new Uint32Array(e))}}}function y(e,t){const i=[e.xmin,e.ymin,e.xmax,e.ymax],m=s.fromExtent(r(i,t)),d=l(m,t,a.WGS84);if(!d)return null;const u=n(new o,d,!1,!1),h=u.coords.filter((e,t)=>!(t%2)),p=u.coords.filter((e,t)=>t%2);return{xmin:Math.min(...h),ymin:Math.min(...p),xmax:Math.max(...h),ymax:Math.max(...p)}}export{c as ParquetTileLoadStrategy};
5
+ import{notDeepEqual as e}from"../../../../../../core/object.js";import{QueueProcessor as t}from"../../../../../../core/QueueProcessor.js";import{difference as i,union as a}from"../../../../../../core/SetUtils.js";import s from"../../../../../../geometry/Polygon.js";import r from"../../../../../../geometry/SpatialReference.js";import{toExtent as n}from"../../../../../../geometry/support/aaBoundingRect.js";import{convertFromPolygon as o}from"../../../../../../layers/graphics/featureConversionUtils.js";import l from"../../../../../../layers/graphics/OptimizedGeometry.js";import{project as d}from"../../../../../../layers/graphics/data/projectionSupport.js";import m from"../../../../../../layers/support/FieldsIndex.js";import{createParquetFile as u}from"../../../../../../libs/parquet/parquet.js";import{ALoadStrategy as h}from"./ALoadStrategy.js";import{ParquetSourceChunk as p}from"./chunks/ParquetSourceChunk.js";import{FeatureSetReaderParquet as f}from"../../support/FeatureSetReaderParquet.js";class c extends h{constructor(e,t,i){if(super(e.metadata,t,i),this._files=[],!e.geometryInfo.displayOptimization)throw new Error("InternalError: ParquetTileLoadStrategy only supports XZ-enabled parquet files");this._index=y.create(t.partial.urls,this.metadata,e,new Set(t.partial.availableFields),this.store,()=>t.full.customParameters)}destroy(){super.destroy();for(const e of this._files)e.free()}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}async tryUpdate(t,i){return e(this.availableFields,i.availableFields)&&await this._updateFields(i.availableFields),this._schema.partial=i,!1}async load(e){const t=await this._index;await t.ensureLoaded(e)}unload(e){this._index.then(t=>t.unload(e.tile))}_onOverride(){}async _updateFields(e){return(await this._index).updateFields(e)}}class y{static async create(e,t,i,a,s,r){const n=await Promise.all(e.map(e=>u(e,{geometryInfo:i.geometryInfo,outSpatialReference:i.outSpatialReference,getCustomParameters:r})));if(1!==n.length)throw new Error("InternalError: experimental parquet XZ display optimization only supports a single file.");const[o]=n,l=o.fields().map(e=>({name:e.name,alias:e.name,type:e.type,column:o.columnForFieldName(e.name)})),{timeZoneByFieldName:d}=i.metadata.fieldsIndex,h=m.fromJSON({fields:l,timeZoneByFieldName:d}),p=new Uint32Array(Array.from(a.values()).map(e=>h.get(e)?.column).filter(e=>null!=e)),f=i.geometryInfo.displayOptimization;if(!f)throw new Error("InternalError: tiled parquet load requires display optimization");return new y(t,await Promise.all(n),h,p,s,a,f)}constructor(e,i,a,s,r,n,o){this._metadata=e,this._files=i,this._fieldsIndex=a,this._fieldIndices=s,this._store=r,this._availableFields=n,this._displayOptimization=o,this.fileIndex=0,this._queue=new t({concurrency:1,process:e=>this._ensureLoaded(e)}),this._tileIdToChunkId=new Map}get file(){return this._files[0]}async ensureLoaded(e){return this._queue.push(e)}unload(e){const t=this._tileIdToChunkId.get(e.id);if(null!=t){for(const e of t)this._store.removeById(e);this._tileIdToChunkId.delete(e.id)}}async _ensureLoaded(e){const t=this._metadata.outSpatialReference,i=e.tile,{xmin:a,ymin:s,xmax:r,ymax:n}=_(i.extent,t);let o=0;const l={extent:i.extent,extent_lat_lng:{xmin:a,ymin:s,xmax:r,ymax:n},tile_level:i.level,attributes:this._fieldIndices};if("z"===this._displayOptimization.mode?await this.file.queryZChunks(l.extent_lat_lng,this._fieldIndices,e.signal,t=>{if(e.signal.aborted)return;const a=new f(this._metadata,this._fieldsIndex,t,o,this.fileIndex),s=new p(this._metadata,a,i,o++,!1);this._insertChunk(i,s)}):await this.file.queryXZChunks(l,e.signal,t=>{if(e.signal.aborted)return;const a=new f(this._metadata,this._fieldsIndex,t,o,this.fileIndex),s=new p(this._metadata,a,i,o++,!1);this._insertChunk(i,s)}),e.signal.aborted)return;const d=new p(this._metadata,null,i,o++,!0);this._insertChunk(i,d)}_insertChunk(e,t){let i=this._tileIdToChunkId.get(e.id);null==i&&(i=[],this._tileIdToChunkId.set(e.id,i)),i.push(t.chunkId),this._store.insert(t)}async updateFields(e){const t=new Set(e),s=i(t,this._availableFields);if(this._availableFields=a(s,this._availableFields),s.size)for(const i of this._files){const e=Array.from(s).map(e=>this._fieldsIndex.get(e)?.column);await i.ensureFields(new Uint32Array(e))}}}function _(e,t){const i=[e.xmin,e.ymin,e.xmax,e.ymax],a=s.fromExtent(n(i,t)),m=d(a,t,r.WGS84);if(!m)return null;const u=o(new l,m,!1,!1),h=u.coords.filter((e,t)=>!(t%2)),p=u.coords.filter((e,t)=>t%2);return{xmin:Math.min(...h),ymin:Math.min(...p),xmax:Math.max(...h),ymax:Math.max(...p)}}export{c as ParquetTileLoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{EventEmitter as e}from"../../../../../../core/Evented.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{destroyMaybe as s}from"../../../../../../core/maybe.js";import{StreamFeatureManager as n}from"../../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as o}from"../../../../../../layers/graphics/sources/connections/createConnection.js";import{internalTimeReceivedField as i}from"../../../../../../layers/support/streamLayerUtils.js";import{StreamConnectionState as r}from"../StreamConnectionState.js";import{StreamFeatureStore as a}from"../StreamFeatureStore.js";import{ALoadStrategy as c}from"./ALoadStrategy.js";import{StreamSourceChunk as h}from"./chunks/StreamSourceChunk.js";class m extends c{constructor(t,s,o,c,h){super(o),this._service=t,this._dataFilter=s,this._streamOptions=c,this._metadata=h,this._connectionState=new r,this._forceRefresh=!1,this.events=new e;const{timeInfo:m}=this._metadata,{purgeOptions:d}=s;this._stagingStore=new a(this._metadata.weakCloneWithAdditionalFields([{name:i,alias:"timeReceived",type:"esriFieldTypeDate"}]),e=>this.events.emit("features-updated",e)),this._manager=new n(this._stagingStore,h.featureIdInfo,m,d),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{supportsDisplayFilter:!1,willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}async refresh(){const e=null!=this._chunk;return this._manager.checkForUpdates()||!e||this._forceRefresh?(this._chunk&&this._store.remove(this._chunk),this._forceRefresh=!1,this._chunk=new h(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick"),!0):(this.events.emit("tick"),!1)}async updateFields(e){throw new Error("Updating available fields not supported for StreamLayer")}async load(e){}unload(e){}disconnect(){this._connection=s(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:e,spatialReference:s}=this._metadata,{maxReconnectionAttempts:n,maxReconnectionInterval:i,geometryDefinition:r,definitionExpression:a,customParameters:c}=this._dataFilter;this._connection=o(this._service.source,s,this._streamOptions.outSR,e,a,r,n,i,c),this._handlesGroup=t([this._connection.on("data-received",e=>this._onFeature(e)),this._connection.on("message-received",e=>this._onWebSocketMessage(e))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(e){this._connection?.updateCustomParameters(e)}sendMessageToSocket(e){this._connection?.sendMessageToSocket(e)}sendMessageToClient(e){this._connection?.sendMessageToClient(e)}_onWebSocketMessage(e){if("type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this.clear()}this.events.emit("message-received",e)}_onFeature(e){try{this._manager.add(e),this.events.emit("data-received",e)}catch(t){}}}export{m as StreamLoadStrategy};
5
+ import{EventEmitter as e}from"../../../../../../core/Evented.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{destroyMaybe as s}from"../../../../../../core/maybe.js";import{StreamFeatureManager as i}from"../../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as n}from"../../../../../../layers/graphics/sources/connections/createConnection.js";import{internalTimeReceivedField as r}from"../../../../../../layers/support/streamLayerUtils.js";import{StreamConnectionState as o}from"../StreamConnectionState.js";import{StreamFeatureStore as a}from"../StreamFeatureStore.js";import{ALoadStrategy as c}from"./ALoadStrategy.js";import{StreamSourceChunk as h}from"./chunks/StreamSourceChunk.js";class m extends c{constructor(t,s,n){super(t.metadata,s,n),this._service=t,this._connectionState=new o,this._forceRefresh=!1,this.events=new e;const{timeInfo:c}=this.metadata,{purgeOptions:h}=s.full;this._stagingStore=new a(this.metadata.weakCloneWithAdditionalFields([{name:r,alias:"timeReceived",type:"esriFieldTypeDate"}]),e=>this.events.emit("features-updated",e)),this._manager=new i(this._stagingStore,this.metadata.featureIdInfo,c,h),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}get availableFields(){return this._schema.full.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}async tryUpdate(e,t){const s=null!=this._chunk;if(t.sourceRefreshVersion!==this._refreshVersion){if(this._refreshVersion=t.sourceRefreshVersion,!this._manager.checkForUpdates()&&s&&!this._forceRefresh)return this.events.emit("tick"),!0;this._chunk&&(this.store.remove(this._chunk),e.requireInvalidation()),this._forceRefresh=!1,this._chunk=new h(this._stagingStore.reader),this.store.insert(this._chunk),this.events.emit("tick")}return this._schema.partial=t,!0}async load(e){}unload(e){}disconnect(){this._streamConnection=s(this._streamConnection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._streamConnection)return;const{geometryType:e,spatialReference:s}=this.metadata,{maxReconnectionAttempts:i,maxReconnectionInterval:r,geometryDefinition:o,definitionExpression:a,customParameters:c}=this._schema.full;this._streamConnection=n(this._service.source,s,this._service.outSpatialReference,e,a,o,i,r,c),this._handlesGroup=t([this._streamConnection.on("data-received",e=>this._onFeature(e)),this._streamConnection.on("message-received",e=>this._onWebSocketMessage(e))]),this._connectionState.connection=this._streamConnection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(e){this._streamConnection?.updateCustomParameters(e)}sendMessageToSocket(e){this._streamConnection?.sendMessageToSocket(e)}sendMessageToClient(e){this._streamConnection?.sendMessageToClient(e)}_onOverride(){}_onWebSocketMessage(e){if("type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this.clear()}this.events.emit("message-received",e)}_onFeature(e){try{this._manager.add(e),this.events.emit("data-received",e)}catch(t){}}}export{m as StreamLoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,r,s){super(),this._reader=e,this._queryJSON=t,this._page=r,this._end=s,this.chunkId=`${this._page}${this.end?"e":""}`,this.normalizedChunkId=this.chunkId}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(e){const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}export{t as FeatureSnapshotSourceChunk};
5
+ import{ASourceChunk as e}from"./ASourceChunk.js";class t extends e{constructor(e,t,s,r,i=0){super(),this._reader=e,this._queryJSON=t,this._page=s,this._end=r,this._fileIndex=i,this.chunkId=`${this._fileIndex}.${this._page}${this.end?"e":""}`,this.normalizedChunkId=this.chunkId}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(e){const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}export{t as FeatureSnapshotSourceChunk};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{EventEmitter as e}from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as t}from"../../../FeatureStoreQueryAdapter.js";import{OverrideState as r}from"./Overrides.js";class o{constructor(s){this._metadata=s,this._chunks=new Map,this._chunksToRemove=[],this._overrides=new r,this.events=new e,this.featureAdapter=new t}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),this._overrides.clearWeakOverrides()}get usedMemory(){let e=0;for(const s of this._chunks.values())e+=s.usedMemory;return e}*chunks(){this._overrides&&(yield this._overrides.asChunk(this._metadata)),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrides.onChunkInsert(e),this._chunks.set(e.chunkId,e),this.events.emit("changed")}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}removeById(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e}] SourceChunkStore.remove`);const s=this._chunks.get(e);this._chunks.delete(e),s&&this._chunksToRemove.push(s)}cleanup(){const e=this._chunksToRemove;return this._chunksToRemove=[],this._overrides.cleanup(this._chunks.values()),e}applyOverride(e){this._overrides.apply(e,this),this.events.emit("changed");for(const s of this._chunks.values())s.invalidate()}takeOverrideUpdate(){return this._overrides.takeOverrideUpdate()}refresh(){this.events.emit("refresh")}forEach(e){const s=new Set;for(const t of this.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r.copy()),s.add(t))}}}forEachUnsafe(e){const s=new Set;for(const t of this.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r),s.add(t))}}}mapObjectIdsFromGlobalIds(e,s){const t=new Map,r=new Set(e);return this._overrides.putWeakObjectIdsFromGlobalIds(t,r,s),this._forEachUnsafeIgnoreOverrides(e=>{const o=e.readAttribute(s);if(o&&r.has(o)&&!t.has(o)){const s=e.getObjectId();t.set(o,s)}}),t}forEachInBounds(e,s){const t=new Set;for(const r of this.chunks()){const o=r.queryFeaturesInBounds(e);for(;o.next();){const e=o.getObjectId();t.has(e)||(s(o.copy()),t.add(e))}}}forEachBounds(e,t){const r=s();for(const s of e){s.getBounds(r)&&t(r)}}_forEachUnsafeIgnoreOverrides(e){const s=new Set;for(const t of this._chunks.values()){const r=t.reader.withoutOverrides().getCursor();for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r),s.add(t))}}}}export{o as FeatureSourceChunkStore};
5
+ import{EventEmitter as e}from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as t}from"../../../FeatureStoreQueryAdapter.js";import{OverrideState as r}from"./Overrides.js";class o{constructor(s){this._getMetadata=s,this._chunks=new Map,this._chunksToRemove=[],this._overrides=new r,this.events=new e,this.featureAdapter=new t}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),this._overrides.clearWeakOverrides()}get usedMemory(){let e=0;for(const s of this._chunks.values())e+=s.usedMemory;return e}*chunks(){this._overrides&&(yield this._overrides.asChunk(this._getMetadata())),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrides.onChunkInsert(e),this._chunks.set(e.chunkId,e),this.events.emit("changed")}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}removeById(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e}] SourceChunkStore.remove`);const s=this._chunks.get(e);this._chunks.delete(e),s&&this._chunksToRemove.push(s)}cleanup(){const e=this._chunksToRemove;return this._chunksToRemove=[],this._overrides.cleanup(this._chunks.values()),e}applyOverride(e){this._overrides.apply(e,this),this.events.emit("changed");for(const s of this._chunks.values())s.invalidate()}takeOverrideUpdate(){return this._overrides.takeOverrideUpdate()}refresh(){this.events.emit("refresh")}forEach(e){const s=new Set;for(const t of this.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r.copy()),s.add(t))}}}forEachUnsafe(e){const s=new Set;for(const t of this.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r),s.add(t))}}}mapObjectIdsFromGlobalIds(e,s){const t=new Map,r=new Set(e);return this._overrides.putWeakObjectIdsFromGlobalIds(t,r,s),this._forEachUnsafeIgnoreOverrides(e=>{const o=e.readAttribute(s);if(o&&r.has(o)&&!t.has(o)){const s=e.getObjectId();t.set(o,s)}}),t}forEachInBounds(e,s){const t=new Set;for(const r of this.chunks()){const o=r.queryFeaturesInBounds(e);for(;o.next();){const e=o.getObjectId();t.has(e)||(s(o.copy()),t.add(e))}}}forEachBounds(e,t){const r=s();for(const s of e){s.getBounds(r)&&t(r)}}_forEachUnsafeIgnoreOverrides(e){const s=new Set;for(const t of this._chunks.values()){const r=t.reader.withoutOverrides().getCursor();for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r),s.add(t))}}}}export{o as FeatureSourceChunkStore};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../../../core/has.js";import t from"../../../../../../../core/workers/Connection.js";import{toQuantizationTransform as e}from"../../../../../../../geometry/support/quantizationUtils.js";import{convertFromFeatureSet as r,quantizeOptimizedFeatureSet as a}from"../../../../../../../layers/graphics/featureConversionUtils.js";import{queryOptimizedFeatureSet as s}from"../../../../../../../layers/ogc/ogcFeatureUtils.js";import{executeQueryPBFBuffer as i,executeQuery as o}from"../../../../../../../rest/query/operations/query.js";import{FeatureSetReaderJSON as n}from"../../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderPBF as u}from"../../../support/FeatureSetReaderPBF.js";class c{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}function m(t,e){switch(t.type){case"memory":return new f(t,e);case"ogc":return new y(t,e);case"feature-service":return t.queryMetadata.supportsFormatPBF&&has("featurelayer-pbf")?new l(t,e):new d(t,e)}}async function p(e){const r=new t;return await r.open(e,{}),r}class f extends c{constructor(t,e){super(t,e),this._portsOpen=p(t.source).then(t=>this.client=t)}destroy(){this.client.close(),this.client=null}async executeQuery(t,e){await this._portsOpen;const r=await this.client.invoke("queryFeatures",t.toJSON(),e);return n.fromFeatureSet(r,this._metadata)}}class l extends c{async executeQuery(t,e){const{data:r}=await i(this.service.source,t,e),a=!t.quantizationParameters;return u.fromBuffer(r,this._metadata,a)}}class d extends c{async executeQuery(t,s){const{source:i,queryMetadata:u}=this.service;if(null!=t.quantizationParameters&&!u.supportsQuantization){const u=t.clone(),c=e(u.quantizationParameters);u.quantizationParameters=null;const{data:m}=await o(i,u,this._metadata.spatialReference,s),p=r(m,this._metadata.featureIdInfo);return a(c,p),n.fromOptimizedFeatureSet(p,this._metadata)}const{data:c}=await o(i,t,this._metadata.spatialReference,s);return"esriGeometryPoint"===this._metadata.geometryType&&(c.features=c.features?.filter(t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0})),n.fromFeatureSet(c,this._metadata)}}class y extends c{async executeQuery(t,r){if(t.quantizationParameters&&!this.service.queryMetadata.supportsQuantization){const i=t.clone(),o=e(i.quantizationParameters);i.quantizationParameters=null;const u=await s(this.service.source,t,r);return a(o,u),n.fromOptimizedFeatureSet(u,this._metadata)}const i=await s(this.service.source,t,r);return n.fromOptimizedFeatureSet(i,this._metadata)}}export{c as SourceAdapter,m as createQueryAdapter};
5
+ import has from"../../../../../../../core/has.js";import t from"../../../../../../../core/workers/Connection.js";import{toQuantizationTransform as e}from"../../../../../../../geometry/support/quantizationUtils.js";import{convertFromFeatureSet as a,quantizeOptimizedFeatureSet as r}from"../../../../../../../layers/graphics/featureConversionUtils.js";import{queryOptimizedFeatureSet as s}from"../../../../../../../layers/ogc/ogcFeatureUtils.js";import{executeQueryPBFBuffer as i,executeQuery as o}from"../../../../../../../rest/query/operations/query.js";import{FeatureSetReaderJSON as n}from"../../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderPBF as u}from"../../../support/FeatureSetReaderPBF.js";class c{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}function m(t,e,a){switch(t.type){case"memory":return new p(t,e,a);case"ogc":return new h(t,e);case"feature-service":return t.queryMetadata.supportsFormatPBF&&has("featurelayer-pbf")?new d(t,e):new f(t,e)}}async function l(e){const a=new t;return await a.open(e,{}),a}class p extends c{constructor(t,e,a){super(t,e),this._ports=[],this._loaded=this._load(a)}destroy(){this._loaded.finally(()=>{this._client.close(),this._client=null;for(const t of this._ports)t.close()}).catch(()=>{})}async _load(t){this._ports=await t.layerView.openMemoryPorts(),this._client=await l(this._ports)}async executeQuery(t,e){await this._loaded;const a=await this._client.invoke("queryFeatures",t.toJSON(),e);return n.fromFeatureSet(a,this._metadata)}}class d extends c{async executeQuery(t,e){const{data:a}=await i(this.service.source,t,e),r=!t.quantizationParameters;return u.fromBuffer(a,this._metadata,r)}}class f extends c{async executeQuery(t,s){const{source:i,queryMetadata:u}=this.service;if(null!=t.quantizationParameters&&!u.supportsQuantization){const u=t.clone(),c=e(u.quantizationParameters);u.quantizationParameters=null;const{data:m}=await o(i,u,this._metadata.spatialReference,s),l=a(m,this._metadata.featureIdInfo);return r(c,l),n.fromOptimizedFeatureSet(l,this._metadata)}const{data:c}=await o(i,t,this._metadata.spatialReference,s);return"esriGeometryPoint"===this._metadata.geometryType&&(c.features=c.features?.filter(t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0})),n.fromFeatureSet(c,this._metadata)}}class h extends c{async executeQuery(t,a){if(t.quantizationParameters&&!this.service.queryMetadata.supportsQuantization){const i=t.clone(),o=e(i.quantizationParameters);i.quantizationParameters=null;const u=await s(this.service.source,t,a);return r(o,u),n.fromOptimizedFeatureSet(u,this._metadata)}const i=await s(this.service.source,t,a);return n.fromOptimizedFeatureSet(i,this._metadata)}}export{c as SourceAdapter,m as createQueryAdapter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{QuantizedGeometryBuffer as r}from"../../../../../chunks/bundle.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";let s;class i extends n{constructor(t,r,n,s,i=new Uint32Array(n.size())){super(t),this._fields=r,this._inner=n,this._chunkId=s,this._displayIds=i,this._index=-1,this.usedMemory=e,this._size=this._inner.size();t.featureIdInfo.type,this._chunkId>65535&&console.error("Exceeded max allowed parquet reader size")}destroy(){super.destroy(),this._inner.free()}get fields(){return this._fields}get geometryType(){return this.metadata.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return null}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let e="";for(const t of this.fields.fields)e+=this._readAttribute(t.name,!1)+".";return e}getObjectId(){return this._inner.rowId(this._index)}getDisplayId(){return this._displayIds[this._index]}setDisplayId(e){this._displayIds[this._index]=e}setIndex(e){this._index=e}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(e){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){return this.readGeometryForDisplay()?.area()??0}copy(){const e=new i(this.metadata,this._fields,this._inner,this._chunkId,this._displayIds);return this.copyInto(e),e}copyInto(e){super.copyInto(e),e._index=this._index}readGeometryForDisplayTransformed(e){const[n,i]=e.translate,[d,o]=e.scale;s||(s=r.new());return this._inner.transformGeometry(s,n,i,d,o,this._index)?new t(s.readLengthsUnsafe(),s.readCoordsUnsafe()):null}_readGeometry(e){const r=this._inner.readCoords(this._index),n=this._inner.readLengths(this._index);return r&&n?new t(n,r):null}_readX(){return this._inner.readX(this._index)}_readY(){return this._inner.readY(this._index)}_readServerCentroid(){return null}_readAttribute(e,t){const r=this.fields.get(e);if(!r)return;if(null==r.column)return this.getObjectId();const n=this._inner.readAttribute(this._index,r.column);if(null==n)return n;const s=this.fields.isDateField(r.name);return t?null==n?n:s?new Date(n):n:n}_readAttributes(){const e={};for(const t of this._fields.fields)null!=t.column&&(this._inner.isEmpty(t.column)||(e[t.name]=this._readAttribute(t.name,!1)));return e.__OBJECTID=this.getObjectId(),e}}export{i as FeatureSetReaderParquet};
5
+ import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{QuantizedGeometryBuffer as r}from"../../../../../chunks/bundle.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";let s;class i extends n{constructor(t,r,n,s,i,d=new Uint32Array(n.size())){super(t),this._fields=r,this._inner=n,this._chunkId=s,this._fileIndex=i,this._displayIds=d,this._index=-1,this.usedMemory=e,this._size=this._inner.size();t.featureIdInfo.type,this._chunkId>65535&&console.error("Exceeded max allowed parquet reader size")}destroy(){super.destroy(),this._inner.free()}get fields(){return this._fields}get geometryType(){return this.metadata.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return null}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let e="";for(const t of this.fields.fields)e+=this._readAttribute(t.name,!1)+".";return e}getObjectId(){return this._fileIndex<<24|this._inner.rowId(this._index)}getDisplayId(){return this._displayIds[this._index]}setDisplayId(e){this._displayIds[this._index]=e}setIndex(e){this._index=e}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(e){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){return this.readGeometryForDisplay()?.area()??0}copy(){const e=new i(this.metadata,this._fields,this._inner,this._chunkId,this._fileIndex,this._displayIds);return this.copyInto(e),e}copyInto(e){super.copyInto(e),e._index=this._index}readGeometryForDisplayTransformed(e){const[n,i]=e.translate,[d,o]=e.scale;s||(s=r.new());return this._inner.transformGeometry(s,n,i,d,o,this._index)?new t(s.readLengthsUnsafe(),s.readCoordsUnsafe()):null}_readGeometry(e){const r=this._inner.readCoords(this._index),n=this._inner.readLengths(this._index);return r&&n?new t(n,r):null}_readX(){return this._inner.readX(this._index)}_readY(){return this._inner.readY(this._index)}_readServerCentroid(){return null}_readAttribute(e,t){const r=this.fields.get(e);if(!r)return;if(null==r.column)return this.getObjectId();const n=this._inner.readAttribute(this._index,r.column);if(null==n)return n;const s=this.fields.isDateField(r.name);return t?null==n?n:s?new Date(n):n:n}_readAttributes(){const e={};for(const t of this._fields.fields)null!=t.column&&(this._inner.isEmpty(t.column)||(e[t.name]=this._readAttribute(t.name,!1)));return e.__OBJECTID=this.getObjectId(),e}}export{i as FeatureSetReaderParquet};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import{EventedMixin as r}from"../../core/Evented.js";import{when as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import a from"../GroundView.js";let s=class extends(r(a)){constructor(e){super(e)}initialize(){super.initialize(),this.addHandles(t(()=>this._terrainSurface,e=>e.on("elevation-change",e=>this._elevationChange(e)))),this.addHandles(t(()=>this._integratedMeshGroundLayerView,e=>{this.removeHandles(o),e&&this.addHandles(e.elevationProvider.on("elevation-change",e=>this._elevationChange(e)),o)}))}_elevationChange(e){this.emit("elevation-change",e)}get _integratedMeshGroundLayerView(){const e=this.ground?.integratedMeshGround;if(e)return this.view.basemapView?.groundLayerViews.find(r=>r.layer===e)}get _terrainSurface(){return this.view.basemapTerrain}get _usingTerrain(){return this._terrainSurface?.enabled??!1}get _usingIntegratedMesh(){return this._integratedMeshGroundLayerView?.visible??!1}get spatialReference(){return this._terrainSurface?.spatialReference}intersect(e,r,t,n){this._source?.intersect(e,r,t,n)}get updating(){return!this.suspended&&((this._source?.updating??!1)||this.layerViews.some(({updating:e})=>e))}get elevationQueryCache(){return this._usingTerrain?this._terrainSurface?.elevationQueryCache:null}get extentAABR(){return this._terrainSurface?.extent}get suspended(){return this._source?.suspended??!1}get ready(){return this._source?.ready??!0}updateOverlayParameters(){this._terrainSurface?.updateOverlayParameters()}get _source(){return this._usingTerrain?this._terrainSurface:this._usingIntegratedMesh?this._integratedMeshGroundLayerView:null}requestRender(e){this.view.stage.renderView?.requestRender(e)}};e([n({readOnly:!0})],s.prototype,"_integratedMeshGroundLayerView",null),e([n({readOnly:!0})],s.prototype,"_terrainSurface",null),e([n({readOnly:!0})],s.prototype,"_usingTerrain",null),e([n({readOnly:!0})],s.prototype,"_usingIntegratedMesh",null),e([n({readOnly:!0})],s.prototype,"spatialReference",null),e([n({type:Boolean,readOnly:!0})],s.prototype,"updating",null),e([n({readOnly:!0})],s.prototype,"elevationQueryCache",null),e([n({readOnly:!0})],s.prototype,"extentAABR",null),e([n({readOnly:!0})],s.prototype,"suspended",null),e([n({readOnly:!0})],s.prototype,"ready",null),s=e([i("esri.views.3d.GroundView3D")],s);const o=Symbol("integratedMeshHandleKey");export{s as GroundView3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{isIterable as t}from"../../../../core/iteratorUtils.js";import{memoize as r}from"../../../../core/memoize.js";import{watch as i}from"../../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as o}from"../../../../core/unitUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{i as l}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../../geometry/ellipsoidUtils.js";import{create as p,fromPoints as u}from"../../../../geometry/support/ray.js";import{GeometryDescriptor as m}from"../../../../layers/support/GeometryDescriptor.js";import{externalToInternalIntersectOptions as d}from"../../support/hitTest.js";import{Intersector as y}from"../../webgl-engine/lib/Intersector.js";import{toGraphic as f}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{getInputGraphic as h}from"../../../analysis/ElevationProfile/elevationProfileGeometryUtils.js";import{ElevationProfileLineComputation as v}from"../../../analysis/ElevationProfile/ElevationProfileLineComputation.js";const _=2e5;let w=class extends v{constructor(){super(...arguments),this.type="scene",this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependenciesMemoized=r((e,t,r,i,o,n,s)=>({inputGraphicUid:j(e),visibleLayers:t,maxIntersectionDistance:r,intersectOptions:i,view:o,stationary:n,spatialReference:s})),this._vecA=a(),this._vecB=a(),this._ray=p()}get minDemResolution(){const e=this._view;if(!e)return null;const t=e.pointsOfInterest?.focus?.worldUnitsPerContentPixel;return null==t?null:t*o(e.spatialReference)}initialize(){const e=()=>this.onInvalidate(this);return this.addHandles([i(()=>this._queryElevationDependencies,e),this.controller.onElevationChange(e)])}async queryElevation(e,{noDataValue:t,signal:r}){const i=this._queryElevationDependencies;if(null==i)throw new Error(`${this.declaredClass}: no dependencies`);const o=this._intersector;if(null==o)throw new Error(`${this.declaredClass}: no view`);const{intersectOptions:n,view:s,spatialReference:a}=i,c=s.renderCoordsHelper,p=s.sceneIntersectionHelper,d=this._vecA,y=this._vecA,f=this._vecB,h=this._ray;if(!a)return{geometry:e,noDataValue:t};const v=await m.fromGeometry(e).project(a,r);if(!v)return{geometry:e,noDataValue:t};const w=v.coordinates,j=w.length;for(let m=0;m<j;++m){const e=w[m];l(f,e.x,e.y,e.z??0),c.toRenderCoords(f,a,f),c.setAltitude(d,_,f);const r=u(d,f,h);p.computeIntersection(r,o,!0,n);const s=g(i,o.results.all);s?(s.getIntersectionPoint(y),c.fromRenderCoords(y,y,a),e.z=y[2]):e.z=t}return{geometry:v.export(),noDataValue:t}}get _queryElevationDependencies(){const e=this._view;return e?this._getQueryElevationDependenciesMemoized(this.controller?.analysis.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}get _intersectOptions(){const e=this._view;if(!e||e.destroyed)return{};const{include:r,exclude:i}=this.profileLine;return d(e,{include:r,exclude:[...this._pointCloudLayers,...t(i)?i:i?[i]:[]]})}get _pointCloudLayers(){const e=this._view;return e?e.allLayerViews.toArray().filter(e=>"point-cloud"===e.layer?.type).map(e=>e.layer):[]}get _view(){const e=this.controller.view;return"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return e?.renderCoordsHelper?c(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY}get _intersector(){const e=this._view;if(!e)return null;const t=new y(e.state.viewingMode),r=t.options;return r.hud=!1,r.invisibleTerrain=!1,r.backfacesTerrain=!1,r.selectionMode=!1,r.store=2,t}};function g({view:e,inputGraphicUid:t,maxIntersectionDistance:r},i){for(const o of i){if(!o.withinDistance(r))continue;const i=f(o,e);if(null==i||j(i)!==t)return o}return null}function j(e){const t=h(e);if(!t)return null;if(t.layer&&"objectIdField"in t.layer){const e=t.attributes[t.layer.objectIdField];if(e)return`o-${t.layer.id}-${e}`}return`u-${t.uid}`}e([n({readOnly:!0})],w.prototype,"minDemResolution",null),e([n()],w.prototype,"_queryElevationDependencies",null),e([n()],w.prototype,"_visibleLayers",null),e([n()],w.prototype,"_intersectOptions",null),e([n()],w.prototype,"_pointCloudLayers",null),e([n()],w.prototype,"_view",null),e([n()],w.prototype,"_maxIntersectionDistance",null),e([n()],w.prototype,"_intersector",null),w=e([s("esri.views.3d.analysis.ElevationProfile.ElevationProfileSceneLineComputation")],w);export{w as ElevationProfileSceneLineComputation};
5
+ import{__decorate as e}from"tslib";import{isIterable as t}from"../../../../core/iteratorUtils.js";import{memoize as r}from"../../../../core/memoize.js";import{watch as i}from"../../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as o}from"../../../../core/unitUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{i as l}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../../geometry/ellipsoidUtils.js";import{create as p,fromPoints as u}from"../../../../geometry/support/ray.js";import{GeometryDescriptor as m}from"../../../../layers/support/GeometryDescriptor.js";import{externalToInternalIntersectOptions as d}from"../../support/hitTest.js";import{Intersector as y}from"../../webgl-engine/lib/Intersector.js";import{toGraphic as f}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{getInputGraphic as h}from"../../../analysis/ElevationProfile/elevationProfileGeometryUtils.js";import{ElevationProfileLineComputation as v}from"../../../analysis/ElevationProfile/ElevationProfileLineComputation.js";const _=2e5;let w=class extends v{constructor(){super(...arguments),this.type="scene",this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependenciesMemoized=r((e,t,r,i,o,n,s)=>({inputGraphicUid:j(e),visibleLayers:t,maxIntersectionDistance:r,intersectOptions:i,view:o,stationary:n,spatialReference:s})),this._vecA=a(),this._vecB=a(),this._ray=p()}get minDemResolution(){const e=this._view;if(!e)return null;const t=e.pointsOfInterest?.focus?.worldUnitsPerContentPixel;return null==t?null:t*o(e.spatialReference)}initialize(){const e=()=>this.onInvalidate(this);return this.addHandles([i(()=>this._queryElevationDependencies,e),this.controller.onElevationChange(e)])}async queryElevation(e,{noDataValue:t,signal:r}){const i=this._queryElevationDependencies;if(null==i)throw new Error(`${this.declaredClass}: no dependencies`);const o=this._intersector;if(null==o)throw new Error(`${this.declaredClass}: no view`);const{intersectOptions:n,view:s,spatialReference:a}=i,c=s.renderCoordsHelper,p=s.sceneIntersectionHelper,d=this._vecA,y=this._vecA,f=this._vecB,h=this._ray;if(!a)return{geometry:e,noDataValue:t};const v=await m.fromGeometry(e).project(a,r);if(!v)return{geometry:e,noDataValue:t};const w=v.coordinates,j=w.length;for(let m=0;m<j;++m){const e=w[m];l(f,e.x,e.y,e.z??0),c.toRenderCoords(f,a,f),c.setAltitude(d,_,f);const r=u(d,f,h);p.computeIntersection(r,o,!0,n);const s=g(i,o.results.all);s?(s.getIntersectionPoint(y),c.fromRenderCoords(y,y,a),e.z=y[2]):e.z=t}return{geometry:v.export(),noDataValue:t}}get _queryElevationDependencies(){const e=this._view;return e?this._getQueryElevationDependenciesMemoized(this.controller?.analysis.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}get _intersectOptions(){const e=this._view;if(!e||e.destroyed)return{};const{include:r,exclude:i}=this.profileLine;return d(e,{include:r,exclude:[...this._pointCloudLayers,...t(i)?i:i?[i]:[]]})}get _pointCloudLayers(){const e=this._view;return e?e.allLayerViews.toArray().filter(e=>"point-cloud"===e.layer?.type).map(e=>e.layer):[]}get _view(){const e=this.controller.view;return"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return e?.renderCoordsHelper?c(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY}get _intersector(){const e=this._view;if(!e)return null;const t=new y(e.state.viewingMode),r=t.options;return r.hud=!1,r.invisibleTerrain=!1,r.backfacesTerrain=!1,r.selectionMode=!1,r.store=2,t}};function g({view:e,inputGraphicUid:t,maxIntersectionDistance:r},i){for(const o of i){if(!o.withinDistance(r))continue;const i=f(o,e);if(null==i||j(i)!==t)return o}return null}function j(e){const t=h(e);if(!t)return null;if(t.layer&&"objectIdField"in t.layer){const e=t.attributes[t.layer.objectIdField];if(e)return`o-${t.layer.id}-${e}`}return`u-${t.uid}`}e([n({readOnly:!0})],w.prototype,"minDemResolution",null),e([n()],w.prototype,"_queryElevationDependencies",null),e([n()],w.prototype,"_visibleLayers",null),e([n()],w.prototype,"_intersectOptions",null),e([n()],w.prototype,"_pointCloudLayers",null),e([n()],w.prototype,"_view",null),e([n()],w.prototype,"_maxIntersectionDistance",null),e([n()],w.prototype,"_intersector",null),w=e([s("esri.views.3d.analysis.ElevationProfile.ElevationProfileLineSceneComputation")],w);export{w as ElevationProfileLineSceneComputation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{AnalysisView3D as r}from"./AnalysisView3D.js";import{ElevationProfileSceneLineComputation as i}from"./ElevationProfile/ElevationProfileSceneLineComputation.js";import{ElevationProfileVisualization3D as s}from"./ElevationProfile/ElevationProfileVisualization3D.js";import{ElevationProfileController as l}from"../../analysis/ElevationProfile/ElevationProfileController.js";import{ElevationProfileGroundLineComputation as n}from"../../analysis/ElevationProfile/ElevationProfileGroundLineComputation.js";import{ElevationProfileInputLineComputation as a}from"../../analysis/ElevationProfile/ElevationProfileInputLineComputation.js";import{ElevationProfileQueryLineComputation as p}from"../../analysis/ElevationProfile/ElevationProfileQueryLineComputation.js";import{ElevationProfileTool as c}from"../../analysis/ElevationProfile/ElevationProfileTool.js";let u=class extends r{constructor(t){super(t),this.type="elevation-profile-view-3d",this.analysis=null,this.hoveredPosition=null}initialize(){const{analysis:t,view:e}=this;this._controller=new l({analysis:t,analysisViewData:this,view:e,computationFactory:{create:t=>{switch(t.profileLine.type){case"ground":return new n(t);case"input":return new a(t);case"query":return new p(t);case"scene":return new i(t)}}}}),this._visualization=new s({view:e,analysisViewData:this}),this._sketchTool=new c({view:e,analysisViewData:this})}destroy(){this._controller.destroy(),this._visualization.destroy(),this._sketchTool?.destroy()}get effectiveUnits(){return this._controller.effectiveUnits}get error(){return this._controller.error}get hoveredPoints(){return this._controller.hoveredPoints}get interactive(){return super.interactive}set interactive(t){super.interactive=t}get progress(){return this._controller.progress}get results(){return this._controller.results}get statistics(){return this._controller.statistics}get updating(){return!0===this._controller.updating||!0===this._visualization.updating||!0===this._sketchTool?.updating}get visible(){return super.visible}set visible(t){super.visible=t}get sketchGraphic(){return this._sketchTool?.sketchGraphic}get toolState(){return this._sketchTool?.state??"idle"}place(t){return this._sketchTool.place(t)}pickGraphic(t){return this._sketchTool.pickGraphic(t)}};t([e({readOnly:!0})],u.prototype,"type",void 0),t([e({constructOnly:!0,nonNullable:!0})],u.prototype,"analysis",void 0),t([e({readOnly:!0})],u.prototype,"effectiveUnits",null),t([e({readOnly:!0})],u.prototype,"error",null),t([e()],u.prototype,"hoveredPosition",void 0),t([e()],u.prototype,"hoveredPoints",null),t([e({readOnly:!0})],u.prototype,"progress",null),t([e({readOnly:!0})],u.prototype,"results",null),t([e({readOnly:!0})],u.prototype,"statistics",null),t([e({readOnly:!0})],u.prototype,"updating",null),t([e()],u.prototype,"sketchGraphic",null),t([e()],u.prototype,"toolState",null),t([e()],u.prototype,"_controller",void 0),t([e()],u.prototype,"_visualization",void 0),t([e()],u.prototype,"_sketchTool",void 0),u=t([o("esri.views.3d.analysis.ElevationProfileAnalysisView3D")],u);const h=u;export{h as default};
5
+ import{__decorate as t}from"tslib";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{AnalysisView3D as r}from"./AnalysisView3D.js";import{ElevationProfileLineSceneComputation as i}from"./ElevationProfile/ElevationProfileLineSceneComputation.js";import{ElevationProfileVisualization3D as s}from"./ElevationProfile/ElevationProfileVisualization3D.js";import{ElevationProfileController as l}from"../../analysis/ElevationProfile/ElevationProfileController.js";import{ElevationProfileLineGroundComputation as n}from"../../analysis/ElevationProfile/ElevationProfileLineGroundComputation.js";import{ElevationProfileLineInputComputation as a}from"../../analysis/ElevationProfile/ElevationProfileLineInputComputation.js";import{ElevationProfileLineQueryComputation as p}from"../../analysis/ElevationProfile/ElevationProfileLineQueryComputation.js";import{ElevationProfileTool as c}from"../../analysis/ElevationProfile/ElevationProfileTool.js";let u=class extends r{constructor(t){super(t),this.type="elevation-profile-view-3d",this.analysis=null,this.hoveredPosition=null}initialize(){const{analysis:t,view:e}=this;this._controller=new l({analysis:t,analysisViewData:this,view:e,computationFactory:{create:t=>{switch(t.profileLine.type){case"ground":return new n(t);case"input":return new a(t);case"query":return new p(t);case"scene":return new i(t)}}}}),this._visualization=new s({view:e,analysisViewData:this}),this._sketchTool=new c({view:e,analysisViewData:this})}destroy(){this._controller.destroy(),this._visualization.destroy(),this._sketchTool?.destroy()}get effectiveUnits(){return this._controller.effectiveUnits}get error(){return this._controller.error}get hoveredPoints(){return this._controller.hoveredPoints}get interactive(){return super.interactive}set interactive(t){super.interactive=t}get progress(){return this._controller.progress}get results(){return this._controller.results}get statistics(){return this._controller.statistics}get updating(){return!0===this._controller.updating||!0===this._visualization.updating||!0===this._sketchTool?.updating}get visible(){return super.visible}set visible(t){super.visible=t}get sketchGraphic(){return this._sketchTool?.sketchGraphic}get toolState(){return this._sketchTool?.state??"idle"}place(t){return this._sketchTool.place(t)}pickGraphic(t){return this._sketchTool.pickGraphic(t)}};t([e({readOnly:!0})],u.prototype,"type",void 0),t([e({constructOnly:!0,nonNullable:!0})],u.prototype,"analysis",void 0),t([e({readOnly:!0})],u.prototype,"effectiveUnits",null),t([e({readOnly:!0})],u.prototype,"error",null),t([e()],u.prototype,"hoveredPosition",void 0),t([e()],u.prototype,"hoveredPoints",null),t([e({readOnly:!0})],u.prototype,"progress",null),t([e({readOnly:!0})],u.prototype,"results",null),t([e({readOnly:!0})],u.prototype,"statistics",null),t([e({readOnly:!0})],u.prototype,"updating",null),t([e()],u.prototype,"sketchGraphic",null),t([e()],u.prototype,"toolState",null),t([e()],u.prototype,"_controller",void 0),t([e()],u.prototype,"_visualization",void 0),t([e()],u.prototype,"_sketchTool",void 0),u=t([o("esri.views.3d.analysis.ElevationProfileAnalysisView3D")],u);const h=u;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import o from"../../../../Color.js";const t=new o("black");class i{constructor(){this.geometryOutlineWidth=1.5,this.targetGeometryOutlineColor=new o("grey"),this.cutColor=new o([153,198,111,.9]),this.fillColor=new o([200,200,230,.8]),this.cutProjectionLineColor=o.blendColors(this.cutColor,t,.4),this.fillProjectionLineColor=o.blendColors(this.fillColor,t,.4),this.projectionLineWidth=2,this.projectionLineStippleSize=4}}const e=new i;export{e as cutFillConfiguration};
5
+ import o from"../../../../Color.js";const t=new o("black");class i{constructor(){this.geometryOutlineWidth=1.5,this.targetGeometryOutlineColor=new o("grey"),this.cutColor=new o([153,198,111,.9]),this.fillColor=new o([200,200,230,.8]),this.cutProjectionLineColor=o.blendColors(this.cutColor,t,.4),this.fillProjectionLineColor=o.blendColors(this.fillColor,t,.4),this.projectionLineWidth=2,this.projectionLineStippleSize=4,this.labelDistance=40}}const e=new i;export{i as CutFillVisualizationConfiguration,e as cutFillConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../Color.js";import i from"../../../../core/Accessor.js";import{destroyMaybe as o}from"../../../../core/maybe.js";import{watch as s,initial as r}from"../../../../core/reactiveUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{e as a}from"../../../../chunks/earcut.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as c}from"../../../../chunks/vec32.js";import{create as p,fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as h}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as d}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as y}from"../../../../geometry/support/Indices.js";import{t as g}from"../../../../chunks/vec3.js";import f from"../../../../symbols/support/ElevationInfo.js";import{cutFillConfiguration as v}from"./VolumeMeasurementConfiguration.js";import{LineVisualElement as j}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as _}from"../../interactive/visualElements/OutlineVisualElement.js";import{GeodesicSegment as G}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as w}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as b}from"../../layers/graphics/Graphics3DExtrudeSymbolLayer.js";import{geometryToRenderInfo as C}from"../../support/renderInfoUtils/polygon.js";import{CutFillColor as V,VolumeGeometry as L}from"../../webgl-engine/lib/CutFillColor.js";import{createStipplePatternSimple as R}from"../../webgl-engine/materials/lineStippleUtils.js";let A=class extends i{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}constructor(e){super(e),this._elevationContext=w.fromElevationInfo(new f({mode:"absolute-height"})),this._extrusionHeight=1e4}initialize(){const{view:e}=this,{accentColor:i}=e.effectiveTheme,o={view:e,isDecoration:!0},n=v,l={...o,width:n.geometryOutlineWidth},a=t.toUnitRGBA(i),m=t.toUnitRGBA(n.targetGeometryOutlineColor);this._elevationAlignedGeometry=new _({...l,isDraped:!0,color:a}),this._targetGeometry=new _({...l,color:m});const c={...o,attached:!0,width:n.projectionLineWidth,stipplePattern:R(n.projectionLineStippleSize),renderOccluded:4},p=t.toUnitRGBA(n.cutProjectionLineColor),u=t.toUnitRGBA(n.fillProjectionLineColor);this._cutProjectionLines=new j({...c,color:p}),this._fillProjectionLines=new j({...c,color:u}),this._cutFillRenderNode=new V({view:e,cutColor:n.cutColor,fillColor:n.fillColor}),this.addHandles([s(()=>[this.analysisViewData.elevationAlignedGeometry,this.analysisViewData.targetGeometry,this.visible],()=>this._updateVisualElements()),s(()=>this.view.effectiveTheme.accentColor,e=>{this._elevationAlignedGeometry.color=t.toUnitRGBA(e)}),s(()=>this.analysisViewData.targetGeometry,()=>this._updateCutFillGeometry(),r),s(()=>this.visible,()=>this._updateCutFillVisibility())])}destroy(){this._elevationAlignedGeometry=o(this._elevationAlignedGeometry),this._targetGeometry=o(this._targetGeometry),this._cutProjectionLines=o(this._cutProjectionLines),this._fillProjectionLines=o(this._fillProjectionLines),this._cutFillRenderNode.destroy()}_updateVisualElements(){this._updateGeometries(),this._updateProjectionLines()}_updateGeometries(){const e=this.visible,{elevationAlignedGeometry:t,targetGeometry:i}=this.analysisViewData;this._elevationAlignedGeometry.geometry=t,this._elevationAlignedGeometry.visible=e,this._targetGeometry.geometry=i,this._targetGeometry.visible=e}_updateProjectionLines(){const e=this.visible,{elevationAlignedGeometry:t,targetGeometry:i}=this.analysisViewData;if(this._cutProjectionLines.visible=e,this._fillProjectionLines.visible=e,!t||!i)return;const{renderCoordsHelper:o}=this.view,s=o.spatialReference,r=[],n=[],l=t.spatialReference;for(let a=0;a<t.rings[0].length;++a){const e=t.rings[0][a],m=c(P,e[0],e[1],e[2]);o.toRenderCoords(m,l,m);const p=i.rings[0][a],u=c(x,p[0],p[1],p[2]);o.toRenderCoords(u,l,u);const h=new G(m,u,s);m[2]>u[2]?r.push(h):n.push(h)}this._cutProjectionLines.setGeometryFromSegments(r),this._fillProjectionLines.setGeometryFromSegments(n)}_updateCutFillVisibility(){this.visible?this._cutFillRenderNode.enable():this._cutFillRenderNode.disable()}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData;if(!t?.extent)return;const{center:i}=t.extent,o=u(i.x,i.y,0),s=p();e.toRenderCoords(o,t.spatialReference,s);const r=this._getExtrudedVolumes(t,this._extrusionHeight,o),n=this._getExtrudedVolumes(t,-this._extrusionHeight,o);this._cutFillRenderNode.updateGeometries(r,n,s)}_getExtrudedVolumes(e,t,i){const{renderCoordsHelper:o,spatialReference:s,elevationProvider:r}=this.view,n=p(),l=1===o.viewingMode;l||o.worldUpAtPosition([0,0,0],n);const c=C(e,r,o,this._elevationContext),{polygons:u,mapPositions:f,position:v}=c,j=u[0],_=j.count,G=a(j.mapPositions,j.holeIndices,3),w=G.length,V=6*_,R=y(V+w),A=y(w),P=d(3*V),x=d(3*V);b(v,f,G,j,P,null,x,null,R,A,t,n,l);const D=m(),E=m();return h(s,i,D,o.spatialReference),E[12]=-D[12],E[13]=-D[13],E[14]=-D[14],g(P,P,E),new L(P,A,R,x)}};e([n({constructOnly:!0})],A.prototype,"view",void 0),e([n({constructOnly:!0})],A.prototype,"analysisViewData",void 0),e([n({readOnly:!0})],A.prototype,"visible",null),A=e([l("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],A);const P=p(),x=p();export{A as VolumeMeasurementCutFillVisualization};
5
+ import{__decorate as e}from"tslib";import t from"../../../../Color.js";import"../../../../intl.js";import i from"../../../../core/Accessor.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{formatDecimal as o}from"../../../../core/quantityFormatUtils.js";import{watch as l,initial as r}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as n}from"../../../../core/unitUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{e as u}from"../../../../chunks/earcut.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as p}from"../../../../chunks/vec32.js";import{create as h,fromValues as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as g}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as f}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as y}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import _ from"../../../../symbols/support/ElevationInfo.js";import{cutFillConfiguration as b}from"./VolumeMeasurementConfiguration.js";import{LabelVisualElement as j}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as V}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as w}from"../../interactive/visualElements/OutlineVisualElement.js";import{GeodesicSegment as L}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as G}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as C}from"../../layers/graphics/Graphics3DExtrudeSymbolLayer.js";import{geometryToRenderInfo as A}from"../../support/renderInfoUtils/polygon.js";import{CutFillColor as x,VolumeGeometry as M}from"../../webgl-engine/lib/CutFillColor.js";import{createStipplePatternSimple as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{onLocaleChange as D}from"../../../../intl/locale.js";import{fetchMessageBundle as P}from"../../../../intl/messages.js";import{substitute as E}from"../../../../intl/substitute.js";let U=class extends i{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=G.fromElevationInfo(new _({mode:"absolute-height"})),this._extrusionHeight=1e4}initialize(){const{view:e}=this,{accentColor:i}=e.effectiveTheme,s={view:e,isDecoration:!0},o=b,n={...s,width:o.geometryOutlineWidth},a=t.toUnitRGBA(i),m=t.toUnitRGBA(o.targetGeometryOutlineColor);this._elevationAlignedGeometry=new w({...n,isDraped:!0,color:a}),this._targetGeometry=new w({...n,color:m});const u={...s,attached:!0,width:o.projectionLineWidth,stipplePattern:R(o.projectionLineStippleSize),renderOccluded:4},c=t.toUnitRGBA(o.cutProjectionLineColor),p=t.toUnitRGBA(o.fillProjectionLineColor);this._cutProjectionLines=new V({...u,color:c}),this._fillProjectionLines=new V({...u,color:p});const h={...s,attached:!0};this._cutVolumeLabel=new j(h),this._fillVolumeLabel=new j(h),this._cutFillRenderNode=new x({view:e,cutColor:o.cutColor,fillColor:o.fillColor}),this.addHandles([l(()=>[this.analysisViewData.elevationAlignedGeometry,this.analysisViewData.targetGeometry,this.visible],()=>this._updateVisualElements()),l(()=>this.view.effectiveTheme.accentColor,e=>{this._elevationAlignedGeometry.color=t.toUnitRGBA(e)}),l(()=>this.analysisViewData.targetGeometry,()=>this._updateCutFillGeometry(),r),l(()=>this.visible,()=>this._updateCutFillVisibility()),l(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{labelAnchors:s.labelAnchors,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i}},e=>this._updateLabels(e)),D(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=s(this._elevationAlignedGeometry),this._targetGeometry=s(this._targetGeometry),this._cutProjectionLines=s(this._cutProjectionLines),this._fillProjectionLines=s(this._fillProjectionLines),this._cutVolumeLabel=s(this._cutVolumeLabel),this._fillVolumeLabel=s(this._fillVolumeLabel),this._cutFillRenderNode.destroy()}get _config(){return b}_updateVisualElements(){this._updateGeometries(),this._updateProjectionLines()}_updateGeometries(){const e=this.visible,{elevationAlignedGeometry:t,targetGeometry:i}=this.analysisViewData;this._elevationAlignedGeometry.geometry=t,this._elevationAlignedGeometry.visible=e,this._targetGeometry.geometry=i,this._targetGeometry.visible=e}_updateProjectionLines(){const e=this.visible,{elevationAlignedGeometry:t,targetGeometry:i}=this.analysisViewData;if(this._cutProjectionLines.visible=e,this._fillProjectionLines.visible=e,!t||!i)return;const{renderCoordsHelper:s}=this.view,o=s.spatialReference,l=[],r=[],n=t.spatialReference;for(let a=0;a<t.rings[0].length;++a){const e=t.rings[0][a],m=p(S,e[0],e[1],e[2]);s.toRenderCoords(m,n,m);const u=i.rings[0][a],c=p(B,u[0],u[1],u[2]);s.toRenderCoords(c,n,c);const h=new L(m,c,o);m[2]>c[2]?l.push(h):r.push(h)}this._cutProjectionLines.setGeometryFromSegments(l),this._fillProjectionLines.setGeometryFromSegments(r)}_updateLabels(e){const{labelDistance:t}=this._config,{effectiveDisplayUnits:i,labelAnchors:s,messages:o,unitsMessages:l,result:r,visible:n}=e;if(this._cutVolumeLabel.visible=n,this._fillVolumeLabel.visible=n,this._cutVolumeLabel.geometry=s.cut?{type:"point",point:s.cut,callout:{distance:t,offset:0}}:null,this._fillVolumeLabel.geometry=s.fill?{type:"point",point:s.fill,callout:{distance:-t,offset:0}}:null,null==r||null==o||null==l)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=i.volume,m=E(o.labels.cut,{volume:F(l,r.cutVolume,a)}),u=E(o.labels.fill,{volume:F(l,r.fillVolume,a)});this._cutVolumeLabel.text=m,this._fillVolumeLabel.text=u}_updateCutFillVisibility(){this.visible?this._cutFillRenderNode.enable():this._cutFillRenderNode.disable()}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData;if(!t?.extent)return;const{center:i}=t.extent,s=d(i.x,i.y,0),o=h();e.toRenderCoords(s,t.spatialReference,o);const l=this._getExtrudedVolumes(t,this._extrusionHeight,s),r=this._getExtrudedVolumes(t,-this._extrusionHeight,s);this._cutFillRenderNode.updateGeometries(l,r,o)}_getExtrudedVolumes(e,t,i){const{renderCoordsHelper:s,spatialReference:o,elevationProvider:l}=this.view,r=h(),n=1===s.viewingMode;n||s.worldUpAtPosition([0,0,0],r);const a=A(e,l,s,this._elevationContext),{polygons:m,mapPositions:p,position:d}=a,_=m[0],b=_.count,j=u(_.mapPositions,_.holeIndices,3),V=j.length,w=6*b,L=y(w+V),G=y(V),x=f(3*w),R=f(3*w);C(d,p,j,_,x,null,R,null,L,G,t,r,n);const D=c(),P=c();return g(o,i,D,s.spatialReference),P[12]=-D[12],P[13]=-D[13],P[14]=-D[14],v(x,x,P),new M(x,G,L,R)}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await P("esri/core/t9n/Units"),this.messages=await P("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function F(e,t,i){return e&&t&&o(e,t,n(t.value,t.unit,i))}e([a({constructOnly:!0})],U.prototype,"view",void 0),e([a({constructOnly:!0})],U.prototype,"analysisViewData",void 0),e([a()],U.prototype,"unitsMessages",void 0),e([a()],U.prototype,"messages",void 0),e([a()],U.prototype,"loadingMessages",void 0),e([a({readOnly:!0})],U.prototype,"visible",null),e([a()],U.prototype,"updating",null),U=e([m("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],U);const S=h(),B=h();export{U as VolumeMeasurementCutFillVisualization};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../core/has.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{verticalLengthUnitFromSpatialReference as i,convertUnit as s}from"../../../core/unitUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{getDefaultUnitForView as r}from"../../../support/getDefaultUnitForView.js";import{AnalysisView3D as a}from"./AnalysisView3D.js";import{VolumeMeasurementCutFillController as n}from"./VolumeMeasurement/VolumeMeasurementCutFillController.js";import{VolumeMeasurementCutFillVisualization as u}from"./VolumeMeasurement/VolumeMeasurementCutFillVisualization.js";import p from"./VolumeMeasurement/VolumeMeasurementTool.js";let m=class extends a{constructor(e){super(e),this.type="volume-measurement-view-3d",this.analysis=null,this.elevationAlignedGeometry=null,this.targetGeometry=null}initialize(){const{analysis:e,view:t}=this;this._analysisController=new n({view:t,analysis:e,analysisViewData:this}),this._analysisTool=new p({analysis:e,view:t,analysisViewData:this}),this._analysisVisualization=new u({view:t,analysisViewData:this})}destroy(){this._analysisController=t(this._analysisController),this._analysisVisualization=t(this._analysisVisualization),this._analysisTool.destroy()}get result(){return this._analysisController?.result}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get visible(){return super.visible}set visible(e){super.visible=e}get effectiveTargetElevation(){const{cutFillOptions:e,inputUnits:t}=this.analysis,{targetElevation:l}=e,o=t?.elevation??"meters",r=i(this.view.spatialReference);if(null!=l&&null!=r)return s(l,o,r);const a=this.elevationAlignedGeometry?.extent;return null==a?.zmin||null==a?.zmax?null:(a.zmax+a.zmin)/2}get effectiveDisplayUnits(){const{displayUnits:e}=this.analysis,t=r(this.view);return{elevation:e.elevation??t,volume:e.volume??t}}get updating(){return null!=this._analysisController&&this._analysisController.updating||this._analysisTool.updating}place(e){return this._analysisTool.place(e)}get test(){}};e([l({readOnly:!0})],m.prototype,"type",void 0),e([l({constructOnly:!0,nonNullable:!0})],m.prototype,"analysis",void 0),e([l({readOnly:!0})],m.prototype,"result",null),e([l()],m.prototype,"elevationAlignedGeometry",void 0),e([l({type:Number})],m.prototype,"effectiveTargetElevation",null),e([l()],m.prototype,"targetGeometry",void 0),e([l()],m.prototype,"effectiveDisplayUnits",null),e([l()],m.prototype,"updating",null),m=e([o("esri.views.3d.analysis.VolumeMeasurementAnalysisView3D")],m);const y=m;export{y as default};
5
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{verticalLengthUnitFromSpatialReference as i,convertUnit as s}from"../../../core/unitUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../geometry/Point.js";import{getDefaultUnitForView as a}from"../../../support/getDefaultUnitForView.js";import{AnalysisView3D as u}from"./AnalysisView3D.js";import{VolumeMeasurementCutFillController as p}from"./VolumeMeasurement/VolumeMeasurementCutFillController.js";import{VolumeMeasurementCutFillVisualization as m}from"./VolumeMeasurement/VolumeMeasurementCutFillVisualization.js";import y from"./VolumeMeasurement/VolumeMeasurementTool.js";let c=class extends u{constructor(e){super(e),this.type="volume-measurement-view-3d",this.analysis=null,this.elevationAlignedGeometry=null,this.targetGeometry=null}initialize(){const{analysis:e,view:t}=this;this._analysisController=new p({view:t,analysis:e,analysisViewData:this}),this._analysisTool=new y({analysis:e,view:t,analysisViewData:this}),this._analysisVisualization=new m({view:t,analysisViewData:this})}destroy(){this._analysisController=t(this._analysisController),this._analysisVisualization=t(this._analysisVisualization),this._analysisTool.destroy()}get result(){return this._analysisController?.result}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get visible(){return super.visible}set visible(e){super.visible=e}get effectiveTargetElevation(){const{cutFillOptions:e,inputUnits:t}=this.analysis,{targetElevation:l}=e,o=t?.elevation??"meters",r=i(this.view.spatialReference);if(null!=l&&null!=r)return s(l,o,r);const n=this.elevationAlignedGeometry?.extent;return null==n?.zmin||null==n?.zmax?null:(n.zmax+n.zmin)/2}get effectiveDisplayUnits(){const{displayUnits:e}=this.analysis,t=a(this.view);return{elevation:e.elevation??t,volume:e.volume??t}}get labelAnchors(){const{elevationAlignedGeometry:e,view:t}=this,{renderCoordsHelper:i}=t;if(!e)return{cut:null,fill:null};let s=e.rings[0][0],l=e.rings[0][0];e.rings[0].forEach(e=>{e[2]>s[2]&&(s=e),e[2]<l[2]&&(l=e)});const{spatialReference:o}=e,a=new n({x:s[0],y:s[1],z:s[2],spatialReference:o}),u=new n({x:l[0],y:l[1],z:l[2],spatialReference:o}),p=r(),m=r();return i.toRenderCoords(a,p),i.toRenderCoords(u,m),{cut:p,fill:m}}get updating(){return null!=this._analysisController&&this._analysisController.updating||this._analysisTool.updating||this._analysisVisualization.updating}place(e){return this._analysisTool.place(e)}get test(){}};e([l({readOnly:!0})],c.prototype,"type",void 0),e([l({constructOnly:!0,nonNullable:!0})],c.prototype,"analysis",void 0),e([l({readOnly:!0})],c.prototype,"result",null),e([l()],c.prototype,"elevationAlignedGeometry",void 0),e([l({type:Number})],c.prototype,"effectiveTargetElevation",null),e([l()],c.prototype,"targetGeometry",void 0),e([l()],c.prototype,"effectiveDisplayUnits",null),e([l()],c.prototype,"labelAnchors",null),e([l()],c.prototype,"updating",null),c=e([o("esri.views.3d.analysis.VolumeMeasurementAnalysisView3D")],c);const v=c;export{v as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{getKey as o}from"../../../../core/object.js";import{allSettledValues as n}from"../../../../core/promiseUtils.js";import{isDataProtocol as s,dataComponents as a,dataToArrayBuffer as i,makeAbsolute as u}from"../../../../core/urlUtils.js";import{Version as f}from"../../../../core/Version.js";import{fromXRotation as c,multiply as d,translate as l,rotate as p,scale as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h,clone as b}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getAxisAngle as w}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{BufferViewVec2f as g,BufferViewVec2u32 as T,BufferViewVec2u16 as _,BufferViewVec2i16 as x,BufferViewVec2u8 as O,BufferViewVec2i8 as N,BufferViewUint32 as S,BufferViewUint16 as C,BufferViewUint8 as A,BufferViewVec3f as L,BufferViewVec4f as E,BufferViewVec4u8 as R,BufferViewVec4u16 as I,BufferViewVec3u8 as v,BufferViewVec3u16 as D}from"../../../../geometry/support/buffer/BufferView.js";import{m as B}from"../../../../chunks/scalar.js";import"../../../../core/has.js";import{getDracoMeshDecoder as U}from"../../../../libs/dracoMeshDecoder/dracoMeshDecoder.js";import{BinaryStreamReader as M}from"./BinaryStreamReader.js";import{material as j,textureSampler as G}from"./fillDefaults.js";import{splitURI as F}from"./pathUtils.js";import{jsonFromBinaryData as H,EncodedMeshTexture as P,imageFromBinaryData as V,isEncodedMeshTexture as z}from"./resourceUtils.js";import{DataType as K}from"../../../webgl/enums.js";const k={MAGIC:1179937895,CHUNK_TYPE_JSON:1313821514,CHUNK_TYPE_BIN:5130562};class Y{constructor(t,r,o,n){if(this._context=t,this.uri=r,this.json=o,this._glbBuffer=n,this._bufferLoaders=new Map,this._textureLoaders=new Map,this._dracoBuffersSize=0,this._textureCache=new Map,this._materialCache=new Map,this._nodeParentMap=new Map,this._nodeTransformCache=new Map,this._supportedExtensions=["KHR_texture_basisu","KHR_texture_transform","KHR_draco_mesh_compression"],this._baseUri=F(this.uri).dirPart,this._checkVersionSupported(),this._checkRequiredExtensionsSupported(),null==o.scenes)throw new e("gltf-loader-unsupported-feature","Scenes must be defined.");if(null==o.meshes)throw new e("gltf-loader-unsupported-feature","Meshes must be defined");if(null==o.nodes)throw new e("gltf-loader-unsupported-feature","Nodes must be defined.");this._computeNodeParents()}static async load(t,r,o){if(s(r)){const e=a(r);if(e&&"model/gltf-binary"!==e.mediaType)try{const o=JSON.parse(e.isBase64?atob(e.data):e.data);return new Y(t,r,o)}catch{}const o=i(r);if(Y._isGLBData(o))return this._fromGLBData(t,r,o)}if(te.test(r)||"gltf"===o?.expectedType){const e=await t.loadJSON(r,o);return new Y(t,r,e)}const n=await t.loadBinary(r,o);if(Y._isGLBData(n))return this._fromGLBData(t,r,n);if(re.test(r)||"glb"===o?.expectedType)throw new e("gltf-loader-invalid-glb","This is not a valid glb file.");const u=await t.loadJSON(r,o);return new Y(t,r,u)}static _isGLBData(e){if(null==e)return!1;const t=new M(e);return t.remainingBytes()>=4&&t.readUint32()===k.MAGIC}static async _fromGLBData(e,t,r){const o=await Y._parseGLBData(r);return new Y(e,t,o.json,o.binaryData)}static async _parseGLBData(r){const o=new M(r);if(o.remainingBytes()<12)throw new e("gltf-loader-error","glb binary data is insufficiently large.");const n=o.readUint32(),s=o.readUint32(),a=o.readUint32();if(n!==k.MAGIC)throw new e("gltf-loader-error","Magic first 4 bytes do not fit to expected glb value.");if(r.byteLength<a)throw new e("gltf-loader-error","glb binary data is smaller than header specifies.");if(2!==s)throw new e("gltf-loader-unsupported-feature","An unsupported glb container version was detected. Only version 2 is supported.");let i,u,f=0;for(;o.remainingBytes()>=8;){const r=o.readUint32(),n=o.readUint32();if(0===f){if(n!==k.CHUNK_TYPE_JSON)throw new e("gltf-loader-error","First glb chunk must be JSON.");if(r<0)throw new e("gltf-loader-error","No JSON data found.");i=await H(o.readUint8Array(r))}else if(1===f){if(n!==k.CHUNK_TYPE_BIN)throw new e("gltf-loader-unsupported-feature","Second glb chunk expected to be BIN.");u=o.readUint8Array(r)}else t.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] More than 2 glb chunks detected. Skipping.");f+=1}if(!i)throw new e("gltf-loader-error","No glb JSON chunk detected.");return{json:i,binaryData:u}}async getBuffer(t,r){const o=this.json.buffers[t];if(null==o.uri){if(null==this._glbBuffer)throw new e("gltf-loader-error","glb buffer not present");return this._glbBuffer}const n=await this._getBufferLoader(t,r);if(n.byteLength!==o.byteLength)throw new e("gltf-loader-error","Buffer byte lengths should match.");return n}async _getBufferLoader(e,t){const r=this._bufferLoaders.get(e);if(r)return r;const o=this.json.buffers[e].uri,n=this._context.loadBinary(this._resolveUri(o),t).then(e=>new Uint8Array(e));return this._bufferLoaders.set(e,n),n}_validateAccessor(t){if(!this.json.accessors)throw new e("gltf-loader-unsupported-feature","Accessors missing.");const r=this.json.accessors[t];if(r.type in["MAT2","MAT3","MAT4"])throw new e("gltf-loader-unsupported-feature",`AttributeType ${r.type} is not supported`);return r}_getComponentInfo(e,t){const r=$[e.type],o=t?.componentType||e.componentType,n=W[o];return{componentType:o,componentCount:r,componentByteSize:n,denseByteStride:r*n}}getDracoAccessor(e,t){const r=this._validateAccessor(e),o=t.accessorInfos.get(e),{componentType:n,componentCount:s,componentByteSize:a,denseByteStride:i}=this._getComponentInfo(r,o);return{raw:t.data.buffer,byteStride:i,byteOffset:t.data.byteOffset+(o?.byteOffset||0),entryCount:o?.count??r.count,isDenselyPacked:!0,componentCount:s,componentByteSize:a,componentType:n,min:r.min,max:r.max,normalized:!!r.normalized}}async getAccessor(t,r){const o=this._validateAccessor(t);if(null==o?.bufferView)throw new e("gltf-loader-unsupported-feature","Some accessor does not specify a bufferView.");const{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=this.json.bufferViews[o.bufferView],u=await this.getBuffer(i.buffer,r),f=i.byteStride||a;return{raw:u.buffer,byteStride:f,byteOffset:u.byteOffset+(i.byteOffset||0)+(o.byteOffset||0),entryCount:o.count,isDenselyPacked:f===a,componentCount:n,componentByteSize:s,componentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getIndexData(e,t,r){if(null==e.indices)return;const o=e.indices,n=r?this.getDracoAccessor(o,r):await this.getAccessor(o,t);if(n.isDenselyPacked)switch(n.componentType){case K.UNSIGNED_BYTE:return new Uint8Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_SHORT:return new Uint16Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_INT:return new Uint32Array(n.raw,n.byteOffset,n.entryCount)}else switch(n.componentType){case K.UNSIGNED_BYTE:return B(Z(A,n));case K.UNSIGNED_SHORT:return B(Z(C,n));case K.UNSIGNED_INT:return B(Z(S,n))}}async getPositionData(t,r,n){if(null==t.attributes.POSITION)throw new e("gltf-loader-unsupported-feature","No POSITION vertex data found.");const s=t.attributes.POSITION,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for POSITION vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","POSITION vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getNormalData(t,r,n){if(null==t.attributes.NORMAL)throw new e("gltf-loader-error","No NORMAL vertex data found.");const s=t.attributes.NORMAL,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for NORMAL vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","NORMAL vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getTangentData(t,r,n){if(null==t.attributes.TANGENT)throw new e("gltf-loader-error","No TANGENT vertex data found.");const s=t.attributes.TANGENT,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for TANGENT vertex attribute, but found "+o(K,a.componentType));if(4!==a.componentCount)throw new e("gltf-loader-unsupported-feature","TANGENT vertex attribute must have 4 components, but found "+a.componentCount.toFixed());return Z(E,a)}async getTextureCoordinates(t,r,o){if(null==t.attributes.TEXCOORD_0)throw new e("gltf-loader-error","No TEXCOORD_0 vertex data found.");const n=t.attributes.TEXCOORD_0,s=o?this.getDracoAccessor(n,o):await this.getAccessor(n,r);if(2!==s.componentCount)throw new e("gltf-loader-unsupported-feature","TEXCOORD_0 vertex attribute must have 2 components, but found "+s.componentCount.toFixed());if(s.componentType===K.FLOAT)return Z(g,s);if(!s.normalized)throw new e("gltf-loader-unsupported-feature","Integer component types are only supported for a normalized accessor for TEXCOORD_0.");return Q(s)}async getVertexColors(t,r,n){if(null==t.attributes.COLOR_0)throw new e("gltf-loader-error","No COLOR_0 vertex data found.");const s=t.attributes.COLOR_0,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(4!==a.componentCount&&3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","COLOR_0 attribute must have 3 or 4 components, but found "+a.componentCount.toFixed());if(4===a.componentCount){if(a.componentType===K.FLOAT)return Z(E,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(R,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(I,a)}else if(3===a.componentCount){if(a.componentType===K.FLOAT)return Z(L,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(v,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(D,a)}throw new e("gltf-loader-unsupported-feature","Unsupported component type for COLOR_0 attribute: "+o(K,a.componentType))}hasPositions(e){return void 0!==e.attributes.POSITION}hasNormals(e){return void 0!==e.attributes.NORMAL}hasVertexColors(e){return void 0!==e.attributes.COLOR_0}hasTextureCoordinates(e){return void 0!==e.attributes.TEXCOORD_0}hasTangents(e){return void 0!==e.attributes.TANGENT}async getMaterial(e,t,r){let o=e.material?this._materialCache.get(e.material):void 0;if(!o){const n=null!=e.material?j(this.json.materials[e.material]):j(),s=n.pbrMetallicRoughness,a=this.hasVertexColors(e),i=this.getTexture(s.baseColorTexture,t),u=this.getTexture(n.normalTexture,t),f=r?this.getTexture(n.occlusionTexture,t):void 0,c=r?this.getTexture(n.emissiveTexture,t):void 0,d=r?this.getTexture(s.metallicRoughnessTexture,t):void 0,l=null!=e.material?e.material:-1;o={alphaMode:n.alphaMode,alphaCutoff:n.alphaCutoff,color:s.baseColorFactor,doubleSided:!!n.doubleSided,colorTexture:await i,normalTexture:await u,name:n.name,id:l,occlusionTexture:await f,emissiveTexture:await c,emissiveFactor:n.emissiveFactor,metallicFactor:s.metallicFactor,roughnessFactor:s.roughnessFactor,metallicRoughnessTexture:await d,hasVertexColors:a,ESRI_externalColorMixMode:n.extras.ESRI_externalColorMixMode,colorTextureTransform:s?.baseColorTexture?.extensions?.KHR_texture_transform,normalTextureTransform:n.normalTexture?.extensions?.KHR_texture_transform,occlusionTextureTransform:n.occlusionTexture?.extensions?.KHR_texture_transform,emissiveTextureTransform:n.emissiveTexture?.extensions?.KHR_texture_transform,metallicRoughnessTextureTransform:s?.metallicRoughnessTexture?.extensions?.KHR_texture_transform,receiveAmbientOcclusion:n.extras.ESRI_receiveAmbientOcclusion,receiveShadows:n.extras.ESRI_receiveShadows}}return o}async decode(t,r){const o=t.extensions?.KHR_draco_mesh_compression;if(!o)return;if(null==t.indices)throw new e("gltf-loader-error","Found Draco compressed primitive without indices.");const n=this.json.bufferViews[o.bufferView],s=await this.getBuffer(n.buffer,r),a=(await U()).decode(new Uint8Array(s.buffer,n.byteOffset,n.byteLength));this._bufferLoaders.delete(n.buffer);const i=new Map([[t.indices,a.indices],[t.attributes.POSITION,a.positions]]);return t.attributes.TEXCOORD_0&&i.set(t.attributes.TEXCOORD_0,a.uvs),t.attributes.NORMAL&&i.set(t.attributes.NORMAL,a.normals),t.attributes.COLOR_0&&i.set(t.attributes.COLOR_0,a.colors),t.attributes.TANGENT&&i.set(t.attributes.TANGENT,a.tangents),this._dracoBuffersSize+=a.buffer.byteLength,{data:a.buffer,accessorInfos:i}}async getTexture(t,o){if(!t)return;if(0!==(t.texCoord||0))throw new e("gltf-loader-unsupported-feature","Only TEXCOORD with index 0 is supported.");const n=t.index,s=this.json.textures[n],a=G(null!=s.sampler?this.json.samplers[s.sampler]:{}),i=ee(s),u=this.json.images[i],f=await this._loadTextureImageData(n,s,o);return r(this._textureCache,n,()=>{const t=e=>33071===e||33648===e||10497===e,r=t=>{throw new e("gltf-loader-error",`Unexpected TextureSampler WrapMode: ${t}`)};return{data:f,wrapS:t(a.wrapS)?a.wrapS:r(a.wrapS),wrapT:t(a.wrapT)?a.wrapT:r(a.wrapT),minFilter:a.minFilter,name:u.name,id:n}})}getNodeTransform(e){if(void 0===e)return X;let t=this._nodeTransformCache.get(e);if(!t){const r=this.getNodeTransform(this._getNodeParent(e)),o=this.json.nodes[e];o.matrix?t=d(h(),r,o.matrix):o.translation||o.rotation||o.scale?(t=b(r),o.translation&&l(t,t,o.translation),o.rotation&&(J[3]=w(J,o.rotation),p(t,t,J[3],J)),o.scale&&m(t,t,o.scale)):t=b(r),this._nodeTransformCache.set(e,t)}return t}_resolveUri(e){return u(e,this._baseUri)}_getNodeParent(e){return this._nodeParentMap.get(e)}_checkVersionSupported(){const e=f.parse(this.json.asset.version,"glTF");q.validate(e)}_checkRequiredExtensionsSupported(){const t=this.json;if(t.extensionsRequired){if(!t.extensionsRequired.every(e=>this._supportedExtensions.includes(e)))throw new e("gltf-loader-unsupported-feature","gltf loader was not able to load unsupported feature. Required extensions: "+t.extensionsRequired.join(", "))}}_computeNodeParents(){this.json.nodes.forEach((e,t)=>{e.children&&e.children.forEach(e=>{this._nodeParentMap.set(e,t)})})}async _loadTextureImageData(e,t,r){const o=this._textureLoaders.get(e);if(o)return o;const n=this._createTextureLoader(t,r);return this._textureLoaders.set(e,n),n}async _createTextureLoader(t,r){const o=ee(t),n=this.json.images[o];if(n.uri){if(n.uri.endsWith(".ktx2")){const e=await this._context.loadBinary(this._resolveUri(n.uri),r);return new P(new Uint8Array(e))}return this._context.loadImage(this._resolveUri(n.uri),r)}if(null==n.bufferView)throw new e("gltf-loader-unsupported-feature","Image bufferView must be defined.");if(null==n.mimeType)throw new e("gltf-loader-unsupported-feature","Image mimeType must be defined.");const s=this.json.bufferViews[n.bufferView],a=await this.getBuffer(s.buffer,r);if(null!=s.byteStride)throw new e("gltf-loader-unsupported-feature","byteStride not supported for image buffer");const i=a.byteOffset+(s.byteOffset||0);return V(new Uint8Array(a.buffer,i,s.byteLength),n.mimeType)}async getLoadedBuffersSize(){if(this._glbBuffer)return this._glbBuffer.byteLength;const e=await n(Array.from(this._bufferLoaders.values())),t=await n(Array.from(this._textureLoaders.values()));return e.reduce((e,t)=>e+(t?.byteLength??0),0)+this._dracoBuffersSize+t.reduce((e,t)=>e+(t?z(t)?t.data.byteLength:t.width*t.height*4:0),0)}}const X=c(h(),Math.PI/2),q=new f(2,0,"glTF"),J=y(),$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W={[K.BYTE]:1,[K.UNSIGNED_BYTE]:1,[K.SHORT]:2,[K.UNSIGNED_SHORT]:2,[K.HALF_FLOAT]:2,[K.FLOAT]:4,[K.INT]:4,[K.UNSIGNED_INT]:4};function Q(e){switch(e.componentType){case K.BYTE:return new N(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_BYTE:return new O(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.SHORT:return new x(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_SHORT:return new _(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_INT:return new T(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.FLOAT:return new g(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount)}}function Z(e,t){return new e(t.raw,t.byteOffset,t.byteStride,t.byteOffset+t.byteStride*(t.entryCount-1)+t.componentByteSize*t.componentCount)}function ee(t){if(null!=t.extensions?.KHR_texture_basisu)return t.extensions.KHR_texture_basisu.source;if(null!==t.source)return t.source;throw new e("gltf-loader-unsupported-feature","Source is expected to be defined for a texture. It can also be omitted in favour of an KHR_texture_basisu extension tag.")}const te=/\.gltf$/i,re=/\.glb$/i;export{Y as GLTFResource,X as transformGltfToEngine};
5
+ import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{getKey as o}from"../../../../core/object.js";import{allSettledValues as n}from"../../../../core/promiseUtils.js";import{isDataProtocol as s,dataComponents as a,dataToArrayBuffer as i,makeAbsolute as u}from"../../../../core/urlUtils.js";import{Version as f}from"../../../../core/Version.js";import{fromXRotation as c,multiply as d,translate as l,rotate as p,scale as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h,clone as b}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getAxisAngle as w}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{BufferViewVec2f as g,BufferViewVec2u32 as T,BufferViewVec2u16 as _,BufferViewVec2i16 as x,BufferViewVec2u8 as O,BufferViewVec2i8 as N,BufferViewUint32 as S,BufferViewUint16 as C,BufferViewUint8 as A,BufferViewVec3f as L,BufferViewVec4f as E,BufferViewVec4u8 as R,BufferViewVec4u16 as I,BufferViewVec3u8 as v,BufferViewVec3u16 as D}from"../../../../geometry/support/buffer/BufferView.js";import{m as B}from"../../../../chunks/scalar.js";import"../../../../core/has.js";import{getDracoMeshDecoder as U}from"../../../../libs/dracoMeshDecoder/dracoMeshDecoder.js";import{BinaryStreamReader as M}from"./BinaryStreamReader.js";import{material as j,textureSampler as G}from"./fillDefaults.js";import{splitURI as F}from"./pathUtils.js";import{jsonFromBinaryData as H,EncodedMeshTexture as P,imageFromBinaryData as V,isEncodedMeshTexture as z}from"./resourceUtils.js";import{DataType as K}from"../../../webgl/enums.js";const k={MAGIC:1179937895,CHUNK_TYPE_JSON:1313821514,CHUNK_TYPE_BIN:5130562};class Y{constructor(t,r,o,n){if(this._context=t,this.uri=r,this.json=o,this._glbBuffer=n,this._bufferLoaders=new Map,this._textureLoaders=new Map,this._dracoBuffersSize=0,this._textureCache=new Map,this._materialCache=new Map,this._nodeParentMap=new Map,this._nodeTransformCache=new Map,this._supportedExtensions=["KHR_texture_basisu","KHR_texture_transform","KHR_draco_mesh_compression"],this._baseUri=F(this.uri).dirPart,this._checkVersionSupported(),this._checkRequiredExtensionsSupported(),null==o.scenes)throw new e("gltf-loader-unsupported-feature","Scenes must be defined.");if(null==o.meshes)throw new e("gltf-loader-unsupported-feature","Meshes must be defined");if(null==o.nodes)throw new e("gltf-loader-unsupported-feature","Nodes must be defined.");this._computeNodeParents()}static async load(t,r,o){if(s(r)){const e=a(r);if(e&&"model/gltf-binary"!==e.mediaType)try{const o=JSON.parse(e.isBase64?atob(e.data):e.data);return new Y(t,r,o)}catch{}const o=i(r);if(Y._isGLBData(o))return this._fromGLBData(t,r,o)}if(te.test(r)||"gltf"===o?.expectedType){const e=await t.loadJSON(r,o);return new Y(t,r,e)}const n=await t.loadBinary(r,o);if(Y._isGLBData(n))return this._fromGLBData(t,r,n);if(re.test(r)||"glb"===o?.expectedType)throw new e("gltf-loader-invalid-glb","This is not a valid glb file.");const u=await t.loadJSON(r,o);return new Y(t,r,u)}static _isGLBData(e){if(null==e)return!1;const t=new M(e);return t.remainingBytes()>=4&&t.readUint32()===k.MAGIC}static async _fromGLBData(e,t,r){const o=await Y._parseGLBData(r);return new Y(e,t,o.json,o.binaryData)}static async _parseGLBData(r){const o=new M(r);if(o.remainingBytes()<12)throw new e("gltf-loader-error","glb binary data is insufficiently large.");const n=o.readUint32(),s=o.readUint32(),a=o.readUint32();if(n!==k.MAGIC)throw new e("gltf-loader-error","Magic first 4 bytes do not fit to expected glb value.");if(r.byteLength<a)throw new e("gltf-loader-error","glb binary data is smaller than header specifies.");if(2!==s)throw new e("gltf-loader-unsupported-feature","An unsupported glb container version was detected. Only version 2 is supported.");let i,u,f=0;for(;o.remainingBytes()>=8;){const r=o.readUint32(),n=o.readUint32();if(0===f){if(n!==k.CHUNK_TYPE_JSON)throw new e("gltf-loader-error","First glb chunk must be JSON.");if(r<0)throw new e("gltf-loader-error","No JSON data found.");i=await H(o.readUint8Array(r))}else if(1===f){if(n!==k.CHUNK_TYPE_BIN)throw new e("gltf-loader-unsupported-feature","Second glb chunk expected to be BIN.");u=o.readUint8Array(r)}else t.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] More than 2 glb chunks detected. Skipping.");f+=1}if(!i)throw new e("gltf-loader-error","No glb JSON chunk detected.");return{json:i,binaryData:u}}async getBuffer(t,r){const o=this.json.buffers[t];if(null==o.uri){if(null==this._glbBuffer)throw new e("gltf-loader-error","glb buffer not present");return this._glbBuffer}const n=await this._getBufferLoader(t,r);if(n.byteLength!==o.byteLength)throw new e("gltf-loader-error","Buffer byte lengths should match.");return n}async _getBufferLoader(e,t){const r=this._bufferLoaders.get(e);if(r)return r;const o=this.json.buffers[e].uri,n=this._context.loadBinary(this._resolveUri(o),t).then(e=>new Uint8Array(e));return this._bufferLoaders.set(e,n),n}_validateAccessor(t){if(!this.json.accessors)throw new e("gltf-loader-unsupported-feature","Accessors missing.");const r=this.json.accessors[t];if(r.type in["MAT2","MAT3","MAT4"])throw new e("gltf-loader-unsupported-feature",`AttributeType ${r.type} is not supported`);return r}_getComponentInfo(e,t){const r=$[e.type],o=t?.componentType||e.componentType,n=W[o];return{componentType:o,componentCount:r,componentByteSize:n,denseByteStride:r*n}}getDracoAccessor(e,t){const r=this._validateAccessor(e),o=t.accessorInfos.get(e),{componentType:n,componentCount:s,componentByteSize:a,denseByteStride:i}=this._getComponentInfo(r,o);return{raw:t.data.buffer,byteStride:i,byteOffset:t.data.byteOffset+(o?.byteOffset||0),entryCount:o?.count??r.count,isDenselyPacked:!0,componentCount:s,componentByteSize:a,componentType:n,min:r.min,max:r.max,normalized:!!r.normalized}}async getAccessor(t,r){const o=this._validateAccessor(t);if(null==o?.bufferView)throw new e("gltf-loader-unsupported-feature","Some accessor does not specify a bufferView.");const{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=this.json.bufferViews[o.bufferView],u=await this.getBuffer(i.buffer,r),f=i.byteStride||a;return{raw:u.buffer,byteStride:f,byteOffset:u.byteOffset+(i.byteOffset||0)+(o.byteOffset||0),entryCount:o.count,isDenselyPacked:f===a,componentCount:n,componentByteSize:s,componentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getIndexData(e,t,r){if(null==e.indices)return;const o=e.indices,n=r?this.getDracoAccessor(o,r):await this.getAccessor(o,t);if(n.isDenselyPacked)switch(n.componentType){case K.UNSIGNED_BYTE:return new Uint8Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_SHORT:return new Uint16Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_INT:return new Uint32Array(n.raw,n.byteOffset,n.entryCount)}else switch(n.componentType){case K.UNSIGNED_BYTE:return B(Z(A,n));case K.UNSIGNED_SHORT:return B(Z(C,n));case K.UNSIGNED_INT:return B(Z(S,n))}}async getPositionData(t,r,n){if(null==t.attributes.POSITION)throw new e("gltf-loader-unsupported-feature","No POSITION vertex data found.");const s=t.attributes.POSITION,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for POSITION vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","POSITION vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getNormalData(t,r,n){if(null==t.attributes.NORMAL)throw new e("gltf-loader-error","No NORMAL vertex data found.");const s=t.attributes.NORMAL,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for NORMAL vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","NORMAL vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getTangentData(t,r,n){if(null==t.attributes.TANGENT)throw new e("gltf-loader-error","No TANGENT vertex data found.");const s=t.attributes.TANGENT,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for TANGENT vertex attribute, but found "+o(K,a.componentType));if(4!==a.componentCount)throw new e("gltf-loader-unsupported-feature","TANGENT vertex attribute must have 4 components, but found "+a.componentCount.toFixed());return Z(E,a)}async getTextureCoordinates(t,r,o){if(null==t.attributes.TEXCOORD_0)throw new e("gltf-loader-error","No TEXCOORD_0 vertex data found.");const n=t.attributes.TEXCOORD_0,s=o?this.getDracoAccessor(n,o):await this.getAccessor(n,r);if(2!==s.componentCount)throw new e("gltf-loader-unsupported-feature","TEXCOORD_0 vertex attribute must have 2 components, but found "+s.componentCount.toFixed());if(s.componentType===K.FLOAT)return Z(g,s);if(!s.normalized)throw new e("gltf-loader-unsupported-feature","Integer component types are only supported for a normalized accessor for TEXCOORD_0.");return Q(s)}async getVertexColors(t,r,n){if(null==t.attributes.COLOR_0)throw new e("gltf-loader-error","No COLOR_0 vertex data found.");const s=t.attributes.COLOR_0,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(4!==a.componentCount&&3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","COLOR_0 attribute must have 3 or 4 components, but found "+a.componentCount.toFixed());if(4===a.componentCount){if(a.componentType===K.FLOAT)return Z(E,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(R,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(I,a)}else if(3===a.componentCount){if(a.componentType===K.FLOAT)return Z(L,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(v,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(D,a)}throw new e("gltf-loader-unsupported-feature","Unsupported component type for COLOR_0 attribute: "+o(K,a.componentType))}hasPositions(e){return void 0!==e.attributes.POSITION}hasNormals(e){return void 0!==e.attributes.NORMAL}hasVertexColors(e){return void 0!==e.attributes.COLOR_0}hasTextureCoordinates(e){return void 0!==e.attributes.TEXCOORD_0}hasTangents(e){return void 0!==e.attributes.TANGENT}async getMaterial(e,t,r){let o=e.material?this._materialCache.get(e.material):void 0;if(!o){const n=null!=e.material?j(this.json.materials[e.material]):j(),s=n.pbrMetallicRoughness,a=this.hasVertexColors(e),i=this.getTexture(s.baseColorTexture,t),u=this.getTexture(n.normalTexture,t),f=r?this.getTexture(n.occlusionTexture,t):void 0,c=r?this.getTexture(n.emissiveTexture,t):void 0,d=r?this.getTexture(s.metallicRoughnessTexture,t):void 0,l=null!=e.material?e.material:-1;o={alphaMode:n.alphaMode,alphaCutoff:n.alphaCutoff,color:s.baseColorFactor,doubleSided:!!n.doubleSided,colorTexture:await i,normalTexture:await u,name:n.name,id:l,occlusionTexture:await f,emissiveTexture:await c,emissiveFactor:n.emissiveFactor,metallicFactor:s.metallicFactor,roughnessFactor:s.roughnessFactor,metallicRoughnessTexture:await d,hasVertexColors:a,ESRI_externalColorMixMode:n.extras.ESRI_externalColorMixMode,colorTextureTransform:s?.baseColorTexture?.extensions?.KHR_texture_transform,normalTextureTransform:n.normalTexture?.extensions?.KHR_texture_transform,occlusionTextureTransform:n.occlusionTexture?.extensions?.KHR_texture_transform,emissiveTextureTransform:n.emissiveTexture?.extensions?.KHR_texture_transform,metallicRoughnessTextureTransform:s?.metallicRoughnessTexture?.extensions?.KHR_texture_transform,receiveAmbientOcclusion:n.extras.ESRI_receiveAmbientOcclusion,receiveShadows:n.extras.ESRI_receiveShadows}}return o}async decode(t,r){const o=t.extensions?.KHR_draco_mesh_compression;if(!o)return;if(null==t.indices)throw new e("gltf-loader-error","Found Draco compressed primitive without indices.");const n=this.json.bufferViews[o.bufferView],s=await this.getBuffer(n.buffer,r),a=(await U()).decode(new Uint8Array(s.buffer,s.byteOffset+(n.byteOffset||0),n.byteLength));this._bufferLoaders.delete(n.buffer);const i=new Map([[t.indices,a.indices],[t.attributes.POSITION,a.positions]]);return t.attributes.TEXCOORD_0&&i.set(t.attributes.TEXCOORD_0,a.uvs),t.attributes.NORMAL&&i.set(t.attributes.NORMAL,a.normals),t.attributes.COLOR_0&&i.set(t.attributes.COLOR_0,a.colors),t.attributes.TANGENT&&i.set(t.attributes.TANGENT,a.tangents),this._dracoBuffersSize+=a.buffer.byteLength,{data:a.buffer,accessorInfos:i}}async getTexture(t,o){if(!t)return;if(0!==(t.texCoord||0))throw new e("gltf-loader-unsupported-feature","Only TEXCOORD with index 0 is supported.");const n=t.index,s=this.json.textures[n],a=G(null!=s.sampler?this.json.samplers[s.sampler]:{}),i=ee(s),u=this.json.images[i],f=await this._loadTextureImageData(n,s,o);return r(this._textureCache,n,()=>{const t=e=>33071===e||33648===e||10497===e,r=t=>{throw new e("gltf-loader-error",`Unexpected TextureSampler WrapMode: ${t}`)};return{data:f,wrapS:t(a.wrapS)?a.wrapS:r(a.wrapS),wrapT:t(a.wrapT)?a.wrapT:r(a.wrapT),minFilter:a.minFilter,name:u.name,id:n}})}getNodeTransform(e){if(void 0===e)return X;let t=this._nodeTransformCache.get(e);if(!t){const r=this.getNodeTransform(this._getNodeParent(e)),o=this.json.nodes[e];o.matrix?t=d(h(),r,o.matrix):o.translation||o.rotation||o.scale?(t=b(r),o.translation&&l(t,t,o.translation),o.rotation&&(J[3]=w(J,o.rotation),p(t,t,J[3],J)),o.scale&&m(t,t,o.scale)):t=b(r),this._nodeTransformCache.set(e,t)}return t}_resolveUri(e){return u(e,this._baseUri)}_getNodeParent(e){return this._nodeParentMap.get(e)}_checkVersionSupported(){const e=f.parse(this.json.asset.version,"glTF");q.validate(e)}_checkRequiredExtensionsSupported(){const t=this.json;if(t.extensionsRequired){if(!t.extensionsRequired.every(e=>this._supportedExtensions.includes(e)))throw new e("gltf-loader-unsupported-feature","gltf loader was not able to load unsupported feature. Required extensions: "+t.extensionsRequired.join(", "))}}_computeNodeParents(){this.json.nodes.forEach((e,t)=>{e.children&&e.children.forEach(e=>{this._nodeParentMap.set(e,t)})})}async _loadTextureImageData(e,t,r){const o=this._textureLoaders.get(e);if(o)return o;const n=this._createTextureLoader(t,r);return this._textureLoaders.set(e,n),n}async _createTextureLoader(t,r){const o=ee(t),n=this.json.images[o];if(n.uri){if(n.uri.endsWith(".ktx2")){const e=await this._context.loadBinary(this._resolveUri(n.uri),r);return new P(new Uint8Array(e))}return this._context.loadImage(this._resolveUri(n.uri),r)}if(null==n.bufferView)throw new e("gltf-loader-unsupported-feature","Image bufferView must be defined.");if(null==n.mimeType)throw new e("gltf-loader-unsupported-feature","Image mimeType must be defined.");const s=this.json.bufferViews[n.bufferView],a=await this.getBuffer(s.buffer,r);if(null!=s.byteStride)throw new e("gltf-loader-unsupported-feature","byteStride not supported for image buffer");const i=a.byteOffset+(s.byteOffset||0);return V(new Uint8Array(a.buffer,i,s.byteLength),n.mimeType)}async getLoadedBuffersSize(){if(this._glbBuffer)return this._glbBuffer.byteLength;const e=await n(Array.from(this._bufferLoaders.values())),t=await n(Array.from(this._textureLoaders.values()));return e.reduce((e,t)=>e+(t?.byteLength??0),0)+this._dracoBuffersSize+t.reduce((e,t)=>e+(t?z(t)?t.data.byteLength:t.width*t.height*4:0),0)}}const X=c(h(),Math.PI/2),q=new f(2,0,"glTF"),J=y(),$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W={[K.BYTE]:1,[K.UNSIGNED_BYTE]:1,[K.SHORT]:2,[K.UNSIGNED_SHORT]:2,[K.HALF_FLOAT]:2,[K.FLOAT]:4,[K.INT]:4,[K.UNSIGNED_INT]:4};function Q(e){switch(e.componentType){case K.BYTE:return new N(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_BYTE:return new O(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.SHORT:return new x(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_SHORT:return new _(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_INT:return new T(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.FLOAT:return new g(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount)}}function Z(e,t){return new e(t.raw,t.byteOffset,t.byteStride,t.byteOffset+t.byteStride*(t.entryCount-1)+t.componentByteSize*t.componentCount)}function ee(t){if(null!=t.extensions?.KHR_texture_basisu)return t.extensions.KHR_texture_basisu.source;if(null!==t.source)return t.source;throw new e("gltf-loader-unsupported-feature","Source is expected to be defined for a texture. It can also be omitted in favour of an KHR_texture_basisu extension tag.")}const te=/\.gltf$/i,re=/\.glb$/i;export{Y as GLTFResource,X as transformGltfToEngine};