@arcgis/core 4.28.0-next.20230720 → 4.28.0-next.20230722
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/Color.js +1 -1
- package/analysis/AreaMeasurementAnalysis.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Top.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/FeatureSetIterator.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/lib/comment-handler.js +1 -1
- package/arcade/lib/parser.js +1 -1
- package/arcade/lib/scanner.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{75c28da8d0b02d612d69.js → 040b3fc9c9c0736dd893.js} +1 -1
- package/assets/esri/core/workers/chunks/0652f6a8d5221e978033.js +1 -0
- package/assets/esri/core/workers/chunks/{c13b332afdb3f6be1ec9.js → 092fda62b6f62c2e4869.js} +1 -1
- package/assets/esri/core/workers/chunks/{57e0ad037188bd2997e7.js → 0af18a96cbd4e2d35436.js} +1 -1
- package/assets/esri/core/workers/chunks/0b5eeec0f66c87a46a0c.js +1 -0
- package/assets/esri/core/workers/chunks/{68e568b67b6fb34393db.js → 0cad2b991d0d0fd07846.js} +1 -1
- package/assets/esri/core/workers/chunks/0dccbc6c2559fdc0c2ad.js +1 -0
- package/assets/esri/core/workers/chunks/256a82f6f6e1405fbcc6.js +1 -0
- package/assets/esri/core/workers/chunks/{bb9213899049e1db90da.js → 2c57c9bd71637c5bed8a.js} +1 -1
- package/assets/esri/core/workers/chunks/2cdbabcbfe32286ec78d.js +1 -0
- package/assets/esri/core/workers/chunks/{2b1c83453a862e01954b.js → 2d9d80b2d0042a9c09fb.js} +1 -1
- package/assets/esri/core/workers/chunks/2f9aec2238ff6cb99e09.js +1 -0
- package/assets/esri/core/workers/chunks/{7dbd3e6406fb3e3a1a8f.js → 3cf748c025f3936c1cb2.js} +1 -1
- package/assets/esri/core/workers/chunks/4481d1103363434f16da.js +1 -0
- package/assets/esri/core/workers/chunks/5ae325e6a795c72eac6c.js +1 -0
- package/assets/esri/core/workers/chunks/5e4dde2886a1027b4b96.js +1 -0
- package/assets/esri/core/workers/chunks/730eb7e5f617fdab4f10.js +1 -0
- package/assets/esri/core/workers/chunks/{5a2e6bed9431cf4f42b1.js → 740dc67038f554431f1b.js} +1 -1
- package/assets/esri/core/workers/chunks/{09178454bda15bb7929a.js → 7fbdfd1527582c52f9b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{1c026947505a9ff94a53.js → 807742f38885fa90b4fe.js} +1 -1
- package/assets/esri/core/workers/chunks/82dfbc175b52c7a10475.js +1 -0
- package/assets/esri/core/workers/chunks/870a05451e074b58f19a.js +1 -0
- package/assets/esri/core/workers/chunks/8c5a8c1dfb086069bb06.js +1 -0
- package/assets/esri/core/workers/chunks/99a5a434e0bad48c7a5c.js +1 -0
- package/assets/esri/core/workers/chunks/9a5916c66dad91d01d5b.js +1 -0
- package/assets/esri/core/workers/chunks/9c133fd8c1fbd0295b86.js +1 -0
- package/assets/esri/core/workers/chunks/9cddb504079d396779ea.js +1 -0
- package/assets/esri/core/workers/chunks/a3a1d4f32e518e97d071.js +1 -0
- package/assets/esri/core/workers/chunks/{9548aa449fe3a300c015.js → a4fa40dc77e116c954ac.js} +1 -1
- package/assets/esri/core/workers/chunks/a54ec9929a7db879d5db.js +1 -0
- package/assets/esri/core/workers/chunks/afc5b84693757fda2bc8.js +1 -0
- package/assets/esri/core/workers/chunks/{591b5c277cfd3a4101a4.js → b08f2a4aa94087c6c367.js} +1 -1
- package/assets/esri/core/workers/chunks/c0e12f6a7bb2360e4c21.js +1 -0
- package/assets/esri/core/workers/chunks/c8e656cd470a17f538e9.js +1 -0
- package/assets/esri/core/workers/chunks/d0e203405f95e14b1399.js +1 -0
- package/assets/esri/core/workers/chunks/{ec72f492f24e67e008ae.js → d8e58dc14d3495f0830c.js} +1 -1
- package/assets/esri/core/workers/chunks/ddc393a012588f799f42.js +1 -0
- package/assets/esri/core/workers/chunks/de3baa85b1639c25458d.js +1 -0
- package/assets/esri/core/workers/chunks/e66cea26064ba8353af0.js +1 -0
- package/assets/esri/core/workers/chunks/ea478f2f4a19463e13fd.js +1 -0
- package/assets/esri/core/workers/chunks/eba197e45507f56f3ed0.js +1 -0
- package/assets/esri/core/workers/chunks/ebd006fcd568a7731115.js +1 -0
- package/assets/esri/core/workers/chunks/ef9a9a7d66d818720e20.js +1 -0
- package/assets/esri/core/workers/chunks/f3b458f55236566c940b.js +1 -0
- package/assets/esri/core/workers/chunks/fd0a91b9e0216cc269c3.js +1 -0
- package/assets/esri/core/workers/chunks/{a4fe220a912b1f428e49.js → fdd6403a8390d629392b.js} +1 -1
- package/assets/esri/themes/base/widgets/_Directions.scss +13 -7
- 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/array.js +1 -1
- package/core/Collection.js +1 -1
- package/core/accessorSupport/decorators/subclass.js +1 -1
- package/core/accessorSupport/ensureType.js +1 -1
- package/core/accessorSupport/get.js +1 -1
- package/core/accessorSupport/tracking.js +1 -1
- package/core/accessorSupport/utils.js +1 -1
- package/core/libs/rbush/PooledRBush.js +1 -1
- package/core/urlUtils.js +1 -1
- package/geometry/GeometryCursor.js +1 -1
- package/geometry/support/TileClipper.js +1 -1
- package/geometry/support/geodesicUtils.js +1 -1
- package/interfaces.d.ts +14 -2
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/effects/EffectView.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/mixins/ArcGISCachedService.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/MultidimensionalSubset.js +1 -1
- package/layers/support/TileInfo.js +1 -1
- package/layers/support/TileInfoTilemapCache.js +1 -1
- package/layers/support/TilemapCache.js +1 -1
- package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
- package/layers/support/rasterDatasets/pamParser.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/layers/support/rasterFormats/Raw.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/support/rasterFunctions/colormaps.js +1 -1
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/layers/voxel/VoxelDimension.js +1 -1
- package/layers/voxel/VoxelTransferFunctionStyle.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/package.json +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
- package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/rest/support/generateRendererUtils.js +1 -1
- package/smartMapping/raster/renderers/classBreaks.js +1 -1
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/support/utils.js +1 -1
- package/smartMapping/renderers/type.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/statistics/utils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/GeometryWalker.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/effects/EffectArrow.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/symbols/support/symbolUtils.js +1 -1
- package/views/2d/constraints/ZoomConstraint.js +1 -1
- package/views/2d/engine/flow/dataUtils.js +1 -1
- package/views/2d/engine/flow/utils.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
- package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
- package/views/2d/engine/vectorTiles/style/VectorTileSource.js +1 -1
- package/views/2d/engine/vectorTiles/tileInfoUtils.js +1 -1
- package/views/2d/engine/webgl/TurboLine.js +1 -1
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
- package/views/2d/layers/BaseLayerView2D.js +1 -1
- package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
- package/views/2d/layers/BitmapTileLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/WMTSLayerView2D.js +1 -1
- package/views/2d/layers/features/support/rendererUtils.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/support/vectorTileDebugUtils.js +5 -0
- package/views/2d/tiling/TileInfoView.js +1 -1
- package/views/2d/tiling/TileInfoViewPOT.js +1 -1
- package/views/2d/tiling/TileQueue.js +1 -1
- package/views/2d/tiling.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/featureReference.js +1 -1
- package/views/3d/support/LaserLineRenderer.js +1 -1
- package/views/3d/terrain/Overlay.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/terrain/OverlayRenderTarget.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/TilingScheme.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/interfaces.js +1 -1
- package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
- package/views/3d/webgl-engine/effects/SmaaRenderPass.js +1 -1
- package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/requireUtils.js +1 -1
- package/views/MapView.js +1 -1
- package/views/animation/pointToPoint/Path.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/UndoGroup.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/views/webgl/ProgramCache.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/webscene/spec-certification/utils.js +1 -1
- package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
- package/widgets/BuildingExplorer/BuildingPhase.js +1 -1
- package/widgets/BuildingExplorer/support/validation.js +1 -1
- package/widgets/Directions/support/resources.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Histogram/HistogramViewModel.js +1 -1
- package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
- package/widgets/Legend/styles/Card.js +1 -1
- package/widgets/Legend/styles/Classic.js +1 -1
- package/widgets/Legend/styles/support/univariateUtils.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend/support/colorRampUtils.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/Legend/support/utils.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRanges.js +1 -1
- package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
- package/widgets/smartMapping/ClassedSizeSlider.js +1 -1
- package/widgets/smartMapping/ColorSizeSlider.js +1 -1
- package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider.js +1 -1
- package/widgets/smartMapping/SmartMappingPrimaryHandleSliderViewModel.js +1 -1
- package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0210f4c2e1f3ed13041b.js +0 -1
- package/assets/esri/core/workers/chunks/07bb40162d97d098bc19.js +0 -1
- package/assets/esri/core/workers/chunks/0a18317566c1fcb68422.js +0 -1
- package/assets/esri/core/workers/chunks/0de65e03db8c611af9fb.js +0 -1
- package/assets/esri/core/workers/chunks/1a60d23a92bcf91dbb22.js +0 -1
- package/assets/esri/core/workers/chunks/205a0b34b698d5329854.js +0 -1
- package/assets/esri/core/workers/chunks/25211d5904ee9d5f4a9d.js +0 -1
- package/assets/esri/core/workers/chunks/26b12d1ea713c1e07701.js +0 -1
- package/assets/esri/core/workers/chunks/2bfa7ee324c32a56b0d3.js +0 -1
- package/assets/esri/core/workers/chunks/4510a17839405146130b.js +0 -1
- package/assets/esri/core/workers/chunks/524156c3f5383c2dd0e3.js +0 -1
- package/assets/esri/core/workers/chunks/59666ecb7c2c1f5a13b2.js +0 -1
- package/assets/esri/core/workers/chunks/5c005c9514354c77ec27.js +0 -1
- package/assets/esri/core/workers/chunks/620ec5c75561183d3d73.js +0 -1
- package/assets/esri/core/workers/chunks/68512670816f59c0e6a5.js +0 -1
- package/assets/esri/core/workers/chunks/6c7374ebc18b46b3480a.js +0 -1
- package/assets/esri/core/workers/chunks/75ba2af92da232067adb.js +0 -1
- package/assets/esri/core/workers/chunks/7c1f0598a016516dcec3.js +0 -1
- package/assets/esri/core/workers/chunks/8dcec8d1b670d2b7ea2b.js +0 -1
- package/assets/esri/core/workers/chunks/8e07dfb6fc2673b640cb.js +0 -1
- package/assets/esri/core/workers/chunks/9050b167355588b7003d.js +0 -1
- package/assets/esri/core/workers/chunks/9230d68799f0b0b9ef36.js +0 -1
- package/assets/esri/core/workers/chunks/af4083f2aad5f5d49dde.js +0 -1
- package/assets/esri/core/workers/chunks/b0a57718a0765d1c8df0.js +0 -1
- package/assets/esri/core/workers/chunks/b431b81a7bf45dd527da.js +0 -1
- package/assets/esri/core/workers/chunks/bda311ad48efdb265939.js +0 -1
- package/assets/esri/core/workers/chunks/d5cce09fbe16cbb8fee4.js +0 -1
- package/assets/esri/core/workers/chunks/da547c3cabe4a89c3ce6.js +0 -1
- package/assets/esri/core/workers/chunks/dd295fa57b45b7ec4ec5.js +0 -1
- package/assets/esri/core/workers/chunks/f553b464e969d45bf451.js +0 -1
- package/assets/esri/core/workers/chunks/f5865294983eb160de8c.js +0 -1
- package/assets/esri/core/workers/chunks/fdb7b1fbdb6fe091ad83.js +0 -1
- package/views/2d/tiling/PagedTileQueue.js +0 -5
package/Color.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{hsla2rgba as t,isNamedColor as r,getNamedColor as s}from"./colorUtils.js";import{clamp as i}from"./core/mathUtils.js";import{ensureInteger as n}from"./core/accessorSupport/ensureType.js";function a(t){return i(n(t),0,255)}function e(t,r,s){return t=Number(t),isNaN(t)?s:t<r?r:t>s?s:t}class o{static blendColors(t,r,s,i=new o){return i.r=Math.round(t.r+(r.r-t.r)*s),i.g=Math.round(t.g+(r.g-t.g)*s),i.b=Math.round(t.b+(r.b-t.b)*s),i.a=t.a+(r.a-t.a)*s,i._sanitize()}static fromRgb(r,s){const i=r.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(i){const r=i[2].split(/\s*,\s*/),n=i[1];if("rgb"===n&&3===r.length||"rgba"===n&&4===r.length){if("%"===
|
|
5
|
+
import{hsla2rgba as t,isNamedColor as r,getNamedColor as s}from"./colorUtils.js";import{clamp as i}from"./core/mathUtils.js";import{ensureInteger as n}from"./core/accessorSupport/ensureType.js";function a(t){return i(n(t),0,255)}function e(t,r,s){return t=Number(t),isNaN(t)?s:t<r?r:t>s?s:t}class o{static blendColors(t,r,s,i=new o){return i.r=Math.round(t.r+(r.r-t.r)*s),i.g=Math.round(t.g+(r.g-t.g)*s),i.b=Math.round(t.b+(r.b-t.b)*s),i.a=t.a+(r.a-t.a)*s,i._sanitize()}static fromRgb(r,s){const i=r.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(i){const r=i[2].split(/\s*,\s*/),n=i[1];if("rgb"===n&&3===r.length||"rgba"===n&&4===r.length){const t=r[0];if("%"===t.charAt(t.length-1)){const t=r.map((t=>2.56*parseFloat(t)));return 4===r.length&&(t[3]=parseFloat(r[3])),o.fromArray(t,s)}return o.fromArray(r.map((t=>parseFloat(t))),s)}if("hsl"===n&&3===r.length||"hsla"===n&&4===r.length)return o.fromArray(t(parseFloat(r[0]),parseFloat(r[1])/100,parseFloat(r[2])/100,parseFloat(r[3])),s)}return null}static fromHex(t,r=new o){if(4!==t.length&&7!==t.length||"#"!==t[0])return null;const s=4===t.length?4:8,i=(1<<s)-1;let n=Number("0x"+t.substr(1));return isNaN(n)?null:(["b","g","r"].forEach((t=>{const a=n&i;n>>=s,r[t]=4===s?17*a:a})),r.a=1,r)}static fromArray(t,r=new o){return r._set(Number(t[0]),Number(t[1]),Number(t[2]),Number(t[3])),isNaN(r.a)&&(r.a=1),r._sanitize()}static fromString(t,i){const n=r(t)?s(t):null;return n&&o.fromArray(n,i)||o.fromRgb(t,i)||o.fromHex(t,i)}static fromJSON(t){return null!=t?new o([t[0],t[1],t[2],(t[3]??255)/255]):void 0}static toUnitRGB(t){return null!=t?[t.r/255,t.g/255,t.b/255]:null}static toUnitRGBA(t){return null!=t?[t.r/255,t.g/255,t.b/255,null!=t.a?t.a:1]:null}constructor(t){this.r=255,this.g=255,this.b=255,this.a=1,t&&this.setColor(t)}get isBright(){return.299*this.r+.587*this.g+.114*this.b>=127}setColor(t){return"string"==typeof t?o.fromString(t,this):Array.isArray(t)?o.fromArray(t,this):(this._set(t.r??0,t.g??0,t.b??0,t.a??1),t instanceof o||this._sanitize()),this}toRgb(){return[this.r,this.g,this.b]}toRgba(){return[this.r,this.g,this.b,this.a]}toHex(){const t=this.r.toString(16),r=this.g.toString(16),s=this.b.toString(16);return`#${t.length<2?"0"+t:t}${r.length<2?"0"+r:r}${s.length<2?"0"+s:s}`}toCss(t=!1){const r=this.r+", "+this.g+", "+this.b;return t?`rgba(${r}, ${this.a})`:`rgb(${r})`}toString(){return this.toCss(!0)}toJSON(){return this.toArray()}toArray(t=o.AlphaMode.ALWAYS){const r=a(this.r),s=a(this.g),i=a(this.b);return t===o.AlphaMode.ALWAYS||1!==this.a?[r,s,i,a(255*this.a)]:[r,s,i]}clone(){return new o(this.toRgba())}hash(){return this.r<<24|this.g<<16|this.b<<8|255*this.a}equals(t){return null!=t&&t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a}_sanitize(){return this.r=Math.round(e(this.r,0,255)),this.g=Math.round(e(this.g,0,255)),this.b=Math.round(e(this.b,0,255)),this.a=e(this.a,0,1),this}_set(t,r,s,i){this.r=t,this.g=r,this.b=s,this.a=i}}o.prototype.declaredClass="esri.Color",function(t){var r;(r=t.AlphaMode||(t.AlphaMode={}))[r.ALWAYS=0]="ALWAYS",r[r.UNLESS_OPAQUE=1]="UNLESS_OPAQUE"}(o||(o={}));const h=o;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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import r from"./Analysis.js";import{equals as t}from"../core/arrayUtils.js";import o from"../core/Logger.js";import{measurementAreaUnits as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"../geometry/Polygon.js";let p=class extends r{constructor(e){super(e),this.type="area-measurement",this.unit=null}set geometry(e){null!=e?(e.rings.length>1&&o.getLogger(this).warn("Measuring polygons with multiple rings is not supported."),this._set("geometry",e.clone())):this._set("geometry",null)}get requiredPropertiesForEditing(){if(null!=this.geometry&&1===this.geometry.rings.length){const e=this.geometry.rings[0];if(e.length<=2||!t(e[0],e.
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import r from"./Analysis.js";import{equals as t}from"../core/arrayUtils.js";import o from"../core/Logger.js";import{measurementAreaUnits as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"../geometry/Polygon.js";let p=class extends r{constructor(e){super(e),this.type="area-measurement",this.unit=null}set geometry(e){null!=e?(e.rings.length>1&&o.getLogger(this).warn("Measuring polygons with multiple rings is not supported."),this._set("geometry",e.clone())):this._set("geometry",null)}get requiredPropertiesForEditing(){if(null!=this.geometry&&1===this.geometry.rings.length){const e=this.geometry.rings[0];if(e.length<=2||!t(e[0],e[e.length-1]))return[null]}return[this.geometry]}clear(){this.geometry=null}};e([i({type:["area-measurement"]})],p.prototype,"type",void 0),e([i({value:null,type:l})],p.prototype,"geometry",null),e([i({type:s,value:null})],p.prototype,"unit",void 0),e([i({readOnly:!0})],p.prototype,"requiredPropertiesForEditing",null),p=e([n("esri.analysis.AreaMeasurementAnalysis")],p);const m=p;export{m as default};
|
package/arcade/arcadeCompiler.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import t from"./Dictionary.js";import{ArcadeExecutionError as o,ExecutionErrorCodes as l,ArcadeCompilationError as r,ArcadeUncompilableError as a}from"./executionError.js";import s from"./Feature.js";import{NativeFunction as i,ArcadeFunction as c,ScopeMarshalledFunction as u,wrapModuleScopedResponse as p}from"./FunctionWrapper.js";import{i as m,u as d,R as g,I as f,v as h,w as y,x as b,y as w,j as S,c as v,a as x,g as M,z as F,A as C,B as I,m as A,b as _,p as O,o as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as E}from"./treeAnalysis.js";import{A as R}from"../chunks/array.js";import{registerFunctions as G}from"./functions/date.js";import{registerFunctions as B,geometryMember as $}from"./functions/geometry.js";import{registerFunctions as j}from"./functions/geomsync.js";import{registerFunctions as N}from"./functions/maths.js";import{registerFunctions as L}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import{isPromiseLike as D}from"../core/promiseUtils.js";import P from"../geometry/Geometry.js";import K from"../geometry/SpatialReference.js";class T extends c{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new o(e,l.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!m(n)||n instanceof u?n:p(n,e,o)));const a=this.call(t,{arguments:r});return D(a)?a.then((e=>p(e,t,o))):a}))}}function q(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(V(e,n.arguments[o]));return t}function W(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function V(e,n){try{switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclarator":return ue(e,n);case"VariableDeclaration":return ce(e,n);case"BlockStatement":case"Program":return oe(e,n);case"FunctionDeclaration":return ie(e,n);case"ImportDeclaration":return re(e,n);case"ExportNamedDeclaration":return ae(e,n);case"ReturnStatement":return le(e,n);case"IfStatement":return te(e,n);case"ExpressionStatement":return ee(e,n);case"AssignmentExpression":return Z(e,n);case"UpdateExpression":return Q(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"TemplateLiteral":return ge(e,n);case"TemplateElement":return JSON.stringify(n.value?n.value.cooked:"");case"ForStatement":return H(e,n);case"ForInStatement":return Y(e,n);case"WhileStatement":return X(e,n);case"Identifier":return ye(e,n);case"MemberExpression":return pe(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return be(e,n);case"UnaryExpression":return me(e,n);case"BinaryExpression":return fe(e,n);case"LogicalExpression":return he(e,n);case"ArrayExpression":return de(e,n);case"ObjectExpression":return J(e,n);case"Property":return z(e,n);case"Array":throw new r(e,l.NeverReach,n);default:throw new r(e,l.Unrecognised,n)}}catch(t){throw t}}function J(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];se(l.key.name);o>0&&(t+=","),t+="lang.strCheck("+("Identifier"===l.key.type?"'"+l.key.name+"'":V(e,l.key))+",'ObjectExpression'),lang.aCheck("+V(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function z(e,n){throw new r(e,l.NeverReach,n)}function Y(e,n){const t=Fe(e),o=Fe(e),l=Fe(e);let r="var "+t+" = "+V(e,n.right)+";\n";"VariableDeclaration"===n.left.type&&(r+=V(e,n.left));let a="VariableDeclaration"===n.left.type?n.left.declarations[0].id.name:n.left.name;a=a.toLowerCase(),se(a);let s="";null!==e.localScope&&(void 0!==e.localScope[a]?s="lscope['"+a+"']":void 0!==e.localScope._SymbolsMap[a]&&(s="lscope['"+e.localScope._SymbolsMap[a]+"']"));let i="";if(""===s)if(void 0!==e.globalScope[a])s="gscope['"+a+"']";else if(void 0!==e.globalScope._SymbolsMap[a])s="gscope['"+e.globalScope._SymbolsMap[a]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(a))s="gscope['"+e.undeclaredGlobalsInFunctions.get(a).manglename+"']",i=e.undeclaredGlobalsInFunctions.get(a).manglename;else{const t={manglename:Me(e),node:n.left};e.undeclaredGlobalsInFunctions.set(a,t),s="gscope['"+t.manglename+"']",i=t.manglename}return i&&(r+="lang.chkAssig('"+i+"',runtimeCtx); \n"),r+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",r+="else if (lc.isArray("+t+") || lc.isString("+t+")) {",r+="var "+o+"="+t+".length; \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (lc.isImmutableArray("+t+")) {",r+="var "+o+"="+t+".length(); \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (( "+t+" instanceof lang.Dictionary) || ( "+t+" instanceof lang.Feature)) {",r+="var "+o+"="+t+".keys(); \n",r+="for(var "+l+"=0; "+l+"<"+o+".length; "+l+"++) {\n",r+=s+"="+o+"["+l+"];\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",e.isAsync&&(r+="else if (lc.isFeatureSet("+t+")) {",r+="var "+o+"="+t+".iterator(runtimeCtx.abortSignal); \n",r+="for(var "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx); "+l+"!=null; "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx)) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n"),r+="else { lastStatement = lc.voidOperation; } \n",r}function H(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&(t+=V(e,n.init)+"; ");const o=Fe(e),r=Fe(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+V(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+r+" = "+V(e,n.test)+"; ",t+="if ("+r+"===false) { break; } else if ("+r+"!==true) { lang.error('"+l.BooleanConditionRequired+"'); }\n"),t+=V(e,n.body),null!==n.update&&(t+="\n "+V(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function Q(e,n){let t=null,r="";if("MemberExpression"===n.argument.type)return t=V(e,n.argument.object),!0===n.argument.computed?r=V(e,n.argument.property):(r="'"+n.argument.property.name+"'",se(n.argument.property.name)),"lang.memberupdate("+t+","+r+",'"+n.operator+"',"+n.prefix+")";if(t=n.argument.name.toLowerCase(),se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lang.update(lscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.localScope._SymbolsMap[t])return"lang.update(lscope, '"+e.localScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")"}if(void 0!==e.globalScope[t])return"lang.update(gscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.globalScope._SymbolsMap[t])return"lang.update(gscope, '"+e.globalScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"lang.update(gscope,lang.chkAssig( '"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"lang.update(gscope, lang.chkAssig('"+o.manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")"}throw new o(e,l.InvalidIdentifier,n)}function X(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Fe(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${V(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${l.BooleanConditionRequired}');\n }\n ${V(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function Z(e,n){const t=V(e,n.right);let r=null,a="";if("MemberExpression"===n.left.type)return r=V(e,n.left.object),!0===n.left.computed?a=V(e,n.left.property):(a="'"+n.left.property.name+"'",se(n.left.property.name)),"lang.assignmember("+r+","+a+",'"+n.operator+"',"+t+")";if(r=n.left.name.toLowerCase(),se(r),null!==e.localScope){if(void 0!==e.localScope[r])return"lscope['"+r+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+r+"'])";if(void 0!==e.localScope._SymbolsMap[r])return"lscope['"+e.localScope._SymbolsMap[r]+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+e.localScope._SymbolsMap[r]+"'])"}if(void 0!==e.globalScope[r])return"gscope['"+r+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+r+"'])";if(void 0!==e.globalScope._SymbolsMap[r])return"gscope['"+e.globalScope._SymbolsMap[r]+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+e.globalScope._SymbolsMap[r]+"'])";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(r))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(r).manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+e.undeclaredGlobalsInFunctions.get(r).manglename+"'])";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(r,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+o.manglename+"'])"}throw new o(e,l.InvalidIdentifier,n)}function ee(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+V(e,n.expression)+"; \n ":(n.expression.type,"lastStatement = "+V(e,n.expression)+"; ")}function ne(e,n){return"BlockStatement"===n.type?V(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?V(e,n)+"; ":"UpdateExpression"===n.type?"lastStatement = "+V(e,n)+"; ":"ExpressionStatement"===n.type?V(e,n):"ObjectExpression"===n.type?"lastStatement = "+V(e,n)+"; ":V(e,n)+"; "}function te(e,n){if("AssignmentExpression"===n.test.type||"UpdateExpression"===n.test.type)throw new r(e,l.BooleanConditionRequired,n);return`if (lang.mustBoolean(${V(e,n.test)}, runtimeCtx) === true) {\n ${ne(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+te(e,n.alternate):` else {\n ${ne(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function oe(e,n){let t="";for(let o=0;o<n.body.length;o++)"EmptyStatement"!==n.body[o].type&&("ReturnStatement"===n.body[o].type||"BreakStatement"===n.body[o].type||"ContinueStatement"===n.body[o].type?t+=V(e,n.body[o])+"; \n":"UpdateExpression"===n.body[o].type||"ObjectExpression"===n.body[o].type?t+="lastStatement = "+V(e,n.body[o])+"; \n":t+=V(e,n.body[o])+" \n");return t}function le(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+V(e,n.argument)}function re(e,n){const t=n.specifiers[0].local.name.toLowerCase();se(t);const o=e.libraryResolver?.loadLibrary(t),l=Me(e);void 0===e.moduleFactory[o.uri]&&(e.moduleFactory[o.uri]=De(o.syntax,{interceptor:e.interceptor,services:e.services,moduleFactory:e.moduleFactory,lrucache:e.lrucache,timeReference:e.timeReference??null,libraryResolver:e.libraryResolver,customfunctions:e.customfunctions,vars:{}},e.isAsync)),e.moduleFactoryMap[l]=o.uri;let r="";if(r=e.isAsync?"(yield lang.loadModule('"+l+"', runtimeCtx) ); ":"lang.loadModule('"+l+"', runtimeCtx); ",void 0!==e.globalScope[t])return"gscope['"+t+"']="+r;if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']="+r;let a="";return e.undeclaredGlobalsInFunctions.has(t)?(a=e.undeclaredGlobalsInFunctions.get(t).manglename,e.undeclaredGlobalsInFunctions.delete(t)):a=Me(e),e.globalScope._SymbolsMap[t]=a,e.mangleMap[t]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+r}function ae(e,n){const t=V(e,n.declaration);if("FunctionDeclaration"===n.declaration.type)e.exports[n.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===n.declaration.type)for(const o of n.declaration.declarations)e.exports[o.id.name.toLowerCase()]="variable";return t}function se(e){if("iif"===e)throw new a;if("decode"===e)throw new a;if("when"===e)throw new a}function ie(e,n){const t=n.id.name.toLowerCase();se(t);let o="",l=!1;void 0!==e.globalScope[t]?o=t:void 0!==e.globalScope._SymbolsMap[t]?o=e.globalScope._SymbolsMap[t]:e.undeclaredGlobalsInFunctions.has(t)?(o=e.undeclaredGlobalsInFunctions.get(t).manglename,e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o,e.undeclaredGlobalsInFunctions.delete(t),l=!0):(o=Me(e),e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o);const r={isAsync:e.isAsync,console:e.console,exports:e.exports,undeclaredGlobalsInFunctions:e.undeclaredGlobalsInFunctions,customfunctions:e.customfunctions,moduleFactory:e.moduleFactory,moduleFactoryMap:e.moduleFactoryMap,libraryResolver:e.libraryResolver,lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,symbols:e.symbols,mangleMap:e.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:e.depthCounter,globalScope:e.globalScope};let a="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let s=0;s<n.params.length;s++){const t=n.params[s].name.toLowerCase();se(t);const o=Me(e);r.localScope._SymbolsMap[t]=o,r.mangleMap[t]=o,a+="lscope['"+o+"']=arguments["+s.toString()+"];\n"}return!0===e.isAsync?(a+="return lang.__awaiter(this, void 0, void 0, function* () {\n",a+=oe(r,n.body)+"\n return lastStatement; ",a+="}); }",a+=", runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"):(a+=oe(r,n.body)+"\n return lastStatement; }, runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"),l?"gscope[lang.setAssig('"+o+"', runtimeCtx)]="+a:"gscope['"+o+"']="+a}function ce(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(V(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function ue(e,n){let t=null===n.init?null:V(e,n.init);t===h&&(t=null);const o=n.id.name.toLowerCase();if(se(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']="+t+"; ";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']="+t+"; ";{const n=Me(e);return e.localScope._SymbolsMap[o]=n,e.mangleMap[o]=n,"lscope['"+n+"']="+t+"; "}}if(void 0!==e.globalScope[o])return"gscope['"+o+"']="+t+"; ";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']="+t+"; ";if(e.undeclaredGlobalsInFunctions.has(o)){const n=e.undeclaredGlobalsInFunctions.get(o).manglename;return e.globalScope._SymbolsMap[o]=n,e.mangleMap[o]=n,e.undeclaredGlobalsInFunctions.delete(o),"gscope[lang.setAssig('"+n+"', runtimeCtx)]="+t+"; "}const l=Me(e);return e.globalScope._SymbolsMap[o]=l,e.mangleMap[o]=l,"gscope['"+l+"']="+t+"; "}function pe(e,n){try{let t;return!0===n.computed?t=V(e,n.property):(t="'"+n.property.name+"'",se(n.property.name)),"lang.member("+V(e,n.object)+","+t+")"}catch(t){throw t}}function me(e,n){try{return"lang.unary("+V(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function de(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(V(e,n.elements[o])):t.push("lang.aCheck("+V(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function ge(e,n){try{const t=[];let o=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+V(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function fe(e,n){try{return"lang.binary("+V(e,n.left)+","+V(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function he(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new r(e,l.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new r(e,l.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+V(e,n.left)+") "+n.operator+" lang.logicalCheck("+V(e,n.right)+"))";throw new r(null,l.LogicExpressionOrAnd,null)}catch(t){throw t}}function ye(e,n){try{const t=n.name.toLowerCase();if(se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lscope['"+t+"']";if(void 0!==e.localScope._SymbolsMap[t])return"lscope['"+e.localScope._SymbolsMap[t]+"']"}if(void 0!==e.globalScope[t])return"gscope['"+t+"']";if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]"}throw new r(e,l.InvalidIdentifier,n)}catch(t){throw t}}function be(e,n){try{if("MemberExpression"===n.callee.type){let t;!0===n.callee.computed?t=V(e,n.callee.property):(t="'"+n.callee.property.name+"'",se(n.callee.property.name));let o="[";for(let l=0;l<n.arguments.length;l++)l>0&&(o+=", "),o+=V(e,n.arguments[l]);return o+="]",e.isAsync?"(yield lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx))":"lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new r(e,l.FunctionNotFound,n);const t=n.callee.name.toLowerCase();if("iif"===t)return we(e,n);if("when"===t)return Se(e,n);if("decode"===t)return ve(e,n);let o="";if(null!==e.localScope&&(void 0!==e.localScope[t]?o="lscope['"+t+"']":void 0!==e.localScope._SymbolsMap[t]&&(o="lscope['"+e.localScope._SymbolsMap[t]+"']")),""===o)if(void 0!==e.globalScope[t])o="gscope['"+t+"']";else if(void 0!==e.globalScope._SymbolsMap[t])o="gscope['"+e.globalScope._SymbolsMap[t]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(t))o="gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";else{const l={manglename:Me(e),node:n.argument};e.undeclaredGlobalsInFunctions.set(t,l),o="gscope[lang.chkAssig('"+l.manglename+"',runtimeCtx)]"}if(""!==o){let t="[";for(let o=0;o<n.arguments.length;o++)o>0&&(t+=", "),t+=V(e,n.arguments[o]);return t+="]",e.isAsync?"(yield lang.callfunc("+o+","+t+",runtimeCtx) )":"lang.callfunc("+o+","+t+",runtimeCtx)"}throw new r(e,l.FunctionNotFound,n)}catch(t){throw t}}function we(e,n){try{if(3!==n.arguments.length)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${V(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${V(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Se(e,n){try{if(n.arguments.length<3)throw new r(e,l.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${V(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${V(e,n.arguments.at(-1))}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function ve(e,n){try{if(n.arguments.length<2)throw new r(e,l.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${V(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e),o=Fe(e);let a="var ";for(let l=1;l<n.arguments.length-1;l+=2)a+=`${o} = ${V(e,n.arguments[l])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n ${a}\n return ${V(e,n.arguments.at(-1))}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const xe={};function Me(e){return e.symbols.symbolCounter++,"_T"+e.symbols.symbolCounter.toString()}function Fe(e){return e.symbols.symbolCounter++,"_Tvar"+e.symbols.symbolCounter.toString()}G(xe,W),U(xe,W),N(xe,W),B(xe,W),L(xe,W),xe.iif=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}},xe.decode=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}},xe.when=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}};const Ce={};for(const Pe in xe)Ce[Pe]=new i(xe[Pe]);j(xe,W);for(const Pe in xe)xe[Pe]=new i(xe[Pe]);const Ie=function(){};Ie.prototype=xe;const Ae=function(){};function _e(e,n,t){const o={};e||(e={}),t||(t={}),o._SymbolsMap={},o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function Oe(e,n,o,l){const r=o?new Ae:new Ie;e||(e={}),n||(n={});const a=new t({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,r._SymbolsMap={textformatting:1,infinity:1,pi:1},r.textformatting=a,r.infinity=Number.POSITIVE_INFINITY,r.pi=Math.PI;for(const t in n)r[t]=n[t],r._SymbolsMap[t]=1;for(const t in e)r._SymbolsMap[t]=1,e[t]&&"esri.Graphic"===e[t].declaredClass?r[t]=s.createFromGraphic(e[t],l??null):r[t]=e[t];return r}Ae.prototype=Ce;const ke={fixSpatialReference:w,parseArguments:q,standardFunction:W};function Ee(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:W,standardFunctionAsync:W,evaluateIdentifier:Ge};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)xe[e]=new i(t.functions[e]),Ie.prototype[e]=xe[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"sync")}else{for(const e in t.functions)Ce[e]=new i(t.functions[e]),Ae.prototype[e]=Ce[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"async")}}function Re(e,n){return e(n)}function Ge(e,n){const t=n.name;if("_SymbolsMap"===t)throw new o(e,l.InvalidIdentifier,null);if(e.localStack.length>0){if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.localStack.at(-1)[t])return e.localStack.at(-1)[t];const n=e.mangleMap[t];if(void 0!==n&&void 0!==e.localStack.at(-1)[n])return e.localStack.at(-1)[n]}if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const r=e.mangleMap[t];return void 0!==r?e.globalScope[r]:void 0}Ee([R],"sync"),Ee([R],"async");let Be=0;const $e={error(e){throw new o(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value&&e.value.then?e.value.then(r,a):(Be++,Be%100==0?setTimeout((()=>{Be=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push([]),n.depthCounter.depth>64)throw new o(null,l.MaximumCallDepth,null);const t=e.apply(this,arguments);return D(t)?t.then((e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e))):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new o(n,l.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new o(n,l.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>S(e),aCheck(e,n){if(m(e)){if("ArrayExpression"===n)throw new o(null,l.NoFunctionInArray,null);if("ObjectExpression"===n)throw new o(null,l.NoFunctionInDictionary,null);throw new o(null,l.NoFunctionInTemplateLiteral,null)}return e===h?null:e},Dictionary:t,Feature:s,UserDefinedCompiledFunction:T,dictionary(e){const n={},r=new Map;for(let t=0;t<e.length;t+=2){if(m(e[t+1]))throw new o(null,l.NoFunctionInDictionary,null);if(!1===v(e[t]))throw new o(null,l.KeyMustBeString,null);let a=e[t].toString();const s=a.toLowerCase();r.has(s)?a=r.get(s):r.set(s,a),e[t+1]===h?n[a]=null:n[a]=e[t+1]}const a=new t(n);return a.immutable=!1,a},strCheck(e){if(!1===v(e))throw new o(null,l.KeyMustBeString,null);return e},unary(e,n){if(x(e)){if("!"===n)return!e;if("-"===n)return-1*M(e);if("+"===n)return 1*M(e);if("~"===n)return~M(e);throw new o(null,l.UnsupportedUnaryOperator,null)}if("-"===n)return-1*M(e);if("+"===n)return 1*M(e);if("~"===n)return~M(e);throw new o(null,l.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===x(e))throw new o(null,l.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(x(e)&&x(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new o(null,l.LogicExpressionOrAnd,null)}throw new o(null,l.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return I(M(e),M(n),t);case"==":case"=":return C(e,n);case"!=":return!C(e,n);case"<":case">":case"<=":case">=":return F(e,n,t);case"+":return v(e)||v(n)?S(e)+S(n):M(e)+M(n);case"-":return M(e)-M(n);case"*":return M(e)*M(n);case"/":return M(e)/M(n);case"%":return M(e)%M(n);default:throw new o(null,l.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===h?null:e;case"/=":return M(t)/M(e);case"*=":return M(t)*M(e);case"-=":return M(t)-M(e);case"+=":return v(t)||v(e)?S(t)+S(e):M(t)+M(e);case"%=":return M(t)%M(e);default:throw new o(null,l.UnsupportedOperator,null)}},update(e,n,t,o){const l=M(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:s.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeReference),memberupdate(e,n,r,a){let s;if(A(e)){if(!_(n))throw new o(null,l.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new o(null,l.OutOfBounds,null);s=M(e[n]),e[n]="++"===r?s+1:s-1}else if(e instanceof t){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,l.FieldNotFound,null,{key:n});s=M(e.field(n)),e.setField(n,"++"===r?s+1:s-1)}else if(O(e)){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,l.FieldNotFound,null);s=M(e.field(n)),e.setField(n,"++"===r?s+1:s-1)}else{if(k(e))throw new o(null,l.Immutable,null);if(!(e instanceof Ue))throw new o(null,l.InvalidIdentifier,null);if(!1===v(n))throw new o(null,l.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new o(null,l.ModuleExportNotFound,null);s=M(e.global(n)),e.setGlobal(n,"++"===r?s+1:s-1)}return!1===a?s:"++"===r?s+1:s-1},assignmember(e,n,r,a){if(A(e)){if(!_(n))throw new o(null,l.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new o(null,l.OutOfBounds,null);if(n===e.length){if("="!==r)throw new o(null,l.OutOfBounds,null);e[n]=this.assign(a,r,e[n])}else e[n]=this.assign(a,r,e[n])}else if(e instanceof t){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,r,e.field(n)));else{if("="!==r)throw new o(null,l.FieldNotFound,null);e.setField(n,this.assign(a,r,null))}}else if(O(e)){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,r,e.field(n)));else{if("="!==r)throw new o(null,l.FieldNotFound,null);e.setField(n,this.assign(a,r,null))}}else{if(k(e))throw new o(null,l.Immutable,null);if(!(e instanceof Ue))throw new o(null,l.InvalidIdentifier,null);if(!1===v(n))throw new o(null,l.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new o(null,l.ModuleExportNotFound,null);e.setGlobal(n,this.assign(a,r,e.global(n)))}},member(e,n){if(null===e)throw new o(null,l.MemberOfNull,null);if(e instanceof t||O(e)){if(v(n))return e.field(n);throw new o(null,l.InvalidMemberAccessKey,null)}if(e instanceof P){if(v(n))return $(e,n,null,null);throw new o(null,l.InvalidMemberAccessKey,null)}if(A(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,l.OutOfBounds,null);return e[n]}throw new o(null,l.InvalidMemberAccessKey,null)}if(v(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,l.OutOfBounds,null);return e[n]}throw new o(null,l.InvalidMemberAccessKey,null)}if(k(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new o(null,l.OutOfBounds,null);return e.get(n)}throw new o(null,l.InvalidMemberAccessKey,null)}if(e instanceof Ue){if(v(n))return e.global(n);throw new o(null,l.InvalidMemberAccessKey,null)}throw new o(null,l.InvalidMemberAccessKey,null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeReference:n.timeReference??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,r){if(!(e instanceof Ue))throw new o(null,l.FunctionNotFound,null);const a=e.global(t);if(!1===m(a))throw new o(null,l.CallNonFunction,null);return a.call(r,{preparsed:!0,arguments:n})}};function je(e){console.log(e)}function Ne(e,t,a=!1){null===t&&(t={vars:{},customfunctions:{}});let s=null;e.usesModules&&(s=new n(null,e.loadedModules));const i={isAsync:a,globalScope:_e(t.vars,a?Ce:xe,t.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:t.customfunctions,libraryResolver:s,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:je,lrucache:t.lrucache,timeReference:t.timeReference??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let c=V(i,e);""===c&&(c="lc.voidOperation; "),i.undeclaredGlobalsInFunctions.size>0&&i.undeclaredGlobalsInFunctions.forEach((e=>{throw new r(t,l.InvalidIdentifier,e.node)}));let u="";u=a?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+c+"\n return lastStatement; }); } \n return this.postProcess(yield mainBody()); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+c+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=i.moduleFactory,w=i.moduleFactoryMap,S=i.exports,v={};for(const n in S)v[n]=void 0!==i.mangleMap[n]?i.mangleMap[n]:n;const x={lc:d,lang:$e,mangles:i.mangleMap,postProcess(e){if(e instanceof g&&(e=e.value),e instanceof f&&(e=e.value),e===h&&(e=null),e===y)throw new o(null,l.IllegalResult,null);if(e===b)throw new o(null,l.IllegalResult,null);if(m(e))throw new o(null,l.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=K.WebMercator);const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:w,mangleMap:this.mangles,moduleSingletons:{},exports:S,gdefs:{},exportmangle:v,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(x)}async function Le(){return Ee([await import("./functions/geomasync.js")],"async"),!0}class Ue extends e{constructor(e){super(null),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,r=e.toLowerCase();if(m(n))throw new o(null,l.AssignModuleFunction,null);t[this.moduleContext.exportmangle[r]]=n}global(e){const n=this.moduleContext.globalScope;e=e.toLowerCase();const t=n[this.moduleContext.exportmangle[e]];if(void 0===t)throw new o(null,l.InvalidIdentifier,null);if(m(t)&&!(t instanceof u)){const o=new u;return o.fn=t,o.parameterEvaluator=W,o.context=this.moduleContext,n[this.moduleContext.exportmangle[e]]=o,o}return t}}function De(e,t,o=!1){const l={isAsync:o,moduleFactory:t.moduleFactory,moduleFactoryMap:{},libraryResolver:new n(null,e.loadedModules),globalScope:_e(t.vars,o?Ce:xe,t.customfunctions),customfunctions:t.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:je,lrucache:t.lrucache,timeReference:t.timeReference??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let r=V(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};for(const n in c)u[n]=void 0!==l.mangleMap[n]?l.mangleMap[n]:n;const p={lc:d,lang:$e,mangles:l.mangleMap,prepareModule:e=>new Ue(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new K({wkid:102100}));const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(p)}export{T as UserDefinedCompiledFunction,Ne as compileScript,Le as enableAsyncSupport,Re as executeScript,Ee as extend,ke as functionHelper};
|
|
5
|
+
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import t from"./Dictionary.js";import{ArcadeExecutionError as o,ExecutionErrorCodes as l,ArcadeCompilationError as r,ArcadeUncompilableError as a}from"./executionError.js";import s from"./Feature.js";import{NativeFunction as i,ArcadeFunction as c,ScopeMarshalledFunction as u,wrapModuleScopedResponse as p}from"./FunctionWrapper.js";import{i as m,u as g,R as d,I as f,v as h,w as y,x as b,y as w,j as S,c as v,a as x,g as M,z as F,A as C,B as I,m as A,b as _,p as O,o as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as E}from"./treeAnalysis.js";import{A as R}from"../chunks/array.js";import{registerFunctions as G}from"./functions/date.js";import{registerFunctions as B,geometryMember as $}from"./functions/geometry.js";import{registerFunctions as j}from"./functions/geomsync.js";import{registerFunctions as N}from"./functions/maths.js";import{registerFunctions as L}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import{isPromiseLike as D}from"../core/promiseUtils.js";import P from"../geometry/Geometry.js";import K from"../geometry/SpatialReference.js";class T extends c{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new o(e,l.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!m(n)||n instanceof u?n:p(n,e,o)));const a=this.call(t,{arguments:r});return D(a)?a.then((e=>p(e,t,o))):a}))}}function q(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(V(e,n.arguments[o]));return t}function W(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function V(e,n){try{switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclarator":return ue(e,n);case"VariableDeclaration":return ce(e,n);case"BlockStatement":case"Program":return oe(e,n);case"FunctionDeclaration":return ie(e,n);case"ImportDeclaration":return re(e,n);case"ExportNamedDeclaration":return ae(e,n);case"ReturnStatement":return le(e,n);case"IfStatement":return te(e,n);case"ExpressionStatement":return ee(e,n);case"AssignmentExpression":return Z(e,n);case"UpdateExpression":return Q(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"TemplateLiteral":return de(e,n);case"TemplateElement":return JSON.stringify(n.value?n.value.cooked:"");case"ForStatement":return H(e,n);case"ForInStatement":return Y(e,n);case"WhileStatement":return X(e,n);case"Identifier":return ye(e,n);case"MemberExpression":return pe(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return be(e,n);case"UnaryExpression":return me(e,n);case"BinaryExpression":return fe(e,n);case"LogicalExpression":return he(e,n);case"ArrayExpression":return ge(e,n);case"ObjectExpression":return J(e,n);case"Property":return z(e,n);case"Array":throw new r(e,l.NeverReach,n);default:throw new r(e,l.Unrecognised,n)}}catch(t){throw t}}function J(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];se(l.key.name);o>0&&(t+=","),t+="lang.strCheck("+("Identifier"===l.key.type?"'"+l.key.name+"'":V(e,l.key))+",'ObjectExpression'),lang.aCheck("+V(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function z(e,n){throw new r(e,l.NeverReach,n)}function Y(e,n){const t=Fe(e),o=Fe(e),l=Fe(e);let r="var "+t+" = "+V(e,n.right)+";\n";"VariableDeclaration"===n.left.type&&(r+=V(e,n.left));let a="VariableDeclaration"===n.left.type?n.left.declarations[0].id.name:n.left.name;a=a.toLowerCase(),se(a);let s="";null!==e.localScope&&(void 0!==e.localScope[a]?s="lscope['"+a+"']":void 0!==e.localScope._SymbolsMap[a]&&(s="lscope['"+e.localScope._SymbolsMap[a]+"']"));let i="";if(""===s)if(void 0!==e.globalScope[a])s="gscope['"+a+"']";else if(void 0!==e.globalScope._SymbolsMap[a])s="gscope['"+e.globalScope._SymbolsMap[a]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(a))s="gscope['"+e.undeclaredGlobalsInFunctions.get(a).manglename+"']",i=e.undeclaredGlobalsInFunctions.get(a).manglename;else{const t={manglename:Me(e),node:n.left};e.undeclaredGlobalsInFunctions.set(a,t),s="gscope['"+t.manglename+"']",i=t.manglename}return i&&(r+="lang.chkAssig('"+i+"',runtimeCtx); \n"),r+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",r+="else if (lc.isArray("+t+") || lc.isString("+t+")) {",r+="var "+o+"="+t+".length; \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (lc.isImmutableArray("+t+")) {",r+="var "+o+"="+t+".length(); \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (( "+t+" instanceof lang.Dictionary) || ( "+t+" instanceof lang.Feature)) {",r+="var "+o+"="+t+".keys(); \n",r+="for(var "+l+"=0; "+l+"<"+o+".length; "+l+"++) {\n",r+=s+"="+o+"["+l+"];\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",e.isAsync&&(r+="else if (lc.isFeatureSet("+t+")) {",r+="var "+o+"="+t+".iterator(runtimeCtx.abortSignal); \n",r+="for(var "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx); "+l+"!=null; "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx)) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n"),r+="else { lastStatement = lc.voidOperation; } \n",r}function H(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&(t+=V(e,n.init)+"; ");const o=Fe(e),r=Fe(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+V(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+r+" = "+V(e,n.test)+"; ",t+="if ("+r+"===false) { break; } else if ("+r+"!==true) { lang.error('"+l.BooleanConditionRequired+"'); }\n"),t+=V(e,n.body),null!==n.update&&(t+="\n "+V(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function Q(e,n){let t=null,r="";if("MemberExpression"===n.argument.type)return t=V(e,n.argument.object),!0===n.argument.computed?r=V(e,n.argument.property):(r="'"+n.argument.property.name+"'",se(n.argument.property.name)),"lang.memberupdate("+t+","+r+",'"+n.operator+"',"+n.prefix+")";if(t=n.argument.name.toLowerCase(),se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lang.update(lscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.localScope._SymbolsMap[t])return"lang.update(lscope, '"+e.localScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")"}if(void 0!==e.globalScope[t])return"lang.update(gscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.globalScope._SymbolsMap[t])return"lang.update(gscope, '"+e.globalScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"lang.update(gscope,lang.chkAssig( '"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"lang.update(gscope, lang.chkAssig('"+o.manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")"}throw new o(e,l.InvalidIdentifier,n)}function X(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Fe(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${V(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${l.BooleanConditionRequired}');\n }\n ${V(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function Z(e,n){const t=V(e,n.right);let r=null,a="";if("MemberExpression"===n.left.type)return r=V(e,n.left.object),!0===n.left.computed?a=V(e,n.left.property):(a="'"+n.left.property.name+"'",se(n.left.property.name)),"lang.assignmember("+r+","+a+",'"+n.operator+"',"+t+")";if(r=n.left.name.toLowerCase(),se(r),null!==e.localScope){if(void 0!==e.localScope[r])return"lscope['"+r+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+r+"'])";if(void 0!==e.localScope._SymbolsMap[r])return"lscope['"+e.localScope._SymbolsMap[r]+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+e.localScope._SymbolsMap[r]+"'])"}if(void 0!==e.globalScope[r])return"gscope['"+r+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+r+"'])";if(void 0!==e.globalScope._SymbolsMap[r])return"gscope['"+e.globalScope._SymbolsMap[r]+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+e.globalScope._SymbolsMap[r]+"'])";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(r))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(r).manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+e.undeclaredGlobalsInFunctions.get(r).manglename+"'])";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(r,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+o.manglename+"'])"}throw new o(e,l.InvalidIdentifier,n)}function ee(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+V(e,n.expression)+"; \n ":(n.expression.type,"lastStatement = "+V(e,n.expression)+"; ")}function ne(e,n){return"BlockStatement"===n.type?V(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?V(e,n)+"; ":"UpdateExpression"===n.type?"lastStatement = "+V(e,n)+"; ":"ExpressionStatement"===n.type?V(e,n):"ObjectExpression"===n.type?"lastStatement = "+V(e,n)+"; ":V(e,n)+"; "}function te(e,n){if("AssignmentExpression"===n.test.type||"UpdateExpression"===n.test.type)throw new r(e,l.BooleanConditionRequired,n);return`if (lang.mustBoolean(${V(e,n.test)}, runtimeCtx) === true) {\n ${ne(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+te(e,n.alternate):` else {\n ${ne(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function oe(e,n){let t="";for(let o=0;o<n.body.length;o++)"EmptyStatement"!==n.body[o].type&&("ReturnStatement"===n.body[o].type||"BreakStatement"===n.body[o].type||"ContinueStatement"===n.body[o].type?t+=V(e,n.body[o])+"; \n":"UpdateExpression"===n.body[o].type||"ObjectExpression"===n.body[o].type?t+="lastStatement = "+V(e,n.body[o])+"; \n":t+=V(e,n.body[o])+" \n");return t}function le(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+V(e,n.argument)}function re(e,n){const t=n.specifiers[0].local.name.toLowerCase();se(t);const o=e.libraryResolver?.loadLibrary(t),l=Me(e);void 0===e.moduleFactory[o.uri]&&(e.moduleFactory[o.uri]=De(o.syntax,{interceptor:e.interceptor,services:e.services,moduleFactory:e.moduleFactory,lrucache:e.lrucache,timeReference:e.timeReference??null,libraryResolver:e.libraryResolver,customfunctions:e.customfunctions,vars:{}},e.isAsync)),e.moduleFactoryMap[l]=o.uri;let r="";if(r=e.isAsync?"(yield lang.loadModule('"+l+"', runtimeCtx) ); ":"lang.loadModule('"+l+"', runtimeCtx); ",void 0!==e.globalScope[t])return"gscope['"+t+"']="+r;if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']="+r;let a="";return e.undeclaredGlobalsInFunctions.has(t)?(a=e.undeclaredGlobalsInFunctions.get(t).manglename,e.undeclaredGlobalsInFunctions.delete(t)):a=Me(e),e.globalScope._SymbolsMap[t]=a,e.mangleMap[t]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+r}function ae(e,n){const t=V(e,n.declaration);if("FunctionDeclaration"===n.declaration.type)e.exports[n.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===n.declaration.type)for(const o of n.declaration.declarations)e.exports[o.id.name.toLowerCase()]="variable";return t}function se(e){if("iif"===e)throw new a;if("decode"===e)throw new a;if("when"===e)throw new a}function ie(e,n){const t=n.id.name.toLowerCase();se(t);let o="",l=!1;void 0!==e.globalScope[t]?o=t:void 0!==e.globalScope._SymbolsMap[t]?o=e.globalScope._SymbolsMap[t]:e.undeclaredGlobalsInFunctions.has(t)?(o=e.undeclaredGlobalsInFunctions.get(t).manglename,e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o,e.undeclaredGlobalsInFunctions.delete(t),l=!0):(o=Me(e),e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o);const r={isAsync:e.isAsync,console:e.console,exports:e.exports,undeclaredGlobalsInFunctions:e.undeclaredGlobalsInFunctions,customfunctions:e.customfunctions,moduleFactory:e.moduleFactory,moduleFactoryMap:e.moduleFactoryMap,libraryResolver:e.libraryResolver,lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,symbols:e.symbols,mangleMap:e.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:e.depthCounter,globalScope:e.globalScope};let a="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let s=0;s<n.params.length;s++){const t=n.params[s].name.toLowerCase();se(t);const o=Me(e);r.localScope._SymbolsMap[t]=o,r.mangleMap[t]=o,a+="lscope['"+o+"']=arguments["+s.toString()+"];\n"}return!0===e.isAsync?(a+="return lang.__awaiter(this, void 0, void 0, function* () {\n",a+=oe(r,n.body)+"\n return lastStatement; ",a+="}); }",a+=", runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"):(a+=oe(r,n.body)+"\n return lastStatement; }, runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"),l?"gscope[lang.setAssig('"+o+"', runtimeCtx)]="+a:"gscope['"+o+"']="+a}function ce(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(V(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function ue(e,n){let t=null===n.init?null:V(e,n.init);t===h&&(t=null);const o=n.id.name.toLowerCase();if(se(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']="+t+"; ";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']="+t+"; ";{const n=Me(e);return e.localScope._SymbolsMap[o]=n,e.mangleMap[o]=n,"lscope['"+n+"']="+t+"; "}}if(void 0!==e.globalScope[o])return"gscope['"+o+"']="+t+"; ";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']="+t+"; ";if(e.undeclaredGlobalsInFunctions.has(o)){const n=e.undeclaredGlobalsInFunctions.get(o).manglename;return e.globalScope._SymbolsMap[o]=n,e.mangleMap[o]=n,e.undeclaredGlobalsInFunctions.delete(o),"gscope[lang.setAssig('"+n+"', runtimeCtx)]="+t+"; "}const l=Me(e);return e.globalScope._SymbolsMap[o]=l,e.mangleMap[o]=l,"gscope['"+l+"']="+t+"; "}function pe(e,n){try{let t;return!0===n.computed?t=V(e,n.property):(t="'"+n.property.name+"'",se(n.property.name)),"lang.member("+V(e,n.object)+","+t+")"}catch(t){throw t}}function me(e,n){try{return"lang.unary("+V(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function ge(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(V(e,n.elements[o])):t.push("lang.aCheck("+V(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function de(e,n){try{const t=[];let o=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+V(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function fe(e,n){try{return"lang.binary("+V(e,n.left)+","+V(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function he(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new r(e,l.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new r(e,l.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+V(e,n.left)+") "+n.operator+" lang.logicalCheck("+V(e,n.right)+"))";throw new r(null,l.LogicExpressionOrAnd,null)}catch(t){throw t}}function ye(e,n){try{const t=n.name.toLowerCase();if(se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lscope['"+t+"']";if(void 0!==e.localScope._SymbolsMap[t])return"lscope['"+e.localScope._SymbolsMap[t]+"']"}if(void 0!==e.globalScope[t])return"gscope['"+t+"']";if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]"}throw new r(e,l.InvalidIdentifier,n)}catch(t){throw t}}function be(e,n){try{if("MemberExpression"===n.callee.type){let t;!0===n.callee.computed?t=V(e,n.callee.property):(t="'"+n.callee.property.name+"'",se(n.callee.property.name));let o="[";for(let l=0;l<n.arguments.length;l++)l>0&&(o+=", "),o+=V(e,n.arguments[l]);return o+="]",e.isAsync?"(yield lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx))":"lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new r(e,l.FunctionNotFound,n);const t=n.callee.name.toLowerCase();if("iif"===t)return we(e,n);if("when"===t)return Se(e,n);if("decode"===t)return ve(e,n);let o="";if(null!==e.localScope&&(void 0!==e.localScope[t]?o="lscope['"+t+"']":void 0!==e.localScope._SymbolsMap[t]&&(o="lscope['"+e.localScope._SymbolsMap[t]+"']")),""===o)if(void 0!==e.globalScope[t])o="gscope['"+t+"']";else if(void 0!==e.globalScope._SymbolsMap[t])o="gscope['"+e.globalScope._SymbolsMap[t]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(t))o="gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";else{const l={manglename:Me(e),node:n.argument};e.undeclaredGlobalsInFunctions.set(t,l),o="gscope[lang.chkAssig('"+l.manglename+"',runtimeCtx)]"}if(""!==o){let t="[";for(let o=0;o<n.arguments.length;o++)o>0&&(t+=", "),t+=V(e,n.arguments[o]);return t+="]",e.isAsync?"(yield lang.callfunc("+o+","+t+",runtimeCtx) )":"lang.callfunc("+o+","+t+",runtimeCtx)"}throw new r(e,l.FunctionNotFound,n)}catch(t){throw t}}function we(e,n){try{if(3!==n.arguments.length)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${V(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${V(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Se(e,n){try{if(n.arguments.length<3)throw new r(e,l.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${V(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function ve(e,n){try{if(n.arguments.length<2)throw new r(e,l.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${V(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e),o=Fe(e);let a="var ";for(let l=1;l<n.arguments.length-1;l+=2)a+=`${o} = ${V(e,n.arguments[l])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n ${a}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const xe={};function Me(e){return e.symbols.symbolCounter++,"_T"+e.symbols.symbolCounter.toString()}function Fe(e){return e.symbols.symbolCounter++,"_Tvar"+e.symbols.symbolCounter.toString()}G(xe,W),U(xe,W),N(xe,W),B(xe,W),L(xe,W),xe.iif=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}},xe.decode=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}},xe.when=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}};const Ce={};for(const Pe in xe)Ce[Pe]=new i(xe[Pe]);j(xe,W);for(const Pe in xe)xe[Pe]=new i(xe[Pe]);const Ie=function(){};Ie.prototype=xe;const Ae=function(){};function _e(e,n,t){const o={};e||(e={}),t||(t={}),o._SymbolsMap={},o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function Oe(e,n,o,l){const r=o?new Ae:new Ie;e||(e={}),n||(n={});const a=new t({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,r._SymbolsMap={textformatting:1,infinity:1,pi:1},r.textformatting=a,r.infinity=Number.POSITIVE_INFINITY,r.pi=Math.PI;for(const t in n)r[t]=n[t],r._SymbolsMap[t]=1;for(const t in e)r._SymbolsMap[t]=1,e[t]&&"esri.Graphic"===e[t].declaredClass?r[t]=s.createFromGraphic(e[t],l??null):r[t]=e[t];return r}Ae.prototype=Ce;const ke={fixSpatialReference:w,parseArguments:q,standardFunction:W};function Ee(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:W,standardFunctionAsync:W,evaluateIdentifier:Ge};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)xe[e]=new i(t.functions[e]),Ie.prototype[e]=xe[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"sync")}else{for(const e in t.functions)Ce[e]=new i(t.functions[e]),Ae.prototype[e]=Ce[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"async")}}function Re(e,n){return e(n)}function Ge(e,n){const t=n.name;if("_SymbolsMap"===t)throw new o(e,l.InvalidIdentifier,null);if(e.localStack.length>0){if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.localStack[e.localStack.length-1][t])return e.localStack[e.localStack.length-1][t];const n=e.mangleMap[t];if(void 0!==n&&void 0!==e.localStack[e.localStack.length-1][n])return e.localStack[e.localStack.length-1][n]}if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const r=e.mangleMap[t];return void 0!==r?e.globalScope[r]:void 0}Ee([R],"sync"),Ee([R],"async");let Be=0;const $e={error(e){throw new o(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value&&e.value.then?e.value.then(r,a):(Be++,Be%100==0?setTimeout((()=>{Be=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push([]),n.depthCounter.depth>64)throw new o(null,l.MaximumCallDepth,null);const t=e.apply(this,arguments);return D(t)?t.then((e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e))):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new o(n,l.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new o(n,l.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>S(e),aCheck(e,n){if(m(e)){if("ArrayExpression"===n)throw new o(null,l.NoFunctionInArray,null);if("ObjectExpression"===n)throw new o(null,l.NoFunctionInDictionary,null);throw new o(null,l.NoFunctionInTemplateLiteral,null)}return e===h?null:e},Dictionary:t,Feature:s,UserDefinedCompiledFunction:T,dictionary(e){const n={},r=new Map;for(let t=0;t<e.length;t+=2){if(m(e[t+1]))throw new o(null,l.NoFunctionInDictionary,null);if(!1===v(e[t]))throw new o(null,l.KeyMustBeString,null);let a=e[t].toString();const s=a.toLowerCase();r.has(s)?a=r.get(s):r.set(s,a),e[t+1]===h?n[a]=null:n[a]=e[t+1]}const a=new t(n);return a.immutable=!1,a},strCheck(e){if(!1===v(e))throw new o(null,l.KeyMustBeString,null);return e},unary(e,n){if(x(e)){if("!"===n)return!e;if("-"===n)return-1*M(e);if("+"===n)return 1*M(e);if("~"===n)return~M(e);throw new o(null,l.UnsupportedUnaryOperator,null)}if("-"===n)return-1*M(e);if("+"===n)return 1*M(e);if("~"===n)return~M(e);throw new o(null,l.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===x(e))throw new o(null,l.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(x(e)&&x(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new o(null,l.LogicExpressionOrAnd,null)}throw new o(null,l.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return I(M(e),M(n),t);case"==":case"=":return C(e,n);case"!=":return!C(e,n);case"<":case">":case"<=":case">=":return F(e,n,t);case"+":return v(e)||v(n)?S(e)+S(n):M(e)+M(n);case"-":return M(e)-M(n);case"*":return M(e)*M(n);case"/":return M(e)/M(n);case"%":return M(e)%M(n);default:throw new o(null,l.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===h?null:e;case"/=":return M(t)/M(e);case"*=":return M(t)*M(e);case"-=":return M(t)-M(e);case"+=":return v(t)||v(e)?S(t)+S(e):M(t)+M(e);case"%=":return M(t)%M(e);default:throw new o(null,l.UnsupportedOperator,null)}},update(e,n,t,o){const l=M(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:s.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeReference),memberupdate(e,n,r,a){let s;if(A(e)){if(!_(n))throw new o(null,l.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new o(null,l.OutOfBounds,null);s=M(e[n]),e[n]="++"===r?s+1:s-1}else if(e instanceof t){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,l.FieldNotFound,null,{key:n});s=M(e.field(n)),e.setField(n,"++"===r?s+1:s-1)}else if(O(e)){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,l.FieldNotFound,null);s=M(e.field(n)),e.setField(n,"++"===r?s+1:s-1)}else{if(k(e))throw new o(null,l.Immutable,null);if(!(e instanceof Ue))throw new o(null,l.InvalidIdentifier,null);if(!1===v(n))throw new o(null,l.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new o(null,l.ModuleExportNotFound,null);s=M(e.global(n)),e.setGlobal(n,"++"===r?s+1:s-1)}return!1===a?s:"++"===r?s+1:s-1},assignmember(e,n,r,a){if(A(e)){if(!_(n))throw new o(null,l.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new o(null,l.OutOfBounds,null);if(n===e.length){if("="!==r)throw new o(null,l.OutOfBounds,null);e[n]=this.assign(a,r,e[n])}else e[n]=this.assign(a,r,e[n])}else if(e instanceof t){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,r,e.field(n)));else{if("="!==r)throw new o(null,l.FieldNotFound,null);e.setField(n,this.assign(a,r,null))}}else if(O(e)){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,r,e.field(n)));else{if("="!==r)throw new o(null,l.FieldNotFound,null);e.setField(n,this.assign(a,r,null))}}else{if(k(e))throw new o(null,l.Immutable,null);if(!(e instanceof Ue))throw new o(null,l.InvalidIdentifier,null);if(!1===v(n))throw new o(null,l.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new o(null,l.ModuleExportNotFound,null);e.setGlobal(n,this.assign(a,r,e.global(n)))}},member(e,n){if(null===e)throw new o(null,l.MemberOfNull,null);if(e instanceof t||O(e)){if(v(n))return e.field(n);throw new o(null,l.InvalidMemberAccessKey,null)}if(e instanceof P){if(v(n))return $(e,n,null,null);throw new o(null,l.InvalidMemberAccessKey,null)}if(A(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,l.OutOfBounds,null);return e[n]}throw new o(null,l.InvalidMemberAccessKey,null)}if(v(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,l.OutOfBounds,null);return e[n]}throw new o(null,l.InvalidMemberAccessKey,null)}if(k(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new o(null,l.OutOfBounds,null);return e.get(n)}throw new o(null,l.InvalidMemberAccessKey,null)}if(e instanceof Ue){if(v(n))return e.global(n);throw new o(null,l.InvalidMemberAccessKey,null)}throw new o(null,l.InvalidMemberAccessKey,null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeReference:n.timeReference??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,r){if(!(e instanceof Ue))throw new o(null,l.FunctionNotFound,null);const a=e.global(t);if(!1===m(a))throw new o(null,l.CallNonFunction,null);return a.call(r,{preparsed:!0,arguments:n})}};function je(e){console.log(e)}function Ne(e,t,a=!1){null===t&&(t={vars:{},customfunctions:{}});let s=null;e.usesModules&&(s=new n(null,e.loadedModules));const i={isAsync:a,globalScope:_e(t.vars,a?Ce:xe,t.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:t.customfunctions,libraryResolver:s,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:je,lrucache:t.lrucache,timeReference:t.timeReference??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let c=V(i,e);""===c&&(c="lc.voidOperation; "),i.undeclaredGlobalsInFunctions.size>0&&i.undeclaredGlobalsInFunctions.forEach((e=>{throw new r(t,l.InvalidIdentifier,e.node)}));let u="";u=a?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+c+"\n return lastStatement; }); } \n return this.postProcess(yield mainBody()); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+c+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=i.moduleFactory,w=i.moduleFactoryMap,S=i.exports,v={};for(const n in S)v[n]=void 0!==i.mangleMap[n]?i.mangleMap[n]:n;const x={lc:g,lang:$e,mangles:i.mangleMap,postProcess(e){if(e instanceof d&&(e=e.value),e instanceof f&&(e=e.value),e===h&&(e=null),e===y)throw new o(null,l.IllegalResult,null);if(e===b)throw new o(null,l.IllegalResult,null);if(m(e))throw new o(null,l.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=K.WebMercator);const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:w,mangleMap:this.mangles,moduleSingletons:{},exports:S,gdefs:{},exportmangle:v,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(x)}async function Le(){return Ee([await import("./functions/geomasync.js")],"async"),!0}class Ue extends e{constructor(e){super(null),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,r=e.toLowerCase();if(m(n))throw new o(null,l.AssignModuleFunction,null);t[this.moduleContext.exportmangle[r]]=n}global(e){const n=this.moduleContext.globalScope;e=e.toLowerCase();const t=n[this.moduleContext.exportmangle[e]];if(void 0===t)throw new o(null,l.InvalidIdentifier,null);if(m(t)&&!(t instanceof u)){const o=new u;return o.fn=t,o.parameterEvaluator=W,o.context=this.moduleContext,n[this.moduleContext.exportmangle[e]]=o,o}return t}}function De(e,t,o=!1){const l={isAsync:o,moduleFactory:t.moduleFactory,moduleFactoryMap:{},libraryResolver:new n(null,e.loadedModules),globalScope:_e(t.vars,o?Ce:xe,t.customfunctions),customfunctions:t.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:je,lrucache:t.lrucache,timeReference:t.timeReference??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let r=V(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};for(const n in c)u[n]=void 0!==l.mangleMap[n]?l.mangleMap[n]:n;const p={lc:g,lang:$e,mangles:l.mangleMap,prepareModule:e=>new Ue(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new K({wkid:102100}));const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(p)}export{T as UserDefinedCompiledFunction,Ne as compileScript,Le as enableAsyncSupport,Re as executeScript,Ee as extend,ke as functionHelper};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../request.js";import t from"./featureSetCollection.js";import{Z as a,_ as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import i from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import l from"./featureset/actions/SpatialFilter.js";import o from"./featureset/actions/Top.js";import u from"./featureset/sources/FeatureLayerDynamic.js";import c from"./featureset/sources/FeatureLayerMemory.js";import d from"./featureset/sources/FeatureLayerRelated.js";import f from"./featureset/support/cache.js";import{FeatureSetError as p,FeatureSetErrorCodes as m}from"./featureset/support/errorsupport.js";import y from"./featureset/support/FeatureSet.js";import{extractServiceUrl as h}from"./featureset/support/shared.js";import{WhereClause as _}from"../core/sql/WhereClause.js";import w from"../layers/FeatureLayer.js";import L from"../portal/PortalItem.js";function S(){null===f.applicationCache&&(f.applicationCache=new f)}async function I(e,t){if(f.applicationCache){const r=f.applicationCache.getLayerInfo(e);if(r){const a=await r;return new w({url:e,outFields:t,sourceJSON:a})}const n=new w({url:e,outFields:t}),i=(async()=>(await n.load(),n.sourceJSON))();if(f.applicationCache){f.applicationCache.setLayerInfo(e,i);try{return await i,n}catch(a){throw f.applicationCache.clearLayerInfo(e),a}}return await i,n}return new w({url:e,outFields:t})}async function F(e,t,a,r,n,i=null){return g(await I(e,["*"]),t,a,r,n,i)}function g(e,t=null,r=null,n=!0,i=null,s=null){if(e instanceof w||a(e)){const a={layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:i,interceptor:s};return!0==!(e.url||!e.source)?new c(a):new u(a)}return g(e.parent,t,r,n,i,s).filter(_.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),e.parent?.fieldsIndex))}async function N(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function A(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements&&e.layerDataElements[0])return e.layerDataElements[0]}throw new p(m.DataElementsNotFound)})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(r,n);try{return await n}catch(i){throw f.applicationCache.clearLayerInfo(r),i}}return n}async function C(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function T(e,t){const a={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null},r=await C(e);if(a.metadata=r,r.controllerDatasetLayers&&void 0!==r.controllerDatasetLayers.utilityNetworkLayerId&&null!==r.controllerDatasetLayers.utilityNetworkLayerId){if(r.layers)for(const e of r.layers)a.layerNameLkp[e.id]=e.name;if(r.tables)for(const e of r.tables)a.layerNameLkp[e.id]=e.name;const n=r.controllerDatasetLayers.utilityNetworkLayerId;a.networkId=n;const i=await A(e,n);if(i){a.queryelem=i,a.queryelem&&a.queryelem.dataElement&&void 0!==a.queryelem.dataElement.schemaGeneration&&(a.unVersion=a.queryelem.dataElement.schemaGeneration),a.lkp={},a.queryelem.dataElement.domainNetworks||(a.queryelem.dataElement.domainNetworks=[]);for(const e of a.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}}if(a.queryelem.dataElement.terminalConfigurations)for(const e of a.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)a.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const r=await N(e+"/"+n);if(r.systemLayers&&void 0!==r.systemLayers.associationsTableId&&null!==r.systemLayers.associationsTableId){const n=[];a.unVersion>=4&&(n.push("STATUS"),n.push("PERCENTALONG"));let i=await F(e+"/"+r.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...n],!1,null,null);return await i.load(),a.unVersion>=4&&(i=i.filter(_.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",i.getFieldsIndex())),await i.load()),{lkp:a.lkp,associations:i,unVersion:a.unVersion,terminals:a.terminals}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}async function k(e,t,a,r=null,n=null,i=!0,s=null,l=null){let o=e.serviceUrl();if(!o)return null;o="/"===o.at(-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await F(o,r,n,i,s,l);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:i,lrucache:s,interceptor:l})}n.registerAction(),i.registerAction(),s.registerAction(),l.registerAction(),o.registerAction();class b extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.title===e)return!0}else if(a(t)){if(t.title===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e=a.outFields?a:{...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.title===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}async featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetById(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.id===e)return!0}else if(a(t)){if(t.id===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>t.id===e));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e={...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.id===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await C(this._url);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new O(this._url,this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])s.name===e&&(i=s);if(!i)for(const s of n.tables??[])s.name===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(!i)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new b(e,t,a,r)}function D(e,t,a=null,r=null){return new O(e,t,a,r)}function j(e,t,n,i,s){if(null===e)return null;if(e instanceof w){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(a(e)){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(r(e)){switch(t){case"datasource":return g(e.parent,s,e.parent.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.parent.outFields,!0,n,i)}return null}if(e instanceof y)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}async function q(e,t,a,r,n,i,s,l=null){if(f.applicationCache){const o=f.applicationCache.getLayerInfo(e+":"+i.url);if(o){const e=await o;return g(new w({url:h(e.url)+"/"+t,outFields:["*"]}),a,r,n,s,l)}}const o=new L({id:e,portal:i}).load();f.applicationCache&&f.applicationCache.setLayerInfo(e+":"+i.url,o);try{const e=await o;return g(new w({url:h(e.url??"")+"/"+t,outFields:["*"]}),a,r,n,s,l)}catch(u){throw f.applicationCache&&f.applicationCache.clearLayerInfo(e+":"+i.url),u}}export{T as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,q as constructFeatureSetFromPortalItem,k as constructFeatureSetFromRelationship,F as constructFeatureSetFromUrl,j as convertToFeatureSet,E as createFeatureSetCollectionFromMap,D as createFeatureSetCollectionFromService,S as initialiseMetaDataCache};
|
|
5
|
+
import e from"../request.js";import t from"./featureSetCollection.js";import{Z as a,_ as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import i from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import l from"./featureset/actions/SpatialFilter.js";import o from"./featureset/actions/Top.js";import u from"./featureset/sources/FeatureLayerDynamic.js";import c from"./featureset/sources/FeatureLayerMemory.js";import d from"./featureset/sources/FeatureLayerRelated.js";import f from"./featureset/support/cache.js";import{FeatureSetError as p,FeatureSetErrorCodes as m}from"./featureset/support/errorsupport.js";import y from"./featureset/support/FeatureSet.js";import{extractServiceUrl as h}from"./featureset/support/shared.js";import{WhereClause as _}from"../core/sql/WhereClause.js";import w from"../layers/FeatureLayer.js";import L from"../portal/PortalItem.js";function S(){null===f.applicationCache&&(f.applicationCache=new f)}async function I(e,t){if(f.applicationCache){const r=f.applicationCache.getLayerInfo(e);if(r){const a=await r;return new w({url:e,outFields:t,sourceJSON:a})}const n=new w({url:e,outFields:t}),i=(async()=>(await n.load(),n.sourceJSON))();if(f.applicationCache){f.applicationCache.setLayerInfo(e,i);try{return await i,n}catch(a){throw f.applicationCache.clearLayerInfo(e),a}}return await i,n}return new w({url:e,outFields:t})}async function F(e,t,a,r,n,i=null){return g(await I(e,["*"]),t,a,r,n,i)}function g(e,t=null,r=null,n=!0,i=null,s=null){if(e instanceof w||a(e)){const a={layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:i,interceptor:s};return!0==!(e.url||!e.source)?new c(a):new u(a)}return g(e.parent,t,r,n,i,s).filter(_.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),e.parent?.fieldsIndex))}async function A(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function N(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements&&e.layerDataElements[0])return e.layerDataElements[0]}throw new p(m.DataElementsNotFound)})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(r,n);try{return await n}catch(i){throw f.applicationCache.clearLayerInfo(r),i}}return n}async function C(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function T(e,t){const a={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null},r=await C(e);if(a.metadata=r,r.controllerDatasetLayers&&void 0!==r.controllerDatasetLayers.utilityNetworkLayerId&&null!==r.controllerDatasetLayers.utilityNetworkLayerId){if(r.layers)for(const e of r.layers)a.layerNameLkp[e.id]=e.name;if(r.tables)for(const e of r.tables)a.layerNameLkp[e.id]=e.name;const n=r.controllerDatasetLayers.utilityNetworkLayerId;a.networkId=n;const i=await N(e,n);if(i){a.queryelem=i,a.queryelem&&a.queryelem.dataElement&&void 0!==a.queryelem.dataElement.schemaGeneration&&(a.unVersion=a.queryelem.dataElement.schemaGeneration),a.lkp={},a.queryelem.dataElement.domainNetworks||(a.queryelem.dataElement.domainNetworks=[]);for(const e of a.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}}if(a.queryelem.dataElement.terminalConfigurations)for(const e of a.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)a.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const r=await A(e+"/"+n);if(r.systemLayers&&void 0!==r.systemLayers.associationsTableId&&null!==r.systemLayers.associationsTableId){const n=[];a.unVersion>=4&&(n.push("STATUS"),n.push("PERCENTALONG"));let i=await F(e+"/"+r.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...n],!1,null,null);return await i.load(),a.unVersion>=4&&(i=i.filter(_.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",i.getFieldsIndex())),await i.load()),{lkp:a.lkp,associations:i,unVersion:a.unVersion,terminals:a.terminals}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}async function k(e,t,a,r=null,n=null,i=!0,s=null,l=null){let o=e.serviceUrl();if(!o)return null;o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await F(o,r,n,i,s,l);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:i,lrucache:s,interceptor:l})}n.registerAction(),i.registerAction(),s.registerAction(),l.registerAction(),o.registerAction();class b extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.title===e)return!0}else if(a(t)){if(t.title===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e=a.outFields?a:{...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.title===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}async featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetById(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.id===e)return!0}else if(a(t)){if(t.id===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>t.id===e));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e={...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.id===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await C(this._url);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new O(this._url,this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])s.name===e&&(i=s);if(!i)for(const s of n.tables??[])s.name===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(!i)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new b(e,t,a,r)}function D(e,t,a=null,r=null){return new O(e,t,a,r)}function j(e,t,n,i,s){if(null===e)return null;if(e instanceof w){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(a(e)){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(r(e)){switch(t){case"datasource":return g(e.parent,s,e.parent.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.parent.outFields,!0,n,i)}return null}if(e instanceof y)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}async function q(e,t,a,r,n,i,s,l=null){if(f.applicationCache){const o=f.applicationCache.getLayerInfo(e+":"+i.url);if(o){const e=await o;return g(new w({url:h(e.url)+"/"+t,outFields:["*"]}),a,r,n,s,l)}}const o=new L({id:e,portal:i}).load();f.applicationCache&&f.applicationCache.setLayerInfo(e+":"+i.url,o);try{const e=await o;return g(new w({url:h(e.url??"")+"/"+t,outFields:["*"]}),a,r,n,s,l)}catch(u){throw f.applicationCache&&f.applicationCache.clearLayerInfo(e+":"+i.url),u}}export{T as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,q as constructFeatureSetFromPortalItem,k as constructFeatureSetFromRelationship,F as constructFeatureSetFromUrl,j as convertToFeatureSet,E as createFeatureSetCollectionFromMap,D as createFeatureSetCollectionFromService,S as initialiseMetaDataCache};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{FeatureSetError as t,FeatureSetErrorCodes as e}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{IdState as i}from"../support/shared.js";class a extends n{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 e=await this._parent._getSet(t);return this._wset=new s(e._candidates.slice(0),e._known.slice(0),!1,this._clonePageDefinition(e.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.
|
|
5
|
+
import{FeatureSetError as t,FeatureSetErrorCodes as e}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{IdState as i}from"../support/shared.js";class a extends n{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 e=await this._parent._getSet(t);return this._wset=new s(e._candidates.slice(0),e._known.slice(0),!1,this._clonePageDefinition(e.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===i.NotInFeatureSet)return e;const n=this._idstates[t];return n===i.InFeatureSet||n===i.NotInFeatureSet?n:e===i.InFeatureSet&&void 0===n?this._countedin<this._topnum?(this._idstates[t]=i.InFeatureSet,this._countedin++,i.InFeatureSet):(this._idstates[t]=i.NotInFeatureSet,i.NotInFeatureSet):i.Unknown}async _expandPagedSet(n,s,i,a,o){if(null===this._parent)throw new t(e.NotImplemented);if(s>this._topnum&&(s=this._topnum),this._countedin>=this._topnum&&n.pagesDefinition.internal.set.length<=n.pagesDefinition.resultOffset){let t=n._known.length;return t>0&&"GETPAGES"===n._known[t-1]&&(n._known.length=t-1),t=n._candidates.length,t>0&&"GETPAGES"===n._candidates[t-1]&&(n._candidates.length=t-1),"success"}const r=await this._parent._expandPagedSet(n,s,i,a,o);return this._setKnownLength(n)>this._topnum&&(n._known.length=this._topnum),this._setKnownLength(n)>=this._topnum&&(n._candidates.length=0),r}async _getFeatures(t,e,n,i){const a=[],o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(t,o))return await this._expandPagedSet(t,o,0,0,i),this._getFeatures(t,e,n,i);-1!==e&&void 0===this._featureCache[e]&&a.push(e);let r=0;for(let s=t._lastFetchedIndex;s<t._known.length&&(r++,r<=n&&(t._lastFetchedIndex+=1),!(void 0===this._featureCache[t._known[s]]&&(t._known[s]!==e&&a.push(t._known[s]),a.length>o)));s++);if(0===a.length)return"success";const _=new s([],a,!1,null),h=Math.min(a.length,n);await this._parent._getFeatures(_,-1,h,i);for(let s=0;s<h;s++){const t=this._parent._featureFromCache(a[s]);void 0!==t&&(this._featureCache[a[s]]=t)}return"success"}async _getFilteredSet(t,e,n,i,a){await this._ensureLoaded();const o=await this._getSet(a);return new s(o._candidates.slice(0).concat(o._known.slice(0)),[],!1,this._clonePageDefinition(o.pagesDefinition))}_refineKnowns(t,e){let n=0,s=null;const a=[];for(let o=0;o<t._candidates.length;o++){const r=this._isInFeatureSet(t._candidates[o]);if(r===i.InFeatureSet){if(t._known.push(t._candidates[o]),n+=1,null===s?s={start:o,end:o}:s.end===o-1?s.end=o:(a.push(s),s={start:o,end:o}),t._known.length>=this._topnum)break}else if(r===i.NotInFeatureSet)null===s?s={start:o,end:o}:s.end===o-1?s.end=o:(a.push(s),s={start:o,end:o}),n+=1;else if(r===i.Unknown)break;if(n>=e)break}null!==s&&a.push(s);for(let i=a.length-1;i>=0;i--)t._candidates.splice(a[i].start,a[i].end-a[i].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(){n._featuresetFunctions.top=function(t){return new a({parentfeatureset:this,topnum: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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{id as t}from"../../../kernel.js";import i from"../../../request.js";import r from"../../Attachment.js";import s from"../../Dictionary.js";import{FeatureSetError as a,FeatureSetErrorCodes as n}from"../support/errorsupport.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import{defaultMaxRecords as u,stableStringify as d,FeatureServiceDatabaseType as c,IdState as h,extractServiceUrl as p}from"../support/shared.js";import{toWhereClause as y,isSingleField as f}from"../support/sqlUtils.js";import{decodeStatType as m}from"../support/stats.js";import{createMD5Hash as _,outputTypes as g}from"../../../core/MD5.js";import{fromJSON as R}from"../../../geometry/support/jsonUtils.js";import w from"../../../layers/FeatureLayer.js";import S from"../../../layers/SubtypeGroupLayer.js";import{executeQuery as F}from"../../../rest/query/executeQuery.js";import"../../../config.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/urlUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as b}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import"../../../geometry/support/normalizeUtils.js";import"../../../core/Error.js";import"../../../core/pbf.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../geometry/ellipsoidUtils.js";import D from"../../../rest/support/Query.js";import{executeForIds as I}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as x}from"../../../rest/query/executeQueryJSON.js";import"../../../layers/graphics/featureConversionUtils.js";import"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../rest/support/TopFeaturesQuery.js";import T from"../../../rest/support/StatisticDefinition.js";class C extends l{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,this._cachedDateMetaData={},e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return u}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+d(e.toJSON());return _(t,g.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=c.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=c.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=c.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=c.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this._layer instanceof S?(this.typeIdField=this._layer.subtypeField??"",this.types=this._layer.subtypes):(this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types)}_isInFeatureSet(){return h.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 D;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){return e.quantizationParameters={mode:"edit"},(await F(this._layer.parsedUrl,e,{format:"pbf"},{})).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){e.returnZ=this.hasZ,e.returnM=this.hasM;const i="execute"===t?x:"executeForCount"===t?b:I,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,s){const a=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new o([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,s);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 u=new D;this.datesInUnknownTimezone&&(u.timeReferenceUnknownClient=!0),u.where=null===i?null===t?"1=1":"":y(i,a),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==n?n.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let d=await this.executeQuery(u,"executeForIds");null===d&&(d=[]),this._checkCancelled(s);return new o([],d,l,null)}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}async _getFilteredSetUsingPaging(e,t,i,r,s){let a="",n=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=r.constructClause(),n=!0);const l=await this.databaseType();let u=null===i?null===t?"1=1":"":y(i,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let d=this._maxQueryRate();const c=this._layer.capabilities?.query.maxRecordCount;null!=c&&c<d&&(d=c);let h=null;if(!0===this._pageJustIds)h=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const r=this._overrideFields??this._fieldsIncludingObjectId(["*"]);h=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(h,d,0,1,s),h}_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 D;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[s+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){const s=[];if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let l=0;for(let a=e._lastFetchedIndex;a<e._known.length;a++){if(e._lastFetchedIndex+=1,l++,void 0===this._featureCache[e._known[a]]){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[a]]){const r=t._featureMap[e._known[a]];null!==r&&(i=!0,this._featureCache[e._known[a]]=r)}}if(!1===i&&(e._known[a]!==t&&s.push(e._known[a]),s.length>=this._maxProcessingRate()-1))break}if(l>=i&&0===s.length)break}if(0===s.length)return"success";const o=new D;this._requestStandardised&&(o.sqlFormat="standard"),this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.objectIds=s,o.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),o.returnGeometry=!0,!0===this._removeGeometry&&(o.returnGeometry=!1),o.outSpatialReference=this.spatialReference;const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),void 0!==u.error)throw new a(n.RequestFailed,{reason:u.error});const d=this._layer.objectIdField;for(let a=0;a<u.features.length;a++)this._featureCache[u.features[a].attributes[d]]=u.features[a];return"success"}async _getDistinctPages(e,t,i,r,s,l,o,u,d){await this._ensureLoaded();const c=await this.databaseType();let h=i.parseTree.column;const p=this._layer.fields??[];for(let a=0;a<p.length;a++)if(p[a].name.toLowerCase()===h.toLowerCase()){h=p[a].name;break}const f=new D;this._requestStandardised&&(f.sqlFormat="standard"),this.datesInUnknownTimezone&&(f.timeReferenceUnknownClient=!0);let m=null===l?null===s?"1=1":"":y(l,c);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression),f.where=m,f.spatialRelationship=this._makeRelationshipEnum(r),f.relationParameter=this._makeRelationshipParam(r),f.geometry=null===s?null:s,f.returnDistinctValues=!0,f.returnGeometry=!1,f.outFields=[h];const _=await this.executeQuery(f,"execute");if(this._checkCancelled(d),!_.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);let g=!1;for(let a=0;a<p.length;a++)if(p[a].name===h){"date"===p[a].type&&(g=!0);break}for(let a=0;a<_.features.length;a++){if(g){const e=_.features[a].attributes[h];null!==e?u.push(new Date(e)):u.push(e)}else u.push(_.features[a].attributes[h]);if(u.length>=o)break}if(0===_.features.length)return u;if(_.features.length===this._layer.capabilities?.query.maxRecordCount&&u.length<o){return{calculated:!0,result:await this._getDistinctPages(e+_.features.length,t,i,r,s,l,o,u,d)}}return u}async _distinctStat(e,t,i,r,s,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,s,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new D;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":"":y(r,s);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,r,s,l,o){await this._ensureLoaded();const u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,d=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,c=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return c?this._countstat(e,i,r,s):{calculated:!1};if(!1===d||!1===f(t)&&!1===u||!1===t.isStandardized)return""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,l,o);if("distinct"===e)return!1===c?""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,l,o):this._distinctStat(e,t,i,r,s,l,o);const h=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};const p=new D;this._requestStandardised&&(p.sqlFormat="standard");let _=null===s?null===r?"1=1":"":y(s,h);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression),p.where=_,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===r?null:r,this.datesInUnknownTimezone&&(p.timeReferenceUnknownClient=!0);const g=new T;g.statisticType=m(e),g.onStatisticField=y(t,h),g.outStatisticFieldName="ARCADE_STAT_RESULT",p.returnGeometry=!1;let R="ARCADE_STAT_RESULT";p.outStatistics=[g];const w=await this.executeQuery(p,"execute");if(!w.hasOwnProperty("features")||0===w.features.length)throw new a(n.InvalidStatResponse);let S=!1;const F=w.fields??[];for(let a=0;a<F.length;a++)if("ARCADE_STAT_RESULT"===F[a].name.toUpperCase()){R=F[a].name,"date"===F[a].type&&(S=!0);break}if(S){let e=w.features[0].attributes[R];return null!==e&&(e=new Date(w.features[0].attributes[R])),{calculated:!0,result:e}}return{calculated:!0,result:w.features[0].attributes[R]}}_stat(e,t,i,r,s,a,n){return this._stats(e,t,i,r,s,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const r=this._layer.capabilities?.query,s=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===f(t[a].workingexpr)&&!1===s)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,s,a,n){await this._ensureLoaded();const l=await this.databaseType();let u="",d=!1,c=!1;null!==a&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=a.constructClause(),c=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(c=!1,d=!0,u=this._layer.objectIdField);const h=[];for(let o=0;o<t.length;o++){const e=new T;e.onStatisticField=null!==t[o].workingexpr?y(t[o].workingexpr,l):"",e.outStatisticFieldName=t[o].field,e.statisticType=t[o].toStatisticsName(),h.push(e)}""===u&&(u=e.join(","));let p=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;null!=f&&f<p&&(p=f);let m=null===s?null===r?"1=1":"":y(s,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression);return new o([],["GETPAGES"],c,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:d,generatedOid:n,resultRecordCount:p,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:h,geometry:null===r?null:r,where:m,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,r){let s=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const l=t.pagesDefinition.internal.lastRetrieved,o=l,u=t.pagesDefinition.internal.lastPage,d=new D;if(this._requestStandardised&&(d.sqlFormat="standard"),d.where=s,d.spatialRelationship=t.pagesDefinition.spatialRel,d.relationParameter=t.pagesDefinition.relationParam,d.outFields=t.pagesDefinition.outFields,d.outStatistics=t.pagesDefinition.outStatistics,d.geometry=t.pagesDefinition.geometry,d.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,d.num=t.pagesDefinition.resultRecordCount,d.start=t.pagesDefinition.internal.lastPage,d.returnGeometry=t.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(d.timeReferenceUnknownClient=!0),d.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&d.geometry&&d.spatialRelationship)return[];const c=await this.executeQuery(d,"execute");if(this._checkCancelled(r),!c.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);const h=[];if(t.pagesDefinition.internal.lastPage!==u)return[];c.features.length>0&&void 0===c.features[0].attributes[t.pagesDefinition.generatedOid]&&(t.pagesDefinition.generatedOid=t.pagesDefinition.generatedOid.toLowerCase());for(let e=0;e<c.features.length;e++)t.pagesDefinition.internal.set[o+e]=c.features[e].attributes[t.pagesDefinition.generatedOid];for(let a=0;a<c.features.length;a++)h.push(new e({attributes:c.features[a].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===c.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=c.features.at(-1).attributes[t.pagesDefinition.generatedOid]:(void 0===c.exceededTransferLimit&&c.features.length!==t.pagesDefinition.resultRecordCount||!1===c.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=l+c.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,h}static create(e,t,i,r,s){const a=new w({url:e,outFields:null===t?["*"]:t});return new C({layer:a,spatialReference:i,lrucache:r,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return p(this._layer.parsedUrl.path)}async queryAttachments(e,t,i,a,n){const l=this._layer.capabilities;if(l?.data.supportsAttachment&&l?.operations.supportsQueryAttachments){const l={objectIds:[e],returnMetadata:n};(t&&t>0||i&&i>0)&&(l.size=[t&&t>0?t:0,i&&i>0?i:t+1]),a&&a.length>0&&(l.attachmentTypes=a),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:l,method:"attachments"});const o=await this._layer.queryAttachments(l),u=[];return o&&o[e]&&o[e].forEach((t=>{const i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let a=null;n&&t.exifInfo&&(a=s.convertJsonToArcade(t.exifInfo,"system",!0)),u.push(new r(t.id,t.name,t.contentType,t.size,i,a,t.keywords??null))})),u}return[]}async queryRelatedFeatures(t){const r={f:"json",relationshipId:t.relationshipId.toString(),definitionExpression:t.where,outFields:t.outFields?.join(","),returnGeometry:t.returnGeometry.toString()};void 0!==t.resultOffset&&null!==t.resultOffset&&(r.resultOffset=t.resultOffset.toString()),void 0!==t.resultRecordCount&&null!==t.resultRecordCount&&(r.resultRecordCount=t.resultRecordCount.toString()),t.orderByFields&&(r.orderByFields=t.orderByFields.join(",")),t.objectIds&&t.objectIds.length>0&&(r.objectIds=t.objectIds.join(",")),t.outSpatialReference&&(r.outSR=JSON.stringify(t.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await i(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?R(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new a(n.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new D;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(i.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const r=await x(this._layer.parsedUrl.path,i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();const e=t?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=t?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let r=this._layer.url;const s=r.toLowerCase().indexOf("/rest/services");if(r=s>-1?r.substring(0,s):r,r){r+="/rest/info";try{const e=await i(r,{query:{f:"json"}});let t="";return e.data&&e.data.owningSystemUrl&&(t=e.data.owningSystemUrl),t}catch(a){return""}}return""}getDataSourceFeatureSet(){const e=new C({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeReference(){return void 0===this._cachedDateMetaData.preferredTimeReference&&(this._cachedDateMetaData.preferredTimeReference=this._layer?.preferredTimeReference?.toJSON()??null),this._cachedDateMetaData.preferredTimeReference}get dateFieldsTimeReference(){return void 0===this._cachedDateMetaData.dateFieldsTimeReference&&(this._cachedDateMetaData.dateFieldsTimeReference=this._layer?.dateFieldsTimeReference?.toJSON()??null),this._cachedDateMetaData.dateFieldsTimeReference}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone}get editFieldsInfo(){return void 0===this._cachedDateMetaData.editFieldsInfo&&(this._cachedDateMetaData.editFieldsInfo=this._layer?.editFieldsInfo?.toJSON()??null),this._cachedDateMetaData.editFieldsInfo}get timeInfo(){return void 0===this._cachedDateMetaData.timeInfo&&(this._cachedDateMetaData.timeInfo=this._layer?.timeInfo?.toJSON()??null),this._cachedDateMetaData.timeInfo}}export{C as default};
|
|
5
|
+
import e from"../../../Graphic.js";import{id as t}from"../../../kernel.js";import i from"../../../request.js";import r from"../../Attachment.js";import s from"../../Dictionary.js";import{FeatureSetError as a,FeatureSetErrorCodes as n}from"../support/errorsupport.js";import l from"../support/FeatureSet.js";import o from"../support/IdSet.js";import{defaultMaxRecords as u,stableStringify as d,FeatureServiceDatabaseType as c,IdState as h,extractServiceUrl as p}from"../support/shared.js";import{toWhereClause as y,isSingleField as f}from"../support/sqlUtils.js";import{decodeStatType as m}from"../support/stats.js";import{createMD5Hash as _,outputTypes as g}from"../../../core/MD5.js";import{fromJSON as R}from"../../../geometry/support/jsonUtils.js";import w from"../../../layers/FeatureLayer.js";import S from"../../../layers/SubtypeGroupLayer.js";import{executeQuery as F}from"../../../rest/query/executeQuery.js";import"../../../config.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/urlUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as b}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import"../../../geometry/support/normalizeUtils.js";import"../../../core/Error.js";import"../../../core/pbf.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../geometry/ellipsoidUtils.js";import D from"../../../rest/support/Query.js";import{executeForIds as I}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as x}from"../../../rest/query/executeQueryJSON.js";import"../../../layers/graphics/featureConversionUtils.js";import"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../rest/support/TopFeaturesQuery.js";import T from"../../../rest/support/StatisticDefinition.js";class C extends l{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,this._cachedDateMetaData={},e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return u}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+d(e.toJSON());return _(t,g.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(await this._layer.load(),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(const r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=c.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=c.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=c.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=c.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this._layer instanceof S?(this.typeIdField=this._layer.subtypeField??"",this.types=this._layer.subtypes):(this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types)}_isInFeatureSet(){return h.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 D;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(i){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){return e.quantizationParameters={mode:"edit"},(await F(this._layer.parsedUrl,e,{format:"pbf"},{})).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){e.returnZ=this.hasZ,e.returnM=this.hasM;const i="execute"===t?x:"executeForCount"===t?b:I,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,s){const a=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e){return new o([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,s);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 u=new D;this.datesInUnknownTimezone&&(u.timeReferenceUnknownClient=!0),u.where=null===i?null===t?"1=1":"":y(i,a),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==n?n.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let d=await this.executeQuery(u,"executeForIds");null===d&&(d=[]),this._checkCancelled(s);return new o([],d,l,null)}_expandPagedSet(e,t,i,r,s){return this._expandPagedSetFeatureSet(e,t,i,r,s)}async _getFilteredSetUsingPaging(e,t,i,r,s){let a="",n=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=r.constructClause(),n=!0);const l=await this.databaseType();let u=null===i?null===t?"1=1":"":y(i,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(u=""!==u?"(("+this._layer.definitionExpression+") AND ("+u+"))":this._layer.definitionExpression);let d=this._maxQueryRate();const c=this._layer.capabilities?.query.maxRecordCount;null!=c&&c<d&&(d=c);let h=null;if(!0===this._pageJustIds)h=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);const r=this._overrideFields??this._fieldsIncludingObjectId(["*"]);h=new o([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:d,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:a,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(h,d,0,1,s),h}_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 D;this._requestStandardised&&(n.sqlFormat="standard"),this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;const l=await this.executeQuery(n,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";const o=this._layer.objectIdField;for(let u=0;u<l.features.length;u++)e.pagesDefinition.internal.set[s+u]=l.features[u].attributes[o];if(!1===this._pageJustIds)for(let u=0;u<l.features.length;u++)this._featureCache[l.features[u].attributes[o]]=l.features[u];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let i=!1;for(const r of t)if(r.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){const s=[];if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let l=0;for(let a=e._lastFetchedIndex;a<e._known.length;a++){if(e._lastFetchedIndex+=1,l++,void 0===this._featureCache[e._known[a]]){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[a]]){const r=t._featureMap[e._known[a]];null!==r&&(i=!0,this._featureCache[e._known[a]]=r)}}if(!1===i&&(e._known[a]!==t&&s.push(e._known[a]),s.length>=this._maxProcessingRate()-1))break}if(l>=i&&0===s.length)break}if(0===s.length)return"success";const o=new D;this._requestStandardised&&(o.sqlFormat="standard"),this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.objectIds=s,o.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),o.returnGeometry=!0,!0===this._removeGeometry&&(o.returnGeometry=!1),o.outSpatialReference=this.spatialReference;const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),void 0!==u.error)throw new a(n.RequestFailed,{reason:u.error});const d=this._layer.objectIdField;for(let a=0;a<u.features.length;a++)this._featureCache[u.features[a].attributes[d]]=u.features[a];return"success"}async _getDistinctPages(e,t,i,r,s,l,o,u,d){await this._ensureLoaded();const c=await this.databaseType();let h=i.parseTree.column;const p=this._layer.fields??[];for(let a=0;a<p.length;a++)if(p[a].name.toLowerCase()===h.toLowerCase()){h=p[a].name;break}const f=new D;this._requestStandardised&&(f.sqlFormat="standard"),this.datesInUnknownTimezone&&(f.timeReferenceUnknownClient=!0);let m=null===l?null===s?"1=1":"":y(l,c);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression),f.where=m,f.spatialRelationship=this._makeRelationshipEnum(r),f.relationParameter=this._makeRelationshipParam(r),f.geometry=null===s?null:s,f.returnDistinctValues=!0,f.returnGeometry=!1,f.outFields=[h];const _=await this.executeQuery(f,"execute");if(this._checkCancelled(d),!_.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);let g=!1;for(let a=0;a<p.length;a++)if(p[a].name===h){"date"===p[a].type&&(g=!0);break}for(let a=0;a<_.features.length;a++){if(g){const e=_.features[a].attributes[h];null!==e?u.push(new Date(e)):u.push(e)}else u.push(_.features[a].attributes[h]);if(u.length>=o)break}if(0===_.features.length)return u;if(_.features.length===this._layer.capabilities?.query.maxRecordCount&&u.length<o){return{calculated:!0,result:await this._getDistinctPages(e+_.features.length,t,i,r,s,l,o,u,d)}}return u}async _distinctStat(e,t,i,r,s,a,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,s,a,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,r){const s=await this.databaseType(),a=new D;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":"":y(r,s);this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),a.where=n,this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.where=n,a.spatialRelationship=this._makeRelationshipEnum(t),a.relationParameter=this._makeRelationshipParam(t),a.geometry=null===i?null:i,a.returnGeometry=!1;return{calculated:!0,result:await this.executeQuery(a,"executeForCount")}}async _stats(e,t,i,r,s,l,o){await this._ensureLoaded();const u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,d=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,c=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return c?this._countstat(e,i,r,s):{calculated:!1};if(!1===d||!1===f(t)&&!1===u||!1===t.isStandardized)return""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,l,o);if("distinct"===e)return!1===c?""!==i||null!==s?{calculated:!1}:this._manualStat(e,t,l,o):this._distinctStat(e,t,i,r,s,l,o);const h=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};const p=new D;this._requestStandardised&&(p.sqlFormat="standard");let _=null===s?null===r?"1=1":"":y(s,h);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression),p.where=_,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===r?null:r,this.datesInUnknownTimezone&&(p.timeReferenceUnknownClient=!0);const g=new T;g.statisticType=m(e),g.onStatisticField=y(t,h),g.outStatisticFieldName="ARCADE_STAT_RESULT",p.returnGeometry=!1;let R="ARCADE_STAT_RESULT";p.outStatistics=[g];const w=await this.executeQuery(p,"execute");if(!w.hasOwnProperty("features")||0===w.features.length)throw new a(n.InvalidStatResponse);let S=!1;const F=w.fields??[];for(let a=0;a<F.length;a++)if("ARCADE_STAT_RESULT"===F[a].name.toUpperCase()){R=F[a].name,"date"===F[a].type&&(S=!0);break}if(S){let e=w.features[0].attributes[R];return null!==e&&(e=new Date(w.features[0].attributes[R])),{calculated:!0,result:e}}return{calculated:!0,result:w.features[0].attributes[R]}}_stat(e,t,i,r,s,a,n){return this._stats(e,t,i,r,s,a,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1;const r=this._layer.capabilities?.query,s=!0===r?.supportsSqlExpression;if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(i=!0),i)for(let a=0;a<t.length-1;a++)(!1===t[a].workingexpr?.isStandardized||!1===f(t[a].workingexpr)&&!1===s)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,s,a,n){await this._ensureLoaded();const l=await this.databaseType();let u="",d=!1,c=!1;null!==a&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=a.constructClause(),c=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(c=!1,d=!0,u=this._layer.objectIdField);const h=[];for(let o=0;o<t.length;o++){const e=new T;e.onStatisticField=null!==t[o].workingexpr?y(t[o].workingexpr,l):"",e.outStatisticFieldName=t[o].field,e.statisticType=t[o].toStatisticsName(),h.push(e)}""===u&&(u=e.join(","));let p=this._maxQueryRate();const f=this._layer.capabilities?.query.maxRecordCount;null!=f&&f<p&&(p=f);let m=null===s?null===r?"1=1":"":y(s,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(m=""!==m?"(("+this._layer.definitionExpression+") AND ("+m+"))":this._layer.definitionExpression);return new o([],["GETPAGES"],c,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:d,generatedOid:n,resultRecordCount:p,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:h,geometry:null===r?null:r,where:m,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(t,i,r){let s=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const l=t.pagesDefinition.internal.lastRetrieved,o=l,u=t.pagesDefinition.internal.lastPage,d=new D;if(this._requestStandardised&&(d.sqlFormat="standard"),d.where=s,d.spatialRelationship=t.pagesDefinition.spatialRel,d.relationParameter=t.pagesDefinition.relationParam,d.outFields=t.pagesDefinition.outFields,d.outStatistics=t.pagesDefinition.outStatistics,d.geometry=t.pagesDefinition.geometry,d.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,d.num=t.pagesDefinition.resultRecordCount,d.start=t.pagesDefinition.internal.lastPage,d.returnGeometry=t.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(d.timeReferenceUnknownClient=!0),d.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&d.geometry&&d.spatialRelationship)return[];const c=await this.executeQuery(d,"execute");if(this._checkCancelled(r),!c.hasOwnProperty("features"))throw new a(n.InvalidStatResponse);const h=[];if(t.pagesDefinition.internal.lastPage!==u)return[];c.features.length>0&&void 0===c.features[0].attributes[t.pagesDefinition.generatedOid]&&(t.pagesDefinition.generatedOid=t.pagesDefinition.generatedOid.toLowerCase());for(let e=0;e<c.features.length;e++)t.pagesDefinition.internal.set[o+e]=c.features[e].attributes[t.pagesDefinition.generatedOid];for(let a=0;a<c.features.length;a++)h.push(new e({attributes:c.features[a].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===c.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=c.features[c.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===c.exceededTransferLimit&&c.features.length!==t.pagesDefinition.resultRecordCount||!1===c.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=l+c.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,h}static create(e,t,i,r,s){const a=new w({url:e,outFields:null===t?["*"]:t});return new C({layer:a,spatialReference:i,lrucache:r,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return p(this._layer.parsedUrl.path)}async queryAttachments(e,t,i,a,n){const l=this._layer.capabilities;if(l?.data.supportsAttachment&&l?.operations.supportsQueryAttachments){const l={objectIds:[e],returnMetadata:n};(t&&t>0||i&&i>0)&&(l.size=[t&&t>0?t:0,i&&i>0?i:t+1]),a&&a.length>0&&(l.attachmentTypes=a),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:l,method:"attachments"});const o=await this._layer.queryAttachments(l),u=[];return o&&o[e]&&o[e].forEach((t=>{const i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let a=null;n&&t.exifInfo&&(a=s.convertJsonToArcade(t.exifInfo,"system",!0)),u.push(new r(t.id,t.name,t.contentType,t.size,i,a,t.keywords??null))})),u}return[]}async queryRelatedFeatures(t){const r={f:"json",relationshipId:t.relationshipId.toString(),definitionExpression:t.where,outFields:t.outFields?.join(","),returnGeometry:t.returnGeometry.toString()};void 0!==t.resultOffset&&null!==t.resultOffset&&(r.resultOffset=t.resultOffset.toString()),void 0!==t.resultRecordCount&&null!==t.resultRecordCount&&(r.resultRecordCount=t.resultRecordCount.toString()),t.orderByFields&&(r.orderByFields=t.orderByFields.join(",")),t.objectIds&&t.objectIds.length>0&&(r.objectIds=t.objectIds.join(",")),t.outSpatialReference&&(r.outSR=JSON.stringify(t.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:r,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const s=await i(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?R(t.geometry):null,attributes:t.attributes});n.push(i)}t[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return t}throw new a(n.InvalidRequest)}async getFeatureByObjectId(e,t){const i=new D;i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(i.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});const r=await x(this._layer.parsedUrl.path,i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();const e=t?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=t?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let r=this._layer.url;const s=r.toLowerCase().indexOf("/rest/services");if(r=s>-1?r.substring(0,s):r,r){r+="/rest/info";try{const e=await i(r,{query:{f:"json"}});let t="";return e.data&&e.data.owningSystemUrl&&(t=e.data.owningSystemUrl),t}catch(a){return""}}return""}getDataSourceFeatureSet(){const e=new C({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeReference(){return void 0===this._cachedDateMetaData.preferredTimeReference&&(this._cachedDateMetaData.preferredTimeReference=this._layer?.preferredTimeReference?.toJSON()??null),this._cachedDateMetaData.preferredTimeReference}get dateFieldsTimeReference(){return void 0===this._cachedDateMetaData.dateFieldsTimeReference&&(this._cachedDateMetaData.dateFieldsTimeReference=this._layer?.dateFieldsTimeReference?.toJSON()??null),this._cachedDateMetaData.dateFieldsTimeReference}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone}get editFieldsInfo(){return void 0===this._cachedDateMetaData.editFieldsInfo&&(this._cachedDateMetaData.editFieldsInfo=this._layer?.editFieldsInfo?.toJSON()??null),this._cachedDateMetaData.editFieldsInfo}get timeInfo(){return void 0===this._cachedDateMetaData.timeInfo&&(this._cachedDateMetaData.timeInfo=this._layer?.timeInfo?.toJSON()??null),this._cachedDateMetaData.timeInfo}}export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{DateTimeReferenceFieldIndex as e}from"../../arcadeTimeUtils.js";import t from"./cache.js";import{FeatureSetError as s,FeatureSetErrorCodes as r}from"./errorsupport.js";import n from"./FeatureSetIterator.js";import i from"./IdSet.js";import{FeatureServiceDatabaseType as a,layerGeometryEsriConstants as l,IdState as u,convertSquareUnitsToCode as h,convertLinearUnitsToCode as c,esriFieldToJson as o,layerGeometryEsriRestConstants as d}from"./shared.js";import{max as _,min as p,sum as f,variance as g,stdev as m,mean as y,distinct as F,count as b}from"./stats.js";import{isPromiseLike as I}from"../../../core/promiseUtils.js";import{WhereClause as w}from"../../../core/sql/WhereClause.js";import{union as S,geodesicArea as T,planarArea as P,geodesicLength as x,planarLength as k}from"../../../geometry/geometryEngineAsync.js";import D from"../../../geometry/SpatialReference.js";import C from"../../../layers/support/FieldsIndex.js";class v{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=a.NotEvaluated,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=[],this.typeIdField=null,this.types=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,this._dateFieldIndex=null,e&&e.lrucache&&(this.recentlyUsedQueries=e.lrucache),e&&e.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_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 D({wkid:4326}),this.geometryType=l.point)}getField(e,t){let s;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some((t=>(t&&t.name.toLowerCase()===e&&(s=t),!!s)))),s}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=new C(this.fields)),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new s(r.Cancelled)}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,s,r,n){return null!==this._parent&&this._parent._canDoAggregates(e,t,s,r,n)}async _getAggregatePagesDataSourceDefinition(e,t,n,i,a,l,u){if(null===this._parent)throw new s(r.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,t,n,i,a,l,u)}async _getAgregagtePhysicalPage(e,t,n){if(null===this._parent)throw new s(r.NeverReach);return this._parent._getAgregagtePhysicalPage(e,t,n)}async databaseType(){if(this._databaseType===a.NotEvaluated){if(null!==t.applicationCache){const e=t.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==e)return e}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==t.applicationCache&&t.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw null!==t.applicationCache&&t.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:a.SqlServer,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:a.Oracle,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:a.StandardisedNoInterval,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return a.StandardisedNoInterval}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new s(r.NotImplemented)}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return u.Unknown}_getSet(e){throw new s(r.NotImplemented)}async _getFeature(e,t,n){if(this._checkCancelled(n),void 0!==this._featureFromCache(t))return this._featureFromCache(t);if(await this._getFeatures(e,t,this._maxProcessingRate(),n),this._checkCancelled(n),void 0!==this._featureFromCache(t))return this._featureFromCache(t);throw new s(r.MissingFeatures)}async _getFeatureBatch(e,t){this._checkCancelled(t);const s=new i([],e,!1,null),r=[];await this._getFeatures(s,-1,e.length,t),this._checkCancelled(t);for(const n of e)void 0!==this._featureFromCache(n)&&r.push(this._featureFromCache(n));return r}async _getFeatures(e,t,s,r){return"success"}_getFilteredSet(e,t,n,i,a){throw new s(r.NotImplemented)}async _refineSetBlock(e,t,s){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,s),this._refineSetBlock(e,t,s);this._checkCancelled(s);const r=e._candidates.length;this._refineKnowns(e,t);let n=r-e._candidates.length;if(0===e._candidates.length)return e;if(n>=t)return e;if(await this._refineIfParentKnown(e,t-n,s),this._checkCancelled(s),this._refineKnowns(e,t-n),n=r-e._candidates.length,n<t&&e._candidates.length>0){const r=t-n,i=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(i,i.length>r?r:e._candidates.length,s),this._checkCancelled(s),this._refineKnowns(e,t-n),e}return e}_fetchAndRefineFeatures(e,t,s){return null}_prepareFetchAndRefineSet(e){const t=[];for(let s=0;s<e.length;s++)this._isPhysicalFeature(e[s])&&t.push(e[s]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let s=0,r=null;const n=[];t=this._maxQueryRate();for(let i=0;i<e._candidates.length&&"GETPAGES"!==e._candidates[i];i++){let a=!1;const l=this._candidateIdTransform(e._candidates[i]);l!==e._candidates[i]&&(a=!0);const h=this._isInFeatureSet(l);if(h===u.InFeatureSet)!0===a?e._known.includes(l)||(e._known.push(l),s+=1):(e._known.push(e._candidates[i]),s+=1),null===r?r={start:i,end:i}:r.end===i-1?r.end=i:(n.push(r),r={start:i,end:i});else if(h===u.NotInFeatureSet)null===r?r={start:i,end:i}:r.end===i-1?r.end=i:(n.push(r),r={start:i,end:i}),s+=1;else if(h===u.Unknown&&(s+=1,!0===e._ordered))break;if(s>=t)break}null!==r&&n.push(r);for(let i=n.length-1;i>=0;i--)e._candidates.splice(n[i].start,n[i].end-n[i].start+1)}_refineIfParentKnown(e,t,s){const r=new i([],[],e._ordered,null);return r._candidates=e._candidates.slice(0),this._parent._refineSetBlock(r,t,s)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let r=e._lastFetchedIndex;r<e._known.length;r++){if("GETPAGES"===e._known[r])return!0;if(void 0===this._featureCache[e._known[r]]&&(s+=1,s>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let r=0;r<e._candidates.length;r++){if("GETPAGES"===e._candidates[r])return!0;if(s+=1,s>=t)break}return!1}async _expandPagedSet(e,t,n,i,a){if(null===this._parent)throw new s(r.NotImplemented);return this._parent._expandPagedSet(e,t,n,i,a)}async _expandPagedSetFeatureSet(e,t,s,r,n){if(e._known.length>0&&"GETPAGES"===e._known.at(-1)&&(r=1),0===r&&e._candidates.length>0&&"GETPAGES"===e._candidates.at(-1)&&(r=2),0===r)return"finished";const i=await this._getPage(e,r,n);return s+i<t?this._expandPagedSet(e,t,s+i,0,n):"success"}async _getPage(e,t,s){const r=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){r.length=r.length-1;let t=0;for(let n=0;n<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+n>=e.pagesDefinition.internal.set.length);n++)r[r.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+n],t++;e.pagesDefinition.resultOffset+=t;let s=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(s=!0),!1===s&&r.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,s),this._getPage(e,t,s)}_getPhysicalPage(e,t,s){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,s,r){await this._ensureLoaded();let n=await this._stat(e,t,"",null,null,s,r);return!1===n.calculated&&(n=await this._manualStat(e,t,s,r)),n.result}async _manualStat(e,t,s,r){let n=null;switch(e.toLowerCase()){case"count":return n=await b(this,r),{calculated:!0,result:n};case"distinct":return n=await F(this,t,s,r),{calculated:!0,result:n};case"avg":case"mean":return n=await y(this,t,r),{calculated:!0,result:n};case"stdev":return n=await m(this,t,r),{calculated:!0,result:n};case"variance":return n=await g(this,t,r),{calculated:!0,result:n};case"sum":return n=await f(this,t,r),{calculated:!0,result:n};case"min":return n=await p(this,t,r),{calculated:!0,result:n};case"max":return n=await _(this,t,r),{calculated:!0,result:n};default:return{calculated:!0,result:0}}}async _stat(e,t,s,r,n,i,a){const l=await this._parent._stat(e,t,s,r,n,i,a);return!1===l.calculated?null===n&&""===s&&null===r?this._manualStat(e,t,i,a):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),s=[];return new Promise(((e,r)=>{this._unionShapeInBatches(s,t,e,r)}))}_unionAllGeom(e){return new Promise(((t,s)=>{const r=this.iterator(this._defaultTracker(e)),n=[];this._unionShapeInBatches(n,r,t,s)}))}_unionShapeInBatches(e,t,s,r){t.next().then((n=>{try{null!==n&&null!==n.geometry&&e.push(n.geometry),e.length>30||null===n&&e.length>1?S(e).then((i=>{try{null===n?s(i):(e=[i],this._unionShapeInBatches(e,t,s,r))}catch(a){r(a)}}),r):null===n?1===e.length?s(e[0]):s(null):this._unionShapeInBatches(e,t,s,r)}catch(i){r(i)}}),r)}iterator(e){return new n(this,e)}intersection(e,t=!1){return v._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,s=!0){return v._featuresetFunctions.difference.bind(this)(e,t,s)}symmetricDifference(e,t=!1,s=!0){return v._featuresetFunctions.symmetricDifference.bind(this)(e,t,s)}morphShape(e,t,s="unknown",r=null){return v._featuresetFunctions.morphShape.bind(this)(e,t,s,r)}morphShapeAndAttributes(e,t,s="unknown"){return v._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,s)}union(e,t=!1){return v._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return v._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return v._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return v._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return v._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return v._featuresetFunctions.relate.bind(this)(e,t)}within(e){return v._featuresetFunctions.within.bind(this)(e)}touches(e){return v._featuresetFunctions.touches.bind(this)(e)}top(e){return v._featuresetFunctions.top.bind(this)(e)}crosses(e){return v._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,s,r=!0){return v._featuresetFunctions.buffer.bind(this)(e,t,s,r)}filter(e,t=null){return v._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return v._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return v._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return v._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,s){return new Promise(((r,n)=>{this._reduceImpl(this.iterator(this._defaultTracker(s)),e,t,0,r,n,0)}))}_reduceImpl(e,t,s,r,n,i,a){try{if(++a>1e3)return void setTimeout((()=>{a=0,this._reduceImpl(e,t,s,r,n,i,a)}));e.next().then((l=>{try{if(null===l)n(s);else{const u=t(s,l,r,this);I(u)?u.then((s=>{this._reduceImpl(e,t,s,r+1,n,i,a)}),i):this._reduceImpl(e,t,u,r+1,n,i,a)}}catch(u){i(u)}}),i)}catch(l){i(l)}}removeField(e){return v._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,s=null){return v._featuresetFunctions.addField.bind(this)(e,t,s)}sumArea(e,t=!1,s){const r=h(e);return this.reduce(((e,s)=>null===s.geometry?0:t?T(s.geometry,r).then((t=>e+t)):P(s.geometry,r).then((t=>e+t))),0,s)}sumLength(e,t=!1,s){const r=c(e);return this.reduce(((e,s)=>null===s.geometry?0:t?x(s.geometry,r).then((t=>e+t)):k(s.geometry,r).then((t=>e+t))),0,s)}_substituteVars(e,t){if(null!==t){const s={};for(const e in t)s[e.toLowerCase()]=t[e];e.parameters=s}}async distinct(e,t=1e3,s=null,r){await this.load();const n=w.create(e,this.getFieldsIndex());return this._substituteVars(n,s),this.calculateStatistic("distinct",n,t,this._defaultTracker(r))}async min(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("min",r,-1,this._defaultTracker(s))}async max(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("max",r,-1,this._defaultTracker(s))}async avg(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("avg",r,-1,this._defaultTracker(s))}async sum(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("sum",r,-1,this._defaultTracker(s))}async stdev(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("stdev",r,-1,this._defaultTracker(s))}async variance(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("variance",r,-1,this._defaultTracker(s))}async count(e){return await this.load(),this.calculateStatistic("count",w.create("1",this.getFieldsIndex()),-1,this._defaultTracker(e))}_defaultTracker(e){return e??{aborted:!1}}forEach(e,t){return new Promise(((s,r)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,s,r,0)}))}_forEachImpl(e,t,s,r,n,i){try{if(++i>1e3)return void setTimeout((()=>{i=0,this._forEachImpl(e,t,s,r,n,i)}),0);e.next().then((a=>{try{if(null===a)r(s);else{const l=t(a);null==l?this._forEachImpl(e,t,s,r,n,i):I(l)?l.then((()=>{try{this._forEachImpl(e,t,s,r,n,i)}catch(a){n(a)}}),n):this._forEachImpl(e,t,s,r,n,i)}}catch(l){n(l)}}),n)}catch(a){n(a)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let s=0;s<this.fields.length;s++)t.layerDefinition.fields.push(o(this.fields[s]));return this.reduce(((e,s)=>{const r={geometry:s.geometry&&s.geometry.toJSON(),attributes:{}};for(const t in s.attributes)r.attributes[t]=s.attributes[t];return t.featureSet.features.push(r),1}),0,e).then((()=>t))}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,s,r,n){return this._parent.queryAttachments(e,t,s,r,n)}serviceUrl(){return this._parent.serviceUrl()}subtypes(){return this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map((e=>({name:e.name,code:e.id}))):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(o(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===d[this.geometryType]?"esriGeometryNull":d[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce(((t,s)=>{const r={geometry:s.geometry?s.geometry.toJSON():null,attributes:s.attributes};return null!==r.geometry&&r.geometry.spatialReference&&delete r.geometry.spatialReference,e.push(r),1}),0,t);const s=this.schema();return s.features=e,s.spatialReference=this.spatialReference.toJSON(),JSON.stringify(s)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const s=[];await this.reduce(((e,r)=>{const n={geometry:r.geometry?!0===t?.keepGeometryType?r.geometry:r.geometry.toJSON():null,attributes:r.attributes};return null!==n.geometry&&n.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete n.geometry.spatialReference,s.push(n),1}),0,e);const r=this.schema();return r.features=s,r.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),r}get dateTimeReferenceFieldIndex(){return null===this._dateFieldIndex&&(this._dateFieldIndex=e.create(this.getFieldsIndex(),this)),this._dateFieldIndex}fieldTimeZone(e){return this.dateTimeReferenceFieldIndex.fieldTimeZone(e)}get preferredTimeReference(){return this._parent?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._parent?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}}v._featuresetFunctions={};export{v as default};
|
|
5
|
+
import{DateTimeReferenceFieldIndex as e}from"../../arcadeTimeUtils.js";import t from"./cache.js";import{FeatureSetError as s,FeatureSetErrorCodes as r}from"./errorsupport.js";import n from"./FeatureSetIterator.js";import i from"./IdSet.js";import{FeatureServiceDatabaseType as a,layerGeometryEsriConstants as l,IdState as u,convertSquareUnitsToCode as h,convertLinearUnitsToCode as c,esriFieldToJson as o,layerGeometryEsriRestConstants as d}from"./shared.js";import{max as _,min as p,sum as f,variance as g,stdev as m,mean as y,distinct as F,count as b}from"./stats.js";import{isPromiseLike as I}from"../../../core/promiseUtils.js";import{WhereClause as w}from"../../../core/sql/WhereClause.js";import{union as S,geodesicArea as T,planarArea as P,geodesicLength as x,planarLength as k}from"../../../geometry/geometryEngineAsync.js";import D from"../../../geometry/SpatialReference.js";import C from"../../../layers/support/FieldsIndex.js";class v{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=a.NotEvaluated,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=[],this.typeIdField=null,this.types=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,this._dateFieldIndex=null,e&&e.lrucache&&(this.recentlyUsedQueries=e.lrucache),e&&e.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_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 D({wkid:4326}),this.geometryType=l.point)}getField(e,t){let s;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some((t=>(t&&t.name.toLowerCase()===e&&(s=t),!!s)))),s}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=new C(this.fields)),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new s(r.Cancelled)}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,s,r,n){return null!==this._parent&&this._parent._canDoAggregates(e,t,s,r,n)}async _getAggregatePagesDataSourceDefinition(e,t,n,i,a,l,u){if(null===this._parent)throw new s(r.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,t,n,i,a,l,u)}async _getAgregagtePhysicalPage(e,t,n){if(null===this._parent)throw new s(r.NeverReach);return this._parent._getAgregagtePhysicalPage(e,t,n)}async databaseType(){if(this._databaseType===a.NotEvaluated){if(null!==t.applicationCache){const e=t.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==e)return e}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==t.applicationCache&&t.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw null!==t.applicationCache&&t.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:a.SqlServer,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:a.Oracle,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:a.StandardisedNoInterval,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return a.StandardisedNoInterval}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new s(r.NotImplemented)}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return u.Unknown}_getSet(e){throw new s(r.NotImplemented)}async _getFeature(e,t,n){if(this._checkCancelled(n),void 0!==this._featureFromCache(t))return this._featureFromCache(t);if(await this._getFeatures(e,t,this._maxProcessingRate(),n),this._checkCancelled(n),void 0!==this._featureFromCache(t))return this._featureFromCache(t);throw new s(r.MissingFeatures)}async _getFeatureBatch(e,t){this._checkCancelled(t);const s=new i([],e,!1,null),r=[];await this._getFeatures(s,-1,e.length,t),this._checkCancelled(t);for(const n of e)void 0!==this._featureFromCache(n)&&r.push(this._featureFromCache(n));return r}async _getFeatures(e,t,s,r){return"success"}_getFilteredSet(e,t,n,i,a){throw new s(r.NotImplemented)}async _refineSetBlock(e,t,s){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,s),this._refineSetBlock(e,t,s);this._checkCancelled(s);const r=e._candidates.length;this._refineKnowns(e,t);let n=r-e._candidates.length;if(0===e._candidates.length)return e;if(n>=t)return e;if(await this._refineIfParentKnown(e,t-n,s),this._checkCancelled(s),this._refineKnowns(e,t-n),n=r-e._candidates.length,n<t&&e._candidates.length>0){const r=t-n,i=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(i,i.length>r?r:e._candidates.length,s),this._checkCancelled(s),this._refineKnowns(e,t-n),e}return e}_fetchAndRefineFeatures(e,t,s){return null}_prepareFetchAndRefineSet(e){const t=[];for(let s=0;s<e.length;s++)this._isPhysicalFeature(e[s])&&t.push(e[s]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let s=0,r=null;const n=[];t=this._maxQueryRate();for(let i=0;i<e._candidates.length&&"GETPAGES"!==e._candidates[i];i++){let a=!1;const l=this._candidateIdTransform(e._candidates[i]);l!==e._candidates[i]&&(a=!0);const h=this._isInFeatureSet(l);if(h===u.InFeatureSet)!0===a?e._known.includes(l)||(e._known.push(l),s+=1):(e._known.push(e._candidates[i]),s+=1),null===r?r={start:i,end:i}:r.end===i-1?r.end=i:(n.push(r),r={start:i,end:i});else if(h===u.NotInFeatureSet)null===r?r={start:i,end:i}:r.end===i-1?r.end=i:(n.push(r),r={start:i,end:i}),s+=1;else if(h===u.Unknown&&(s+=1,!0===e._ordered))break;if(s>=t)break}null!==r&&n.push(r);for(let i=n.length-1;i>=0;i--)e._candidates.splice(n[i].start,n[i].end-n[i].start+1)}_refineIfParentKnown(e,t,s){const r=new i([],[],e._ordered,null);return r._candidates=e._candidates.slice(0),this._parent._refineSetBlock(r,t,s)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let r=e._lastFetchedIndex;r<e._known.length;r++){if("GETPAGES"===e._known[r])return!0;if(void 0===this._featureCache[e._known[r]]&&(s+=1,s>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let r=0;r<e._candidates.length;r++){if("GETPAGES"===e._candidates[r])return!0;if(s+=1,s>=t)break}return!1}async _expandPagedSet(e,t,n,i,a){if(null===this._parent)throw new s(r.NotImplemented);return this._parent._expandPagedSet(e,t,n,i,a)}async _expandPagedSetFeatureSet(e,t,s,r,n){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(r=1),0===r&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(r=2),0===r)return"finished";const i=await this._getPage(e,r,n);return s+i<t?this._expandPagedSet(e,t,s+i,0,n):"success"}async _getPage(e,t,s){const r=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){r.length=r.length-1;let t=0;for(let n=0;n<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+n>=e.pagesDefinition.internal.set.length);n++)r[r.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+n],t++;e.pagesDefinition.resultOffset+=t;let s=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(s=!0),!1===s&&r.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,s),this._getPage(e,t,s)}_getPhysicalPage(e,t,s){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,s,r){await this._ensureLoaded();let n=await this._stat(e,t,"",null,null,s,r);return!1===n.calculated&&(n=await this._manualStat(e,t,s,r)),n.result}async _manualStat(e,t,s,r){let n=null;switch(e.toLowerCase()){case"count":return n=await b(this,r),{calculated:!0,result:n};case"distinct":return n=await F(this,t,s,r),{calculated:!0,result:n};case"avg":case"mean":return n=await y(this,t,r),{calculated:!0,result:n};case"stdev":return n=await m(this,t,r),{calculated:!0,result:n};case"variance":return n=await g(this,t,r),{calculated:!0,result:n};case"sum":return n=await f(this,t,r),{calculated:!0,result:n};case"min":return n=await p(this,t,r),{calculated:!0,result:n};case"max":return n=await _(this,t,r),{calculated:!0,result:n};default:return{calculated:!0,result:0}}}async _stat(e,t,s,r,n,i,a){const l=await this._parent._stat(e,t,s,r,n,i,a);return!1===l.calculated?null===n&&""===s&&null===r?this._manualStat(e,t,i,a):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),s=[];return new Promise(((e,r)=>{this._unionShapeInBatches(s,t,e,r)}))}_unionAllGeom(e){return new Promise(((t,s)=>{const r=this.iterator(this._defaultTracker(e)),n=[];this._unionShapeInBatches(n,r,t,s)}))}_unionShapeInBatches(e,t,s,r){t.next().then((n=>{try{null!==n&&null!==n.geometry&&e.push(n.geometry),e.length>30||null===n&&e.length>1?S(e).then((i=>{try{null===n?s(i):(e=[i],this._unionShapeInBatches(e,t,s,r))}catch(a){r(a)}}),r):null===n?1===e.length?s(e[0]):s(null):this._unionShapeInBatches(e,t,s,r)}catch(i){r(i)}}),r)}iterator(e){return new n(this,e)}intersection(e,t=!1){return v._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,s=!0){return v._featuresetFunctions.difference.bind(this)(e,t,s)}symmetricDifference(e,t=!1,s=!0){return v._featuresetFunctions.symmetricDifference.bind(this)(e,t,s)}morphShape(e,t,s="unknown",r=null){return v._featuresetFunctions.morphShape.bind(this)(e,t,s,r)}morphShapeAndAttributes(e,t,s="unknown"){return v._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,s)}union(e,t=!1){return v._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return v._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return v._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return v._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return v._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return v._featuresetFunctions.relate.bind(this)(e,t)}within(e){return v._featuresetFunctions.within.bind(this)(e)}touches(e){return v._featuresetFunctions.touches.bind(this)(e)}top(e){return v._featuresetFunctions.top.bind(this)(e)}crosses(e){return v._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,s,r=!0){return v._featuresetFunctions.buffer.bind(this)(e,t,s,r)}filter(e,t=null){return v._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return v._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return v._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return v._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,s){return new Promise(((r,n)=>{this._reduceImpl(this.iterator(this._defaultTracker(s)),e,t,0,r,n,0)}))}_reduceImpl(e,t,s,r,n,i,a){try{if(++a>1e3)return void setTimeout((()=>{a=0,this._reduceImpl(e,t,s,r,n,i,a)}));e.next().then((l=>{try{if(null===l)n(s);else{const u=t(s,l,r,this);I(u)?u.then((s=>{this._reduceImpl(e,t,s,r+1,n,i,a)}),i):this._reduceImpl(e,t,u,r+1,n,i,a)}}catch(u){i(u)}}),i)}catch(l){i(l)}}removeField(e){return v._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,s=null){return v._featuresetFunctions.addField.bind(this)(e,t,s)}sumArea(e,t=!1,s){const r=h(e);return this.reduce(((e,s)=>null===s.geometry?0:t?T(s.geometry,r).then((t=>e+t)):P(s.geometry,r).then((t=>e+t))),0,s)}sumLength(e,t=!1,s){const r=c(e);return this.reduce(((e,s)=>null===s.geometry?0:t?x(s.geometry,r).then((t=>e+t)):k(s.geometry,r).then((t=>e+t))),0,s)}_substituteVars(e,t){if(null!==t){const s={};for(const e in t)s[e.toLowerCase()]=t[e];e.parameters=s}}async distinct(e,t=1e3,s=null,r){await this.load();const n=w.create(e,this.getFieldsIndex());return this._substituteVars(n,s),this.calculateStatistic("distinct",n,t,this._defaultTracker(r))}async min(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("min",r,-1,this._defaultTracker(s))}async max(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("max",r,-1,this._defaultTracker(s))}async avg(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("avg",r,-1,this._defaultTracker(s))}async sum(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("sum",r,-1,this._defaultTracker(s))}async stdev(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("stdev",r,-1,this._defaultTracker(s))}async variance(e,t=null,s){await this.load();const r=w.create(e,this.getFieldsIndex());return this._substituteVars(r,t),this.calculateStatistic("variance",r,-1,this._defaultTracker(s))}async count(e){return await this.load(),this.calculateStatistic("count",w.create("1",this.getFieldsIndex()),-1,this._defaultTracker(e))}_defaultTracker(e){return e??{aborted:!1}}forEach(e,t){return new Promise(((s,r)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,s,r,0)}))}_forEachImpl(e,t,s,r,n,i){try{if(++i>1e3)return void setTimeout((()=>{i=0,this._forEachImpl(e,t,s,r,n,i)}),0);e.next().then((a=>{try{if(null===a)r(s);else{const l=t(a);null==l?this._forEachImpl(e,t,s,r,n,i):I(l)?l.then((()=>{try{this._forEachImpl(e,t,s,r,n,i)}catch(a){n(a)}}),n):this._forEachImpl(e,t,s,r,n,i)}}catch(l){n(l)}}),n)}catch(a){n(a)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let s=0;s<this.fields.length;s++)t.layerDefinition.fields.push(o(this.fields[s]));return this.reduce(((e,s)=>{const r={geometry:s.geometry&&s.geometry.toJSON(),attributes:{}};for(const t in s.attributes)r.attributes[t]=s.attributes[t];return t.featureSet.features.push(r),1}),0,e).then((()=>t))}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,s,r,n){return this._parent.queryAttachments(e,t,s,r,n)}serviceUrl(){return this._parent.serviceUrl()}subtypes(){return this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map((e=>({name:e.name,code:e.id}))):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(o(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===d[this.geometryType]?"esriGeometryNull":d[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce(((t,s)=>{const r={geometry:s.geometry?s.geometry.toJSON():null,attributes:s.attributes};return null!==r.geometry&&r.geometry.spatialReference&&delete r.geometry.spatialReference,e.push(r),1}),0,t);const s=this.schema();return s.features=e,s.spatialReference=this.spatialReference.toJSON(),JSON.stringify(s)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const s=[];await this.reduce(((e,r)=>{const n={geometry:r.geometry?!0===t?.keepGeometryType?r.geometry:r.geometry.toJSON():null,attributes:r.attributes};return null!==n.geometry&&n.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete n.geometry.spatialReference,s.push(n),1}),0,e);const r=this.schema();return r.features=s,r.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),r}get dateTimeReferenceFieldIndex(){return null===this._dateFieldIndex&&(this._dateFieldIndex=e.create(this.getFieldsIndex(),this)),this._dateFieldIndex}fieldTimeZone(e){return this.dateTimeReferenceFieldIndex.fieldTimeZone(e)}get preferredTimeReference(){return this._parent?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._parent?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}}v._featuresetFunctions={};export{v as default};
|