featuresetgeom.js 3.0 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{ArcadeExecutionError as e,ExecutionErrorCodes as n}from"../executionError.js";import{shapeExtent as t}from"../kernel.js";import{G as r,y as i,j as a,T as s}from"../../chunks/languageUtils.js";import u from"../featureset/actions/SpatialFilter.js";import o from"../featureset/sources/Empty.js";import l from"../../geometry/Geometry.js";import{relate as c,crosses as f,touches as p,within as m,overlaps as d,contains as w,intersects as y}from"../../geometry/geometryEngineAsync.js";function h(e){return e instanceof l}function S(i,a,c,S){return S(i,a,(async(S,R,v)=>{if(v.length<2)throw new e(i,n.WrongNumberOfParameters,a);if(null===(v=r(v))[0]&&null===v[1])return!1;if(s(v[0])){if(v[1]instanceof l)return new u({parentfeatureset:v[0],relation:c,relationGeom:v[1]});if(null===v[1])return new o({parentfeatureset:v[0]});throw new e(i,n.InvalidParameter,a)}if(h(v[0])){if(h(v[1])){switch(c){case"esriSpatialRelEnvelopeIntersects":return y(t(v[0]),t(v[1]));case"esriSpatialRelIntersects":return y(v[0],v[1]);case"esriSpatialRelContains":return w(v[0],v[1]);case"esriSpatialRelOverlaps":return d(v[0],v[1]);case"esriSpatialRelWithin":return m(v[0],v[1]);case"esriSpatialRelTouches":return p(v[0],v[1]);case"esriSpatialRelCrosses":return f(v[0],v[1])}throw new e(i,n.InvalidParameter,a)}if(s(v[1]))return new u({parentfeatureset:v[1],relation:c,relationGeom:v[0]});if(null===v[1])return!1;throw new e(i,n.InvalidParameter,a)}if(null!==v[0])throw new e(i,n.InvalidParameter,a);return s(v[1])?new o({parentfeatureset:v[1]}):!(v[1]instanceof l||null===v[1])&&void 0}))}function R(t){"async"===t.mode&&(t.functions.intersects=function(e,n){return S(e,n,"esriSpatialRelIntersects",t.standardFunctionAsync)},t.functions.envelopeintersects=function(e,n){return S(e,n,"esriSpatialRelEnvelopeIntersects",t.standardFunctionAsync)},t.signatures.push({name:"envelopeintersects",min:2,max:2}),t.functions.contains=function(e,n){return S(e,n,"esriSpatialRelContains",t.standardFunctionAsync)},t.functions.overlaps=function(e,n){return S(e,n,"esriSpatialRelOverlaps",t.standardFunctionAsync)},t.functions.within=function(e,n){return S(e,n,"esriSpatialRelWithin",t.standardFunctionAsync)},t.functions.touches=function(e,n){return S(e,n,"esriSpatialRelTouches",t.standardFunctionAsync)},t.functions.crosses=function(e,n){return S(e,n,"esriSpatialRelCrosses",t.standardFunctionAsync)},t.functions.relate=function(u,f){return t.standardFunctionAsync(u,f,((t,p,m)=>{if(m=r(m),i(m,3,3,u,f),h(m[0])&&h(m[1]))return c(m[0],m[1],a(m[2]));if(m[0]instanceof l&&null===m[1])return!1;if(m[1]instanceof l&&null===m[0])return!1;if(s(m[0])&&null===m[1])return new o({parentfeatureset:m[0]});if(s(m[1])&&null===m[0])return new o({parentfeatureset:m[1]});if(s(m[0])&&m[1]instanceof l)return m[0].relate(m[1],a(m[2]));if(s(m[1])&&m[0]instanceof l)return m[1].relate(m[0],a(m[2]));if(null===m[0]&&null===m[1])return!1;throw new e(u,n.InvalidParameter,f)}))})}export{R as registerFunctions};