@arcgis/core 4.24.0-next.20220329 → 4.24.0-next.20220401
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/PopupTemplate.js +1 -1
- package/WebMap.js +1 -1
- package/WebScene.js +1 -1
- package/analysis/LineOfSightAnalysisObserver.js +1 -1
- package/analysis/LineOfSightAnalysisTarget.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/RecentlyUsedCache.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/lib/character.js +1 -1
- package/arcade/lib/scanner.js +1 -1
- package/arcade/lib/tokenizer.js +1 -1
- package/arcade/request.js +1 -1
- package/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0bfedb1dbdff8205e468.js +1 -0
- package/assets/esri/core/workers/chunks/{5e472c89a38d6a42b84d.js → 0e29250c24a3a7b1ce13.js} +1 -1
- package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +1 -0
- package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +1 -0
- package/assets/esri/core/workers/chunks/10a119889d1ab13402a3.js +1 -0
- package/assets/esri/core/workers/chunks/125b14c2ccd96d7c20c2.js +1 -0
- package/assets/esri/core/workers/chunks/23ec33a30db201e8b2c3.js +1 -0
- package/assets/esri/core/workers/chunks/2530e8ccf6e12787ce76.js +1 -0
- package/assets/esri/core/workers/chunks/2d9e97ba5b50aec4dd01.js +1 -0
- package/assets/esri/core/workers/chunks/365dc146398420f13f82.js +1 -0
- package/assets/esri/core/workers/chunks/3ae2827e8d55d6713d20.js +1 -0
- package/assets/esri/core/workers/chunks/3e3eebaa0844742db2f2.js +1 -0
- package/assets/esri/core/workers/chunks/3fd5b2d6eccd9098d492.js +1 -0
- package/assets/esri/core/workers/chunks/404f1d7bce014c7e6965.js +1 -0
- package/assets/esri/core/workers/chunks/411b7777bb5e943c156f.js +1 -0
- package/assets/esri/core/workers/chunks/{12ca192a5233bb2875d0.js → 4312902ab6e42fbe119b.js} +1 -1
- package/assets/esri/core/workers/chunks/{4ef07f50da39f8607c1c.js → 44e95e87bd9e820aeb53.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d4c5e535d8b9ceb865a.js → 4810edf605838d07e5c5.js} +1 -1
- package/assets/esri/core/workers/chunks/4bce446391176a9d4588.js +1 -0
- package/assets/esri/core/workers/chunks/52a0e387073ea264e194.js +1 -0
- package/assets/esri/core/workers/chunks/560234694f3e53802aff.js +1 -0
- package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +1 -0
- package/assets/esri/core/workers/chunks/5682039666f874836451.js +1 -0
- package/assets/esri/core/workers/chunks/6f01905936396fe87865.js +1 -0
- package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +1 -0
- package/assets/esri/core/workers/chunks/7388824eac8da01ea03d.js +1 -0
- package/assets/esri/core/workers/chunks/7745efef7d5119d0b087.js +1 -0
- package/assets/esri/core/workers/chunks/794b47764ebb0257ed41.js +1 -0
- package/assets/esri/core/workers/chunks/{da64dedf9270b64f42b2.js → 79bdb26244ec7b4472fe.js} +1 -1
- package/assets/esri/core/workers/chunks/79ec28b3e3c57fe026aa.js +1 -0
- package/assets/esri/core/workers/chunks/81e9d860a044acec74ce.js +1 -0
- package/assets/esri/core/workers/chunks/831dc0187f71e658550c.js +1 -0
- package/assets/esri/core/workers/chunks/86ad6b020c01850d9095.js +1 -0
- package/assets/esri/core/workers/chunks/{fb7397da8d4ec2ae4587.js → 87458fbf395338511662.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a859be598ad96bb4719.js → 8771296b537f366596c4.js} +18 -18
- package/assets/esri/core/workers/chunks/8958cd555f4887526e8b.js +1 -0
- package/assets/esri/core/workers/chunks/{e57b71ba70f088a3a052.js → 90dcd86cdef90099abfa.js} +1 -1
- package/assets/esri/core/workers/chunks/93067e27eea5844edc6c.js +1 -0
- package/assets/esri/core/workers/chunks/{9fbee2d9bf50c4c148c6.js → 9a146c9e9b4bf7fba88f.js} +1 -1
- package/assets/esri/core/workers/chunks/9b9821772b6cbe189fe0.js +1 -0
- package/assets/esri/core/workers/chunks/{6c4ce530b493c6f7c430.js → 9df2f9f7c28b31866be8.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0620ce99b620621d8bc.js → a0552044e123a3c51ddf.js} +1 -1
- package/assets/esri/core/workers/chunks/acc1a4acd57f5657e782.js +1 -0
- package/assets/esri/core/workers/chunks/b055ae7c54796751b64c.js +1 -0
- package/assets/esri/core/workers/chunks/{acc2cfb116fee7f82ae9.js → b26bd8fde2fc65bb67fb.js} +1 -1
- package/assets/esri/core/workers/chunks/{9b45b94c4dbdc8d2c5fd.js → b34ba22c7a5adce8a7a2.js} +1 -1
- package/assets/esri/core/workers/chunks/b75665d0bf417c6ef24a.js +1 -0
- package/assets/esri/core/workers/chunks/bd50ec30688463b821d1.js +1 -0
- package/assets/esri/core/workers/chunks/c28f7ae4756ad1ba94bd.js +1 -0
- package/assets/esri/core/workers/chunks/c4f713959d4115b87c6c.js +1 -0
- package/assets/esri/core/workers/chunks/c58aa209492bd94b7aad.js +1 -0
- package/assets/esri/core/workers/chunks/{9b117097b7be0efd21d4.js → c59b0b58e24e6a60cf3e.js} +1 -1
- package/assets/esri/core/workers/chunks/c7bd5a4d318299388645.js +1 -0
- package/assets/esri/core/workers/chunks/c7cee13a962396b23a5e.js +1 -0
- package/assets/esri/core/workers/chunks/{3bbff5ea1ea0e955c592.js → cd3679fa86129ebabfdf.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a36dc0daffd536ea44d.js → cee7ce362860717713bf.js} +1 -1
- package/assets/esri/core/workers/chunks/cf463d6309f14df2f2fa.js +1 -0
- package/assets/esri/core/workers/chunks/{224c0e64160bdc170051.js → d076627bb7dadea89e89.js} +1 -1
- package/assets/esri/core/workers/chunks/{fff4200bc61b82dd6193.js → d1d1c45243af614f2e74.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e0498dc9836658d9aba.js → d5fd12ea541c1a6b7fce.js} +1 -1
- package/assets/esri/core/workers/chunks/{10322d990cda5aedf2f0.js → d6e32ca237ad9309c76a.js} +1 -1
- package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +1 -0
- package/assets/esri/core/workers/chunks/{7a77d4cd27c30f1a5cae.js → ee3387a43dfbb3df23e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d5fa2b1fc48a17eb9ab.js → f4fc165420d449e442b8.js} +1 -1
- package/assets/esri/core/workers/chunks/{3d6d9906a534ddd8fa37.js → f5ee03f3fca7a75192de.js} +1 -1
- package/assets/esri/themes/base/widgets/_Daylight.scss +1 -1
- package/assets/esri/themes/base/widgets/_ElevationProfile.scss +1 -1
- package/assets/esri/themes/base/widgets/_Weather.scss +1 -1
- package/assets/esri/themes/base/widgets/_Widget.scss +12 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/dark-blue/main.css +1 -1
- package/assets/esri/themes/dark-green/main.css +1 -1
- package/assets/esri/themes/dark-purple/main.css +1 -1
- package/assets/esri/themes/dark-red/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/themes/light-blue/main.css +1 -1
- package/assets/esri/themes/light-green/main.css +1 -1
- package/assets/esri/themes/light-purple/main.css +1 -1
- package/assets/esri/themes/light-red/main.css +1 -1
- package/chunks/ComponentShader.glsl.js +25 -25
- package/chunks/HighlightApply.glsl.js +36 -0
- package/chunks/HighlightBlur.glsl.js +26 -0
- package/chunks/HighlightDownsample.glsl.js +12 -0
- package/chunks/ImageMaterial.glsl.js +8 -8
- package/chunks/LineCallout.glsl.js +1 -1
- package/chunks/Pattern.glsl.js +2 -2
- package/chunks/SimpleAtmosphere.glsl.js +7 -7
- package/chunks/Stars.glsl.js +1 -1
- package/chunks/arcade.js +1 -1
- package/chunks/color.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/chunks/mat3.js +1 -1
- package/copyright.txt +2 -2
- package/core/AsyncUpdate.js +1 -1
- package/core/Evented.js +1 -1
- package/core/PooledArray.js +1 -1
- package/core/accessorSupport/diffUtils.js +1 -1
- package/core/accessorSupport/get.js +1 -1
- package/core/accessorSupport/read.js +1 -1
- package/core/accessorSupport/set.js +1 -1
- package/core/accessorSupport/tracking.js +1 -1
- package/core/accessorSupport/utils.js +1 -1
- package/core/arrayUtils.js +1 -1
- package/core/libs/gl-matrix-2/mat3.js +1 -1
- package/core/libs/gl-matrix-2/math/mat3.js +1 -1
- package/core/number.js +1 -1
- package/core/object.js +1 -1
- package/core/string.js +1 -1
- package/core/unitUtils.js +1 -1
- package/core/watchUtils.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/exports/csv.js +1 -1
- package/geometry/support/heightModelInfoUtils.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
- package/geometry/support/normalizeUtils.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/interfaces.d.ts +155 -20
- package/layers/ImageryLayer.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/RouteLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/TileLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/WMSLayer.js +1 -1
- package/layers/WMTSLayer.js +1 -1
- package/layers/WebTileLayer.js +1 -1
- package/layers/graphics/data/AttributesBuilder.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/graphics/sources/support/inferenceUtils.js +1 -1
- package/layers/mixins/ArcGISCachedService.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/ogc/ogcFeatureUtils.js +1 -1
- package/layers/support/ExportImageServiceParameters.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/SpriteSource.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/TilemapCache.js +1 -1
- package/layers/support/WMTSSublayer.js +1 -1
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/kmlUtils.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/RasterFactory.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterDatasets/multipartParser.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/layers/support/rasterDatasets/xmlUtilities.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/layers/support/wmsUtils.js +1 -1
- package/layers/support/wmtsUtils.js +1 -1
- package/libs/i3s/I3SModule.js +1 -1
- package/libs/vxl/VxlModule.js +1 -1
- package/package.json +1 -1
- package/portal/Portal.js +1 -1
- package/portal/PortalItem.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/portalItemUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
- package/renderers/support/DictionaryLoader.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/numberUtils.js +1 -1
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/renderers/support/utils.js +1 -1
- package/request.js +1 -1
- package/rest/imageService.js +1 -1
- package/rest/operations/find.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/query/operations/queryRelatedRecords.js +1 -1
- package/rest/query/operations/queryTopFeatures.js +1 -1
- package/rest/support/DirectionLine.js +1 -1
- package/rest/support/DirectionPoint.js +1 -1
- package/rest/support/PointBarrier.js +1 -1
- package/rest/support/PolygonBarrier.js +1 -1
- package/rest/support/PolylineBarrier.js +1 -1
- package/rest/support/RouteInfo.js +1 -1
- package/rest/support/Stop.js +1 -1
- package/smartMapping/labels/clusters.js +1 -1
- package/smartMapping/popup/dotDensity.js +1 -1
- package/smartMapping/popup/support/clusterUtils.js +1 -1
- package/smartMapping/popup/support/utils.js +1 -1
- package/smartMapping/raster/support/utils.js +1 -1
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/location.js +1 -1
- package/smartMapping/renderers/predominance.js +1 -1
- package/smartMapping/renderers/relationship.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/utils.js +1 -1
- package/smartMapping/renderers/type.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/smartMapping/statistics/summaryStatisticsForAge.js +1 -1
- package/smartMapping/statistics/support/ageUtils.js +1 -1
- package/smartMapping/statistics/support/utils.js +1 -1
- package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/smartMapping/support/utils.js +1 -1
- package/smartMapping/symbology/support/Theme.js +1 -1
- package/smartMapping/symbology/support/colorRamps.js +1 -1
- package/smartMapping/symbology/support/symbologyUtils.js +1 -1
- package/smartMapping/symbology/support/utils.js +1 -1
- package/statistics/utils.js +1 -1
- package/support/basemapDefinitions.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/popupUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolRasterizer.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/utils.js +1 -1
- package/symbols/support/previewSymbol3D.js +1 -1
- package/symbols/support/renderUtils.js +1 -1
- package/symbols/support/symbolLayerUtils.js +1 -1
- package/views/2d/engine/Bitmap.js +1 -1
- package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
- package/views/2d/engine/imagery/RasterBitmap.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/vectorTiles/TextShaping.js +1 -1
- package/views/2d/engine/vectorTiles/TileParser.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
- package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
- package/views/2d/engine/webgl/Profiler.js +1 -1
- package/views/2d/engine/webgl/Utils.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
- package/views/2d/engine/webgl/definitions.js +1 -1
- package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
- package/views/2d/engine/webgl/effects/HittestEffectVTL.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLTemplateStore.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/util/Lock.js +1 -1
- package/views/2d/layers/RouteLayerView2D.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/2d/layers/features/sources/SnapshotFeatureSource.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
- package/views/2d/layers/support/webStyleUtils.js +1 -1
- package/views/2d/support/Timeline.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/Slice/SliceController.js +1 -1
- package/views/3d/environment/PanoramicAtmosphere.js +1 -1
- package/views/3d/environment/SceneViewAtmosphere.js +1 -1
- package/views/3d/environment/StarsTechnique.js +1 -1
- package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
- package/views/3d/glTF/loader.js +1 -1
- package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryLayerView3D.js +1 -1
- package/views/3d/layers/LayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/RouteLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/i3s/IDBMockCache.js +5 -0
- package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
- package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/support/HighlightOptions.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/support/debugFlags.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +5 -5
- package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HighlightApplyTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/HighlightBlur.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HighlightBlurTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HighlightDownsampleTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/HighlightOptions.js +4 -0
- package/views/3d/webgl-engine/shaders/HighlightPassParameters.js +5 -0
- package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/AdjustProjectedPosition.glsl.js +5 -7
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +14 -14
- package/views/SceneView.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/input/InputHandler.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/views/layers/MapImageLayerView.js +1 -1
- package/views/layers/TileLayerView.js +1 -1
- package/views/layers/support/popupUtils.js +1 -1
- package/views/support/DefaultsFromMap.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/screenshotUtils.js +1 -1
- package/views/ui/DefaultUI.js +1 -1
- package/views/webgl/ShaderTranspiler.js +1 -1
- package/webscene/Slide.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
- package/widgets/Attachments/support/attachmentUtils.js +1 -1
- package/widgets/Attachments.js +1 -1
- package/widgets/Attribution.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/BuildingExplorer/support/filterUtils.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion/support/coordinateConversionUtils.js +1 -1
- package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
- package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/styles/Card.js +1 -1
- package/widgets/Legend/styles/Classic.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend/support/colorRampUtils.js +1 -1
- package/widgets/Legend/support/relationshipRampUtils.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup/actionUtils.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/Swipe.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/support/DatePicker.js +1 -1
- package/widgets/support/Popover.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/TimePicker.js +1 -1
- package/widgets/support/timeWidgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/083a5d10f8e243641cb9.js +0 -1
- package/assets/esri/core/workers/chunks/0872812ce4d0ec8faf8f.js +0 -1
- package/assets/esri/core/workers/chunks/0bc26899780c33637746.js +0 -1
- package/assets/esri/core/workers/chunks/113362697da1b69deaed.js +0 -1
- package/assets/esri/core/workers/chunks/11a2f9708938eac98815.js +0 -1
- package/assets/esri/core/workers/chunks/11a45709b703be84caaf.js +0 -1
- package/assets/esri/core/workers/chunks/1c1294ff1ebbd8f774f7.js +0 -1
- package/assets/esri/core/workers/chunks/1c915cc9a9d5729b6f17.js +0 -1
- package/assets/esri/core/workers/chunks/31786756b3d44540f8c0.js +0 -1
- package/assets/esri/core/workers/chunks/36a6f34fe40785beff5d.js +0 -1
- package/assets/esri/core/workers/chunks/373c16f8b8093d001064.js +0 -1
- package/assets/esri/core/workers/chunks/382a331a592abb61267f.js +0 -1
- package/assets/esri/core/workers/chunks/3bf106fe34e3992032c4.js +0 -1
- package/assets/esri/core/workers/chunks/3dcec610f1c1497d87bc.js +0 -1
- package/assets/esri/core/workers/chunks/46495e726d8739260d44.js +0 -1
- package/assets/esri/core/workers/chunks/4a82a6a473b3d540d0be.js +0 -1
- package/assets/esri/core/workers/chunks/4b6719377a95ac10fa43.js +0 -1
- package/assets/esri/core/workers/chunks/4d2ef57ff3a5cfc1313f.js +0 -1
- package/assets/esri/core/workers/chunks/4fd2b8153d62592210a2.js +0 -1
- package/assets/esri/core/workers/chunks/56e6a1079269e2964b02.js +0 -1
- package/assets/esri/core/workers/chunks/5b4d9786c010d265346c.js +0 -1
- package/assets/esri/core/workers/chunks/604637e1c3937b376a0d.js +0 -1
- package/assets/esri/core/workers/chunks/60f83257e361f87fa6fd.js +0 -1
- package/assets/esri/core/workers/chunks/6d3f80be6fceb2c18b5d.js +0 -1
- package/assets/esri/core/workers/chunks/6f827a32646bab0a8777.js +0 -1
- package/assets/esri/core/workers/chunks/70bd2ab42e3801ef5974.js +0 -1
- package/assets/esri/core/workers/chunks/746222184b361b50d6ba.js +0 -1
- package/assets/esri/core/workers/chunks/7fb72b2d11e8d840f982.js +0 -1
- package/assets/esri/core/workers/chunks/85bb6a1a7704fcdcbec2.js +0 -1
- package/assets/esri/core/workers/chunks/8b4c76cebb100e6c06f8.js +0 -1
- package/assets/esri/core/workers/chunks/9586a6b320edb1922926.js +0 -1
- package/assets/esri/core/workers/chunks/99638697ffda9022ce92.js +0 -1
- package/assets/esri/core/workers/chunks/a9da1cb118ca62a9581d.js +0 -1
- package/assets/esri/core/workers/chunks/aaa41a5013eef713c032.js +0 -1
- package/assets/esri/core/workers/chunks/ac321f939dd488ff6ce4.js +0 -1
- package/assets/esri/core/workers/chunks/add6027a96398ecf69de.js +0 -1
- package/assets/esri/core/workers/chunks/b75206b46ba81606087c.js +0 -1
- package/assets/esri/core/workers/chunks/bf8456828e38a768eba3.js +0 -1
- package/assets/esri/core/workers/chunks/c0720d0d8adcba6738d4.js +0 -1
- package/assets/esri/core/workers/chunks/c5bb712d5cf8c05a4e13.js +0 -1
- package/assets/esri/core/workers/chunks/d343f05a3366f95e0494.js +0 -1
- package/assets/esri/core/workers/chunks/d8b1f00075983d769985.js +0 -1
- package/chunks/Highlight.glsl.js +0 -88
- package/views/3d/webgl-engine/shaders/Highlight.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/HighlightTechnique.js +0 -5
- package/views/3d/webgl-engine/shaders/HighlightTechniqueConfiguration.js +0 -5
package/PopupTemplate.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"./chunks/tslib.es6.js";import e from"./core/Collection.js";import{JSONSupport as o}from"./core/JSONSupport.js";import{clone as s}from"./core/lang.js";import i from"./core/Logger.js";import{isPromiseLike as r}from"./core/promiseUtils.js";import{property as n}from"./core/accessorSupport/decorators/property.js";import{cast as p}from"./core/accessorSupport/decorators/cast.js";import{reader as l}from"./core/accessorSupport/decorators/reader.js";import{subclass as a}from"./core/accessorSupport/decorators/subclass.js";import{writer as d}from"./core/accessorSupport/decorators/writer.js";import{ensureOneOfType as c}from"./core/accessorSupport/ensureType.js";import{collectFields as f,collectArcadeFieldNames as m}from"./layers/support/fieldUtils.js";import{persistableTypes as u}from"./popup/content.js";import y from"./popup/ExpressionInfo.js";import h from"./popup/FieldInfo.js";import I from"./popup/LayerOptions.js";import x from"./popup/RelatedRecordsInfo.js";import{types as F}from"./popup/content/support/mediaInfoTypes.js";import A from"./support/actions/ActionBase.js";import _ from"./support/actions/ActionButton.js";import g from"./support/actions/ActionToggle.js";import w from"./popup/content/MediaContent.js";import j from"./popup/content/TextContent.js";import N from"./popup/content/AttachmentsContent.js";import C from"./popup/content/FieldsContent.js";import v from"./popup/content/ExpressionContent.js";import E from"./popup/content/Content.js";import O from"./popup/content/CustomContent.js";var S;const T=e.ofType({key:"type",defaultKeyValue:"button",base:A,typeMap:{button:_,toggle:g}}),b={base:E,key:"type",typeMap:{media:w,custom:O,text:j,attachments:N,fields:C,expression:v}},R="esri.PopupTemplate",L=i.getLogger(R),J=["attachments","fields","media","text","expression"];let M=S=class extends o{constructor(){super(...arguments),this.actions=null,this.content="",this.expressionInfos=null,this.fieldInfos=null,this.layerOptions=null,this.lastEditInfoEnabled=!0,this.outFields=null,this.overwriteActions=!1,this.returnGeometry=!1,this.title="",this.relatedRecordsInfo=null}castContent(t){return Array.isArray(t)?t.map((t=>c(b,t))):"string"==typeof t||"function"==typeof t||t instanceof HTMLElement||r(t)?t:(L.error("content error","unsupported content value",{value:t}),null)}readContent(t,e){const{popupElements:o}=e;return Array.isArray(o)&&o.length>0?this._readPopupInfoElements(e):this._readPopupInfo(e)}writeContent(t,e,o,s){"string"!=typeof t?Array.isArray(t)&&(e.popupElements=t.filter((t
|
|
5
|
+
import{_ as t}from"./chunks/tslib.es6.js";import e from"./core/Collection.js";import{JSONSupport as o}from"./core/JSONSupport.js";import{clone as s}from"./core/lang.js";import i from"./core/Logger.js";import{isPromiseLike as r}from"./core/promiseUtils.js";import{property as n}from"./core/accessorSupport/decorators/property.js";import{cast as p}from"./core/accessorSupport/decorators/cast.js";import{reader as l}from"./core/accessorSupport/decorators/reader.js";import{subclass as a}from"./core/accessorSupport/decorators/subclass.js";import{writer as d}from"./core/accessorSupport/decorators/writer.js";import{ensureOneOfType as c}from"./core/accessorSupport/ensureType.js";import{collectFields as f,collectArcadeFieldNames as m}from"./layers/support/fieldUtils.js";import{persistableTypes as u}from"./popup/content.js";import y from"./popup/ExpressionInfo.js";import h from"./popup/FieldInfo.js";import I from"./popup/LayerOptions.js";import x from"./popup/RelatedRecordsInfo.js";import{types as F}from"./popup/content/support/mediaInfoTypes.js";import A from"./support/actions/ActionBase.js";import _ from"./support/actions/ActionButton.js";import g from"./support/actions/ActionToggle.js";import w from"./popup/content/MediaContent.js";import j from"./popup/content/TextContent.js";import N from"./popup/content/AttachmentsContent.js";import C from"./popup/content/FieldsContent.js";import v from"./popup/content/ExpressionContent.js";import E from"./popup/content/Content.js";import O from"./popup/content/CustomContent.js";var S;const T=e.ofType({key:"type",defaultKeyValue:"button",base:A,typeMap:{button:_,toggle:g}}),b={base:E,key:"type",typeMap:{media:w,custom:O,text:j,attachments:N,fields:C,expression:v}},R="esri.PopupTemplate",L=i.getLogger(R),J=["attachments","fields","media","text","expression"];let M=S=class extends o{constructor(){super(...arguments),this.actions=null,this.content="",this.expressionInfos=null,this.fieldInfos=null,this.layerOptions=null,this.lastEditInfoEnabled=!0,this.outFields=null,this.overwriteActions=!1,this.returnGeometry=!1,this.title="",this.relatedRecordsInfo=null}castContent(t){return Array.isArray(t)?t.map((t=>c(b,t))):"string"==typeof t||"function"==typeof t||t instanceof HTMLElement||r(t)?t:(L.error("content error","unsupported content value",{value:t}),null)}readContent(t,e){const{popupElements:o}=e;return Array.isArray(o)&&o.length>0?this._readPopupInfoElements(e):this._readPopupInfo(e)}writeContent(t,e,o,s){"string"!=typeof t?Array.isArray(t)&&(e.popupElements=t.filter((t=>J.includes(t.type))).map((t=>t&&t.toJSON(s))),e.popupElements.forEach((t=>{"attachments"===t.type?this._writeAttachmentContent(e):"media"===t.type?this._writeMediaContent(t,e):"text"===t.type&&this._writeTextContent(t,e)}))):e.description=t}writeFieldInfos(t,e,o,s){const{content:i}=this,r=Array.isArray(i)?i:null;if(t){const o=r?r.filter((t=>"fields"===t.type)):[],i=o.length&&o.every((t=>{var e;return null==(e=t.fieldInfos)?void 0:e.length}));e.fieldInfos=t.filter(Boolean).map((t=>{const e=t.toJSON(s);return i&&(e.visible=!1),e}))}if(r)for(const n of r)"fields"===n.type&&this._writeFieldsContent(n,e)}writeLayerOptions(t,e,o,s){e[o]=!t||null===t.showNoDataRecords&&null===t.returnTopmostRaster?null:t.toJSON(s)}writeTitle(t,e){e.title=t||""}clone(){const{actions:t}=this,e=t?s(t.toArray()):[];return new S({actions:e,content:Array.isArray(this.content)?s(this.content):this.content,expressionInfos:Array.isArray(this.expressionInfos)?s(this.expressionInfos):null,fieldInfos:Array.isArray(this.fieldInfos)?s(this.fieldInfos):null,layerOptions:this.layerOptions?s(this.layerOptions):null,lastEditInfoEnabled:this.lastEditInfoEnabled,outFields:Array.isArray(this.outFields)?s(this.outFields):null,overwriteActions:this.overwriteActions,returnGeometry:this.returnGeometry,title:this.title,relatedRecordsInfo:this.relatedRecordsInfo?s(this.relatedRecordsInfo):null})}async collectRequiredFields(t,e){const o=this.expressionInfos||[];await this._collectExpressionInfoFields(t,e,[...o,...this._getContentExpressionInfos(this.content,o)]),f(t,e,[...this.outFields||[],...this._getActionsFields(this.actions),...this._getTitleFields(this.title),...this._getContentFields(this.content)])}async getRequiredFields(t){const e=new Set;return await this.collectRequiredFields(e,t),[...e].sort()}_writeFieldsContent(t,e){if(!Array.isArray(t.fieldInfos)||!t.fieldInfos.length)return;const o=s(t.fieldInfos);Array.isArray(e.fieldInfos)?o.forEach((t=>{const o=e.fieldInfos.find((e=>e.fieldName.toLowerCase()===t.fieldName.toLowerCase()));o?o.visible=!0:e.fieldInfos.push(t)})):e.fieldInfos=o}_writeAttachmentContent(t){t.showAttachments||(t.showAttachments=!0)}_writeTextContent(t,e){!e.description&&t.text&&(e.description=t.text)}_writeMediaContent(t,e){if(!Array.isArray(t.mediaInfos)||!t.mediaInfos.length)return;const o=s(t.mediaInfos);Array.isArray(e.mediaInfos)?e.mediaInfos=[...e.mediaInfos,...o]:e.mediaInfos=o}_readPopupInfoElements({description:t,mediaInfos:e,popupElements:o}){const s={description:!1,mediaInfos:!1};return o.map((o=>"media"===o.type?(o.mediaInfos||!e||s.mediaInfos||(o.mediaInfos=e,s.mediaInfos=!0),w.fromJSON(o)):"text"===o.type?(o.text||!t||s.description||(o.text=t,s.description=!0),j.fromJSON(o)):"attachments"===o.type?N.fromJSON(o):"fields"===o.type?C.fromJSON(o):"expression"===o.type?v.fromJSON(o):void 0)).filter(Boolean)}_readPopupInfo({description:t,mediaInfos:e,showAttachments:o}){const s=[];return t?s.push(new j({text:t})):s.push(new C),Array.isArray(e)&&e.length&&s.push(w.fromJSON({mediaInfos:e})),o&&s.push(N.fromJSON({displayType:"auto"})),s.length?s:t}_getContentElementFields(t){const e=null==t?void 0:t.type;if("attachments"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)];if("custom"===e)return t.outFields||[];if("fields"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...this._getFieldInfoFields(t.fieldInfos||this.fieldInfos)];if("media"===e){const e=t.mediaInfos||[];return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...e.reduce(((t,e)=>[...t,...this._getMediaInfoFields(e)]),[])]}return"text"===e?this._extractFieldNames(t.text):[]}_getMediaInfoFields(t){const{caption:e,title:o,value:s}=t,i=s||{},{fields:r=[],normalizeField:n,tooltipField:p,sourceURL:l,linkURL:a}=i,d=[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(l),...this._extractFieldNames(a),...r];return n&&d.push(n),p&&d.push(p),d}_getContentExpressionInfos(t,e){return Array.isArray(t)?t.reduce(((t,e)=>[...t,..."expression"===e.type&&e.expressionInfo?[e.expressionInfo]:[]]),e):[]}_getContentFields(t){return"string"==typeof t?this._extractFieldNames(t):Array.isArray(t)?t.reduce(((t,e)=>[...t,...this._getContentElementFields(e)]),[]):[]}async _collectExpressionInfoFields(t,e,o){o&&await Promise.all(o.map((o=>m(t,e,o.expression))))}_getFieldInfoFields(t){return t?t.filter((t=>void 0===t.visible||!!t.visible)).map((t=>t.fieldName)).filter((t=>!t.includes("relationships/")&&!t.includes("expression/"))):[]}_getActionsFields(t){return t?t.toArray().reduce(((t,e)=>[...t,...this._getActionFields(e)]),[]):[]}_getActionFields(t){const{className:e,title:o,type:s}=t,i="button"===s||"toggle"===s?t.image:"";return[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(i)]}_getTitleFields(t){return"string"==typeof t?this._extractFieldNames(t):[]}_extractFieldNames(t){if(!t||"string"!=typeof t)return[];const e=/{[^}]*}/g,o=t.match(e);if(!o)return[];const s=/\{(\w+):.+\}/,i=o.filter((t=>!(0===t.indexOf("{relationships/")||0===t.indexOf("{expression/")))).map((t=>t.replace(s,"{$1}")));return i?i.map((t=>t.slice(1,-1))):[]}};t([n({type:T})],M.prototype,"actions",void 0),t([n()],M.prototype,"content",void 0),t([p("content")],M.prototype,"castContent",null),t([l("content",["description","fieldInfos","popupElements","mediaInfos","showAttachments"])],M.prototype,"readContent",null),t([d("content",{popupElements:{type:e.ofType(u)},showAttachments:{type:Boolean},mediaInfos:{type:e.ofType(F)},description:{type:String}})],M.prototype,"writeContent",null),t([n({type:[y],json:{write:!0}})],M.prototype,"expressionInfos",void 0),t([n({type:[h]})],M.prototype,"fieldInfos",void 0),t([d("fieldInfos")],M.prototype,"writeFieldInfos",null),t([n({type:I})],M.prototype,"layerOptions",void 0),t([d("layerOptions")],M.prototype,"writeLayerOptions",null),t([n({type:Boolean,json:{read:{source:"showLastEditInfo"},write:{target:"showLastEditInfo"},default:!0}})],M.prototype,"lastEditInfoEnabled",void 0),t([n()],M.prototype,"outFields",void 0),t([n()],M.prototype,"overwriteActions",void 0),t([n()],M.prototype,"returnGeometry",void 0),t([n({json:{type:String}})],M.prototype,"title",void 0),t([d("title")],M.prototype,"writeTitle",null),t([n({type:x,json:{write:!0}})],M.prototype,"relatedRecordsInfo",void 0),M=S=t([a(R)],M);const B=M;export{B as default};
|
package/WebMap.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{flatten as o}from"./core/arrayUtils.js";import a from"./core/Collection.js";import s from"./core/Error.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{unwrap as m,isSome as u}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as c}from"./core/Promise.js";import{eachAlways as y}from"./core/promiseUtils.js";import{whenOnce as w}from"./core/reactiveUtils.js";import{urlToObject as f,isDataProtocol as g,dataComponents as b,addQueryParameter as _}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as S}from"./core/accessorSupport/decorators/reader.js";import{subclass as I}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as j}from"./core/accessorSupport/originUtils.js";import{readLoadable as O}from"./core/accessorSupport/read.js";import L from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as V,webMercatorToGeographic as U}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as F}from"./layers/support/arcgisLayerUrl.js";import T from"./networks/UtilityNetwork.js";import W from"./portal/Portal.js";import R from"./portal/PortalItem.js";import{removeTypeKeyword as x,addTypeKeyword as N,hasTypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as k}from"./rest/geometryService/project.js";import C from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as E,isDeveloperBasemapLayer as B,findSpatialReference as G}from"./support/basemapUtils.js";import J from"./support/MapFloorInfo.js";import D from"./webdoc/RangeInfo.js";import K from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as z}from"./webdoc/support/writeUtils.js";import q from"./webmap/ApplicationProperties.js";import H from"./webmap/Bookmark.js";import Q from"./webmap/InitialViewProperties.js";import{Version as X}from"./webmap/Version.js";import Y from"./webmap/background/ColorBackground.js";const Z=new X(2,24),ee="Web Map",te=a.ofType(H),re=a.ofType(T),ie=p.getLogger("esri.WebMap"),oe=new Map;oe.set("image/jpeg","jpeg"),oe.set("image/jpg","jpg"),oe.set("image/png","png"),oe.set("image/gif","gif");const ae="ArcGIS Pro",se="ArcGIS API for JavaScript",ne="CollectorDisabled",le="Collector",pe="Data Editing",me="OfflineDisabled",ue="Offline",he="Workforce Project",de="Workforce Worker",ce="Workforce Dispatcher",ye="Offline Map Areas",we="FieldMapsDisabled",fe="DeveloperBasemap",ge=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));let be=class extends(h(n.LoadableMixin(c(r)))){constructor(e){super(e),this.applicationProperties=null,this.bookmarks=new te,this.floorInfo=null,this.initialViewProperties=new Q,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}initialize(){if(this.when().catch((e=>{ie.error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=se}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){var r;const o=new Q;t.background&&(o.background=Y.fromJSON(t.background));const a=null==(r=t.initialState)?void 0:r.viewpoint;if(a){if(a.rotation){X.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ae&&(a.rotation*=-1)}o.viewpoint=i.fromJSON(a)}return t.mapRangeInfo&&(o.rangeInfo=D.fromJSON(t.mapRangeInfo)),t.spatialReference&&(o.spatialReference=L.fromJSON(t.spatialReference)),o}writeInitialViewProperties(e,t,r,i){if(!e)return;const o=e.background;o&&o.color&&(t.background=o.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i))}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new X(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${Z.major}.${Z.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:"web-map"};const r=this._getAuthoringPropsState();O(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webmap:not-loaded","Web map must be loaded before it can be serialized");throw ie.error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:"web-map",restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){e=e||{},this._validateItem(),await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const t=this.portalItem,r={origin:"web-map",messages:[],writtenProperties:[],url:t.itemUrl&&f(t.itemUrl),portal:t.portal||W.getDefault()},i=this.write({},r);return this._validateJSONForWriting(r,e),await this._updateItemProperties(t),await this._updateItem(t,i,r),await this._updateItemThumbnail(),t}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e);await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const i={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal},o=this.write({},i);this._validateJSONForWriting(i,t),await this._updateItemPropertiesForSaveAs(r);const a=this._getThumbnailState();return await this._createItem(r,o,i,t),this._restoreThumbnailFromState(a),await this._updateItemThumbnail(),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){var t,r,i,a;const s=this.resourceInfo;return this._collectAllLayersJSON(o([null==s||null==(t=s.baseMap)?void 0:t.baseMapLayers,null==s?void 0:s.operationalLayers,null==(r=this.basemap)||null==(i=r.resourceInfo)||null==(a=i.data)?void 0:a.baseMapLayers])).find((t=>t.id===e.id))}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>m(z(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t)))).filter(Boolean).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve(null)}_loadFromItem(e){return e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})).then((()=>{if("Web Map"!==e.type)throw new s("webmap:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Map'",{type:e.type})})).then((()=>e.fetchData())).then((t=>(this.resourceInfo=t,this._readAndLoadFromJSON(t,{origin:"web-map",portal:e.portal||W.getDefault()})))).then((()=>this._computeInitialViewpoint()))}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=X.parse(e.version||"","webmap");return Z.validate(t),e.version=`${t.major}.${t.minor}`,e}_loadFromJSON(e,t){const r={context:{...t,layerContainerType:"operational-layers"}};return this.portalItem&&(r.context.portal=this.portalItem.portal||W.getDefault()),import("./layers/support/layersCreator.js").then((({populateOperationalLayers:t})=>{const i=[],o=e.operationalLayers;o&&o.length&&i.push(t(this.layers,o,r));const a={...r,context:{...r.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=e.tables;return s&&s.length&&i.push(t(this.tables,s,a)),y(i).then((()=>{}))}))}async _computeInitialViewpoint(){var e,t;let r=this.initialViewProperties;if(null==(e=r)||null==(t=e.viewpoint)?void 0:t.targetGeometry)return;const o=await this._getExtentFromItem();o&&(r=r?r.clone():new Q,r.viewpoint=new i,r.viewpoint.targetGeometry=o,this.initialViewProperties=r)}async _getExtentFromItem(){var e,t;const r=null==(e=this.initialViewProperties)?void 0:e.spatialReference,i=null==(t=this.portalItem)?void 0:t.extent;if(r&&i){if(r.isWGS84)return i.clone();if(r.isWebMercator)return V(i);return(await import("./portal/support/geometryServiceUtils.js")).getGeometryServiceURL(this.portalItem).then((e=>{const t=new C;return t.geometries=[i],t.outSpatialReference=r,k(e,t)})).then((e=>e[0])).catch((e=>(ie.error("Error projecting item's extent:",e),null)))}return null}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>!!this.allLayers.find((t=>t.id===e));t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>!!this.tables.find((t=>t.id===e.id)))));const i=e&&e.editing&&e.editing.locationTracking;i&&i.info&&!r(i.info.layerId)&&(e.editing=null);const o=this.presentation&&this.presentation.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _validateMap(){var e;if(null==(e=this.basemap)||!e.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let t=null;if(await w((()=>{const e=G(this.initialViewProperties,this.basemap);return t=e.spatialReference,!e.updating})),!P(t,this.initialViewProperties.spatialReference))throw new s("webmap:save","The spatial reference of the basemap is not compatible with the one from the map.",{expected:this.initialViewProperties.spatialReference,actual:t})}_validateItem(){if(!this.portalItem)throw ie.error("save: requires the portalItem property to be set"),new s("webmap:portal-item-not-set","Portal item to save to has not been set on the WebMap");this._validateItemType(this.portalItem)}_validateItemType(e){if(e.type!==ee)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ee}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),y(e).then((()=>{}))}async _beforeSave(){const e=[];for(const t of this.allLayers)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await y(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return y(e).then((()=>{}))}_getAllLayersAndTables(){return this.allLayers.concat(this.allTables)}_validateJSONForWriting(e,t){let r=e.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));if(t.ignoreUnsupported&&(r=r.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),r.length>0)throw new s("webmap:save","Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:r})}async _updateItemProperties(e){e.extent=await this._getWGS84Extent(this.initialViewProperties.viewpoint.targetGeometry),await this._updateTypeKeywords(e)}async _updateItemPropertiesForSaveAs(e){x(e,ne),x(e,me),x(e,he),x(e,de),x(e,ce),x(e,ye),x(e,we),await this._updateItemProperties(e)}async _getWGS84Extent(e){const t=e.clone().normalize();let r;if(t.length>1)for(const i of t)r?i.width>r.width&&(r=i):r=i;else r=t[0];return this._projectToWGS84(r)}async _projectToWGS84(e){const t=e.spatialReference;if(t.isWGS84)return e.clone();if(t.isWebMercator)return U(e);const r=await import("./portal/support/geometryServiceUtils.js"),i=await r.getGeometryServiceURL(this.portalItem),o=new C;o.geometries=[e],o.outSpatialReference=L.WGS84;return(await k(i,o))[0]}async _updateTypeKeywords(e){N(e,se),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){M(e,ne)||M(e,he)||M(e,de)||M(e,ce)||!this._hasEditableFeatureLayer()?x(e,le):N(e,le)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?N(e,pe):x(e,pe)}_evalOfflineKeyword(e){!M(e,me)&&this._isOfflineCapableMap()?N(e,ue):x(e,ue)}_evalDeveloperBasemapKeyword(e){E(this.basemap)?N(e,fe):x(e,fe)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled))}_isFeatureServiceLayer(e){return!("feature"!==e.type||!e.source||"feature-layer"!==e.source.type)}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isOfflineCapableLayer(e){return this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsSync||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||B(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(F(e.url)&&ge.some((t=>e.url.toLowerCase().indexOf("/"+t+"/")>-1)))}async _updateItem(e,t,r){await e.update({data:t}),this._syncUpInstanceWithItem(e,t,r)}async _createItem(e,t,r,i){const o=this.portalItem,a=!!(o&&o.id&&o.portal.user),n=e.portal;if(await n._signIn(),!await this._canCopyItem(o,a,n))throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");await n.user.addItem({item:e,folder:i.folder,data:t}),this.portalItem=e,this._syncUpInstanceWithItem(e,t,r)}async _canCopyItem(e,t,r){return!(u(e)&&e.id&&e.typeKeywords&&e.typeKeywords.indexOf("useOnly")>-1)||e.portal.portalHostname===r.portalHostname&&(t||await e.reload(),"admin"===e.itemControl||"update"===e.itemControl)}_syncUpInstanceWithItem(e,t,r){d.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl&&f(e.itemUrl)}),j(r),this.resourceInfo=t}async _updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename}),this._clearThumbnailOverride())}_getPortalItem(e){let t=R.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ee),t.portal||(t.portal=W.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await w((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)for(const e of["visible","featureEffect"])e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e]);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){var r;t.backgroundExcluded||(this.initialViewProperties.background=null==(r=e.background)?void 0:r.clone());if(this.initialViewProperties.spatialReference=e.spatialReference.clone(),t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=$(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(g(e)){const t=b(e),r=t&&t.mediaType,i=r&&oe.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:_(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}_restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new s("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};be.VERSION=Z,e([v({type:q,json:{write:!0}})],be.prototype,"applicationProperties",void 0),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringApp",null),e([A("authoringApp")],be.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],be.prototype,"writeAuthoringAppVersion",null),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],be.prototype,"basemap",void 0),e([v({type:te,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],be.prototype,"bookmarks",void 0),e([v({type:J,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],be.prototype,"floorInfo",void 0),e([v({type:Q,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:Y},"initialState.viewpoint":{type:i},mapRangeInfo:{type:D},spatialReference:{type:L}}}}})],be.prototype,"initialViewProperties",void 0),e([S("initialViewProperties")],be.prototype,"readInitialViewProperties",null),e([A("initialViewProperties")],be.prototype,"writeInitialViewProperties",null),e([v({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],be.prototype,"layers",void 0),e([A("layers")],be.prototype,"writeLayers",null),e([v({type:R})],be.prototype,"portalItem",void 0),e([v({json:{write:!0}})],be.prototype,"presentation",void 0),e([v()],be.prototype,"resourceInfo",void 0),e([v({readOnly:!0,type:X,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],be.prototype,"sourceVersion",void 0),e([S("sourceVersion")],be.prototype,"readSourceVersion",null),e([A("sourceVersion")],be.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{ignoreOrigin:!0}}})],be.prototype,"tables",void 0),e([A("tables")],be.prototype,"writeTables",null),e([v()],be.prototype,"thumbnailUrl",null),e([v({type:K,json:{write:!0}})],be.prototype,"widgets",void 0),e([v({type:re,json:{read:!0,write:!0}})],be.prototype,"utilityNetworks",void 0),be=e([I("esri.WebMap")],be);const _e=be;export{_e as default};
|
|
5
|
+
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{flatten as o}from"./core/arrayUtils.js";import a from"./core/Collection.js";import s from"./core/Error.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{unwrap as m,isSome as u}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as c}from"./core/Promise.js";import{eachAlways as y}from"./core/promiseUtils.js";import{whenOnce as w}from"./core/reactiveUtils.js";import{urlToObject as f,isDataProtocol as g,dataComponents as b,addQueryParameter as _}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as S}from"./core/accessorSupport/decorators/reader.js";import{subclass as I}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as j}from"./core/accessorSupport/originUtils.js";import{readLoadable as L}from"./core/accessorSupport/read.js";import O from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as V,webMercatorToGeographic as U}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as F}from"./layers/support/arcgisLayerUrl.js";import T from"./networks/UtilityNetwork.js";import W from"./portal/Portal.js";import R from"./portal/PortalItem.js";import{removeTypeKeyword as N,addTypeKeyword as x,hasTypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as k}from"./rest/geometryService/project.js";import C from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as E,isDeveloperBasemapLayer as B,findSpatialReference as G}from"./support/basemapUtils.js";import J from"./support/MapFloorInfo.js";import D from"./webdoc/RangeInfo.js";import K from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as z}from"./webdoc/support/writeUtils.js";import q from"./webmap/ApplicationProperties.js";import H from"./webmap/Bookmark.js";import Q from"./webmap/InitialViewProperties.js";import{Version as X}from"./webmap/Version.js";import Y from"./webmap/background/ColorBackground.js";const Z=new X(2,24),ee="Web Map",te=a.ofType(H),re=a.ofType(T),ie=p.getLogger("esri.WebMap"),oe=new Map;oe.set("image/jpeg","jpeg"),oe.set("image/jpg","jpg"),oe.set("image/png","png"),oe.set("image/gif","gif");const ae="ArcGIS Pro",se="ArcGIS API for JavaScript",ne="CollectorDisabled",le="Collector",pe="Data Editing",me="OfflineDisabled",ue="Offline",he="Workforce Project",de="Workforce Worker",ce="Workforce Dispatcher",ye="Offline Map Areas",we="FieldMapsDisabled",fe="DeveloperBasemap",ge=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));let be=class extends(h(n.LoadableMixin(c(r)))){constructor(e){super(e),this.applicationProperties=null,this.bookmarks=new te,this.floorInfo=null,this.initialViewProperties=new Q,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}initialize(){if(this.when().catch((e=>{ie.error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=se}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){var r;const o=new Q;t.background&&(o.background=Y.fromJSON(t.background));const a=null==(r=t.initialState)?void 0:r.viewpoint;if(a){if(a.rotation){X.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ae&&(a.rotation*=-1)}o.viewpoint=i.fromJSON(a)}return t.mapRangeInfo&&(o.rangeInfo=D.fromJSON(t.mapRangeInfo)),t.spatialReference&&(o.spatialReference=O.fromJSON(t.spatialReference)),o}writeInitialViewProperties(e,t,r,i){if(!e)return;const o=e.background;o&&o.color&&(t.background=o.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i))}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new X(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${Z.major}.${Z.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:"web-map"};const r=this._getAuthoringPropsState();L(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webmap:not-loaded","Web map must be loaded before it can be serialized");throw ie.error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:"web-map",restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){e=e||{},this._validateItem(),await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const t=this.portalItem,r={origin:"web-map",messages:[],writtenProperties:[],url:t.itemUrl&&f(t.itemUrl),portal:t.portal||W.getDefault()},i=this.write({},r);return this._validateJSONForWriting(r,e),await this._updateItemProperties(t),await this._updateItem(t,i,r),await this._updateItemThumbnail(),t}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e);await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const i={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal},o=this.write({},i);this._validateJSONForWriting(i,t),await this._updateItemPropertiesForSaveAs(r);const a=this._getThumbnailState();return await this._createItem(r,o,i,t),this._restoreThumbnailFromState(a),await this._updateItemThumbnail(),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){var t,r,i,a;const s=this.resourceInfo;return this._collectAllLayersJSON(o([null==s||null==(t=s.baseMap)?void 0:t.baseMapLayers,null==s?void 0:s.operationalLayers,null==(r=this.basemap)||null==(i=r.resourceInfo)||null==(a=i.data)?void 0:a.baseMapLayers])).find((t=>t.id===e.id))}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>m(z(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t)))).filter(Boolean).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve(null)}_loadFromItem(e){return e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})).then((()=>{if("Web Map"!==e.type)throw new s("webmap:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Map'",{type:e.type})})).then((()=>e.fetchData())).then((t=>(this.resourceInfo=t,this._readAndLoadFromJSON(t,{origin:"web-map",portal:e.portal||W.getDefault()})))).then((()=>this._computeInitialViewpoint()))}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=X.parse(e.version||"","webmap");return Z.validate(t),e.version=`${t.major}.${t.minor}`,e}_loadFromJSON(e,t){const r={context:{...t,layerContainerType:"operational-layers"}};return this.portalItem&&(r.context.portal=this.portalItem.portal||W.getDefault()),import("./layers/support/layersCreator.js").then((({populateOperationalLayers:t})=>{const i=[],o=e.operationalLayers;o&&o.length&&i.push(t(this.layers,o,r));const a={...r,context:{...r.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=e.tables;return s&&s.length&&i.push(t(this.tables,s,a)),y(i).then((()=>{}))}))}async _computeInitialViewpoint(){var e,t;let r=this.initialViewProperties;if(null==(e=r)||null==(t=e.viewpoint)?void 0:t.targetGeometry)return;const o=await this._getExtentFromItem();o&&(r=r?r.clone():new Q,r.viewpoint=new i,r.viewpoint.targetGeometry=o,this.initialViewProperties=r)}async _getExtentFromItem(){var e,t;const r=null==(e=this.initialViewProperties)?void 0:e.spatialReference,i=null==(t=this.portalItem)?void 0:t.extent;if(r&&i){if(r.isWGS84)return i.clone();if(r.isWebMercator)return V(i);return(await import("./portal/support/geometryServiceUtils.js")).getGeometryServiceURL(this.portalItem).then((e=>{const t=new C;return t.geometries=[i],t.outSpatialReference=r,k(e,t)})).then((e=>e[0])).catch((e=>(ie.error("Error projecting item's extent:",e),null)))}return null}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>!!this.allLayers.find((t=>t.id===e));t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>!!this.tables.find((t=>t.id===e.id)))));const i=e&&e.editing&&e.editing.locationTracking;i&&i.info&&!r(i.info.layerId)&&(e.editing=null);const o=this.presentation&&this.presentation.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _validateMap(){var e;if(null==(e=this.basemap)||!e.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let t=null;if(await w((()=>{const e=G(this.initialViewProperties,this.basemap);return t=e.spatialReference,!e.updating})),!P(t,this.initialViewProperties.spatialReference))throw new s("webmap:save","The spatial reference of the basemap is not compatible with the one from the map.",{expected:this.initialViewProperties.spatialReference,actual:t})}_validateItem(){if(!this.portalItem)throw ie.error("save: requires the portalItem property to be set"),new s("webmap:portal-item-not-set","Portal item to save to has not been set on the WebMap");this._validateItemType(this.portalItem)}_validateItemType(e){if(e.type!==ee)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ee}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),y(e).then((()=>{}))}async _beforeSave(){const e=[];for(const t of this.allLayers)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await y(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return y(e).then((()=>{}))}_getAllLayersAndTables(){return this.allLayers.concat(this.allTables)}_validateJSONForWriting(e,t){let r=e.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));if(t.ignoreUnsupported&&(r=r.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),r.length>0)throw new s("webmap:save","Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:r})}async _updateItemProperties(e){e.extent=await this._getWGS84Extent(this.initialViewProperties.viewpoint.targetGeometry),await this._updateTypeKeywords(e)}async _updateItemPropertiesForSaveAs(e){N(e,ne),N(e,me),N(e,he),N(e,de),N(e,ce),N(e,ye),N(e,we),await this._updateItemProperties(e)}async _getWGS84Extent(e){const t=e.clone().normalize();let r;if(t.length>1)for(const i of t)r?i.width>r.width&&(r=i):r=i;else r=t[0];return this._projectToWGS84(r)}async _projectToWGS84(e){const t=e.spatialReference;if(t.isWGS84)return e.clone();if(t.isWebMercator)return U(e);const r=await import("./portal/support/geometryServiceUtils.js"),i=await r.getGeometryServiceURL(this.portalItem),o=new C;o.geometries=[e],o.outSpatialReference=O.WGS84;return(await k(i,o))[0]}async _updateTypeKeywords(e){x(e,se),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){M(e,ne)||M(e,he)||M(e,de)||M(e,ce)||!this._hasEditableFeatureLayer()?N(e,le):x(e,le)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?x(e,pe):N(e,pe)}_evalOfflineKeyword(e){!M(e,me)&&this._isOfflineCapableMap()?x(e,ue):N(e,ue)}_evalDeveloperBasemapKeyword(e){E(this.basemap)?x(e,fe):N(e,fe)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled))}_isFeatureServiceLayer(e){return!("feature"!==e.type||!e.source||"feature-layer"!==e.source.type)}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isOfflineCapableLayer(e){return this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsSync||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||B(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(F(e.url)&&ge.some((t=>e.url.toLowerCase().includes("/"+t+"/"))))}async _updateItem(e,t,r){await e.update({data:t}),this._syncUpInstanceWithItem(e,t,r)}async _createItem(e,t,r,i){const o=this.portalItem,a=!!(o&&o.id&&o.portal.user),n=e.portal;if(await n._signIn(),!await this._canCopyItem(o,a,n))throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");await n.user.addItem({item:e,folder:i.folder,data:t}),this.portalItem=e,this._syncUpInstanceWithItem(e,t,r)}async _canCopyItem(e,t,r){return!(u(e)&&e.id&&e.typeKeywords&&e.typeKeywords.includes("useOnly"))||e.portal.portalHostname===r.portalHostname&&(t||await e.reload(),"admin"===e.itemControl||"update"===e.itemControl)}_syncUpInstanceWithItem(e,t,r){d.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl&&f(e.itemUrl)}),j(r),this.resourceInfo=t}async _updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename}),this._clearThumbnailOverride())}_getPortalItem(e){let t=R.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ee),t.portal||(t.portal=W.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await w((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)for(const e of["visible","featureEffect"])e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e]);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){var r;t.backgroundExcluded||(this.initialViewProperties.background=null==(r=e.background)?void 0:r.clone());if(this.initialViewProperties.spatialReference=e.spatialReference.clone(),t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=$(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(g(e)){const t=b(e),r=t&&t.mediaType,i=r&&oe.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:_(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}_restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new s("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};be.VERSION=Z,e([v({type:q,json:{write:!0}})],be.prototype,"applicationProperties",void 0),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringApp",null),e([A("authoringApp")],be.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],be.prototype,"writeAuthoringAppVersion",null),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],be.prototype,"basemap",void 0),e([v({type:te,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],be.prototype,"bookmarks",void 0),e([v({type:J,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],be.prototype,"floorInfo",void 0),e([v({type:Q,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:Y},"initialState.viewpoint":{type:i},mapRangeInfo:{type:D},spatialReference:{type:O}}}}})],be.prototype,"initialViewProperties",void 0),e([S("initialViewProperties")],be.prototype,"readInitialViewProperties",null),e([A("initialViewProperties")],be.prototype,"writeInitialViewProperties",null),e([v({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],be.prototype,"layers",void 0),e([A("layers")],be.prototype,"writeLayers",null),e([v({type:R})],be.prototype,"portalItem",void 0),e([v({json:{write:!0}})],be.prototype,"presentation",void 0),e([v()],be.prototype,"resourceInfo",void 0),e([v({readOnly:!0,type:X,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],be.prototype,"sourceVersion",void 0),e([S("sourceVersion")],be.prototype,"readSourceVersion",null),e([A("sourceVersion")],be.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{ignoreOrigin:!0}}})],be.prototype,"tables",void 0),e([A("tables")],be.prototype,"writeTables",null),e([v()],be.prototype,"thumbnailUrl",null),e([v({type:K,json:{write:!0}})],be.prototype,"widgets",void 0),e([v({type:re,json:{read:!0,write:!0}})],be.prototype,"utilityNetworks",void 0),be=e([I("esri.WebMap")],be);const _e=be;export{_e as default};
|
package/WebScene.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import a from"./core/Handles.js";import"./core/has.js";import{clone as n}from"./core/lang.js";import l from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import c from"./core/Logger.js";import{isSome as d}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as u}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as y,eachAlways as w}from"./core/promiseUtils.js";import{urlToObject as g,addQueryParameter as f}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as I}from"./core/accessorSupport/originUtils.js";import{readLoadable as _}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import R from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as P}from"./geometry/projection.js";import V from"./geometry/SpatialReference.js";import{validateWebSceneError as L}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as M}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import E from"./portal/PortalItem.js";import N from"./support/MapFloorInfo.js";import{createSchemaValidationError as C,createCopyError as T}from"./support/webSceneUtils.js";import{ViewingMode as G}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as F}from"./views/support/spatialReferenceSupport.js";import{saveResources as W}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import x from"./webscene/ApplicationProperties.js";import J from"./webscene/Environment.js";import k from"./webscene/InitialViewProperties.js";import B from"./webscene/Presentation.js";import q from"./webscene/TransportationNetwork.js";import{Version as K}from"./webscene/Version.js";const D=c.getLogger("esri.WebScene"),H=new K(1,27),z=()=>{const e=8,t=[],r=H.major;for(let i=e;i<=H.minor;i++)t.push(`${r}.${i}`);return t},Q="Web Scene",X="ViewingMode-Local";let Y=class extends(l.LoadableMixin(m(h(r)))){constructor(e){super(e),this._handles=new a,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=null,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new B,this.initialViewProperties=new k,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=y((async(e,t,r)=>{switch(e){case Z.SAVE:return this._saveImpl(t);case Z.SAVE_AS:return this._saveAsImpl(r,t)}})),this.resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{D.error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this._handles.add(this.allLayers.on("change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this._handles.destroy(),this.presentation&&this.presentation.destroy();const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){const o={...i,layerContainerType:"operational-layers"},s=e.map((e=>this.verifyWriteLayer(e,i)?e.write({},o):null)).filter((e=>!!e));t[r]=s.toArray()}verifyWriteLayer(e,t){return"write"in e||(t&&t.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new K(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${H.major}.${H.minor}`}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState&&t.initialState.environment&&(r.environment=J.fromJSON(t.initialState.environment)),t.spatialReference?r.spatialReference=V.fromJSON(t.spatialReference):r.spatialReference=V.WebMercator,r.viewingMode=t.viewingMode||"global",t.initialState&&t.initialState.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new k(r)}get spatialReference(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.spatialReference)?e:V.WebMercator}get viewingMode(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.viewingMode)?e:"global"}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return p(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)))}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(_(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground&&e.ground.layers;!e.baseMap&&t&&t.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=n(t))}write(e,t){var r;if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw D.error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const i=!(null!=(r=t)&&r.messages);t={messages:[],...t,origin:"web-scene"};const o=super.write(e,t);if(i){const e=t.messages.filter((e=>"web-document-write:property-required"===e.name));if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw D.error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(o),o}async save(e){return this._debouncedSaveOperations(Z.SAVE,e)}async _saveImpl(e){this.portalItem||(D.error("save(): requires the .portalItem property to be set"),await Promise.reject(new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene"))),this.portalItem.type!==Q&&await Promise.reject(new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${Q}"`));const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:this.portalItem.itemUrl&&g(this.portalItem.itemUrl),messages:[],portal:this.portalItem.portal||O.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await this.portalItem.update({data:i}),await W(this.resourceReferences,r,null),I(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(Z.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=E.from(e);r||(D.error("saveAs(portalItem): requires a portal item parameter"),await Promise.reject(new s("webscene:portal-item-required","saveAs requires a portal item to save to"))),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=Q,r.portal=i;const o=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:i,portalItem:r,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");return this._updateTypeKeywords(r),await i._signIn(),await i.user.addItem({item:r,folder:t&&t.folder,data:a}),await W(this.resourceReferences,o,null),this.portalItem=r,u.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl&&g(r.itemUrl)}),I(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl}),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}_verifySave(e,t,r,i=!1){if(!M(this.spatialReference))return Promise.reject(new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently."));let o,a=t.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));t.blockedRelativeUrls&&(a=a.concat(t.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Scene`))))),r&&r.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),null!=r&&r.requiredPropertyChecksDisabled&&(a=a.filter((e=>"web-document-write:property-required"!==e.name)));const n=r&&r.strictSchemaValidationEnabled;return o=n?import("./webscene/support/schemaValidator.js").then((t=>{const r=t.validate(e);if(r.length>0){const e=`webscene did not validate:\n${r.join("\n")}`;D.error(`${i?"saveAs":"save"}(): ${e}`)}return r.map((e=>new s("webscene:schema-validation",e)))})).then((e=>{if(n&&e.length>0){throw C(e.concat(a))}return a})):Promise.resolve(a),o.then((e=>{if(e.length>0)return Promise.reject(new s("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:e}))}))}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(T()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),e.verifyItemRelativeUrls&&e.verifyItemRelativeUrls.writtenUrls.length>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment){if(e.environment.lighting.type&&"sun"!==e.environment.lighting.type)throw new s("lighting:unsupported",`${e.environment.lighting.type} lighting cannot be stored in WebScene`);this.initialViewProperties.environment=J.prototype.clone.apply(e.environment)}if(!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,d(e.clippingArea)?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize||void 0)}async _updateFromThumbnail(e,t){const r=$(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}_loadFromJSON(e,t){const r=new o;return this._validateSpatialReference().then((()=>this._validateHeightModelInfo())).then((()=>import("./layers/support/layersCreator.js"))).then((({populateOperationalLayers:i})=>{const{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||O.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(r,s,e))}return o&&o.length>0&&n.push(i(this.layers,o,l)),w(n).then((()=>{}))})).then((()=>this._loadObjectsWithLayers())).then((()=>{this.ground.layers.addMany(r)}))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[];for(const t of this.allLayers.items)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await w(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await w(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:g(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this.resourceReferences={portalItem:e,paths:r.readResourcePaths}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!F(t,G.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||P(e,t)}else{if(!F(t,G.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e&&(d(e.camera)&&e.camera.position&&e.camera.position.spatialReference||d(e.targetGeometry)&&e.targetGeometry.spatialReference),o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=L(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=K.parse(e.version||"","webscene");return H.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=V.WebMercator.toJSON()),e}_updateTypeKeywords(e){"local"===this.initialViewProperties.viewingMode?e.typeKeywords?-1===e.typeKeywords.indexOf(X)&&e.typeKeywords.push(X):e.typeKeywords=[X]:"global"===this.initialViewProperties.viewingMode&&e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e=>e!==X))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||V.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem&&this.portalItem.itemUrl?g(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties&&this.applicationProperties.viewing&&this.applicationProperties.viewing.search,t=e=>!!this.allLayers.find((t=>t.id===e));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};var Z;Y.VERSION=H,e([v({type:x,json:{write:!0}})],Y.prototype,"applicationProperties",void 0),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],Y.prototype,"basemap",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],Y.prototype,"clippingArea",void 0),e([A("clippingArea")],Y.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],Y.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],Y.prototype,"readClippingEnabled",null),e([A("clippingEnabled")],Y.prototype,"writeClippingEnabled",null),e([v({type:N,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],Y.prototype,"floorInfo",void 0),e([v({type:R,json:{write:!0}})],Y.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],Y.prototype,"layers",void 0),e([A("layers")],Y.prototype,"writeLayers",null),e([v({readOnly:!0,type:K,json:{type:z(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],Y.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],Y.prototype,"readSourceVersion",null),e([A("sourceVersion")],Y.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:!1}})],Y.prototype,"tables",void 0),e([v()],Y.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringApp",null),e([A("authoringApp")],Y.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],Y.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],Y.prototype,"ground",void 0),e([A("ground")],Y.prototype,"writeGround",null),e([v({type:o.ofType(q),json:{write:!0}})],Y.prototype,"transportationNetworks",void 0),e([v({type:B,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],Y.prototype,"presentation",void 0),e([v({type:k,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new k({viewingMode:"global",spatialReference:V.WebMercator})}})],Y.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","spatialReference","viewingMode","initialState.viewpoint"])],Y.prototype,"readInitialViewProperties",null),e([v({type:V,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"spatialReference",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"viewingMode",null),e([v({type:E})],Y.prototype,"portalItem",void 0),e([v()],Y.prototype,"resourceInfo",void 0),Y=e([S("esri.WebScene")],Y),function(e){e[e.SAVE=0]="SAVE",e[e.SAVE_AS=1]="SAVE_AS"}(Z||(Z={}));const ee=Y;export{ee as default};
|
|
5
|
+
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import a from"./core/Handles.js";import"./core/has.js";import{clone as n}from"./core/lang.js";import l from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import c from"./core/Logger.js";import{isSome as d}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as u}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as y,eachAlways as w}from"./core/promiseUtils.js";import{urlToObject as g,addQueryParameter as f}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as I}from"./core/accessorSupport/originUtils.js";import{readLoadable as _}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import R from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as V}from"./geometry/projection.js";import L from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as M}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import E from"./portal/PortalItem.js";import N from"./support/MapFloorInfo.js";import{createSchemaValidationError as C,createCopyError as T}from"./support/webSceneUtils.js";import{ViewingMode as G}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as F}from"./views/support/spatialReferenceSupport.js";import{saveResources as W}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import J from"./webscene/ApplicationProperties.js";import x from"./webscene/Environment.js";import k from"./webscene/InitialViewProperties.js";import B from"./webscene/Presentation.js";import q from"./webscene/TransportationNetwork.js";import{Version as K}from"./webscene/Version.js";const D=c.getLogger("esri.WebScene"),H=new K(1,28),z=()=>{const e=8,t=[],r=H.major;for(let i=e;i<=H.minor;i++)t.push(`${r}.${i}`);return t},Q="Web Scene",X="ViewingMode-Local";let Y=class extends(l.LoadableMixin(m(h(r)))){constructor(e){super(e),this._handles=new a,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=null,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new B,this.initialViewProperties=new k,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=y((async(e,t,r)=>{switch(e){case Z.SAVE:return this._saveImpl(t);case Z.SAVE_AS:return this._saveAsImpl(r,t)}})),this.resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{D.error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this._handles.add(this.allLayers.on("change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this._handles.destroy(),this.presentation&&this.presentation.destroy();const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){const o={...i,layerContainerType:"operational-layers"},s=e.map((e=>this.verifyWriteLayer(e,i)?e.write({},o):null)).filter((e=>!!e));t[r]=s.toArray()}verifyWriteLayer(e,t){return"write"in e||(t&&t.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new K(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${H.major}.${H.minor}`}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState&&t.initialState.environment&&(r.environment=x.fromJSON(t.initialState.environment)),t.spatialReference?r.spatialReference=L.fromJSON(t.spatialReference):r.spatialReference=L.WebMercator,r.viewingMode=t.viewingMode||"global",t.initialState&&t.initialState.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new k(r)}get spatialReference(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.spatialReference)?e:L.WebMercator}get viewingMode(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.viewingMode)?e:"global"}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return p(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)))}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(_(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground&&e.ground.layers;!e.baseMap&&t&&t.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=n(t))}write(e,t){var r;if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw D.error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const i=!(null!=(r=t)&&r.messages);t={messages:[],...t,origin:"web-scene"};const o=super.write(e,t);if(i){const e=t.messages.filter((e=>"web-document-write:property-required"===e.name));if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw D.error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(o),o}async save(e){return this._debouncedSaveOperations(Z.SAVE,e)}async _saveImpl(e){this.portalItem||(D.error("save(): requires the .portalItem property to be set"),await Promise.reject(new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene"))),this.portalItem.type!==Q&&await Promise.reject(new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${Q}"`));const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:this.portalItem.itemUrl&&g(this.portalItem.itemUrl),messages:[],portal:this.portalItem.portal||O.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await this.portalItem.update({data:i}),await W(this.resourceReferences,r,null),I(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(Z.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=E.from(e);r||(D.error("saveAs(portalItem): requires a portal item parameter"),await Promise.reject(new s("webscene:portal-item-required","saveAs requires a portal item to save to"))),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=Q,r.portal=i;const o=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:i,portalItem:r,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");return this._updateTypeKeywords(r),await i._signIn(),await i.user.addItem({item:r,folder:t&&t.folder,data:a}),await W(this.resourceReferences,o,null),this.portalItem=r,u.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl&&g(r.itemUrl)}),I(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl}),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}_verifySave(e,t,r,i=!1){if(!M(this.spatialReference))return Promise.reject(new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently."));let o,a=t.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));t.blockedRelativeUrls&&(a=a.concat(t.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Scene`))))),r&&r.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),null!=r&&r.requiredPropertyChecksDisabled&&(a=a.filter((e=>"web-document-write:property-required"!==e.name)));const n=r&&r.strictSchemaValidationEnabled;return o=n?import("./webscene/support/schemaValidator.js").then((t=>{const r=t.validate(e);if(r.length>0){const e=`webscene did not validate:\n${r.join("\n")}`;D.error(`${i?"saveAs":"save"}(): ${e}`)}return r.map((e=>new s("webscene:schema-validation",e)))})).then((e=>{if(n&&e.length>0){throw C(e.concat(a))}return a})):Promise.resolve(a),o.then((e=>{if(e.length>0)throw new s("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:e})}))}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(T()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),e.verifyItemRelativeUrls&&e.verifyItemRelativeUrls.writtenUrls.length>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment){if(e.environment.lighting.type&&"sun"!==e.environment.lighting.type)throw new s("lighting:unsupported",`${e.environment.lighting.type} lighting cannot be stored in WebScene`);this.initialViewProperties.environment=x.prototype.clone.apply(e.environment)}if(!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,d(e.clippingArea)?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize||void 0)}async _updateFromThumbnail(e,t){const r=$(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}_loadFromJSON(e,t){const r=new o;return this._validateSpatialReference().then((()=>this._validateHeightModelInfo())).then((()=>import("./layers/support/layersCreator.js"))).then((({populateOperationalLayers:i})=>{const{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||O.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(r,s,e))}return o&&o.length>0&&n.push(i(this.layers,o,l)),w(n).then((()=>{}))})).then((()=>this._loadObjectsWithLayers())).then((()=>{this.ground.layers.addMany(r)}))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[];for(const t of this.allLayers.items)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await w(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await w(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:g(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this.resourceReferences={portalItem:e,paths:r.readResourcePaths}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!F(t,G.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||V(e,t)}else{if(!F(t,G.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e&&(d(e.camera)&&e.camera.position&&e.camera.position.spatialReference||d(e.targetGeometry)&&e.targetGeometry.spatialReference),o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=K.parse(e.version||"","webscene");return H.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=L.WebMercator.toJSON()),e}_updateTypeKeywords(e){"local"===this.initialViewProperties.viewingMode?e.typeKeywords?e.typeKeywords.includes(X)||e.typeKeywords.push(X):e.typeKeywords=[X]:"global"===this.initialViewProperties.viewingMode&&e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e=>e!==X))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||L.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem&&this.portalItem.itemUrl?g(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties&&this.applicationProperties.viewing&&this.applicationProperties.viewing.search,t=e=>!!this.allLayers.find((t=>t.id===e));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};var Z;Y.VERSION=H,e([v({type:J,json:{write:!0}})],Y.prototype,"applicationProperties",void 0),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],Y.prototype,"basemap",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],Y.prototype,"clippingArea",void 0),e([A("clippingArea")],Y.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],Y.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],Y.prototype,"readClippingEnabled",null),e([A("clippingEnabled")],Y.prototype,"writeClippingEnabled",null),e([v({type:N,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],Y.prototype,"floorInfo",void 0),e([v({type:R,json:{write:!0}})],Y.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],Y.prototype,"layers",void 0),e([A("layers")],Y.prototype,"writeLayers",null),e([v({readOnly:!0,type:K,json:{type:z(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],Y.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],Y.prototype,"readSourceVersion",null),e([A("sourceVersion")],Y.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:!1}})],Y.prototype,"tables",void 0),e([v()],Y.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringApp",null),e([A("authoringApp")],Y.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],Y.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],Y.prototype,"ground",void 0),e([A("ground")],Y.prototype,"writeGround",null),e([v({type:o.ofType(q),json:{write:!0}})],Y.prototype,"transportationNetworks",void 0),e([v({type:B,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],Y.prototype,"presentation",void 0),e([v({type:k,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new k({viewingMode:"global",spatialReference:L.WebMercator})}})],Y.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","spatialReference","viewingMode","initialState.viewpoint"])],Y.prototype,"readInitialViewProperties",null),e([v({type:L,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"spatialReference",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"viewingMode",null),e([v({type:E})],Y.prototype,"portalItem",void 0),e([v()],Y.prototype,"resourceInfo",void 0),Y=e([S("esri.WebScene")],Y),function(e){e[e.SAVE=0]="SAVE",e[e.SAVE_AS=1]="SAVE_AS"}(Z||(Z={}));const ee=Y;export{ee as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../chunks/tslib.es6.js";import{Clonable as
|
|
5
|
+
import{_ as o}from"../chunks/tslib.es6.js";import{Clonable as t}from"../core/Clonable.js";import{equalsMaybe as r}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as e}from"../core/accessorSupport/decorators/subclass.js";import i from"../geometry/Point.js";import{elevationInfoLikeEquals as p}from"../support/elevationInfoUtils.js";let n=class extends t{constructor(o){super(o),this.position=null,this.elevationInfo=null}equals(o){return r(this.position,o.position)&&r(this.intersection,o.intersection)&&p(this.elevationInfo,o.elevationInfo)}};o([s({type:i})],n.prototype,"position",void 0),o([s()],n.prototype,"elevationInfo",void 0),o([s()],n.prototype,"intersection",void 0),n=o([e("esri.analysis.LineOfSightAnalysisObserver")],n);const a=n;export{a as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../chunks/tslib.es6.js";import{Clonable as
|
|
5
|
+
import{_ as o}from"../chunks/tslib.es6.js";import{Clonable as t}from"../core/Clonable.js";import{equalsMaybe as r}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as e}from"../core/accessorSupport/decorators/subclass.js";import i from"../geometry/Point.js";import{elevationInfoLikeEquals as p}from"../support/elevationInfoUtils.js";let n=class extends t{constructor(o){super(o),this.position=null,this.elevationInfo=null}equals(o){return r(this.position,o.position)&&r(this.intersection,o.intersection)&&p(this.elevationInfo,o.elevationInfo)}};o([s({type:i})],n.prototype,"position",void 0),o([s()],n.prototype,"elevationInfo",void 0),o([s()],n.prototype,"intersection",void 0),n=o([e("esri.analysis.LineOfSightAnalysisTarget")],n);const a=n;export{a as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{cloneField as a,FeatureServiceDatabaseType as i,layerGeometryEsriConstants as l}from"../support/shared.js";import{reformulateWithoutField as n,toWhereClause as o,translateFunctionToDatabaseSpecific as h,makeToday as u,makeDateString as d,convertIntervalToSql as c,combine as p,scanForField as f}from"../support/sqlUtils.js";import{resolve as g,reject as _}from"../../../core/promiseUtils.js";import{WhereClause as N}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";class m{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class w extends m{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class v extends m{constructor(e,t,r){super(a(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:n(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class C extends m{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,i.Standardised,this.field.name,this.codefield instanceof N?o(this.codefield,i.Standardised):this.codefield,e.parameters);return r.indexOf(C.BADNESS)>=0?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:N.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,s=null,a){let i,l,n,o;switch(e.type){case"interval":return c(this.evaluateNodeToWhereClause(e.value,t,r,s,a),e.qualifier,e.op);case"case_expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,C.BADNESS,a));for(let i=0;i<e.clauses.length;i++)s+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[i].operand,t,r,C.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[i].value,t,r,C.BADNESS,a);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,C.BADNESS,a)),s+=" END ",s}case"param":{const r=a[e.value.toLowerCase()];if("string"==typeof r){return"'"+a[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return d(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(d(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expr_list":l=[];for(const i of e.value)l.push(this.evaluateNodeToWhereClause(i,t,r,s,a));return l;case"unary_expr":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,C.BADNESS,a)+" ) ";case"binary_expr":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NOT NULL )";case"IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o+")) ";case"NOT IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o+")) ";case"BETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"NOTBETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<>":case"=":if("column_ref"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column_ref"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") "}throw new Error("Not Supported Operator "+e.operator);case"null":return"null";case"bool":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return d(e.value,t);case"number":return e.value.toString();case"current_time":return u("date"===e.mode,t);case"column_ref":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":e.column;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,C.BADNESS,a);return h(e.name,s,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof N?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}C.BADNESS="_!!!_BAD_LKP_!!!!";class T extends m{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:n(e,this.field.name,o(this.sql,i.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class E extends r{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new S({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new s(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):g(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(r,a,i,l){const n=[];-1!==a&&void 0===this._featureCache[a]&&n.push(a);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return this._expandPagedSet(r,o,0,0,l).then((()=>this._getFeatures(r,a,i,l)));let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=i&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==a&&n.push(r._known[e]),n.length>=o)));e++);if(0===n.length)return g("success");r=new s([],n,r._ordered,null);const u=Math.min(n.length,i);return this._parent._getFeatures(r,-1,u,l).then((()=>{this._checkCancelled(l);const r=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&r.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(const s of r){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(s);this._featureCache[s.id]=new e({attributes:r,geometry:t(s.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return _(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,a,i){let l=!1;const n=this._reformulateWithoutAdaptions(r);l=n.cannot,r=n.where;let o=!1;if(null!==a){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof w)&&!0===a.scanForField(t.field.name)){if(!(t instanceof v)){a=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}a&&e.length>0&&(a=a.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=p(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,a,i))).then((e=>{let t;return this._checkCancelled(i),t=!0===l?new s(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s(e._candidates.slice(0),e._known.slice(0),!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===f(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}_stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);return n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,!0===n?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):g({calculated:!1}):this._parent._stat(e,t,r,s,a,i,l).then((n=>!1===n.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:n))}_canDoAggregates(e,t,r,s,a){if(null===this._parent)return g(!1);for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof w))return g(!1);const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return g(!1);const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return l.cannot?g(!1):(null!==(a=l.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}_getAggregatePagesDataSourceDefinition(e,t,r,s,a,i,l){if(null===this._parent)return _(new Error("Should never be called"));const n=[];for(let h=0;h<t.length;h++){const e=t[h];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return _(new Error("Should never be called"));const r=e.clone();r.workingexpr=t.where,n.push(r)}else n.push(e)}const o=this._reformulateWithoutAdaptions(a);return o.cannot?_(new Error("Should never be called")):(null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,n,r,s,a,i,l))}}export{E as AdaptedFeatureSet,m as AdaptedField,v as FieldRename,w as OriginalField,T as SqlExpressionAdapted,C as StringToCodeAdapted};
|
|
5
|
+
import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{cloneField as a,FeatureServiceDatabaseType as i,layerGeometryEsriConstants as l}from"../support/shared.js";import{reformulateWithoutField as n,toWhereClause as o,translateFunctionToDatabaseSpecific as h,makeToday as u,makeDateString as d,convertIntervalToSql as c,combine as p,scanForField as f}from"../support/sqlUtils.js";import{resolve as g,reject as _}from"../../../core/promiseUtils.js";import{WhereClause as N}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";class m{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class w extends m{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class v extends m{constructor(e,t,r){super(a(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:n(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class C extends m{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,i.Standardised,this.field.name,this.codefield instanceof N?o(this.codefield,i.Standardised):this.codefield,e.parameters);return r.includes(C.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:N.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,s=null,a){let i,l,n,o;switch(e.type){case"interval":return c(this.evaluateNodeToWhereClause(e.value,t,r,s,a),e.qualifier,e.op);case"case_expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,C.BADNESS,a));for(let i=0;i<e.clauses.length;i++)s+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[i].operand,t,r,C.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[i].value,t,r,C.BADNESS,a);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,C.BADNESS,a)),s+=" END ",s}case"param":{const r=a[e.value.toLowerCase()];if("string"==typeof r){return"'"+a[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return d(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(d(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expr_list":l=[];for(const i of e.value)l.push(this.evaluateNodeToWhereClause(i,t,r,s,a));return l;case"unary_expr":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,C.BADNESS,a)+" ) ";case"binary_expr":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NOT NULL )";case"IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o+")) ";case"NOT IN":if(i=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o+")) ";case"BETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"NOTBETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<>":case"=":if("column_ref"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column_ref"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,a)+") "}throw new Error("Not Supported Operator "+e.operator);case"null":return"null";case"bool":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return d(e.value,t);case"number":return e.value.toString();case"current_time":return u("date"===e.mode,t);case"column_ref":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":e.column;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,C.BADNESS,a);return h(e.name,s,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof N?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}C.BADNESS="_!!!_BAD_LKP_!!!!";class T extends m{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:n(e,this.field.name,o(this.sql,i.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class E extends r{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new S({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new s(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):g(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(r,a,i,l){const n=[];-1!==a&&void 0===this._featureCache[a]&&n.push(a);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return this._expandPagedSet(r,o,0,0,l).then((()=>this._getFeatures(r,a,i,l)));let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=i&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==a&&n.push(r._known[e]),n.length>=o)));e++);if(0===n.length)return g("success");r=new s([],n,r._ordered,null);const u=Math.min(n.length,i);return this._parent._getFeatures(r,-1,u,l).then((()=>{this._checkCancelled(l);const r=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&r.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(const s of r){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(s);this._featureCache[s.id]=new e({attributes:r,geometry:t(s.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return _(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,a,i){let l=!1;const n=this._reformulateWithoutAdaptions(r);l=n.cannot,r=n.where;let o=!1;if(null!==a){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof w)&&!0===a.scanForField(t.field.name)){if(!(t instanceof v)){a=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}a&&e.length>0&&(a=a.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=p(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,a,i))).then((e=>{let t;return this._checkCancelled(i),t=!0===l?new s(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s(e._candidates.slice(0),e._known.slice(0),!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===f(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}_stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);return n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,!0===n?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):g({calculated:!1}):this._parent._stat(e,t,r,s,a,i,l).then((n=>!1===n.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:n))}_canDoAggregates(e,t,r,s,a){if(null===this._parent)return g(!1);for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof w))return g(!1);const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return g(!1);const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return l.cannot?g(!1):(null!==(a=l.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}_getAggregatePagesDataSourceDefinition(e,t,r,s,a,i,l){if(null===this._parent)return _(new Error("Should never be called"));const n=[];for(let h=0;h<t.length;h++){const e=t[h];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return _(new Error("Should never be called"));const r=e.clone();r.workingexpr=t.where,n.push(r)}else n.push(e)}const o=this._reformulateWithoutAdaptions(a);return o.cannot?_(new Error("Should never be called")):(null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,n,r,s,a,i,l))}}export{E as AdaptedFeatureSet,m as AdaptedField,v as FieldRename,w as OriginalField,T as SqlExpressionAdapted,C as StringToCodeAdapted};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as R}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/Query.js";import{executeForIds as w}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import"../../../core/has.js";import"../../../geometry/support/spatialReferenceUtils.js";import q from"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import v from"../../../rest/support/StatisticDefinition.js";import C from"../../Dictionary.js";class j extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new x;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>q.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?I:"executeForCount"===t?R:w,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new x;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new x;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.indexOf("*")>-1)return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new x;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new x;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new x;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new x;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new v;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.indexOf("esriSpatialRelRelation")>=0)return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.indexOf("esriSpatialRelRelation")>=0?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new v;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new x;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new j({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=C.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new x;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),I(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=f)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const r=null==(e=f)?void 0:e.findServerInfo(this._layer.url);if(r)return m(r.owningSystemUrl);let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");return i=s>-1?i.substring(0,s):i,i?(i+="/rest/info",_(((e,r)=>{t(i,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{j as default};
|
|
5
|
+
import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as R}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/Query.js";import{executeForIds as w}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import"../../../core/has.js";import"../../../geometry/support/spatialReferenceUtils.js";import q from"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import v from"../../../rest/support/StatisticDefinition.js";import C from"../../Dictionary.js";class j extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new x;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>q.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?I:"executeForCount"===t?R:w,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new x;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new x;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new x;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new x;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new x;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new x;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new v;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new v;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new x;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new j({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=C.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new x;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),I(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=f)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const r=null==(e=f)?void 0:e.findServerInfo(this._layer.url);if(r)return m(r.owningSystemUrl);let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");return i=s>-1?i.substring(0,s):i,i?(i+="/rest/info",_(((e,r)=>{t(i,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{j as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../support/FeatureSet.js";import r from"../support/IdSet.js";import{defaultMaxRecords as s,FeatureServiceDatabaseType as i,IdState as a}from"../support/shared.js";import{toWhereClause as l}from"../support/sqlUtils.js";import{create as n,resolve as o,reject as u}from"../../../core/promiseUtils.js";import h from"../../../geometry/Geometry.js";import c from"../../../layers/FeatureLayer.js";import d from"../../../layers/support/FeatureType.js";import
|
|
5
|
+
import e from"../../../Graphic.js";import t from"../support/FeatureSet.js";import r from"../support/IdSet.js";import{defaultMaxRecords as s,FeatureServiceDatabaseType as i,IdState as a}from"../support/shared.js";import{toWhereClause as l}from"../support/sqlUtils.js";import{create as n,resolve as o,reject as u}from"../../../core/promiseUtils.js";import h from"../../../geometry/Geometry.js";import c from"../../../layers/FeatureLayer.js";import d from"../../../layers/support/FeatureType.js";import p from"../../../layers/support/Field.js";import y from"../../../rest/support/Query.js";class f extends t{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return s}end(){return this._layer}optimisePagingFeatureQueries(){}load(){return null===this._loadPromise&&(this._loadPromise=n(((e,t)=>{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}))),this._loadPromise}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const s of this._overrideFields)if(s.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this._databaseType=i.Standardised,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}isTable(){return this._forceIsTable||this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return a.InFeatureSet}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):o(this._wset)}_changeFeature(t){const r={};for(const e of this.fields)r[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:r})}_getFilteredSet(e,t,s,a,n){let u="",h=!1;if(null!==a&&(u=a.constructClause(),h=!0),this.isTable()&&t&&null!==e&&""!==e){const e=new r([],[],!0,null);return o(e)}const c=new y;return c.where=null===s?null===t?"1=1":"":l(s,i.Standardised),c.spatialRelationship=this._makeRelationshipEnum(e),c.outSpatialReference=this.spatialReference,c.orderByFields=""!==u?u.split(","):null,c.geometry=null===t?null:t,c.returnGeometry=!0,c.relationParameter=this._makeRelationshipParam(e),this._layer.queryFeatures(c).then((e=>{if(null===e)return new r([],[],h,null);this._checkCancelled(n);const t=[];e.features.forEach((e=>{const r=e.attributes[this._layer.objectIdField];t.push(r),this._featureCache[r]=this._changeFeature(e)}));return new r([],t,h,null)}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_queryAllFeatures(){if(this._wset)return o(this._wset);const e=new y;return e.where="1=1",this._ensureLoaded().then((()=>{if(this._layer.source&&this._layer.source.items){const e=[];return this._layer.source.items.forEach((t=>{const r=t.attributes[this._layer.objectIdField];e.push(r),this._featureCache[r]=this._changeFeature(t)})),this._wset=new r([],e,!1,null),this._wset}return this._layer.queryFeatures(e).then((e=>{const t=[];return e.features.forEach((e=>{const r=e.attributes[this._layer.objectIdField];t.push(r),this._featureCache[r]=this._changeFeature(e)})),this._wset=new r([],t,!1,null),this._wset}))}))}_getFeatures(e,t,r){const s=[];-1!==t&&void 0===this._featureCache[t]&&s.push(t);for(let i=e._lastFetchedIndex;i<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&s.push(e._known[i]),s.length>r)));i++);return 0===s.length?o("success"):u(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e){return o(e)}_stat(){return o({calculated:!1})}_canDoAggregates(){return o(!1)}relationshipMetaData(){return[]}static _cloneAttr(e){const t={};for(const r in e)t[r]=e[r];return t}nativeCapabilities(){return{title:this._layer.title,canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let r=e.layerDefinition.objectIdField;const s=e.layerDefinition.typeIdField?e.layerDefinition.typeIdField:"",i=[];if(e.layerDefinition.types)for(const h of e.layerDefinition.types)i.push(d.fromJSON(h));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let l=e.featureSet.features;const n=t.toJSON();if(""===r||void 0===r){let t=!1;for(const s of e.layerDefinition.fields)if("oid"===s.type||"esriFieldTypeOID"===s.type){r=s.name,t=!0;break}if(!1===t){let t="FID",s=!0,i=0;for(;s;){let r=!0;for(const s of e.layerDefinition.fields)if(s.name===t){r=!1;break}!0===r?s=!1:(i++,t="FID"+i.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const a=[];for(let r=0;r<l.length;r++)a.push({geometry:e.featureSet.features[r].geometry,attributes:e.featureSet.features[r].attributes?this._cloneAttr(e.featureSet.features[r].attributes):{}}),a[r].attributes[t]=r;l=a,r=t}}const o=[];for(const h of e.layerDefinition.fields)h instanceof p?o.push(h):o.push(p.fromJSON(h));let u=a;switch(u){case"esriGeometryPoint":u="point";break;case"esriGeometryPolyline":u="polyline";break;case"esriGeometryPolygon":u="polygon";break;case"esriGeometryExtent":u="extent";break;case"esriGeometryMultipoint":u="multipoint"}for(const c of l)c.geometry&&c.geometry instanceof h==!1&&(c.geometry.type=u,void 0===c.geometry.spatialReference&&(c.geometry.spatialReference=n));const y={outFields:["*"],source:l,fields:o,types:i,typeIdField:s,objectIdField:r,spatialReference:t};y.geometryType=u||"point";const _=new c(y);return new f({layer:_,spatialReference:t,isTable:null===u||""===u})}queryAttachments(){return o([])}getFeatureByObjectId(e){const t=new y;return t.where=this.objectIdField+"="+e.toString(),this._layer.queryFeatures(t).then((e=>1===e.features.length?e.features[0]:null))}getOwningSystemUrl(){return o("")}getIdentityUser(){return o("")}}export{f as default};
|