@arcgis/core 4.27.0-next.20230521 → 4.27.0-next.20230523
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/Graphic.js +1 -1
- package/WebMap.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.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/functions/featuresetbase.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/030b43764f945cb1f8b0.js +1 -0
- package/assets/esri/core/workers/chunks/0d02856e55d20b99fc8b.js +1 -0
- package/assets/esri/core/workers/chunks/{69242c66492717c7388c.js → 0fcb8d408696075338e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{b91c155de9a89e4e6971.js → 187c3b971ed0fc4363ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{85c6ce93aa41e6b65997.js → 18db07d739a713cc0465.js} +1 -1
- package/assets/esri/core/workers/chunks/1b6177e23327be645c8c.js +1 -0
- package/assets/esri/core/workers/chunks/28286014a575042619ee.js +1 -0
- package/assets/esri/core/workers/chunks/{692dfeb2e255fdc0ade2.js → 39288fa69561d21f04f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2b9d3e60977934a6d471.js → 3bc6b5f0643364749ef8.js} +1 -1
- package/assets/esri/core/workers/chunks/45e5ad704d18dd0857ce.js +1 -0
- package/assets/esri/core/workers/chunks/4d24efa01d1accc5a5f0.js +1 -0
- package/assets/esri/core/workers/chunks/{6312783626bacf52df7a.js → 55486c644e8b01326a0d.js} +1 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +1 -0
- package/assets/esri/core/workers/chunks/{62d9d15f0d00a75da42c.js → 571dac507622948ac03e.js} +1 -1
- package/assets/esri/core/workers/chunks/59063d6abf70f6598425.js +1 -0
- package/assets/esri/core/workers/chunks/5a4c04bf4f57e74457c5.js +1 -0
- package/assets/esri/core/workers/chunks/5bf04c32e0ac89dcbf9f.js +1 -0
- package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js +2 -0
- package/assets/esri/core/workers/chunks/{55ca6ba8b40921025181.js.LICENSE.txt → 6a3d611e8842afbb50ab.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/70d6e5edf05ef7079fa8.js +1 -0
- package/assets/esri/core/workers/chunks/71bdf8f10aee0077f681.js +1 -0
- package/assets/esri/core/workers/chunks/72b2c3c8e76da699690c.js +1 -0
- package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +1 -0
- package/assets/esri/core/workers/chunks/791f529e90135398b3d5.js +1 -0
- package/assets/esri/core/workers/chunks/8d3abfe6fdc5ac8d6cb7.js +1 -0
- package/assets/esri/core/workers/chunks/{1edc5c06874cb12c5478.js → 924e4a18d8403d1caea3.js} +1 -1
- package/assets/esri/core/workers/chunks/96d339abcd917f1f0ae1.js +1 -0
- package/assets/esri/core/workers/chunks/97cdbec7532cfcdf9ad2.js +1 -0
- package/assets/esri/core/workers/chunks/{f3f6035a17f7dcd19675.js → 9ab400a89dd701778d2c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1488b3d48232844b8bb4.js → 9fe349f43d5ff5a4ac2d.js} +1 -1
- package/assets/esri/core/workers/chunks/{22396dd3717d17a5d235.js → a1c31bb8c12831539328.js} +1 -1
- package/assets/esri/core/workers/chunks/b0571b9e602218cdc7aa.js +1 -0
- package/assets/esri/core/workers/chunks/b1d88f8e528bf7092f35.js +1 -0
- package/assets/esri/core/workers/chunks/b4e2dc6b3d06b426e596.js +1 -0
- package/assets/esri/core/workers/chunks/{48abcb2d88f22e6e9fde.js → c2cb9fa18c77f0c5104e.js} +1 -1
- package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +1 -0
- package/assets/esri/core/workers/chunks/d08800a30b1227591986.js +1 -0
- package/assets/esri/core/workers/chunks/d725dbbdeb05322e6d88.js +1 -0
- package/assets/esri/core/workers/chunks/df3e497d12ed77bae168.js +1 -0
- package/assets/esri/core/workers/chunks/fb080339bfaf32731ca6.js +1 -0
- package/assets/esri/core/workers/chunks/{56fc7924b4fb30239c19.js → fdf58386a67e54c09bfb.js} +1 -1
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +86 -96
- package/assets/esri/themes/base/widgets/_FloorFilter.scss +6 -0
- package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +40 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip.json +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip_en.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ar.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bg.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ca.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_cs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_da.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_de.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_el.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_en.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_es.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_et.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_he.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hu.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_id.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_it.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ja.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ko.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lt.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nb.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-BR.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-PT.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ro.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ru.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_th.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_tr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_uk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_vi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-CN.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-HK.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-TW.json +1 -1
- package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
- package/chunks/arcgis-knowledge-client-core.js +1 -1
- package/chunks/mat4.js +1 -1
- package/core/accessorSupport/write.js +1 -1
- package/core/fontUtils.js +1 -1
- package/core/libs/gl-matrix-2/math/mat4.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.js +5 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.js +5 -0
- package/geometry/support/MeshLocalVertexSpace.d.ts +4 -0
- package/geometry/support/MeshLocalVertexSpace.js +5 -0
- package/geometry/support/MeshTransform.d.ts +4 -0
- package/geometry/support/MeshTransform.js +1 -1
- package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
- package/geometry/support/meshUtils/centerAt.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/geographicUtils.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/offset.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/interfaces.d.ts +227 -25
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/SessionMemoryStorage.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
- package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
- package/layers/support/rasterFunctions/CompositeBandFunction.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +2 -2
- package/popup/FieldInfo.js +1 -1
- package/portal/Portal.js +1 -1
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/smartMapping/symbology/color.js +1 -1
- package/smartMapping/symbology/support/colors.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/undoRecords.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/symbolComplexity.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +1 -1
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/helpMessageUtils.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/layers/StreamLayerView.js +1 -1
- package/widgets/BasemapGallery/css.js +1 -1
- package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +5 -0
- package/widgets/UtilityNetworkValidateTopology.js +5 -0
- package/widgets/support/widgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/163bf2e13abbdd298374.js +0 -1
- package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +0 -1
- package/assets/esri/core/workers/chunks/2640204c4655aa535ccb.js +0 -1
- package/assets/esri/core/workers/chunks/2bf42d060f877566b989.js +0 -1
- package/assets/esri/core/workers/chunks/34ec9623a1bece86a82b.js +0 -1
- package/assets/esri/core/workers/chunks/3bf52139340827794c3b.js +0 -1
- package/assets/esri/core/workers/chunks/3cebdd77a8401495097f.js +0 -1
- package/assets/esri/core/workers/chunks/48cb634255e39711a720.js +0 -1
- package/assets/esri/core/workers/chunks/4d5f71d84c85f45c97ea.js +0 -1
- package/assets/esri/core/workers/chunks/52d02021e858820bc4fa.js +0 -1
- package/assets/esri/core/workers/chunks/55ca6ba8b40921025181.js +0 -2
- package/assets/esri/core/workers/chunks/64b8f65e2ef6cbf08380.js +0 -1
- package/assets/esri/core/workers/chunks/662e479c370c11bcb8a7.js +0 -1
- package/assets/esri/core/workers/chunks/78aede1e114deefacb54.js +0 -1
- package/assets/esri/core/workers/chunks/7ef100158ca28631fcaf.js +0 -1
- package/assets/esri/core/workers/chunks/93ad67930aa7d4a4b0ac.js +0 -1
- package/assets/esri/core/workers/chunks/964795dfb57f0d0635d0.js +0 -1
- package/assets/esri/core/workers/chunks/99ce0a202dcd3d7dc290.js +0 -1
- package/assets/esri/core/workers/chunks/abe6c99a1a719543dbe8.js +0 -1
- package/assets/esri/core/workers/chunks/c3bf44146fddfe8990f7.js +0 -1
- package/assets/esri/core/workers/chunks/cbe817e966b57599bafd.js +0 -1
- package/assets/esri/core/workers/chunks/e15b5d7e46a834eacc57.js +0 -1
- package/assets/esri/core/workers/chunks/e1e0b3580e2c3098c9f4.js +0 -1
- package/assets/esri/core/workers/chunks/e305d20e4424451cab5b.js +0 -1
- package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.js +0 -1
- package/assets/esri/core/workers/chunks/f924732902703233655e.js +0 -1
- package/assets/esri/core/workers/chunks/ff1c005eede0cf964332.js +0 -1
package/Graphic.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"./chunks/tslib.es6.js";import{geometryTypes as e}from"./geometry.js";import r from"./PopupTemplate.js";import{symbolTypes as
|
|
5
|
+
import{_ as t}from"./chunks/tslib.es6.js";import{geometryTypes as e}from"./geometry.js";import r from"./PopupTemplate.js";import{symbolTypes as o}from"./symbols.js";import{ClonableMixin as s}from"./core/Clonable.js";import{JSONSupport as i}from"./core/JSONSupport.js";import{generateUID as a}from"./core/uid.js";import{property as l}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import"./core/arrayUtils.js";import"./core/has.js";import{subclass as p}from"./core/accessorSupport/decorators/subclass.js";import{fromJSON as n}from"./geometry/support/jsonUtils.js";var u;function y(t){if(!t)return null;const e={};for(const r in t){const o=n(t[r]);o&&(e[r]=o)}return 0!==Object.keys(e).length?e:null}function m(t){if(null==t)return null;const e={};for(const r in t){const o=t[r];o&&(e[r]=o.toJSON())}return 0!==Object.keys(e).length?e:null}let g=u=class extends(s(i)){constructor(...t){super(...t),this.isAggregate=!1,this.layer=null,this.popupTemplate=null,this.sourceLayer=null,Object.defineProperty(this,"uid",{value:a(),configurable:!0})}normalizeCtorArgs(t,e,r,o){return t&&!t.declaredClass?t:{geometry:t,symbol:e,attributes:r,popupTemplate:o}}set aggregateGeometries(t){const e=this._get("aggregateGeometries");JSON.stringify(e)!==JSON.stringify(t)&&this._set("aggregateGeometries",t)}set attributes(t){const e=this._get("attributes");e!==t&&(this._set("attributes",t),this._notifyLayer("attributes",e,t))}set geometry(t){const e=this._get("geometry");e!==t&&(this._set("geometry",t),this._notifyLayer("geometry",e,t))}set symbol(t){const e=this._get("symbol");e!==t&&(this._set("symbol",t),this._notifyLayer("symbol",e,t))}set visible(t){const e=this._get("visible");e!==t&&(this._set("visible",t),this._notifyLayer("visible",e,t))}cloneShallow(){return new u({aggregateGeometries:this.aggregateGeometries,attributes:this.attributes,geometry:this.geometry,isAggregate:this.isAggregate,layer:this.layer,popupTemplate:this.popupTemplate,sourceLayer:this.sourceLayer,symbol:this.symbol,visible:this.visible})}getEffectivePopupTemplate(t=!1){if(this.popupTemplate)return this.popupTemplate;for(const e of[this.sourceLayer,this.layer])if(e){if("popupTemplate"in e&&e.popupTemplate)return e.popupTemplate;if(t&&"defaultPopupTemplate"in e&&null!=e.defaultPopupTemplate)return e.defaultPopupTemplate}return null}getAttribute(t){return this.attributes?.[t]}setAttribute(t,e){if(this.attributes){const r=this.getAttribute(t);this.attributes[t]=e,this._notifyLayer("attributes",r,e,t)}else this.attributes={[t]:e},this._notifyLayer("attributes",void 0,e,t)}getObjectId(){return this.sourceLayer&&"objectIdField"in this.sourceLayer&&this.sourceLayer.objectIdField?this.getAttribute(this.sourceLayer.objectIdField):null}toJSON(){return{aggregateGeometries:m(this.aggregateGeometries),geometry:null!=this.geometry?this.geometry.toJSON():null,symbol:null!=this.symbol?this.symbol.toJSON():null,attributes:{...this.attributes},popupTemplate:this.popupTemplate&&this.popupTemplate.toJSON()}}notifyGeometryChanged(){this._notifyLayer("geometry",this.geometry,this.geometry)}notifyMeshTransformChanged(t={}){const{geometry:e}=this;if("mesh"===e?.type){const r={origin:e.origin,transform:e.transform};this._notifyLayer("origin-transform",r,r,t.action)}}_notifyLayer(t,e,r,o){if(!this.layer||!("graphicChanged"in this.layer))return;const s={graphic:this,property:t,oldValue:e,newValue:r};"origin-transform"===t&&(s.action=o),"attributes"===t&&(s.attributeName=o),this.layer.graphicChanged(s)}};t([l({value:null,json:{read:y}})],g.prototype,"aggregateGeometries",null),t([l({value:null})],g.prototype,"attributes",null),t([l({value:null,types:e,json:{read:n}})],g.prototype,"geometry",null),t([l({type:Boolean})],g.prototype,"isAggregate",void 0),t([l({clonable:"reference"})],g.prototype,"layer",void 0),t([l({type:r})],g.prototype,"popupTemplate",void 0),t([l({clonable:"reference"})],g.prototype,"sourceLayer",void 0),t([l({value:null,types:o})],g.prototype,"symbol",null),t([l({type:Boolean,value:!0})],g.prototype,"visible",null),g=u=t([p("esri.Graphic")],g),function(t){t.generateUID=a}(g||(g={}));const h=g;export{h 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.27/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{isSome 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{MultiOriginJSONMixin as m,MultiOriginJSONSupport as u}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{eachAlways as d}from"./core/promiseUtils.js";import{whenOnce as c}from"./core/reactiveUtils.js";import{urlToObject as y,hasSameCanonicalArcGISOnlinePortal as w,isDataProtocol as f,dataComponents as g,addQueryParameter as b}from"./core/urlUtils.js";import{property as _}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import"./core/has.js";import{reader as v}from"./core/accessorSupport/decorators/reader.js";import{subclass as A}from"./core/accessorSupport/decorators/subclass.js";import{writer as I}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as S}from"./core/accessorSupport/originUtils.js";import{readLoadable as j}from"./core/accessorSupport/read.js";import U from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as O}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as L}from"./layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as R,isFeatureCollectionLayer as V}from"./layers/support/layerUtils.js";import T from"./networks/UtilityNetwork.js";import F from"./portal/Portal.js";import W from"./portal/PortalItem.js";import{removeTypeKeyword as k,addTypeKeyword as N,hasTypeKeyword as E,TypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as C}from"./rest/geometryService/project.js";import x from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as B,isDeveloperBasemapLayer as J,findSpatialReference as D}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import K from"./webdoc/GeotriggersInfo.js";import $ from"./webdoc/RangeInfo.js";import z from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as q}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as H}from"./webdoc/support/writeUtils.js";import Q from"./webmap/ApplicationProperties.js";import X from"./webmap/Bookmark.js";import Y from"./webmap/InitialViewProperties.js";import{computeInitialViewpoint as Z}from"./webmap/initialViewPropertiesUtils.js";import{Version as ee}from"./webmap/Version.js";import te from"./webmap/background/ColorBackground.js";const re=new ee(2,28),ie="Web Map",oe=a.ofType(X),ae=a.ofType(T),se=new Map;se.set("image/jpeg","jpeg"),se.set("image/jpg","jpg"),se.set("image/png","png"),se.set("image/gif","gif");const ne="ArcGIS Pro",le=M.JSAPI,pe="CollectorDisabled",me="Collector",ue="Data Editing",he="OfflineDisabled",de="Offline",ce="Workforce Project",ye="Workforce Worker",we="Workforce Dispatcher",fe="Offline Map Areas",ge="FieldMapsDisabled",be=M.DEVELOPER_BASEMAP,_e="UtilityNetwork",ve=["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 Ae=class extends(m(n.LoadableMixin(h(r)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this._resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new oe,this.floorInfo=null,this.geotriggersInfo=null,this.initialViewProperties=new Y,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,e?.destroy()}initialize(){if(this.when().catch((e=>{p.getLogger(this).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=le}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){const r=new Y;t.background&&(r.background=te.fromJSON(t.background));const o=t.initialState?.viewpoint;if(o){if(o.rotation){ee.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ne&&(o.rotation*=-1)}r.viewpoint=i.fromJSON(o)}return t.mapRangeInfo&&(r.rangeInfo=$.fromJSON(t.mapRangeInfo)),t.spatialReference&&(r.spatialReference=U.fromJSON(t.spatialReference)),r}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 ee(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${re.major}.${re.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();j(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 p.getLogger(this).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();const t=import("./webdoc/support/saveUtils.js");await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const r=this.portalItem,i=y(r.itemUrl),o={origin:"web-map",messages:[],writtenProperties:[],url:i,portal:r.portal||F.getDefault(),portalItem:r,verifyItemRelativeUrls:i?{rootPath:i.path,writtenUrls:[]}:null,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},a=this.write({},o);return await Promise.all(o.resources.pendingOperations),this._validateJSONForWriting(o,e),await this._updateItemProperties(r),await this._updateItem(r,a,o),await Promise.all([this._updateItemThumbnail(),t.then((({saveResources:e})=>e(this._resourceReferences,o,null)))]),r}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e),i=import("./webdoc/support/saveUtils.js");await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const o={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal,portalItem:r,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},a=this.write({},o);await Promise.all(o.resources.pendingOperations),this._validateJSONForWriting(o,t),await this._updateItemPropertiesForSaveAs(r);const s=this._getThumbnailState();return await this._createItem(r,a,o,t)&&(this._resourceReferences.portalItem=r),this._restoreThumbnailFromState(s),await Promise.all([this._updateItemThumbnail(),i.then((({saveResources:e})=>e(this._resourceReferences,o,null)))]),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.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=>H(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t))).filter(o).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve()}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})),"Web Map"!==e.type)throw new s("webmap:invalid-portal-item",`Invalid portal item type '${e.type}', expected 'Web Map'`,{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-map",url:y(e.itemUrl),portal:e.portal||F.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]};const i=await Z(this.initialViewProperties,e,p.getLogger(this));if(i){const e=this.initialViewProperties?.clone()??new Y;e.viewpoint=i,this.initialViewProperties=e}}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=ee.parse(e.version||"","webmap");return re.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||F.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)),d(i).then((()=>{}))}))}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>this.allLayers.some((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.some((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(){if(!this.basemap?.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let e=null;if(await c((()=>{const t=D(this.initialViewProperties,this.basemap);return e=t.spatialReference,!t.updating})),!P(e,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:e})}_validateItem(){if(!this.portalItem)throw p.getLogger(this).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!==ie)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ie}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),d(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 d(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return d(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(e.blockedRelativeUrls&&(r=r.concat(e.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Map`))))),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){k(e,pe),k(e,ge),k(e,M.METADATA),k(e,he),k(e,fe),k(e,we),k(e,ce),k(e,ye),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 O(e);const{getGeometryServiceURL:r}=await import("./portal/support/geometryServiceUtils.js"),i=await r(this.portalItem),o=new x;o.geometries=[e],o.outSpatialReference=U.WGS84;return(await C(i,o))[0]}async _updateTypeKeywords(e){N(e,le),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),this._evalUtilityNetworkKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){E(e,pe)||E(e,ce)||E(e,ye)||E(e,we)||!this._hasEditableFeatureLayer()?k(e,me):N(e,me)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?N(e,ue):k(e,ue)}_evalOfflineKeyword(e){!E(e,he)&&this._isOfflineCapableMap()?N(e,de):k(e,de)}_evalDeveloperBasemapKeyword(e){B(this.basemap)?N(e,be):k(e,be)}_evalUtilityNetworkKeyword(e){this.utilityNetworks?.length?N(e,_e):k(e,_e)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&R(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isFeatureCollectionLike(e){return V(e)||"map-notes"===e.type||"route"===e.type}_isOfflineCapableLayer(e){return R(e)&&e.capabilities.operations.supportsSync||this._isFeatureCollectionLike(e)&&!e.portalItem||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||J(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(L(e.url)&&ve.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={item:o,authenticated:!(!o?.id||!o.portal.user)},n=e.portal;await n.signIn();const{copyAllowed:l,itemReloaded:p}=await this._isCopyAllowed(a,n);if(a.authenticated||=p,!l)throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");const m=await this._initializeNewItem(e,a,t,i);return this.portalItem=e,this._syncUpInstanceWithItem(e,t,r),m}async _isCopyAllowed(e,t){const{item:r,authenticated:i}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(i||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async _initializeNewItem(e,t,r,i){const o=e.portal,{item:a,authenticated:s}=t,{folder:n,copyAllResources:l}=i;let p=!1;if(l&&a?.id&&w(a.portal.url,o.url)&&(s||await a.reload(),a.isOrgItem)){const{total:e}=await a.fetchResources();p=!!e}if(p){const t=await a.copy({copyResources:"all",folder:n});e.id=t.id,e.portal=t.portal;const i=e.toJSON();await e.load(),e.read(i),await e.update({data:r})}else await(o.user?.addItem({item:e,folder:n,data:r}));return p}_syncUpInstanceWithItem(e,t,r){u.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl?y(e.itemUrl):void 0}),S(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=W.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ie),t.portal||(t.portal=F.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await c((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)"visible"in r&&"visible"in r.layer&&r._isOverridden("visible")&&(r.layer.visible=r.visible),"featureEffect"in r&&"featureEffect"in r.layer&&r._isOverridden("featureEffect")&&(r.layer.featureEffect=r.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),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 r of e.persistableViewModels)r.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=q(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(f(e)){const t=g(e),r=t&&t.mediaType,i=r&&se.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:b(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})}};Ae.VERSION=re,e([_({type:Q,json:{write:!0}})],Ae.prototype,"applicationProperties",void 0),e([_({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],Ae.prototype,"authoringApp",null),e([I("authoringApp")],Ae.prototype,"writeAuthoringApp",null),e([_({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],Ae.prototype,"authoringAppVersion",null),e([I("authoringAppVersion")],Ae.prototype,"writeAuthoringAppVersion",null),e([_({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],Ae.prototype,"basemap",void 0),e([_({type:oe,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],Ae.prototype,"bookmarks",void 0),e([_({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],Ae.prototype,"floorInfo",void 0),e([_({type:K,json:{write:!0}})],Ae.prototype,"geotriggersInfo",void 0),e([_({type:Y,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:te},"initialState.viewpoint":{type:i},mapRangeInfo:{type:$},spatialReference:{type:U}}}}})],Ae.prototype,"initialViewProperties",void 0),e([v("initialViewProperties")],Ae.prototype,"readInitialViewProperties",null),e([I("initialViewProperties")],Ae.prototype,"writeInitialViewProperties",null),e([_({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],Ae.prototype,"layers",void 0),e([I("layers")],Ae.prototype,"writeLayers",null),e([_({type:W})],Ae.prototype,"portalItem",void 0),e([_({json:{write:!0}})],Ae.prototype,"presentation",void 0),e([_()],Ae.prototype,"resourceInfo",void 0),e([_({readOnly:!0,type:ee,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],Ae.prototype,"sourceVersion",void 0),e([v("sourceVersion")],Ae.prototype,"readSourceVersion",null),e([I("sourceVersion")],Ae.prototype,"writeSourceVersion",null),e([_({json:{read:!1,write:{ignoreOrigin:!0}}})],Ae.prototype,"tables",void 0),e([I("tables")],Ae.prototype,"writeTables",null),e([_()],Ae.prototype,"thumbnailUrl",null),e([_({type:z,json:{write:!0}})],Ae.prototype,"widgets",void 0),e([_({type:ae,json:{read:!0,write:!0}})],Ae.prototype,"utilityNetworks",void 0),Ae=e([A("esri.WebMap")],Ae);const Ie=Ae;export{Ie 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{isSome 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{MultiOriginJSONMixin as m,MultiOriginJSONSupport as u}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{eachAlways as d}from"./core/promiseUtils.js";import{whenOnce as c}from"./core/reactiveUtils.js";import{urlToObject as y,hasSameCanonicalArcGISOnlinePortal as w,isDataProtocol as f,dataComponents as g,addQueryParameter as b}from"./core/urlUtils.js";import{property as _}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import"./core/has.js";import{reader as v}from"./core/accessorSupport/decorators/reader.js";import{subclass as A}from"./core/accessorSupport/decorators/subclass.js";import{writer as I}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as S}from"./core/accessorSupport/originUtils.js";import{readLoadable as j}from"./core/accessorSupport/read.js";import U from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as O}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as L}from"./layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as R,isFeatureCollectionLayer as V}from"./layers/support/layerUtils.js";import T from"./networks/UtilityNetwork.js";import F from"./portal/Portal.js";import W from"./portal/PortalItem.js";import{removeTypeKeyword as k,addTypeKeyword as N,hasTypeKeyword as E,TypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as C}from"./rest/geometryService/project.js";import x from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as B,isDeveloperBasemapLayer as J,findSpatialReference as D}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import K from"./webdoc/GeotriggersInfo.js";import $ from"./webdoc/RangeInfo.js";import z from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as q}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as H}from"./webdoc/support/writeUtils.js";import Q from"./webmap/ApplicationProperties.js";import X from"./webmap/Bookmark.js";import Y from"./webmap/InitialViewProperties.js";import{computeInitialViewpoint as Z}from"./webmap/initialViewPropertiesUtils.js";import{Version as ee}from"./webmap/Version.js";import te from"./webmap/background/ColorBackground.js";const re=new ee(2,28),ie="Web Map",oe=a.ofType(X),ae=a.ofType(T),se=new Map;se.set("image/jpeg","jpeg"),se.set("image/jpg","jpg"),se.set("image/png","png"),se.set("image/gif","gif");const ne="ArcGIS Pro",le=M.JSAPI,pe="CollectorDisabled",me="Collector",ue="Data Editing",he="OfflineDisabled",de="Offline",ce="Workforce Project",ye="Workforce Worker",we="Workforce Dispatcher",fe="Offline Map Areas",ge="FieldMapsDisabled",be=M.DEVELOPER_BASEMAP,_e="UtilityNetwork",ve=["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 Ae=class extends(m(n.LoadableMixin(h(r)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this._resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new oe,this.floorInfo=null,this.geotriggersInfo=null,this.initialViewProperties=new Y,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,e?.destroy()}initialize(){if(this.when().catch((e=>{p.getLogger(this).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=le}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){const r=new Y;t.background&&(r.background=te.fromJSON(t.background));const o=t.initialState?.viewpoint;if(o){if(o.rotation){ee.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ne&&(o.rotation*=-1)}r.viewpoint=i.fromJSON(o)}return t.mapRangeInfo&&(r.rangeInfo=$.fromJSON(t.mapRangeInfo)),t.spatialReference&&(r.spatialReference=U.fromJSON(t.spatialReference)),r}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 ee(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${re.major}.${re.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();j(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 p.getLogger(this).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();const t=import("./webdoc/support/saveUtils.js");await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const r=this.portalItem,i=y(r.itemUrl),o={origin:"web-map",messages:[],writtenProperties:[],url:i,portal:r.portal||F.getDefault(),portalItem:r,verifyItemRelativeUrls:i?{rootPath:i.path,writtenUrls:[]}:null,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},a=this.write({},o);return await Promise.all(o.resources.pendingOperations),this._validateJSONForWriting(o,e),await this._updateItemProperties(r),await this._updateItem(r,a,o),await Promise.all([this._updateItemThumbnail(),t.then((({saveResources:e})=>e(this._resourceReferences,o,null)))]),r}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e),i=import("./webdoc/support/saveUtils.js");await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const o={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal,portalItem:r,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},a=this.write({},o);await Promise.all(o.resources.pendingOperations),this._validateJSONForWriting(o,t),await this._updateItemPropertiesForSaveAs(r);const s=this._getThumbnailState();return await this._createItem(r,a,o,t)&&(this._resourceReferences.portalItem=r),this._restoreThumbnailFromState(s),await Promise.all([this._updateItemThumbnail(),i.then((({saveResources:e})=>e(this._resourceReferences,o,null)))]),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.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=>H(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t))).filter(o).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve()}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})),"Web Map"!==e.type)throw new s("webmap:invalid-portal-item",`Invalid portal item type '${e.type}', expected 'Web Map'`,{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-map",url:y(e.itemUrl),portal:e.portal||F.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]};const i=await Z(this.initialViewProperties,e,p.getLogger(this));if(i){const e=this.initialViewProperties?.clone()??new Y;e.viewpoint=i,this.initialViewProperties=e}}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=ee.parse(e.version||"","webmap");return re.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||F.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)),d(i).then((()=>{}))}))}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>this.allLayers.some((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.some((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(){if(!this.basemap?.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let e=null;if(await c((()=>{const t=D(this.initialViewProperties,this.basemap);return e=t.spatialReference,!t.updating})),!P(e,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:e})}_validateItem(){if(!this.portalItem)throw p.getLogger(this).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!==ie)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ie}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),d(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 d(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return d(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(e.blockedRelativeUrls&&(r=r.concat(e.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Map`))))),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){k(e,pe),k(e,ge),k(e,M.METADATA),k(e,he),k(e,fe),k(e,we),k(e,ce),k(e,ye),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 O(e);const{getGeometryServiceURL:r}=await import("./portal/support/geometryServiceUtils.js"),i=await r(this.portalItem),o=new x;o.geometries=[e],o.outSpatialReference=U.WGS84;return(await C(i,o))[0]}async _updateTypeKeywords(e){N(e,le),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),this._evalUtilityNetworkKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){E(e,pe)||E(e,ce)||E(e,ye)||E(e,we)||!this._hasEditableFeatureLayer()?k(e,me):N(e,me)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?N(e,ue):k(e,ue)}_evalOfflineKeyword(e){!E(e,he)&&this._isOfflineCapableMap()?N(e,de):k(e,de)}_evalDeveloperBasemapKeyword(e){B(this.basemap)?N(e,be):k(e,be)}_evalUtilityNetworkKeyword(e){this.utilityNetworks?.length?N(e,_e):k(e,_e)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&R(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isFeatureCollectionLike(e){return V(e)||"map-notes"===e.type||"route"===e.type}_isOfflineCapableLayer(e){return R(e)&&e.capabilities.operations.supportsSync||this._isFeatureCollectionLike(e)&&!e.portalItem||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||J(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(L(e.url)&&ve.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={item:o,authenticated:!(!o?.id||!o.portal.user)},n=e.portal;await n.signIn();const{copyAllowed:l,itemReloaded:p}=await this._isCopyAllowed(a,n);if(a.authenticated||=p,!l)throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");const m=await this._initializeNewItem(e,a,t,i);return this.portalItem=e,this._syncUpInstanceWithItem(e,t,r),m}async _isCopyAllowed(e,t){const{item:r,authenticated:i}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(i||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async _initializeNewItem(e,t,r,i){const o=e.portal,{item:a}=t,{folder:s,copyAllResources:n}=i;let l=!1;if(n&&a?.id&&w(a.portal.url,o.url)){const{total:e}=await a.fetchResources();l=!!e}if(l){const t=await a.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const i=e.toJSON();await e.load(),e.read(i),await e.update({data:r})}else await(o.user?.addItem({item:e,folder:s,data:r}));return l}_syncUpInstanceWithItem(e,t,r){u.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl?y(e.itemUrl):void 0}),S(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=W.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ie),t.portal||(t.portal=F.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await c((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)"visible"in r&&"visible"in r.layer&&r._isOverridden("visible")&&(r.layer.visible=r.visible),"featureEffect"in r&&"featureEffect"in r.layer&&r._isOverridden("featureEffect")&&(r.layer.featureEffect=r.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),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 r of e.persistableViewModels)r.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=q(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(f(e)){const t=g(e),r=t&&t.mediaType,i=r&&se.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:b(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})}};Ae.VERSION=re,e([_({type:Q,json:{write:!0}})],Ae.prototype,"applicationProperties",void 0),e([_({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],Ae.prototype,"authoringApp",null),e([I("authoringApp")],Ae.prototype,"writeAuthoringApp",null),e([_({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],Ae.prototype,"authoringAppVersion",null),e([I("authoringAppVersion")],Ae.prototype,"writeAuthoringAppVersion",null),e([_({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],Ae.prototype,"basemap",void 0),e([_({type:oe,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],Ae.prototype,"bookmarks",void 0),e([_({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],Ae.prototype,"floorInfo",void 0),e([_({type:K,json:{write:!0}})],Ae.prototype,"geotriggersInfo",void 0),e([_({type:Y,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:te},"initialState.viewpoint":{type:i},mapRangeInfo:{type:$},spatialReference:{type:U}}}}})],Ae.prototype,"initialViewProperties",void 0),e([v("initialViewProperties")],Ae.prototype,"readInitialViewProperties",null),e([I("initialViewProperties")],Ae.prototype,"writeInitialViewProperties",null),e([_({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],Ae.prototype,"layers",void 0),e([I("layers")],Ae.prototype,"writeLayers",null),e([_({type:W})],Ae.prototype,"portalItem",void 0),e([_({json:{write:!0}})],Ae.prototype,"presentation",void 0),e([_()],Ae.prototype,"resourceInfo",void 0),e([_({readOnly:!0,type:ee,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],Ae.prototype,"sourceVersion",void 0),e([v("sourceVersion")],Ae.prototype,"readSourceVersion",null),e([I("sourceVersion")],Ae.prototype,"writeSourceVersion",null),e([_({json:{read:!1,write:{ignoreOrigin:!0}}})],Ae.prototype,"tables",void 0),e([I("tables")],Ae.prototype,"writeTables",null),e([_()],Ae.prototype,"thumbnailUrl",null),e([_({type:z,json:{write:!0}})],Ae.prototype,"widgets",void 0),e([_({type:ae,json:{read:!0,write:!0}})],Ae.prototype,"utilityNetworks",void 0),Ae=e([A("esri.WebMap")],Ae);const Ie=Ae;export{Ie 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../sources/Empty.js";import{FeatureSetError as t,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import n from"../support/IdSet.js";import{IdState as a,shapeExtent as s}from"../support/shared.js";import{relate as o,crosses as l,touches as u,within as h,overlaps as _,contains as c,intersects as p}from"../../../geometry/geometryEngineAsync.js";class f extends r{constructor(e){super(e),this._relation="",this._relationGeom=null,this._relationString="",this.declaredClass="esri.arcade.featureset.actions.SpatialFilter",this._relationString=e.relationString,this._parent=e.parentfeatureset,this._maxProcessing=40,this._relation=e.relation,this._relationGeom=e.relationGeom}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,null,null,e);return this._checkCancelled(e),this._wset=new n(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===a.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?a.Unknown:t)}_getFeature(e,t,i){return this._parent._getFeature(e,t,i)}_getFeatures(e,t,i,r){return this._parent._getFeatures(e,t,i,r)}_featureFromCache(e){return this._parent._featureFromCache(e)}async executeSpatialRelationTest(e){if(null===e.geometry)return!1;switch(this._relation){case"esriSpatialRelEnvelopeIntersects":
|
|
5
|
+
import e from"../sources/Empty.js";import{FeatureSetError as t,FeatureSetErrorCodes as i}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import n from"../support/IdSet.js";import{IdState as a,shapeExtent as s}from"../support/shared.js";import{relate as o,crosses as l,touches as u,within as h,overlaps as _,contains as c,intersects as p}from"../../../geometry/geometryEngineAsync.js";class f extends r{constructor(e){super(e),this._relation="",this._relationGeom=null,this._relationString="",this.declaredClass="esri.arcade.featureset.actions.SpatialFilter",this._relationString=e.relationString,this._parent=e.parentfeatureset,this._maxProcessing=40,this._relation=e.relation,this._relationGeom=e.relationGeom}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,null,null,e);return this._checkCancelled(e),this._wset=new n(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===a.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?a.Unknown:t)}_getFeature(e,t,i){return this._parent._getFeature(e,t,i)}_getFeatures(e,t,i,r){return this._parent._getFeatures(e,t,i,r)}_featureFromCache(e){return this._parent._featureFromCache(e)}async executeSpatialRelationTest(e){if(null===e.geometry)return!1;switch(this._relation){case"esriSpatialRelEnvelopeIntersects":return p(s(this._relationGeom),s(e.geometry));case"esriSpatialRelIntersects":return p(this._relationGeom,e.geometry);case"esriSpatialRelContains":return c(this._relationGeom,e.geometry);case"esriSpatialRelOverlaps":return _(this._relationGeom,e.geometry);case"esriSpatialRelWithin":return h(this._relationGeom,e.geometry);case"esriSpatialRelTouches":return u(this._relationGeom,e.geometry);case"esriSpatialRelCrosses":return l(this._relationGeom,e.geometry);case"esriSpatialRelRelation":return o(this._relationGeom,e.geometry,this._relationString??"")}}async _fetchAndRefineFeatures(e,t,i){const r=new n([],e,!1,null),s=Math.min(t,e.length);await(this._parent?._getFeatures(r,-1,s,i)),this._checkCancelled(i);const o=[];for(let n=0;n<s;n++){const t=this._parent._featureFromCache(e[n]);o.push(await this.executeSpatialRelationTest(t))}for(let n=0;n<t;n++)!0===o[n]?this._idstates[e[n]]=a.InFeatureSet:this._idstates[e[n]]=a.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,i,r,a){await this._ensureLoaded();const s=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,i,r,a);let o;return this._checkCancelled(a),o=null!==t?new n(s._candidates.slice(0).concat(s._known.slice(0)),[],s._ordered,this._clonePageDefinition(s.pagesDefinition)):new n(s._candidates.slice(0),s._known.slice(0),s._ordered,this._clonePageDefinition(s.pagesDefinition)),o}async _stat(e,t,i,r,n,a,s){if(""!==i)return{calculated:!1};const o=await this._parent._stat(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n,a,s);return!1===o.calculated?null===n&&""===i&&null===r?this._manualStat(e,t,a,s):{calculated:!1}:o}async _canDoAggregates(e,t,i,r,n){return""===i&&null===r&&(null!==this._parent&&this._parent._canDoAggregates(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n))}async _getAggregatePagesDataSourceDefinition(e,r,n,a,s,o,l){if(null===this._parent)throw new t(i.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,r,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,s,o,l)}static registerAction(){r._featuresetFunctions.intersects=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelIntersects",relationGeom:t})},r._featuresetFunctions.envelopeIntersects=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelEnvelopeIntersects",relationGeom:t})},r._featuresetFunctions.contains=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelContains",relationGeom:t})},r._featuresetFunctions.overlaps=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelOverlaps",relationGeom:t})},r._featuresetFunctions.within=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelWithin",relationGeom:t})},r._featuresetFunctions.touches=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelTouches",relationGeom:t})},r._featuresetFunctions.crosses=function(t){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelCrosses",relationGeom:t})},r._featuresetFunctions.relate=function(t,i){return null==t?new e({parentfeatureset:this}):new f({parentfeatureset:this,relation:"esriSpatialRelRelation",relationGeom:t,relationString:i})}}}export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../../../request.js";import i from"../../Attachment.js";import r 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 c}from"../support/sqlUtils.js";import{decodeStatType as h}from"../support/stats.js";import{createMD5Hash as p,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{fromJSON as m}from"../../../geometry/support/jsonUtils.js";import _ from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as g}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as R}from"../../../rest/query/executeQueryJSON.js";import"../../../config.js";import"../../../core/arrayUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import{executeQueryPBF as S}from"../../../rest/query/operations/query.js";import w from"../../../rest/support/FeatureSet.js";import F from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as b}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeForIds as D}from"../../../rest/query/executeForIds.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as I}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import x from"../../../rest/support/StatisticDefinition.js";import T from"../../Dictionary.js";import{FeatureSetError as C,FeatureSetErrorCodes as P}from"../support/errorsupport.js";import j from"../../../layers/SubtypeGroupLayer.js";class q extends r{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,this._cachedDateMetaData={},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}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+n(e.toJSON());return p(t,y.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.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._layer instanceof j?(this.typeIdField=this._layer.subtypeField??"",this.types=this._layer.subtypes):(this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types)}_isInFeatureSet(){return o.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new F;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){e.quantizationParameters={mode:"edit"};const t=await S(this._layer.parsedUrl,e,new I({}));return w.fromJSON(g(t.data)).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?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 i="execute"===t?R:"executeForCount"===t?b:D,r="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!==r?i(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!==r?i(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}async _getFilteredSet(e,t,i,r,a){const n=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,a);let l="",o=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=r.constructClause(),o=!0);const u=new F;this.datesInUnknownTimezone&&(u.timeReferenceUnknownClient=!0),u.where=null===i?null===t?"1=1":"":d(i,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);let c=await this.executeQuery(u,"executeForIds");null===c&&(c=[]),this._checkCancelled(a);return new s([],c,o,null)}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}async _getFilteredSetUsingPaging(e,t,i,r,a){let n="",l=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=r.constructClause(),l=!0);const o=await this.databaseType();let u=null===i?null===t?"1=1":"":d(i,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let c=this._maxQueryRate();const h=this._layer.capabilities?.query.maxRecordCount;null!=h&&h<c&&(c=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:c,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const r=this._overrideFields??this._fieldsIncludingObjectId(["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:c,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(p,c,0,1,a),p}_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}}async _getPhysicalPage(e,t,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,a=e.pagesDefinition.internal.lastPage,n=new F;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[s+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){const s=[];if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let a=0;for(let u=e._lastFetchedIndex;u<e._known.length;u++){if(e._lastFetchedIndex+=1,a++,void 0===this._featureCache[e._known[u]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[u]]){const r=t._featureMap[e._known[u]];null!==r&&(i=!0,this._featureCache[e._known[u]]=r)}}if(!1===i&&(e._known[u]!==t&&s.push(e._known[u]),s.length>=this._maxProcessingRate()-1))break}if(a>=i&&0===s.length)break}if(0===s.length)return"success";const n=new F;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.objectIds=s,n.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),n.returnGeometry=!0,!0===this._removeGeometry&&(n.returnGeometry=!1),n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(r),void 0!==l.error)throw new C(P.RequestFailed,{reason:l.error});const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return"success"}async _getDistinctPages(e,t,i,r,s,a,n,l,o){await this._ensureLoaded();const u=await this.databaseType();let c=i.parseTree.column;const h=this._layer.fields??[];for(let d=0;d<h.length;d++)if(h[d].name.toLowerCase()===c.toLowerCase()){c=h[d].name;break}const p=new F;this._requestStandardised&&(p.sqlFormat="standard"),this.datesInUnknownTimezone&&(p.timeReferenceUnknownClient=!0);let y=null===a?null===s?"1=1":"":d(a,u);this._layer.definitionExpression&&this._useDefinitionExpression&&(y=""!==y?"(("+this._layer.definitionExpression+") AND ("+y+"))":this._layer.definitionExpression),p.where=y,p.spatialRelationship=this._makeRelationshipEnum(r),p.relationParameter=this._makeRelationshipParam(r),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[c];const f=await this.executeQuery(p,"execute");if(this._checkCancelled(o),!f.hasOwnProperty("features"))throw new C(P.InvalidStatResponse);let m=!1;for(let d=0;d<h.length;d++)if(h[d].name===c){"date"===h[d].type&&(m=!0);break}for(let d=0;d<f.features.length;d++){if(m){const e=f.features[d].attributes[c];null!==e?l.push(new Date(e)):l.push(e)}else l.push(f.features[d].attributes[c]);if(l.length>=n)break}if(0===f.features.length)return l;if(f.features.length===this._layer.capabilities?.query.maxRecordCount&&l.length<n){return{calculated:!0,result:await this._getDistinctPages(e+f.features.length,t,i,r,s,a,n,l,o)}}return l}async _distinctStat(e,t,i,r,s,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,s,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new F;if(this._requestStandardised&&(a.sqlFormat="standard"),this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===r?null===i?"1=1":"":d(r,s);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,r,s,a,n){await this._ensureLoaded();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;if("count"===e)return u?this._countstat(e,i,r,s):{calculated:!1};if(!1===o||!1===c(t)&&!1===l||!1===t.isStandardized)return""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n);if("distinct"===e)return!1===u?""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,i,r,s,a,n);const p=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};const y=new F;this._requestStandardised&&(y.sqlFormat="standard");let f=null===s?null===r?"1=1":"":d(s,p);this._layer.definitionExpression&&this._useDefinitionExpression&&(f=""!==f?"(("+this._layer.definitionExpression+") AND ("+f+"))":this._layer.definitionExpression),y.where=f,y.spatialRelationship=this._makeRelationshipEnum(i),y.relationParameter=this._makeRelationshipParam(i),y.geometry=null===r?null:r,this.datesInUnknownTimezone&&(y.timeReferenceUnknownClient=!0);const m=new x;m.statisticType=h(e),m.onStatisticField=d(t,p),m.outStatisticFieldName="ARCADE_STAT_RESULT",y.returnGeometry=!1;let _="ARCADE_STAT_RESULT";y.outStatistics=[m];const g=await this.executeQuery(y,"execute");if(!g.hasOwnProperty("features")||0===g.features.length)throw new C(P.InvalidStatResponse);let R=!1;const S=g.fields??[];for(let d=0;d<S.length;d++)if("ARCADE_STAT_RESULT"===S[d].name.toUpperCase()){_=S[d].name,"date"===S[d].type&&(R=!0);break}if(R){let e=g.features[0].attributes[_];return null!==e&&(e=new Date(g.features[0].attributes[_])),{calculated:!0,result:e}}return{calculated:!0,result:g.features[0].attributes[_]}}_stat(e,t,i,r,s,a,n){return this._stats(e,t,i,r,s,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const r=this._layer.capabilities?.query,s=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===c(t[a].workingexpr)&&!1===s)&&(i=!1);return!1!==i}_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]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,a,n,l){await this._ensureLoaded();const o=await this.databaseType();let u="",c=!1,h=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),h=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(h=!1,c=!0,u=this._layer.objectIdField);const p=[];for(let s=0;s<t.length;s++){const e=new x;e.onStatisticField=null!==t[s].workingexpr?d(t[s].workingexpr,o):"",e.outStatisticFieldName=t[s].field,e.statisticType=t[s].toStatisticsName(),p.push(e)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;null!=f&&f<y&&(y=f);let m=null===a?null===r?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],h,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:c,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:p,geometry:null===r?null:r,where:m,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,r){let s=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const a=t.pagesDefinition.internal.lastRetrieved,n=a,l=t.pagesDefinition.internal.lastPage,o=new F;if(this._requestStandardised&&(o.sqlFormat="standard"),o.where=s,o.spatialRelationship=t.pagesDefinition.spatialRel,o.relationParameter=t.pagesDefinition.relationParam,o.outFields=t.pagesDefinition.outFields,o.outStatistics=t.pagesDefinition.outStatistics,o.geometry=t.pagesDefinition.geometry,o.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,o.num=t.pagesDefinition.resultRecordCount,o.start=t.pagesDefinition.internal.lastPage,o.returnGeometry=t.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&o.geometry&&o.spatialRelationship)return[];const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),!u.hasOwnProperty("features"))throw new C(P.InvalidStatResponse);const d=[];if(t.pagesDefinition.internal.lastPage!==l)return[];u.features.length>0&&void 0===u.features[0].attributes[t.pagesDefinition.generatedOid]&&(t.pagesDefinition.generatedOid=t.pagesDefinition.generatedOid.toLowerCase());for(let e=0;e<u.features.length;e++)t.pagesDefinition.internal.set[n+e]=u.features[e].attributes[t.pagesDefinition.generatedOid];for(let c=0;c<u.features.length;c++)d.push(new e({attributes:u.features[c].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===u.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=u.features[u.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===u.exceededTransferLimit&&u.features.length!==t.pagesDefinition.resultRecordCount||!1===u.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=a+u.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,d}static create(e,t,i,r,s){const a=new _({url:e,outFields:null===t?["*"]:t});return new q({layer:a,spatialReference:i,lrucache:r,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)}async queryAttachments(e,t,r,s,a){const n=this._layer.capabilities;if(n?.data.supportsAttachment&&n?.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"});const l=await this._layer.queryAttachments(n),o=[];return l&&l[e]&&l[e].forEach((t=>{const r=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let s=null;a&&t.exifInfo&&(s=T.convertJsonToArcade(t.exifInfo,"system",!0)),o.push(new i(t.id,t.name,t.contentType,t.size,r,s,t.keywords??null))})),o}return[]}async queryRelatedFeatures(i){const r={f:"json",relationshipId:i.relationshipId.toString(),definitionExpression:i.where,outFields:i.outFields?.join(","),returnGeometry:i.returnGeometry.toString()};void 0!==i.resultOffset&&null!==i.resultOffset&&(r.resultOffset=i.resultOffset.toString()),void 0!==i.resultRecordCount&&null!==i.resultRecordCount&&(r.resultRecordCount=i.resultRecordCount.toString()),i.orderByFields&&(r.orderByFields=i.orderByFields.join(",")),i.objectIds&&i.objectIds.length>0&&(r.objectIds=i.objectIds.join(",")),i.outSpatialReference&&(r.outSR=JSON.stringify(i.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:r});if(s.data){const t={},i=s.data;if(i&&i.relatedRecordGroups){const r=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const t of s.relatedRecords){t.geometry&&(t.geometry.spatialReference=r);const i=new e({geometry:t.geometry?m(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new C(P.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new F;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(i.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const r=await R(this._layer.parsedUrl.path,i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();const e=f?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=f?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let i=this._layer.url;const r=i.toLowerCase().indexOf("/rest/services");if(i=r>-1?i.substring(0,r):i,i){i+="/rest/info";try{const e=await t(i,{query:{f:"json"}});let r="";return e.data&&e.data.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch(s){return""}}return""}getDataSourceFeatureSet(){const e=new q({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeReference(){return void 0===this._cachedDateMetaData.preferredTimeReference&&(this._cachedDateMetaData.preferredTimeReference=this._layer?.preferredTimeReference?.toJSON()??null),this._cachedDateMetaData.preferredTimeReference}get dateFieldsTimeReference(){return void 0===this._cachedDateMetaData.dateFieldsTimeReference&&(this._cachedDateMetaData.dateFieldsTimeReference=this._layer?.dateFieldsTimeReference?.toJSON()??null),this._cachedDateMetaData.dateFieldsTimeReference}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone}get editFieldsInfo(){return void 0===this._cachedDateMetaData.editFieldsInfo&&(this._cachedDateMetaData.editFieldsInfo=this._layer?.editFieldsInfo?.toJSON()??null),this._cachedDateMetaData.editFieldsInfo}get timeInfo(){return void 0===this._cachedDateMetaData.timeInfo&&(this._cachedDateMetaData.timeInfo=this._layer?.timeInfo?.toJSON()??null),this._cachedDateMetaData.timeInfo}}export{q as default};
|
|
5
|
+
import e from"../../../Graphic.js";import t from"../../../request.js";import i from"../../Attachment.js";import r 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 c}from"../support/sqlUtils.js";import{decodeStatType as h}from"../support/stats.js";import{createMD5Hash as p,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{fromJSON as m}from"../../../geometry/support/jsonUtils.js";import _ from"../../../layers/FeatureLayer.js";import{executeQuery as g}from"../../../rest/query/executeQuery.js";import"../../../config.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/urlUtils.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"../../../geometry/support/normalizeUtils.js";import"../../../core/Error.js";import"../../../core/pbf.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import w from"../../../rest/support/Query.js";import{executeForIds as S}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as F}from"../../../rest/query/executeQueryJSON.js";import"../../../layers/graphics/featureConversionUtils.js";import"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../rest/support/TopFeaturesQuery.js";import b from"../../../rest/support/StatisticDefinition.js";import D from"../../Dictionary.js";import{FeatureSetError as I,FeatureSetErrorCodes as x}from"../support/errorsupport.js";import T from"../../../layers/SubtypeGroupLayer.js";class C extends r{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,this._cachedDateMetaData={},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}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+n(e.toJSON());return p(t,y.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.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._layer instanceof T?(this.typeIdField=this._layer.subtypeField??"",this.types=this._layer.subtypes):(this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types)}_isInFeatureSet(){return o.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new w;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){return e.quantizationParameters={mode:"edit"},(await g(this._layer.parsedUrl,e,{format:"pbf"},{})).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?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){e.returnZ=this.hasZ,e.returnM=this.hasM;const i="execute"===t?F:"executeForCount"===t?R:S,r="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!==r?i(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!==r?i(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}async _getFilteredSet(e,t,i,r,a){const n=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,a);let l="",o=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=r.constructClause(),o=!0);const u=new w;this.datesInUnknownTimezone&&(u.timeReferenceUnknownClient=!0),u.where=null===i?null===t?"1=1":"":d(i,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);let c=await this.executeQuery(u,"executeForIds");null===c&&(c=[]),this._checkCancelled(a);return new s([],c,o,null)}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}async _getFilteredSetUsingPaging(e,t,i,r,a){let n="",l=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=r.constructClause(),l=!0);const o=await this.databaseType();let u=null===i?null===t?"1=1":"":d(i,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let c=this._maxQueryRate();const h=this._layer.capabilities?.query.maxRecordCount;null!=h&&h<c&&(c=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:c,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const r=this._overrideFields??this._fieldsIncludingObjectId(["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:c,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:n,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(p,c,0,1,a),p}_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}}async _getPhysicalPage(e,t,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,a=e.pagesDefinition.internal.lastPage,n=new w;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[s+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){const s=[];if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let a=0;for(let u=e._lastFetchedIndex;u<e._known.length;u++){if(e._lastFetchedIndex+=1,a++,void 0===this._featureCache[e._known[u]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[u]]){const r=t._featureMap[e._known[u]];null!==r&&(i=!0,this._featureCache[e._known[u]]=r)}}if(!1===i&&(e._known[u]!==t&&s.push(e._known[u]),s.length>=this._maxProcessingRate()-1))break}if(a>=i&&0===s.length)break}if(0===s.length)return"success";const n=new w;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.objectIds=s,n.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),n.returnGeometry=!0,!0===this._removeGeometry&&(n.returnGeometry=!1),n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(r),void 0!==l.error)throw new I(x.RequestFailed,{reason:l.error});const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return"success"}async _getDistinctPages(e,t,i,r,s,a,n,l,o){await this._ensureLoaded();const u=await this.databaseType();let c=i.parseTree.column;const h=this._layer.fields??[];for(let d=0;d<h.length;d++)if(h[d].name.toLowerCase()===c.toLowerCase()){c=h[d].name;break}const p=new w;this._requestStandardised&&(p.sqlFormat="standard"),this.datesInUnknownTimezone&&(p.timeReferenceUnknownClient=!0);let y=null===a?null===s?"1=1":"":d(a,u);this._layer.definitionExpression&&this._useDefinitionExpression&&(y=""!==y?"(("+this._layer.definitionExpression+") AND ("+y+"))":this._layer.definitionExpression),p.where=y,p.spatialRelationship=this._makeRelationshipEnum(r),p.relationParameter=this._makeRelationshipParam(r),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[c];const f=await this.executeQuery(p,"execute");if(this._checkCancelled(o),!f.hasOwnProperty("features"))throw new I(x.InvalidStatResponse);let m=!1;for(let d=0;d<h.length;d++)if(h[d].name===c){"date"===h[d].type&&(m=!0);break}for(let d=0;d<f.features.length;d++){if(m){const e=f.features[d].attributes[c];null!==e?l.push(new Date(e)):l.push(e)}else l.push(f.features[d].attributes[c]);if(l.length>=n)break}if(0===f.features.length)return l;if(f.features.length===this._layer.capabilities?.query.maxRecordCount&&l.length<n){return{calculated:!0,result:await this._getDistinctPages(e+f.features.length,t,i,r,s,a,n,l,o)}}return l}async _distinctStat(e,t,i,r,s,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,s,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new w;if(this._requestStandardised&&(a.sqlFormat="standard"),this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===r?null===i?"1=1":"":d(r,s);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,r,s,a,n){await this._ensureLoaded();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;if("count"===e)return u?this._countstat(e,i,r,s):{calculated:!1};if(!1===o||!1===c(t)&&!1===l||!1===t.isStandardized)return""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n);if("distinct"===e)return!1===u?""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,i,r,s,a,n);const p=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};const y=new w;this._requestStandardised&&(y.sqlFormat="standard");let f=null===s?null===r?"1=1":"":d(s,p);this._layer.definitionExpression&&this._useDefinitionExpression&&(f=""!==f?"(("+this._layer.definitionExpression+") AND ("+f+"))":this._layer.definitionExpression),y.where=f,y.spatialRelationship=this._makeRelationshipEnum(i),y.relationParameter=this._makeRelationshipParam(i),y.geometry=null===r?null:r,this.datesInUnknownTimezone&&(y.timeReferenceUnknownClient=!0);const m=new b;m.statisticType=h(e),m.onStatisticField=d(t,p),m.outStatisticFieldName="ARCADE_STAT_RESULT",y.returnGeometry=!1;let _="ARCADE_STAT_RESULT";y.outStatistics=[m];const g=await this.executeQuery(y,"execute");if(!g.hasOwnProperty("features")||0===g.features.length)throw new I(x.InvalidStatResponse);let R=!1;const S=g.fields??[];for(let d=0;d<S.length;d++)if("ARCADE_STAT_RESULT"===S[d].name.toUpperCase()){_=S[d].name,"date"===S[d].type&&(R=!0);break}if(R){let e=g.features[0].attributes[_];return null!==e&&(e=new Date(g.features[0].attributes[_])),{calculated:!0,result:e}}return{calculated:!0,result:g.features[0].attributes[_]}}_stat(e,t,i,r,s,a,n){return this._stats(e,t,i,r,s,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const r=this._layer.capabilities?.query,s=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===c(t[a].workingexpr)&&!1===s)&&(i=!1);return!1!==i}_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]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,a,n,l){await this._ensureLoaded();const o=await this.databaseType();let u="",c=!1,h=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),h=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(h=!1,c=!0,u=this._layer.objectIdField);const p=[];for(let s=0;s<t.length;s++){const e=new b;e.onStatisticField=null!==t[s].workingexpr?d(t[s].workingexpr,o):"",e.outStatisticFieldName=t[s].field,e.statisticType=t[s].toStatisticsName(),p.push(e)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;null!=f&&f<y&&(y=f);let m=null===a?null===r?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],h,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:c,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:p,geometry:null===r?null:r,where:m,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,r){let s=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const a=t.pagesDefinition.internal.lastRetrieved,n=a,l=t.pagesDefinition.internal.lastPage,o=new w;if(this._requestStandardised&&(o.sqlFormat="standard"),o.where=s,o.spatialRelationship=t.pagesDefinition.spatialRel,o.relationParameter=t.pagesDefinition.relationParam,o.outFields=t.pagesDefinition.outFields,o.outStatistics=t.pagesDefinition.outStatistics,o.geometry=t.pagesDefinition.geometry,o.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,o.num=t.pagesDefinition.resultRecordCount,o.start=t.pagesDefinition.internal.lastPage,o.returnGeometry=t.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&o.geometry&&o.spatialRelationship)return[];const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),!u.hasOwnProperty("features"))throw new I(x.InvalidStatResponse);const d=[];if(t.pagesDefinition.internal.lastPage!==l)return[];u.features.length>0&&void 0===u.features[0].attributes[t.pagesDefinition.generatedOid]&&(t.pagesDefinition.generatedOid=t.pagesDefinition.generatedOid.toLowerCase());for(let e=0;e<u.features.length;e++)t.pagesDefinition.internal.set[n+e]=u.features[e].attributes[t.pagesDefinition.generatedOid];for(let c=0;c<u.features.length;c++)d.push(new e({attributes:u.features[c].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===u.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=u.features[u.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===u.exceededTransferLimit&&u.features.length!==t.pagesDefinition.resultRecordCount||!1===u.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=a+u.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,d}static create(e,t,i,r,s){const a=new _({url:e,outFields:null===t?["*"]:t});return new C({layer:a,spatialReference:i,lrucache:r,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)}async queryAttachments(e,t,r,s,a){const n=this._layer.capabilities;if(n?.data.supportsAttachment&&n?.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"});const l=await this._layer.queryAttachments(n),o=[];return l&&l[e]&&l[e].forEach((t=>{const r=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let s=null;a&&t.exifInfo&&(s=D.convertJsonToArcade(t.exifInfo,"system",!0)),o.push(new i(t.id,t.name,t.contentType,t.size,r,s,t.keywords??null))})),o}return[]}async queryRelatedFeatures(i){const r={f:"json",relationshipId:i.relationshipId.toString(),definitionExpression:i.where,outFields:i.outFields?.join(","),returnGeometry:i.returnGeometry.toString()};void 0!==i.resultOffset&&null!==i.resultOffset&&(r.resultOffset=i.resultOffset.toString()),void 0!==i.resultRecordCount&&null!==i.resultRecordCount&&(r.resultRecordCount=i.resultRecordCount.toString()),i.orderByFields&&(r.orderByFields=i.orderByFields.join(",")),i.objectIds&&i.objectIds.length>0&&(r.objectIds=i.objectIds.join(",")),i.outSpatialReference&&(r.outSR=JSON.stringify(i.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:r});if(s.data){const t={},i=s.data;if(i&&i.relatedRecordGroups){const r=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const t of s.relatedRecords){t.geometry&&(t.geometry.spatialReference=r);const i=new e({geometry:t.geometry?m(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new I(x.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new w;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(i.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const r=await F(this._layer.parsedUrl.path,i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();const e=f?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=f?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let i=this._layer.url;const r=i.toLowerCase().indexOf("/rest/services");if(i=r>-1?i.substring(0,r):i,i){i+="/rest/info";try{const e=await t(i,{query:{f:"json"}});let r="";return e.data&&e.data.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch(s){return""}}return""}getDataSourceFeatureSet(){const e=new C({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeReference(){return void 0===this._cachedDateMetaData.preferredTimeReference&&(this._cachedDateMetaData.preferredTimeReference=this._layer?.preferredTimeReference?.toJSON()??null),this._cachedDateMetaData.preferredTimeReference}get dateFieldsTimeReference(){return void 0===this._cachedDateMetaData.dateFieldsTimeReference&&(this._cachedDateMetaData.dateFieldsTimeReference=this._layer?.dateFieldsTimeReference?.toJSON()??null),this._cachedDateMetaData.dateFieldsTimeReference}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone}get editFieldsInfo(){return void 0===this._cachedDateMetaData.editFieldsInfo&&(this._cachedDateMetaData.editFieldsInfo=this._layer?.editFieldsInfo?.toJSON()??null),this._cachedDateMetaData.editFieldsInfo}get timeInfo(){return void 0===this._cachedDateMetaData.timeInfo&&(this._cachedDateMetaData.timeInfo=this._layer?.timeInfo?.toJSON()??null),this._cachedDateMetaData.timeInfo}}export{C 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import s from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{defaultMaxRecords as a,FeatureServiceDatabaseType as
|
|
5
|
+
import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import s from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{defaultMaxRecords as a,FeatureServiceDatabaseType as n,IdState as l}from"../support/shared.js";import{toWhereClause as o}from"../support/sqlUtils.js";import u from"../../../geometry/Geometry.js";import h from"../../../layers/FeatureLayer.js";import c from"../../../layers/SubtypeGroupLayer.js";import y from"../../../layers/support/FeatureType.js";import p from"../../../layers/support/Field.js";import d from"../../../rest/support/Query.js";class f extends s{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 a}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}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),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._databaseType=n.Standardised,this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,this._layer instanceof c?(this.typeIdField=this._layer.subtypeField??"",this.types=this._layer.subtypes):(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 l.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return 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})}async _getFilteredSet(e,t,r,s,a){let l="",u=!1;if(null!==s&&(l=s.constructClause(),u=!0),this.isTable()&&t&&null!==e&&""!==e){return new i([],[],!0,null)}const h=new d;h.returnZ=this.hasZ,h.returnM=this.hasM,h.where=null===r?null===t?"1=1":"":o(r,n.Standardised),h.spatialRelationship=this._makeRelationshipEnum(e),h.outSpatialReference=this.spatialReference,h.orderByFields=""!==l?l.split(","):null,h.geometry=null===t?null:t,h.returnGeometry=!0,h.relationParameter=this._makeRelationshipParam(e);const c=await this._layer.queryFeatures(h);if(null===c)return new i([],[],u,null);this._checkCancelled(a);const y=[];c.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];y.push(t),this._featureCache[t]=this._changeFeature(e)}));return new i([],y,u,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]:""}async _queryAllFeatures(){if(this._wset)return this._wset;const e=new d;if(e.where="1=1",await this._ensureLoaded(),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 i([],e,!1,null),this._wset}e.returnZ=this.hasZ,e.returnM=this.hasM;const t=await this._layer.queryFeatures(e),r=[];return t.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];r.push(t),this._featureCache[t]=this._changeFeature(e)})),this._wset=new i([],r,!1,null),this._wset}async _getFeatures(e,s,i){const a=[];-1!==s&&void 0===this._featureCache[s]&&a.push(s);for(let t=e._lastFetchedIndex;t<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[t]]&&(e._known[t]!==s&&a.push(e._known[t]),a.length>i)));t++);if(0===a.length)return"success";throw new t(r.MissingFeatures)}async _refineSetBlock(e){return e}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!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??"",i=[];if(e.layerDefinition.types)for(const u of e.layerDefinition.types)i.push(y.fromJSON(u));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let n=e.featureSet.features;const l=t.toJSON();if(!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<n.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;n=a,r=t}}const o=[];for(const u of e.layerDefinition.fields)u instanceof p?o.push(u):o.push(p.fromJSON(u));let c=a;switch(c||(c=""),c){case"esriGeometryPoint":c="point";break;case"esriGeometryPolyline":c="polyline";break;case"esriGeometryPolygon":c="polygon";break;case"esriGeometryEnvelope":c="extent";break;case"esriGeometryMultipoint":c="multipoint";break;case"":case"esriGeometryNull":c="esriGeometryNull"}if("esriGeometryNull"!==c)for(const h of n)h.geometry&&h.geometry instanceof u==!1&&(h.geometry.type=c,void 0===h.geometry.spatialReference&&(h.geometry.spatialReference=l));else for(const u of n)u.geometry&&(u.geometry=null);const d={outFields:["*"],source:n,fields:o,hasZ:!0===e?.layerDefinition?.hasZ||!0===e?.featureSet?.hasZ,hasM:!0===e?.layerDefinition?.hasM||!0===e?.featureSet?.hasM,types:i,typeIdField:s,objectIdField:r,spatialReference:t},m="esriGeometryNull"===c||null===c;m||(d.geometryType=c);const _=new h(d);return new f({layer:_,spatialReference:t,isTable:m})}async queryAttachments(){return[]}async getFeatureByObjectId(e){const t=new d;t.where=this.objectIdField+"="+e.toString(),t.returnZ=this.hasZ,t.returnM=this.hasM;const r=await this._layer.queryFeatures(t);return 1===r.features.length?r.features[0]:null}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}get preferredTimeReference(){return this._layer?.preferredTimeReference?.toJSON()??null}get dateFieldsTimeReference(){return this._layer?.dateFieldsTimeReference?.toJSON()??null}get datesInUnknownTimezone(){return this._layer?.datesInUnknownTimezone}get editFieldsInfo(){return this._layer?.editFieldsInfo?.toJSON()??null}get timeInfo(){return this._layer?.timeInfo?.toJSON()??null}}export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,IdState as n}from"../support/shared.js";import l from"../../../rest/support/RelationshipQuery.js";class d extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,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(){}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer?.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(0),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}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types}async databaseType(){return await this._relatedLayer.databaseType(),this._databaseType=this._relatedLayer._databaseType,this._databaseType}isTable(){return this._relatedLayer.isTable()}_isInFeatureSet(){return n.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return 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})}async _getFilteredSet(e,t,r,i,a){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated){return new s([],[],!0,null)}if(n.capabilities?.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,i,a);let d="",o=!1;null!==i&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(d=i.constructClause(),o=!0);const u=new l;u.objectIds=[this._findObjectId];const h=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);u.outFields=h,u.relationshipId=this.relationship.id,u.where="1=1";let c=!0;!0===this._removeGeometry&&(c=!1),u.returnGeometry=c,this._requestStandardised&&(u.sqlFormat="standard"),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==d?d.split(","):null;const y=await n.source.queryRelatedFeatures(u);this._checkCancelled(a);const p=y[this._findObjectId]?y[this._findObjectId].features:[],_=[];for(let s=0;s<p.length;s++)this._featureCache[p[s].attributes[this._relatedLayer.objectIdField]]=p[s],_.push(p[s].attributes[this._relatedLayer.objectIdField]);const f=t&&null!==e&&""!==e,g=null!=r;return new s(f||g?_:[],f||g?[]:_,o,null)}_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}async _getFilteredSetUsingPaging(e,t,r,i,a){let n="",l=!1;const d=this._layer.nativeCapabilities();null!==i&&d&&d.capabilities?.queryRelated&&!0===d.capabilities.queryRelated.supportsOrderBy&&(n=i.constructClause(),l=!0),await this.databaseType();const o="1=1";let u=this._maxQueryRate();const h=d.capabilities?.query.maxRecordCount;null!=h&&h<u&&(u=h);const c=t&&null!==e&&""!==e,y=null!=r;let p=null,_=!0;!0===this._removeGeometry&&(_=!1);const f=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);return p=new s(c||y?["GETPAGES"]:[],c||y?[]:["GETPAGES"],l,{outFields:f.join(","),resultRecordCount:u,resultOffset:0,objectIds:[this._findObjectId],where:o,orderByFields:n,returnGeometry:_,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(p,u,0,0,a),p}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,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,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,r){const i=e.pagesDefinition.internal.lastRetrieved,s=i,a=e.pagesDefinition.internal.lastPage,n=this._layer.nativeCapabilities(),d=new l;!0===this._requestStandardised&&(d.sqlFormat="standard"),d.relationshipId=this.relationship.id,d.objectIds=e.pagesDefinition.objectIds,d.resultOffset=e.pagesDefinition.internal.lastPage,d.resultRecordCount=e.pagesDefinition.resultRecordCount,d.outFields=e.pagesDefinition.outFields.split(","),d.where=e.pagesDefinition.where,d.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,d.returnGeometry=e.pagesDefinition.returnGeometry,d.outSpatialReference=this.spatialReference;const o=await n.source.queryRelatedFeatures(d);if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==a)return 0;const u=o[this._findObjectId]?o[this._findObjectId].features:[];for(let l=0;l<u.length;l++)e.pagesDefinition.internal.set[s+l]=u[l].attributes[this._relatedLayer.objectIdField];for(let l=0;l<u.length;l++)this._featureCache[u[l].attributes[this._relatedLayer.objectIdField]]=u[l];const h=!o[this._findObjectId]||!1===o[this._findObjectId].exceededTransferLimit;return u.length!==e.pagesDefinition.resultRecordCount&&h&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=i+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,i,s,a){const n=[];-1!==i&&void 0===this._featureCache[i]&&n.push(i);const l=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,l))return await this._expandPagedSet(e,l,0,0,a),this._getFeatures(e,i,s,a);let d=0;for(let t=e._lastFetchedIndex;t<e._known.length&&(d++,d<=s&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[t]&&void 0===this._featureCache[e._known[t]]&&(e._known[t]!==i&&n.push(e._known[t]),n.length>s)))&&!(d>=s&&0===n.length);t++);if(0===n.length)return"success";throw new t(r.MissingFeatures)}async _refineSetBlock(e,t,r){return e}async _stat(e,t,r,i,s,a,n){return{calculated:!1}}get gdbVersion(){return this._relatedLayer.gdbVersion}async _canDoAggregates(e,t,r,i,s){return!1}relationshipMetaData(){return this._relatedLayer.relationshipMetaData()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,r,i,s){return this._relatedLayer.queryAttachments(e,t,r,i,s)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}get preferredTimeReference(){return this._relatedLayer?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._relatedLayer?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._relatedLayer?.datesInUnknownTimezone}get editFieldsInfo(){return this._relatedLayer?.editFieldsInfo??null}get timeInfo(){return this._relatedLayer?.timeInfo??null}}export{d as default};
|
|
5
|
+
import e from"../../../Graphic.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,IdState as n}from"../support/shared.js";import l from"../../../rest/support/RelationshipQuery.js";class d extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,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(){}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer?.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(0),this.hasZ=this._relatedLayer.hasZ,this.hasM=this._relatedLayer.hasM,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}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types}async databaseType(){return await this._relatedLayer.databaseType(),this._databaseType=this._relatedLayer._databaseType,this._databaseType}isTable(){return this._relatedLayer.isTable()}_isInFeatureSet(){return n.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return 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})}async _getFilteredSet(e,t,r,i,a){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated){return new s([],[],!0,null)}if(n.capabilities?.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,i,a);let d="",o=!1;null!==i&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(d=i.constructClause(),o=!0);const u=new l;u.objectIds=[this._findObjectId];const h=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);u.outFields=h,u.relationshipId=this.relationship.id,u.where="1=1";let c=!0;!0===this._removeGeometry&&(c=!1),u.returnGeometry=c,this._requestStandardised&&(u.sqlFormat="standard"),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==d?d.split(","):null;const y=await n.source.queryRelatedFeatures(u);this._checkCancelled(a);const p=y[this._findObjectId]?y[this._findObjectId].features:[],_=[];for(let s=0;s<p.length;s++)this._featureCache[p[s].attributes[this._relatedLayer.objectIdField]]=p[s],_.push(p[s].attributes[this._relatedLayer.objectIdField]);const f=t&&null!==e&&""!==e,g=null!=r;return new s(f||g?_:[],f||g?[]:_,o,null)}_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}async _getFilteredSetUsingPaging(e,t,r,i,a){let n="",l=!1;const d=this._layer.nativeCapabilities();null!==i&&d&&d.capabilities?.queryRelated&&!0===d.capabilities.queryRelated.supportsOrderBy&&(n=i.constructClause(),l=!0),await this.databaseType();const o="1=1";let u=this._maxQueryRate();const h=d.capabilities?.query.maxRecordCount;null!=h&&h<u&&(u=h);const c=t&&null!==e&&""!==e,y=null!=r;let p=null,_=!0;!0===this._removeGeometry&&(_=!1);const f=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);return p=new s(c||y?["GETPAGES"]:[],c||y?[]:["GETPAGES"],l,{outFields:f.join(","),resultRecordCount:u,resultOffset:0,objectIds:[this._findObjectId],where:o,orderByFields:n,returnGeometry:_,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(p,u,0,0,a),p}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,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,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,r){const i=e.pagesDefinition.internal.lastRetrieved,s=i,a=e.pagesDefinition.internal.lastPage,n=this._layer.nativeCapabilities(),d=new l;!0===this._requestStandardised&&(d.sqlFormat="standard"),d.relationshipId=this.relationship.id,d.objectIds=e.pagesDefinition.objectIds,d.resultOffset=e.pagesDefinition.internal.lastPage,d.resultRecordCount=e.pagesDefinition.resultRecordCount,d.outFields=e.pagesDefinition.outFields.split(","),d.where=e.pagesDefinition.where,d.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,d.returnGeometry=e.pagesDefinition.returnGeometry,d.outSpatialReference=this.spatialReference;const o=await n.source.queryRelatedFeatures(d);if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==a)return 0;const u=o[this._findObjectId]?o[this._findObjectId].features:[];for(let l=0;l<u.length;l++)e.pagesDefinition.internal.set[s+l]=u[l].attributes[this._relatedLayer.objectIdField];for(let l=0;l<u.length;l++)this._featureCache[u[l].attributes[this._relatedLayer.objectIdField]]=u[l];const h=!o[this._findObjectId]||!1===o[this._findObjectId].exceededTransferLimit;return u.length!==e.pagesDefinition.resultRecordCount&&h&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=i+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,i,s,a){const n=[];-1!==i&&void 0===this._featureCache[i]&&n.push(i);const l=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,l))return await this._expandPagedSet(e,l,0,0,a),this._getFeatures(e,i,s,a);let d=0;for(let t=e._lastFetchedIndex;t<e._known.length&&(d++,d<=s&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[t]&&void 0===this._featureCache[e._known[t]]&&(e._known[t]!==i&&n.push(e._known[t]),n.length>s)))&&!(d>=s&&0===n.length);t++);if(0===n.length)return"success";throw new t(r.MissingFeatures)}async _refineSetBlock(e,t,r){return e}async _stat(e,t,r,i,s,a,n){return{calculated:!1}}get gdbVersion(){return this._relatedLayer.gdbVersion}async _canDoAggregates(e,t,r,i,s){return!1}relationshipMetaData(){return this._relatedLayer.relationshipMetaData()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,r,i,s){return this._relatedLayer.queryAttachments(e,t,r,i,s)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}get preferredTimeReference(){return this._relatedLayer?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._relatedLayer?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._relatedLayer?.datesInUnknownTimezone}get editFieldsInfo(){return this._relatedLayer?.editFieldsInfo??null}get timeInfo(){return this._relatedLayer?.timeInfo??null}}export{d 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeDate as e}from"../ArcadeDate.js";import t from"../ArcadePortal.js";import n from"../Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as a}from"../executionError.js";import r from"../Feature.js";import s from"../featureSetCollection.js";import{convertToFeatureSet as l,constructFeatureSetFromPortalItem as o,constructFeatureSet as f,constructFeatureSetFromRelationship as u,constructFeatureSetFromUrl as c,constructAssociationMetaDataFeatureSetFromUrl as d}from"../featureSetUtils.js";import m from"../ImmutableArray.js";import{C as p,r as y,c as g,j as h,l as w,G as I,k as F,D as E,h as D,m as b,p as x,o as A,i as N,g as S,_ as T,P as L}from"../../chunks/languageUtils.js";import{getPortal as $}from"../portalUtils.js";import{SqlExpressionAdapted as v,StringToCodeAdapted as P,FieldRename as R,AdaptedFeatureSet as j,OriginalField as C}from"../featureset/actions/Adapted.js";import M from"../featureset/actions/AttributeFilter.js";import O from"../featureset/actions/OrderBy.js";import k from"../featureset/actions/Top.js";import z from"../featureset/sources/Empty.js";import H from"../featureset/sources/FeatureLayerMemory.js";import G from"../featureset/support/OrderbyClause.js";import{cloneField as Z}from"../featureset/support/shared.js";import{isSingleField as _}from"../featureset/support/sqlUtils.js";import{calculateStat as W}from"./fieldStats.js";import{isPromiseLike as U}from"../../core/promiseUtils.js";import{WhereClause as B}from"../../core/sql/WhereClause.js";import q from"../../layers/FeatureLayer.js";import V from"../../layers/support/Field.js";import Q from"../../portal/Portal.js";function J(e,t,n,i){if(1===i.length){if(b(i[0]))return W(e,i[0],-1);if(A(i[0]))return W(e,i[0].toArray(),-1)}return W(e,i,-1)}async function K(e,t,n){const i=e.getVariables();if(i.length>0){const a=[];for(let e=0;e<i.length;e++){const r={name:i[e]};a.push(await t.evaluateIdentifier(n,r))}const r={};for(let e=0;e<i.length;e++)r[i[e]]=a[e];return e.parameters=r,e}return e}function Y(e,t,n=null){for(const i in e)if(i.toLowerCase()===t.toLowerCase())return e[i];return n}function X(e){if(null===e)return null;const t={type:Y(e,"type",""),name:Y(e,"name","")};if("range"===t.type)t.range=Y(e,"range",[]);else{t.codedValues=[];for(const n of Y(e,"codedValues",[]))t.codedValues.push({name:Y(n,"name",""),code:Y(n,"code",null)})}return t}function ee(e){if(null===e)return null;const t={},n=Y(e,"wkt",null);null!==n&&(t.wkt=n);const i=Y(e,"wkid",null);return null!==i&&(t.wkid=i),t}function te(e){if(null===e)return null;const t={hasZ:Y(e,"hasz",!1),hasM:Y(e,"hasm",!1)},n=Y(e,"spatialreference",null);n&&(t.spatialReference=ee(n));const i=Y(e,"x",null);if(null!==i)return t.x=i,t.y=Y(e,"y",null),t;const a=Y(e,"rings",null);if(null!==a)return t.rings=a,t;const r=Y(e,"paths",null);if(null!==r)return t.paths=r,t;const s=Y(e,"points",null);if(null!==s)return t.points=s,t;for(const l of["xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]){const n=Y(e,l,null);null!==n&&(t[l]=n)}return t}function ne(e,t){for(const n of t)if(n===e)return!0;return!1}function ie(e){return!!e.layerDefinition&&(!!e.featureSet&&(!1!==ne(e.layerDefinition.geometryType,["",null,"esriGeometryNull","esriGeometryPoint","esriGeometryPolyline","esriGeometryPolygon","esriGeometryMultipoint","esriGeometryEnvelope"])&&(!1!==b(e.layerDefinition.fields)&&!1!==b(e.featureSet.features))))}function ae(W){"async"===W.mode&&(W.functions.timezone=function(t,r){return W.standardFunctionAsync(t,r,(async(s,l,o)=>{if(p(o,1,2,t,r),y(o[0])){if(await o[0].load(),1===o.length||null===o[1])return o[0].dateTimeReferenceFieldIndex.layerDateFieldsTimeZone;if(!(o[1]instanceof n)||!1===o[1].hasField("type"))throw new i(t,a.InvalidParameter,r);const e=o[1].field("type");if(!1===g(e))throw new i(t,a.InvalidParameter,r);switch(h(e).toLowerCase()){case"preferredtimezone":return o[0].dateTimeReferenceFieldIndex.layerPreferredTimeZone;case"editfieldsinfo":return o[0].dateTimeReferenceFieldIndex.layerEditFieldsTimeZone;case"timeinfo":return o[0].dateTimeReferenceFieldIndex.layerTimeInfoTimeZone;case"field":if(o[1].hasField("fieldname")&&g(o[1].field("fieldname")))return o[0].dateTimeReferenceFieldIndex.fieldTimeZone(h(o[1].field("fieldname")))}throw new i(t,a.InvalidParameter,r)}const f=w(o[0],I(t));if(null===f)return null;const u=f.timeZone;return"system"===u?e.systemTimeZoneCanonicalName:u}))},W.functions.sqltimestamp=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,1,3,e,t);const l=s[0];if(F(l)){if(1===s.length)return l.toSQLString();if(2===s.length)return l.changeTimeZone(h(s[1])).toSQLString();throw new i(e,a.InvalidParameter,t)}if(y(l)){if(3!==s.length)throw new i(e,a.InvalidParameter,t);await l.load();const n=h(s[1]);if(!1===F(s[2]))throw new i(e,a.InvalidParameter,t);const r=l.fieldTimeZone(n);return null===r?s[2].toSQLString():s[2].changeTimeZone(r).toSQLString()}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"sqltimestamp",min:2,max:4}),W.functions.featuresetbyid=function(e,t){return W.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=h(l[1]);let r=E(l[2],null);const s=D(E(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetById(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"featuresetbyid",min:2,max:4}),W.functions.getfeatureset=function(e,t){return W.standardFunctionAsync(e,t,((n,r,s)=>{if(p(s,1,2,e,t),x(s[0])){let t=E(s[1],"datasource");return null===t&&(t="datasource"),t=h(t).toLowerCase(),l(s[0].fullSchema(),t,e.lrucache,e.interceptor,e.spatialReference)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"getfeatureset",min:1,max:2}),W.functions.featuresetbyportalitem=function(e,n){return W.standardFunctionAsync(e,n,((r,s,l)=>{if(p(l,2,5,e,n),null===l[0])throw new i(e,a.PortalRequired,n);if(l[0]instanceof t){const t=h(l[1]),r=h(l[2]);let s=E(l[3],null);const f=D(E(l[4],!0));if(null===s&&(s=["*"]),!1===b(s))throw new i(e,a.InvalidParameter,n);let u=null;return u=e.services&&e.services.portal?e.services.portal:Q.getDefault(),u=$(l[0],u),o(t,r,e.spatialReference,s,f,u,e.lrucache,e.interceptor)}if(!1===g(l[0]))throw new i(e,a.PortalRequired,n);const f=h(l[0]),u=h(l[1]);let c=E(l[2],null);const d=D(E(l[3],!0));if(null===c&&(c=["*"]),!1===b(c))throw new i(e,a.InvalidParameter,n);return o(f,u,e.spatialReference,c,d,e.services?.portal??Q.getDefault(),e.lrucache,e.interceptor)}))},W.signatures.push({name:"featuresetbyportalitem",min:2,max:5}),W.functions.featuresetbyname=function(e,t){return W.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=h(l[1]);let r=E(l[2],null);const s=D(E(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetByName(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"featuresetbyname",min:2,max:4}),W.functions.featureset=function(e,t){return W.standardFunction(e,t,((r,s,l)=>{p(l,1,1,e,t);let o=l[0];const f={layerDefinition:{geometryType:"",objectIdField:"",globalIdField:"",typeIdField:"",fields:[]},featureSet:{geometryType:"",features:[]}};if(g(o))o=JSON.parse(o),void 0!==o.layerDefinition?(f.layerDefinition=o.layerDefinition,f.featureSet=o.featureSet,o.layerDefinition.spatialReference&&(f.layerDefinition.spatialReference=o.layerDefinition.spatialReference)):(f.featureSet.features=o.features,f.featureSet.geometryType=o.geometryType,f.layerDefinition.geometryType=f.featureSet.geometryType,f.layerDefinition.objectIdField=o.objectIdFieldName??"",f.layerDefinition.typeIdField=o.typeIdFieldName,f.layerDefinition.globalIdField=o.globalIdFieldName,f.layerDefinition.fields=o.fields,o.spatialReference&&(f.layerDefinition.spatialReference=o.spatialReference));else{if(!(l[0]instanceof n))throw new i(e,a.InvalidParameter,t);{o=JSON.parse(l[0].castToText(!0));const e=Y(o,"layerdefinition");if(null!==e){f.layerDefinition.geometryType=Y(e,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.globalIdField=Y(e,"globalidfield",""),f.layerDefinition.objectIdField=Y(e,"objectidfield",""),f.layerDefinition.typeIdField=Y(e,"typeidfield","");const t=Y(e,"spatialreference",null);t&&(f.layerDefinition.spatialReference=ee(t));for(const i of Y(e,"fields",[])){const e={name:Y(i,"name",""),alias:Y(i,"alias",""),type:Y(i,"type",""),nullable:Y(i,"nullable",!0),editable:Y(i,"editable",!0),length:Y(i,"length",null),domain:X(Y(i,"domain"))};f.layerDefinition.fields.push(e)}const n=Y(o,"featureset",null);if(n){const e={};for(const t of f.layerDefinition.fields)e[t.name.toLowerCase()]=t.name;for(const t of Y(n,"features",[])){const n={},i=Y(t,"attributes",{});for(const t in i)n[e[t.toLowerCase()]]=i[t];f.featureSet.features.push({attributes:n,geometry:te(Y(t,"geometry",null))})}}}else{f.layerDefinition.geometryType=Y(o,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.objectIdField=Y(o,"objectidfieldname",""),f.layerDefinition.typeIdField=Y(o,"typeidfieldname","");const e=Y(o,"spatialreference",null);e&&(f.layerDefinition.spatialReference=ee(e));let t=Y(o,"fields",null);if(b(t))for(const a of t){const e={name:Y(a,"name",""),alias:Y(a,"alias",""),type:Y(a,"type",""),nullable:Y(a,"nullable",!0),editable:Y(a,"editable",!0),length:Y(a,"length",null),domain:X(Y(a,"domain"))};f.layerDefinition.fields.push(e)}else t=null,f.layerDefinition.fields=t;const n={};for(const a of f.layerDefinition.fields)n[a.name.toLowerCase()]=a.name;let i=Y(o,"features",null);if(b(i))for(const a of i){const e={},t=Y(a,"attributes",{});for(const i in t)e[n[i.toLowerCase()]]=t[i];f.featureSet.features.push({attributes:e,geometry:te(Y(a,"geometry",null))})}else i=null,f.featureSet.features=i}}}if(!1===ie(f))throw new i(e,a.InvalidParameter,t);return""===(f?.layerDefinition?.geometryType||"")&&(f.layerDefinition.geometryType="esriGeometryNull"),H.create(f,e.spatialReference)}))},W.signatures.push({name:"featureset",min:1,max:1}),W.functions.filter=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),b(s[0])||A(s[0])){const n=[];let r=s[0];r instanceof m&&(r=r.toArray());let l=null;if(!N(s[1]))throw new i(e,a.InvalidParameter,t);l=s[1].createFunction(e);for(const e of r){const t=l(e);U(t)?!0===await t&&n.push(e):!0===t&&n.push(e)}return n}if(y(s[0])){const t=await s[0].load(),n=B.create(s[1],t.getFieldsIndex()),i=n.getVariables();if(i.length>0){const t=[];for(let n=0;n<i.length;n++){const a={name:i[n]};t.push(await W.evaluateIdentifier(e,a))}const a={};for(let e=0;e<i.length;e++)a[i[e]]=t[e];return n.parameters=a,new M({parentfeatureset:s[0],whereclause:n})}return new M({parentfeatureset:s[0],whereclause:n})}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"filter",min:2,max:2}),W.functions.orderby=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0])){const e=new G(s[1]);return new O({parentfeatureset:s[0],orderbyclause:e})}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"orderby",min:2,max:2}),W.functions.top=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0]))return new k({parentfeatureset:s[0],topnum:s[1]});if(b(s[0]))return S(s[1])>=s[0].length?s[0].slice(0):s[0].slice(0,S(s[1]));if(A(s[0]))return S(s[1])>=s[0].length()?s[0].slice(0):s[0].slice(0,S(s[1]));throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"top",min:2,max:2}),W.functions.first=function(e,t){return W.standardFunctionAsync(e,t,(async(n,i,a)=>{if(p(a,1,1,e,t),y(a[0])){const t=await a[0].first(n.abortSignal);if(null!==t){const n=r.createFromGraphicLikeObject(t.geometry,t.attributes,a[0],e.timeReference);return n._underlyingGraphic=t,n}return t}return b(a[0])?0===a[0].length?null:a[0][0]:A(a[0])?0===a[0].length()?null:a[0].get(0):null}))},W.signatures.push({name:"first",min:1,max:1}),W.functions.attachments=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{p(l,1,2,e,t);const o={minsize:-1,maxsize:-1,types:null,returnMetadata:!1};if(l.length>1)if(l[1]instanceof n){if(l[1].hasField("minsize")&&(o.minsize=S(l[1].field("minsize"))),l[1].hasField("metadata")&&(o.returnMetadata=D(l[1].field("metadata"))),l[1].hasField("maxsize")&&(o.maxsize=S(l[1].field("maxsize"))),l[1].hasField("types")){const e=T(l[1].field("types"),!1);e.length>0&&(o.types=e)}}else if(null!==l[1])throw new i(e,a.InvalidParameter,t);if(x(l[0])){let t=l[0]._layer;return t instanceof q&&(t=f(t,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===t?[]:!1===y(t)?[]:(await t.load(),t.queryAttachments(l[0].field(t.objectIdField),o.minsize,o.maxsize,o.types,o.returnMetadata))}if(null===l[0])return[];throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"attachments",min:1,max:2}),W.functions.featuresetbyrelationshipname=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,4,e,t);const l=s[0],o=h(s[1]);let d=E(s[2],null);const m=D(E(s[3],!0));if(null===d&&(d=["*"]),!1===b(d))throw new i(e,a.InvalidParameter,t);if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let g=l._layer;if(g instanceof q&&(g=f(g,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===g)return null;if(!1===y(g))return null;g=await g.load();const w=g.relationshipMetaData().filter((e=>e.name===o));if(0===w.length)return null;if(void 0!==w[0].relationshipTableId&&null!==w[0].relationshipTableId&&w[0].relationshipTableId>-1)return u(g,w[0],l.field(g.objectIdField),g.spatialReference,d,m,e.lrucache,e.interceptor);let I=g.serviceUrl();if(!I)return null;I="/"===I.charAt(I.length-1)?I+w[0].relatedTableId.toString():I+"/"+w[0].relatedTableId.toString();const F=await c(I,g.spatialReference,d,m,e.lrucache,e.interceptor);await F.load();let A=F.relationshipMetaData();if(A=A.filter((e=>e.id===w[0].id)),!1===l.hasField(w[0].keyField)||null===l.field(w[0].keyField)){const e=await g.getFeatureByObjectId(l.field(g.objectIdField),[w[0].keyField]);if(e){const t=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return t.parameters={id:e.attributes[w[0].keyField]},F.filter(t)}return new z({parentfeatureset:F})}const N=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return N.parameters={id:l.field(w[0].keyField)},F.filter(N)}))},W.signatures.push({name:"featuresetbyrelationshipname",min:2,max:4}),W.functions.featuresetbyassociation=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,3,e,t);const l=s[0],o=h(E(s[1],"")).toLowerCase(),u=g(s[2])?h(s[2]):null;if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let c=l._layer;if(c instanceof q&&(c=f(c,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===c)return null;if(!1===y(c))return null;await c.load();const m=c.serviceUrl(),w=await d(m,e.spatialReference);let I=null,F=null,D=!1;if(null!==u&&""!==u&&void 0!==u){for(const e of w.terminals)e.terminalName===u&&(F=e.terminalId);null===F&&(D=!0)}const b=w.associations.getFieldsIndex(),A=b.get("TOGLOBALID").name,N=b.get("FROMGLOBALID").name,S=b.get("TOTERMINALID").name,T=b.get("FROMTERMINALID").name,$=b.get("FROMNETWORKSOURCEID").name,M=b.get("TONETWORKSOURCEID").name,O=b.get("ASSOCIATIONTYPE").name,k=b.get("ISCONTENTVISIBLE").name,z=b.get("OBJECTID").name;for(const e of c.fields)if("global-id"===e.type){I=l.field(e.name);break}let H=null,G=new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex())),_=new v(new V({name:"side",alias:"side",type:"string"}),B.create("''",w.associations.getFieldsIndex()));const W="globalid",U="globalId",Q={};for(const e in w.lkp)Q[e]=w.lkp[e].sourceId;const J=new P(new V({name:"classname",alias:"classname",type:"string"}),null,Q);let K="";switch(o){case"midspan":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (5))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=Z(j.findField(w.associations.fields,N));e.name=W,e.alias=W,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),G=w.unVersion>=4?new C(j.findField(w.associations.fields,b.get("PERCENTALONG").name)):new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex()));break}case"junctionedge":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (4,6))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=Z(j.findField(w.associations.fields,N));e.name=W,e.alias=W,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),_=new v(new V({name:"side",alias:"side",type:"string"}),B.create(`CASE WHEN (${O}=4) THEN 'from' ELSE 'to' END`,w.associations.getFieldsIndex()));break}case"connected":{let e=`${A}='@T'`,t=`${N}='@T'`;null!==F&&(e+=` AND ${S}=@A`,t+=` AND ${T}=@A`),K="(("+e+") OR ("+t+"))",K=L(K,"@T",I??""),e=L(e,"@T",I??""),null!==F&&(e=L(e,"@A",F.toString()),K=L(K,"@A",F.toString())),J.codefield=B.create("CASE WHEN "+e+` THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const n=Z(j.findField(w.associations.fields,N));n.name=W,n.alias=W,H=new v(n,B.create("CASE WHEN "+e+` THEN ${N} ELSE ${A} END`,w.associations.getFieldsIndex()));break}case"container":K=`${A}='${I}' AND ${O} = 2`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),W,W);break;case"content":K=`(${N}='${I}' AND ${O} = 2)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),W,W);break;case"structure":K=`(${A}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),W,U);break;case"attached":K=`(${N}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),W,U);break;default:throw new i(e,a.InvalidParameter,t)}D&&(K="1 <> 1");return new j({parentfeatureset:w.associations,adaptedFields:[new C(j.findField(w.associations.fields,z)),new C(j.findField(w.associations.fields,k)),H,_,J,G],extraFilter:K?B.create(K,w.associations.getFieldsIndex()):null})}))},W.signatures.push({name:"featuresetbyassociation",min:2,max:6}),W.functions.groupby=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{if(p(l,3,3,e,t),!y(l[0]))throw new i(e,a.InvalidParameter,t);const o=await l[0].load(),f=[],u=[];let c=!1,d=[];if(g(l[1]))d.push(l[1]);else if(l[1]instanceof n)d.push(l[1]);else if(b(l[1]))d=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);d=l[1].toArray()}for(const m of d)if(g(m)){const e=B.create(h(m),o.getFieldsIndex()),t=!0===_(e)?h(m):"%%%%FIELDNAME";f.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(c=!0)}else{if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"%%%%FIELDNAME",r=m.hasField("expression")?m.field("expression"):"";if("%%%%FIELDNAME"===n&&(c=!0),!n)throw new i(e,a.InvalidParameter,t);f.push({name:n,expression:B.create(r||n,o.getFieldsIndex())})}}if(d=[],g(l[2]))d.push(l[2]);else if(b(l[2]))d=l[2];else if(A(l[2]))d=l[2].toArray();else{if(!(l[2]instanceof n))throw new i(e,a.InvalidParameter,t);d.push(l[2])}for(const m of d){if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"",r=m.hasField("statistic")?m.field("statistic"):"",s=m.hasField("expression")?m.field("expression"):"";if(!n||!r||!s)throw new i(e,a.InvalidParameter,t);u.push({name:n,statistic:r.toLowerCase(),expression:B.create(s,o.getFieldsIndex())})}}if(c){const e={};for(const n of o.fields)e[n.name.toLowerCase()]=1;for(const n of f)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);for(const n of u)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of f)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const t of f)await K(t.expression,W,e);for(const t of u)await K(t.expression,W,e);return l[0].groupby(f,u)}))},W.signatures.push({name:"groupby",min:3,max:3}),W.functions.distinct=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{if(y(l[0])){p(l,2,2,e,t);const r=await l[0].load(),s=[];let o=[];if(g(l[1]))o.push(l[1]);else if(l[1]instanceof n)o.push(l[1]);else if(b(l[1]))o=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);o=l[1].toArray()}let f=!1;for(const l of o)if(g(l)){const e=B.create(h(l),r.getFieldsIndex()),t=!0===_(e)?h(l):"%%%%FIELDNAME";s.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(f=!0)}else{if(!(l instanceof n))throw new i(e,a.InvalidParameter,t);{const n=l.hasField("name")?l.field("name"):"%%%%FIELDNAME",o=l.hasField("expression")?l.field("expression"):"";if("%%%%FIELDNAME"===n&&(f=!0),!n)throw new i(e,a.InvalidParameter,t);s.push({name:n,expression:B.create(o||n,r.getFieldsIndex())})}}if(f){const e={};for(const n of r.fields)e[n.name.toLowerCase()]=1;for(const n of s)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of s)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const t of s)await K(t.expression,W,e);return l[0].groupby(s,[])}return J("distinct",r,s,l)}))})}export{ae as registerFunctions};
|
|
5
|
+
import{ArcadeDate as e}from"../ArcadeDate.js";import t from"../ArcadePortal.js";import n from"../Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as a}from"../executionError.js";import r from"../Feature.js";import s from"../featureSetCollection.js";import{convertToFeatureSet as l,constructFeatureSetFromPortalItem as o,constructFeatureSet as f,constructFeatureSetFromRelationship as u,constructFeatureSetFromUrl as c,constructAssociationMetaDataFeatureSetFromUrl as d}from"../featureSetUtils.js";import m from"../ImmutableArray.js";import{C as p,r as y,c as h,j as g,l as w,G as I,k as F,D,h as E,m as b,p as x,o as A,i as N,g as S,_ as T,P as L}from"../../chunks/languageUtils.js";import{getPortal as $}from"../portalUtils.js";import{SqlExpressionAdapted as v,StringToCodeAdapted as P,FieldRename as R,AdaptedFeatureSet as j,OriginalField as C}from"../featureset/actions/Adapted.js";import M from"../featureset/actions/AttributeFilter.js";import O from"../featureset/actions/OrderBy.js";import k from"../featureset/actions/Top.js";import z from"../featureset/sources/Empty.js";import H from"../featureset/sources/FeatureLayerMemory.js";import Z from"../featureset/support/OrderbyClause.js";import{cloneField as G}from"../featureset/support/shared.js";import{isSingleField as _}from"../featureset/support/sqlUtils.js";import{calculateStat as W}from"./fieldStats.js";import{isPromiseLike as U}from"../../core/promiseUtils.js";import{WhereClause as B}from"../../core/sql/WhereClause.js";import q from"../../layers/FeatureLayer.js";import V from"../../layers/support/Field.js";import Q from"../../portal/Portal.js";function J(e,t,n,i){if(1===i.length){if(b(i[0]))return W(e,i[0],-1);if(A(i[0]))return W(e,i[0].toArray(),-1)}return W(e,i,-1)}async function K(e,t,n){const i=e.getVariables();if(i.length>0){const a=[];for(let e=0;e<i.length;e++){const r={name:i[e]};a.push(await t.evaluateIdentifier(n,r))}const r={};for(let e=0;e<i.length;e++)r[i[e]]=a[e];return e.parameters=r,e}return e}function Y(e,t,n=null){for(const i in e)if(i.toLowerCase()===t.toLowerCase())return e[i];return n}function X(e){if(null===e)return null;const t={type:Y(e,"type",""),name:Y(e,"name","")};if("range"===t.type)t.range=Y(e,"range",[]);else{t.codedValues=[];for(const n of Y(e,"codedValues",[]))t.codedValues.push({name:Y(n,"name",""),code:Y(n,"code",null)})}return t}function ee(e){if(null===e)return null;const t={},n=Y(e,"wkt",null);null!==n&&(t.wkt=n);const i=Y(e,"wkid",null);return null!==i&&(t.wkid=i),t}function te(e){if(null===e)return null;const t={hasZ:Y(e,"hasz",!1),hasM:Y(e,"hasm",!1)},n=Y(e,"spatialreference",null);n&&(t.spatialReference=ee(n));const i=Y(e,"x",null);if(null!==i)return t.x=i,t.y=Y(e,"y",null),t;const a=Y(e,"rings",null);if(null!==a)return t.rings=a,t;const r=Y(e,"paths",null);if(null!==r)return t.paths=r,t;const s=Y(e,"points",null);if(null!==s)return t.points=s,t;for(const l of["xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]){const n=Y(e,l,null);null!==n&&(t[l]=n)}return t}function ne(e,t){for(const n of t)if(n===e)return!0;return!1}function ie(e){return!!e.layerDefinition&&(!!e.featureSet&&(!1!==ne(e.layerDefinition.geometryType,["",null,"esriGeometryNull","esriGeometryPoint","esriGeometryPolyline","esriGeometryPolygon","esriGeometryMultipoint","esriGeometryEnvelope"])&&(!1!==b(e.layerDefinition.fields)&&!1!==b(e.featureSet.features))))}function ae(W){"async"===W.mode&&(W.functions.timezone=function(t,r){return W.standardFunctionAsync(t,r,(async(s,l,o)=>{if(p(o,1,2,t,r),y(o[0])){if(await o[0].load(),1===o.length||null===o[1])return o[0].dateTimeReferenceFieldIndex.layerDateFieldsTimeZone;if(!(o[1]instanceof n)||!1===o[1].hasField("type"))throw new i(t,a.InvalidParameter,r);const e=o[1].field("type");if(!1===h(e))throw new i(t,a.InvalidParameter,r);switch(g(e).toLowerCase()){case"preferredtimezone":return o[0].dateTimeReferenceFieldIndex.layerPreferredTimeZone;case"editfieldsinfo":return o[0].dateTimeReferenceFieldIndex.layerEditFieldsTimeZone;case"timeinfo":return o[0].dateTimeReferenceFieldIndex.layerTimeInfoTimeZone;case"field":if(o[1].hasField("fieldname")&&h(o[1].field("fieldname")))return o[0].dateTimeReferenceFieldIndex.fieldTimeZone(g(o[1].field("fieldname")))}throw new i(t,a.InvalidParameter,r)}const f=w(o[0],I(t));if(null===f)return null;const u=f.timeZone;return"system"===u?e.systemTimeZoneCanonicalName:u}))},W.functions.sqltimestamp=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,1,3,e,t);const l=s[0];if(F(l)){if(1===s.length)return l.toSQLString();if(2===s.length)return l.changeTimeZone(g(s[1])).toSQLString();throw new i(e,a.InvalidParameter,t)}if(y(l)){if(3!==s.length)throw new i(e,a.InvalidParameter,t);await l.load();const n=g(s[1]);if(!1===F(s[2]))throw new i(e,a.InvalidParameter,t);const r=l.fieldTimeZone(n);return null===r?s[2].toSQLString():s[2].changeTimeZone(r).toSQLString()}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"sqltimestamp",min:2,max:4}),W.functions.featuresetbyid=function(e,t){return W.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=g(l[1]);let r=D(l[2],null);const s=E(D(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetById(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"featuresetbyid",min:2,max:4}),W.functions.getfeatureset=function(e,t){return W.standardFunctionAsync(e,t,((n,r,s)=>{if(p(s,1,2,e,t),x(s[0])){let t=D(s[1],"datasource");return null===t&&(t="datasource"),t=g(t).toLowerCase(),l(s[0].fullSchema(),t,e.lrucache,e.interceptor,e.spatialReference)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"getfeatureset",min:1,max:2}),W.functions.featuresetbyportalitem=function(e,n){return W.standardFunctionAsync(e,n,((r,s,l)=>{if(p(l,2,5,e,n),null===l[0])throw new i(e,a.PortalRequired,n);if(l[0]instanceof t){const t=g(l[1]),r=g(l[2]);let s=D(l[3],null);const f=E(D(l[4],!0));if(null===s&&(s=["*"]),!1===b(s))throw new i(e,a.InvalidParameter,n);let u=null;return u=e.services&&e.services.portal?e.services.portal:Q.getDefault(),u=$(l[0],u),o(t,r,e.spatialReference,s,f,u,e.lrucache,e.interceptor)}if(!1===h(l[0]))throw new i(e,a.PortalRequired,n);const f=g(l[0]),u=g(l[1]);let c=D(l[2],null);const d=E(D(l[3],!0));if(null===c&&(c=["*"]),!1===b(c))throw new i(e,a.InvalidParameter,n);return o(f,u,e.spatialReference,c,d,e.services?.portal??Q.getDefault(),e.lrucache,e.interceptor)}))},W.signatures.push({name:"featuresetbyportalitem",min:2,max:5}),W.functions.featuresetbyname=function(e,t){return W.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=g(l[1]);let r=D(l[2],null);const s=E(D(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetByName(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"featuresetbyname",min:2,max:4}),W.functions.featureset=function(e,t){return W.standardFunction(e,t,((r,s,l)=>{p(l,1,1,e,t);let o=l[0];const f={layerDefinition:{geometryType:"",objectIdField:"",hasM:!1,hasZ:!1,globalIdField:"",typeIdField:"",fields:[]},featureSet:{geometryType:"",features:[]}};if(h(o))o=JSON.parse(o),void 0!==o.layerDefinition?(f.layerDefinition=o.layerDefinition,f.featureSet=o.featureSet,o.layerDefinition.spatialReference&&(f.layerDefinition.spatialReference=o.layerDefinition.spatialReference)):(f.featureSet.features=o.features,f.featureSet.geometryType=o.geometryType,f.layerDefinition.geometryType=f.featureSet.geometryType,f.layerDefinition.objectIdField=o.objectIdFieldName??"",f.layerDefinition.typeIdField=o.typeIdFieldName,f.layerDefinition.globalIdField=o.globalIdFieldName,f.layerDefinition.fields=o.fields,o.spatialReference&&(f.layerDefinition.spatialReference=o.spatialReference));else{if(!(l[0]instanceof n))throw new i(e,a.InvalidParameter,t);{o=JSON.parse(l[0].castToText(!0));const e=Y(o,"layerdefinition");if(null!==e){f.layerDefinition.geometryType=Y(e,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.globalIdField=Y(e,"globalidfield",""),f.layerDefinition.objectIdField=Y(e,"objectidfield",""),f.layerDefinition.typeIdField=Y(e,"typeidfield",""),f.layerDefinition.hasZ=!0===Y(e,"hasz",!1),f.layerDefinition.hasM=!0===Y(e,"hasm",!1);const t=Y(e,"spatialreference",null);t&&(f.layerDefinition.spatialReference=ee(t));for(const i of Y(e,"fields",[])){const e={name:Y(i,"name",""),alias:Y(i,"alias",""),type:Y(i,"type",""),nullable:Y(i,"nullable",!0),editable:Y(i,"editable",!0),length:Y(i,"length",null),domain:X(Y(i,"domain"))};f.layerDefinition.fields.push(e)}const n=Y(o,"featureset",null);if(n){const e={};for(const t of f.layerDefinition.fields)e[t.name.toLowerCase()]=t.name;for(const t of Y(n,"features",[])){const n={},i=Y(t,"attributes",{});for(const t in i)n[e[t.toLowerCase()]]=i[t];f.featureSet.features.push({attributes:n,geometry:te(Y(t,"geometry",null))})}}}else{f.layerDefinition.hasZ=!0===Y(o,"hasz",!1),f.layerDefinition.hasM=!0===Y(o,"hasm",!1),f.layerDefinition.geometryType=Y(o,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.objectIdField=Y(o,"objectidfieldname",""),f.layerDefinition.typeIdField=Y(o,"typeidfieldname","");const e=Y(o,"spatialreference",null);e&&(f.layerDefinition.spatialReference=ee(e));let t=Y(o,"fields",null);if(b(t))for(const a of t){const e={name:Y(a,"name",""),alias:Y(a,"alias",""),type:Y(a,"type",""),nullable:Y(a,"nullable",!0),editable:Y(a,"editable",!0),length:Y(a,"length",null),domain:X(Y(a,"domain"))};f.layerDefinition.fields.push(e)}else t=null,f.layerDefinition.fields=t;const n={};for(const a of f.layerDefinition.fields)n[a.name.toLowerCase()]=a.name;let i=Y(o,"features",null);if(b(i))for(const a of i){const e={},t=Y(a,"attributes",{});for(const i in t)e[n[i.toLowerCase()]]=t[i];f.featureSet.features.push({attributes:e,geometry:te(Y(a,"geometry",null))})}else i=null,f.featureSet.features=i}}}if(!1===ie(f))throw new i(e,a.InvalidParameter,t);return""===(f?.layerDefinition?.geometryType||"")&&(f.layerDefinition.geometryType="esriGeometryNull"),H.create(f,e.spatialReference)}))},W.signatures.push({name:"featureset",min:1,max:1}),W.functions.filter=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),b(s[0])||A(s[0])){const n=[];let r=s[0];r instanceof m&&(r=r.toArray());let l=null;if(!N(s[1]))throw new i(e,a.InvalidParameter,t);l=s[1].createFunction(e);for(const e of r){const t=l(e);U(t)?!0===await t&&n.push(e):!0===t&&n.push(e)}return n}if(y(s[0])){const t=await s[0].load(),n=B.create(s[1],t.getFieldsIndex()),i=n.getVariables();if(i.length>0){const t=[];for(let n=0;n<i.length;n++){const a={name:i[n]};t.push(await W.evaluateIdentifier(e,a))}const a={};for(let e=0;e<i.length;e++)a[i[e]]=t[e];return n.parameters=a,new M({parentfeatureset:s[0],whereclause:n})}return new M({parentfeatureset:s[0],whereclause:n})}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"filter",min:2,max:2}),W.functions.orderby=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0])){const e=new Z(s[1]);return new O({parentfeatureset:s[0],orderbyclause:e})}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"orderby",min:2,max:2}),W.functions.top=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0]))return new k({parentfeatureset:s[0],topnum:s[1]});if(b(s[0]))return S(s[1])>=s[0].length?s[0].slice(0):s[0].slice(0,S(s[1]));if(A(s[0]))return S(s[1])>=s[0].length()?s[0].slice(0):s[0].slice(0,S(s[1]));throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"top",min:2,max:2}),W.functions.first=function(e,t){return W.standardFunctionAsync(e,t,(async(n,i,a)=>{if(p(a,1,1,e,t),y(a[0])){const t=await a[0].first(n.abortSignal);if(null!==t){const n=r.createFromGraphicLikeObject(t.geometry,t.attributes,a[0],e.timeReference);return n._underlyingGraphic=t,n}return t}return b(a[0])?0===a[0].length?null:a[0][0]:A(a[0])?0===a[0].length()?null:a[0].get(0):null}))},W.signatures.push({name:"first",min:1,max:1}),W.functions.attachments=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{p(l,1,2,e,t);const o={minsize:-1,maxsize:-1,types:null,returnMetadata:!1};if(l.length>1)if(l[1]instanceof n){if(l[1].hasField("minsize")&&(o.minsize=S(l[1].field("minsize"))),l[1].hasField("metadata")&&(o.returnMetadata=E(l[1].field("metadata"))),l[1].hasField("maxsize")&&(o.maxsize=S(l[1].field("maxsize"))),l[1].hasField("types")){const e=T(l[1].field("types"),!1);e.length>0&&(o.types=e)}}else if(null!==l[1])throw new i(e,a.InvalidParameter,t);if(x(l[0])){let t=l[0]._layer;return t instanceof q&&(t=f(t,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===t?[]:!1===y(t)?[]:(await t.load(),t.queryAttachments(l[0].field(t.objectIdField),o.minsize,o.maxsize,o.types,o.returnMetadata))}if(null===l[0])return[];throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"attachments",min:1,max:2}),W.functions.featuresetbyrelationshipname=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,4,e,t);const l=s[0],o=g(s[1]);let d=D(s[2],null);const m=E(D(s[3],!0));if(null===d&&(d=["*"]),!1===b(d))throw new i(e,a.InvalidParameter,t);if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let h=l._layer;if(h instanceof q&&(h=f(h,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===h)return null;if(!1===y(h))return null;h=await h.load();const w=h.relationshipMetaData().filter((e=>e.name===o));if(0===w.length)return null;if(void 0!==w[0].relationshipTableId&&null!==w[0].relationshipTableId&&w[0].relationshipTableId>-1)return u(h,w[0],l.field(h.objectIdField),h.spatialReference,d,m,e.lrucache,e.interceptor);let I=h.serviceUrl();if(!I)return null;I="/"===I.charAt(I.length-1)?I+w[0].relatedTableId.toString():I+"/"+w[0].relatedTableId.toString();const F=await c(I,h.spatialReference,d,m,e.lrucache,e.interceptor);await F.load();let A=F.relationshipMetaData();if(A=A.filter((e=>e.id===w[0].id)),!1===l.hasField(w[0].keyField)||null===l.field(w[0].keyField)){const e=await h.getFeatureByObjectId(l.field(h.objectIdField),[w[0].keyField]);if(e){const t=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return t.parameters={id:e.attributes[w[0].keyField]},F.filter(t)}return new z({parentfeatureset:F})}const N=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return N.parameters={id:l.field(w[0].keyField)},F.filter(N)}))},W.signatures.push({name:"featuresetbyrelationshipname",min:2,max:4}),W.functions.featuresetbyassociation=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,3,e,t);const l=s[0],o=g(D(s[1],"")).toLowerCase(),u=h(s[2])?g(s[2]):null;if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let c=l._layer;if(c instanceof q&&(c=f(c,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===c)return null;if(!1===y(c))return null;await c.load();const m=c.serviceUrl(),w=await d(m,e.spatialReference);let I=null,F=null,E=!1;if(null!==u&&""!==u&&void 0!==u){for(const e of w.terminals)e.terminalName===u&&(F=e.terminalId);null===F&&(E=!0)}const b=w.associations.getFieldsIndex(),A=b.get("TOGLOBALID").name,N=b.get("FROMGLOBALID").name,S=b.get("TOTERMINALID").name,T=b.get("FROMTERMINALID").name,$=b.get("FROMNETWORKSOURCEID").name,M=b.get("TONETWORKSOURCEID").name,O=b.get("ASSOCIATIONTYPE").name,k=b.get("ISCONTENTVISIBLE").name,z=b.get("OBJECTID").name;for(const e of c.fields)if("global-id"===e.type){I=l.field(e.name);break}let H=null,Z=new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex())),_=new v(new V({name:"side",alias:"side",type:"string"}),B.create("''",w.associations.getFieldsIndex()));const W="globalid",U="globalId",Q={};for(const e in w.lkp)Q[e]=w.lkp[e].sourceId;const J=new P(new V({name:"classname",alias:"classname",type:"string"}),null,Q);let K="";switch(o){case"midspan":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (5))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=G(j.findField(w.associations.fields,N));e.name=W,e.alias=W,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),Z=w.unVersion>=4?new C(j.findField(w.associations.fields,b.get("PERCENTALONG").name)):new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex()));break}case"junctionedge":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (4,6))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=G(j.findField(w.associations.fields,N));e.name=W,e.alias=W,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),_=new v(new V({name:"side",alias:"side",type:"string"}),B.create(`CASE WHEN (${O}=4) THEN 'from' ELSE 'to' END`,w.associations.getFieldsIndex()));break}case"connected":{let e=`${A}='@T'`,t=`${N}='@T'`;null!==F&&(e+=` AND ${S}=@A`,t+=` AND ${T}=@A`),K="(("+e+") OR ("+t+"))",K=L(K,"@T",I??""),e=L(e,"@T",I??""),null!==F&&(e=L(e,"@A",F.toString()),K=L(K,"@A",F.toString())),J.codefield=B.create("CASE WHEN "+e+` THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const n=G(j.findField(w.associations.fields,N));n.name=W,n.alias=W,H=new v(n,B.create("CASE WHEN "+e+` THEN ${N} ELSE ${A} END`,w.associations.getFieldsIndex()));break}case"container":K=`${A}='${I}' AND ${O} = 2`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),W,W);break;case"content":K=`(${N}='${I}' AND ${O} = 2)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),W,W);break;case"structure":K=`(${A}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),W,U);break;case"attached":K=`(${N}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),W,U);break;default:throw new i(e,a.InvalidParameter,t)}E&&(K="1 <> 1");return new j({parentfeatureset:w.associations,adaptedFields:[new C(j.findField(w.associations.fields,z)),new C(j.findField(w.associations.fields,k)),H,_,J,Z],extraFilter:K?B.create(K,w.associations.getFieldsIndex()):null})}))},W.signatures.push({name:"featuresetbyassociation",min:2,max:6}),W.functions.groupby=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{if(p(l,3,3,e,t),!y(l[0]))throw new i(e,a.InvalidParameter,t);const o=await l[0].load(),f=[],u=[];let c=!1,d=[];if(h(l[1]))d.push(l[1]);else if(l[1]instanceof n)d.push(l[1]);else if(b(l[1]))d=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);d=l[1].toArray()}for(const m of d)if(h(m)){const e=B.create(g(m),o.getFieldsIndex()),t=!0===_(e)?g(m):"%%%%FIELDNAME";f.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(c=!0)}else{if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"%%%%FIELDNAME",r=m.hasField("expression")?m.field("expression"):"";if("%%%%FIELDNAME"===n&&(c=!0),!n)throw new i(e,a.InvalidParameter,t);f.push({name:n,expression:B.create(r||n,o.getFieldsIndex())})}}if(d=[],h(l[2]))d.push(l[2]);else if(b(l[2]))d=l[2];else if(A(l[2]))d=l[2].toArray();else{if(!(l[2]instanceof n))throw new i(e,a.InvalidParameter,t);d.push(l[2])}for(const m of d){if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"",r=m.hasField("statistic")?m.field("statistic"):"",s=m.hasField("expression")?m.field("expression"):"";if(!n||!r||!s)throw new i(e,a.InvalidParameter,t);u.push({name:n,statistic:r.toLowerCase(),expression:B.create(s,o.getFieldsIndex())})}}if(c){const e={};for(const n of o.fields)e[n.name.toLowerCase()]=1;for(const n of f)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);for(const n of u)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of f)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const t of f)await K(t.expression,W,e);for(const t of u)await K(t.expression,W,e);return l[0].groupby(f,u)}))},W.signatures.push({name:"groupby",min:3,max:3}),W.functions.distinct=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{if(y(l[0])){p(l,2,2,e,t);const r=await l[0].load(),s=[];let o=[];if(h(l[1]))o.push(l[1]);else if(l[1]instanceof n)o.push(l[1]);else if(b(l[1]))o=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);o=l[1].toArray()}let f=!1;for(const l of o)if(h(l)){const e=B.create(g(l),r.getFieldsIndex()),t=!0===_(e)?g(l):"%%%%FIELDNAME";s.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(f=!0)}else{if(!(l instanceof n))throw new i(e,a.InvalidParameter,t);{const n=l.hasField("name")?l.field("name"):"%%%%FIELDNAME",o=l.hasField("expression")?l.field("expression"):"";if("%%%%FIELDNAME"===n&&(f=!0),!n)throw new i(e,a.InvalidParameter,t);s.push({name:n,expression:B.create(o||n,r.getFieldsIndex())})}}if(f){const e={};for(const n of r.fields)e[n.name.toLowerCase()]=1;for(const n of s)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of s)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const t of s)await K(t.expression,W,e);return l[0].groupby(s,[])}return J("distinct",r,s,l)}))})}export{ae as registerFunctions};
|