@arcgis/core 4.24.0-next.20220508 → 4.24.0-next.20220511
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/AggregateGraphic.js +1 -1
- package/analysis/Analysis.js +1 -1
- package/analysis/DimensioningAnalysis.js +1 -1
- package/analysis/LengthDimension.d.ts +4 -0
- package/analysis/LengthDimension.js +5 -0
- package/analysis/dimensionUtils.js +5 -0
- package/arcade/Dictionary.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/arcade.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/credentials.js +1 -1
- package/arcade/featureSetCollection.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/actions/AttributeFilter.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/actions/OrderBy.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/featureset/actions/Top.js +1 -1
- package/arcade/featureset/sources/Empty.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/FeatureSetIterator.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/arcade/featureset/support/stats.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade/request.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0564f1cfa3d17ff1aad3.js +1 -0
- package/assets/esri/core/workers/chunks/0806d5d706a864542bfb.js +1 -0
- package/assets/esri/core/workers/chunks/0a6977144ea1abf96fbf.js +1 -0
- package/assets/esri/core/workers/chunks/13387f56acbc3291561a.js +1 -0
- package/assets/esri/core/workers/chunks/16c4e0a32d50d4db984d.js +1 -0
- package/assets/esri/core/workers/chunks/{076d1b1101b59af0d389.js → 1c010202b4c7e1d15f23.js} +1 -1
- package/assets/esri/core/workers/chunks/26827ec144676e6385f8.js +1 -0
- package/assets/esri/core/workers/chunks/287c484fd40eee643f3a.js +1 -0
- package/assets/esri/core/workers/chunks/5210f0b42dba27945226.js +1 -0
- package/assets/esri/core/workers/chunks/{db6c5b3b4efe8d804f9c.js → 52478ee2d2a1354b6900.js} +1 -1
- package/assets/esri/core/workers/chunks/5759af97f96f24c40105.js +1 -0
- package/assets/esri/core/workers/chunks/{b85218d44c6094b7e5e6.js → 6d7e2a23a0a5dd9ded1d.js} +1 -1
- package/assets/esri/core/workers/chunks/70b6356357e7640c4e8b.js +1 -0
- package/assets/esri/core/workers/chunks/7574316b3af61c389e8f.js +1 -0
- package/assets/esri/core/workers/chunks/7bc828fbdd54c0b28aac.js +1 -0
- package/assets/esri/core/workers/chunks/7e5c22b5a32ac74b1b6e.js +1 -0
- package/assets/esri/core/workers/chunks/8102bb78fe96e6197e4e.js +1 -0
- package/assets/esri/core/workers/chunks/88384e7cafbfd2348598.js +1 -0
- package/assets/esri/core/workers/chunks/9d7533aaeac3b8d145c4.js +1 -0
- package/assets/esri/core/workers/chunks/{1eecae5227318f491263.js → 9f4d892abf55e8625bc9.js} +3 -3
- package/assets/esri/core/workers/chunks/{98607a0da63626cc4614.js → a054a52712a118c6d505.js} +1 -1
- package/assets/esri/core/workers/chunks/{69a20e4d9e28c3e599fc.js → a3bb600bfcb0282622f1.js} +1 -1
- package/assets/esri/core/workers/chunks/aa49841b14c6e6df2a07.js +1 -0
- package/assets/esri/core/workers/chunks/b089058b64db3912478f.js +1 -0
- package/assets/esri/core/workers/chunks/b28539c5a6bedb71b038.js +1 -0
- package/assets/esri/core/workers/chunks/b4f171db73355c6f766e.js +1 -0
- package/assets/esri/core/workers/chunks/b7572b0921b23aef8b9d.js +1 -0
- package/assets/esri/core/workers/chunks/b758f3c419edc2306784.js +1 -0
- package/assets/esri/core/workers/chunks/c3e7290fb128d4fefd44.js +1 -0
- package/assets/esri/core/workers/chunks/c51c9b5da855f84b9a48.js +1 -0
- package/assets/esri/core/workers/chunks/c66ac36da6392b6bf331.js +1 -0
- package/assets/esri/core/workers/chunks/d16b328d32a6ddc2fdb9.js +1 -0
- package/assets/esri/core/workers/chunks/d94c5f36d52cf71f0bb9.js +1 -0
- package/assets/esri/core/workers/chunks/db937849b2c1af87b481.js +1 -0
- package/assets/esri/core/workers/chunks/{66cd99e91dad60c5274c.js → dc3ed59f450283d97a19.js} +1 -1
- package/assets/esri/core/workers/chunks/dcd0653191cd4a1ccaae.js +2 -0
- package/assets/esri/core/workers/chunks/{31df729c17470245288c.js.LICENSE.txt → dcd0653191cd4a1ccaae.js.LICENSE.txt} +2 -2
- package/assets/esri/core/workers/chunks/e4fdd1eaf987977d0a51.js +1 -0
- package/assets/esri/core/workers/chunks/e51f0e71f2a55af604d3.js +1 -0
- package/assets/esri/core/workers/chunks/eb3855d3753d6b8334bd.js +1 -0
- package/assets/esri/core/workers/chunks/{7c290763920f52a1f504.js → eeed138930a4a805691d.js} +1 -1
- package/assets/esri/core/workers/chunks/f435dc615fdc8917f6ca.js +1 -0
- package/assets/esri/core/workers/chunks/{d5c5b9f7f5401f36a3a5.js → f7f3dde4c8f9c687cc1e.js} +1 -1
- package/assets/esri/core/workers/chunks/fc6beaf9466ea3898549.js +1 -0
- package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Tooltip.scss +1 -0
- package/assets/esri/themes/base/widgets/_Weather.scss +1 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/BlendLayers.glsl.js +6 -6
- package/chunks/arcade.js +1 -1
- package/chunks/array.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/config.js +1 -1
- package/core/sql/StandardizedFunctions.js +1 -1
- package/geohash/GeohashTree.js +1 -1
- package/geometry/support/contains.js +1 -1
- package/geometry/support/heightModelInfoUtils.js +1 -1
- package/geometry/support/intersects.js +1 -1
- package/geometry/support/intersectsBase.js +1 -1
- package/geometry/support/normalizeUtilsCommon.js +1 -1
- package/geometry/support/spatialReferenceUtils.js +1 -1
- package/interfaces.d.ts +685 -37
- package/layers/MediaLayer.d.ts +4 -0
- package/layers/MediaLayer.js +5 -0
- package/layers/VoxelLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +5 -0
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/data/BoundsStore.js +1 -1
- package/layers/support/CornersGeoreference.d.ts +4 -0
- package/layers/support/CornersGeoreference.js +5 -0
- package/layers/support/ExtentAndRotationGeoreference.d.ts +4 -0
- package/layers/support/ExtentAndRotationGeoreference.js +5 -0
- package/layers/support/FeatureReduction.js +1 -1
- package/layers/support/FeatureReductionBinning.js +5 -0
- package/layers/support/GeoreferenceBase.js +5 -0
- package/layers/support/ImageElement.d.ts +4 -0
- package/layers/support/ImageElement.js +5 -0
- package/layers/support/LocalMediaElementSource.d.ts +4 -0
- package/layers/support/LocalMediaElementSource.js +5 -0
- package/layers/support/MediaElementBase.d.ts +4 -0
- package/layers/support/MediaElementBase.js +5 -0
- package/layers/support/RouteStopSymbols.d.ts +4 -0
- package/layers/support/RouteSymbols.d.ts +4 -0
- package/layers/support/VoxelFormat.d.ts +4 -0
- package/layers/support/VoxelStyle.d.ts +4 -0
- package/layers/support/VoxelVariable.d.ts +4 -0
- package/layers/support/VoxelVolume.d.ts +4 -0
- package/layers/support/VoxelVolumeStyle.d.ts +4 -0
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/featureReductionUtils.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/rasterFormats/Lerc.js +1 -1
- package/package.json +3 -3
- package/request.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/Font.js +1 -1
- package/symbols/support/textUtils.js +1 -1
- package/views/2d/engine/brushes.js +1 -1
- package/views/2d/engine/webgl/FeatureTile.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +5 -0
- package/views/2d/engine/webgl/OverlayContainer.js +5 -0
- package/views/2d/engine/webgl/brushes/BrushOverlay.js +5 -0
- package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
- package/views/2d/engine/webgl/shaders/OverlayPrograms.js +5 -0
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layerViewModuleImportUtils.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/MapImageLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +5 -0
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/WMTSLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureStore2D.js +1 -1
- package/views/2d/layers/features/Pipeline.js +1 -1
- package/views/2d/layers/features/Store2D.js +1 -1
- package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
- package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/2d/layers/features/sources/GeoEventSource.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/BinStore.js +5 -0
- package/views/2d/layers/features/support/ClusterStore.js +1 -1
- package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/layers/support/clusterUtils.js +1 -1
- package/views/2d/magnifier/MagnifierView2D.js +1 -1
- package/views/2d/navigation/actions/Pinch.js +1 -1
- package/views/2d/viewpointUtils.js +1 -1
- package/views/3d/analysis/AnalysisView3D.js +1 -1
- package/views/3d/analysis/Dimensioning/DimensioningTool.js +5 -0
- package/views/3d/analysis/Dimensioning/DimensioningVisualization.js +1 -1
- package/views/3d/analysis/Dimensioning/LengthDimensionSubTool.js +5 -0
- package/views/3d/analysis/Dimensioning/{LinearDimensionVisualization.js → LengthDimensionVisualization.js} +1 -1
- package/views/3d/analysis/Dimensioning/settings.js +5 -0
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/interactive/SegmentLabels3D.js +5 -0
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/GraphicReshapeTool.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateObjectSymbol3DAdapter.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/layerViewModuleImportUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +5 -0
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/i3s/IDBCache.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/materials/WaterGLMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/ToolViewManager.js +1 -1
- package/views/View.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/InteractiveToolBase.js +1 -1
- package/views/interactive/SegmentLabels.js +5 -0
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/LineSnapper.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/snappingUtils.js +1 -1
- package/views/interactive/support/viewUtils.js +5 -0
- package/views/interactive/tooltip/DrawPointTooltipInfo.js +5 -0
- package/views/interactive/tooltip/DrawPolygonTooltipInfo.js +5 -0
- package/views/interactive/tooltip/DrawPolylineTooltipInfo.js +5 -0
- package/views/interactive/tooltip/Tooltip.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
- package/views/interactive/tooltip/support/measurements.js +5 -0
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/views/overlay/TextOverlayItem.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/screenUtils.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Feature/FeatureAttachments.js +1 -1
- package/widgets/Feature/FeatureContent/FeatureContentViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression.js +1 -1
- package/widgets/Feature/FeatureFields.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureForm/InputFieldGroup.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +11 -11
- package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/FeatureTemplates/TemplateItem.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/FloorFilter.js +1 -1
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/LayerList/LayerListViewModel.js +1 -1
- package/widgets/LayerList/ListItem.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/styles/Card.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
- package/widgets/Measurement.js +1 -1
- package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/Print/FileLink.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ScaleBar.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/TableList/ListItem.js +1 -1
- package/widgets/Weather/LabeledSlider.js +1 -1
- package/widgets/Weather/VisibleElements.js +5 -0
- package/widgets/Weather/css.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/support/AnalysisViewModel.js +1 -1
- package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
- package/analysis/LinearDimension.d.ts +0 -4
- package/analysis/LinearDimension.js +0 -5
- package/assets/esri/core/workers/chunks/0018053ac16a09feba70.js +0 -1
- package/assets/esri/core/workers/chunks/042938ca73f0b9e5a7e2.js +0 -1
- package/assets/esri/core/workers/chunks/048645611caa28dca7cd.js +0 -1
- package/assets/esri/core/workers/chunks/0b72d123386dc4ec7538.js +0 -1
- package/assets/esri/core/workers/chunks/13b04d5bf348ab5054c2.js +0 -1
- package/assets/esri/core/workers/chunks/215007e7c44811d90777.js +0 -1
- package/assets/esri/core/workers/chunks/31df729c17470245288c.js +0 -2
- package/assets/esri/core/workers/chunks/36272141b3c33cb19026.js +0 -1
- package/assets/esri/core/workers/chunks/36c8e8de9c3f67d32572.js +0 -1
- package/assets/esri/core/workers/chunks/37c428489c59df4b597b.js +0 -1
- package/assets/esri/core/workers/chunks/493169fd978fd543ef3b.js +0 -1
- package/assets/esri/core/workers/chunks/4f378ad6f4299183df85.js +0 -1
- package/assets/esri/core/workers/chunks/58e4c6ce1580427e7b55.js +0 -1
- package/assets/esri/core/workers/chunks/6c5441da675a8af35be2.js +0 -1
- package/assets/esri/core/workers/chunks/6ea16f6a0df946de480b.js +0 -1
- package/assets/esri/core/workers/chunks/7dfd70f4fa1096e56641.js +0 -1
- package/assets/esri/core/workers/chunks/88193e61072d7bf957f5.js +0 -1
- package/assets/esri/core/workers/chunks/8ccbde593c86c872e525.js +0 -1
- package/assets/esri/core/workers/chunks/9c6be39f1f21ab8b1c2d.js +0 -1
- package/assets/esri/core/workers/chunks/a73795cce722ba15b3da.js +0 -1
- package/assets/esri/core/workers/chunks/a8ed1a938dc164b401d9.js +0 -1
- package/assets/esri/core/workers/chunks/a9a73bc4875a5aeaf1b9.js +0 -1
- package/assets/esri/core/workers/chunks/adcc5bce6c0971c1b592.js +0 -1
- package/assets/esri/core/workers/chunks/afddfe620e6539991e6b.js +0 -1
- package/assets/esri/core/workers/chunks/b340c9bdabdb37995c8f.js +0 -1
- package/assets/esri/core/workers/chunks/b4c23630d6c85f7b59c0.js +0 -1
- package/assets/esri/core/workers/chunks/c180c40838246985479d.js +0 -1
- package/assets/esri/core/workers/chunks/caed2365bd296fcc8a75.js +0 -1
- package/assets/esri/core/workers/chunks/d85b5b73a151c6fbb658.js +0 -1
- package/assets/esri/core/workers/chunks/da6261673c3e1537b6a6.js +0 -1
- package/assets/esri/core/workers/chunks/dafe120243db6648a4ab.js +0 -1
- package/assets/esri/core/workers/chunks/ec6d138e8183e193f977.js +0 -1
- package/assets/esri/core/workers/chunks/ed4519ac9533a4d340f1.js +0 -1
- package/assets/esri/core/workers/chunks/f206300eef4560611728.js +0 -1
- package/assets/esri/core/workers/chunks/f55cbaf5a1d6ee6ac171.js +0 -1
- package/layers/GeoreferencedImageLayer.d.ts +0 -4
- package/layers/GeoreferencedImageLayer.js +0 -5
- package/layers/VoxelWasmManager.js +0 -5
- package/layers/VoxelWasmPerScene.js +0 -5
- package/views/3d/interactive/measurementTools/support/viewUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{cloneField as i,FeatureServiceDatabaseType as a,layerGeometryEsriConstants as l}from"../support/shared.js";import{reformulateWithoutField as n,toWhereClause as o,translateFunctionToDatabaseSpecific as h,makeToday as u,makeDateString as c,convertIntervalToSql as d,combine as p,scanForField as f}from"../support/sqlUtils.js";import{resolve as g,reject as _}from"../../../core/promiseUtils.js";import{WhereClause as N}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";class m{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class w extends m{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class v extends m{constructor(e,t,r){super(i(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:n(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class C extends m{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,a.Standardised,this.field.name,this.codefield instanceof N?o(this.codefield,a.Standardised):this.codefield,e.parameters);return r.includes(C.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:N.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,s=null,i){let a,l,n,o;switch(e.type){case"interval":return d(this.evaluateNodeToWhereClause(e.value,t,r,s,i),e.qualifier,e.op);case"case-expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,C.BADNESS,i));for(let a=0;a<e.clauses.length;a++)s+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[a].operand,t,r,C.BADNESS,i)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[a].value,t,r,C.BADNESS,i);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,C.BADNESS,i)),s+=" END ",s}case"parameter":{const r=i[e.value.toLowerCase()];if("string"==typeof r){return"'"+i[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return c(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(c(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expression-list":l=[];for(const a of e.value)l.push(this.evaluateNodeToWhereClause(a,t,r,s,i));return l;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,C.BADNESS,i)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,i)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,i)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" IS NOT NULL )";case"IN":if(a=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const a=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}a.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" IN ("+a.join(",")+")) "}return a=this.evaluateNodeToWhereClause(e.right,t,r,s,i)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" IN ("+a.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,i),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" IN ("+o+")) ";case"NOT IN":if(a=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const a=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}a.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" NOT IN ("+a.join(",")+")) "}return a=this.evaluateNodeToWhereClause(e.right,t,r,s,i)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" NOT IN ("+a.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,i),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" NOT IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,i)+" NOT IN ("+o+")) ";case"BETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"NOTBETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)," ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" NOT BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,C.BADNESS,i)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,C.BADNESS,i)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return c(e.value,t);case"number":return e.value.toString();case"current-time":return u("date"===e.mode,t);case"column-reference":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":e.column;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,C.BADNESS,i);return h(e.name,s,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof N?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}C.BADNESS="_!!!_BAD_LKP_!!!!";class T extends m{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:n(e,this.field.name,o(this.sql,a.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class E extends r{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new S({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new s(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):g(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(r,i,a,l){const n=[];-1!==i&&void 0===this._featureCache[i]&&n.push(i);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return this._expandPagedSet(r,o,0,0,l).then((()=>this._getFeatures(r,i,a,l)));let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=a&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==i&&n.push(r._known[e]),n.length>=o)));e++);if(0===n.length)return g("success");r=new s([],n,r._ordered,null);const u=Math.min(n.length,a);return this._parent._getFeatures(r,-1,u,l).then((()=>{this._checkCancelled(l);const r=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&r.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(const s of r){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(s);this._featureCache[s.id]=new e({attributes:r,geometry:t(s.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return _(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,i,a){let l=!1;const n=this._reformulateWithoutAdaptions(r);l=n.cannot,r=n.where;let o=!1;if(null!==i){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof w)&&!0===i.scanForField(t.field.name)){if(!(t instanceof v)){i=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}i&&e.length>0&&(i=i.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=p(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,i,a))).then((e=>{let t;return this._checkCancelled(a),t=!0===l?new s(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s(e._candidates.slice(0),e._known.slice(0),!0===o&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===f(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}_stat(e,t,r,s,i,a,l){let n=!1,o=this._reformulateWithoutAdaptions(t);return n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(i),n=n||o.cannot,null!==(i=o.where)?null!==this._extraFilter&&(i=p(this._extraFilter,i)):i=this._extraFilter,!0===n?null===i&&""===r&&null===s?this._manualStat(e,t,a,l):g({calculated:!1}):this._parent._stat(e,t,r,s,i,a,l).then((n=>!1===n.calculated?null===i&&""===r&&null===s?this._manualStat(e,t,a,l):{calculated:!1}:n))}_canDoAggregates(e,t,r,s,i){if(null===this._parent)return g(!1);for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof w))return g(!1);const a=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return g(!1);const r=e.clone();r.workingexpr=t.where,a.push(r)}else a.push(e)}const l=this._reformulateWithoutAdaptions(i);return l.cannot?g(!1):(null!==(i=l.where)?null!==this._extraFilter&&(i=p(this._extraFilter,i)):i=this._extraFilter,this._parent._canDoAggregates(e,a,r,s,i))}_getAggregatePagesDataSourceDefinition(e,t,r,s,i,a,l){if(null===this._parent)return _(new Error("Should never be called"));const n=[];for(let h=0;h<t.length;h++){const e=t[h];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return _(new Error("Should never be called"));const r=e.clone();r.workingexpr=t.where,n.push(r)}else n.push(e)}const o=this._reformulateWithoutAdaptions(i);return o.cannot?_(new Error("Should never be called")):(null!==(i=o.where)?null!==this._extraFilter&&(i=p(this._extraFilter,i)):i=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,n,r,s,i,a,l))}}export{E as AdaptedFeatureSet,m as AdaptedField,v as FieldRename,w as OriginalField,T as SqlExpressionAdapted,C as StringToCodeAdapted};
|
|
5
|
+
import e from"../../../Graphic.js";import{cloneGeometry as t}from"../../kernel.js";import r from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{cloneField as a,FeatureServiceDatabaseType as i,layerGeometryEsriConstants as l}from"../support/shared.js";import{reformulateWithoutField as n,toWhereClause as o,translateFunctionToDatabaseSpecific as h,makeToday as u,makeDateString as c,convertIntervalToSql as d,combine as p,scanForField as f}from"../support/sqlUtils.js";import{WhereClause as g}from"../../../core/sql/WhereClause.js";import _ from"../../../geometry/SpatialReference.js";class N{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class S extends N{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class w extends N{constructor(e,t,r){super(a(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:n(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class m extends N{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,i.Standardised,this.field.name,this.codefield instanceof g?o(this.codefield,i.Standardised):this.codefield,e.parameters);return r.includes(m.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:g.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,s=null,a){let i,l,n,o;switch(e.type){case"interval":return d(this.evaluateNodeToWhereClause(e.value,t,r,s,a),e.qualifier,e.op);case"case-expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,m.BADNESS,a));for(let i=0;i<e.clauses.length;i++)s+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[i].operand,t,r,m.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[i].value,t,r,m.BADNESS,a);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,m.BADNESS,a)),s+=" END ",s}case"parameter":{const r=a[e.value.toLowerCase()];if("string"==typeof r){return"'"+a[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'"}if(r instanceof Date)return c(r,t);if(r instanceof Array){const e=[];for(let s=0;s<r.length;s++)"string"==typeof r[s]?e.push("'"+r[s].toString().replace(/'/g,"''")+"'"):r[s]instanceof Date?e.push(c(r[s],t)):e.push(r[s].toString());return e}return r.toString()}case"expression-list":l=[];for(const i of e.value)l.push(this.evaluateNodeToWhereClause(i,t,r,s,a));return l;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,m.BADNESS,a)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NOT NULL )";case"IN":if(i=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+o+")) ";case"NOT IN":if(i=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this.lkp[t.value]){l=!1;break}i.push(this.lkp[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return i=this.evaluateNodeToWhereClause(e.right,t,r,s,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,t,r,s,a),o instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+o+")) ";case"BETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"NOTBETWEEN":return n=this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" NOT BETWEEN "+n[0]+" AND "+n[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,m.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,m.BADNESS,a)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return c(e.value,t);case"number":return e.value.toString();case"current-time":return u("date"===e.mode,t);case"column-reference":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":e.column;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,m.BADNESS,a);return h(e.name,s,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof g?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}m.BADNESS="_!!!_BAD_LKP_!!!!";class v extends N{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:n(e,this.field.name,o(this.sql,i.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class C extends r{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new _({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=null;return t=this._extraFilter?await this._getFilteredSet("",null,null,null,e):await this._parent._getSet(e),this._checkCancelled(e),this._wset=new s(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}async _getFeatures(r,a,i,l){const n=[];-1!==a&&void 0===this._featureCache[a]&&n.push(a);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(r,o))return await this._expandPagedSet(r,o,0,0,l),this._getFeatures(r,a,i,l);let h=0;for(let e=r._lastFetchedIndex;e<r._known.length&&(h++,h<=i&&(r._lastFetchedIndex+=1),!(void 0===this._featureCache[r._known[e]]&&(r._known[e]!==a&&n.push(r._known[e]),n.length>=o)));e++);if(0===n.length)return"success";r=new s([],n,r._ordered,null);const u=Math.min(n.length,i);await this._parent._getFeatures(r,-1,u,l),this._checkCancelled(l);const c=[];for(let e=0;e<u;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&c.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(const s of c){const r=[];for(const e of this.adaptedFields)r[e.field.name]=e.extractValue(s);this._featureCache[s.id]=new e({attributes:r,geometry:t(s.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new Error("Fetch and Refine should not be called in this featureset")}async _getFilteredSet(e,t,r,a,i){let l=!1;const n=this._reformulateWithoutAdaptions(r);l=n.cannot,r=n.where;let o=!1;if(null!==a){o=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof S)&&!0===a.scanForField(t.field.name)){if(!(t instanceof w)){a=null,o=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}a&&e.length>0&&(a=a.replaceFields(e))}null!==r?null!==this._extraFilter&&(r=p(this._extraFilter,r)):r=this._extraFilter,await this._ensureLoaded();const h=await this._parent._getFilteredSet(e,t,r,a,i);let u;return this._checkCancelled(i),u=!0===l?new s(h._candidates.slice(0).concat(h._known.slice(0)),[],!0===o&&h._ordered,this._clonePageDefinition(h.pagesDefinition)):new s(h._candidates.slice(0),h._known.slice(0),!0===o&&h._ordered,this._clonePageDefinition(h.pagesDefinition)),u}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===f(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}async _stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);if(n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,!0===n)return null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1};const h=await this._parent._stat(e,t,r,s,a,i,l);return!1===h.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:h}async _canDoAggregates(e,t,r,s,a){if(null===this._parent)return!1;for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof S))return!1;const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return!1;const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return!l.cannot&&(null!==(a=l.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}async _getAggregatePagesDataSourceDefinition(e,t,r,s,a,i,l){if(null===this._parent)throw new Error("Should never be called");const n=[];for(let h=0;h<t.length;h++){const e=t[h];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)throw new Error("Should never be called");const r=e.clone();r.workingexpr=t.where,n.push(r)}else n.push(e)}const o=this._reformulateWithoutAdaptions(a);if(o.cannot)throw new Error("Should never be called");return null!==(a=o.where)?null!==this._extraFilter&&(a=p(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,n,r,s,a,i,l)}}export{C as AdaptedFeatureSet,N as AdaptedField,w as FieldRename,S as OriginalField,v as SqlExpressionAdapted,m as StringToCodeAdapted};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../support/FeatureSet.js";import t from"../support/IdSet.js";import{layerGeometryEsriConstants as s,IdState as i}from"../support/shared.js";import{combine as r}from"../support/sqlUtils.js";import{
|
|
5
|
+
import e from"../support/FeatureSet.js";import t from"../support/IdSet.js";import{layerGeometryEsriConstants as s,IdState as i}from"../support/shared.js";import{combine as r}from"../support/sqlUtils.js";import{isPromiseLike as n}from"../../../core/promiseUtils.js";import{WhereClause as a}from"../../../core/sql/WhereClause.js";import l from"../../../geometry/SpatialReference.js";class h extends e{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof a?(this._whereclause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereclause=null)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new l({wkid:4326}),this.geometryType=s.point)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const s=await this._parent._getFilteredSet("",null,this._whereclause,null,e);return this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new t(s._candidates.slice(0).concat(s._known.slice(0)),[],s._ordered,this._clonePageDefinition(s.pagesDefinition)):this._wset=new t(s._candidates.slice(0),s._known.slice(0),s._ordered,this._clonePageDefinition(s.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===i.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?i.Unknown:t)}_getFeature(e,t,s){return this._parent._getFeature(e,t,s)}_getFeatures(e,t,s,i){return this._parent._getFeatures(e,t,s,i)}_featureFromCache(e){return this._parent._featureFromCache(e)}executeWhereClause(e){return this._whereclause.testFeature(e)}async executeWhereClauseDeferred(e){if(null!==this._whereClauseFunction){const t=this._whereClauseFunction(e);return n(t),t}return this.executeWhereClause(e)}async _fetchAndRefineFeatures(e,s,r){const n=new t([],e,!1,null),a=Math.min(s,e.length);if(await this._parent._getFeatures(n,-1,a,r),this._checkCancelled(r),null==this._whereClauseFunction){for(let t=0;t<a;t++){const s=this._parent._featureFromCache(e[t]);!0===this.executeWhereClause(s)?this._idstates[e[t]]=i.InFeatureSet:this._idstates[e[t]]=i.NotInFeatureSet}return"success"}const l=[];for(let t=0;t<a;t++){const s=this._parent._featureFromCache(e[t]);l.push(await this.executeWhereClauseDeferred(s))}for(let t=0;t<s;t++)!0===l[t]?this._idstates[e[t]]=i.InFeatureSet:this._idstates[e[t]]=i.NotInFeatureSet;return"success"}async _getFilteredSet(e,s,i,n,a){null!==this._whereClauseFunction||(null!==i?null!==this._whereclause&&(i=r(this._whereclause,i)):i=this._whereclause),await this._ensureLoaded();const l=await this._parent._getFilteredSet(e,s,i,n,a);let h;return this._checkCancelled(a),h=null!==this._whereClauseFunction?new t(l._candidates.slice(0).concat(l._known.slice(0)),[],l._ordered,this._clonePageDefinition(l.pagesDefinition)):new t(l._candidates.slice(0),l._known.slice(0),l._ordered,this._clonePageDefinition(l.pagesDefinition)),h}async _stat(e,t,s,i,n,a,l){if(null!==this._whereClauseFunction)return null===n&&""===s&&null===i?this._manualStat(e,t,a,l):{calculated:!1};let h=this._whereclause;null!==n&&null!==this._whereclause&&(h=r(this._whereclause,n));const u=await this._parent._stat(e,t,s,i,h,a,l);return!1===u.calculated?null===n&&""===s&&null===i?this._manualStat(e,t,a,l):{calculated:!1}:u}async _canDoAggregates(e,t,s,i,n){return null===this._whereClauseFunction&&(null!==n?null!==this._whereclause&&(n=r(this._whereclause,n)):n=this._whereclause,null!==this._parent&&this._parent._canDoAggregates(e,t,s,i,n))}async _getAggregatePagesDataSourceDefinition(e,t,s,i,n,a,l){if(null===this._parent)throw new Error("Should never be called");return null!==n?null!==this._whereclause&&(n=r(this._whereclause,n)):n=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(e,t,s,i,n,a,l)}static registerAction(){e._featuresetFunctions.filter=function(e){if("function"==typeof e)return new h({parentfeatureset:this,whereclause:e});let t=null;return e instanceof a&&(t=e),new h({parentfeatureset:this,whereclause:t})}}}export{h as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{X as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as h}from"../support/shared.js";import{isSingleField as c,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{resolve as I,reject as S,create as x}from"../../../core/promiseUtils.js";import{WhereClause as k}from"../../../core/sql/WhereClause.js";import D from"../../../geometry/SpatialReference.js";import A from"../../../layers/support/Field.js";import j from"../../../layers/support/FieldsIndex.js";function C(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class G extends l{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_getSet(e){return null===this._wset?this._getFilteredSet("",null,null,null,e).then((e=>(this._wset=e,this._wset))):I(this._wset)}_isInFeatureSet(){return u.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new j([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof k?i.expression:k.create(i.expression,r),e.typeofstat=C(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof k?i.expression:k.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new D({wkid:4326});this.fields=[];const a=new b;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=k.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new A;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,c(s.expression)){const e=this._parent.getField(p(s.expression,h.Standardised));if(!e)throw new Error("Field is not present for Aggregation");s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new A;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new A;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&c(n.workingexpr)?p(n.workingexpr,h.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new Error("Field is not present for Aggregation");t.type="double"}this.fields.push(t)}}_canDoAggregates(){return I(!1)}_getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?this._expandPagedSet(e,n,0,0,s).then((()=>this._getFeatures(e,t,i,s))):I("success")}_getFilteredSet(e,t,i,s,l){if(""!==e)return I(new o([],[],!0,null));let u=null;const f={ordered:!1,nowhereclause:!1};return this._ensureLoaded().then((()=>{if(null!==i)for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===_(i,this._decodedStatsfield[e].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}return!1===this._candosimplegroupby?I(!1):this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)})).then((e=>{if(e){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;return s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s)),this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField).then((e=>(this._checkCancelled(l),u=!0===f.nowhereclause?new o(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===f.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new o(e._candidates.slice(0),e._known.slice(0),!0===f.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),u)))}let t=this._parent;if(this._adaptedFields.length>0&&(t=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:t,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=t;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}))}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,h.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,h.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}_refineSetBlock(e,t,i){try{if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return this._expandPagedSet(e,this._maxQuery,0,0,i).then((()=>this._refineSetBlock(e,t,i)));this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,I(e)}catch(s){return S(s)}}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}_getPhysicalPage(t,i,s){return!0===t.pagesDefinition.aggregatefeaturesetpagedefinition?x(((e,i)=>{this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]).then((t=>{e(t)}),i)})):this._getAgregagtePhysicalPage(t,i,s).then((t=>{for(const i of t){const t={geometry:i.geometry,attributes:{}};for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i.attributes[e.name];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i.attributes[e.field];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return t.length}))}_sequentialGetPhysicalItem(e,t,i,s){return x(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const l=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:l},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(l){a(l)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}_stat(){return I({calculated:!1})}getFeatureByObjectId(){return I(null)}static registerAction(){l._featuresetFunctions.groupby=function(e,t){return new G({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{G as default};
|
|
5
|
+
import e from"../../../Graphic.js";import{X as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as c}from"../support/shared.js";import{isSingleField as h,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{WhereClause as I}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/Field.js";import k from"../../../layers/support/FieldsIndex.js";function D(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class A extends l{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return u.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new k([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof I?i.expression:I.create(i.expression,r),e.typeofstat=D(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof I?i.expression:I.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new S({wkid:4326});this.fields=[];const a=new b;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=I.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new x;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,h(s.expression)){const e=this._parent.getField(p(s.expression,c.Standardised));if(!e)throw new Error("Field is not present for Aggregation");s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new x;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new x;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&h(n.workingexpr)?p(n.workingexpr,c.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new Error("Field is not present for Aggregation");t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new Error("Field is not present for Aggregation");t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,l){if(""!==e)return new o([],[],!0,null);let u=null;const f={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===_(i,this._decodedStatsfield[n].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(l),u=!0===f.nowhereclause?new o(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new o(n._candidates.slice(0),n._known.slice(0),!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),u}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new o(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,c.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,c.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}};for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=r.attributes[e.name];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=r.attributes[e.field];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const l=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:l},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(l){a(l)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){l._featuresetFunctions.groupby=function(e,t){return new A({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{A as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{X as e}from"../../../chunks/languageUtils.js";import t from"../support/FeatureSet.js";import
|
|
5
|
+
import{X as e}from"../../../chunks/languageUtils.js";import t from"../support/FeatureSet.js";import n from"../support/IdSet.js";import r from"../support/OrderbyClause.js";class s extends t{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,this._orderbyclause,e);return this._checkCancelled(e),this._wset=t,this._wset}return this._wset}async manualOrderSet(e,t){const r=await this.getIdColumnDictionary(e,[],-1,t);this._orderbyclause.order(r);const s=new n([],[],!0,null);for(let n=0;n<r.length;n++)s._known.push(r[n].id);return s}async getIdColumnDictionary(t,n,r,s){if(r<t._known.length-1){const i=this._maxQueryRate();if("GETPAGES"===t._known[r+1])return await e(this._parent._expandPagedSet(t,i,0,0,s)),this.getIdColumnDictionary(t,n,r,s);let a=r+1;const o=[];for(;a<t._known.length&&"GETPAGES"!==t._known[a];)o.push(t._known[a]),a++;r+=o.length;const c=await e(this._parent._getFeatureBatch(o,s));this._checkCancelled(s);for(const e of c)n.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(t,n,r,s)}return t._candidates.length>0?(await e(this._refineSetBlock(t,this._maxProcessingRate(),s)),this._checkCancelled(s),this.getIdColumnDictionary(t,n,r,s)):n}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,n,r){return this._parent._getFeatures(e,t,n,r)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}async _fetchAndRefineFeatures(){throw new Error("Fetch and Refine should not be called in this featureset")}async _getFilteredSet(e,t,r,s,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===s?this._orderbyclause:s,i);this._checkCancelled(i);const o=new n(a._candidates.slice(0),a._known.slice(0),a._ordered,this._clonePageDefinition(a.pagesDefinition));let c=!0;if(a._candidates.length>0&&(c=!1),!1===o._ordered){let e=await this.manualOrderSet(o,i);return!1===c&&(null===t&&null===r||(e=new n(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){t._featuresetFunctions.orderBy=function(e){return""===e?this:new s({parentfeatureset:this,orderbyclause:new r(e)})}}}export{s as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../sources/Empty.js";import t from"../support/FeatureSet.js";import
|
|
5
|
+
import e from"../sources/Empty.js";import t from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{IdState as n,shapeExtent as r}from"../support/shared.js";import{relate as a,crosses as s,touches as l,within as o,overlaps as u,contains as h,intersects as _}from"../../../geometry/geometryEngineAsync.js";class c extends t{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 i(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===n.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?n.Unknown:t)}_getFeature(e,t,i){return this._parent._getFeature(e,t,i)}_getFeatures(e,t,i,n){return this._parent._getFeatures(e,t,i,n)}_featureFromCache(e){return this._parent._featureFromCache(e)}async executeSpatialRelationTest(e){if(null===e.geometry)return!1;switch(this._relation){case"esriSpatialRelEnvelopeIntersects":{const t=r(this._relationGeom),i=r(e.geometry);return _(t,i)}case"esriSpatialRelIntersects":return _(this._relationGeom,e.geometry);case"esriSpatialRelContains":return h(this._relationGeom,e.geometry);case"esriSpatialRelOverlaps":return u(this._relationGeom,e.geometry);case"esriSpatialRelWithin":return o(this._relationGeom,e.geometry);case"esriSpatialRelTouches":return l(this._relationGeom,e.geometry);case"esriSpatialRelCrosses":return s(this._relationGeom,e.geometry);case"esriSpatialRelRelation":return a(this._relationGeom,e.geometry,this._relationString)}}async _fetchAndRefineFeatures(e,t,r){const a=new i([],e,!1,null),s=Math.min(t,e.length);await this._parent._getFeatures(a,-1,s,r),this._checkCancelled(r);const l=[];for(let i=0;i<s;i++){const t=this._parent._featureFromCache(e[i]);l.push(await this.executeSpatialRelationTest(t))}for(let i=0;i<t;i++)!0===l[i]?this._idstates[e[i]]=n.InFeatureSet:this._idstates[e[i]]=n.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,n,r,a){await this._ensureLoaded();const s=await this._parent._getFilteredSet("esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,n,r,a);let l;return this._checkCancelled(a),l=null!==t?new i(s._candidates.slice(0).concat(s._known.slice(0)),[],s._ordered,this._clonePageDefinition(s.pagesDefinition)):new i(s._candidates.slice(0),s._known.slice(0),s._ordered,this._clonePageDefinition(s.pagesDefinition)),l}async _stat(e,t,i,n,r,a,s){if(""!==i)return{calculated:!1};const l=await this._parent._stat(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,r,a,s);return!1===l.calculated?null===r&&""===i&&null===n?this._manualStat(e,t,a,s):{calculated:!1}:l}async _canDoAggregates(e,t,i,n,r){return""===i&&null===n&&(null!==this._parent&&this._parent._canDoAggregates(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,r))}async _getAggregatePagesDataSourceDefinition(e,t,i,n,r,a,s){if(null===this._parent)throw new Error("Should never be called");return this._parent._getAggregatePagesDataSourceDefinition(e,t,"esriSpatialRelRelation"!==this._relation?this._relation:this._relation+":"+this._relationString,this._relationGeom,r,a,s)}static registerAction(){t._featuresetFunctions.intersects=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelIntersects",relationGeom:t})},t._featuresetFunctions.envelopeIntersects=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelEnvelopeIntersects",relationGeom:t})},t._featuresetFunctions.contains=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelContains",relationGeom:t})},t._featuresetFunctions.overlaps=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelOverlaps",relationGeom:t})},t._featuresetFunctions.within=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelWithin",relationGeom:t})},t._featuresetFunctions.touches=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelTouches",relationGeom:t})},t._featuresetFunctions.crosses=function(t){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelCrosses",relationGeom:t})},t._featuresetFunctions.relate=function(t,i){return null==t?new e({parentfeatureset:this}):new c({parentfeatureset:this,relation:"esriSpatialRelRelation",relationGeom:t,relationString:i})}}}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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../support/FeatureSet.js";import e from"../support/IdSet.js";import{IdState as n}from"../support/shared.js";
|
|
5
|
+
import t from"../support/FeatureSet.js";import e from"../support/IdSet.js";import{IdState as n}from"../support/shared.js";class s extends t{constructor(t){super(t),this._topnum=0,this.declaredClass="esri.arcade.featureset.actions.Top",this._countedin=0,this._maxProcessing=100,this._topnum=t.topnum,this._parent=t.parentfeatureset}async _getSet(t){if(null===this._wset){await this._ensureLoaded();const n=await this._parent._getSet(t);return this._wset=new e(n._candidates.slice(0),n._known.slice(0),!1,this._clonePageDefinition(n.pagesDefinition)),this._setKnownLength(this._wset)>this._topnum&&(this._wset._known=this._wset._known.slice(0,this._topnum)),this._setKnownLength(this._wset)>=this._topnum&&(this._wset._candidates=[]),this._wset}return this._wset}_setKnownLength(t){return t._known.length>0&&"GETPAGES"===t._known[t._known.length-1]?t._known.length-1:t._known.length}_isInFeatureSet(t){const e=this._parent._isInFeatureSet(t);if(e===n.NotInFeatureSet)return e;const s=this._idstates[t];return s===n.InFeatureSet||s===n.NotInFeatureSet?s:e===n.InFeatureSet&&void 0===s?this._countedin<this._topnum?(this._idstates[t]=n.InFeatureSet,this._countedin++,n.InFeatureSet):(this._idstates[t]=n.NotInFeatureSet,n.NotInFeatureSet):n.Unknown}async _expandPagedSet(t,e,n,s,i){if(null===this._parent)throw new Error("Parent Paging not implemented");if(e>this._topnum&&(e=this._topnum),this._countedin>=this._topnum&&t.pagesDefinition.internal.set.length<=t.pagesDefinition.resultOffset){let e=t._known.length;return e>0&&"GETPAGES"===t._known[e-1]&&(t._known.length=e-1),e=t._candidates.length,e>0&&"GETPAGES"===t._candidates[e-1]&&(t._candidates.length=e-1),"success"}const a=await this._parent._expandPagedSet(t,e,n,s,i);return this._setKnownLength(t)>this._topnum&&(t._known.length=this._topnum),this._setKnownLength(t)>=this._topnum&&(t._candidates.length=0),a}async _getFeatures(t,n,s,i){const a=[],o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(t,o))return await this._expandPagedSet(t,o,0,0,i),this._getFeatures(t,n,s,i);-1!==n&&void 0===this._featureCache[n]&&a.push(n);let r=0;for(let e=t._lastFetchedIndex;e<t._known.length&&(r++,r<=s&&(t._lastFetchedIndex+=1),!(void 0===this._featureCache[t._known[e]]&&(t._known[e]!==n&&a.push(t._known[e]),a.length>o)));e++);if(0===a.length)return"success";const _=new e([],a,!1,null),h=Math.min(a.length,s);await this._parent._getFeatures(_,-1,h,i);for(let e=0;e<h;e++){const t=this._parent._featureFromCache(a[e]);void 0!==t&&(this._featureCache[a[e]]=t)}return"success"}async _getFilteredSet(t,n,s,i,a){await this._ensureLoaded();const o=await this._getSet(a);return new e(o._candidates.slice(0).concat(o._known.slice(0)),[],!1,this._clonePageDefinition(o.pagesDefinition))}_refineKnowns(t,e){let s=0,i=null;const a=[];for(let o=0;o<t._candidates.length;o++){const r=this._isInFeatureSet(t._candidates[o]);if(r===n.InFeatureSet){if(t._known.push(t._candidates[o]),s+=1,null===i?i={start:o,end:o}:i.end===o-1?i.end=o:(a.push(i),i={start:o,end:o}),t._known.length>=this._topnum)break}else if(r===n.NotInFeatureSet)null===i?i={start:o,end:o}:i.end===o-1?i.end=o:(a.push(i),i={start:o,end:o}),s+=1;else if(r===n.Unknown)break;if(s>=e)break}null!==i&&a.push(i);for(let n=a.length-1;n>=0;n--)t._candidates.splice(a[n].start,a[n].end-a[n].start+1);this._setKnownLength(t)>this._topnum&&(t._known=t._known.slice(0,this._topnum)),this._setKnownLength(t)>=this._topnum&&(t._candidates=[])}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!1}static registerAction(){t._featuresetFunctions.top=function(t){return new s({parentfeatureset:this,topnum:t})}}}export{s as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../support/FeatureSet.js";import t from"../support/IdSet.js";import{FeatureServiceDatabaseType as r,IdState as s}from"../support/shared.js";
|
|
5
|
+
import e from"../support/FeatureSet.js";import t from"../support/IdSet.js";import{FeatureServiceDatabaseType as r,IdState as s}from"../support/shared.js";class a extends e{constructor(e){super(e),this.declaredClass="esri.layers.featureset.sources.Empty",this._maxProcessing=1e3,this._wset=new t([],[],!1,null),this._parent=e.parentfeatureset,this._databaseType=r.Standardised}async _getSet(){return this._wset}optimisePagingFeatureQueries(){}_isInFeatureSet(){return s.NotInFeatureSet}async _getFeature(){throw new Error("No Feature Found in EmptySet")}async queryAttachments(){return[]}async _getFeatures(){return"success"}_featureFromCache(){return null}async _fetchAndRefineFeatures(){throw new Error("Fetch and Refine should not be called in this featureset")}async _getFilteredSet(){return new t([],[],!1,null)}_stat(e,t,r,s,a,n,u){return this._manualStat(e,t,n,u)}async _canDoAggregates(){return!1}}export{a as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as R}from"../../../rest/query/executeQueryJSON.js";import"../../../core/arrayUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/FeatureSet.js";import w from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as I}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeForIds as q}from"../../../rest/query/executeForIds.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import j from"../../../rest/support/StatisticDefinition.js";import C from"../../Dictionary.js";class v extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new w;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>x.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?R:"executeForCount"===t?I:q,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new w;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new w;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new w;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new w;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new w;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new w;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new j;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new j;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new w;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new v({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=C.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new w;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),R(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{const e=f?.findCredential(this._layer.url);return e?e.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{const e=f?.findServerInfo(this._layer.url);if(e)return m(e.owningSystemUrl);let r=this._layer.url;const i=r.toLowerCase().indexOf("/rest/services");return r=i>-1?r.substring(0,i):r,r?(r+="/rest/info",_(((e,i)=>{t(r,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new v({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{v 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 h}from"../support/sqlUtils.js";import{decodeStatType as c}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 _}from"../../../geometry/support/jsonUtils.js";import m from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as g}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/promiseUtils.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as F}from"../../../rest/query/executeQueryJSON.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 b from"../../../rest/support/FeatureSet.js";import R from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as w}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 x}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import I from"../../../rest/support/StatisticDefinition.js";import q from"../../Dictionary.js";class P 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,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return 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._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const i of this._layer.outFields)if(i.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const 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.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 R;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){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}async queryPBF(e){e.quantizationParameters={mode:"edit"};const t=await S(this._layer.parsedUrl,e,new x({}));return b.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?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?F:"executeForCount"===t?w: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 R;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 h=await this.executeQuery(u,"executeForIds");null===h&&(h=[]),this._checkCancelled(a);return new s([],h,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 h=this._maxQueryRate();const c=this._layer.capabilities.query.maxRecordCount;void 0!==c&&c<h&&(h=c);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:h,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=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:h,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,h,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 R;this._requestStandardised&&(n.sqlFormat="standard"),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";for(let o=0;o<l.features.length;o++)e.pagesDefinition.internal.set[s+o]=l.features[o].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let o=0;o<l.features.length;o++)this._featureCache[l.features[o].attributes[this._layer.objectIdField]]=l.features[o];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 o=e._lastFetchedIndex;o<e._known.length;o++){if(e._lastFetchedIndex+=1,a++,void 0===this._featureCache[e._known[o]]){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[o]]){const r=t._featureMap[e._known[o]];null!==r&&(i=!0,this._featureCache[e._known[o]]=r)}}if(!1===i&&(e._known[o]!==t&&s.push(e._known[o]),s.length>=this._maxProcessingRate()-1))break}if(a>=i&&0===s.length)break}if(0===s.length)return"success";const n=new R;this._requestStandardised&&(n.sqlFormat="standard"),n.objectIds=s,n.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),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 Error(l.error);for(let o=0;o<l.features.length;o++)this._featureCache[l.features[o].attributes[this._layer.objectIdField]]=l.features[o];return"success"}async _getDistinctPages(e,t,i,r,s,a,n,l,o){await this._ensureLoaded();const u=await this.databaseType();let h=i.parseTree.column;for(let d=0;d<this._layer.fields.length;d++)if(this._layer.fields[d].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[d].name;break}const c=new R;this._requestStandardised&&(c.sqlFormat="standard");let p=null===a?null===s?"1=1":"":d(a,u);this._layer.definitionExpression&&this._useDefinitionExpression&&(p=""!==p?"(("+this._layer.definitionExpression+") AND ("+p+"))":this._layer.definitionExpression),c.where=p,c.spatialRelationship=this._makeRelationshipEnum(r),c.relationParameter=this._makeRelationshipParam(r),c.geometry=null===s?null:s,c.returnDistinctValues=!0,c.returnGeometry=!1,c.outFields=[h];const y=await this.executeQuery(c,"execute");if(this._checkCancelled(o),!y.hasOwnProperty("features"))throw new Error("Unnexected Result querying statistics from layer");let f=!1;for(let d=0;d<this._layer.fields.length;d++)if(this._layer.fields[d].name===h){"date"===this._layer.fields[d].type&&(f=!0);break}for(let d=0;d<y.features.length;d++){if(f){const e=y.features[d].attributes[h];null!==e?l.push(new Date(e)):l.push(e)}else l.push(y.features[d].attributes[h]);if(l.length>=n)break}if(0===y.features.length)return l;if(y.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n){return{calculated:!0,result:await this._getDistinctPages(e+y.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}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new R;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,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===h(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 R;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;const _=new I;_.statisticType=c(e),_.onStatisticField=d(t,p),_.outStatisticFieldName="ARCADE_STAT_RESULT",y.returnGeometry=!1;let m="ARCADE_STAT_RESULT";y.outStatistics=[_];const g=await this.executeQuery(y,"execute");if(!g.hasOwnProperty("features")||0===g.features.length)throw new Error("Unnexected Result querying statistics from layer");let F=!1;for(let d=0;d<g.fields.length;d++)if("ARCADE_STAT_RESULT"===g.fields[d].name.toUpperCase()){m=g.fields[d].name,"date"===g.fields[d].type&&(F=!0);break}if(F){let e=g.features[0].attributes[m];return null!==e&&(e=new Date(g.features[0].attributes[m])),{calculated:!0,result:e}}return{calculated:!0,result:g.features[0].attributes[m]}}_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&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(i=!0),i)for(let s=0;s<t.length-1;s++)null!==t[s].workingexpr&&(!1===t[s].workingexpr.isStandardized||!1===h(t[s].workingexpr)&&!1===r)&&(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="",h=!1,c=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),c=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(c=!1,h=!0,u=this._layer.objectIdField);const p=[];for(let s=0;s<t.length;s++){const e=new I;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;void 0!==f&&f<y&&(y=f);let _=null===a?null===r?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],c,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:p,geometry:null===r?null:r,where:_,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 R;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,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 Error("Unnexected Result querying aggregates from layer");const d=[];if(t.pagesDefinition.internal.lastPage!==l)return[];for(let e=0;e<u.features.length;e++)t.pagesDefinition.internal.set[n+e]=u.features[e].attributes[t.pagesDefinition.generatedOid];for(let h=0;h<u.features.length;h++)d.push(new e({attributes:u.features[h].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 m({url:e,outFields:null===t?["*"]:t});return new P({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){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.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=q.convertJsonToArcade(t.exifInfo,!0)),o.push(new i(t.id,t.name,t.contentType,t.size,r,s))})),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.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?_(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new Error("Invalid Request")}async getFeatureByObjectId(e,t){const i=new R;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),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 P({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{P as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../support/FeatureSet.js";import
|
|
5
|
+
import e from"../../../Graphic.js";import t from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as r,FeatureServiceDatabaseType as i,IdState as a}from"../support/shared.js";import{toWhereClause as l}from"../support/sqlUtils.js";import n from"../../../geometry/Geometry.js";import o from"../../../layers/FeatureLayer.js";import u from"../../../layers/support/FeatureType.js";import h from"../../../layers/support/Field.js";import c from"../../../rest/support/Query.js";class y extends t{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return r}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),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const s of this._layer.outFields)if(s.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const s of this.fields)if("oid"===s.type)e.push(s),t.push(s.name);else for(const r of this._overrideFields)if(r.toLowerCase()===s.name.toLowerCase()){e.push(s),t.push(s.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this._databaseType=i.Standardised,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}isTable(){return this._forceIsTable||this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return a.InFeatureSet}_candidateIdTransform(e){return e}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 s={};for(const e of this.fields)s[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:s})}async _getFilteredSet(e,t,r,a,n){let o="",u=!1;if(null!==a&&(o=a.constructClause(),u=!0),this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}const h=new c;h.where=null===r?null===t?"1=1":"":l(r,i.Standardised),h.spatialRelationship=this._makeRelationshipEnum(e),h.outSpatialReference=this.spatialReference,h.orderByFields=""!==o?o.split(","):null,h.geometry=null===t?null:t,h.returnGeometry=!0,h.relationParameter=this._makeRelationshipParam(e);const y=await this._layer.queryFeatures(h);if(null===y)return new s([],[],u,null);this._checkCancelled(n);const d=[];y.features.forEach((e=>{const t=e.attributes[this._layer.objectIdField];d.push(t),this._featureCache[t]=this._changeFeature(e)}));return new s([],d,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 c;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 s=t.attributes[this._layer.objectIdField];e.push(s),this._featureCache[s]=this._changeFeature(t)})),this._wset=new s([],e,!1,null),this._wset}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 s([],r,!1,null),this._wset}async _getFeatures(e,t,s){const r=[];-1!==t&&void 0===this._featureCache[t]&&r.push(t);for(let i=e._lastFetchedIndex;i<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&r.push(e._known[i]),r.length>s)));i++);if(0===r.length)return"success";throw new Error("Unaccounted for Features. Not in Feature Collection")}async _refineSetBlock(e){return e}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!1}relationshipMetaData(){return[]}static _cloneAttr(e){const t={};for(const s in e)t[s]=e[s];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 s=e.layerDefinition.objectIdField;const r=e.layerDefinition.typeIdField?e.layerDefinition.typeIdField:"",i=[];if(e.layerDefinition.types)for(const n of e.layerDefinition.types)i.push(u.fromJSON(n));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let l=e.featureSet.features;const c=t.toJSON();if(""===s||void 0===s){let t=!1;for(const r of e.layerDefinition.fields)if("oid"===r.type||"esriFieldTypeOID"===r.type){s=r.name,t=!0;break}if(!1===t){let t="FID",r=!0,i=0;for(;r;){let s=!0;for(const r of e.layerDefinition.fields)if(r.name===t){s=!1;break}!0===s?r=!1:(i++,t="FID"+i.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const a=[];for(let s=0;s<l.length;s++)a.push({geometry:e.featureSet.features[s].geometry,attributes:e.featureSet.features[s].attributes?this._cloneAttr(e.featureSet.features[s].attributes):{}}),a[s].attributes[t]=s;l=a,s=t}}const d=[];for(const n of e.layerDefinition.fields)n instanceof h?d.push(n):d.push(h.fromJSON(n));let f=a;switch(f){case"esriGeometryPoint":f="point";break;case"esriGeometryPolyline":f="polyline";break;case"esriGeometryPolygon":f="polygon";break;case"esriGeometryExtent":f="extent";break;case"esriGeometryMultipoint":f="multipoint"}for(const o of l)o.geometry&&o.geometry instanceof n==!1&&(o.geometry.type=f,void 0===o.geometry.spatialReference&&(o.geometry.spatialReference=c));const p={outFields:["*"],source:l,fields:d,types:i,typeIdField:r,objectIdField:s,spatialReference:t};p.geometryType=f||"point";const _=new o(p);return new y({layer:_,spatialReference:t,isTable:null===f||""===f})}async queryAttachments(){return[]}async getFeatureByObjectId(e){const t=new c;t.where=this.objectIdField+"="+e.toString();const s=await this._layer.queryFeatures(t);return 1===s.features.length?s.features[0]:null}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}}export{y as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import t from"../support/FeatureSet.js";import
|
|
5
|
+
import e from"../../../Graphic.js";import t from"../support/FeatureSet.js";import i from"../support/IdSet.js";import{defaultMaxRecords as r,IdState as s}from"../support/shared.js";import a from"../../../rest/support/RelationshipQuery.js";class n extends t{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,this.relatedLayer=null,this.relationship=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 r}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 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}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 s.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 i={};for(const e of this.fields)i[e.name]=t.attributes[e.name];return new e({geometry:!0===this._removeGeometry?null:t.geometry,attributes:i})}async _getFilteredSet(e,t,r,s,n){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e){return new i([],[],!0,null)}const l=this._layer.nativeCapabilities();if(!1===l.canQueryRelated){return new i([],[],!0,null)}if(l.capabilities.queryRelated&&l.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,s,n);let d="",o=!1;null!==s&&l.capabilities&&l.capabilities.queryRelated&&!0===l.capabilities.queryRelated.supportsOrderBy&&(d=s.constructClause(),o=!0);const u=new a;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 l.source.queryRelatedFeatures(u);this._checkCancelled(n);const p=y[this._findObjectId]?y[this._findObjectId].features:[],f=[];for(let i=0;i<p.length;i++)this._featureCache[p[i].attributes[this.relatedLayer.objectIdField]]=p[i],f.push(p[i].attributes[this.relatedLayer.objectIdField]);const g=t&&null!==e&&""!==e,_=null!=r;return new i(g||_?f:[],g||_?[]:f,o,null)}_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 _getFilteredSetUsingPaging(e,t,r,s,a){let n="",l=!1;const d=this._layer.nativeCapabilities();null!==s&&d&&d.capabilities.queryRelated&&!0===d.capabilities.queryRelated.supportsOrderBy&&(n=s.constructClause(),l=!0),await this.databaseType();const o="1=1";let u=this._maxQueryRate();const h=d.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);const c=t&&null!==e&&""!==e,y=null!=r;let p=null,f=!0;!0===this._removeGeometry&&(f=!1);const g=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this.relatedLayer.fields?this.relatedLayer.fields.map((e=>e.name)):["*"]);return p=new i(c||y?["GETPAGES"]:[],c||y?[]:["GETPAGES"],l,{outFields:g.join(","),resultRecordCount:u,resultOffset:0,objectIds:[this._findObjectId],where:o,orderByFields:n,returnGeometry:f,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(p,u,0,0,a),p}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,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,i){const r=e.pagesDefinition.internal.lastRetrieved,s=r,n=e.pagesDefinition.internal.lastPage,l=this._layer.nativeCapabilities(),d=new a;!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 l.source.queryRelatedFeatures(d);if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==n)return 0;const u=o[this._findObjectId]?o[this._findObjectId].features:[];for(let a=0;a<u.length;a++)e.pagesDefinition.internal.set[s+a]=u[a].attributes[this.relatedLayer.objectIdField];for(let a=0;a<u.length;a++)this._featureCache[u[a].attributes[this.relatedLayer.objectIdField]]=u[a];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=r+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,t,i,r){const s=[];-1!==t&&void 0===this._featureCache[t]&&s.push(t);const a=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,a))return await this._expandPagedSet(e,a,0,0,r),this._getFeatures(e,t,i,r);let n=0;for(let l=e._lastFetchedIndex;l<e._known.length&&(n++,n<=i&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[l]&&void 0===this._featureCache[e._known[l]]&&(e._known[l]!==t&&s.push(e._known[l]),s.length>i)))&&!(n>=i&&0===s.length);l++);if(0===s.length)return"success";throw new Error("Unaccounted for Features. Not in Feature Collection")}async _refineSetBlock(e,t,i){return e}async _stat(e,t,i,r,s,a,n){return{calculated:!1}}get gdbVersion(){return this.relatedLayer.gdbVersion}async _canDoAggregates(e,t,i,r,s){return!1}relationshipMetaData(){return this.relatedLayer.relationshipMetaData()}serviceUrl(){return this.relatedLayer.serviceUrl()}queryAttachments(e,t,i,r,s){return this.relatedLayer.queryAttachments(e,t,i,r,s)}getFeatureByObjectId(e,t){return this.relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this.relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this.relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this.relatedLayer}}export{n as default};
|