@arcgis/core 5.0.0-next.7 → 5.0.0-next.9
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.
- package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{8f56f298e7c1a283f407.js → 0030d68d9edf42b4af57.js} +1 -1
- package/assets/esri/core/workers/chunks/01d460398f3ba6767a37.js +1 -0
- package/assets/esri/core/workers/chunks/02e7359162cf974b41b6.js +1 -0
- package/assets/esri/core/workers/chunks/{17d5f8dba6ebb1184506.js → 042cd64e1f4eb326c30f.js} +1 -1
- package/assets/esri/core/workers/chunks/{66db5f77e09d25e33951.js → 063905fbf9a0c6586949.js} +1 -1
- package/assets/esri/core/workers/chunks/{9486032af3e934d85582.js → 0a5d74414dd02a2fb8e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{3815ffa13e7b439bca6e.js → 0d5212f59e9b62c16164.js} +1 -1
- package/assets/esri/core/workers/chunks/0f735b0dec173142f3b6.js +2 -0
- package/assets/esri/core/workers/chunks/{a8f998b8ec8c56150479.js.LICENSE.txt → 0f735b0dec173142f3b6.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{73487b9d85e726e9c012.js → 1257c37bf04d39c27b62.js} +1 -1
- package/assets/esri/core/workers/chunks/{398f356b11fd33bd3831.js → 136a7d781dad05a7463b.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e4e7aedf4b779241a02.js → 15c7c10ff9ac63f0e792.js} +1 -1
- package/assets/esri/core/workers/chunks/17784cf16fa91504b9ea.js +1 -0
- package/assets/esri/core/workers/chunks/{a395373e3173e6458a56.js → 1ab37e13947d0e2e4181.js} +1 -1
- package/assets/esri/core/workers/chunks/{f03635ddf56e2ef90e4c.js → 1d06fcae4c2f02fb1c95.js} +1 -1
- package/assets/esri/core/workers/chunks/1dfca37f95f2b968aa54.js +1 -0
- package/assets/esri/core/workers/chunks/{5bd36dbf46c25bd961c8.js → 21293b0c6405a10ec7b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{285762ff92d5388b6024.js → 2166238a7ad63a2d43c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{620a94b54be3ed78350d.js → 22ca80f491e070b2a5e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{88074189fa10c335370b.js → 24cd7b84cd0f3de4bff2.js} +1 -1
- package/assets/esri/core/workers/chunks/{ccc0da0e01f023c8aa1f.js → 28d1f2cf6aae547615c3.js} +1 -1
- package/assets/esri/core/workers/chunks/292daac70bb828e4923f.js +1 -0
- package/assets/esri/core/workers/chunks/{7e43c105f1cfc44b7bd0.js → 2fa01bd3f3608616fd7f.js} +1 -1
- package/assets/esri/core/workers/chunks/30e220f4f843681a4cdd.js +1 -0
- package/assets/esri/core/workers/chunks/{5d3661d1fe46dd29aae9.js → 311b564e44ae637c960d.js} +1 -1
- package/assets/esri/core/workers/chunks/{f4d0ae6be1b3984228d0.js → 31b6406960261da21dd4.js} +1 -1
- package/assets/esri/core/workers/chunks/31c7ce65e16f7858400f.js +1 -0
- package/assets/esri/core/workers/chunks/31dbe07047dc61303d7d.js +1 -0
- package/assets/esri/core/workers/chunks/{8a314b3790313e6dc5db.js → 333b62dad3811cff0f14.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8733cd621105afab2ac.js → 35c9b24e4430bd6c2b6b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e31192ae920e3e19b6aa.js → 37c1f155da14de91565a.js} +1 -1
- package/assets/esri/core/workers/chunks/{c55c096669677321a227.js → 38cd3648932bf2534b0f.js} +1 -1
- package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{f5e47eea8720ba84665b.js → 3c07aa2015ab1dff5f7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e9311386f58f3cb95c22.js → 42a1e71d09e8583a7327.js} +1 -1
- package/assets/esri/core/workers/chunks/443dfe7029ec208f670c.js +1 -0
- package/assets/esri/core/workers/chunks/{b75930d60449eceb0f1c.js → 4baf6f6e7ddedb25f806.js} +1 -1
- package/assets/esri/core/workers/chunks/{bb5484b5eeacc9ad2ceb.js → 4d0cbf9584446f411a37.js} +1 -1
- package/assets/esri/core/workers/chunks/{17103e6542aae53c7301.js → 4e3e27673d0671fc2b58.js} +1 -1
- package/assets/esri/core/workers/chunks/4fb5f1c671892001a4fd.js +1 -0
- package/assets/esri/core/workers/chunks/{5fc7b61f467f1d60a284.js → 51ab2acac4ecc1ca9c34.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc4417d1260b717a9385.js → 52282f767bd0e99ddca0.js} +1 -1
- package/assets/esri/core/workers/chunks/{dedc4583b5f32a278124.js → 5350d50b47b6a4e0e169.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 53654edd766d9b4ef750.js} +1 -1
- package/assets/esri/core/workers/chunks/{90f8b4bda28af43ea019.js → 538f509d7fc8337d37ac.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed8a85efbd90241512bb.js → 588533c3abe876f20f62.js} +1 -1
- package/assets/esri/core/workers/chunks/58e59ead33368ce38c8f.js +1 -0
- package/assets/esri/core/workers/chunks/5db37547963857295273.js +1 -0
- package/assets/esri/core/workers/chunks/{72846fb9c87c6642daf0.js → 5e2ce34def5e053913b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c056eac35d05d9524b7.js → 5f29422a051311ef9b3c.js} +1 -1
- package/assets/esri/core/workers/chunks/{ac26e3e77df4302f47a2.js → 604777417722d4effe06.js} +1 -1
- package/assets/esri/core/workers/chunks/{ff35a077ac6776469805.js → 61d970ed75c2c358b1e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a6a96edc892d7060b7d.js → 629127877042ad784ad2.js} +1 -1
- package/assets/esri/core/workers/chunks/{90b2b43b8b54c9a1ec35.js → 664ae441617afe4b17ec.js} +1 -1
- package/assets/esri/core/workers/chunks/67f03d042455cd0f7009.js +1 -0
- package/assets/esri/core/workers/chunks/{4c5a7249a311070d8f43.js → 6af18d7a0d314d7c1756.js} +1 -1
- package/assets/esri/core/workers/chunks/{f35aaa04cca676c2d3f8.js → 6b59f94040c7d2f6728a.js} +1 -1
- package/assets/esri/core/workers/chunks/6d9f2b113d6bde936a04.js +1 -0
- package/assets/esri/core/workers/chunks/{5132ca68e8c7af111a47.js → 6e22b02a9715c10578d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{f0e0a63962784acb4ba1.js → 6f0aec7428021e440ac9.js} +1 -1
- package/assets/esri/core/workers/chunks/{deb2854bb7d082a26f52.js → 7005d956c990a04ee8b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3991ae8caa713d4ddcd.js → 731f7b552dde0fb325cd.js} +1 -1
- package/assets/esri/core/workers/chunks/7565b382f6b3d2cb46a3.js +2 -0
- package/assets/esri/core/workers/chunks/{b96eb0ea506379182d62.js.LICENSE.txt → 7565b382f6b3d2cb46a3.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{464d42bebb365287808d.js → 773f2c6c9d38db76dfed.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f3d492f1093b7832aab.js → 7803495f8862d9025bcd.js} +1 -1
- package/assets/esri/core/workers/chunks/7d641f2f5edd95b9bc18.js +1 -0
- package/assets/esri/core/workers/chunks/7e4c14d4502e3f06d94b.js +1 -0
- package/assets/esri/core/workers/chunks/812f2ccc01f44e3cfd41.js +1 -0
- package/assets/esri/core/workers/chunks/826fa0dfb63df77bfd95.js +1 -0
- package/assets/esri/core/workers/chunks/{7544316a75dbd981aea6.js → 86cb097deec50b0da3f3.js} +1 -1
- package/assets/esri/core/workers/chunks/87921f3fa9001f5801ed.js +1 -0
- package/assets/esri/core/workers/chunks/{95c594a87b732f5c4979.js → 89b748e064ca90b4f76a.js} +1 -1
- package/assets/esri/core/workers/chunks/8a40ed2ee4b032822c30.js +1 -0
- package/assets/esri/core/workers/chunks/{09de8be660174a229efb.js → 8cbb28476151a37ae958.js} +1 -1
- package/assets/esri/core/workers/chunks/{fe77ae6cf232a7a3298e.js → 8d9d3797c6d62fdfff9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{62a49cfd9a2508950e9f.js → 8fedfd33c37172dba6bf.js} +1 -1
- package/assets/esri/core/workers/chunks/91aa1157da32f650983b.js +1 -0
- package/assets/esri/core/workers/chunks/{e7638b9ab6674bc8a18f.js → 91dfd29e2dba200eab09.js} +1 -1
- package/assets/esri/core/workers/chunks/{794748fd1edc29a621cd.js → 9698f36c143953a975d4.js} +1 -1
- package/assets/esri/core/workers/chunks/98584902c9db6faa3e4d.js +1 -0
- package/assets/esri/core/workers/chunks/9e5e05d6430712b0b1bc.js +1 -0
- package/assets/esri/core/workers/chunks/{e5a06ce0ef6a9a90e100.js → 9f21436016ff7a899e79.js} +1 -1
- package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js → 9ff8ee6ed6b98c03ae7e.js} +2 -2
- package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js.LICENSE.txt → 9ff8ee6ed6b98c03ae7e.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/a6ee40dfc471d6612f3c.js +1 -0
- package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{a4db5c9a90107e097df8.js → af47272aaaef0ea57e71.js} +1 -1
- package/assets/esri/core/workers/chunks/b05208d56a724a8f1661.js +1 -0
- package/assets/esri/core/workers/chunks/{79968c183135281d2a6f.js → b3613a38178cad2ebc82.js} +1 -1
- package/assets/esri/core/workers/chunks/{22d6b8102e75bdef204c.js → b7eb486354994dc70855.js} +1 -1
- package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +1 -0
- package/assets/esri/core/workers/chunks/c29486c4eeb3e72effff.js +1 -0
- package/assets/esri/core/workers/chunks/{2b94623cabc6ae0f86ce.js → c37f7756d48ff9af2656.js} +1 -1
- package/assets/esri/core/workers/chunks/{1c52999a6392370844a6.js → c4090a60d149a5962179.js} +1 -1
- package/assets/esri/core/workers/chunks/c715fd32f814a0f14f40.js +1 -0
- package/assets/esri/core/workers/chunks/{73c1d43070b4fe1e5c1e.js → c8e686efe344a33a0258.js} +1 -1
- package/assets/esri/core/workers/chunks/{6bb5158de43c4b59107f.js → c9b16fd41cd59d452522.js} +1 -1
- package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/cf971e7b1b98d9c502d3.js +1 -0
- package/assets/esri/core/workers/chunks/{279366e6b743f9680603.js → cfff044859e6e6dcc75d.js} +1 -1
- package/assets/esri/core/workers/chunks/d07f911d40bf05fc0306.js +1 -0
- package/assets/esri/core/workers/chunks/{8833c3d168951be4bf20.js → d0d79dd3e88eecf5c314.js} +1 -1
- package/assets/esri/core/workers/chunks/d1ca7c3a32ce00ed8b81.js +1 -0
- package/assets/esri/core/workers/chunks/{76ae1702fecc7ad7017c.js → d1e97cce5047f1791e22.js} +1 -1
- package/assets/esri/core/workers/chunks/{17acde0245ecd956306c.js → d233cc33497a663450f9.js} +1 -1
- package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js → d391bfbaf0e790cd10d6.js} +2 -2
- package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js.LICENSE.txt → d391bfbaf0e790cd10d6.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{36fe6b8228e622407ec2.js → d8793eead02491136841.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d599008e1ea42321b37.js → da24ad57747714ac5eda.js} +1 -1
- package/assets/esri/core/workers/chunks/db678a6e352275e507a9.js +1 -0
- package/assets/esri/core/workers/chunks/{facb3886714222772ab2.js → ddfd01bb9ba8577c3ffc.js} +1 -1
- package/assets/esri/core/workers/chunks/de2ebd9cc3d9e68d435b.js +1 -0
- package/assets/esri/core/workers/chunks/{50d9f69d5255af4b29bb.js → df5afa06c6deb6b40109.js} +1 -1
- package/assets/esri/core/workers/chunks/e25c4b4a03270d48f408.js +1 -0
- package/assets/esri/core/workers/chunks/e3294318daf1192b8319.js +1 -0
- package/assets/esri/core/workers/chunks/e599125e746c27de106e.js +1 -0
- package/assets/esri/core/workers/chunks/{da573ecc68e6aa8f6da9.js → e767f83f9e2de6650f80.js} +1 -1
- package/assets/esri/core/workers/chunks/e9d4cae2144974489d6e.js +1 -0
- package/assets/esri/core/workers/chunks/{91df8638b8b904e6d8c5.js → ead8d0cbcebd12dbfad7.js} +1 -1
- package/assets/esri/core/workers/chunks/{f9324e88c359c03f35aa.js → eb9c166db0db6fa60e95.js} +1 -1
- package/assets/esri/core/workers/chunks/ebcc94234d9d4be1941f.js +316 -0
- package/assets/esri/core/workers/chunks/ee5f0fd5384caa11c986.js +1 -0
- package/assets/esri/core/workers/chunks/{bc241c7735e4efba734a.js → f34e3fa0c5b28531e289.js} +1 -1
- package/assets/esri/core/workers/chunks/f64037a88ab03662dc2a.js +1 -0
- package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{d97fadbc69e055d183a0.js → f77f4bd6a577b92cf66f.js} +1 -1
- package/assets/esri/core/workers/chunks/f80f5dbf96c343ac4df6.js +1 -0
- package/assets/esri/core/workers/chunks/{16d66770ef841564ee3f.js → f89c90f98c85667b0ebc.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c4227b0ea21a5e429ab.js → fb192de7e4fa152342bb.js} +1 -1
- package/assets/esri/core/workers/chunks/fbd8d2f61f8a15bcf3db.js +1 -0
- package/assets/esri/core/workers/chunks/fccd931f95d81ecc57b2.js +1 -0
- package/assets/esri/core/workers/chunks/{2f78861afe0e9037dd8d.js → fe49321dca22dc60d105.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_NavigationToggle.scss +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -4
- package/assets/esri/themes/base/widgets/_Widget.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/config.js +1 -1
- package/core/QueueProcessor.js +1 -1
- package/core/SetUtils.js +1 -1
- package/core/has.js +1 -1
- package/form/FormTemplate.js +1 -1
- package/form/elements/Element.js +1 -1
- package/form/elements/FieldElement.js +1 -1
- package/form/elements/GroupElement.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/identity/Credential.js +1 -1
- package/identity/IdentityManager.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/interfaces.d.ts +92 -50
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/fieldConfigUtils.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/layers/support/rasterFunctions/pixelTransformUtils.js +5 -0
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/layers/support/source/DataLayerSource.js +1 -1
- package/package.json +4 -4
- package/popup/FieldInfo.js +1 -1
- package/processRequest.js +5 -0
- package/request.js +1 -1
- package/requestConfig.js +5 -0
- package/requestQueue.js +5 -0
- package/rest/query/executeForCount.js +1 -1
- package/rest/query/executeForExtent.js +1 -1
- package/rest/query/executeForIds.js +1 -1
- package/rest/query/executeQueryJSON.js +1 -1
- package/rest/query/executeQueryPBF.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/support/BaseImageMeasureResultValue.js +5 -0
- package/rest/support/ImageAreaResult.js +1 -1
- package/rest/support/ImageDistanceResult.js +1 -1
- package/rest/support/ImageHeightResult.js +1 -1
- package/rest/support/ImageMeasureResultAngleValue.js +5 -0
- package/rest/support/ImageMeasureResultAreaValue.js +5 -0
- package/rest/support/ImageMeasureResultLengthValue.js +5 -0
- package/rest/support/ImageWithType.js +5 -0
- package/rest/support/imageMeasureUtils.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/{3d/support/ImageWithType.js → 2d/layers/features/sources/strategies/constants.js} +1 -1
- package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +1 -1
- package/views/3d/glTF/DefaultLoadingContext.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
- package/views/3d/layers/ElevationLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/graphics/FeatureGraphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
- package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/I3SDataRequester.js +5 -0
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/MediaLayerInteractionOptions.js +1 -1
- package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.js +5 -0
- package/views/3d/layers/support/SampledGeometryMaxDistanceRatio.js +5 -0
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/layers/support/fetchTile.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/StreamTextureCollection.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +6 -0
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/draw/MultipointDrawAction.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/input/CursorUpdateEvents.js +5 -0
- package/views/draw/input/DrawCompleteEvent.js +5 -0
- package/views/draw/input/VertexAddEvent.js +5 -0
- package/views/draw/input/VertexRemoveEvent.js +5 -0
- package/views/draw/input/VertexUpdateEvent.js +5 -0
- package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +5 -0
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +5 -0
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
- package/views/support/PromiseQueue.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Editor/AddAssociationWorkflow.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor/support/errors.js +5 -0
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicZoomManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
- package/widgets/PanoramicViewer/support/getVisibleTiles.js +5 -0
- package/widgets/Sketch/CreateToolVisibilityMap.js +5 -0
- package/widgets/Sketch/SelectionToolVisibilityMap.js +5 -0
- package/widgets/Sketch/VisibleElements.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/020c8913d8e35d63080b.js +0 -1
- package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +0 -1
- package/assets/esri/core/workers/chunks/05eee334d58a0b9f6316.js +0 -1
- package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +0 -1
- package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +0 -1
- package/assets/esri/core/workers/chunks/326a76a4e80269d4029d.js +0 -1
- package/assets/esri/core/workers/chunks/377a66034e7c1bad5599.js +0 -1
- package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +0 -1
- package/assets/esri/core/workers/chunks/459a67928bde4a62b6a4.js +0 -1
- package/assets/esri/core/workers/chunks/4eebd74ebc20579dade8.js +0 -1
- package/assets/esri/core/workers/chunks/53bd8996e8812f1ad7b2.js +0 -1
- package/assets/esri/core/workers/chunks/557960763695abee4a83.js +0 -1
- package/assets/esri/core/workers/chunks/6201356f7f91e5c06425.js +0 -1
- package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +0 -1
- package/assets/esri/core/workers/chunks/6f4bd0ee85e7e5a74340.js +0 -1
- package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +0 -1
- package/assets/esri/core/workers/chunks/7461124454bfb4fb6474.js +0 -1
- package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +0 -1
- package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +0 -1
- package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +0 -1
- package/assets/esri/core/workers/chunks/811d4c46c75cf6a63e78.js +0 -1
- package/assets/esri/core/workers/chunks/8ffd4710d168c2fcfd96.js +0 -1
- package/assets/esri/core/workers/chunks/90250e9239c173aace88.js +0 -1
- package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +0 -1
- package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +0 -1
- package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +0 -1
- package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +0 -1
- package/assets/esri/core/workers/chunks/9fac5a12e878cd745354.js +0 -1
- package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +0 -316
- package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +0 -1
- package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js +0 -2
- package/assets/esri/core/workers/chunks/aa54b6f2aba6952af149.js +0 -1
- package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +0 -2
- package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +0 -1
- package/assets/esri/core/workers/chunks/c4e4da69969499a89a2c.js +0 -1
- package/assets/esri/core/workers/chunks/cd1930f08e1fc8b30b14.js +0 -1
- package/assets/esri/core/workers/chunks/d1fe816b6990918c13c7.js +0 -1
- package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +0 -1
- package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +0 -1
- package/assets/esri/core/workers/chunks/e0bbfbe1ed39c82f1bd4.js +0 -1
- package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +0 -1
- package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +0 -1
- package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +0 -1
- package/assets/esri/core/workers/chunks/fd2efd1d1cf9d95a87e6.js +0 -1
- package/views/3d/layers/i3s/I3SStreamDataController.js +0 -5
- package/views/3d/support/StreamDataLoader.js +0 -5
- package/views/3d/support/StreamDataRequester.js +0 -5
- package/views/3d/support/downloadSlots.js +0 -5
- package/views/draw/input/DrawEvents.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../request.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import n from"../../../../core/Logger.js";import{estimateNestedObjectMemory as s}from"../../../../core/memoryEstimations.js";import{NestedMap as o}from"../../../../core/NestedMap.js";import{throwIfAbortError as a}from"../../../../core/promiseUtils.js";import{Version as i}from"../../../../core/Version.js";import{fromArray as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as u,expandWithVec3 as c}from"../../../../geometry/support/aaBoundingBox.js";import{getContinuousIndexArray as m}from"../../../../geometry/support/Indices.js";import{requestImage as p}from"../../../../support/requestImageUtils.js";import{Attribute as f}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as y}from"../../webgl-engine/materials/DefaultMaterial.js";const w=()=>n.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");class x{constructor(e,t,r){this.resource=e,this.textures=t,this.usedMemory=r}}async function h(e,t){const r=await b(e,t),n=await
|
|
5
|
+
import e from"../../../../request.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import n from"../../../../core/Logger.js";import{estimateNestedObjectMemory as s}from"../../../../core/memoryEstimations.js";import{NestedMap as o}from"../../../../core/NestedMap.js";import{throwIfAbortError as a}from"../../../../core/promiseUtils.js";import{Version as i}from"../../../../core/Version.js";import{fromArray as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as u,expandWithVec3 as c}from"../../../../geometry/support/aaBoundingBox.js";import{getContinuousIndexArray as m}from"../../../../geometry/support/Indices.js";import{requestImage as p}from"../../../../support/requestImageUtils.js";import{Attribute as f}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as y}from"../../webgl-engine/materials/DefaultMaterial.js";const w=()=>n.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");class x{constructor(e,t,r){this.resource=e,this.textures=t,this.usedMemory=r}}async function h(e,t){const r=await b(e,t),n=await P(r.textureDefinitions??{},t);let o=0;for(const s in n)if(n.hasOwnProperty(s)){const e=n[s];o+=e?.image?e.image.width*e.image.height*4:0}return new x(r,n,o+s(r))}async function b(r,n){const s=await t(e(r,n));if(s.ok)return s.value.data;a(s.error),v(s.error)}function v(e){throw new r("",`Request for object resource failed: ${e}`)}function A(e){const t=e.params,r=t.topology;let n=!0;switch(t.vertexAttributes||(w().warn("Geometry must specify vertex attributes"),n=!1),t.topology){case"PerAttributeArray":break;case"Indexed":case null:case void 0:{const e=t.faces;if(e){if(t.vertexAttributes)for(const r in t.vertexAttributes){const t=e[r];t?.values?(null!=t.valueType&&"UInt32"!==t.valueType&&(w().warn(`Unsupported indexed geometry indices type '${t.valueType}', only UInt32 is currently supported`),n=!1),null!=t.valuesPerElement&&1!==t.valuesPerElement&&(w().warn(`Unsupported indexed geometry values per element '${t.valuesPerElement}', only 1 is currently supported`),n=!1)):(w().warn(`Indexed geometry does not specify face indices for '${r}' attribute`),n=!1)}}else w().warn("Indexed geometries must specify faces"),n=!1;break}default:w().warn(`Unsupported topology '${r}'`),n=!1}e.params.material||(w().warn("Geometry requires material"),n=!1);const s=e.params.vertexAttributes;for(const o in s){s[o].values||(w().warn("Geometries with externally defined attributes are not yet supported"),n=!1)}return n}function j(e,t){const r=new Array,n=new Array,s=new Array,a=new o,u=e.resource,c=i.parse(u.version||"1.0","wosr");E.validate(c);const p=u.model.name,w=u.model.geometries,x=u.materialDefinitions??{},h=e.textures;let b=0;const v=new Map;for(let o=0;o<w.length;o++){const e=w[o];if(!A(e))continue;const i=I(e),u=e.params.vertexAttributes,c=[],p=t=>{if("PerAttributeArray"===e.params.topology)return null;const r=e.params.faces;for(const e in r)if(e===t)return r[e].values;return null},j=u.position,M=j.values.length/j.valuesPerElement;for(const t in u){const e=u[t],r=e.values,n=p(t)??m(M);c.push([t,new f(r,n,e.valuesPerElement,!0)])}const P=i.texture,E=h&&h[P];if(E&&!v.has(P)){const{image:e,parameters:t}=E,r=new g(e,t);n.push(r),v.set(P,r)}const T=v.get(P),k=T?T.id:void 0,O=i.material;let C=a.get(O,P);if(null==C){const e=x[O.slice(O.lastIndexOf("/")+1)].params;1===e.transparency&&(e.transparency=0);const r=E?U(E.alphaChannelUsage):void 0,n={ambient:l(e.diffuse),diffuse:l(e.diffuse),opacity:1-(e.transparency||0),textureAlphaMode:r,textureAlphaCutoff:.33,textureId:k,doubleSided:!0,cullFace:0,colorMixMode:e.externalColorMixMode||"tint",textureAlphaPremultiplied:E?.parameters.preMultiplyAlpha??!1};t?.materialParameters&&Object.assign(n,t.materialParameters),C=new y(n,t),a.set(O,P,C)}s.push(C);const $=new d(C,c);b+=c.find(e=>"position"===e[0])?.[1]?.indices.length??0,r.push($)}return{engineResources:[{name:p,stageResources:{textures:n,materials:s,geometries:r},pivotOffset:u.model.pivotOffset,numberOfVertices:b,lodThreshold:null}],referenceBoundingBox:M(r)}}function M(e){const t=u();return e.forEach(e=>{const r=e.boundingInfo;null!=r&&(c(t,r.bbMin),c(t,r.bbMax))}),t}async function P(e,t){const r=new Array;for(const o in e){const n=e[o],s=n.images[0].data;if(!s){w().warn("Externally referenced texture data is not yet supported");continue}const a=n.encoding+";base64,"+s,i="/textureDefinitions/"+o,l="rgba"===n.channels?n.alphaChannelUsage||"transparency":"none",u={noUnpackFlip:!0,wrap:{s:10497,t:10497},preMultiplyAlpha:1!==U(l)},c=t?.disableTextures?Promise.resolve(null):p(a,t);r.push(c.then(e=>({refId:i,image:e,parameters:u,alphaChannelUsage:l})))}const n=await Promise.all(r),s={};for(const o of n)s[o.refId]=o;return s}function U(e){switch(e){case"mask":return 2;case"maskAndTransparency":return 3;case"none":return 1;default:return 0}}function I(e){const t=e.params;return{id:1,material:t.material,texture:t.texture,region:t.texture}}const E=new i(1,2,"wosr");export{x as LoaderResultWOSR,P as createTextureResources,h as load,j as processLoadResult};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../../request.js";import{isRequestQueueFull as t,queueAutoPriority as r}from"../../../../requestQueue.js";import{removeMaybe as o,abortMaybe as s}from"../../../../core/maybe.js";import{onAbortOrThrow as a}from"../../../../core/promiseUtils.js";class l{constructor(e,t){this._customParameters=e,this._apiKey=t,this._activeRequests=new Set}isFull(e){return t(e)}request(t,s,l){const i=new AbortController,n=a(l,()=>i.abort()),u={...r,signal:i.signal,responseType:s,query:{...this._customParameters,token:this._apiKey}},c=e(t,u),m={abortController:i,abortHandle:n};return this._activeRequests.add(m),c.then(({data:e})=>e).finally(()=>{m.abortController=null,m.abortHandle=o(m.abortHandle),this._activeRequests.delete(m)})}cancelAll(){this._activeRequests.forEach(e=>{e.abortController=s(e.abortController),e.abortHandle=o(e.abortHandle)}),this._activeRequests.clear()}}export{l as I3SDataRequester};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as i}from"../../../../geometry/projection/projectBoundingSphere.js";import{j as n,m as s,c as o,z as r}from"../../../../chunks/sphere.js";import{NodeBase as a,Node as l,NodeTraversalState as d}from"./I3SNode.js";import{invalidateMbs as h,addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as c}from"./ValidatedNode.js";import{ElevationRange as g}from"../../support/ElevationRange.js";import{Obb as _}from"../../support/orientedBoundingBox.js";class f{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this._ref=n,this.node=s,this.useAsHole=0,this.filterImpact=2,this.traversalState=null,this.parent=-1}get ref(){return this._ref}destroy(){this._ref=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.ref?.invalidateServiceBVsInRenderSR()}}class m{constructor(e=new Array,t=new Array){this._nodeInternals=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(const e of this._nodeInternals)e.destroy();this._nodeInternals.length=0,this._children.length=0}get nodes(){return this._nodeInternals}addNode(e){return this._nodeInternals.push(e),this._nodeInternals.length-1}setNodes(e,t){this._nodeInternals=e,this._children=t}get children(){return this._children}}class v{get _useNodePages(){return this._pageSize>0}constructor(t,i,n,s,o,r,l,d,h,u,c,g,_,f,v,N){if(this.viewingMode=t,this._layer=i,this._streamDataController=s,this._clientNodeLoader=o,this._viewportQueries=r,this._logger=l,this.holeFilling=d,this._isLoaded=h,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=v,this._computeNodeFiltering=N,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=I(0),this._visibilityCacheVersion=I(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new p(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._traverseDescendantsQueue=[0],this._traverseDescendantsNestingLevel=0,this._isEditable=null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,"page"===n.type){const e=n.rootPage;switch(this.urlPrefix=n.urlPrefix,this._pageSize=n.pageSize,n.lodMetric){case"maxScreenThreshold":this._lodMetric=1;break;case"maxScreenThresholdSQ":this._lodMetric=1,this._lodConversion=O}if(this._isEditable){this._rootIndex=-1;const t=S(n.rootIndex,n.pageSize),i=e.nodes[t],s={nodes:[{index:this._rootIndex,children:[n.rootIndex],mesh:void 0,obb:i.obb,lodThreshold:i.lodThreshold}]};this._addPage(R(this._rootIndex,this._pageSize),s),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=n.rootIndex;this._addPage(R(n.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if("node"===n.type){this.urlPrefix=n.urlPrefix;const e=new m;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new m;const e={id:"-1",version:null,mbs:n.rootNode.mbs,obb:n.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:n.rootNode.mbs,obb:n.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new a(e.id,null),-1);const t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new a(n.rootNode.id,null),-1);const t=this._validateNode(n.rootNode.id,n.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,n=new a(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this.urlPrefix+e;this._streamDataController.request(i,0).then(t=>this._pageQueue.push({pageIndex:e,page:t})).catch(i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach(e=>{let t=e.parent;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e&&!Number.isNaN(e?.elevationRangeMin)&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this.getParentIndex(t)}})}}_addPage(e,t){const i=[],s=[],o=t.nodes.map((t,o)=>{const r=i.length,a=t.children?t.children.length:0;s.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const d=`${t.index}`,h=_.fromJSON(t.obb),u=n(h.center,h.radius),c=t.mesh?.attribute,g=t.mesh?.geometry,m=t.mesh?.material,v={hasSharedResource:!1,isEmpty:null==g,attributes:null!=c?.resource?`${c.resource}`:void 0,geometry:null!=g?.resource?`${g.resource}`:void 0,texture:null!=m?.resource?`${m.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:m?m.definition:-1},N=new l(d,C(o,e,this._pageSize),u,a,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?.featureCount??null);return N.serviceObbInIndexSR=h,N.visibilityObbInRenderSR=this._computeVisibilityObb(N),N.vertexCount=g?g.vertexCount:0,new f(r,a,b(this._visibilityCacheVersion),null,N)}),r=new m(o,i);-1===e?this._clientNodePage=r:this._nodePages.set(e,r)}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=S(t,this._pageSize),r=s.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=R(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[S(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=E(e.lodSelection),r=this._getNodeInternal(t),a=new l(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures);r.node=a,e.obb&&(a.serviceObbInIndexSR=_.fromJSON(e.obb)),a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const d=r.ref;return null!=d&&(null==d.serviceMbsInIndexSR&&(d.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(d),d.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length,s=new f(0,0,b(this._visibilityCacheVersion),e,null);return i.addNode(s),s.parent=t,e.invalidateServiceBVsInRenderSR(),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1),s=new f(0,0,b(this._visibilityCacheVersion),e,null);return i.addNode(s),s.parent=t,e.invalidateServiceBVsInRenderSR(),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=S(e,this._pageSize),s=S(t,this._pageSize),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[s].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,a=e=>{const i=S(e,this._pageSize),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)a(n.children[t]);const r=s.node?.id??s.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(s)};a(e);const l=n.nodes,d=n.children,h=n.nodes.map(()=>-1),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,n=C(g,-1,this._pageSize),s=C(t,-1,this._pageSize);if(e.node&&(e.node.index=s),h[g]=s,u.push(e),n!==s){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,n,s),r.set(n,s)}}for(let g=0;g<u.length;++g){const e=C(g,-1,this._pageSize),t=u[g],i=c.length;for(let n=t.childOffset;n<t.childOffset+t.childCount;++n){const t=d[n];if(t>=0)c.push(t);else{const i=S(t,this._pageSize),n=l[i];if(o.has(n))continue;const s=h[i];c.push(s),n.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}n.setNodes(u,c),this._updateParentBoundingInformation(h[S(s,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let o=0;o<l.childCount;o++){const l=this.getChildIndex(t,o),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.serviceMbsInIndexSR[3]>0)if(null==e)e=s(h.serviceMbsInIndexSR,A);else{const t=L,s=F,o=z;i(h.serviceMbsInIndexSR,n,t,a),i(e,n,s,a),r(t,s,o),i(o,a,e,n)}}const d=t=>{null!=t&&(t.serviceObbInIndexSR=null,null!=e?(t.serviceMbsInIndexSR??=o(),s(e,t.serviceMbsInIndexSR)):h(t.serviceMbsInIndexSR),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};d(l.ref),d(l.node),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)}),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[S(e,this._pageSize)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[S(e,this._pageSize)]?.parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=I(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=b(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeUpToDate(e){if(!this.needNodeElevationRange)return!0;const t=e?.node??e?.ref;return!t||t.elevationRangeValid}updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const n=i?.node??i?.ref;if(!n)return!1;if(n.elevationRangeValid)return t?.expandElevationRange(n),!0;const s=new g;let o=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l),i=this._updateElevationRangeInternal(t,s);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(n,e,s)}s.elevationRangeMin!==1/0&&s.elevationRangeMax!==-1/0||s.expandElevationRangeValues(0,0);const r=n.elevationRangeMin,a=n.elevationRangeMax;return r===s.elevationRangeMin&&a===s.elevationRangeMax?(t?.expandElevationRange(n),!0):(i.node?.setElevationRange(s),i.ref?.setElevationRange(s),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(n),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t)return!0;const i=t.ref;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(this._isElevationRangeUpToDate(t)&&P(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);const n=t.node,s=this._viewportQueries;if(n){const e=s.ensureElevationAgnosticBoundingVolume(n),i=s.isElevationAgnosticBoundingVolumeVisible(e);let o=i;if(this.needNodeElevationRange&&i){const t=s.getNodeObbInRenderSRIndependentOfElevationOffset(n);null!=t&&(o=s.isObbVisibleIndependentOfElevation(e,t))}if(!o)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=n||null!=i)&&2===t.filterImpact){const e=null!=n?n.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):0}const o=null!=n&&1===t.filterImpact;let r=!(null!=n&&2===n.imModificationImpact)&&!o;if(r){const t=!n||i&&!n.visibilityObbInRenderSR?i??null:n;if(null!=t){this.needNodeElevationRange&&this.updateElevationRange(e);r=s.isNodeVisible(t)}}return t.visibilityCache=y(r,this._visibilityCacheVersion),r}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&4===t.node.imModificationImpact)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}n/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,l,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(P(t.useAsHole,this._version))return x(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=y(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.prune(),this._prefetchNodes.prune(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=I(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{null!=e&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(null!=e){e.filterImpact=2;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),N.clear();let n=!0;const s=new M,o=new V,r=this._imModificationUncategorized;r.clear();const a=new Set;let l=0;const d=(a,d,h)=>{const u=R(a,this._pageSize);if(null==d){let e=this._entryPriority(a);return e===1/0&&(e=this._entryPriority(h)),N.set(u,Math.max(e,N.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||(this._missingPagesAndNodes.push(u),++l),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=d.node;if(this._updateNodeFeatureEstimate(c,o),null==c){const e=this._entryPriority(a);return this._loadingNodes.has(a)||this._failedNodes.has(a)||(this._missingPagesAndNodes.push(a),N.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=this._getPage(a);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<d.childCount;e++){const t=g.children[d.childOffset+e],i=this._getNodeInternal(t);null!=i&&!i.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(N.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(c.failed||c.resources.isEmpty)return void(n&&d.childCount>0&&this._isSelected(c)&&(n=!1));if(this._isLoaded(a)){if(s.known+=c.memory,++s.knownNodes,this._isSelected(c)?d.childCount>0&&(n=!1):(s.unremoved+=c.memory,n=!1),this._needsUpdate(c)){const e=this._entryPriority(a);N.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(c.memory&&(s.known+=c.memory,++s.knownNodes),!this._isSelected(c))return void(this._isReloading(a)&&this._updates.remove.push(a));if(d.childCount>0&&(n=!1),c.memory?(s.missing+=c.memory,s.known+=c.memory,++s.knownNodes):++s.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(a)),void(this._updates.cancel=this._updates.cancel.filter(e=>e!==c.index));if(!t.done&&this._enable(c))return void t.madeProgress();const _=this._entryPriority(a);N.set(a,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(a),this.layerHasModifications&&i&&null!=c&&4===c.imModificationImpact&&r.push(a)};this.traverseVisible(d,a),this._frameNumber++,this._missingPagesAndNodes.sort((e,t)=>e-t),this._missingPagesAndNodes.filterInPlace((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e),this._missingPagesAndNodes.sort((e,t)=>N.get(e)-N.get(t)),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=N.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,l);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace(e=>{const t=this._getNodeInternal(e),i=null==t?.node||2!==t.node.imModificationImpact;return i||this.invalidateNodeVisibilityCache(e),i})),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._updates.add.filterInPlace(e=>N.get(e)>=this._maxUnloadedPrio).sort((e,t)=>N.get(e)-N.get(t)),this._updates.update.sort((e,t)=>N.get(e)-N.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,N.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new V;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,n=this._nodePages,s=n.size+this._loadingPages.size+t;if(s>D&&s>i){const t=new Array;for(const[i,s]of n)0!==s.numNodesWithLoadedChildren||e.has(i)||t.push([s.lastTraversed,i]);t.sort((e,t)=>e[0]-t[0]).some(e=>{const t=e[1];return this._deleteNodePage(t),n.size<=D})}}_updateFeatureEstimate(e,t){this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,i)=>this._updateNodeFeatureEstimate(i?.node,t))}_updateNodeFeatureEstimate(e,t){null!=e&&!e.failed&&this._isSelected(e)&&(null!=e.numFeatures?(t.numFeatures+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort((e,t)=>N.get(e)-N.get(t)),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let n=i?.traversalState;if(n&&P(n.version,this._version))return n;const s=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&s>i.lodLevel}else r=s>0}else r=0===e.childCount;return n?(n.lodLevel=s,n.isChosen=r,n.version=y(!0,this._version),n):(n=new d(o,r,s,y(!0,this._version)),i.traversalState=n,n)}_loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this.urlPrefix+n,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};(e>=0?this._streamDataController.request(s,0):this._clientNodeLoader.loadNodeJSON(n)).catch(i=>{o(),t(i)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e))}).then(t=>{o();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)})}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`)||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,l=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=new a(`${t.id}`,t.mbs);return n.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?_.fromJSON(t.obb):null,n.visibilityObbInRenderSR=this._computeVisibilityObb(n),n},d=Array.isArray(t.children)?t.children.map(l).filter(e=>null!=e):null,h=t.featureData?.length??!1,u=!0===t.isEmpty;return new c(e,t.mbs,o,"string"==typeof t.version?t.version:null,{isEmpty:!h&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},d,Array.isArray(t.lodSelection)?t.lodSelection:null,r)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{null!=e.node&&(e.node.failed=!1)})}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e,t){const i=this._getNodeInternal(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n,s){const o=R(e,this._pageSize);if(s&&s.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const a=this._getPageFromPageIndex(o);for(let l=0;l<i.childCount;l++){const t=a.children[i.childOffset+l],o=this._getNodeInternal(t);if(o)this._traverseVisible(t,e,o,n,s);else{if(s){const e=R(t,this._pageSize);s.add(e)}n(t,null,e)}}}traverse(e,t){t(e)&&this.traverseDescendants(e,t)}traverseDescendants(e,t){++this._traverseDescendantsNestingLevel;const i=e.index,n=this._pageSize,s=R(i,n),o=this._getPageFromPageIndex(s);if(null==o)return;const r=this._frameNumber,a=this._nodePages,l=S(i,n),d=o.nodes[l],h=d.childCount;if(o.lastTraversed=r,0===h)return;const u=new Array,c=1===this._traverseDescendantsNestingLevel?this._traverseDescendantsQueue:[0];let g=0;{const{childOffset:e,childCount:t}=d,{children:i}=o;c.length=2**Math.ceil(Math.log2(g+t));for(let n=e;n<e+t;++n){const e=i[n];e>=0?(c[g]=e,++g):u.push(e)}}if(u.length>0){const e=this._clientNodePage;if(e){const i=e.children;let n=0;for(;n<u.length;){const s=u[n];++n;const o=-s-1,r=e.nodes[o],a=r.node;if(!a||!t(a))continue;const{childCount:l}=r;if(0===l)continue;const{childOffset:d}=r,h=d+l;for(let e=d;e<h;++e)u.push(i[e])}}}if(g>0){let e=0;if(n>0){let i=s*n,l=o,d=l.nodes;for(;e<g;){const s=c[e];let o;if(++e,i<=s&&s<i+n)o=l;else{const e=s/n|0,t=a.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,l=o,d=l.nodes,i=n*e}const h=d[s-i],u=h.node;if(null==u||!1===t(u))continue;const{childCount:_}=h;if(0===_)continue;const f=g+_;for(c.length<f&&(c.length=2**Math.ceil(Math.log2(g+_)));c.length<g+_;)c.length+=c.length;const m=o.children,{childOffset:v}=h,N=v+_;for(let e=v;e<N;++e)c[g]=m[e],++g}}else{const i=a.get(0);if(i)for(;e<g;){const n=c[e++],s=i.nodes[n],o=s.node;if(!o||!t(o))continue;const{childCount:r}=s;if(0===r)continue;c.length=Math.max(c.length,2**Math.ceil(Math.log2(g+r)));const a=i.children,{childOffset:l}=s,d=l+r;for(let e=l;e<d;++e)c[g]=a[e],++g}}}--this._traverseDescendantsNestingLevel}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,n=e+t;i.childrenLoaded=n;const s=0===e?1:0===n?-1:0,o=i.index;if(0!==s){this._getPage(o).numNodesWithLoadedChildren+=s}i=this.getParent(o)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"relative-to-scene"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.ref?.invalidateElevationRange()})}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const n=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(R(e,this._pageSize)));for(const[i,n]of e)if(0!==n.numNodesWithLoadedChildren||t.has(i))for(const e of n.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){const t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const N=new Map;class p{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function b(e){return u(e,-2)}function I(e){return u(e,2)}function y(e,t){return t+(e?1:0)}function P(e,t){return(-2&e)===t}function x(e){return!(1&~e)}function R(e,t){return e<0?-1:t>0?e/t|0:0}function S(e,t){return e<0?-e-1:0===t?e:e%t}function C(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const w=[["maxScreenThreshold",1],["screenSpaceRelative",2],["removedFeatureDiameter",3],["distanceRangeFromDefaultCamera",4]];function E(e){if(e)for(let t=0;t<e.length;t++)for(const i of w)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:0,maxError:0}}class M{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class V{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function O(e){return Math.sqrt(e*(4/Math.PI))}const A=o(),L=o(),F=o(),z=o(),D=has("esri-mobile")?100:300;export{v as I3SIndex,E as selectErrorMetric};
|
|
5
|
+
import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as i}from"../../../../geometry/projection/projectBoundingSphere.js";import{j as s,m as n,c as o,z as r}from"../../../../chunks/sphere.js";import{NodeBase as a,Node as d,NodeTraversalState as l}from"./I3SNode.js";import{invalidateMbs as h,addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as c}from"./ValidatedNode.js";import{ElevationRange as g}from"../../support/ElevationRange.js";import{Obb as _}from"../../support/orientedBoundingBox.js";class f{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this._ref=s,this.node=n,this.useAsHole=0,this.filterImpact=2,this.traversalState=null,this.parent=-1}get ref(){return this._ref}destroy(){this._ref=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.ref?.invalidateServiceBVsInRenderSR()}}class m{constructor(e=new Array,t=new Array){this._nodeInternals=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(const e of this._nodeInternals)e.destroy();this._nodeInternals.length=0,this._children.length=0}get nodes(){return this._nodeInternals}addNode(e){return this._nodeInternals.push(e),this._nodeInternals.length-1}setNodes(e,t){this._nodeInternals=e,this._children=t}get children(){return this._children}}class v{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,d,l,h,u,c,g,_,f,v){if(this.viewingMode=t,this._layer=i,this._requester=n,this._clientNodeLoader=o,this._viewportQueries=r,this._logger=d,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._computeVisibilityObb=f,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=I(0),this._visibilityCacheVersion=I(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new p(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._traverseDescendantsQueue=[0],this._traverseDescendantsNestingLevel=0,this._isEditable=null!=i.associatedLayer?.infoFor3D,i.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${i.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,"page"===s.type){const e=s.rootPage;switch(this.urlPrefix=s.urlPrefix,this._pageSize=s.pageSize,s.lodMetric){case"maxScreenThreshold":this._lodMetric=1;break;case"maxScreenThresholdSQ":this._lodMetric=1,this._lodConversion=O}if(this._isEditable){this._rootIndex=-1;const t=S(s.rootIndex,s.pageSize),i=e.nodes[t],n={nodes:[{index:this._rootIndex,children:[s.rootIndex],mesh:void 0,obb:i.obb,lodThreshold:i.lodThreshold}]};this._addPage(R(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=s.rootIndex;this._addPage(R(s.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if("node"===s.type){this.urlPrefix=s.urlPrefix;const e=new m;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new m;const e={id:"-1",version:null,mbs:s.rootNode.mbs,obb:s.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:s.rootNode.mbs,obb:s.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new a(e.id,null),-1);const t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new a(s.rootNode.id,null),-1);const t=this._validateNode(s.rootNode.id,s.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,s=new a(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){this._loadingPages.add(e);const i=this.urlPrefix+e;this._requester.request(i,"json").then(t=>this._pageQueue.push({pageIndex:e,page:t})).catch(i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());e?.nodes.forEach(e=>{let t=e.parent;for(;null!=t&&t!==this._rootIndex;){const e=this.getNode(t);e&&!Number.isNaN(e?.elevationRangeMin)&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}}_addPage(e,t){const i=[],n=[],o=t.nodes.map((t,o)=>{const r=i.length,a=t.children?t.children.length:0;n.push(this._rootIndex);for(let e=0;e<a;e++)i.push(t.children[e]);const l=`${t.index}`,h=_.fromJSON(t.obb),u=s(h.center,h.radius),c=t.mesh?.attribute,g=t.mesh?.geometry,m=t.mesh?.material,v={hasSharedResource:!1,isEmpty:null==g,attributes:null!=c?.resource?`${c.resource}`:void 0,geometry:null!=g?.resource?`${g.resource}`:void 0,texture:null!=m?.resource?`${m.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:m?m.definition:-1},N=new d(l,C(o,e,this._pageSize),u,a,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?.featureCount??null);return N.serviceObbInIndexSR=h,N.visibilityObbInRenderSR=this._computeVisibilityObb(N),N.vertexCount=g?g.vertexCount:0,new f(r,a,b(this._visibilityCacheVersion),null,N)}),r=new m(o,i);-1===e?this._clientNodePage=r:this._nodePages.set(e,r)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=S(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=R(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[S(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=E(e.lodSelection),r=this._getNodeInternal(t),a=new d(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures);r.node=a,e.obb&&(a.serviceObbInIndexSR=_.fromJSON(e.obb)),a.visibilityObbInRenderSR=this._computeVisibilityObb(a);const l=r.ref;return null!=l&&(null==l.serviceMbsInIndexSR&&(l.serviceMbsInIndexSR=e.mbs),a.shareServiceBVsInRenderSRWith(l),l.visibilityObbInRenderSR=a.visibilityObbInRenderSR),a}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new f(0,0,b(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parent=t,e.invalidateServiceBVsInRenderSR(),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new f(0,0,b(this._visibilityCacheVersion),e,null);return i.addNode(n),n.parent=t,e.invalidateServiceBVsInRenderSR(),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=S(e,this._pageSize),n=S(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const d of i.nodes)d.childOffset>r&&(d.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this._getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=S(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const d=s.nodes,l=s.children,h=s.nodes.map(()=>-1),u=[],c=[];for(let g=0;g<d.length;++g){const e=d[g];if(o.has(e))continue;const t=u.length,s=C(g,-1,this._pageSize),n=C(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=C(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=l[s];if(t>=0)c.push(t);else{const i=S(t,this._pageSize),s=d[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.setNodes(u,c),this._updateParentBoundingInformation(h[S(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const s=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,d=this._getNodeInternal(t);if(null==d)return;for(let o=0;o<d.childCount;o++){const d=this.getChildIndex(t,o),l=this._getNodeInternal(d),h=null!=l?l.ref||l.node:null;if(null!=h&&h.serviceMbsInIndexSR[3]>0)if(null==e)e=n(h.serviceMbsInIndexSR,A);else{const t=L,n=F,o=z;i(h.serviceMbsInIndexSR,s,t,a),i(e,s,n,a),r(t,n,o),i(o,a,e,s)}}const l=t=>{null!=t&&(t.serviceObbInIndexSR=null,null!=e?(t.serviceMbsInIndexSR??=o(),n(e,t.serviceMbsInIndexSR)):h(t.serviceMbsInIndexSR),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};l(d.ref),l(d.node),this.invalidateNodeVisibilityCacheInternal(d),t=this._getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)}),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[S(e,this._pageSize)];return i.children[s.childOffset+t]}_getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[S(e,this._pageSize)]?.parent:null}getParent(e){const t=this._getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{null!=e.node&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=I(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=b(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e),i=t?.node;i&&(i.geometryObbInRenderSR=null,i.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeUpToDate(e){if(!this.needNodeElevationRange)return!0;const t=e?.node??e?.ref;return!t||t.elevationRangeValid}_updateElevationRange(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;if(s.elevationRangeValid)return t?.expandElevationRange(s),!0;const n=new g;let o=!1;for(let d=0;d<i.childCount;d++){const t=this.getChildIndex(e,d),i=this._updateElevationRange(t,n);o=o||!i}if(0===i.childCount||o){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,n)}n.elevationRangeMin!==1/0&&n.elevationRangeMax!==-1/0||n.expandElevationRangeValues(0,0);const{elevationRangeMin:r,elevationRangeMax:a}=s;return r===n.elevationRangeMin&&a===n.elevationRangeMax?(t?.expandElevationRange(s),!0):(i.node?.setElevationRange(n),i.ref?.setElevationRange(n),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t)return!0;const i=t.ref;if(null!=i&&!i.serviceMbsInIndexSR)return!0;if(this._isElevationRangeUpToDate(t)&&y(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);const s=t.node,n=this._viewportQueries;if(s){const e=n.ensureElevationAgnosticBoundingVolume(s),i=n.isElevationAgnosticBoundingVolumeVisible(e);let o=i;if(this.needNodeElevationRange&&i){const t=n.getNodeObbInRenderSRIndependentOfElevationOffset(s);null!=t&&(o=n.isObbVisibleIndependentOfElevation(e,t))}if(!o)return t.visibilityCache=P(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=s||null!=i)&&2===t.filterImpact){const e=null!=s?s.serviceMbsInIndexSR:null!=i?i.serviceMbsInIndexSR:null;t.filterImpact=null!=e?this._computeNodeFiltering(e):0}const o=null!=s&&1===t.filterImpact;let r=!(null!=s&&2===s.imModificationImpact)&&!o;if(r){const t=!s||i&&!s.visibilityObbInRenderSR?i??null:s;if(null!=t){this.needNodeElevationRange&&this._updateElevationRange(e);r=n.isNodeVisible(t)}}return t.visibilityCache=P(r,this._visibilityCacheVersion),r}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObbInRenderSR||this.layerHasModifications&&4===t.node.imModificationImpact)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let d=t.childOffset;d<r;++d){const e=o.children[d],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const d of a){const e=d.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,d,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(y(t.useAsHole,this._version))return x(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=P(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.prune(),this._prefetchNodes.prune(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=I(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{null!=e&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(null!=e){e.filterImpact=2;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),N.clear();let s=!0;const n=new M,o=new V,r=this._imModificationUncategorized;r.clear();const a=new Set;let d=0;const l=(a,l,h)=>{const u=R(a,this._pageSize);if(null==l){let e=this._getNodeLoadPriority(a);return e===1/0&&(e=this._getNodeLoadPriority(h)),N.set(u,Math.max(e,N.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||(this._missingPagesAndNodes.push(u),++d),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=l.node;if(this._updateNodeFeatureEstimate(c,o),null==c){const e=this._getNodeLoadPriority(a);return this._loadingNodes.has(a)||this._failedNodes.has(a)||(this._missingPagesAndNodes.push(a),N.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=this._getPage(a);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<l.childCount;e++){const t=g.children[l.childOffset+e],i=this._getNodeInternal(t);null!=i&&!i.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(N.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.push(t))}if(c.failed||c.resources.isEmpty)return void(s&&l.childCount>0&&this._isSelected(c)&&(s=!1));if(this._isLoaded(a)){if(n.known+=c.memory,++n.knownNodes,this._isSelected(c)?l.childCount>0&&(s=!1):(n.unremoved+=c.memory,s=!1),this._needsUpdate(c)){const e=this._getNodeLoadPriority(a);N.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._isSelected(c))return void(this._isReloading(a)&&this._updates.remove.push(a));if(l.childCount>0&&(s=!1),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(a)),void(this._updates.cancel=this._updates.cancel.filter(e=>e!==c.index));if(!t.done&&this._enable(c))return void t.madeProgress();const _=this._getNodeLoadPriority(a);N.set(a,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(a),this.layerHasModifications&&i&&null!=c&&4===c.imModificationImpact&&r.push(a)};this.traverseVisible(l,a),this._frameNumber++,this._missingPagesAndNodes.sort((e,t)=>e-t),this._missingPagesAndNodes.filterInPlace((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e),this._missingPagesAndNodes.sort((e,t)=>N.get(e)-N.get(t)),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=N.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,d);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace(e=>{const t=this._getNodeInternal(e),i=null==t?.node||2!==t.node.imModificationImpact;return i||this.invalidateNodeVisibilityCache(e),i})),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace(e=>N.get(e)>=this._maxUnloadedPrio).sort((e,t)=>N.get(e)-N.get(t)),this._updates.update.sort((e,t)=>N.get(e)-N.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,N.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new V;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=e.size,s=this._nodePages,n=s.size+this._loadingPages.size+t;if(n>D&&n>i){const t=new Array;for(const[i,n]of s)0!==n.numNodesWithLoadedChildren||e.has(i)||t.push([n.lastTraversed,i]);t.sort((e,t)=>e[0]-t[0]).some(e=>{const t=e[1];return this._deleteNodePage(t),s.size<=D})}}_updateFeatureEstimate(e,t){this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,i)=>this._updateNodeFeatureEstimate(i?.node,t))}_updateNodeFeatureEstimate(e,t){null!=e&&!e.failed&&this._isSelected(e)&&(null!=e.numFeatures?(t.numFeatures+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort((e,t)=>N.get(e)-N.get(t)),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&y(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this._getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=P(!0,this._version),s):(s=new l(o,r,n,P(!0,this._version)),i.traversalState=s,s)}_loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this.urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};(e>=0?this._requester.request(n,"json"):this._clientNodeLoader.loadNodeJSON(s)).catch(i=>{o(),t(i)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e))}).then(t=>{o();const i=this._validateNode(s,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const n=this._addNode(i,e);this.nodeTraversalState(n)})}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`)||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:void 0,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,d=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=new a(`${t.id}`,t.mbs);return s.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty("obb")&&t.obb?_.fromJSON(t.obb):null,s.visibilityObbInRenderSR=this._computeVisibilityObb(s),s},l=Array.isArray(t.children)?t.children.map(d).filter(e=>null!=e):null,h=t.featureData?.length??!1,u=!0===t.isEmpty;return new c(e,t.mbs,o,"string"==typeof t.version?t.version:null,{isEmpty:!h&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},l,Array.isArray(t.lodSelection)?t.lodSelection:null,r)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{null!=e.node&&(e.node.failed=!1)})}_getNodeLoadPriority(e){const t=this._getNodeInternal(e),i=this._getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._getNodeLoadPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i);s=e.traversalState?.lodLevel??0}const n=10,o=this._hasLoadedAncestor(e)?0:n*this._viewportQueries.distCameraToPOI();return-(this._viewportQueries.distToPOI(t.ref??t.node)*(1+s)+s*n*this._viewportQueries.distCameraToPOI())+o}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;null!=t;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){const i=this._getNodeInternal(this._rootIndex);null!=i?this._traverseVisible(this._rootIndex,null,i,e,t):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s,n){const o=R(e,this._pageSize);if(n&&n.add(o),i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const r=this.nodeTraversalState(i.node);if(r?.nodeHasLOD&&r.lodLevel===this._maxLodLevel)return;const a=this._getPageFromPageIndex(o);for(let d=0;d<i.childCount;d++){const t=a.children[i.childOffset+d],o=this._getNodeInternal(t);if(o)this._traverseVisible(t,e,o,s,n);else{if(n){const e=R(t,this._pageSize);n.add(e)}s(t,null,e)}}}traverse(e,t){t(e)&&this.traverseDescendants(e,t)}traverseDescendants(e,t){++this._traverseDescendantsNestingLevel;const i=e.index,s=this._pageSize,n=R(i,s),o=this._getPageFromPageIndex(n);if(null==o)return;const r=this._frameNumber,a=this._nodePages,d=S(i,s),l=o.nodes[d],h=l.childCount;if(o.lastTraversed=r,0===h)return;const u=new Array,c=1===this._traverseDescendantsNestingLevel?this._traverseDescendantsQueue:[0];let g=0;{const{childOffset:e,childCount:t}=l,{children:i}=o;c.length=2**Math.ceil(Math.log2(g+t));for(let s=e;s<e+t;++s){const e=i[s];e>=0?(c[g]=e,++g):u.push(e)}}if(u.length>0){const e=this._clientNodePage;if(e){const i=e.children;let s=0;for(;s<u.length;){const n=u[s];++s;const o=-n-1,r=e.nodes[o],a=r.node;if(!a||!t(a))continue;const{childCount:d}=r;if(0===d)continue;const{childOffset:l}=r,h=l+d;for(let e=l;e<h;++e)u.push(i[e])}}}if(g>0){let e=0;if(s>0){let i=n*s,d=o,l=d.nodes;for(;e<g;){const n=c[e];let o;if(++e,i<=n&&n<i+s)o=d;else{const e=n/s|0,t=a.get(e);if(void 0===t)continue;o=t,o.lastTraversed=r,d=o,l=d.nodes,i=s*e}const h=l[n-i],u=h.node;if(null==u||!1===t(u))continue;const{childCount:_}=h;if(0===_)continue;const f=g+_;for(c.length<f&&(c.length=2**Math.ceil(Math.log2(g+_)));c.length<g+_;)c.length+=c.length;const m=o.children,{childOffset:v}=h,N=v+_;for(let e=v;e<N;++e)c[g]=m[e],++g}}else{const i=a.get(0);if(i)for(;e<g;){const s=c[e++],n=i.nodes[s],o=n.node;if(!o||!t(o))continue;const{childCount:r}=n;if(0===r)continue;c.length=Math.max(c.length,2**Math.ceil(Math.log2(g+r)));const a=i.children,{childOffset:d}=n,l=d+r;for(let e=d;e<l;++e)c[g]=a[e],++g}}}--this._traverseDescendantsNestingLevel}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"relative-to-scene"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.ref?.invalidateElevationRange()})}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(R(e,this._pageSize)));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){const t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const N=new Map;class p{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function b(e){return u(e,-2)}function I(e){return u(e,2)}function P(e,t){return t+(e?1:0)}function y(e,t){return(-2&e)===t}function x(e){return!(1&~e)}function R(e,t){return e<0?-1:t>0?e/t|0:0}function S(e,t){return e<0?-e-1:0===t?e:e%t}function C(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const w=[["maxScreenThreshold",1],["screenSpaceRelative",2],["removedFeatureDiameter",3],["distanceRangeFromDefaultCamera",4]];function E(e){if(e)for(let t=0;t<e.length;t++)for(const i of w)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:0,maxError:0}}class M{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class V{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function O(e){return Math.sqrt(e*(4/Math.PI))}const A=o(),L=o(),F=o(),z=o(),D=has("esri-mobile")?100:300;export{v as I3SIndex,E as selectErrorMetric};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{result as e,assertResult as t}from"../../../../core/asyncUtils.js";import has from"../../../../core/has.js";import{clone as r}from"../../../../core/lang.js";import{throwIfAbortError as i}from"../../../../core/promiseUtils.js";import{makeAbsolute as
|
|
5
|
+
import{result as e,assertResult as t}from"../../../../core/asyncUtils.js";import has from"../../../../core/has.js";import{clone as r}from"../../../../core/lang.js";import{throwIfAbortError as i}from"../../../../core/promiseUtils.js";import{makeAbsolute as s}from"../../../../core/urlUtils.js";import{readBinaryAttribute as o,createGeometryDescriptor as n}from"./I3SBinaryReader.js";import{getMaterialAndTextures as a,getMaterialAndTexturesFromShared as u,selectEncoding as l}from"./I3SMaterialUtil.js";class f{constructor(e,t,r,i,s,o){if(this._requester=t,this._logger=r,this._defaultGeometrySchema=i,this._requiredAttributes=s,this._options=o,this._logLayer=e,this._layerUrl=e.parsedUrl.path,this._geometryDefinitions=e.geometryDefinitions,e.materialDefinitions){const t=e.textureSetDefinitions;this._materialAndTextures=e.materialDefinitions.map(r=>a(t,r,"integrated-mesh"===e.type))}}_loadAttribute(e,t,r){const i=`${this._layerUrl}/nodes/${e.resources.attributes}/attributes/${t.key}/0`;return this._requester.request(i,"array-buffer",r).then(e=>o(t,e))}async loadAttributes(e,t,r){const s=await Promise.allSettled(t.map(t=>this._loadAttribute(e,t.attributeStorageInfo,r))),o={};for(let n=0;n<t.length;++n){const r=s[n],a=t[n];if("fulfilled"===r.status){const e=r.value;o[a.name]=e}else{const t=r.reason;i(t),this._logger.error("#loadAttributes",this._logLayer,`Failed to load attributeData for '${a.name}' on node '${e.id}'`,t)}}return o}async loadNodeData(r,i){const s=null!=this._requiredAttributes&&r.resources.attributes?e(this.loadAttributes(r,this._requiredAttributes,i)):null,{bufferDefinition:o,bufferIndex:a}=g(this._geometryDefinitions,r),l=!!r.resources.geometry,f=l?e(this._loadGeometry(r.resources.geometry,a,i)):null,_=r.resources.hasSharedResource?await this._loadShared(r,i):null,y=r.resources.materialDefinition,b=this._materialAndTextures&&null!=y&&y>=0?this._materialAndTextures[y]:null!=_?u(_):null,D=b?.material,x=b?.textures??[],p=`${r.id}`,A=!l&&this._options.loadFeatureData,q=A?await this._loadFeatureData(p,i):null,$=A?c(q):d(D),T=null==$?m(q):null,j=x.length>0?e(this.loadTextures(r,x,i)):null;let w=null,I=null;if(f){w=t(await f);const e=h(this._defaultGeometrySchema,_);I=n(o,e)}const U=j?t(await j):null,S=s?t(await s):{},P=S?{attributeData:S,loadedAttributes:this._requiredAttributes}:null;if(null!=$)return{geometryData:$,attributeDataInfo:P,geometryBuffer:w,geometryDescriptor:I,requiredTextures:x,textureData:U};if(null!=T)return{pointData:T,attributeDataInfo:P,geometryBuffer:w,geometryDescriptor:I,requiredTextures:x,textureData:U};throw new Error}static _addAbsoluteHrefTexture(e,t){const r=e.textureDefinitions;if(null!=r)for(const i of Object.keys(r))for(const e of r[i].images)Array.isArray(e.href)?e.hrefConcat=e.href.map(e=>s(e,t)):e.hrefConcat=s(e.href,t)}static _fixTextureEncodings(e){const t=e.textureDefinitions;if(null!=t)for(const r in t){const e=t[r];if(Array.isArray(e.encoding))for(let t=0;t<e.encoding.length;t++){const r=e.encoding[t];r.startsWith("data:")&&(e.encoding[t]=r.slice(5))}else{const t=e.encoding;t.startsWith("data:")&&(e.encoding=t.slice(5))}}}async _loadShared(e,t){if(null==e.resources.geometry)return{};const r=`${this._layerUrl}/nodes/${e.resources.geometry}/shared`,i=await this._requester.request(r,"json",t);return f._fixTextureEncodings(i),f._addAbsoluteHrefTexture(i,r),i}_loadTexture(e,t,r,i,s){return 4===i||1===i||2===i?this._requester.request(e,"array-buffer",s).then(e=>({id:t,usage:r,data:e,encoding:i})):this._requester.request(e,"image",s).then(e=>({id:t,usage:r,data:e,encoding:i}))}loadTextures(e,t,r){const i=this._options.textureUsageMask;return Promise.all(t.map(t=>{if(0===(t.usage&i))return null;const s=l(t.encodings,this._options.textureEncodings);if(null==s)return this._logger.error("#loadTextures",this._logLayer,`No known encoding for texture found on node ${e.id}`),Promise.reject();const o=e.resources.texture||e.id,n=`${this._layerUrl}/nodes/${o}/textures/${s.name}`;return this._loadTexture(n,t.id,t.usage,s.encoding,r)}))}_loadFeatureData(e,t){const r=`${this._layerUrl}/nodes/${e}/features/0`;return this._requester.request(r,"json",t)}_loadGeometry(e,t,r){const i=`${this._layerUrl}/nodes/${e}/geometries/${t}`;return this._requester.request(i,"array-buffer",r)}}function d(e){return{featureIds:[],geometries:[{type:"ArrayBufferView",params:{material:e}}],featureDataPosition:[0,0,0]}}function c(e){if(!e)return null;for(const t of e.featureData){const e=t.geometries;if(null!=e)for(const r of e)return{featureIds:[t.id],featureDataPosition:t.position,geometries:[r]}}return null}function m(e){if(!e)return null;const t=new Array;for(const r of e.featureData)null!=r.position&&t.push({featureIds:[r.id],featureDataPosition:r.position,geometries:[]});return t}function h(e,t){if(!e||!t?.materialDefinitions)return e;const i=Object.keys(t.materialDefinitions)[0];return!t.materialDefinitions[i].params.vertexRegions&&e.vertexAttributes.region&&delete(e=r(e)).vertexAttributes.region,e}function g(e,t){const r={bufferDefinition:null,bufferIndex:0},i=t.resources.geometryDefinition;if(null==e||null==i||i<0)return r;const s=i>=0?e[i].geometryBuffers:null;if(null==s)return r;for(let o=0;o<s.length;o++){const e=s[o];if(null==e.compressedAttributes)r.bufferIndex=o,r.bufferDefinition=s[o];else if("draco"===e.compressedAttributes.encoding&&!has("disable-feature:i3s-draco"))return r.bufferIndex=o,r.bufferDefinition=e,r}return r}export{f 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{n as e,a as t,f as i,c as s,d as n,H as r,x as o,h as a,F as c,s as u,k as l,b as h,m as d,e as m,g as _}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as g}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as R}from"../../../../geometry/projection/projectors.js";import{create as S,fromMatrix as x,createPoints as M,intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{getNormal as I,signedDistance as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{m as F,a as D}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{evaluateElevationAlignmentAtPoint as A}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as B}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as j}from"../graphics/featureExpressionInfoUtils.js";import{isValidMbs as L,intersectBoundingRectWithMbs as y}from"./I3SUtil.js";import{Obb as w,computeOffsetObb as U}from"../../support/orientedBoundingBox.js";const k=1e5;class q{get _frustumMbsCenter(){return this._frustumMbs}get _frustumMbsRadius(){return this._frustumMbs[3]}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=S(),this._frustumMbs=f(),this._useFrustumCulling=!1,this._poi=p(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new w,this._tmp1=p(),this._tmp2=p(),this._tmp3=p(),this._tmp0=p(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=g(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||E(u)),this._indexSREllipsoidRadius=v(this._indexSR).radius,this._indexSRSphericalPCPF=g(e),this._projectorIndexSRToIndexSRSphericalPCPF=R(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=B.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(j(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){x(n.viewMatrix,n.projectionMatrix,this._frustum,N);{const r=n.eye,o=G;e(o,n.viewForward);const a=T;t(a,N[4],r);const c=.5*i(a,a)/i(o,a),u=this._frustumMbs;s(u,r,o,c);const l=1+c;u[3]=l}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(L(t))return t;const{serviceMbsInIndexSR:i}=e;i&&F(i,t);const s=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(s)){let i=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":i=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+s-t[2],n=r-s;break;case"on-the-ground":i=s-t[2],n=r-s}t[2]+=i+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<k&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=A(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new w,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<k){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=A(e,this._elevationProvider,u,c)-a}const l=o>0,h=l?this._tmpObb:t;return s.transform(h,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),l&&U(h,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(Y,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),Y):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume;let a,c=-1;if(s){const t=J;s.getCenter(t),e(t,t),a=t,s.getCorners(K);for(const s of K){e(s,s);const n=i(s,t);if(n<=0)return void o.invalidate();const r=Math.sqrt(1-n*n);c=Math.max(c,r)}}else{const i=t.serviceMbsInRenderSR;if(!L(i))return void o.invalidate();{const t=n(J,D(i)),s=i[3],u=r(t);if(u<s)return void o.invalidate();c=s/u,e(t,t),a=t}}const u=.001;o.set(a,c+u)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(J);e[2]=0;let s=0;const n=Q;i.getCorners(K);for(const t of K){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(L(i)){const e=n(J,D(i));e[2]=0,t.set(e,i[3])}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):C(this._frustum,t)}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n.radius;if(-1===r||r>.9)return!0;const o=this._frustumPlanes,c=this._frustumMbsCenter,u=n.getAxis(ie),l=i(u,c),h=this._frustumMbsRadius,d=l-h,m=l+h;if(d<=0)return!0;const _=a(W,u,d),p=a(Z,u,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=I(v),r=e(X,n),o=i(r,u);if(Math.abs(1-o)<.01)continue;const c=$;a(c,u,o),t(c,c,r),e(c,c);const l=ee;s(l,_,c,d*f);if(P(v,l)<=0)continue;s(l,p,c,m*f);if(P(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,o=r(n);if(o<=s)return!0;const u=e.getAxis(ie),l=i(u,n);{const e=a(H,u,l);if(c(e,n)<s)return!0}const h=l/o;if(l<=0){return-h<s}const d=Math.sqrt(1-h*h);if(d<t)return!0;const m=s/o;return d*Math.sqrt(1-m*m)-m*h<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=K;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(ie),c=i(t,n),u=c-s,l=c+s;if(u<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=te;if(a(o,n,u/r),P(e,o)<=0){s=!1;break}const c=te;if(a(c,n,l/r),P(e,c)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=I(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=n(H,t);s[2]=0;const r=e.radius,o=e.getAxis(ie);return c(s,o)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==y(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(u(D(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=l(D(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/h(D(t))+i)/l(D(t),this._camPos);return Math.min(1,s)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=h(D(t)),n=h(e)-s;a(this._tmp0,e,i(e,D(t))/d(e));const r=u(D(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,D(t),1/s),c=s,u=o*o/2/c,d=a(this._tmp1,r,c-u),p=e,f=m(this._tmp2,p,d),v=m(this._tmp2,f,a(this._tmp3,r,i(r,f))),g=_(this._tmp2,d,a(this._tmp2,v,o/h(v)));let b=l(p,g);if(n>=2e5){const e=m(this._tmp1,p,g);let t=i(e,r)/h(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):z(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 2:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case 1:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return l(D(t),this._poi)-t[3]}distCameraToPOI(){return l(this._camPos,this._poi)}}function z(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const G=p(),N=M(),T=p(),H=p(),W=p(),Z=p(),X=p(),Y=new w,J=p(),K=[p(),p(),p(),p(),p(),p(),p(),p()],Q=p(),$=p(),ee=p(),te=p(),ie=p();export{q as default};
|
|
5
|
+
import{n as e,a as t,f as i,c as s,d as n,H as r,x as o,h as a,F as c,s as u,k as l,b as h,m as d,e as m,g as _}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as g}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as R}from"../../../../geometry/projection/projectors.js";import{create as S,fromMatrix as x,createPoints as M,intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{getNormal as I,signedDistance as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{m as F,a as D}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{evaluateElevationAlignmentAtPoint as A}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as B}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as j}from"../graphics/featureExpressionInfoUtils.js";import{isValidMbs as L,intersectBoundingRectWithMbs as y}from"./I3SUtil.js";import{Obb as w,computeOffsetObb as U}from"../../support/orientedBoundingBox.js";const k=1e5;class q{get _frustumMbsCenter(){return this._frustumMbs}get _frustumMbsRadius(){return this._frustumMbs[3]}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=S(),this._frustumMbs=f(),this._useFrustumCulling=!1,this._poi=p(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new w,this._tmp1=p(),this._tmp2=p(),this._tmp3=p(),this._tmp0=p(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=g(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||E(u)),this._indexSREllipsoidRadius=v(this._indexSR).radius,this._indexSRSphericalPCPF=g(e),this._projectorIndexSRToIndexSRSphericalPCPF=R(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=B.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(j(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){x(n.viewMatrix,n.projectionMatrix,this._frustum,N);{const r=n.eye,o=G;e(o,n.viewForward);const a=T;t(a,N[4],r);const c=.5*i(a,a)/i(o,a),u=this._frustumMbs;s(u,r,o,c);const l=1+c;u[3]=l}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(L(t))return t;const{serviceMbsInIndexSR:i}=e;i&&F(i,t);const s=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(s)){let i=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":i=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+s-t[2],n=r-s;break;case"on-the-ground":i=s-t[2],n=r-s}t[2]+=i+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<k&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=A(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new w,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<k){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=A(e,this._elevationProvider,u,c)-a}const l=o>0,h=l?this._tmpObb:t;return s.transform(h,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),l&&U(h,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(Y,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),Y):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume;let a,c=-1;if(s){const t=J;s.getCenter(t),e(t,t),a=t,s.getCorners(K);for(const s of K){e(s,s);const n=i(s,t);if(n<=0)return void o.invalidate();const r=Math.sqrt(1-n*n);c=Math.max(c,r)}}else{const i=t.serviceMbsInRenderSR;if(!L(i))return void o.invalidate();{const t=n(J,D(i)),s=i[3],u=r(t);if(u<s)return void o.invalidate();c=s/u,e(t,t),a=t}}const u=.001;o.set(a,c+u)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(J);e[2]=0;let s=0;const n=Q;i.getCorners(K);for(const t of K){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(L(i)){const e=n(J,D(i));e[2]=0,t.set(e,i[3])}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):C(this._frustum,t)}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n.radius;if(-1===r||r>.9)return!0;const o=this._frustumPlanes,c=this._frustumMbsCenter,u=n.getAxis(ie),l=i(u,c),h=this._frustumMbsRadius,d=l-h,m=l+h;if(d<=0)return!0;const _=a(W,u,d),p=a(Z,u,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=I(v),r=e(X,n),o=i(r,u);if(Math.abs(1-o)<.01)continue;const c=$;a(c,u,o),t(c,c,r),e(c,c);const l=ee;s(l,_,c,d*f);if(P(v,l)<=0)continue;s(l,p,c,m*f);if(P(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,o=r(n);if(o<=s)return!0;const u=e.getAxis(ie),l=i(u,n);{const e=a(H,u,l);if(c(e,n)<s)return!0}const h=l/o;if(l<=0){return-h<s}const d=Math.sqrt(1-h*h);if(d<t)return!0;const m=s/o;return d*Math.sqrt(1-m*m)-m*h<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=K;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(ie),c=i(t,n),u=c-s,l=c+s;if(u<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=te;if(a(o,n,u/r),P(e,o)<=0){s=!1;break}const c=te;if(a(c,n,l/r),P(e,c)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=I(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=n(H,t);s[2]=0;const r=e.radius,o=e.getAxis(ie);return c(s,o)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==y(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(u(D(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=l(D(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/h(D(t))+i)/l(D(t),this._camPos);return Math.min(1,s)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=h(D(t)),n=h(e)-s;a(this._tmp0,e,i(e,D(t))/d(e));const r=u(D(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,D(t),1/s),c=s,u=o*o/2/c,d=a(this._tmp1,r,c-u),p=e,f=m(this._tmp2,p,d),v=m(this._tmp2,f,a(this._tmp3,r,i(r,f))),g=_(this._tmp2,d,a(this._tmp2,v,o/h(v)));let b=l(p,g);if(n>=2e5){const e=m(this._tmp1,p,g);let t=i(e,r)/h(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):z(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 2:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case 1:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){if(null==e)return 0;const t=this.getServiceMbsInRenderSR(e);return l(D(t),this._poi)-t[3]}distCameraToPOI(){return l(this._camPos,this._poi)}}function z(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const G=p(),N=M(),T=p(),H=p(),W=p(),Z=p(),X=p(),Y=new w,J=p(),K=[p(),p(),p(),p(),p(),p(),p(),p()],Q=p(),$=p(),ee=p(),te=p(),ie=p();export{q 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{shuffle as t}from"../../../../core/arrayUtils.js";import{baseObjectMemory as e}from"../../../../core/memoryEstimations.js";import{signal as s}from"../../../../core/signal.js";import{diameter as i,create as r}from"../../../../geometry/support/aaBoundingBox.js";import{fromExtent as a,create as u,intersects as h,copy as n,positiveInfinity as
|
|
5
|
+
import{shuffle as t}from"../../../../core/arrayUtils.js";import{baseObjectMemory as e}from"../../../../core/memoryEstimations.js";import{signal as s}from"../../../../core/signal.js";import{diameter as i,create as r}from"../../../../geometry/support/aaBoundingBox.js";import{fromExtent as a,create as u,intersects as h,copy as n,positiveInfinity as l,intersection as m}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as f,estimateSize as o,getObjectId as d,computeAABB as c}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as _}from"../graphics/graphicUtils.js";import{SampledGeometryMaxDistanceRatio as g}from"./SampledGeometryMaxDistanceRatio.js";const F=16438;class p{constructor(t){this.descriptor=t,this._numVertices=0,this.exceededTransferLimit=s(!1),this._fetchFailed=s(!1),this._sorted=!1,this._numFeatures=s(y),this._emptyFeatureRatio=s(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._sampledDensityEstimate=-1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=s(0),this._featureLimit=s(0),this._fetchStatus=0,this.fetchInformation=s(""),this.fetchingResolution=this.displayingResolution=t.resolution}get featuresMissing(){return this.fetchFailed||(this.hasPreciseFeatureCount?this._featuresLength.value<this.numFeatures:this.exceededTransferLimit.value)}get showsAllFeatures(){return!this.fetchFailed&&null!=this.displayingFeatures&&(this.hasPreciseFeatureCount?this.displayingFeatures.length===this.numFeatures:!this.exceededTransferLimit.value)}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=this.isFetched&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s,this._features=t,this._featuresLength.value=t?.length??0,this._sorted=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._sampledDensityEstimate=-1,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce((t,e)=>t+f(e.geometry),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce((t,{geometry:e})=>Math.max(t,_(e)??0),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures.value:this._features?this._featuresLength.value:0}set numFeatures(t){this._numFeatures.value=t}get hasPreciseFeatureCount(){return this._numFeatures.value>y}get needsFeatureCount(){return this._numFeatures.value===y}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateEstimates(),this._estimatedSize}get sampledDensityEstimate(){return this._sampledDensityEstimate}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateEstimates(){if(this._estimatedSize<0||this._sampledDensityEstimate<0){this._estimatedSize=0,this._estimatedUnusedSize=0,this._sampledDensityEstimate=0;const t=Math.floor(Math.sqrt(z));if(this._features){let e=null;const s=new g(z,R*this.fetchingResolution),i=this._features.length;for(let r=0;r<i;++r){const a=this._features[r],u=o(a);if(this._estimatedSize+=u,r>=this.featureLimit&&(this._estimatedUnusedSize+=u),!s.done){const u=i-r;if(r%Math.ceil(u/Math.max(1,Math.floor(Math.sqrt(s.numRemainingSamples))))===0){const i=Math.max(Math.floor(s.numRemainingSamples/u),t);s.sampleGeometry(a.geometry,e,i)}}e=a.geometry}s.numSamples>=x?this._sampledDensityEstimate=s.ratio:this._sampledDensityEstimate=0}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=o(this._features[t]);return!0}return!1}get fetchStatus(){return this._fetchStatus}requestFetch(){this._fetchStatus=0}requestRefetch(){this._fetchStatus=1}startFetch(){this._fetchStatus=this.needsRefetch?3:2}fetchDone(t){this._fetchStatus=t}get isFetching(){return 2===this._fetchStatus||3===this._fetchStatus}get isRefetching(){return 3===this._fetchStatus}get needsFetch(){return 0===this._fetchStatus||1===this._fetchStatus}get needsRefetch(){return 1===this._fetchStatus}get isFetched(){return 4===this._fetchStatus||5===this._fetchStatus}isFullyFetched(t){return!!this.features&&(this.features.length>=t||5===this.fetchStatus)}resetFetching(){this._fetchStatus=this.isRefetching?1:0}get needsDisplayUpdate(){return!!this._features&&!L(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(a(t,D),h(this.descriptor.extent,D))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(a(t,e),m(e,s,e)):n(e,s),e):(n(e,l),e)}_shuffle(e){this._features?.sort((t,s)=>d(t,e)-d(s,e)),t(this._features,F)}_sortBySize(t){this._features?.sort((e,s)=>i(c(s.geometry,M))-i(c(e.geometry,M))||d(e,t)-d(s,t))}reduceFeatures(t,e,s,i){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let r=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&4===this._fetchStatus&&this._features.length>0&&(this._fetchStatus=1,r=!0),!this._sorted&&t<1&&(1===i?this._shuffle(s):this._sortBySize(s),this._sorted=!0,this._estimatedUnusedSizeDirty=!0);const a=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>a&&(this._features.length=this._featuresLength.value=a,this.exceededTransferLimit.value=!1,5===this._fetchStatus&&(this._fetchStatus=4)),r}get cache(){return new v(this,this._features,this._numFeatures.value,this._emptyFeatureRatio.value)}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures.value=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this._fetchStatus=t.fetchStatus,this.exceededTransferLimit.value=t.exceededTransferLimit,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._estimatedUnusedSizeDirty=!0,this.fetchInformation.value=t.fetchInformation}}const y=-1,S=-2;class v{constructor(t,s,i,r){this.features=s,this.numFeatures=i,this.emptyFeatureRatio=r,this.usedMemory=e+t.estimatedSize,this.resolution=t.displayingResolution,this.availableFields=t.availableFields,this.fetchStatus=t.fetchStatus,this.exceededTransferLimit=t.exceededTransferLimit.value,this.fetchInformation=t.fetchInformation.value}}function L(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}const z=150,x=100,R=2,D=u(),M=r();export{p as FeatureTile,v as FeatureTileCacheItem,S as failedFeatureCount};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{filterInPlace as s}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import o from"../../../../core/ReactiveMap.js";import{on as l,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as h}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as c}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{getEpsilon as _}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as m,equals as g,clone as y,expand as F,toExtent as T,width as x,height as v}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as R,hasVertices as b,computeAABR as E}from"../../../../layers/graphics/dehydratedFeatures.js";import C from"../../../../rest/support/QuantizationParameters.js";import D from"../../../../rest/support/Query.js";import{MultiFeatureReference as w,SingleFeatureReference as M}from"./featureReference.js";import{failedFeatureCount as U,FeatureTile as j}from"./FeatureTile.js";import{virtualDisplayFilterHighlightTileId as A,virtualSnapshotTileId as I}from"./FeatureTileDescriptor.js";import{tilesAreRelated as O}from"../../terrain/tileUtils.js";import{ImmediateTask as P,TaskPriority as z}from"../../../support/Scheduler.js";let q=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get readyToRun(){return this._dirty}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.estimatedUnusedSize),e}get totalVertices(){let e=0;return this._featureTiles.forEach(t=>e+=t.numVertices),e}get totalFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.numFeatures),e}get showsAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.showsAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;const e=this.tileDescriptors?.some(Q);return e||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void i.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const s=null!=e?e.clone():null;this._set("filterExtent",s),this._reclip(s,t)}_updateTileZQuantization(e){if(1===this.context.viewingMode){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._featureTiles=new o,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1;const t=e.context;this._frameTask=t.scheduler?.registerTask(z.FEATURE_TILE_FETCHER,this)??P,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?w:M,this._objectIdField=t.objectIdField}initialize(){this.addHandles([l(()=>this.tileDescriptors,"change",()=>this._setDirty(),{onListenerAdd:()=>this._setDirty(),onListenerRemove:()=>this._setDirty()}),u(()=>this._tileZQuantization,()=>this.refetch())]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._removeTile(e)}),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)}),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._resetFetchTile(e)}),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetchDisplayFilterHighlightTile(){const e=this._featureTiles.get(A);e&&(this._cancelFetchTile(e),this._resetFetchTile(e),this._setDirty())}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach(e=>this._cancelFetchTile(e)),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach(t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach(s=>{t.availableFields?.has(s)||e.delete(s)}))}),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then(()=>e.result.catch(e=>{if(a(e))throw e;return null}).then(e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then(()=>e)):e).then(e=>(0===--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,s=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach(({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(s||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)}),this._featureTiles.forEach(e=>{if(!e.features)return;const t=e.features.filter(e=>!r.has(R(e,this._objectIdField)));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())})}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find(t=>t.attributes?.[s]===e);return i?R(i,t):null}async _applyEditsAddUpdateFeatures(e,t,s){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,l=new Set;for(const i of e){const e=i.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),l.add(e))}if(0===o.size)return;const u=[];this._featureTiles.forEach(e=>{const t=this._applyEditsAddUpdateTile(e,o,l,s);u.push(t)}),this._updated(),await Promise.allSettled(u)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter(e=>!s.has(R(e,this._objectIdField)));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Z(e.availableFields,a.fields),V(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:J})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._featureTilesArray;if(this._markTilesNotAlive(s),!e.run(()=>this._addTiles(s,e))||!e.run(()=>this._filterExtentTiles(s,e))||!e.run(()=>this._removeTiles(s,e))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run(()=>this._showTiles(i,e))&&e.run(()=>this._fetchTiles(i,e))&&e.run(()=>this._updateMemoryEstimates(i,e))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach(s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())}),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();const{numFeatures:i,fetchingResolution:r,descriptor:a,isFetched:n}=e;return this._supportsResolution&&i>0&&r!==a.resolution&&n&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run(()=>i(r))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let s=!1;for(const i of e){if(!i.needsFetch)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(i.id):null;if(e?.resolution!==i.displayingResolution){if(this._needsNumFeatures(i)){const e=new AbortController,r=this._fetchTileCount(i,e.signal);this._handleRequest(i,r,e,()=>i.resetFetching(),()=>i.numFeatures=U),s=!0,t.madeProgress()}if(t.done)return!0}else i.cache=e,i.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(s)return t.hasProgressed;for(const r of e){if(!r.needsFetch)continue;const e=new AbortController,s=this._fetchTile(r,e.signal);if(this._handleRequest(r,s,e,e=>r.fetchDone(e),e=>{r.fetchFailed=!0,this.context.logFetchError(i.getLogger(this),e)}),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some(e=>!t.run(()=>e.updateMemoryEstimates())&&(this._setDirty(),!0)),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach(i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,B),i.intersectionIncludingBorrowed(e,G),g(B,G)||s.push(i))}),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=R(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach(t=>t.isFetching?++e:0),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach(e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetch?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)}),r+=e;let o=0,l=0;t?(l=t,o=Math.min(r*t/i,t)):(l=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",l),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=L(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach(e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))}),this._setDirty())}_addTile(e){const t=new j(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach(s=>{if(null!=s.displayingFeatures&&e!==s&&O(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=y(e.descriptor.extent),F(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(R(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(4):e.requestFetch()}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t}),this._updateRatio(this._featureTilesArray)}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),k(e),e.fetchInformation.value="Empty tile",4;const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,N(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>D.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const a=this._createQuery(e);if(a.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}e.fetchInformation.value=`Single fetch\n${s} features`;const{features:o,exceededTransferLimit:l,fields:u,missingAttributes:h}=await this._queryFeatures(a,t),d=l||a.maxRecordCountFactor>=D.MAX_MAX_RECORD_COUNT_FACTOR||s===this._totalFeaturesForTile(e)?5:4,c=await this._frameTask.schedule(()=>{e.exceededTransferLimit.value=!!l;const t=this._removeEmptyFeatures(o,this._getEffectiveTileResolution(e));return e.fetchInformation.value=`Single fetch\n${o.length}/${s} features`,e.setFeatures(o,t,H(u),V(void 0,h)),this._updateTileZQuantization(e),this._maximumFeaturesForTile(e)>s?1:d},t);return n(t),this._invalidateCounts(),c}async _fetchPagedTile(e,t){let s,i=0,r=0,a=0,o=this._maximumFeaturesForTile(e)-a;const l=this._getMaxRecordCount(e);let u,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,l);e.fetchInformation.value=`Paged fetch\n${e.features?.length}/${o} features`;const{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule(()=>{c&&(i+=d.num),a+=p.length,r+=this._removeEmptyFeatures(p,this._getEffectiveTileResolution(e)),e.exceededTransferLimit.value=!!f,s=s?.concat(p)??p,h=Z(h,_),u=V(u,m),e.setFeatures(s,r,h,u),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()},t),n(t),o=this._maximumFeaturesForTile(e)-(s?.length??0),!c||!f||o<=0)return f?4:5}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();if(t.resultType=this._resultType(e),!N(e)&&e.descriptor.extent&&this.context.tilingScheme&&(t.geometry=T(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),"tile"!==t.resultType&&this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),S(e)){const{highlightIds:e}=this.context;e&&e.length>$&&i.getLogger(this).warn("highlight-too-many-features",`highlight is limited to ${$} features on large layers configured with a display filter to avoid performance issues`),t.objectIds=e?.slice(0,$)}else!Q(e)&&this.context.effectiveDisplayFilter&&(t.where=c(t.where,this.context.effectiveDisplayFilter.where));return t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(N(e)||!this._supportsResolution)return null;const t=1===this.context.viewingMode&&this.context.tilingScheme?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new C({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e,t){const i=e.length;if(t&&this._supportsResolution){const i=t*(1+_());s(e,({geometry:e})=>!(!e||!b(e))&&(E(e,X),x(X)>i||v(X)>i))}else s(e,({geometry:e})=>b(e));return i-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!Q(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case"tile":if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case"standard":if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||$}_resultType(e){if(this.context.capabilities.supportsResultType)return Q(e)?"standard":"tile"}get _reduceMode(){const e=this.context.geometryType;return"polygon"===e||"polyline"===e?0:1}_handleRequest(e,t,s,i,r){e.startFetch(),e.requestController=s;let n=!1;t.then(t=>{e.requestController=null,i(t)}).catch(t=>{e.requestController===s&&(e.requestController=null,e.fetchDone(4)),a(t)?n=!0:r(t)}).then(()=>{n||this._setDirty(),this._scheduleUpdated()})}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(h(()=>{this.removeHandles("scheduleUpdated"),this._updated()}),"scheduleUpdated")}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const t=e.features;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);for(let n=0;n<a;++n){const e=t[n],a=R(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=R(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+K,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}get _featureTilesArray(){return Array.from(this._featureTiles.values())}get featureTiles(){return this._featureTiles}get storedFeatures(){return this._featureTilesArray.reduce((e,t)=>e+(t.features?t.features.length:0),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce((e,t)=>e+(t.needsFetch||t.isFetching?1:0),0)}_totalFeaturesForTile(e){return e.hasPreciseFeatureCount?e.numFeatures:this.maximumNumberOfFeatures}_maximumFeaturesForTile(e){const t=this._totalFeaturesForTile(e),s=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(t*s/(1-e.emptyFeatureRatio)),t)}get test(){}};function Q(e){return e.id===I}function S(e){return e.id===A}function N(e){return Q(e)||S(e)}function L(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function k(e){e.setFeatures([],0,null,void 0)}function H(e){return null==e?new Set:new Set(e.map(e=>e.name))}function Z(e,t){if(null==e||null==t)return H(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function V(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:i,attribute:a}of t)r(e,i,s).add(a);return e}e([p({constructOnly:!0})],q.prototype,"features",void 0),e([p({constructOnly:!0})],q.prototype,"context",void 0),e([p()],q.prototype,"tileDescriptors",void 0),e([p({value:1/0})],q.prototype,"maximumNumberOfFeatures",null),e([p({value:1})],q.prototype,"memoryFactor",null),e([p({value:1})],q.prototype,"lodFactor",null),e([p()],q.prototype,"useTileCount",null),e([p({readOnly:!0})],q.prototype,"updating",null),e([p({readOnly:!0})],q.prototype,"dataUpdating",void 0),e([p({readOnly:!0})],q.prototype,"updatingTotal",void 0),e([p({readOnly:!0})],q.prototype,"updatingRemaining",void 0),e([p({readOnly:!0})],q.prototype,"expectedFeatureDiff",void 0),e([p({readOnly:!0})],q.prototype,"memoryForUnusedFeatures",null),e([p({readOnly:!0})],q.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([p({readOnly:!0})],q.prototype,"totalVertices",null),e([p({readOnly:!0})],q.prototype,"totalFeatures",null),e([p({readOnly:!0})],q.prototype,"showsAllFeatures",null),e([p({readOnly:!0})],q.prototype,"hasFullGeometries",null),e([p()],q.prototype,"filterExtent",null),e([p()],q.prototype,"_dirty",void 0),e([p()],q.prototype,"_suspended",void 0),e([p()],q.prototype,"_pendingEdits",void 0),e([p()],q.prototype,"_applyEditsTilesUpdated",void 0),e([p()],q.prototype,"_paused",null),e([p()],q.prototype,"_isFetching",void 0),q=e([f("esri.views.3d.layers.support.FeatureTileFetcher3D")],q);const $=2e3,B=m(),G=m(),X=m(),J=6e5,K=200;export{q as FeatureTileFetcher3D};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{filterInPlace as s}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import o from"../../../../core/ReactiveMap.js";import{on as l,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as h}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as c}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{getEpsilon as _}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as m,equals as g,clone as y,expand as F,toExtent as T,width as x,height as v}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as R,hasVertices as E,computeAABR as b}from"../../../../layers/graphics/dehydratedFeatures.js";import C from"../../../../rest/support/QuantizationParameters.js";import D from"../../../../rest/support/Query.js";import{MultiFeatureReference as w,SingleFeatureReference as M}from"./featureReference.js";import{failedFeatureCount as U,FeatureTile as j}from"./FeatureTile.js";import{virtualDisplayFilterHighlightTileId as A,virtualSnapshotTileId as I}from"./FeatureTileDescriptor.js";import{tilesAreRelated as O}from"../../terrain/tileUtils.js";import{ImmediateTask as P,TaskPriority as z}from"../../../support/Scheduler.js";let q=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get readyToRun(){return this._dirty}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.estimatedUnusedSize),e}get totalVertices(){let e=0;return this._featureTiles.forEach(t=>e+=t.numVertices),e}get totalFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.numFeatures),e}get showsAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.showsAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;const e=this.tileDescriptors?.some(Q);return e||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void i.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const s=null!=e?e.clone():null;this._set("filterExtent",s),this._reclip(s,t)}_updateTileZQuantization(e){if(1===this.context.viewingMode){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._featureTiles=new o,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this.snappingComplexityExceeded=!0,this._isFetching=!1;const t=e.context;this._frameTask=t.scheduler?.registerTask(z.FEATURE_TILE_FETCHER,this)??P,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?w:M,this._objectIdField=t.objectIdField}initialize(){this.addHandles([l(()=>this.tileDescriptors,"change",()=>this._setDirty(),{onListenerAdd:()=>this._setDirty(),onListenerRemove:()=>this._setDirty()}),u(()=>this._tileZQuantization,()=>this.refetch())]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._removeTile(e)}),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)}),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._resetFetchTile(e)}),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetchDisplayFilterHighlightTile(){const e=this._featureTiles.get(A);e&&(this._cancelFetchTile(e),this._resetFetchTile(e),this._setDirty())}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach(e=>this._cancelFetchTile(e)),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach(t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach(s=>{t.availableFields?.has(s)||e.delete(s)}))}),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then(()=>e.result.catch(e=>{if(a(e))throw e;return null}).then(e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then(()=>e)):e).then(e=>(0===--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,s=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach(({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(s||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)}),this._featureTiles.forEach(e=>{if(!e.features)return;const t=e.features.filter(e=>!r.has(R(e,this._objectIdField)));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())})}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find(t=>t.attributes?.[s]===e);return i?R(i,t):null}async _applyEditsAddUpdateFeatures(e,t,s){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,l=new Set;for(const i of e){const e=i.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),l.add(e))}if(0===o.size)return;const u=[];this._featureTiles.forEach(e=>{const t=this._applyEditsAddUpdateTile(e,o,l,s);u.push(t)}),this._updated(),await Promise.allSettled(u)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter(e=>!s.has(R(e,this._objectIdField)));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Z(e.availableFields,a.fields),V(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:J})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._featureTilesArray;if(this._markTilesNotAlive(s),!e.run(()=>this._addTiles(s,e))||!e.run(()=>this._filterExtentTiles(s,e))||!e.run(()=>this._removeTiles(s,e))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run(()=>this._showTiles(i,e))&&e.run(()=>this._fetchTiles(i,e))&&e.run(()=>this._updateMemoryEstimates(i,e))||this._setDirty(),this._updated(),this.updating||(this._updateMaximumNumberOfFeaturesExceeded(),this._updateSnappingComplexityExceeded(i))}_updateSnappingComplexityExceeded(e){let t=Y;for(const s of e){if(Q(s)||t<=0)break;if(!S(s)&&(t--,s.sampledDensityEstimate>W))return void(this.snappingComplexityExceeded=!0)}this.snappingComplexityExceeded=0===this._featureTiles.size}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach(s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())}),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();const{numFeatures:i,fetchingResolution:r,descriptor:a,isFetched:n}=e;return this._supportsResolution&&i>0&&r!==a.resolution&&n&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run(()=>i(r))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let s=!1;for(const i of e){if(!i.needsFetch)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(i.id):null;if(e?.resolution!==i.displayingResolution){if(this._needsNumFeatures(i)){const e=new AbortController,r=this._fetchTileCount(i,e.signal);this._handleRequest(i,r,e,()=>i.resetFetching(),()=>i.numFeatures=U),s=!0,t.madeProgress()}if(t.done)return!0}else i.cache=e,i.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(s)return t.hasProgressed;for(const r of e){if(!r.needsFetch)continue;const e=new AbortController,s=this._fetchTile(r,e.signal);if(this._handleRequest(r,s,e,e=>r.fetchDone(e),e=>{r.fetchFailed=!0,this.context.logFetchError(i.getLogger(this),e)}),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some(e=>!t.run(()=>e.updateEstimates())&&(this._setDirty(),!0)),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach(i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,B),i.intersectionIncludingBorrowed(e,G),g(B,G)||s.push(i))}),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=R(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach(t=>t.isFetching?++e:0),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach(e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetch?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)}),r+=e;let o=0,l=0;t?(l=t,o=Math.min(r*t/i,t)):(l=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",l),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=L(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach(e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))}),this._setDirty())}_addTile(e){const t=new j(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach(s=>{if(null!=s.displayingFeatures&&e!==s&&O(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=y(e.descriptor.extent),F(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(R(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(4):e.requestFetch()}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t}),this._updateRatio(this._featureTilesArray)}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),k(e),e.fetchInformation.value="Empty tile",4;const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,N(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>D.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const a=this._createQuery(e);if(a.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}e.fetchInformation.value=`Single fetch\n${s} features`;const{features:o,exceededTransferLimit:l,fields:u,missingAttributes:h}=await this._queryFeatures(a,t),d=l||a.maxRecordCountFactor>=D.MAX_MAX_RECORD_COUNT_FACTOR||s===this._totalFeaturesForTile(e)?5:4,c=await this._frameTask.schedule(()=>{e.exceededTransferLimit.value=!!l;const t=this._removeEmptyFeatures(o,this._getEffectiveTileResolution(e));return e.fetchInformation.value=`Single fetch\n${o.length}/${s} features`,e.setFeatures(o,t,H(u),V(void 0,h)),this._updateTileZQuantization(e),this._maximumFeaturesForTile(e)>s?1:d},t);return n(t),this._invalidateCounts(),c}async _fetchPagedTile(e,t){let s,i=0,r=0,a=0,o=this._maximumFeaturesForTile(e)-a;const l=this._getMaxRecordCount(e);let u,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,l);e.fetchInformation.value=`Paged fetch\n${e.features?.length}/${o} features`;const{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule(()=>{c&&(i+=d.num),a+=p.length,r+=this._removeEmptyFeatures(p,this._getEffectiveTileResolution(e)),e.exceededTransferLimit.value=!!f,s=s?.concat(p)??p,h=Z(h,_),u=V(u,m),e.setFeatures(s,r,h,u),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()},t),n(t),o=this._maximumFeaturesForTile(e)-(s?.length??0),!c||!f||o<=0)return f?4:5}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();if(t.resultType=this._resultType(e),!N(e)&&e.descriptor.extent&&this.context.tilingScheme&&(t.geometry=T(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),"tile"!==t.resultType&&this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),S(e)){const{highlightIds:e}=this.context;e&&e.length>$&&i.getLogger(this).warn("highlight-too-many-features",`highlight is limited to ${$} features on large layers configured with a display filter to avoid performance issues`),t.objectIds=e?.slice(0,$)}else!Q(e)&&this.context.effectiveDisplayFilter&&(t.where=c(t.where,this.context.effectiveDisplayFilter.where));return t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(N(e)||!this._supportsResolution)return null;const t=1===this.context.viewingMode&&this.context.tilingScheme?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new C({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e,t){const i=e.length;if(t&&this._supportsResolution){const i=t*(1+_());s(e,({geometry:e})=>!(!e||!E(e))&&(b(e,X),x(X)>i||v(X)>i))}else s(e,({geometry:e})=>E(e));return i-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!Q(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case"tile":if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case"standard":if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||$}_resultType(e){if(this.context.capabilities.supportsResultType)return Q(e)?"standard":"tile"}get _reduceMode(){const e=this.context.geometryType;return"polygon"===e||"polyline"===e?0:1}_handleRequest(e,t,s,i,r){e.startFetch(),e.requestController=s;let n=!1;t.then(t=>{e.requestController=null,i(t)}).catch(t=>{e.requestController===s&&(e.requestController=null,e.fetchDone(4)),a(t)?n=!0:r(t)}).then(()=>{n||this._setDirty(),this._scheduleUpdated()})}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(h(()=>{this.removeHandles("scheduleUpdated"),this._updated()}),"scheduleUpdated")}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const t=e.features;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);for(let n=0;n<a;++n){const e=t[n],a=R(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=R(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+K,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}get _featureTilesArray(){return Array.from(this._featureTiles.values())}get featureTiles(){return this._featureTiles}get storedFeatures(){return this._featureTilesArray.reduce((e,t)=>e+(t.features?t.features.length:0),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce((e,t)=>e+(t.needsFetch||t.isFetching?1:0),0)}_totalFeaturesForTile(e){return e.hasPreciseFeatureCount?e.numFeatures:this.maximumNumberOfFeatures}_maximumFeaturesForTile(e){const t=this._totalFeaturesForTile(e),s=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(t*s/(1-e.emptyFeatureRatio)),t)}get test(){}};function Q(e){return e.id===I}function S(e){return e.id===A}function N(e){return Q(e)||S(e)}function L(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function k(e){e.setFeatures([],0,null,void 0)}function H(e){return null==e?new Set:new Set(e.map(e=>e.name))}function Z(e,t){if(null==e||null==t)return H(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function V(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:i,attribute:a}of t)r(e,i,s).add(a);return e}e([p({constructOnly:!0})],q.prototype,"features",void 0),e([p({constructOnly:!0})],q.prototype,"context",void 0),e([p()],q.prototype,"tileDescriptors",void 0),e([p({value:1/0})],q.prototype,"maximumNumberOfFeatures",null),e([p({value:1})],q.prototype,"memoryFactor",null),e([p({value:1})],q.prototype,"lodFactor",null),e([p()],q.prototype,"useTileCount",null),e([p({readOnly:!0})],q.prototype,"updating",null),e([p({readOnly:!0})],q.prototype,"dataUpdating",void 0),e([p({readOnly:!0})],q.prototype,"updatingTotal",void 0),e([p({readOnly:!0})],q.prototype,"updatingRemaining",void 0),e([p({readOnly:!0})],q.prototype,"expectedFeatureDiff",void 0),e([p({readOnly:!0})],q.prototype,"memoryForUnusedFeatures",null),e([p({readOnly:!0})],q.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([p({readOnly:!0})],q.prototype,"totalVertices",null),e([p({readOnly:!0})],q.prototype,"totalFeatures",null),e([p({readOnly:!0})],q.prototype,"showsAllFeatures",null),e([p({readOnly:!0})],q.prototype,"hasFullGeometries",null),e([p()],q.prototype,"filterExtent",null),e([p()],q.prototype,"_dirty",void 0),e([p()],q.prototype,"_suspended",void 0),e([p()],q.prototype,"_pendingEdits",void 0),e([p()],q.prototype,"_applyEditsTilesUpdated",void 0),e([p()],q.prototype,"_paused",null),e([p()],q.prototype,"snappingComplexityExceeded",void 0),e([p()],q.prototype,"_isFetching",void 0),q=e([f("esri.views.3d.layers.support.FeatureTileFetcher3D")],q);const $=2e3,B=m(),G=m(),X=m(),J=6e5,K=200,W=.95,Y=10;export{q as FeatureTileFetcher3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as o}from"tslib";import r from"../../../../core/Accessor.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";
|
|
5
|
+
import{__decorate as o}from"tslib";import r from"../../../../core/Accessor.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{MediaLayerInteractionReshapeOptions as e}from"./MediaLayerInteractionReshapeOptions.js";let p=class extends r{constructor(o){super(o),this.tool="transform",this.reshapeOptions=new e}};o([s()],p.prototype,"tool",void 0),o([s({type:e})],p.prototype,"reshapeOptions",void 0),p=o([t("esri.views.3d.layers.support.MediaLayerInteractionOptions")],p);export{p as MediaLayerInteractionOptions};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as o}from"tslib";import r from"../../../../core/Accessor.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";let t=class extends r{constructor(o){super(o),this.editSourcePoints=!1}};o([s()],t.prototype,"editSourcePoints",void 0),t=o([e("esri.views.3d.layers.support.MediaLayerInteractionReshapeOptions")],t);export{t as MediaLayerInteractionReshapeOptions};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
class t{constructor(t,s){this._maxTotalSamples=t,this._maxDistance=s,this.count=0,this.numSamples=0}get done(){return 0===this.numRemainingSamples}get numRemainingSamples(){return Math.max(0,this._maxTotalSamples-this.numSamples)}get ratio(){return this.numSamples?this.count/this.numSamples:0}sampleGeometry(t,s,e){switch(t?.type){case"point":if("point"!==s?.type)return;this._withinDistance(t.x-s.x,t.y-s.y)&&this.count++,this.numSamples++;break;case"polyline":case"polygon":{const s="polyline"===t.type?t.paths:t.rings;for(let t=0;t<s.length;t++){const a=s[t],n=e/(s.length-t),i=Math.max(1,Math.ceil(a.length/n));for(let t=Math.floor(i/2);t<a.length-1;t+=i){const s=a[t],n=a[t+1],i=n[0]-s[0],h=n[1]-s[1];if(this._withinDistance(i,h)&&this.count++,this.numSamples++,--e<=0||this.numSamples>=this._maxTotalSamples)return}}}}}_withinDistance(t,s){return Math.abs(t)<=this._maxDistance||Math.abs(s)<=this._maxDistance}}export{t as SampledGeometryMaxDistanceRatio};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import r from"../../../../core/Accessor.js";import{neverReached as
|
|
5
|
+
import{__decorate as e}from"tslib";import{queueAutoPriority as r}from"../../../../requestQueue.js";import t from"../../../../core/Accessor.js";import{neverReached as s}from"../../../../core/compilerUtils.js";import o from"../../../../core/Error.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as a,createAbortError as u}from"../../../../core/promiseUtils.js";import{difference as c}from"../../../../core/SetUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromFeatureSetJSON as p}from"../../../../layers/graphics/dehydratedFeatures.js";import{runQuery as y,executeQuery as d,executeQueryForCount as m}from"../../../../rest/query/operations/query.js";import{PBFDecoder as f}from"../../support/PBFDecoder.js";let h=class extends t{constructor(e){super(e)}get implicitFields(){const e=this.layer.outFields?.includes("*");if(!e)return new Set;const r=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return c(t,r)}async queryFeaturesDehydrated(e,r){const{layer:t}=this,s=t.capabilities,o=s?.query?.supportsFormatPBF,i=t.parsedUrl;if(o){null==this._decoder&&(this._decoder=new f(this.controller));const s={sourceSpatialReference:t.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:g};return y(i,e,"pbf",this._createRequestOptions(r)).then(e=>(a(r),null!=this._decoder?this._decoder.invoke({buffer:e,options:s},r.signal):Promise.reject(u())))}return d(i,e,t.spatialReference,this._createRequestOptions(r)).then(e=>p(e,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:g}))}queryFeatureCount(e,r){return m(this.layer.parsedUrl,e,this._createRequestOptions(r))}destroy(){this._decoder=i(this._decoder)}_createRequestOptions(e){return{...r,...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([l({constructOnly:!0})],h.prototype,"layer",void 0),e([l({constructOnly:!0})],h.prototype,"layerView",void 0),e([l({constructOnly:!0})],h.prototype,"controller",void 0),e([l({readOnly:!0})],h.prototype,"implicitFields",null),h=e([n("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D")],h);let F=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.queryFeatures(e,r)}};e([l({constructOnly:!0})],F.prototype,"layer",void 0),F=e([n("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D")],F);let w=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.source.queryFeaturesJSON(e,r).then(p,t=>{if(t&&"query-features-json:unsupported"===t.name)return this.layer.queryFeatures(e,r);throw t})}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}};function q(e,r){const{layer:t}=e;switch(t.type){case"feature":switch(t.source.type){case"feature-layer":return new h({layer:t,layerView:e,controller:r});case"memory":return new w({layer:t});case"csv":case"geojson":case"oriented-imagery":case"wfs":case"ogc-feature":case"parquet":break;default:s(t.source.type)}break;case"catalog-footprint":return new h({layer:t,layerView:e,controller:r});case"csv":case"geojson":case"oriented-imagery":case"wfs":return new w({layer:t});case"ogc-feature":return new F({layer:t})}throw new o("feature-layer:unsupported",`Unsupported Feature layer type ${e.layer.type}:${e.layer.source.type}`)}e([l({constructOnly:!0})],w.prototype,"layer",void 0),w=e([n("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D")],w);const g=1024;export{q as createFeatureTileQuery3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Logger.js";import{isAborted as
|
|
5
|
+
import e from"../../../../request.js";import r from"../../../../core/Logger.js";import{isAborted as t,createAbortError as s}from"../../../../core/promiseUtils.js";import{isRefreshableLayer as i}from"../../../../layers/mixins/RefreshableLayer.js";import{useFetchTileForLayer as o}from"../../terrain/terrainUtils.js";async function a(a,m,l){const n=a.layer;if(o(n)){const e=await n.fetchTile(m[0],m[1],m[2],l);if(t(l))throw r.getLogger(a).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),s();return e}let f=a.getTileUrl(m);return i(n)&&n.refreshTimestamp&&(f+=`${f.includes("?")?"&":"?"}_ts=${n.refreshTimestamp}`),(await e(f,{...l,responseType:"image",imageWithType:a.hasMixedImageFormats})).data}export{a as fetchTile};
|