@arcgis/core 4.30.0-next.20240306 → 4.30.0-next.20240308
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/ImmutablePointArray.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/1ed6fba0d188f845eaa6.js +1 -0
- package/assets/esri/core/workers/chunks/1fdbeb110fae52b96bb3.js +1 -0
- package/assets/esri/core/workers/chunks/2a612d51c7be754dacaa.js +1 -0
- package/assets/esri/core/workers/chunks/{f049d8c298f85dc03cd6.js → 36d697a3788b86f24588.js} +1 -1
- package/assets/esri/core/workers/chunks/{a308386b651aec19fa3f.js → 49a715520999bbfab18d.js} +3 -3
- package/assets/esri/core/workers/chunks/50a7742a7e7f7eda5bee.js +1 -0
- package/assets/esri/core/workers/chunks/5c2091816c6c3f630c90.js +1 -0
- package/assets/esri/core/workers/chunks/5f5f6bba98e5671e63a7.js +1 -0
- package/assets/esri/core/workers/chunks/61d903fe9200dced54df.js +1 -0
- package/assets/esri/core/workers/chunks/{c6abfebe20b0ad14ea95.js → 6b6bbd969d21282b9936.js} +1 -1
- package/assets/esri/core/workers/chunks/6b817d4b7ea08db6bfd6.js +1 -0
- package/assets/esri/core/workers/chunks/6d34b96d73916fb237ba.js +1 -0
- package/assets/esri/core/workers/chunks/7025dd8bf67178d7d9bc.js +1 -0
- package/assets/esri/core/workers/chunks/7a3a6bb83b03bbb3e1dc.js +1 -0
- package/assets/esri/core/workers/chunks/7a5e8eb8ea826864c7da.js +1 -0
- package/assets/esri/core/workers/chunks/{b000bf41ff12604e7289.js → 7bba67d345da6eced804.js} +1 -1
- package/assets/esri/core/workers/chunks/86143534b2e35ede6819.js +1 -0
- package/assets/esri/core/workers/chunks/86fe8077986a991f0462.js +1 -0
- package/assets/esri/core/workers/chunks/87c30b4dee17b4a1ecb5.js +1 -0
- package/assets/esri/core/workers/chunks/8b4304f47c6f060f793f.js +1 -0
- package/assets/esri/core/workers/chunks/8be0df498101438ff671.js +1 -0
- package/assets/esri/core/workers/chunks/92fc6c48ff9f50a7351a.js +1 -0
- package/assets/esri/core/workers/chunks/955d7a0c8b2cdabfa8a3.js +1 -0
- package/assets/esri/core/workers/chunks/9fd907dad340454fb585.js +1 -0
- package/assets/esri/core/workers/chunks/a1a557cbfb0aa915f81b.js +1 -0
- package/assets/esri/core/workers/chunks/{2efa03419327da7e0537.js → ab2d4f6595abdefcc71f.js} +1 -1
- package/assets/esri/core/workers/chunks/{c81cf406eec1692341e6.js → be10d0b4ad5c0b4a1b2e.js} +1 -1
- package/assets/esri/core/workers/chunks/bf041907bac8fae05c2b.js +1 -0
- package/assets/esri/core/workers/chunks/c2573c1cb7c714435acc.js +1 -0
- package/assets/esri/core/workers/chunks/d518a0adc3d88700235c.js +1 -0
- package/assets/esri/core/workers/chunks/dccf636a7dfc548bcd75.js +1 -0
- package/assets/esri/core/workers/chunks/{6cd73a2b9a4bac467ab5.js → ef19c4fabc3682fc7aa7.js} +1 -1
- package/assets/esri/core/workers/chunks/{7adbddf4b029b7db8c59.js → f67f61afded4f4e21821.js} +1 -1
- package/assets/esri/core/workers/chunks/f8dd749722ebb731d5f5.js +1 -0
- package/assets/esri/core/workers/chunks/fc2a12f9e4068ab89628.js +1 -0
- package/assets/esri/themes/base/widgets/_ElevationProfile.scss +15 -17
- package/assets/esri/themes/base/widgets/_LayerList.scss +2 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/core/Handles.js +1 -1
- package/core/Logger.js +1 -1
- package/core/MemCachePool.js +1 -1
- package/core/accessorSupport/decorators/subclass.js +1 -1
- package/core/jsonMap.js +1 -1
- package/core/libs/rbush/PooledRBush.js +1 -1
- package/core/sql.js +1 -1
- package/core/workers/InvokeHandler.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/core/workers/utils.js +1 -1
- package/geometry/Extent.js +1 -1
- package/geometry/support/MeshTexture.js +1 -1
- package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/glb.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/normalizeUtilsSync.js +1 -1
- package/interfaces.d.ts +72 -36
- package/layers/CatalogLayer.js +1 -1
- package/layers/catalog/CatalogFootprintLayer.js +1 -1
- package/layers/mixins/operationalLayers.js +1 -1
- package/layers/support/layersCreator.js +1 -1
- package/layers/support/lazyLayerLoader.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/rest/geoprocessor/execute.js +1 -1
- package/rest/geoprocessor/utils.js +1 -1
- package/rest/support/ParameterValue.js +1 -1
- package/rest/support/parameterValueUtils.js +5 -0
- package/smartMapping/renderers/size.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
- package/views/2d/layers/features/RenderState.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/Tile.js +1 -1
- package/views/2d/tiling/TileInfoView.js +1 -1
- package/views/3d/analysis/support/measurementUtils.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/input/handlers/DoubleClickZoom.js +1 -1
- package/views/3d/input/handlers/DragZoom.js +1 -1
- package/views/3d/input/handlers/MouseWheelZoom.js +1 -1
- package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +5 -0
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +5 -0
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +5 -0
- package/views/3d/state/controllers/ZoomControllerLocal.js +5 -0
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +5 -0
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +5 -0
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/terrain/PlanarPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +5 -0
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/LayerList/support/layerListUtils.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/00e54a698b8d8e0a4382.js +0 -1
- package/assets/esri/core/workers/chunks/00fa710b00eb50dd1443.js +0 -1
- package/assets/esri/core/workers/chunks/06de26b02dd75acc53e0.js +0 -1
- package/assets/esri/core/workers/chunks/0e13fd6b4da900dcb554.js +0 -1
- package/assets/esri/core/workers/chunks/1acc9b4663aeaa94441b.js +0 -1
- package/assets/esri/core/workers/chunks/35effdb3c6d4826e166e.js +0 -1
- package/assets/esri/core/workers/chunks/45406d46a14b3c8725bc.js +0 -1
- package/assets/esri/core/workers/chunks/4819b528190eac9ad5cb.js +0 -1
- package/assets/esri/core/workers/chunks/50fa4d4f287a86bd66ac.js +0 -1
- package/assets/esri/core/workers/chunks/6e25f4bc41eda2dada52.js +0 -1
- package/assets/esri/core/workers/chunks/6f8d259cc142a4ff4e36.js +0 -1
- package/assets/esri/core/workers/chunks/7252dd932813451b5327.js +0 -1
- package/assets/esri/core/workers/chunks/7b81221826357c208a3c.js +0 -1
- package/assets/esri/core/workers/chunks/7fc045104f232f7db0b6.js +0 -1
- package/assets/esri/core/workers/chunks/83bb6868a462ca3aab7d.js +0 -1
- package/assets/esri/core/workers/chunks/907d8b9a7c81dc6dc580.js +0 -1
- package/assets/esri/core/workers/chunks/96dc9f1ac35f2146329f.js +0 -1
- package/assets/esri/core/workers/chunks/b3c42a7a83e5f09b1bbe.js +0 -1
- package/assets/esri/core/workers/chunks/bbf7007cdea13a334ff5.js +0 -1
- package/assets/esri/core/workers/chunks/bdd13e94d2ffd3bb6c88.js +0 -1
- package/assets/esri/core/workers/chunks/c08640bd1953dd3a860b.js +0 -1
- package/assets/esri/core/workers/chunks/cd6092a375f5689fe6c3.js +0 -1
- package/assets/esri/core/workers/chunks/da86d3743a279da8668f.js +0 -1
- package/assets/esri/core/workers/chunks/dda558c834bf9f493f94.js +0 -1
- package/assets/esri/core/workers/chunks/e4992aa9c2094a4408d4.js +0 -1
- package/assets/esri/core/workers/chunks/e9716d84711c84c82ee2.js +0 -1
- package/assets/esri/core/workers/chunks/ec9211e8bb5fbfd93453.js +0 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +0 -5
- package/views/3d/state/controllers/global/ZoomController.js +0 -5
- package/views/3d/state/controllers/global/ZoomStepController.js +0 -5
- package/views/3d/state/controllers/local/PinchAndPanController.js +0 -5
- package/views/3d/state/controllers/local/ZoomController.js +0 -5
- package/views/3d/state/controllers/local/ZoomStepController.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import r from"../../core/Logger.js";import{isHostedAgolService as e}from"../../layers/support/arcgisLayerUrl.js";import{registerLoader as o}from"../../layers/support/schemaValidatorLoader.js";import{schemaValidationErrorName as t}from"../../support/webSceneUtils.js";import{renderSVG as n}from"../../symbols/support/svgUtils.js";import{viewingModeFromString as s}from"../../views/ViewingMode.js";import{
|
|
5
|
+
import r from"../../core/Logger.js";import{isHostedAgolService as e}from"../../layers/support/arcgisLayerUrl.js";import{registerLoader as o}from"../../layers/support/schemaValidatorLoader.js";import{schemaValidationErrorName as t}from"../../support/webSceneUtils.js";import{renderSVG as n}from"../../symbols/support/svgUtils.js";import{viewingModeFromString as s}from"../../views/ViewingMode.js";import{ZoomControllerGlobal as i}from"../../views/3d/state/controllers/ZoomControllerGlobal.js";import{ZoomControllerLocal as a}from"../../views/3d/state/controllers/ZoomControllerLocal.js";import{TilingScheme as p}from"../../views/3d/terrain/TilingScheme.js";import{isSpatialReferenceSupported as u}from"../../views/support/spatialReferenceSupport.js";import{registerLoader as c}from"../../webscene/support/schemaValidatorLoader.js";function m(r){return r.back()}function l(r){return r.hasPendingEdits}function f(e,o){return r.getLogger("sceneViewer.appState.saveState").warn(e,o)}function d(r){return e(r)}function g(r,e,o,t){return n(r,e,o,t)}function j(r){return!r.canNotSaveAs()}function w(r,e){return u(r,s(e))}function S(r,e){return r.getCompatibleForVTL(e)}function v(r){return new p(r)}function L(r){return null==p.checkUnsupported(r)}function V(){o((()=>import("../../layers/support/schemaValidator.js"))),c((()=>import("../../webscene/support/schemaValidator.js")))}function b(r){return r&&r.name===t}function h(r){const e=r.state.cameraController;return e instanceof i||e instanceof a?e.dragBeginPoint:null}export{j as canSaveAs,v as createTilingScheme,l as editorHasPendingEdits,m as editorNavigateBack,S as getCompatibleTileInfoForVTL,V as initializeSchemaValidators,d as isHostedAgolServiceUrl,b as isSchemaValidationError,w as isSpatialReferenceSupported,L as isSupportedTileInfo,g as renderSVG,f as saveStateWarning,h as zoomDragBeginPoint};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"./ImmutableArray.js";import s from"../geometry/Point.js";class i extends t{constructor(t,s,i,e,h,a){super(t),this._lazyPt=[],this._hasZ=!1,this._hasM=!1,this._spRef=s,this._hasZ=i,this._hasM=e,this._cacheId=h,this._partId=a}get(t){if(void 0===this._lazyPt[t]){const i=this._elements[t];if(void 0===i)return;const e=this._hasZ,h=this._hasM;let a
|
|
5
|
+
import t from"./ImmutableArray.js";import s from"../geometry/Point.js";class i extends t{constructor(t,s,i,e,h,a){super(t),this._lazyPt=[],this._hasZ=!1,this._hasM=!1,this._spRef=s,this._hasZ=i,this._hasM=e,this._cacheId=h,this._partId=a}get(t){if(void 0===this._lazyPt[t]){const i=this._elements[t];if(void 0===i)return;const e=this._hasZ,h=this._hasM;let a;a=e&&!h?new s(i[0],i[1],i[2],void 0,this._spRef):h&&!e?new s(i[0],i[1],void 0,i[2],this._spRef):e&&h?new s(i[0],i[1],i[2],i[3],this._spRef):new s(i[0],i[1],this._spRef),a.cache._arcadeCacheId=this._cacheId.toString()+"-"+this._partId.toString()+"-"+t.toString(),this._lazyPt[t]=a}return this._lazyPt[t]}equalityTest(t){return t===this||null!==t&&(t instanceof i!=!1&&t.getUniqueHash()===this.getUniqueHash())}getUniqueHash(){return this._cacheId.toString()+"-"+this._partId.toString()}}export{i as default};
|
package/arcade/arcadeRuntime.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import n from"./Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as o,ensureArcadeExecutionError as l}from"./executionError.js";import i from"./Feature.js";import{NativeFunction as a,ArcadeFunction as s,ScopeMarshalledFunction as c,wrapModuleScopedResponse as u}from"./FunctionWrapper.js";import{H as f,a as p,q as d,o as h,r as w,c as m,b as g,F as v,D as y,C as b,B as x,i as S,z as F,g as I,A as C,j as R,E as A,G as M,x as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as L}from"./treeAnalysis.js";import{A as N}from"../chunks/array.js";import{registerFunctions as O}from"./functions/date.js";import{registerFunctions as B,geometryMember as k}from"./functions/geometry.js";import{registerFunctions as j}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as K}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import q from"../geometry/Geometry.js";import G from"../geometry/SpatialReference.js";class Z extends s{constructor(e,t){super(),this.definition=null,this.context=null,this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,null);return Fe(this.definition,n,t,null)}}call(e,t){return W(e,t,((n,l,i)=>{const a={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(a.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,t);return Fe(this.definition,a,i,t)}))}marshalledCall(e,t,n,r){return r(e,t,((o,l,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!S(t)||t instanceof c?t:u(t,e,r))),u(Fe(this.definition,a,i,t),n,r)}))}}class P extends e{constructor(e){super(e)}global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=V(this.executingContext,t.node),t.valueset=!0),S(t.value)&&!(t.value instanceof c)){const e=new c;e.fn=t.value,e.parameterEvaluator=W,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(S(t))throw new r(null,o.AssignModuleFunction,null);this.executingContext.globalScope[e.toLowerCase()]={value:t,valueset:!0,node:null}}hasGlobal(e){return void 0===this.executingContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.executingContext.exports[e]}loadModule(e){let n=e.spatialReference;null==n&&(n=new G({wkid:102100})),this.moduleScope=Ce({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:n,globalScope:this.moduleScope,localScope:null,libraryResolver:new t(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ae,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},V(this.executingContext,this.source.syntax)}}function T(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(V(e,t.arguments[r]));return n}function W(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,T(e,t))}catch(r){throw r}}function V(e,t){try{switch(t?.type){case"EmptyStatement":return x;case"VariableDeclarator":return ce(e,t);case"VariableDeclaration":return se(e,t);case"ImportDeclaration":return ie(e,t);case"ExportNamedDeclaration":return ae(e,t);case"BlockStatement":case"Program":return re(e,t);case"FunctionDeclaration":return le(e,t);case"ReturnStatement":return oe(e,t);case"IfStatement":return ne(e,t);case"ExpressionStatement":return te(e,t);case"AssignmentExpression":return ee(e,t);case"UpdateExpression":return X(e,t);case"BreakStatement":return b;case"ContinueStatement":return y;case"TemplateElement":return we(e,t);case"TemplateLiteral":return ge(e,t);case"ForStatement":return Y(e,t);case"ForInStatement":return H(e,t);case"WhileStatement":return J(e,t);case"Identifier":return ve(e,t);case"MemberExpression":return ue(e,t);case"Literal":return t.value;case"CallExpression":return ye(e,t);case"UnaryExpression":return fe(e,t);case"BinaryExpression":return de(e,t);case"LogicalExpression":return he(e,t);case"ArrayExpression":return pe(e,t);case"ObjectExpression":return _(e,t);case"Property":return z(e,t);default:throw new r(e,o.Unrecognized,t)}}catch(n){throw l(e,t,n)}}function _(e,t){const l={},i=new Map;for(let n=0;n<t.properties.length;n++){const a=V(e,t.properties[n]);if(S(a.value))throw new r(e,o.NoFunctionInDictionary,t);if(!1===m(a.key))throw new r(e,o.KeyMustBeString,t);let s=a.key.toString();const c=s.toLowerCase();i.has(c)?s=i.get(c):i.set(c,s),a.value===x?l[s]=null:l[s]=a.value}const a=new n(l);return a.immutable=!1,a}function z(e,t){return{key:"Identifier"===t.key.type?t.key.name:V(e,t.key),value:V(e,t.value)}}function H(e,t){const l=V(e,t.right);"VariableDeclaration"===t.left.type&&V(e,t.left);let i=null,a="";if("VariableDeclaration"===t.left.type){const e=t.left.declarations[0].id;"Identifier"===e.type&&(a=e.name)}else"Identifier"===t.left.type&&(a=t.left.name);if(!a)throw new r(e,o.InvalidIdentifier,t);if(a=a.toLowerCase(),null!=e.localScope&&void 0!==e.localScope[a]&&(i=e.localScope[a]),null===i&&void 0!==e.globalScope[a]&&(i=e.globalScope[a]),null===i)throw new r(e,o.InvalidIdentifier,t);if(h(l)||m(l)){const n=l.length;for(let r=0;r<n;r++){i.value=r;const n=V(e,t.body);if(n===b)break;if(n instanceof F)return n}return x}if(d(l)){for(let n=0;n<l.length();n++){i.value=n;const r=V(e,t.body);if(r===b)break;if(r instanceof F)return r}return x}if(!(l instanceof n||w(l)))return x;{const n=l.keys();for(let r=0;r<n.length;r++){i.value=n[r];const o=V(e,t.body);if(o===b)break;if(o instanceof F)return o}}}function Y(e,t){null!==t.init&&V(e,t.init);const n={testResult:!0,lastAction:x};do{Q(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof F?n.lastAction:x}function J(e,t){const n={testResult:!0,lastAction:x};if(n.testResult=V(e,t.test),!1===n.testResult)return x;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=V(e,t.body),n.lastAction!==b)&&!(n.lastAction instanceof F);)if(n.testResult=V(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return n.lastAction instanceof F?n.lastAction:x}function Q(e,t,n){if(null!==t.test){if(n.testResult=V(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t)}n.lastAction=V(e,t.body),n.lastAction!==b?n.lastAction instanceof F?n.testResult=!1:null!==t.update&&V(e,t.update):n.testResult=!1}function X(e,t){let l,i=null,a="";if("MemberExpression"===t.argument.type){if(i=V(e,t.argument.object),!0===t.argument.computed?a=V(e,t.argument.property):"Identifier"===t.argument.property.type&&(a=t.argument.property.name),h(i)){if(!g(a))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(a<0&&(a=i.length+a),a<0||a>=i.length)throw new r(e,o.OutOfBounds,t);l=I(i[a]),i[a]="++"===t.operator?l+1:l-1}else if(i instanceof n){if(!1===m(a))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new r(e,o.FieldNotFound,t);l=I(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else if(w(i)){if(!1===m(a))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new r(e,o.FieldNotFound,t);l=I(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else{if(d(i))throw new r(e,o.Immutable,t);if(!(i instanceof P))throw new r(e,o.InvalidParameter,t);if(!1===m(a))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==i.hasGlobal(a))throw new r(e,o.ModuleExportNotFound,t);l=I(i.global(a)),i.setGlobal(a,"++"===t.operator?l+1:l-1)}return!1===t.prefix?l:"++"===t.operator?l+1:l-1}if(i="Identifier"===t.argument.type?t.argument.name.toLowerCase():"",!i)throw new r(e,o.InvalidIdentifier,t);if(null!=e.localScope&&void 0!==e.localScope[i])return l=I(e.localScope[i].value),e.localScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;if(void 0!==e.globalScope[i])return l=I(e.globalScope[i].value),e.globalScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;throw new r(e,o.InvalidIdentifier,t)}function $(e,t,n,l,i){switch(t){case"=":return e===x?null:e;case"/=":return I(n)/I(e);case"*=":return I(n)*I(e);case"-=":return I(n)-I(e);case"+=":return m(n)||m(e)?R(n)+R(e):I(n)+I(e);case"%=":return I(n)%I(e);default:throw new r(i,o.UnsupportedOperator,l)}}function ee(e,t){let l=null,i="";if("MemberExpression"===t.left.type){if(l=V(e,t.left.object),!0===t.left.computed)i=V(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new r(e,o.InvalidIdentifier,t);i=t.left.property.name}const a=V(e,t.right);if(h(l)){if(!g(i))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(i<0&&(i=l.length+i),i<0||i>l.length)throw new r(e,o.OutOfBounds,t);if(i===l.length){if("="!==t.operator)throw new r(e,o.OutOfBounds,t);l[i]=$(a,t.operator,l[i],t,e)}else l[i]=$(a,t.operator,l[i],t,e)}else if(l instanceof n){if(!1===m(i))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else if(w(l)){if(!1===m(i))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else{if(d(l))throw new r(e,o.Immutable,t);if(!(l instanceof P))throw new r(e,o.InvalidIdentifier,t);if(!1===m(i))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==l.hasGlobal(i))throw new r(e,o.ModuleExportNotFound,t);l.setGlobal(i,$(a,t.operator,l.global(i),t,e))}return x}l=t.left.name.toLowerCase();const a=V(e,t.right);if(null!=e.localScope&&void 0!==e.localScope[l])return e.localScope[l]={value:$(a,t.operator,e.localScope[l].value,t,e),valueset:!0,node:t.right},x;if(void 0!==e.globalScope[l])return e.globalScope[l]={value:$(a,t.operator,e.globalScope[l].value,t,e),valueset:!0,node:t.right},x;throw new r(e,o.InvalidIdentifier,t)}function te(e,t){if("AssignmentExpression"===t.expression.type||"UpdateExpression"===t.expression.type)return V(e,t.expression);if("CallExpression"===t.expression.type){const n=V(e,t.expression);return n===x?x:new C(n)}{const n=V(e,t.expression);return n===x?x:new C(n)}}function ne(e,t){const n=V(e,t.test);if(!0===n)return V(e,t.consequent);if(!1===n)return null!==t.alternate?V(e,t.alternate):x;throw new r(e,o.BooleanConditionRequired,t)}function re(e,t){let n=x;for(let r=0;r<t.body.length;r++)if(n=V(e,t.body[r]),n instanceof F||n===b||n===y)return n;return n}function oe(e,t){if(null===t.argument)return new F(x);const n=V(e,t.argument);return new F(n)}function le(e,t){const n=t.id.name.toLowerCase();return e.globalScope[n]={valueset:!0,node:null,value:new Z(t,e)},x}function ie(e,t){const n=t.specifiers[0].local.name.toLowerCase(),r=e.libraryResolver.loadLibrary(n);let o=null;return e.libraryResolver._moduleSingletons?.has(r.uri)?o=e.libraryResolver._moduleSingletons.get(r.uri):(o=new P(r),o.loadModule(e),e.libraryResolver._moduleSingletons?.set(r.uri,o)),e.globalScope[n]={value:o,valueset:!0,node:t},x}function ae(e,t){if(V(e,t.declaration),"FunctionDeclaration"===t.declaration.type)e.exports[t.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===t.declaration.type)for(const n of t.declaration.declarations)e.exports[n.id.name.toLowerCase()]="variable";return x}function se(e,t){for(let n=0;n<t.declarations.length;n++)V(e,t.declarations[n]);return x}function ce(e,t){let n=null===t.init?null:V(e,t.init);if(n===x&&(n=null),"Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const l=t.id.name.toLowerCase();return null!=e.localScope?e.localScope[l]={value:n,valueset:!0,node:t.init}:e.globalScope[l]={value:n,valueset:!0,node:t.init},x}function ue(e,t){try{const l=V(e,t.object);if(null===l)throw new r(e,o.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(l instanceof n||w(l))return l.field(t.property.name);if(l instanceof q)return k(l,t.property.name,t,e);if(l instanceof P){if(!l.hasGlobal(t.property.name))throw new r(e,o.InvalidIdentifier,t);return l.global(t.property.name)}}throw new r(e,o.InvalidMemberAccessKey,t)}{let i=V(e,t.property);if(l instanceof n||w(l)){if(m(i))return l.field(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(l instanceof P){if(m(i))return l.global(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(l instanceof q){if(m(i))return k(l,i,t,e);throw new r(e,o.InvalidMemberAccessKey,t)}if(h(l)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new r(e,o.OutOfBounds,t);return l[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(m(l)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new r(e,o.OutOfBounds,t);return l[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(d(l)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length()+i),i>=l.length()||i<0)throw new r(e,o.OutOfBounds,t);return l.get(i)}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}}catch(l){throw l}}function fe(e,t){try{const n=V(e,t.argument);if(p(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*I(n);if("+"===t.operator)return 1*I(n);if("~"===t.operator)return~I(n);throw new r(e,o.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~I(n);if("-"===t.operator)return-1*I(n);if("+"===t.operator)return 1*I(n);throw new r(e,o.UnsupportedUnaryOperator,t)}catch(n){throw n}}function pe(e,t){try{const n=[];for(let l=0;l<t.elements.length;l++){const i=V(e,t.elements[l]);if(S(i))throw new r(e,o.NoFunctionInArray,t);i===x?n.push(null):n.push(i)}return n}catch(n){throw n}}function de(e,t){try{const n=[V(e,t.left),V(e,t.right)],l=n[0],i=n[1];switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(I(l),I(i),t.operator);case"==":return v(l,i);case"!=":return!v(l,i);case"<":case">":case"<=":case">=":return A(l,i,t.operator);case"+":return m(l)||m(i)?R(l)+R(i):I(l)+I(i);case"-":return I(l)-I(i);case"*":return I(l)*I(i);case"/":return I(l)/I(i);case"%":return I(l)%I(i);default:throw new r(e,o.UnsupportedOperator,t)}}catch(n){throw n}}function he(e,t){try{const n=V(e,t.left);if(p(n))switch(t.operator){case"||":if(!0===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new r(e,o.LogicExpressionOrAnd,t)}case"&&":if(!1===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new r(e,o.LogicExpressionOrAnd,t)}default:throw new r(e,o.LogicExpressionOrAnd,t)}throw new r(e,o.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function we(e,t){return t.value?t.value.cooked:""}function me(e,t,n){if(S(e))throw new r(t,o.NoFunctionInTemplateLiteral,n);return e}function ge(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?R(me(V(e,t.expressions[r]),e,t)):"",r++}return n}function ve(e,t){let n;try{const l=t.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[l])return n=e.localScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;if(void 0!==e.globalScope[l])return n=e.globalScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;throw new r(e,o.InvalidIdentifier,t)}catch(l){throw l}}function ye(e,t){try{if("MemberExpression"===t.callee.type){const n=V(e,t.callee.object);if(!(n instanceof P))throw new r(e,o.FunctionNotFound,t);const l=!1===t.callee.computed?t.callee.property.name:V(e,t.callee.property);if(!n.hasGlobal(l))throw new r(e,o.FunctionNotFound,t);const i=n.global(l);if(!S(i))throw new r(e,o.CallNonFunction,t);return i.call(e,t)}if("Identifier"!==t.callee.type)throw new r(e,o.FunctionNotFound,t);if(null!=e.localScope&&void 0!==e.localScope[t.callee.name.toLowerCase()]){const n=e.localScope[t.callee.name.toLowerCase()];if(S(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}if(void 0!==e.globalScope[t.callee.name.toLowerCase()]){const n=e.globalScope[t.callee.name.toLowerCase()];if(S(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}throw new r(e,o.FunctionNotFound,t)}catch(n){throw n}}const be={};function xe(e,t,n,r){try{const o=t.arguments,l=V(e,o[n]);if(v(l,r))return V(e,o[n+1]);{const l=o.length-n;return 1===l?V(e,o[n]):2===l?null:3===l?V(e,o[n+2]):xe(e,t,n+2,r)}}catch(o){throw o}}function Se(e,t,n,l){try{const i=t.arguments;if(!0===l)return V(e,i[n+1]);if(3===i.length-n)return V(e,i[n+2]);{const l=V(e,i[n+2]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,i[n+2]);return Se(e,t,n+2,l)}}catch(i){throw i}}function Fe(e,t,n,l){try{const i=e.body;if(n.length!==e.params.length)throw new r(t,o.WrongNumberOfParameters,l);if(null!=t.localScope)for(let r=0;r<n.length;r++)t.localScope[e.params[r].name.toLowerCase()]={value:n[r],valueset:!0,node:null};const a=V(t,i);if(a instanceof F)return a.value;if(a===b)throw new r(t,o.UnexpectedToken,l);if(a===y)throw new r(t,o.UnexpectedToken,l);return a instanceof C?a.value:a}catch(i){throw i}}O(be,W),U(be,W),D(be,W),B(be,W),K(be,W),j(be,W),be.iif=function(e,t){try{const n=t.arguments;f(null===n?[]:n,3,3,e,t);const l=V(e,n[0]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,t);return V(e,!0===l?n[1]:n[2])}catch(n){throw n}},be.defaultvalue=function(e,t){try{const l=t.arguments;f(null===l?[]:l,2,3,e,t);const i=V(e,l[0]);if(3===l.length){const a=V(e,l[1]);let s=[];if(d(a))s=a.toArray();else{if(!h(a))throw new r(e,o.InvalidParameter,t);s=a}let c=i;if(null===c)return V(e,l[2]);for(const t of s)if(w(c)){if(!1===m(t))return V(e,l[2]);if(!c.hasField(t))return V(e,l[2]);c=c.field(t)}else if(c instanceof n){if(!1===m(t))return V(e,l[2]);if(!c.hasField(t))return V(e,l[2]);c=c.field(t)}else if(c instanceof q){if(!1===m(t))return V(e,l[2]);if(c=k(c,t,null,null,2),null===c)return V(e,l[2]);if("notfound"===c?.keystate)return V(e,l[2])}else if(h(c)){if(!1===g(t))return V(e,l[2]);if(c=c[t],null==c)return V(e,l[2])}else{if(!d(c))return V(e,l[2]);if(!1===g(t))return V(e,l[2]);if(c=c.get(t),null==c)return V(e,l[2])}return c}return null===i||""===i||void 0===i?V(e,l[1]):i}catch(l){throw l}},be.decode=function(e,t){try{const n=t.arguments;if(n.length<2)throw new r(e,o.WrongNumberOfParameters,t);if(2===n.length)return V(e,n[1]);{if((n.length-1)%2==0)throw new r(e,o.WrongNumberOfParameters,t);const l=V(e,n[0]);return xe(e,t,1,l)}}catch(n){throw n}},be.when=function(e,t){try{const n=t.arguments;if(n.length<3)throw new r(e,o.WrongNumberOfParameters,t);if(n.length%2==0)throw new r(e,o.WrongNumberOfParameters,t);const l=V(e,n[0]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,n[0]);return Se(e,t,0,l)}catch(n){throw n}};for(const Le in be)be[Le]={value:new a(be[Le]),valueset:!0,node:null};const Ie=function(){};function Ce(e,t,r){const o=new Ie;e||(e={}),t||(t={});const l=new n({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});l.immutable=!1,o.textformatting={value:l,valueset:!0,node:null};for(const n in t)o[n]={value:new a(t[n]),native:!0,valueset:!0,node:null};for(const n in e)e[n]&&"esri.Graphic"===e[n].declaredClass?o[n]={value:i.createFromGraphic(e[n],r),valueset:!0,node:null}:o[n]={value:e[n],valueset:!0,node:null};return o}Ie.prototype=be,Ie.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Ie.prototype.pi={value:Math.PI,valueset:!0,node:null};const Re={fixSpatialReference:E,parseArguments:T,standardFunction:W};function Ae(e){console.log(e)}function Me(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:W,evaluateIdentifier:ve};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)be[n]={value:new a(t.functions[n]),valueset:!0,node:null},Ie.prototype[n]=be[n];for(let n=0;n<t.signatures.length;n++)L(t.signatures[n],"sync")}function Ee(e,n){let l=n.spatialReference;null==l&&(l=new G({wkid:102100}));let i=null;e.usesModules&&(i=new t(new Map,e.loadedModules));const a={spatialReference:l,globalScope:Ce(n.vars,n.customfunctions,n.timeZone),localScope:null,services:n.services??null,exports:{},libraryResolver:i,console:n.console??Ae,timeZone:n.timeZone??null,lrucache:n.lrucache,interceptor:n.interceptor,depthCounter:{depth:1}};let s=V(a,e);if(s instanceof F&&(s=s.value),s instanceof C&&(s=s.value),s===x&&(s=null),s===b)throw new r(a,o.IllegalResult,null);if(s===y)throw new r(a,o.IllegalResult,null);if(S(s))throw new r(a,o.IllegalResult,null);return s}Me([N]);export{Ee as executeScript,Me as extend,Re as functionHelper};
|
|
5
|
+
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import n from"./Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as o,ensureArcadeExecutionError as l}from"./executionError.js";import i from"./Feature.js";import{NativeFunction as a,ArcadeFunction as s,ScopeMarshalledFunction as c,wrapModuleScopedResponse as u}from"./FunctionWrapper.js";import{H as f,a as p,q as d,o as h,r as w,c as m,b as g,F as v,D as y,C as b,B as x,i as S,z as F,g as I,A as C,j as R,E as A,G as M,x as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as L}from"./treeAnalysis.js";import{A as N}from"../chunks/array.js";import{registerFunctions as O}from"./functions/date.js";import{registerFunctions as B,geometryMember as k}from"./functions/geometry.js";import{registerFunctions as j}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as K}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import q from"../geometry/Geometry.js";import G from"../geometry/SpatialReference.js";class Z extends s{constructor(e,t){super(),this.definition=null,this.context=null,this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,null);return Fe(this.definition,n,t,null)}}call(e,t){return W(e,t,((n,l,i)=>{const a={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(a.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,t);return Fe(this.definition,a,i,t)}))}marshalledCall(e,t,n,r){return r(e,t,((o,l,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!S(t)||t instanceof c?t:u(t,e,r))),u(Fe(this.definition,a,i,t),n,r)}))}}class P extends e{constructor(e){super(e)}global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=V(this.executingContext,t.node),t.valueset=!0),S(t.value)&&!(t.value instanceof c)){const e=new c;e.fn=t.value,e.parameterEvaluator=W,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(S(t))throw new r(null,o.AssignModuleFunction,null);this.executingContext.globalScope[e.toLowerCase()]={value:t,valueset:!0,node:null}}hasGlobal(e){return void 0===this.executingContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.executingContext.exports[e]}loadModule(e){let n=e.spatialReference;null==n&&(n=new G({wkid:102100})),this.moduleScope=Ce({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:n,globalScope:this.moduleScope,localScope:null,libraryResolver:new t(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ae,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},V(this.executingContext,this.source.syntax)}}function T(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(V(e,t.arguments[r]));return n}function W(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,T(e,t))}catch(r){throw r}}function V(e,t){try{switch(t?.type){case"EmptyStatement":return x;case"VariableDeclarator":return ce(e,t);case"VariableDeclaration":return se(e,t);case"ImportDeclaration":return ie(e,t);case"ExportNamedDeclaration":return ae(e,t);case"BlockStatement":case"Program":return re(e,t);case"FunctionDeclaration":return le(e,t);case"ReturnStatement":return oe(e,t);case"IfStatement":return ne(e,t);case"ExpressionStatement":return te(e,t);case"AssignmentExpression":return ee(e,t);case"UpdateExpression":return X(e,t);case"BreakStatement":return b;case"ContinueStatement":return y;case"TemplateElement":return we(e,t);case"TemplateLiteral":return ge(e,t);case"ForStatement":return Y(e,t);case"ForInStatement":return H(e,t);case"WhileStatement":return J(e,t);case"Identifier":return ve(e,t);case"MemberExpression":return ue(e,t);case"Literal":return t.value;case"CallExpression":return ye(e,t);case"UnaryExpression":return fe(e,t);case"BinaryExpression":return de(e,t);case"LogicalExpression":return he(e,t);case"ArrayExpression":return pe(e,t);case"ObjectExpression":return _(e,t);case"Property":return z(e,t);default:throw new r(e,o.Unrecognized,t)}}catch(n){throw l(e,t,n)}}function _(e,t){const l={},i=new Map;for(let n=0;n<t.properties.length;n++){const a=V(e,t.properties[n]);if(S(a.value))throw new r(e,o.NoFunctionInDictionary,t);if(!1===m(a.key))throw new r(e,o.KeyMustBeString,t);let s=a.key.toString();const c=s.toLowerCase();i.has(c)?s=i.get(c):i.set(c,s),a.value===x?l[s]=null:l[s]=a.value}const a=new n(l);return a.immutable=!1,a}function z(e,t){return{key:"Identifier"===t.key.type?t.key.name:V(e,t.key),value:V(e,t.value)}}function H(e,t){const l=V(e,t.right);"VariableDeclaration"===t.left.type&&V(e,t.left);let i=null,a="";if("VariableDeclaration"===t.left.type){const e=t.left.declarations[0].id;"Identifier"===e.type&&(a=e.name)}else"Identifier"===t.left.type&&(a=t.left.name);if(!a)throw new r(e,o.InvalidIdentifier,t);if(a=a.toLowerCase(),null!=e.localScope&&void 0!==e.localScope[a]&&(i=e.localScope[a]),null===i&&void 0!==e.globalScope[a]&&(i=e.globalScope[a]),null===i)throw new r(e,o.InvalidIdentifier,t);if(h(l)||m(l)){const n=l.length;for(let r=0;r<n;r++){i.value=r;const n=V(e,t.body);if(n===b)break;if(n instanceof F)return n}return x}if(d(l)){for(let n=0;n<l.length();n++){i.value=n;const r=V(e,t.body);if(r===b)break;if(r instanceof F)return r}return x}if(!(l instanceof n||w(l)))return x;{const n=l.keys();for(let r=0;r<n.length;r++){i.value=n[r];const o=V(e,t.body);if(o===b)break;if(o instanceof F)return o}}}function Y(e,t){null!==t.init&&V(e,t.init);const n={testResult:!0,lastAction:x};do{Q(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof F?n.lastAction:x}function J(e,t){const n={testResult:!0,lastAction:x};if(n.testResult=V(e,t.test),!1===n.testResult)return x;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=V(e,t.body),n.lastAction!==b)&&!(n.lastAction instanceof F);)if(n.testResult=V(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return n.lastAction instanceof F?n.lastAction:x}function Q(e,t,n){if(null!==t.test){if(n.testResult=V(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t)}n.lastAction=V(e,t.body),n.lastAction!==b?n.lastAction instanceof F?n.testResult=!1:null!==t.update&&V(e,t.update):n.testResult=!1}function X(e,t){let l,i=null,a="";if("MemberExpression"===t.argument.type){if(i=V(e,t.argument.object),!0===t.argument.computed?a=V(e,t.argument.property):"Identifier"===t.argument.property.type&&(a=t.argument.property.name),h(i)){if(!g(a))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(a<0&&(a=i.length+a),a<0||a>=i.length)throw new r(e,o.OutOfBounds,t);l=I(i[a]),i[a]="++"===t.operator?l+1:l-1}else if(i instanceof n){if(!1===m(a))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new r(e,o.FieldNotFound,t);l=I(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else if(w(i)){if(!1===m(a))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasField(a))throw new r(e,o.FieldNotFound,t);l=I(i.field(a)),i.setField(a,"++"===t.operator?l+1:l-1)}else{if(d(i))throw new r(e,o.Immutable,t);if(!(i instanceof P))throw new r(e,o.InvalidParameter,t);if(!1===m(a))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==i.hasGlobal(a))throw new r(e,o.ModuleExportNotFound,t);l=I(i.global(a)),i.setGlobal(a,"++"===t.operator?l+1:l-1)}return!1===t.prefix?l:"++"===t.operator?l+1:l-1}if(i="Identifier"===t.argument.type?t.argument.name.toLowerCase():"",!i)throw new r(e,o.InvalidIdentifier,t);if(null!=e.localScope&&void 0!==e.localScope[i])return l=I(e.localScope[i].value),e.localScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;if(void 0!==e.globalScope[i])return l=I(e.globalScope[i].value),e.globalScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;throw new r(e,o.InvalidIdentifier,t)}function $(e,t,n,l,i){switch(t){case"=":return e===x?null:e;case"/=":return I(n)/I(e);case"*=":return I(n)*I(e);case"-=":return I(n)-I(e);case"+=":return m(n)||m(e)?R(n)+R(e):I(n)+I(e);case"%=":return I(n)%I(e);default:throw new r(i,o.UnsupportedOperator,l)}}function ee(e,t){let l=null,i="";if("MemberExpression"===t.left.type){if(l=V(e,t.left.object),!0===t.left.computed)i=V(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new r(e,o.InvalidIdentifier,t);i=t.left.property.name}const a=V(e,t.right);if(h(l)){if(!g(i))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(i<0&&(i=l.length+i),i<0||i>l.length)throw new r(e,o.OutOfBounds,t);if(i===l.length){if("="!==t.operator)throw new r(e,o.OutOfBounds,t);l[i]=$(a,t.operator,l[i],t,e)}else l[i]=$(a,t.operator,l[i],t,e)}else if(l instanceof n){if(!1===m(i))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else if(w(l)){if(!1===m(i))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===l.hasField(i))l.setField(i,$(a,t.operator,l.field(i),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:i});l.setField(i,$(a,t.operator,null,t,e))}}else{if(d(l))throw new r(e,o.Immutable,t);if(!(l instanceof P))throw new r(e,o.InvalidIdentifier,t);if(!1===m(i))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==l.hasGlobal(i))throw new r(e,o.ModuleExportNotFound,t);l.setGlobal(i,$(a,t.operator,l.global(i),t,e))}return x}l=t.left.name.toLowerCase();const a=V(e,t.right);if(null!=e.localScope&&void 0!==e.localScope[l])return e.localScope[l]={value:$(a,t.operator,e.localScope[l].value,t,e),valueset:!0,node:t.right},x;if(void 0!==e.globalScope[l])return e.globalScope[l]={value:$(a,t.operator,e.globalScope[l].value,t,e),valueset:!0,node:t.right},x;throw new r(e,o.InvalidIdentifier,t)}function te(e,t){if("AssignmentExpression"===t.expression.type||"UpdateExpression"===t.expression.type)return V(e,t.expression);if("CallExpression"===t.expression.type){const n=V(e,t.expression);return n===x?x:new C(n)}{const n=V(e,t.expression);return n===x?x:new C(n)}}function ne(e,t){const n=V(e,t.test);if(!0===n)return V(e,t.consequent);if(!1===n)return null!==t.alternate?V(e,t.alternate):x;throw new r(e,o.BooleanConditionRequired,t)}function re(e,t){let n=x;for(let r=0;r<t.body.length;r++)if(n=V(e,t.body[r]),n instanceof F||n===b||n===y)return n;return n}function oe(e,t){if(null===t.argument)return new F(x);const n=V(e,t.argument);return new F(n)}function le(e,t){const n=t.id.name.toLowerCase();return e.globalScope[n]={valueset:!0,node:null,value:new Z(t,e)},x}function ie(e,t){const n=t.specifiers[0].local.name.toLowerCase(),r=e.libraryResolver.loadLibrary(n);let o=null;return e.libraryResolver._moduleSingletons?.has(r.uri)?o=e.libraryResolver._moduleSingletons.get(r.uri):(o=new P(r),o.loadModule(e),e.libraryResolver._moduleSingletons?.set(r.uri,o)),e.globalScope[n]={value:o,valueset:!0,node:t},x}function ae(e,t){if(V(e,t.declaration),"FunctionDeclaration"===t.declaration.type)e.exports[t.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===t.declaration.type)for(const n of t.declaration.declarations)e.exports[n.id.name.toLowerCase()]="variable";return x}function se(e,t){for(let n=0;n<t.declarations.length;n++)V(e,t.declarations[n]);return x}function ce(e,t){let n=null===t.init?null:V(e,t.init);if(n===x&&(n=null),"Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const l=t.id.name.toLowerCase();return null!=e.localScope?e.localScope[l]={value:n,valueset:!0,node:t.init}:e.globalScope[l]={value:n,valueset:!0,node:t.init},x}function ue(e,t){try{const l=V(e,t.object);if(null===l)throw new r(e,o.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(l instanceof n||w(l))return l.field(t.property.name);if(l instanceof q)return k(l,t.property.name,e,t);if(l instanceof P){if(!l.hasGlobal(t.property.name))throw new r(e,o.InvalidIdentifier,t);return l.global(t.property.name)}}throw new r(e,o.InvalidMemberAccessKey,t)}{let i=V(e,t.property);if(l instanceof n||w(l)){if(m(i))return l.field(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(l instanceof P){if(m(i))return l.global(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(l instanceof q){if(m(i))return k(l,i,e,t);throw new r(e,o.InvalidMemberAccessKey,t)}if(h(l)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new r(e,o.OutOfBounds,t);return l[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(m(l)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length+i),i>=l.length||i<0)throw new r(e,o.OutOfBounds,t);return l[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(d(l)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=l.length()+i),i>=l.length()||i<0)throw new r(e,o.OutOfBounds,t);return l.get(i)}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}}catch(l){throw l}}function fe(e,t){try{const n=V(e,t.argument);if(p(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*I(n);if("+"===t.operator)return 1*I(n);if("~"===t.operator)return~I(n);throw new r(e,o.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~I(n);if("-"===t.operator)return-1*I(n);if("+"===t.operator)return 1*I(n);throw new r(e,o.UnsupportedUnaryOperator,t)}catch(n){throw n}}function pe(e,t){try{const n=[];for(let l=0;l<t.elements.length;l++){const i=V(e,t.elements[l]);if(S(i))throw new r(e,o.NoFunctionInArray,t);i===x?n.push(null):n.push(i)}return n}catch(n){throw n}}function de(e,t){try{const n=[V(e,t.left),V(e,t.right)],l=n[0],i=n[1];switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(I(l),I(i),t.operator);case"==":return v(l,i);case"!=":return!v(l,i);case"<":case">":case"<=":case">=":return A(l,i,t.operator);case"+":return m(l)||m(i)?R(l)+R(i):I(l)+I(i);case"-":return I(l)-I(i);case"*":return I(l)*I(i);case"/":return I(l)/I(i);case"%":return I(l)%I(i);default:throw new r(e,o.UnsupportedOperator,t)}}catch(n){throw n}}function he(e,t){try{const n=V(e,t.left);if(p(n))switch(t.operator){case"||":if(!0===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new r(e,o.LogicExpressionOrAnd,t)}case"&&":if(!1===n)return n;{const n=V(e,t.right);if(p(n))return n;throw new r(e,o.LogicExpressionOrAnd,t)}default:throw new r(e,o.LogicExpressionOrAnd,t)}throw new r(e,o.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function we(e,t){return t.value?t.value.cooked:""}function me(e,t,n){if(S(e))throw new r(t,o.NoFunctionInTemplateLiteral,n);return e}function ge(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?R(me(V(e,t.expressions[r]),e,t)):"",r++}return n}function ve(e,t){let n;try{const l=t.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[l])return n=e.localScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;if(void 0!==e.globalScope[l])return n=e.globalScope[l],!0===n.valueset||(n.value=V(e,n.node),n.valueset=!0),n.value;throw new r(e,o.InvalidIdentifier,t)}catch(l){throw l}}function ye(e,t){try{if("MemberExpression"===t.callee.type){const n=V(e,t.callee.object);if(!(n instanceof P))throw new r(e,o.FunctionNotFound,t);const l=!1===t.callee.computed?t.callee.property.name:V(e,t.callee.property);if(!n.hasGlobal(l))throw new r(e,o.FunctionNotFound,t);const i=n.global(l);if(!S(i))throw new r(e,o.CallNonFunction,t);return i.call(e,t)}if("Identifier"!==t.callee.type)throw new r(e,o.FunctionNotFound,t);if(null!=e.localScope&&void 0!==e.localScope[t.callee.name.toLowerCase()]){const n=e.localScope[t.callee.name.toLowerCase()];if(S(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}if(void 0!==e.globalScope[t.callee.name.toLowerCase()]){const n=e.globalScope[t.callee.name.toLowerCase()];if(S(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}throw new r(e,o.FunctionNotFound,t)}catch(n){throw n}}const be={};function xe(e,t,n,r){try{const o=t.arguments,l=V(e,o[n]);if(v(l,r))return V(e,o[n+1]);{const l=o.length-n;return 1===l?V(e,o[n]):2===l?null:3===l?V(e,o[n+2]):xe(e,t,n+2,r)}}catch(o){throw o}}function Se(e,t,n,l){try{const i=t.arguments;if(!0===l)return V(e,i[n+1]);if(3===i.length-n)return V(e,i[n+2]);{const l=V(e,i[n+2]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,i[n+2]);return Se(e,t,n+2,l)}}catch(i){throw i}}function Fe(e,t,n,l){try{const i=e.body;if(n.length!==e.params.length)throw new r(t,o.WrongNumberOfParameters,l);if(null!=t.localScope)for(let r=0;r<n.length;r++)t.localScope[e.params[r].name.toLowerCase()]={value:n[r],valueset:!0,node:null};const a=V(t,i);if(a instanceof F)return a.value;if(a===b)throw new r(t,o.UnexpectedToken,l);if(a===y)throw new r(t,o.UnexpectedToken,l);return a instanceof C?a.value:a}catch(i){throw i}}O(be,W),U(be,W),D(be,W),B(be,W),K(be,W),j(be,W),be.iif=function(e,t){try{const n=t.arguments;f(null===n?[]:n,3,3,e,t);const l=V(e,n[0]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,t);return V(e,!0===l?n[1]:n[2])}catch(n){throw n}},be.defaultvalue=function(e,t){try{const l=t.arguments;f(null===l?[]:l,2,3,e,t);const i=V(e,l[0]);if(3===l.length){const a=V(e,l[1]);let s=[];if(d(a))s=a.toArray();else{if(!h(a))throw new r(e,o.InvalidParameter,t);s=a}let c=i;if(null===c)return V(e,l[2]);for(const t of s)if(w(c)){if(!1===m(t))return V(e,l[2]);if(!c.hasField(t))return V(e,l[2]);c=c.field(t)}else if(c instanceof n){if(!1===m(t))return V(e,l[2]);if(!c.hasField(t))return V(e,l[2]);c=c.field(t)}else if(c instanceof q){if(!1===m(t))return V(e,l[2]);if(c=k(c,t,null,null,2),null===c)return V(e,l[2]);if("notfound"===c?.keystate)return V(e,l[2])}else if(h(c)){if(!1===g(t))return V(e,l[2]);if(c=c[t],null==c)return V(e,l[2])}else{if(!d(c))return V(e,l[2]);if(!1===g(t))return V(e,l[2]);if(c=c.get(t),null==c)return V(e,l[2])}return c}return null===i||""===i||void 0===i?V(e,l[1]):i}catch(l){throw l}},be.decode=function(e,t){try{const n=t.arguments;if(n.length<2)throw new r(e,o.WrongNumberOfParameters,t);if(2===n.length)return V(e,n[1]);{if((n.length-1)%2==0)throw new r(e,o.WrongNumberOfParameters,t);const l=V(e,n[0]);return xe(e,t,1,l)}}catch(n){throw n}},be.when=function(e,t){try{const n=t.arguments;if(n.length<3)throw new r(e,o.WrongNumberOfParameters,t);if(n.length%2==0)throw new r(e,o.WrongNumberOfParameters,t);const l=V(e,n[0]);if(!1===p(l))throw new r(e,o.BooleanConditionRequired,n[0]);return Se(e,t,0,l)}catch(n){throw n}};for(const Le in be)be[Le]={value:new a(be[Le]),valueset:!0,node:null};const Ie=function(){};function Ce(e,t,r){const o=new Ie;e||(e={}),t||(t={});const l=new n({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});l.immutable=!1,o.textformatting={value:l,valueset:!0,node:null};for(const n in t)o[n]={value:new a(t[n]),native:!0,valueset:!0,node:null};for(const n in e)e[n]&&"esri.Graphic"===e[n].declaredClass?o[n]={value:i.createFromGraphic(e[n],r),valueset:!0,node:null}:o[n]={value:e[n],valueset:!0,node:null};return o}Ie.prototype=be,Ie.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Ie.prototype.pi={value:Math.PI,valueset:!0,node:null};const Re={fixSpatialReference:E,parseArguments:T,standardFunction:W};function Ae(e){console.log(e)}function Me(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:W,evaluateIdentifier:ve};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)be[n]={value:new a(t.functions[n]),valueset:!0,node:null},Ie.prototype[n]=be[n];for(let n=0;n<t.signatures.length;n++)L(t.signatures[n],"sync")}function Ee(e,n){let l=n.spatialReference;null==l&&(l=new G({wkid:102100}));let i=null;e.usesModules&&(i=new t(new Map,e.loadedModules));const a={spatialReference:l,globalScope:Ce(n.vars,n.customfunctions,n.timeZone),localScope:null,services:n.services??null,exports:{},libraryResolver:i,console:n.console??Ae,timeZone:n.timeZone??null,lrucache:n.lrucache,interceptor:n.interceptor,depthCounter:{depth:1}};let s=V(a,e);if(s instanceof F&&(s=s.value),s instanceof C&&(s=s.value),s===x&&(s=null),s===b)throw new r(a,o.IllegalResult,null);if(s===y)throw new r(a,o.IllegalResult,null);if(S(s))throw new r(a,o.IllegalResult,null);return s}Me([N]);export{Ee as executeScript,Me as extend,Re 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{version as n}from"../../kernel.js";import t from"../ArcadePortal.js";import e from"../Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as i}from"../executionError.js";import{cloneGeometry as a,convertSquareUnitsToCode as o,convertLinearUnitsToCode as l}from"../kernel.js";import{I as s,H as u,k as c,n as f,m as d,j as m,o as w,q as h,x as y,u as p,K as g,J as v,L as P,M as I,g as A,h as F,b as R,N as j}from"../../chunks/languageUtils.js";import{getPortal as x}from"../portalUtils.js";import{centroidPolyline as b,centroidMultiPoint as N,getMetersPerVerticalUnitForSR as O,segmentLength3d as S}from"./centroid.js";import{measureToCoordinate as D,pointToCoordinate as k,distanceToCoordinate as L}from"./measures.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import T from"../../geometry/Extent.js";import J from"../../geometry/Geometry.js";import{disjoint as Z,intersects as C,touches as U,crosses as z,within as E,contains as q,overlaps as W,equals as G,relate as H,intersect as K,union as V,difference as B,symmetricDifference as Q,clip as X,cut as Y,planarArea as $,geodesicArea as _,planarLength as nn,geodesicLength as tn,distance as en,densify as rn,geodesicDensify as an,generalize as on,buffer as ln,geodesicBuffer as sn,offset as un,rotate as cn,simplify as fn,isSimple as dn,convexHull as mn,nearestCoordinate as wn,nearestVertex as hn}from"../../geometry/geometryEngineAsync.js";import yn from"../../geometry/Multipoint.js";import pn from"../../geometry/Point.js";import gn from"../../geometry/Polygon.js";import vn from"../../geometry/Polyline.js";import{fromJSON as Pn}from"../../geometry/support/jsonUtils.js";import In from"../../portal/Portal.js";import{lookupUser as An}from"../../portal/support/utils.js";function Fn(t){return 0===n.indexOf("4.")?gn.fromExtent(t):new gn({spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]})}function Rn(n,t,e){if(u(n,2,2,t,e),n[0]instanceof J&&n[1]instanceof J);else if(n[0]instanceof J&&null===n[1]);else if(n[1]instanceof J&&null===n[0]);else if(null!==n[0]||null!==n[1])throw new r(t,i.InvalidParameter,e)}async function jn(n,t){if("polygon"!==n.type&&"polyline"!==n.type&&"extent"!==n.type)return 0;let e=1;if(n.spatialReference.vcsWkid||n.spatialReference.latestVcsWkid){e=O(n.spatialReference)/M(n.spatialReference)}let r=0;if("polyline"===n.type)for(const a of n.paths)for(let n=1;n<a.length;n++)r+=S(a[n],a[n-1],e);else if("polygon"===n.type)for(const a of n.rings){for(let n=1;n<a.length;n++)r+=S(a[n],a[n-1],e);(a[0][0]!==a[a.length-1][0]||a[0][1]!==a[a.length-1][1]||void 0!==a[0][2]&&a[0][2]!==a[a.length-1][2])&&(r+=S(a[0],a[a.length-1],e))}else"extent"===n.type&&(r+=2*S([n.xmin,n.ymin,0],[n.xmax,n.ymin,0],e),r+=2*S([n.xmin,n.ymin,0],[n.xmin,n.ymax,0],e),r*=2,r+=4*Math.abs(g(n.zmax,0)*e-g(n.zmin,0)*e));const i=new vn({hasZ:!1,hasM:!1,spatialReference:n.spatialReference,paths:[[0,0],[0,r]]});return nn(i,t)}function xn(n){"async"===n.mode&&(n.functions.disjoint=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]||null===i[1]||Z(i[0],i[1]))))},n.functions.intersects=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&C(i[0],i[1]))))},n.functions.touches=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&U(i[0],i[1]))))},n.functions.crosses=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&z(i[0],i[1]))))},n.functions.within=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&E(i[0],i[1]))))},n.functions.contains=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&q(i[0],i[1]))))},n.functions.overlaps=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&W(i[0],i[1]))))},n.functions.equals=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(u(i,2,2,t,e),i[0]===i[1]||(i[0]instanceof J&&i[1]instanceof J?G(i[0],i[1]):(c(i[0])&&c(i[1])||!!(f(i[0])&&f(i[1])||d(i[0])&&d(i[1])))&&i[0].equals(i[1])))))},n.functions.relate=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,3,3,t,e),o[0]instanceof J&&o[1]instanceof J)return H(o[0],o[1],m(o[2]));if(o[0]instanceof J&&null===o[1])return!1;if(o[1]instanceof J&&null===o[0])return!1;if(null===o[0]&&null===o[1])return!1;throw new r(t,i.InvalidParameter,e)}))},n.functions.intersection=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]||null===i[1]?null:K(i[0],i[1]))))},n.functions.union=function(t,e){return n.standardFunctionAsync(t,e,((n,o,l)=>{const u=[];if(0===(l=s(l)).length)throw new r(t,i.WrongNumberOfParameters,e);if(1===l.length)if(w(l[0])){const n=s(l[0]);for(let a=0;a<n.length;a++)if(null!==n[a]){if(!(n[a]instanceof J))throw new r(t,i.InvalidParameter,e);u.push(n[a])}}else{if(!h(l[0])){if(l[0]instanceof J)return y(a(l[0]),t.spatialReference);if(null===l[0])return null;throw new r(t,i.InvalidParameter,e)}{const n=s(l[0].toArray());for(let a=0;a<n.length;a++)if(null!==n[a]){if(!(n[a]instanceof J))throw new r(t,i.InvalidParameter,e);u.push(n[a])}}}else for(let a=0;a<l.length;a++)if(null!==l[a]){if(!(l[a]instanceof J))throw new r(t,i.InvalidParameter,e);u.push(l[a])}return 0===u.length?null:V(u)}))},n.functions.difference=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null===i[1]?a(i[0]):null===i[0]?null:B(i[0],i[1]))))},n.functions.symmetricdifference=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]&&null===i[1]?null:null===i[0]?a(i[1]):null===i[1]?a(i[0]):Q(i[0],i[1]))))},n.functions.clip=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,2,t,e),!(o[1]instanceof T)&&null!==o[1])throw new r(t,i.InvalidParameter,e);if(null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return null===o[1]?null:X(o[0],o[1])}))},n.functions.cut=function(t,e){return n.standardFunctionAsync(t,e,((n,o,l)=>{if(l=s(l),u(l,2,2,t,e),!(l[1]instanceof vn)&&null!==l[1])throw new r(t,i.InvalidParameter,e);if(null===l[0])return[];if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);return null===l[1]?[a(l[0])]:Y(l[0],l[1])}))},n.functions.area=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,l)=>{if(u(l,1,2,t,e),null===(l=s(l))[0])return 0;if(p(l[0])){const n=await l[0].sumArea(o(g(l[1],-1)),!1,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(l[0])||h(l[0])){const n=v(l[0],t.spatialReference);return null===n?0:$(n,o(g(l[1],-1)))}if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);return $(l[0],o(g(l[1],-1)))}))},n.functions.areageodetic=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,l)=>{if(u(l,1,2,t,e),null===(l=s(l))[0])return 0;if(p(l[0])){const n=await l[0].sumArea(o(g(l[1],-1)),!0,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(l[0])||h(l[0])){const n=v(l[0],t.spatialReference);return null===n?0:_(n,o(g(l[1],-1)))}if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);return _(l[0],o(g(l[1],-1)))}))},n.functions.length=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,o)=>{if(u(o,1,2,t,e),null===(o=s(o))[0])return 0;if(p(o[0])){const n=await o[0].sumLength(l(g(o[1],-1)),!1,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(o[0])||h(o[0])){const n=P(o[0],t.spatialReference);return null===n?0:nn(n,l(g(o[1],-1)))}if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return nn(o[0],l(g(o[1],-1)))}))},n.functions.length3d=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(u(o,1,2,t,e),null===(o=s(o))[0])return 0;if(w(o[0])||h(o[0])){const n=P(o[0],t.spatialReference);return null===n?0:!0===n.hasZ?jn(n,l(g(o[1],-1))):nn(n,l(g(o[1],-1)))}if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return!0===o[0].hasZ?jn(o[0],l(g(o[1],-1))):nn(o[0],l(g(o[1],-1)))}))},n.functions.lengthgeodetic=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,o)=>{if(u(o,1,2,t,e),null===(o=s(o))[0])return 0;if(p(o[0])){const n=await o[0].sumLength(l(g(o[1],-1)),!0,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(o[0])||h(o[0])){const n=P(o[0],t.spatialReference);return null===n?0:tn(n,l(g(o[1],-1)))}if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return tn(o[0],l(g(o[1],-1)))}))},n.functions.distance=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{o=s(o),u(o,2,3,t,e);let c=o[0];(w(o[0])||h(o[0]))&&(c=I(o[0],t.spatialReference));let f=o[1];if((w(o[1])||h(o[1]))&&(f=I(o[1],t.spatialReference)),!(c instanceof J))throw new r(t,i.InvalidParameter,e);if(!(f instanceof J))throw new r(t,i.InvalidParameter,e);return en(c,f,l(g(o[2],-1)))}))},n.functions.distancegeodetic=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{o=s(o),u(o,2,3,t,e);const c=o[0],f=o[1];if(!(c instanceof pn))throw new r(t,i.InvalidParameter,e);if(!(f instanceof pn))throw new r(t,i.InvalidParameter,e);const d=new vn({paths:[],spatialReference:c.spatialReference});return d.addPath([c,f]),tn(d,l(g(o[2],-1)))}))},n.functions.densify=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,3,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);if(c<=0)throw new r(t,i.InvalidParameter,e);return o[0]instanceof gn||o[0]instanceof vn?rn(o[0],c,l(g(o[2],-1))):o[0]instanceof T?rn(Fn(o[0]),c,l(g(o[2],-1))):o[0]}))},n.functions.densifygeodetic=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,3,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);if(c<=0)throw new r(t,i.InvalidParameter,e);return o[0]instanceof gn||o[0]instanceof vn?an(o[0],c,l(g(o[2],-1))):o[0]instanceof T?an(Fn(o[0]),c,l(g(o[2],-1))):o[0]}))},n.functions.generalize=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,4,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);return on(o[0],c,F(g(o[2],!0)),l(g(o[3],-1)))}))},n.functions.buffer=function(t,e){return n.standardFunctionAsync(t,e,((n,o,c)=>{if(c=s(c),u(c,2,3,t,e),null===c[0])return null;if(!(c[0]instanceof J))throw new r(t,i.InvalidParameter,e);const f=A(c[1]);if(isNaN(f))throw new r(t,i.InvalidParameter,e);return 0===f?a(c[0]):ln(c[0],f,l(g(c[2],-1)))}))},n.functions.buffergeodetic=function(t,e){return n.standardFunctionAsync(t,e,((n,o,c)=>{if(c=s(c),u(c,2,3,t,e),null===c[0])return null;if(!(c[0]instanceof J))throw new r(t,i.InvalidParameter,e);const f=A(c[1]);if(isNaN(f))throw new r(t,i.InvalidParameter,e);return 0===f?a(c[0]):sn(c[0],f,l(g(c[2],-1)))}))},n.functions.offset=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,6,t,e),null===o[0])return null;if(!(o[0]instanceof gn||o[0]instanceof vn))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);const f=A(g(o[4],10));if(isNaN(f))throw new r(t,i.InvalidParameter,e);const d=A(g(o[5],0));if(isNaN(d))throw new r(t,i.InvalidParameter,e);return un(o[0],c,l(g(o[2],-1)),m(g(o[3],"round")).toLowerCase(),f,d)}))},n.functions.rotate=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{o=s(o),u(o,2,3,t,e);let l=o[0];if(null===l)return null;if(!(l instanceof J))throw new r(t,i.InvalidParameter,e);l instanceof T&&(l=gn.fromExtent(l));const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);const f=g(o[2],null);if(null===f)return cn(l,c);if(f instanceof pn)return cn(l,c,f);throw new r(t,i.InvalidParameter,e)}))},n.functions.centroid=function(t,e){return n.standardFunctionAsync(t,e,((n,o,l)=>{if(l=s(l),u(l,1,1,t,e),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=I(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,e);return c instanceof pn?y(a(l[0]),t.spatialReference):c instanceof gn?c.centroid:c instanceof vn?b(c):c instanceof yn?N(c):c instanceof T?c.center:null}))},n.functions.measuretocoordinate=function(t,a){return n.standardFunctionAsync(t,a,((n,o,l)=>{if(l=s(l),u(l,2,2,t,a),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=P(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,a);if(!(c instanceof vn))throw new r(t,i.InvalidParameter,a);if(R(!1===l[1]))throw new r(t,i.InvalidParameter,a);const f=D(c,l[1]);return f?e.convertObjectToArcadeDictionary(f,j(t),!1,!0):null}))},n.functions.pointtocoordinate=function(t,a){return n.standardFunctionAsync(t,a,((n,o,l)=>{if(l=s(l),u(l,2,2,t,a),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=P(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,a);if(!(c instanceof vn))throw new r(t,i.InvalidParameter,a);const f=l[1];if(null===f)return null;if(!(f instanceof pn))throw new r(t,i.InvalidParameter,a);if(R(!1===l[1]))throw new r(t,i.InvalidParameter,a);const d=k(c,f);return d?e.convertObjectToArcadeDictionary(d,j(t),!1,!0):null}))},n.functions.distancetocoordinate=function(t,a){return n.standardFunctionAsync(t,a,((n,o,l)=>{if(l=s(l),u(l,2,2,t,a),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=P(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,a);if(!(c instanceof vn))throw new r(t,i.InvalidParameter,a);if(R(!1===l[1]))throw new r(t,i.InvalidParameter,a);const f=L(c,l[1]);return f?e.convertObjectToArcadeDictionary(f,j(t),!1,!0):null}))},n.functions.multiparttosinglepart=function(t,e){return n.standardFunctionAsync(t,e,(async(n,o,l)=>{l=s(l),u(l,1,1,t,e);const c=[];if(null===l[0])return null;if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);if(l[0]instanceof pn)return[y(a(l[0]),t.spatialReference)];if(l[0]instanceof T)return[y(a(l[0]),t.spatialReference)];const f=await fn(l[0]);if(f instanceof gn){const n=[],t=[];for(let e=0;e<f.rings.length;e++)if(f.isClockwise(f.rings[e])){const t=Pn({rings:[f.rings[e]],hasZ:!0===f.hasZ,hazM:!0===f.hasM,spatialReference:f.spatialReference.toJSON()});n.push(t)}else t.push({ring:f.rings[e],pt:f.getPoint(e,0)});for(let e=0;e<t.length;e++)for(let r=0;r<n.length;r++)if(n[r].contains(t[e].pt)){n[r].addRing(t[e].ring);break}return n}if(f instanceof vn){const n=[];for(let t=0;t<f.paths.length;t++){const e=Pn({paths:[f.paths[t]],hasZ:!0===f.hasZ,hazM:!0===f.hasM,spatialReference:f.spatialReference.toJSON()});n.push(e)}return n}if(l[0]instanceof yn){const n=y(a(l[0]),t.spatialReference);for(let t=0;t<n.points.length;t++)c.push(n.getPoint(t));return c}return null}))},n.functions.issimple=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,1,1,t,e),null===o[0])return!0;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return dn(o[0])}))},n.functions.simplify=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,1,1,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return fn(o[0])}))},n.functions.convexhull=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,1,1,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return mn(o[0])}))},n.functions.getuser=function(a,o){return n.standardFunctionAsync(a,o,(async(n,l,s)=>{u(s,0,2,a,o);let c=g(s[1],""),f=!0===c;if(c=!0===c||!1===c?"":m(c),0===s.length||s[0]instanceof t){let n=null;n=a.services?.portal?a.services.portal:In.getDefault(),s.length>0&&(n=x(s[0],n));const t=await An(n,c,f);if(t){const n=JSON.parse(JSON.stringify(t));for(const t of["lastLogin","created","modified"])void 0!==n[t]&&null!==n[t]&&(n[t]=new Date(n[t]));return e.convertObjectToArcadeDictionary(n,j(a))}return null}let d=null;if(p(s[0])&&(d=s[0]),d){if(f=!1,c)return null;await d.load();const n=await d.getOwningSystemUrl();if(!n){if(!c){const n=await d.getIdentityUser();return n?e.convertObjectToArcadeDictionary({username:n},j(a)):null}return null}let r=null;r=a.services?.portal?a.services.portal:In.getDefault(),r=x(new t(n),r);const i=await An(r,c,f);if(i){const n=JSON.parse(JSON.stringify(i));for(const t of["lastLogin","created","modified"])void 0!==n[t]&&null!==n[t]&&(n[t]=new Date(n[t]));return e.convertObjectToArcadeDictionary(n,j(a))}return null}throw new r(a,i.InvalidParameter,o)}))}),n.functions.nearestcoordinate=function(t,a){return n.standardFunctionAsync(t,a,(async(n,o,l)=>{if(l=s(l),u(l,2,2,t,a),!(l[0]instanceof J||null===l[0]))throw new r(t,i.InvalidParameter,a);if(!(l[1]instanceof pn||null===l[1]))throw new r(t,i.InvalidParameter,a);if(null===l[0]||null===l[1])return null;const c=await wn(l[0],l[1]);return null===c?null:e.convertObjectToArcadeDictionary({coordinate:c.coordinate,distance:c.distance,sideOfLine:0===c.distance?"straddle":c.isRightSide?"right":"left"},j(t),!1,!0)}))},n.functions.nearestvertex=function(t,a){return n.standardFunctionAsync(t,a,(async(n,o,l)=>{if(l=s(l),u(l,2,2,t,a),!(l[0]instanceof J||null===l[0]))throw new r(t,i.InvalidParameter,a);if(!(l[1]instanceof pn||null===l[1]))throw new r(t,i.InvalidParameter,a);if(null===l[0]||null===l[1])return null;const c=await hn(l[0],l[1]);return null===c?null:e.convertObjectToArcadeDictionary({coordinate:c.coordinate,distance:c.distance,sideOfLine:0===c.distance?"straddle":c.isRightSide?"right":"left"},j(t),!1,!0)}))}}export{xn as registerFunctions};
|
|
5
|
+
import{version as n}from"../../kernel.js";import t from"../ArcadePortal.js";import e from"../Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as i}from"../executionError.js";import{cloneGeometry as a,convertSquareUnitsToCode as o,convertLinearUnitsToCode as l}from"../kernel.js";import{I as s,H as u,k as c,n as f,m as d,j as m,o as w,q as h,x as y,u as p,K as g,J as v,L as P,M as I,g as A,h as F,b as R,N as j}from"../../chunks/languageUtils.js";import{getPortal as x}from"../portalUtils.js";import{centroidPolyline as b,centroidMultiPoint as N,getMetersPerVerticalUnitForSR as O,segmentLength3d as S}from"./centroid.js";import{measureToCoordinate as D,pointToCoordinate as k,distanceToCoordinate as L}from"./measures.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import T from"../../geometry/Extent.js";import J from"../../geometry/Geometry.js";import{disjoint as Z,intersects as C,touches as U,crosses as E,within as q,contains as z,overlaps as W,equals as G,relate as H,intersect as K,union as V,difference as B,symmetricDifference as Q,clip as X,cut as Y,planarArea as $,geodesicArea as _,planarLength as nn,geodesicLength as tn,distance as en,densify as rn,geodesicDensify as an,generalize as on,buffer as ln,geodesicBuffer as sn,offset as un,rotate as cn,simplify as fn,isSimple as dn,convexHull as mn,nearestCoordinate as wn,nearestVertex as hn}from"../../geometry/geometryEngineAsync.js";import yn from"../../geometry/Multipoint.js";import pn from"../../geometry/Point.js";import gn from"../../geometry/Polygon.js";import vn from"../../geometry/Polyline.js";import{fromJSON as Pn}from"../../geometry/support/jsonUtils.js";import In from"../../portal/Portal.js";import{lookupUser as An}from"../../portal/support/utils.js";function Fn(t){return 0===n.indexOf("4.")?gn.fromExtent(t):new gn({spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]})}function Rn(n,t,e){if(u(n,2,2,t,e),n[0]instanceof J&&n[1]instanceof J);else if(n[0]instanceof J&&null===n[1]);else if(n[1]instanceof J&&null===n[0]);else if(null!==n[0]||null!==n[1])throw new r(t,i.InvalidParameter,e)}async function jn(n,t){if("polygon"!==n.type&&"polyline"!==n.type&&"extent"!==n.type)return 0;let e=1;if(n.spatialReference.vcsWkid||n.spatialReference.latestVcsWkid){e=O(n.spatialReference)/M(n.spatialReference)}let r=0;if("polyline"===n.type)for(const a of n.paths)for(let n=1;n<a.length;n++)r+=S(a[n],a[n-1],e);else if("polygon"===n.type)for(const a of n.rings){for(let n=1;n<a.length;n++)r+=S(a[n],a[n-1],e);(a[0][0]!==a[a.length-1][0]||a[0][1]!==a[a.length-1][1]||void 0!==a[0][2]&&a[0][2]!==a[a.length-1][2])&&(r+=S(a[0],a[a.length-1],e))}else"extent"===n.type&&(r+=2*S([n.xmin,n.ymin,0],[n.xmax,n.ymin,0],e),r+=2*S([n.xmin,n.ymin,0],[n.xmin,n.ymax,0],e),r*=2,r+=4*Math.abs(g(n.zmax,0)*e-g(n.zmin,0)*e));const i=new vn({hasZ:!1,hasM:!1,spatialReference:n.spatialReference,paths:[[0,0],[0,r]]});return nn(i,t)}function xn(n){"async"===n.mode&&(n.functions.disjoint=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]||null===i[1]||Z(i[0],i[1]))))},n.functions.intersects=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&C(i[0],i[1]))))},n.functions.touches=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&U(i[0],i[1]))))},n.functions.crosses=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&E(i[0],i[1]))))},n.functions.within=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&q(i[0],i[1]))))},n.functions.contains=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&z(i[0],i[1]))))},n.functions.overlaps=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null!==i[0]&&null!==i[1]&&W(i[0],i[1]))))},n.functions.equals=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(u(i,2,2,t,e),i[0]===i[1]||(i[0]instanceof J&&i[1]instanceof J?G(i[0],i[1]):(c(i[0])&&c(i[1])||!!(f(i[0])&&f(i[1])||d(i[0])&&d(i[1])))&&i[0].equals(i[1])))))},n.functions.relate=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,3,3,t,e),o[0]instanceof J&&o[1]instanceof J)return H(o[0],o[1],m(o[2]));if(o[0]instanceof J&&null===o[1])return!1;if(o[1]instanceof J&&null===o[0])return!1;if(null===o[0]&&null===o[1])return!1;throw new r(t,i.InvalidParameter,e)}))},n.functions.intersection=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]||null===i[1]?null:K(i[0],i[1]))))},n.functions.union=function(t,e){return n.standardFunctionAsync(t,e,((n,o,l)=>{const u=[];if(0===(l=s(l)).length)throw new r(t,i.WrongNumberOfParameters,e);if(1===l.length)if(w(l[0])){const n=s(l[0]);for(let a=0;a<n.length;a++)if(null!==n[a]){if(!(n[a]instanceof J))throw new r(t,i.InvalidParameter,e);u.push(n[a])}}else{if(!h(l[0])){if(l[0]instanceof J)return y(a(l[0]),t.spatialReference);if(null===l[0])return null;throw new r(t,i.InvalidParameter,e)}{const n=s(l[0].toArray());for(let a=0;a<n.length;a++)if(null!==n[a]){if(!(n[a]instanceof J))throw new r(t,i.InvalidParameter,e);u.push(n[a])}}}else for(let a=0;a<l.length;a++)if(null!==l[a]){if(!(l[a]instanceof J))throw new r(t,i.InvalidParameter,e);u.push(l[a])}return 0===u.length?null:V(u)}))},n.functions.difference=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]?null:null===i[1]?a(i[0]):B(i[0],i[1]))))},n.functions.symmetricdifference=function(t,e){return n.standardFunctionAsync(t,e,((n,r,i)=>(Rn(i=s(i),t,e),null===i[0]&&null===i[1]?null:null===i[0]?a(i[1]):null===i[1]?a(i[0]):Q(i[0],i[1]))))},n.functions.clip=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,2,t,e),!(o[1]instanceof T)&&null!==o[1])throw new r(t,i.InvalidParameter,e);if(null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return null===o[1]?null:X(o[0],o[1])}))},n.functions.cut=function(t,e){return n.standardFunctionAsync(t,e,((n,o,l)=>{if(l=s(l),u(l,2,2,t,e),!(l[1]instanceof vn)&&null!==l[1])throw new r(t,i.InvalidParameter,e);if(null===l[0])return[];if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);return null===l[1]?[a(l[0])]:Y(l[0],l[1])}))},n.functions.area=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,l)=>{if(u(l,1,2,t,e),null===(l=s(l))[0])return 0;if(p(l[0])){const n=await l[0].sumArea(o(g(l[1],-1)),!1,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(l[0])||h(l[0])){const n=v(l[0],t.spatialReference);return null===n?0:$(n,o(g(l[1],-1)))}if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);return $(l[0],o(g(l[1],-1)))}))},n.functions.areageodetic=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,l)=>{if(u(l,1,2,t,e),null===(l=s(l))[0])return 0;if(p(l[0])){const n=await l[0].sumArea(o(g(l[1],-1)),!0,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(l[0])||h(l[0])){const n=v(l[0],t.spatialReference);return null===n?0:_(n,o(g(l[1],-1)))}if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);return _(l[0],o(g(l[1],-1)))}))},n.functions.length=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,o)=>{if(u(o,1,2,t,e),null===(o=s(o))[0])return 0;if(p(o[0])){const n=await o[0].sumLength(l(g(o[1],-1)),!1,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(o[0])||h(o[0])){const n=P(o[0],t.spatialReference);return null===n?0:nn(n,l(g(o[1],-1)))}if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return nn(o[0],l(g(o[1],-1)))}))},n.functions.length3d=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(u(o,1,2,t,e),null===(o=s(o))[0])return 0;if(w(o[0])||h(o[0])){const n=P(o[0],t.spatialReference);return null===n?0:!0===n.hasZ?jn(n,l(g(o[1],-1))):nn(n,l(g(o[1],-1)))}if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return!0===o[0].hasZ?jn(o[0],l(g(o[1],-1))):nn(o[0],l(g(o[1],-1)))}))},n.functions.lengthgeodetic=function(t,e){return n.standardFunctionAsync(t,e,(async(n,a,o)=>{if(u(o,1,2,t,e),null===(o=s(o))[0])return 0;if(p(o[0])){const n=await o[0].sumLength(l(g(o[1],-1)),!0,t.abortSignal);if(t.abortSignal.aborted)throw new r(t,i.Cancelled,e);return n}if(w(o[0])||h(o[0])){const n=P(o[0],t.spatialReference);return null===n?0:tn(n,l(g(o[1],-1)))}if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return tn(o[0],l(g(o[1],-1)))}))},n.functions.distance=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{o=s(o),u(o,2,3,t,e);let c=o[0];(w(o[0])||h(o[0]))&&(c=I(o[0],t.spatialReference));let f=o[1];if((w(o[1])||h(o[1]))&&(f=I(o[1],t.spatialReference)),!(c instanceof J))throw new r(t,i.InvalidParameter,e);if(!(f instanceof J))throw new r(t,i.InvalidParameter,e);return en(c,f,l(g(o[2],-1)))}))},n.functions.distancegeodetic=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{o=s(o),u(o,2,3,t,e);const c=o[0],f=o[1];if(!(c instanceof pn))throw new r(t,i.InvalidParameter,e);if(!(f instanceof pn))throw new r(t,i.InvalidParameter,e);const d=new vn({paths:[],spatialReference:c.spatialReference});return d.addPath([c,f]),tn(d,l(g(o[2],-1)))}))},n.functions.densify=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,3,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);if(c<=0)throw new r(t,i.InvalidParameter,e);return o[0]instanceof gn||o[0]instanceof vn?rn(o[0],c,l(g(o[2],-1))):o[0]instanceof T?rn(Fn(o[0]),c,l(g(o[2],-1))):o[0]}))},n.functions.densifygeodetic=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,3,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);if(c<=0)throw new r(t,i.InvalidParameter,e);return o[0]instanceof gn||o[0]instanceof vn?an(o[0],c,l(g(o[2],-1))):o[0]instanceof T?an(Fn(o[0]),c,l(g(o[2],-1))):o[0]}))},n.functions.generalize=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,4,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);return on(o[0],c,F(g(o[2],!0)),l(g(o[3],-1)))}))},n.functions.buffer=function(t,e){return n.standardFunctionAsync(t,e,((n,o,c)=>{if(c=s(c),u(c,2,3,t,e),null===c[0])return null;if(!(c[0]instanceof J))throw new r(t,i.InvalidParameter,e);const f=A(c[1]);if(isNaN(f))throw new r(t,i.InvalidParameter,e);return 0===f?a(c[0]):ln(c[0],f,l(g(c[2],-1)))}))},n.functions.buffergeodetic=function(t,e){return n.standardFunctionAsync(t,e,((n,o,c)=>{if(c=s(c),u(c,2,3,t,e),null===c[0])return null;if(!(c[0]instanceof J))throw new r(t,i.InvalidParameter,e);const f=A(c[1]);if(isNaN(f))throw new r(t,i.InvalidParameter,e);return 0===f?a(c[0]):sn(c[0],f,l(g(c[2],-1)))}))},n.functions.offset=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,6,t,e),null===o[0])return null;if(!(o[0]instanceof gn||o[0]instanceof vn))throw new r(t,i.InvalidParameter,e);const c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);const f=A(g(o[4],10));if(isNaN(f))throw new r(t,i.InvalidParameter,e);const d=A(g(o[5],0));if(isNaN(d))throw new r(t,i.InvalidParameter,e);return un(o[0],c,l(g(o[2],-1)),m(g(o[3],"round")).toLowerCase(),f,d)}))},n.functions.rotate=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,2,3,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);const l=o[0]instanceof T?gn.fromExtent(o[0]):o[0],c=A(o[1]);if(isNaN(c))throw new r(t,i.InvalidParameter,e);const f=g(o[2],null);if(null===f)return cn(l,c);if(f instanceof pn)return cn(l,c,f);throw new r(t,i.InvalidParameter,e)}))},n.functions.centroid=function(t,e){return n.standardFunctionAsync(t,e,((n,o,l)=>{if(l=s(l),u(l,1,1,t,e),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=I(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,e);return c instanceof pn?y(a(c),t.spatialReference):c instanceof gn?c.centroid:c instanceof vn?b(c):c instanceof yn?N(c):c instanceof T?c.center:null}))},n.functions.measuretocoordinate=function(t,a){return n.standardFunctionAsync(t,a,((n,o,l)=>{if(l=s(l),u(l,2,2,t,a),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=P(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,a);if(!(c instanceof vn))throw new r(t,i.InvalidParameter,a);if(R(!1===l[1]))throw new r(t,i.InvalidParameter,a);const f=D(c,l[1]);return f?e.convertObjectToArcadeDictionary(f,j(t),!1,!0):null}))},n.functions.pointtocoordinate=function(t,a){return n.standardFunctionAsync(t,a,((n,o,l)=>{if(l=s(l),u(l,2,2,t,a),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=P(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,a);if(!(c instanceof vn))throw new r(t,i.InvalidParameter,a);const f=l[1];if(null===f)return null;if(!(f instanceof pn))throw new r(t,i.InvalidParameter,a);if(R(!1===l[1]))throw new r(t,i.InvalidParameter,a);const d=k(c,f);return d?e.convertObjectToArcadeDictionary(d,j(t),!1,!0):null}))},n.functions.distancetocoordinate=function(t,a){return n.standardFunctionAsync(t,a,((n,o,l)=>{if(l=s(l),u(l,2,2,t,a),null===l[0])return null;let c=l[0];if((w(l[0])||h(l[0]))&&(c=P(l[0],t.spatialReference)),null===c)return null;if(!(c instanceof J))throw new r(t,i.InvalidParameter,a);if(!(c instanceof vn))throw new r(t,i.InvalidParameter,a);if(R(!1===l[1]))throw new r(t,i.InvalidParameter,a);const f=L(c,l[1]);return f?e.convertObjectToArcadeDictionary(f,j(t),!1,!0):null}))},n.functions.multiparttosinglepart=function(t,e){return n.standardFunctionAsync(t,e,(async(n,o,l)=>{if(l=s(l),u(l,1,1,t,e),null===l[0])return null;if(!(l[0]instanceof J))throw new r(t,i.InvalidParameter,e);if(l[0]instanceof pn)return[y(a(l[0]),t.spatialReference)];if(l[0]instanceof T)return[y(a(l[0]),t.spatialReference)];const c=await fn(l[0]);if(c instanceof gn){const n=[],t=[];for(let e=0;e<c.rings.length;e++)if(c.isClockwise(c.rings[e])){const t=Pn({rings:[c.rings[e]],hasZ:!0===c.hasZ,hasM:!0===c.hasM,spatialReference:c.spatialReference.toJSON()});n.push(t)}else t.push({ring:c.rings[e],pt:c.getPoint(e,0)});for(let e=0;e<t.length;e++)for(let r=0;r<n.length;r++)if(n[r].contains(t[e].pt)){n[r].addRing(t[e].ring);break}return n}if(c instanceof vn){const n=[];for(let t=0;t<c.paths.length;t++){const e=Pn({paths:[c.paths[t]],hasZ:!0===c.hasZ,hasM:!0===c.hasM,spatialReference:c.spatialReference.toJSON()});n.push(e)}return n}if(l[0]instanceof yn){const n=[],e=y(a(l[0]),t.spatialReference);for(let t=0;t<e.points.length;t++)n.push(e.getPoint(t));return n}return null}))},n.functions.issimple=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,1,1,t,e),null===o[0])return!0;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return dn(o[0])}))},n.functions.simplify=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,1,1,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return fn(o[0])}))},n.functions.convexhull=function(t,e){return n.standardFunctionAsync(t,e,((n,a,o)=>{if(o=s(o),u(o,1,1,t,e),null===o[0])return null;if(!(o[0]instanceof J))throw new r(t,i.InvalidParameter,e);return mn(o[0])}))},n.functions.getuser=function(a,o){return n.standardFunctionAsync(a,o,(async(n,l,s)=>{u(s,0,2,a,o);let c=g(s[1],""),f=!0===c;if(c=!0===c||!1===c?"":m(c),0===s.length||s[0]instanceof t){let n;n=a.services?.portal?a.services.portal:In.getDefault(),s.length>0&&(n=x(s[0],n));const t=await An(n,c,f);if(t){const n=JSON.parse(JSON.stringify(t));for(const t of["lastLogin","created","modified"])void 0!==n[t]&&null!==n[t]&&(n[t]=new Date(n[t]));return e.convertObjectToArcadeDictionary(n,j(a))}return null}let d=null;if(p(s[0])&&(d=s[0]),d){if(f=!1,c)return null;await d.load();const n=await d.getOwningSystemUrl();if(!n){if(!c){const n=await d.getIdentityUser();return n?e.convertObjectToArcadeDictionary({username:n},j(a)):null}return null}let r;r=a.services?.portal?a.services.portal:In.getDefault(),r=x(new t(n),r);const i=await An(r,c,f);if(i){const n=JSON.parse(JSON.stringify(i));for(const t of["lastLogin","created","modified"])void 0!==n[t]&&null!==n[t]&&(n[t]=new Date(n[t]));return e.convertObjectToArcadeDictionary(n,j(a))}return null}throw new r(a,i.InvalidParameter,o)}))},n.functions.nearestcoordinate=function(t,a){return n.standardFunctionAsync(t,a,(async(n,o,l)=>{if(l=s(l),u(l,2,2,t,a),!(l[0]instanceof J||null===l[0]))throw new r(t,i.InvalidParameter,a);if(!(l[1]instanceof pn||null===l[1]))throw new r(t,i.InvalidParameter,a);if(null===l[0]||null===l[1])return null;const c=await wn(l[0],l[1]);return null===c?null:e.convertObjectToArcadeDictionary({coordinate:c.coordinate,distance:c.distance,sideOfLine:0===c.distance?"straddle":c.isRightSide?"right":"left"},j(t),!1,!0)}))},n.functions.nearestvertex=function(t,a){return n.standardFunctionAsync(t,a,(async(n,o,l)=>{if(l=s(l),u(l,2,2,t,a),!(l[0]instanceof J||null===l[0]))throw new r(t,i.InvalidParameter,a);if(!(l[1]instanceof pn||null===l[1]))throw new r(t,i.InvalidParameter,a);if(null===l[0]||null===l[1])return null;const c=await hn(l[0],l[1]);return null===c?null:e.convertObjectToArcadeDictionary({coordinate:c.coordinate,distance:c.distance,sideOfLine:0===c.distance?"straddle":c.isRightSide?"right":"left"},j(t),!1,!0)}))})}export{xn as registerFunctions};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../Dictionary.js";import{ArcadeExecutionError as t,ExecutionErrorCodes as n}from"../executionError.js";import r from"../Feature.js";import a from"../ImmutablePathArray.js";import i from"../ImmutablePointArray.js";import{H as l,o as s,q as o,x as f,S as c,I as u,B as m,c as p,j as h,k as w,b as d,n as y,m as R,a as g,i as I,f as v,N as P,r as b,F,L as x}from"../../chunks/languageUtils.js";import{angle2D as O,angleBetween2D as S,bearing2D as j,bearingBetween2D as N,pathsSelfIntersecting as k}from"./centroid.js";import J from"../../geometry/Extent.js";import D from"../../geometry/Geometry.js";import z from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import Z from"../../geometry/Polygon.js";import C from"../../geometry/Polyline.js";import{isClockwise as _}from"../../geometry/support/coordsUtils.js";import{fromJSON as M}from"../../geometry/support/jsonUtils.js";function A(e){return e&&"esri.arcade.Feature"===e.arcadeDeclaredClass}function W(a,W){a.ringisclockwise=function(e,r){return W(e,r,((a,f,c)=>{l(c,1,1,e,r);let u=[];if(null===c[0])return!1;if(s(c[0]))for(const i of c[0]){if(!(i instanceof G))throw new t(e,n.InvalidParameter,r);u.push(i.hasZ?i.hasM?[i.x,i.y,i.z,i.m]:[i.x,i.y,i.z]:[i.x,i.y])}else if(c[0]instanceof i)u=c[0]._elements;else{if(!o(c[0]))throw new t(e,n.InvalidParameter,r);for(const a of c[0].toArray()){if(!(a instanceof G))throw new t(e,n.InvalidParameter,r);u.push(a.hasZ?a.hasM?[a.x,a.y,a.z,a.m]:[a.x,a.y,a.z]:[a.x,a.y])}}return!(u.length<3)&&_(u)}))},a.polygon=function(a,i){return W(a,i,((s,o,u)=>{l(u,1,1,a,i);let m=null;if(u[0]instanceof e){if(m=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference),m instanceof Z==!1)throw new t(a,n.InvalidParameter,i)}else if(u[0]instanceof Z)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new Z(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.polyline=function(a,i){return W(a,i,((s,o,u)=>{l(u,1,1,a,i);let m=null;if(u[0]instanceof e){if(m=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference),m instanceof C==!1)throw new t(a,n.InvalidParameter,i)}else if(u[0]instanceof C)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new C(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.point=function(a,i){return W(a,i,((s,o,u)=>{l(u,1,1,a,i);let m=null;if(u[0]instanceof e){if(m=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference),m instanceof G==!1)throw new t(a,n.InvalidParameter,i)}else if(u[0]instanceof G)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new G(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.multipoint=function(a,i){return W(a,i,((s,o,u)=>{l(u,1,1,a,i);let m=null;if(u[0]instanceof e){if(m=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference),m instanceof z==!1)throw new t(a,n.InvalidParameter,i)}else if(u[0]instanceof z)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new z(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.extent=function(a,i){return W(a,i,((s,o,m)=>{m=u(m),l(m,1,1,a,i);let p=null;if(m[0]instanceof e)p=f(r.parseGeometryFromDictionary(m[0],a.spatialReference),a.spatialReference);else if(m[0]instanceof G){const e={xmin:m[0].x,ymin:m[0].y,xmax:m[0].x,ymax:m[0].y,spatialReference:m[0].spatialReference.toJSON()},t=m[0];t.hasZ?(e.zmin=t.z,e.zmax=t.z):t.hasM&&(e.mmin=t.m,e.mmax=t.m),p=M(e)}else if(m[0]instanceof Z)p=M(m[0].extent?.toJSON());else if(m[0]instanceof C)p=M(m[0].extent?.toJSON());else if(m[0]instanceof z)p=M(m[0].extent?.toJSON());else if(m[0]instanceof J)p=M(m[0].toJSON());else{const e=JSON.parse(m[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),p=f(new J(e),a.spatialReference)}if(null!==p&&!1===p.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(p)}))},a.geometry=function(a,i){return W(a,i,((s,o,u)=>{l(u,1,1,a,i);let m=null;if(null===u[0])return null;if(A(u[0]))m=f(u[0].geometry(),a.spatialReference);else if(u[0]instanceof e)m=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference);else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(M(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.setgeometry=function(e,r){return W(e,r,((a,i,s)=>{if(l(s,2,2,e,r),!A(s[0]))throw new t(e,n.InvalidParameter,r);if(!0===s[0].immutable)throw new t(e,n.Immutable,r);if(!(s[1]instanceof D||null===s[1]))throw new t(e,n.InvalidParameter,r);return s[0]._geometry=s[1],m}))},a.feature=function(a,i){return W(a,i,((l,s,o)=>{if(0===o.length)throw new t(a,n.WrongNumberOfParameters,i);let c=null;if(1===o.length)if(p(o[0]))c=r.fromJson(JSON.parse(o[0]),a.timeZone);else if(A(o[0]))c=r.createFromArcadeFeature(o[0]);else if(o[0]instanceof D)c=r.createFromGraphicLikeObject(o[0],null,null,a.timeZone);else{if(!(o[0]instanceof e))throw new t(a,n.InvalidParameter,i);{let t=o[0].hasField("geometry")?o[0].field("geometry"):null,n=o[0].hasField("attributes")?o[0].field("attributes"):null;null!==t&&t instanceof e&&(t=r.parseGeometryFromDictionary(t,a.spatialReference)),null!==n&&(n=r.parseAttributesFromDictionary(n)),c=r.createFromGraphicLikeObject(t,n,null,a.timeZone)}}else if(2===o.length){let l=null,s=null;if(null!==o[0])if(o[0]instanceof D)l=o[0];else{if(!(l instanceof e))throw new t(a,n.InvalidParameter,i);l=r.parseGeometryFromDictionary(o[0],a.spatialReference)}if(null!==o[1]){if(!(o[1]instanceof e))throw new t(a,n.InvalidParameter,i);s=r.parseAttributesFromDictionary(o[1])}c=r.createFromGraphicLikeObject(l,s,null,a.timeZone)}else{let l=null;const s={};if(null!==o[0])if(o[0]instanceof D)l=o[0];else{if(!(l instanceof e))throw new t(a,n.InvalidParameter,i);l=r.parseGeometryFromDictionary(o[0],a.spatialReference)}for(let e=1;e<o.length;e+=2){const r=h(o[e]),l=o[e+1];if(!(null==l||p(l)||isNaN(l)||w(l)||d(l)||y(l)||R(l)||g(l)))throw new t(a,n.InvalidParameter,i);if(I(l)||!1===v(l))throw new t(a,n.InvalidParameter,i);s[r]=l===m?null:l}c=r.createFromGraphicLikeObject(l,s,null,a.timeZone)}return c._geometry=f(c.geometry(),a.spatialReference),c.immutable=!1,c}))},a.dictionary=function(r,a){return W(r,a,((i,l,f)=>{if(0===f.length||1===f.length&&null===f[0]){const t=new e;return t.immutable=!1,t}if(1===f.length&&p(f[0]))try{const t=JSON.parse(f[0]),n=e.convertObjectToArcadeDictionary(t,P(r),!1);return n.immutable=!1,n}catch(v){throw new t(r,n.InvalidParameter,a)}if(1===f.length&&f[0]instanceof D)try{const t=f[0].toJSON();t.hasZ=!0===f[0].hasZ,t.hasM=!0===f[0].hasM;const n=e.convertObjectToArcadeDictionary(t,P(r),!1);return n.immutable=!1,n}catch(v){throw new t(r,n.InvalidParameter,a)}if(1===f.length&&b(f[0]))try{const t=new e;t.immutable=!1,t.setField("geometry",f[0].geometry());const n=new e;n.immutable=!1,t.setField("attributes",n);for(const e of f[0].keys())n.setField(e,f[0].field(e));return t}catch(v){throw new t(r,n.InvalidParameter,a)}if(1===f.length&&f[0]instanceof e)try{const t=new e;t.immutable=!1;for(const e of f[0].keys())t.setField(e,f[0].field(e));return t}catch(v){throw new t(r,n.InvalidParameter,a)}if(2===f.length&&f[0]instanceof e&&g(f[1]))try{if(!(!0===f[1])){const t=new e;t.immutable=!1;for(const e of f[0].keys())t.setField(e,f[0].field(e));return t}return f[0].deepClone()}catch(v){throw new t(r,n.InvalidParameter,a)}if(f.length%2!=0)throw new t(r,n.WrongNumberOfParameters,a);const c={};for(let e=0;e<f.length;e+=2){const i=h(f[e]),l=f[e+1];if(!(null==l||p(l)||isNaN(l)||w(l)||d(l)||g(l)||R(l)||y(l)||s(l)||o(l)))throw new t(r,n.InvalidParameter,a);if(I(l))throw new t(r,n.InvalidParameter,a);c[i]=l===m?null:l}const u=new e(c);return u.immutable=!1,u}))},a.haskey=function(r,a){return W(r,a,((i,s,o)=>{l(o,2,2,r,a);const f=h(o[1]);if(A(o[0]))return o[0].hasField(f);if(o[0]instanceof e)return o[0].hasField(f);if(o[0]instanceof D){const e=L(o[0],f,null,null,2);return!e||"notfound"!==e.keystate}throw new t(r,n.InvalidParameter,a)}))},a.hasvalue=function(r,a){return W(r,a,((i,f,c)=>{if(l(c,2,2,r,a),s(c[1])||o(c[1])){const i=c[1];let l=[];if(o(i))l=i.toArray();else{if(!s(i))throw new t(r,n.InvalidParameter,a);l=i}let f=c[0];if(null===f)return!1;for(const t of l)if(b(f)){if(!1===p(t))return!1;if(!f.hasField(t))return!1;if(f=f.field(t),null===f)return!1}else if(f instanceof e){if(!1===p(t))return!1;if(!f.hasField(t))return!1;if(f=f.field(t),null===f)return!1}else if(f instanceof D){if(!1===p(t))return!1;if(f=L(f,t,null,null,0),null===f)return!1}else if(s(f)){if(!1===d(t))return!1;if(f=f[t],null==f)return!1}else{if(!o(f))return!1;if(!1===d(t))return!1;if(f=f.get(t),null==f)return!1}return!0}if(null===c[0]||null===c[1])return!1;const u=h(c[1]);if(b(c[0]))return!!c[0].hasField(u)&&null!==c[0].field(u);if(c[0]instanceof e)return!!c[0].hasField(u)&&null!==c[0].field(u);if(c[0]instanceof D){return null!==L(c[0],u,null,null,0)}return!1}))},a.indexof=function(e,r){return W(e,r,((a,i,f)=>{l(f,2,2,e,r);const c=f[1];if(s(f[0])){for(let e=0;e<f[0].length;e++)if(F(c,f[0][e]))return e;return-1}if(o(f[0])){const e=f[0].length();for(let t=0;t<e;t++)if(F(c,f[0].get(t)))return t;return-1}throw new t(e,n.InvalidParameter,r)}))},a.angle=function(e,r){return W(e,r,((a,i,s)=>{if(s=u(s),l(s,2,3,e,r),!(s[0]instanceof G))throw new t(e,n.InvalidParameter,r);if(!(s[1]instanceof G))throw new t(e,n.InvalidParameter,r);if(s.length>2&&!(s[2]instanceof G))throw new t(e,n.InvalidParameter,r);return 2===s.length?O(s[0],s[1]):S(s[0],s[1],s[2])}))},a.bearing=function(e,r){return W(e,r,((a,i,s)=>{if(s=u(s),l(s,2,3,e,r),!(s[0]instanceof G))throw new t(e,n.InvalidParameter,r);if(!(s[1]instanceof G))throw new t(e,n.InvalidParameter,r);if(s.length>2&&!(s[2]instanceof G))throw new t(e,n.InvalidParameter,r);return 2===s.length?j(s[0],s[1]):N(s[0],s[1],s[2])}))},a.isselfintersecting=function(e,t){return W(e,t,((n,r,a)=>{a=u(a),l(a,1,1,e,t);let i=a[0];if(i instanceof Z)return i.isSelfIntersecting;if(i instanceof C)return i=i.paths,k(i);if(i instanceof z){const e=i.points;for(let t=0;t<e.length;t++)for(let n=0;n<e.length;n++)if(n!==t){let r=!0;for(let a=0;a<e[t].length;a++)if(e[t][a]!==e[n][a]){r=!1;break}if(!0===r)return!0}}return!(!s(i)&&!o(i))&&(i=x(i,e.spatialReference),null!==i&&(i=i.paths),k(i))}))}}let q=0;function L(r,l,s,o,f=1){let c;switch(l=l.toLowerCase()){case"hasz":{const e=r.hasZ;return void 0!==e&&e}case"hasm":{const e=r.hasM;return void 0!==e&&e}case"spatialreference":{let t=r.spatialReference._arcadeCacheId;if(void 0===t){let e=!0;Object.freeze&&Object.isFrozen(r.spatialReference)&&(e=!1),e&&(q++,r.spatialReference._arcadeCacheId=q,t=q)}const n=new e({wkt:r.spatialReference.wkt,wkid:r.spatialReference.wkid});return void 0!==t&&(n._arcadeCacheId="SPREF"+t.toString()),n}}switch(r.type){case"extent":switch(l){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=r[l];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(l){case"rings":c=r.cache._arcadeCacheId,void 0===c&&(q++,c=q,r.cache._arcadeCacheId=c);return new a(r.rings,r.spatialReference,!0===r.hasZ,!0===r.hasM,c);case"type":return"Polygon"}break;case"point":switch(l){case"x":case"y":case"z":case"m":return void 0!==r[l]?r[l]:null;case"type":return"Point"}break;case"polyline":switch(l){case"paths":c=r.cache._arcadeCacheId,void 0===c&&(q++,c=q,r.cache._arcadeCacheId=c);return new a(r.paths,r.spatialReference,!0===r.hasZ,!0===r.hasM,c);case"type":return"Polyline"}break;case"multipoint":switch(l){case"points":c=r.cache._arcadeCacheId,void 0===c&&(q++,c=q,r.cache._arcadeCacheId=c);return new i(r.points,r.spatialReference,!0===r.hasZ,!0===r.hasM,c,1);case"type":return"Multipoint"}}if(1===f)throw new t(s,n.InvalidIdentifier,o);return 2===f?{keystate:"notfound"}:null}export{L as geometryMember,W as registerFunctions};
|
|
5
|
+
import e from"../Dictionary.js";import{ArcadeExecutionError as t,ExecutionErrorCodes as n}from"../executionError.js";import r from"../Feature.js";import a from"../ImmutablePathArray.js";import i from"../ImmutablePointArray.js";import{H as s,o as l,q as o,x as f,S as c,I as u,r as m,B as p,c as h,j as w,k as d,b as y,n as R,m as g,a as I,i as v,f as P,N as b,F,L as x}from"../../chunks/languageUtils.js";import{angle2D as O,angleBetween2D as S,bearing2D as j,bearingBetween2D as N,pathsSelfIntersecting as k}from"./centroid.js";import J from"../../geometry/Extent.js";import z from"../../geometry/Geometry.js";import D from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import Z from"../../geometry/Polygon.js";import _ from"../../geometry/Polyline.js";import{isClockwise as C}from"../../geometry/support/coordsUtils.js";import{fromJSON as M}from"../../geometry/support/jsonUtils.js";function A(a,A){a.ringisclockwise=function(e,r){return A(e,r,((a,f,c)=>{s(c,1,1,e,r);let u=[];if(null===c[0])return!1;if(l(c[0]))for(const i of c[0]){if(!(i instanceof G))throw new t(e,n.InvalidParameter,r);u.push(i.hasZ?i.hasM?[i.x,i.y,i.z,i.m]:[i.x,i.y,i.z]:[i.x,i.y])}else if(c[0]instanceof i)u=c[0]._elements;else{if(!o(c[0]))throw new t(e,n.InvalidParameter,r);for(const a of c[0].toArray()){if(!(a instanceof G))throw new t(e,n.InvalidParameter,r);u.push(a.hasZ?a.hasM?[a.x,a.y,a.z,a.m]:[a.x,a.y,a.z]:[a.x,a.y])}}return!(u.length<3)&&C(u)}))},a.polygon=function(a,i){return A(a,i,((l,o,u)=>{let m;if(s(u,1,1,a,i),u[0]instanceof e){const e=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference);if(e instanceof Z==!1)throw new t(a,n.InvalidParameter,i);m=e}else if(u[0]instanceof Z)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new Z(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.polyline=function(a,i){return A(a,i,((l,o,u)=>{let m;if(s(u,1,1,a,i),u[0]instanceof e){const e=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference);if(e instanceof _==!1)throw new t(a,n.InvalidParameter,i);m=e}else if(u[0]instanceof _)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new _(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.point=function(a,i){return A(a,i,((l,o,u)=>{let m;if(s(u,1,1,a,i),u[0]instanceof e){const e=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference);if(e instanceof G==!1)throw new t(a,n.InvalidParameter,i);m=e}else if(u[0]instanceof G)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new G(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.multipoint=function(a,i){return A(a,i,((l,o,u)=>{let m;if(s(u,1,1,a,i),u[0]instanceof e){const e=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference);if(e instanceof D==!1)throw new t(a,n.InvalidParameter,i);m=e}else if(u[0]instanceof D)m=M(u[0].toJSON());else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),m=f(new D(e),a.spatialReference)}if(null!==m&&!1===m.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(m)}))},a.extent=function(a,i){return A(a,i,((l,o,m)=>{m=u(m),s(m,1,1,a,i);let p=null;if(m[0]instanceof e)p=f(r.parseGeometryFromDictionary(m[0],a.spatialReference),a.spatialReference);else if(m[0]instanceof G){const e={xmin:m[0].x,ymin:m[0].y,xmax:m[0].x,ymax:m[0].y,spatialReference:m[0].spatialReference.toJSON()},t=m[0];t.hasZ?(e.zmin=t.z,e.zmax=t.z):t.hasM&&(e.mmin=t.m,e.mmax=t.m),p=M(e)}else if(m[0]instanceof Z)p=M(m[0].extent?.toJSON());else if(m[0]instanceof _)p=M(m[0].extent?.toJSON());else if(m[0]instanceof D)p=M(m[0].extent?.toJSON());else if(m[0]instanceof J)p=M(m[0].toJSON());else{const e=JSON.parse(m[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),p=f(new J(e),a.spatialReference)}if(null!==p&&!1===p.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(p)}))},a.geometry=function(a,i){return A(a,i,((l,o,u)=>{s(u,1,1,a,i);let p=null;if(null===u[0])return null;if(m(u[0]))p=f(u[0].geometry(),a.spatialReference);else if(u[0]instanceof e)p=f(r.parseGeometryFromDictionary(u[0],a.spatialReference),a.spatialReference);else{const e=JSON.parse(u[0]);e&&!e.spatialReference&&(e.spatialReference=a.spatialReference),p=f(M(e),a.spatialReference)}if(null!==p&&!1===p.spatialReference.equals(a.spatialReference))throw new t(a,n.WrongSpatialReference,i);return c(p)}))},a.setgeometry=function(e,r){return A(e,r,((a,i,l)=>{if(s(l,2,2,e,r),!m(l[0]))throw new t(e,n.InvalidParameter,r);if(!0===l[0].immutable)throw new t(e,n.Immutable,r);if(!(l[1]instanceof z||null===l[1]))throw new t(e,n.InvalidParameter,r);return l[0]._geometry=l[1],p}))},a.feature=function(a,i){return A(a,i,((s,l,o)=>{if(0===o.length)throw new t(a,n.WrongNumberOfParameters,i);let c;if(1===o.length)if(h(o[0]))c=r.fromJson(JSON.parse(o[0]),a.timeZone);else if(m(o[0]))c=r.createFromArcadeFeature(o[0]);else if(o[0]instanceof z)c=r.createFromGraphicLikeObject(o[0],null,null,a.timeZone);else{if(!(o[0]instanceof e))throw new t(a,n.InvalidParameter,i);{let t=o[0].hasField("geometry")?o[0].field("geometry"):null,n=o[0].hasField("attributes")?o[0].field("attributes"):null;null!==t&&t instanceof e&&(t=r.parseGeometryFromDictionary(t,a.spatialReference)),null!==n&&(n=r.parseAttributesFromDictionary(n)),c=r.createFromGraphicLikeObject(t,n,null,a.timeZone)}}else if(2===o.length){let s=null,l=null;if(null!==o[0])if(o[0]instanceof z)s=o[0];else{if(!(s instanceof e))throw new t(a,n.InvalidParameter,i);s=r.parseGeometryFromDictionary(o[0],a.spatialReference)}if(null!==o[1]){if(!(o[1]instanceof e))throw new t(a,n.InvalidParameter,i);l=r.parseAttributesFromDictionary(o[1])}c=r.createFromGraphicLikeObject(s,l,null,a.timeZone)}else{let s=null;const l={};if(null!==o[0])if(o[0]instanceof z)s=o[0];else{if(!(s instanceof e))throw new t(a,n.InvalidParameter,i);s=r.parseGeometryFromDictionary(o[0],a.spatialReference)}for(let e=1;e<o.length;e+=2){const r=w(o[e]),s=o[e+1];if(!(null==s||h(s)||isNaN(s)||d(s)||y(s)||R(s)||g(s)||I(s)))throw new t(a,n.InvalidParameter,i);if(v(s)||!1===P(s))throw new t(a,n.InvalidParameter,i);l[r]=s===p?null:s}c=r.createFromGraphicLikeObject(s,l,null,a.timeZone)}return c._geometry=f(c.geometry(),a.spatialReference),c.immutable=!1,c}))},a.dictionary=function(r,a){return A(r,a,((i,s,f)=>{if(0===f.length||1===f.length&&null===f[0]){const t=new e;return t.immutable=!1,t}if(1===f.length&&h(f[0]))try{const t=JSON.parse(f[0]),n=e.convertObjectToArcadeDictionary(t,b(r),!1);return n.immutable=!1,n}catch(P){throw new t(r,n.InvalidParameter,a)}if(1===f.length&&f[0]instanceof z)try{const t=f[0].toJSON();t.hasZ=!0===f[0].hasZ,t.hasM=!0===f[0].hasM;const n=e.convertObjectToArcadeDictionary(t,b(r),!1);return n.immutable=!1,n}catch(P){throw new t(r,n.InvalidParameter,a)}if(1===f.length&&m(f[0]))try{const t=new e;t.immutable=!1,t.setField("geometry",f[0].geometry());const n=new e;n.immutable=!1,t.setField("attributes",n);for(const e of f[0].keys())n.setField(e,f[0].field(e));return t}catch(P){throw new t(r,n.InvalidParameter,a)}if(1===f.length&&f[0]instanceof e)try{const t=new e;t.immutable=!1;for(const e of f[0].keys())t.setField(e,f[0].field(e));return t}catch(P){throw new t(r,n.InvalidParameter,a)}if(2===f.length&&f[0]instanceof e&&I(f[1]))try{if(!(!0===f[1])){const t=new e;t.immutable=!1;for(const e of f[0].keys())t.setField(e,f[0].field(e));return t}return f[0].deepClone()}catch(P){throw new t(r,n.InvalidParameter,a)}if(f.length%2!=0)throw new t(r,n.WrongNumberOfParameters,a);const c={};for(let e=0;e<f.length;e+=2){const i=w(f[e]),s=f[e+1];if(!(null==s||h(s)||isNaN(s)||d(s)||y(s)||I(s)||g(s)||R(s)||l(s)||o(s)))throw new t(r,n.InvalidParameter,a);if(v(s))throw new t(r,n.InvalidParameter,a);c[i]=s===p?null:s}const u=new e(c);return u.immutable=!1,u}))},a.haskey=function(r,a){return A(r,a,((i,l,o)=>{s(o,2,2,r,a);const f=w(o[1]);if(m(o[0]))return o[0].hasField(f);if(o[0]instanceof e)return o[0].hasField(f);if(o[0]instanceof z){const e=q(o[0],f,null,null,2);return!e||"notfound"!==e.keystate}throw new t(r,n.InvalidParameter,a)}))},a.hasvalue=function(r,a){return A(r,a,((i,f,c)=>{if(s(c,2,2,r,a),l(c[1])||o(c[1])){const i=c[1];let s=[];if(o(i))s=i.toArray();else{if(!l(i))throw new t(r,n.InvalidParameter,a);s=i}let f=c[0];if(null===f)return!1;for(const t of s)if(m(f)){if(!1===h(t))return!1;if(!f.hasField(t))return!1;if(f=f.field(t),null===f)return!1}else if(f instanceof e){if(!1===h(t))return!1;if(!f.hasField(t))return!1;if(f=f.field(t),null===f)return!1}else if(f instanceof z){if(!1===h(t))return!1;if(f=q(f,t,null,null,0),null===f)return!1}else if(l(f)){if(!1===y(t))return!1;if(f=f[t],null==f)return!1}else{if(!o(f))return!1;if(!1===y(t))return!1;if(f=f.get(t),null==f)return!1}return!0}if(null===c[0]||null===c[1])return!1;const u=w(c[1]);if(m(c[0]))return!!c[0].hasField(u)&&null!==c[0].field(u);if(c[0]instanceof e)return!!c[0].hasField(u)&&null!==c[0].field(u);if(c[0]instanceof z){return null!==q(c[0],u,null,null,0)}return!1}))},a.indexof=function(e,r){return A(e,r,((a,i,f)=>{s(f,2,2,e,r);const c=f[1];if(l(f[0])){for(let e=0;e<f[0].length;e++)if(F(c,f[0][e]))return e;return-1}if(o(f[0])){const e=f[0].length();for(let t=0;t<e;t++)if(F(c,f[0].get(t)))return t;return-1}throw new t(e,n.InvalidParameter,r)}))},a.angle=function(e,r){return A(e,r,((a,i,l)=>{if(l=u(l),s(l,2,3,e,r),!(l[0]instanceof G))throw new t(e,n.InvalidParameter,r);if(!(l[1]instanceof G))throw new t(e,n.InvalidParameter,r);if(l.length>2&&!(l[2]instanceof G))throw new t(e,n.InvalidParameter,r);return 2===l.length?O(l[0],l[1]):S(l[0],l[1],l[2])}))},a.bearing=function(e,r){return A(e,r,((a,i,l)=>{if(l=u(l),s(l,2,3,e,r),!(l[0]instanceof G))throw new t(e,n.InvalidParameter,r);if(!(l[1]instanceof G))throw new t(e,n.InvalidParameter,r);if(l.length>2&&!(l[2]instanceof G))throw new t(e,n.InvalidParameter,r);return 2===l.length?j(l[0],l[1]):N(l[0],l[1],l[2])}))},a.isselfintersecting=function(e,t){return A(e,t,((n,r,a)=>{a=u(a),s(a,1,1,e,t);let i=a[0];if(i instanceof Z)return i.isSelfIntersecting;if(i instanceof _)return k(i.paths);if(i instanceof D){const e=i.points;for(let t=0;t<e.length;t++)for(let n=0;n<e.length;n++)if(n!==t){let r=!0;for(let a=0;a<e[t].length;a++)if(e[t][a]!==e[n][a]){r=!1;break}if(!0===r)return!0}}if(l(i)||o(i)){const t=x(i,e.spatialReference);return null!==t&&(i=t.paths),k(i)}return!1}))}}let W=0;function q(r,s,l,o,f=1){let c;switch(s=s.toLowerCase()){case"hasz":{const e=r.hasZ;return void 0!==e&&e}case"hasm":{const e=r.hasM;return void 0!==e&&e}case"spatialreference":{let t=r.spatialReference._arcadeCacheId;if(void 0===t){let e=!0;Object.freeze&&Object.isFrozen(r.spatialReference)&&(e=!1),e&&(W++,r.spatialReference._arcadeCacheId=W,t=W)}const n=new e({wkt:r.spatialReference.wkt,wkid:r.spatialReference.wkid});return void 0!==t&&(n._arcadeCacheId="SPREF"+t.toString()),n}}switch(r.type){case"extent":switch(s){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=r[s];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(s){case"rings":c=r.cache._arcadeCacheId,void 0===c&&(W++,c=W,r.cache._arcadeCacheId=c);return new a(r.rings,r.spatialReference,!0===r.hasZ,!0===r.hasM,c);case"type":return"Polygon"}break;case"point":switch(s){case"x":case"y":case"z":case"m":return r[s]??null;case"type":return"Point"}break;case"polyline":switch(s){case"paths":c=r.cache._arcadeCacheId,void 0===c&&(W++,c=W,r.cache._arcadeCacheId=c);return new a(r.paths,r.spatialReference,!0===r.hasZ,!0===r.hasM,c);case"type":return"Polyline"}break;case"multipoint":switch(s){case"points":c=r.cache._arcadeCacheId,void 0===c&&(W++,c=W,r.cache._arcadeCacheId=c);return new i(r.points,r.spatialReference,!0===r.hasZ,!0===r.hasM,c,1);case"type":return"Multipoint"}}if(1===f)throw new t(l,n.InvalidIdentifier,o);return 2===f?{keystate:"notfound"}:null}export{q as geometryMember,A as registerFunctions};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{version as n}from"../../kernel.js";import e from"../Dictionary.js";import{ArcadeExecutionError as t,ExecutionErrorCodes as r}from"../executionError.js";import{cloneGeometry as i,convertSquareUnitsToCode as a,convertLinearUnitsToCode as l}from"../kernel.js";import{I as o,H as f,k as u,n as s,m as c,j as m,o as d,q as h,x as w,J as p,K as g,L as v,M as P,g as I,h as y,b as R,N as x}from"../../chunks/languageUtils.js";import{centroidPolyline as j,centroidMultiPoint as N,getMetersPerVerticalUnitForSR as b,segmentLength3d as L}from"./centroid.js";import{measureToCoordinate as O,pointToCoordinate as A,distanceToCoordinate as D}from"./measures.js";import{getMetersPerUnitForSR as k}from"../../core/unitUtils.js";import M from"../../geometry/Extent.js";import Z from"../../geometry/Geometry.js";import E from"../../geometry/Multipoint.js";import S from"../../geometry/Point.js";import T from"../../geometry/Polygon.js";import q from"../../geometry/Polyline.js";import{fromJSON as z}from"../../geometry/support/jsonUtils.js";let C=null;function J(e){return 0===n.indexOf("4.")?T.fromExtent(e):new T({spatialReference:e.spatialReference,rings:[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}function U(n){C=n}function W(n,e){if("polygon"!==n.type&&"polyline"!==n.type&&"extent"!==n.type)return 0;let t=1;if(n.spatialReference.vcsWkid||n.spatialReference.latestVcsWkid){t=b(n.spatialReference)/k(n.spatialReference)}let r=0;if("polyline"===n.type)for(const a of n.paths)for(let n=1;n<a.length;n++)r+=L(a[n],a[n-1],t);else if("polygon"===n.type)for(const a of n.rings){for(let n=1;n<a.length;n++)r+=L(a[n],a[n-1],t);(a[0][0]!==a[a.length-1][0]||a[0][1]!==a[a.length-1][1]||void 0!==a[0][2]&&a[0][2]!==a[a.length-1][2])&&(r+=L(a[0],a[a.length-1],t))}else"extent"===n.type&&(r+=2*L([n.xmin,n.ymin,0],[n.xmax,n.ymin,0],t),r+=2*L([n.xmin,n.ymin,0],[n.xmin,n.ymax,0],t),r*=2,r+=4*Math.abs(g(n.zmax,0)*t-g(n.zmin,0)*t));const i=new q({hasZ:!1,hasM:!1,spatialReference:n.spatialReference,paths:[[0,0],[0,r]]});return C.planarLength(i,e)}function H(n,b){function L(n,e,i){if(f(i,2,2,n,e),i[0]instanceof Z&&i[1]instanceof Z);else if(i[0]instanceof Z&&null===i[1]);else if(i[1]instanceof Z&&null===i[0]);else if(null!==i[0]||null!==i[1])throw new t(n,r.InvalidParameter,e)}n.disjoint=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null===i[0]||null===i[1]||C.disjoint(i[0],i[1]))))},n.intersects=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.intersects(i[0],i[1]))))},n.touches=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.touches(i[0],i[1]))))},n.crosses=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.crosses(i[0],i[1]))))},n.within=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.within(i[0],i[1]))))},n.contains=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.contains(i[0],i[1]))))},n.overlaps=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.overlaps(i[0],i[1]))))},n.equals=function(n,e){return b(n,e,((t,r,i)=>(f(i,2,2,n,e),i[0]===i[1]||(i[0]instanceof Z&&i[1]instanceof Z?C.equals(i[0],i[1]):(u(i[0])&&u(i[1])||s(i[0])&&s(i[1])||!(!c(i[0])||!c(i[1])))&&i[0].equals(i[1])))))},n.relate=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,3,3,n,e),l[0]instanceof Z&&l[1]instanceof Z)return C.relate(l[0],l[1],m(l[2]));if(l[0]instanceof Z&&null===l[1])return!1;if(l[1]instanceof Z&&null===l[0])return!1;if(null===l[0]&&null===l[1])return!1;throw new t(n,r.InvalidParameter,e)}))},n.intersection=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null===i[0]||null===i[1]?null:C.intersect(i[0],i[1]))))},n.union=function(n,e){return b(n,e,((a,l,f)=>{const u=[];if(0===(f=o(f)).length)throw new t(n,r.WrongNumberOfParameters,e);if(1===f.length)if(d(f[0])){const i=o(f[0]);for(let a=0;a<i.length;a++)if(null!==i[a]){if(!(i[a]instanceof Z))throw new t(n,r.InvalidParameter,e);u.push(i[a])}}else{if(!h(f[0])){if(f[0]instanceof Z)return w(i(f[0]),n.spatialReference);if(null===f[0])return null;throw new t(n,r.InvalidParameter,e)}{const i=o(f[0].toArray());for(let a=0;a<i.length;a++)if(null!==i[a]){if(!(i[a]instanceof Z))throw new t(n,r.InvalidParameter,e);u.push(i[a])}}}else for(let i=0;i<f.length;i++)if(null!==f[i]){if(!(f[i]instanceof Z))throw new t(n,r.InvalidParameter,e);u.push(f[i])}return 0===u.length?null:C.union(u)}))},n.difference=function(n,e){return b(n,e,((t,r,a)=>(a=o(a),L(n,e,a),null!==a[0]&&null===a[1]?i(a[0]):null===a[0]?null:C.difference(a[0],a[1]))))},n.symmetricdifference=function(n,e){return b(n,e,((t,r,a)=>(a=o(a),L(n,e,a),null===a[0]&&null===a[1]?null:null===a[0]?i(a[1]):null===a[1]?i(a[0]):C.symmetricDifference(a[0],a[1]))))},n.clip=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,2,2,n,e),!(l[1]instanceof M)&&null!==l[1])throw new t(n,r.InvalidParameter,e);if(null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return null===l[1]?null:C.clip(l[0],l[1])}))},n.cut=function(n,e){return b(n,e,((a,l,u)=>{if(u=o(u),f(u,2,2,n,e),!(u[1]instanceof q)&&null!==u[1])throw new t(n,r.InvalidParameter,e);if(null===u[0])return[];if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return null===u[1]?[i(u[0])]:C.cut(u[0],u[1])}))},n.area=function(n,e){return b(n,e,((i,l,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=p(u[0],n.spatialReference);return null===e?0:C.planarArea(e,a(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.planarArea(u[0],a(g(u[1],-1)))}))},n.areageodetic=function(n,e){return b(n,e,((i,l,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=p(u[0],n.spatialReference);return null===e?0:C.geodesicArea(e,a(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.geodesicArea(u[0],a(g(u[1],-1)))}))},n.length=function(n,e){return b(n,e,((i,a,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=v(u[0],n.spatialReference);return null===e?0:C.planarLength(e,l(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.planarLength(u[0],l(g(u[1],-1)))}))},n.length3d=function(n,e){return b(n,e,((i,a,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=v(u[0],n.spatialReference);return null===e?0:!0===e.hasZ?W(e,l(g(u[1],-1))):C.planarLength(e,l(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return!0===u[0].hasZ?W(u[0],l(g(u[1],-1))):C.planarLength(u[0],l(g(u[1],-1)))}))},n.lengthgeodetic=function(n,e){return b(n,e,((i,a,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=v(u[0],n.spatialReference);return null===e?0:C.geodesicLength(e,l(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.geodesicLength(u[0],l(g(u[1],-1)))}))},n.distance=function(n,e){return b(n,e,((i,a,u)=>{u=o(u),f(u,2,3,n,e);let s=u[0];(d(u[0])||h(u[0]))&&(s=P(u[0],n.spatialReference));let c=u[1];if((d(u[1])||h(u[1]))&&(c=P(u[1],n.spatialReference)),!(s instanceof Z))throw new t(n,r.InvalidParameter,e);if(!(c instanceof Z))throw new t(n,r.InvalidParameter,e);return C.distance(s,c,l(g(u[2],-1)))}))},n.distancegeodetic=function(n,e){return b(n,e,((i,a,u)=>{u=o(u),f(u,2,3,n,e);const s=u[0],c=u[1];if(!(s instanceof S))throw new t(n,r.InvalidParameter,e);if(!(c instanceof S))throw new t(n,r.InvalidParameter,e);const m=new q({paths:[],spatialReference:s.spatialReference});return m.addPath([s,c]),C.geodesicLength(m,l(g(u[2],-1)))}))},n.densify=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,3,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);if(s<=0)throw new t(n,r.InvalidParameter,e);return u[0]instanceof T||u[0]instanceof q?C.densify(u[0],s,l(g(u[2],-1))):u[0]instanceof M?C.densify(J(u[0]),s,l(g(u[2],-1))):u[0]}))},n.densifygeodetic=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,3,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);if(s<=0)throw new t(n,r.InvalidParameter,e);return u[0]instanceof T||u[0]instanceof q?C.geodesicDensify(u[0],s,l(g(u[2],-1))):u[0]instanceof M?C.geodesicDensify(J(u[0]),s,l(g(u[2],-1))):u[0]}))},n.generalize=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,4,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);return C.generalize(u[0],s,y(g(u[2],!0)),l(g(u[3],-1)))}))},n.buffer=function(n,e){return b(n,e,((a,u,s)=>{if(s=o(s),f(s,2,3,n,e),null===s[0])return null;if(!(s[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const c=I(s[1]);if(isNaN(c))throw new t(n,r.InvalidParameter,e);return 0===c?i(s[0]):C.buffer(s[0],c,l(g(s[2],-1)))}))},n.buffergeodetic=function(n,e){return b(n,e,((a,u,s)=>{if(s=o(s),f(s,2,3,n,e),null===s[0])return null;if(!(s[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const c=I(s[1]);if(isNaN(c))throw new t(n,r.InvalidParameter,e);return 0===c?i(s[0]):C.geodesicBuffer(s[0],c,l(g(s[2],-1)))}))},n.offset=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,6,n,e),null===u[0])return null;if(!(u[0]instanceof T||u[0]instanceof q))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);const c=I(g(u[4],10));if(isNaN(c))throw new t(n,r.InvalidParameter,e);const d=I(g(u[5],0));if(isNaN(d))throw new t(n,r.InvalidParameter,e);return C.offset(u[0],s,l(g(u[2],-1)),m(g(u[3],"round")).toLowerCase(),c,d)}))},n.rotate=function(n,e){return b(n,e,((i,a,l)=>{l=o(l),f(l,2,3,n,e);let u=l[0];if(null===u)return null;if(!(u instanceof Z))throw new t(n,r.InvalidParameter,e);u instanceof M&&(u=T.fromExtent(u));const s=I(l[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);const c=g(l[2],null);if(null===c)return C.rotate(u,s);if(c instanceof S)return C.rotate(u,s,c);throw new t(n,r.InvalidParameter,e)}))},n.centroid=function(n,e){return b(n,e,((a,l,u)=>{if(u=o(u),f(u,1,1,n,e),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=P(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,e);return s instanceof S?w(i(u[0]),n.spatialReference):s instanceof T?s.centroid:s instanceof q?j(s):s instanceof E?N(s):s instanceof M?s.center:null}))},n.measuretocoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=v(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,i);if(!(s instanceof q))throw new t(n,r.InvalidParameter,i);if(R(!1===u[1]))throw new t(n,r.InvalidParameter,i);const c=O(s,u[1]);return c?e.convertObjectToArcadeDictionary(c,x(n),!1,!0):null}))},n.pointtocoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=v(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,i);if(!(s instanceof q))throw new t(n,r.InvalidParameter,i);const c=u[1];if(null===c)return null;if(!(c instanceof S))throw new t(n,r.InvalidParameter,i);if(R(!1===u[1]))throw new t(n,r.InvalidParameter,i);const m=A(s,c);return m?e.convertObjectToArcadeDictionary(m,x(n),!1,!0):null}))},n.distancetocoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=v(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,i);if(!(s instanceof q))throw new t(n,r.InvalidParameter,i);if(R(!1===u[1]))throw new t(n,r.InvalidParameter,i);const c=D(s,u[1]);return c?e.convertObjectToArcadeDictionary(c,x(n),!1,!0):null}))},n.multiparttosinglepart=function(n,e){return b(n,e,((a,l,u)=>{u=o(u),f(u,1,1,n,e);const s=[];if(null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);if(u[0]instanceof S)return[w(i(u[0]),n.spatialReference)];if(u[0]instanceof M)return[w(i(u[0]),n.spatialReference)];const c=C.simplify(u[0]);if(c instanceof T){const n=[],e=[];for(let t=0;t<c.rings.length;t++)if(c.isClockwise(c.rings[t])){const e=z({rings:[c.rings[t]],hasZ:!0===c.hasZ,hasM:!0===c.hasM,spatialReference:c.spatialReference.toJSON()});n.push(e)}else e.push({ring:c.rings[t],pt:c.getPoint(t,0)});for(let t=0;t<e.length;t++)for(let r=0;r<n.length;r++)if(n[r].contains(e[t].pt)){n[r].addRing(e[t].ring);break}return n}if(c instanceof q){const n=[];for(let e=0;e<c.paths.length;e++){const t=z({paths:[c.paths[e]],hasZ:!0===c.hasZ,hasM:!0===c.hasM,spatialReference:c.spatialReference.toJSON()});n.push(t)}return n}if(u[0]instanceof E){const e=w(i(u[0]),n.spatialReference);for(let n=0;n<e.points.length;n++)s.push(e.getPoint(n));return s}return null}))},n.issimple=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,1,1,n,e),null===l[0])return!0;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.isSimple(l[0])}))},n.simplify=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,1,1,n,e),null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.simplify(l[0])}))},n.convexhull=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,1,1,n,e),null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.convexHull(l[0])}))},n.nearestcoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),!(u[0]instanceof Z||null===u[0]))throw new t(n,r.InvalidParameter,i);if(!(u[1]instanceof S||null===u[1]))throw new t(n,r.InvalidParameter,i);if(null===u[0]||null===u[1])return null;const s=C.nearestCoordinate(u[0],u[1]);return null===s||s.isEmpty?null:e.convertObjectToArcadeDictionary({coordinate:s.coordinate,distance:s.distance,sideOfLine:0===s.distance?"straddle":s.isRightSide?"right":"left"},x(n),!1,!0)}))},n.nearestvertex=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),!(u[0]instanceof Z||null===u[0]))throw new t(n,r.InvalidParameter,i);if(!(u[1]instanceof S||null===u[1]))throw new t(n,r.InvalidParameter,i);if(null===u[0]||null===u[1])return null;const s=C.nearestVertex(u[0],u[1]);return null===s||s.isEmpty?null:e.convertObjectToArcadeDictionary({coordinate:s.coordinate,distance:s.distance,sideOfLine:0===s.distance?"straddle":s.isRightSide?"right":"left"},x(n),!1,!0)}))}}export{H as registerFunctions,U as setGeometryEngine};
|
|
5
|
+
import{version as n}from"../../kernel.js";import e from"../Dictionary.js";import{ArcadeExecutionError as t,ExecutionErrorCodes as r}from"../executionError.js";import{cloneGeometry as i,convertSquareUnitsToCode as a,convertLinearUnitsToCode as l}from"../kernel.js";import{I as o,H as f,k as u,n as s,m as c,j as m,o as d,q as h,x as w,J as p,K as g,L as v,M as P,g as I,h as y,b as R,N as x}from"../../chunks/languageUtils.js";import{centroidPolyline as j,centroidMultiPoint as N,getMetersPerVerticalUnitForSR as b,segmentLength3d as L}from"./centroid.js";import{measureToCoordinate as O,pointToCoordinate as A,distanceToCoordinate as D}from"./measures.js";import{getMetersPerUnitForSR as k}from"../../core/unitUtils.js";import M from"../../geometry/Extent.js";import Z from"../../geometry/Geometry.js";import E from"../../geometry/Multipoint.js";import S from"../../geometry/Point.js";import T from"../../geometry/Polygon.js";import q from"../../geometry/Polyline.js";import{fromJSON as z}from"../../geometry/support/jsonUtils.js";let C=null;function J(e){return 0===n.indexOf("4.")?T.fromExtent(e):new T({spatialReference:e.spatialReference,rings:[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}function U(n){C=n}function W(n,e){if("polygon"!==n.type&&"polyline"!==n.type&&"extent"!==n.type)return 0;let t=1;if(n.spatialReference.vcsWkid||n.spatialReference.latestVcsWkid){t=b(n.spatialReference)/k(n.spatialReference)}let r=0;if("polyline"===n.type)for(const a of n.paths)for(let n=1;n<a.length;n++)r+=L(a[n],a[n-1],t);else if("polygon"===n.type)for(const a of n.rings){for(let n=1;n<a.length;n++)r+=L(a[n],a[n-1],t);(a[0][0]!==a[a.length-1][0]||a[0][1]!==a[a.length-1][1]||void 0!==a[0][2]&&a[0][2]!==a[a.length-1][2])&&(r+=L(a[0],a[a.length-1],t))}else"extent"===n.type&&(r+=2*L([n.xmin,n.ymin,0],[n.xmax,n.ymin,0],t),r+=2*L([n.xmin,n.ymin,0],[n.xmin,n.ymax,0],t),r*=2,r+=4*Math.abs(g(n.zmax,0)*t-g(n.zmin,0)*t));const i=new q({hasZ:!1,hasM:!1,spatialReference:n.spatialReference,paths:[[0,0],[0,r]]});return C.planarLength(i,e)}function H(n,b){function L(n,e,i){if(f(i,2,2,n,e),i[0]instanceof Z&&i[1]instanceof Z);else if(i[0]instanceof Z&&null===i[1]);else if(i[1]instanceof Z&&null===i[0]);else if(null!==i[0]||null!==i[1])throw new t(n,r.InvalidParameter,e)}n.disjoint=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null===i[0]||null===i[1]||C.disjoint(i[0],i[1]))))},n.intersects=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.intersects(i[0],i[1]))))},n.touches=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.touches(i[0],i[1]))))},n.crosses=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.crosses(i[0],i[1]))))},n.within=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.within(i[0],i[1]))))},n.contains=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.contains(i[0],i[1]))))},n.overlaps=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null!==i[0]&&null!==i[1]&&C.overlaps(i[0],i[1]))))},n.equals=function(n,e){return b(n,e,((t,r,i)=>(f(i,2,2,n,e),i[0]===i[1]||(i[0]instanceof Z&&i[1]instanceof Z?C.equals(i[0],i[1]):(u(i[0])&&u(i[1])||s(i[0])&&s(i[1])||!(!c(i[0])||!c(i[1])))&&i[0].equals(i[1])))))},n.relate=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,3,3,n,e),l[0]instanceof Z&&l[1]instanceof Z)return C.relate(l[0],l[1],m(l[2]));if(l[0]instanceof Z&&null===l[1])return!1;if(l[1]instanceof Z&&null===l[0])return!1;if(null===l[0]&&null===l[1])return!1;throw new t(n,r.InvalidParameter,e)}))},n.intersection=function(n,e){return b(n,e,((t,r,i)=>(i=o(i),L(n,e,i),null===i[0]||null===i[1]?null:C.intersect(i[0],i[1]))))},n.union=function(n,e){return b(n,e,((a,l,f)=>{const u=[];if(0===(f=o(f)).length)throw new t(n,r.WrongNumberOfParameters,e);if(1===f.length)if(d(f[0])){const i=o(f[0]);for(let a=0;a<i.length;a++)if(null!==i[a]){if(!(i[a]instanceof Z))throw new t(n,r.InvalidParameter,e);u.push(i[a])}}else{if(!h(f[0])){if(f[0]instanceof Z)return w(i(f[0]),n.spatialReference);if(null===f[0])return null;throw new t(n,r.InvalidParameter,e)}{const i=o(f[0].toArray());for(let a=0;a<i.length;a++)if(null!==i[a]){if(!(i[a]instanceof Z))throw new t(n,r.InvalidParameter,e);u.push(i[a])}}}else for(let i=0;i<f.length;i++)if(null!==f[i]){if(!(f[i]instanceof Z))throw new t(n,r.InvalidParameter,e);u.push(f[i])}return 0===u.length?null:C.union(u)}))},n.difference=function(n,e){return b(n,e,((t,r,a)=>(a=o(a),L(n,e,a),null===a[0]?null:null===a[1]?i(a[0]):C.difference(a[0],a[1]))))},n.symmetricdifference=function(n,e){return b(n,e,((t,r,a)=>(a=o(a),L(n,e,a),null===a[0]&&null===a[1]?null:null===a[0]?i(a[1]):null===a[1]?i(a[0]):C.symmetricDifference(a[0],a[1]))))},n.clip=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,2,2,n,e),!(l[1]instanceof M)&&null!==l[1])throw new t(n,r.InvalidParameter,e);if(null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return null===l[1]?null:C.clip(l[0],l[1])}))},n.cut=function(n,e){return b(n,e,((a,l,u)=>{if(u=o(u),f(u,2,2,n,e),!(u[1]instanceof q)&&null!==u[1])throw new t(n,r.InvalidParameter,e);if(null===u[0])return[];if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return null===u[1]?[i(u[0])]:C.cut(u[0],u[1])}))},n.area=function(n,e){return b(n,e,((i,l,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=p(u[0],n.spatialReference);return null===e?0:C.planarArea(e,a(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.planarArea(u[0],a(g(u[1],-1)))}))},n.areageodetic=function(n,e){return b(n,e,((i,l,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=p(u[0],n.spatialReference);return null===e?0:C.geodesicArea(e,a(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.geodesicArea(u[0],a(g(u[1],-1)))}))},n.length=function(n,e){return b(n,e,((i,a,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=v(u[0],n.spatialReference);return null===e?0:C.planarLength(e,l(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.planarLength(u[0],l(g(u[1],-1)))}))},n.length3d=function(n,e){return b(n,e,((i,a,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=v(u[0],n.spatialReference);return null===e?0:!0===e.hasZ?W(e,l(g(u[1],-1))):C.planarLength(e,l(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return!0===u[0].hasZ?W(u[0],l(g(u[1],-1))):C.planarLength(u[0],l(g(u[1],-1)))}))},n.lengthgeodetic=function(n,e){return b(n,e,((i,a,u)=>{if(f(u,1,2,n,e),null===(u=o(u))[0])return 0;if(d(u[0])||h(u[0])){const e=v(u[0],n.spatialReference);return null===e?0:C.geodesicLength(e,l(g(u[1],-1)))}if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.geodesicLength(u[0],l(g(u[1],-1)))}))},n.distance=function(n,e){return b(n,e,((i,a,u)=>{u=o(u),f(u,2,3,n,e);let s=u[0];(d(u[0])||h(u[0]))&&(s=P(u[0],n.spatialReference));let c=u[1];if((d(u[1])||h(u[1]))&&(c=P(u[1],n.spatialReference)),!(s instanceof Z))throw new t(n,r.InvalidParameter,e);if(!(c instanceof Z))throw new t(n,r.InvalidParameter,e);return C.distance(s,c,l(g(u[2],-1)))}))},n.distancegeodetic=function(n,e){return b(n,e,((i,a,u)=>{u=o(u),f(u,2,3,n,e);const s=u[0],c=u[1];if(!(s instanceof S))throw new t(n,r.InvalidParameter,e);if(!(c instanceof S))throw new t(n,r.InvalidParameter,e);const m=new q({paths:[],spatialReference:s.spatialReference});return m.addPath([s,c]),C.geodesicLength(m,l(g(u[2],-1)))}))},n.densify=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,3,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);if(s<=0)throw new t(n,r.InvalidParameter,e);return u[0]instanceof T||u[0]instanceof q?C.densify(u[0],s,l(g(u[2],-1))):u[0]instanceof M?C.densify(J(u[0]),s,l(g(u[2],-1))):u[0]}))},n.densifygeodetic=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,3,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);if(s<=0)throw new t(n,r.InvalidParameter,e);return u[0]instanceof T||u[0]instanceof q?C.geodesicDensify(u[0],s,l(g(u[2],-1))):u[0]instanceof M?C.geodesicDensify(J(u[0]),s,l(g(u[2],-1))):u[0]}))},n.generalize=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,4,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);return C.generalize(u[0],s,y(g(u[2],!0)),l(g(u[3],-1)))}))},n.buffer=function(n,e){return b(n,e,((a,u,s)=>{if(s=o(s),f(s,2,3,n,e),null===s[0])return null;if(!(s[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const c=I(s[1]);if(isNaN(c))throw new t(n,r.InvalidParameter,e);return 0===c?i(s[0]):C.buffer(s[0],c,l(g(s[2],-1)))}))},n.buffergeodetic=function(n,e){return b(n,e,((a,u,s)=>{if(s=o(s),f(s,2,3,n,e),null===s[0])return null;if(!(s[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const c=I(s[1]);if(isNaN(c))throw new t(n,r.InvalidParameter,e);return 0===c?i(s[0]):C.geodesicBuffer(s[0],c,l(g(s[2],-1)))}))},n.offset=function(n,e){return b(n,e,((i,a,u)=>{if(u=o(u),f(u,2,6,n,e),null===u[0])return null;if(!(u[0]instanceof T||u[0]instanceof q))throw new t(n,r.InvalidParameter,e);const s=I(u[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);const c=I(g(u[4],10));if(isNaN(c))throw new t(n,r.InvalidParameter,e);const d=I(g(u[5],0));if(isNaN(d))throw new t(n,r.InvalidParameter,e);return C.offset(u[0],s,l(g(u[2],-1)),m(g(u[3],"round")).toLowerCase(),c,d)}))},n.rotate=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,2,3,n,e),null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);const u=l[0]instanceof M?T.fromExtent(l[0]):l[0],s=I(l[1]);if(isNaN(s))throw new t(n,r.InvalidParameter,e);const c=g(l[2],null);if(null===c)return C.rotate(u,s);if(c instanceof S)return C.rotate(u,s,c);throw new t(n,r.InvalidParameter,e)}))},n.centroid=function(n,e){return b(n,e,((a,l,u)=>{if(u=o(u),f(u,1,1,n,e),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=P(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,e);return s instanceof S?w(i(s),n.spatialReference):s instanceof T?s.centroid:s instanceof q?j(s):s instanceof E?N(s):s instanceof M?s.center:null}))},n.measuretocoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=v(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,i);if(!(s instanceof q))throw new t(n,r.InvalidParameter,i);if(R(!1===u[1]))throw new t(n,r.InvalidParameter,i);const c=O(s,u[1]);return c?e.convertObjectToArcadeDictionary(c,x(n),!1,!0):null}))},n.pointtocoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=v(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,i);if(!(s instanceof q))throw new t(n,r.InvalidParameter,i);const c=u[1];if(null===c)return null;if(!(c instanceof S))throw new t(n,r.InvalidParameter,i);if(R(!1===u[1]))throw new t(n,r.InvalidParameter,i);const m=A(s,c);return m?e.convertObjectToArcadeDictionary(m,x(n),!1,!0):null}))},n.distancetocoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),null===u[0])return null;let s=u[0];if((d(u[0])||h(u[0]))&&(s=v(u[0],n.spatialReference)),null===s)return null;if(!(s instanceof Z))throw new t(n,r.InvalidParameter,i);if(!(s instanceof q))throw new t(n,r.InvalidParameter,i);if(R(!1===u[1]))throw new t(n,r.InvalidParameter,i);const c=D(s,u[1]);return c?e.convertObjectToArcadeDictionary(c,x(n),!1,!0):null}))},n.multiparttosinglepart=function(n,e){return b(n,e,((a,l,u)=>{if(u=o(u),f(u,1,1,n,e),null===u[0])return null;if(!(u[0]instanceof Z))throw new t(n,r.InvalidParameter,e);if(u[0]instanceof S)return[w(i(u[0]),n.spatialReference)];if(u[0]instanceof M)return[w(i(u[0]),n.spatialReference)];const s=C.simplify(u[0]);if(s instanceof T){const n=[],e=[];for(let t=0;t<s.rings.length;t++)if(s.isClockwise(s.rings[t])){const e=z({rings:[s.rings[t]],hasZ:!0===s.hasZ,hasM:!0===s.hasM,spatialReference:s.spatialReference.toJSON()});n.push(e)}else e.push({ring:s.rings[t],pt:s.getPoint(t,0)});for(let t=0;t<e.length;t++)for(let r=0;r<n.length;r++)if(n[r].contains(e[t].pt)){n[r].addRing(e[t].ring);break}return n}if(s instanceof q){const n=[];for(let e=0;e<s.paths.length;e++){const t=z({paths:[s.paths[e]],hasZ:!0===s.hasZ,hasM:!0===s.hasM,spatialReference:s.spatialReference.toJSON()});n.push(t)}return n}if(u[0]instanceof E){const e=[],t=w(i(u[0]),n.spatialReference);for(let n=0;n<t.points.length;n++)e.push(t.getPoint(n));return e}return null}))},n.issimple=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,1,1,n,e),null===l[0])return!0;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.isSimple(l[0])}))},n.simplify=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,1,1,n,e),null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.simplify(l[0])}))},n.convexhull=function(n,e){return b(n,e,((i,a,l)=>{if(l=o(l),f(l,1,1,n,e),null===l[0])return null;if(!(l[0]instanceof Z))throw new t(n,r.InvalidParameter,e);return C.convexHull(l[0])}))},n.nearestcoordinate=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),!(u[0]instanceof Z||null===u[0]))throw new t(n,r.InvalidParameter,i);if(!(u[1]instanceof S||null===u[1]))throw new t(n,r.InvalidParameter,i);if(null===u[0]||null===u[1])return null;const s=C.nearestCoordinate(u[0],u[1]);return null===s||s.isEmpty?null:e.convertObjectToArcadeDictionary({coordinate:s.coordinate,distance:s.distance,sideOfLine:0===s.distance?"straddle":s.isRightSide?"right":"left"},x(n),!1,!0)}))},n.nearestvertex=function(n,i){return b(n,i,((a,l,u)=>{if(u=o(u),f(u,2,2,n,i),!(u[0]instanceof Z||null===u[0]))throw new t(n,r.InvalidParameter,i);if(!(u[1]instanceof S||null===u[1]))throw new t(n,r.InvalidParameter,i);if(null===u[0]||null===u[1])return null;const s=C.nearestVertex(u[0],u[1]);return null===s||s.isEmpty?null:e.convertObjectToArcadeDictionary({coordinate:s.coordinate,distance:s.distance,sideOfLine:0===s.distance?"straddle":s.isRightSide?"right":"left"},x(n),!1,!0)}))}}export{H as registerFunctions,U as setGeometryEngine};
|