You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
12 KiB
27 lines
12 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("exports ../containerUtils ../Dictionary ../executionError ../Feature ../ImmutablePointArray ../../chunks/languageUtils ./centroid ../../geometry/Extent ../../geometry/Geometry ../../geometry/Multipoint ../../geometry/Point ../../geometry/Polygon ../../geometry/Polyline ../../geometry/support/coordsUtils ../../geometry/support/jsonUtils".split(" "),function(A,B,l,f,n,E,e,v,C,w,x,r,y,z,F,u){A.registerFunctions=function(p,q){p.ringisclockwise=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a, |
|
1,1,b,d);c=[];if(null===a[0])return!1;if(e.isArray(a[0]))for(const g of a[0])if(g instanceof r)c.push(g.hasZ?g.hasM?[g.x,g.y,g.z,g.m]:[g.x,g.y,g.z]:[g.x,g.y]);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);else if(a[0]instanceof E)c=a[0]._elements;else if(e.isImmutableArray(a[0]))for(const g of a[0].toArray())if(g instanceof r)c.push(g.hasZ?g.hasM?[g.x,g.y,g.z,g.m]:[g.x,g.y,g.z]:[g.x,g.y]);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter, |
|
d);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);return 3>c.length?!1:F.isClockwise(c)})};p.polygon=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,1,1,b,d);if(a[0]instanceof l){if(c=e.fixSpatialReference(n.parseGeometryFromDictionary(a[0],b.spatialReference),b.spatialReference),!1===c instanceof y)throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}else a[0]instanceof y?c=u.fromJSON(a[0].toJSON()):((c=JSON.parse(a[0]))&&!c.spatialReference&& |
|
(c.spatialReference=b.spatialReference),c=e.fixSpatialReference(new y(c),b.spatialReference));if(null!==c&&!1===c.spatialReference.equals(b.spatialReference))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.WrongSpatialReference,d);return e.fixNullGeometry(c)})};p.polyline=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,1,1,b,d);if(a[0]instanceof l){if(c=e.fixSpatialReference(n.parseGeometryFromDictionary(a[0],b.spatialReference),b.spatialReference),!1===c instanceof z)throw new f.ArcadeExecutionError(b, |
|
f.ExecutionErrorCodes.InvalidParameter,d);}else a[0]instanceof z?c=u.fromJSON(a[0].toJSON()):((c=JSON.parse(a[0]))&&!c.spatialReference&&(c.spatialReference=b.spatialReference),c=e.fixSpatialReference(new z(c),b.spatialReference));if(null!==c&&!1===c.spatialReference.equals(b.spatialReference))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.WrongSpatialReference,d);return e.fixNullGeometry(c)})};p.point=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,1,1,b,d);if(a[0]instanceof l){if(c=e.fixSpatialReference(n.parseGeometryFromDictionary(a[0], |
|
b.spatialReference),b.spatialReference),!1===c instanceof r)throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}else a[0]instanceof r?c=u.fromJSON(a[0].toJSON()):((c=JSON.parse(a[0]))&&!c.spatialReference&&(c.spatialReference=b.spatialReference),c=e.fixSpatialReference(new r(c),b.spatialReference));if(null!==c&&!1===c.spatialReference.equals(b.spatialReference))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.WrongSpatialReference,d);return e.fixNullGeometry(c)})}; |
|
p.multipoint=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,1,1,b,d);if(a[0]instanceof l){if(c=e.fixSpatialReference(n.parseGeometryFromDictionary(a[0],b.spatialReference),b.spatialReference),!1===c instanceof x)throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}else a[0]instanceof x?c=u.fromJSON(a[0].toJSON()):((c=JSON.parse(a[0]))&&!c.spatialReference&&(c.spatialReference=b.spatialReference),c=e.fixSpatialReference(new x(c),b.spatialReference));if(null!==c&&!1===c.spatialReference.equals(b.spatialReference))throw new f.ArcadeExecutionError(b, |
|
f.ExecutionErrorCodes.WrongSpatialReference,d);return e.fixNullGeometry(c)})};p.extent=function(b,d){return q(b,d,(c,h,a)=>{a=e.autoCastFeatureToGeometry(a);e.pcCheck(a,1,1,b,d);c=null;a[0]instanceof l?c=e.fixSpatialReference(n.parseGeometryFromDictionary(a[0],b.spatialReference),b.spatialReference):a[0]instanceof r?(c={xmin:a[0].x,ymin:a[0].y,xmax:a[0].x,ymax:a[0].y,spatialReference:a[0].spatialReference.toJSON()},a=a[0],a.hasZ?(c.zmin=a.z,c.zmax=a.z):a.hasM&&(c.mmin=a.m,c.mmax=a.m),c=u.fromJSON(c)): |
|
a[0]instanceof y?c=u.fromJSON(a[0].extent?.toJSON()):a[0]instanceof z?c=u.fromJSON(a[0].extent?.toJSON()):a[0]instanceof x?c=u.fromJSON(a[0].extent?.toJSON()):a[0]instanceof C?c=u.fromJSON(a[0].toJSON()):((a=JSON.parse(a[0]))&&!a.spatialReference&&(a.spatialReference=b.spatialReference),c=e.fixSpatialReference(new C(a),b.spatialReference));if(null!==c&&!1===c.spatialReference.equals(b.spatialReference))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.WrongSpatialReference,d);return e.fixNullGeometry(c)})}; |
|
p.geometry=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,1,1,b,d);c=null;if(null===a[0])return null;e.isFeature(a[0])?c=e.fixSpatialReference(a[0].geometry(),b.spatialReference):a[0]instanceof l?c=e.fixSpatialReference(n.parseGeometryFromDictionary(a[0],b.spatialReference),b.spatialReference):((a=JSON.parse(a[0]))&&!a.spatialReference&&(a.spatialReference=b.spatialReference),c=e.fixSpatialReference(u.fromJSON(a),b.spatialReference));if(null!==c&&!1===c.spatialReference.equals(b.spatialReference))throw new f.ArcadeExecutionError(b, |
|
f.ExecutionErrorCodes.WrongSpatialReference,d);return e.fixNullGeometry(c)})};p.setgeometry=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,2,2,b,d);if(e.isFeature(a[0])){if(!0===a[0].immutable)throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.Immutable,d);if(a[1]instanceof w||null===a[1])a[0]._geometry=a[1];else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);return e.voidOperation})}; |
|
p.feature=function(b,d){return q(b,d,(c,h,a)=>{if(0===a.length)throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.WrongNumberOfParameters,d);if(1===a.length)if(e.isString(a[0]))a=n.fromJson(JSON.parse(a[0]),b.timeZone);else if(e.isFeature(a[0]))a=n.createFromArcadeFeature(a[0]);else if(a[0]instanceof w)a=n.createFromGraphicLikeObject(a[0],null,null,b.timeZone);else if(a[0]instanceof l)c=a[0].hasField("geometry")?a[0].field("geometry"):null,a=a[0].hasField("attributes")?a[0].field("attributes"): |
|
null,null!==c&&c instanceof l&&(c=n.parseGeometryFromDictionary(c,b.spatialReference)),null!==a&&(a=n.parseAttributesFromDictionary(a)),a=n.createFromGraphicLikeObject(c,a,null,b.timeZone);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);else if(2===a.length){h=c=null;if(null!==a[0])if(a[0]instanceof w)c=a[0];else if(c instanceof l)c=n.parseGeometryFromDictionary(a[0],b.spatialReference);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter, |
|
d);if(null!==a[1])if(a[1]instanceof l)h=n.parseAttributesFromDictionary(a[1]);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);a=n.createFromGraphicLikeObject(c,h,null,b.timeZone)}else{c=null;h={};if(null!==a[0])if(a[0]instanceof w)c=a[0];else if(c instanceof l)c=n.parseGeometryFromDictionary(a[0],b.spatialReference);else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);for(let g=1;g<a.length;g+=2){const m=e.toString(a[g]),k=a[g+1];if(null=== |
|
k||void 0===k||e.isString(k)||isNaN(k)||e.isDate(k)||e.isNumber(k)||e.isTime(k)||e.isDateOnly(k)||e.isBoolean(k)){if(e.isFunctionParameter(k)||!1===e.isSimpleType(k))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);h[m]=k===e.voidOperation?null:k}else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}a=n.createFromGraphicLikeObject(c,h,null,b.timeZone)}a._geometry=e.fixSpatialReference(a.geometry(),b.spatialReference);a.immutable=!1;return a})}; |
|
p.dictionary=function(b,d){return q(b,d,(c,h,a)=>{if(0===a.length||1===a.length&&null===a[0])return a=new l,a.immutable=!1,a;if(1===a.length&&e.isString(a[0]))try{var g=JSON.parse(a[0]),m=l.convertObjectToArcadeDictionary(g,e.defaultTimeZone(b),!1);m.immutable=!1;return m}catch(k){throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}if(1===a.length&&a[0]instanceof w)try{const k=a[0].toJSON();k.hasZ=!0===a[0].hasZ;k.hasM=!0===a[0].hasM;const t=l.convertObjectToArcadeDictionary(k, |
|
e.defaultTimeZone(b),!1);t.immutable=!1;return t}catch(k){throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}if(1===a.length&&e.isFeature(a[0]))try{const k=new l;k.immutable=!1;k.setField("geometry",a[0].geometry());const t=new l;t.immutable=!1;k.setField("attributes",t);for(const D of a[0].keys())t.setField(D,a[0].field(D));return k}catch(k){throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}if(1===a.length&&a[0]instanceof l)try{const k=new l; |
|
k.immutable=!1;for(const t of a[0].keys())k.setField(t,a[0].field(t));return k}catch(k){throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}if(2===a.length&&a[0]instanceof l&&e.isBoolean(a[1]))try{if(!0!==a[1]){const k=new l;k.immutable=!1;for(const t of a[0].keys())k.setField(t,a[0].field(t));return k}return a[0].deepClone()}catch(k){throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);}if(0!==a.length%2)throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.WrongNumberOfParameters, |
|
d);c={};for(h=0;h<a.length;h+=2)if(g=e.toString(a[h]),m=a[h+1],null===m||void 0===m||e.isString(m)||isNaN(m)||e.isDate(m)||e.isNumber(m)||e.isBoolean(m)||e.isDateOnly(m)||e.isTime(m)||e.isArray(m)||e.isImmutableArray(m)){if(e.isFunctionParameter(m))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);c[g]=m===e.voidOperation?null:m}else throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);a=new l(c);a.immutable=!1;return a})};p.haskey=function(b,d){return q(b, |
|
d,(c,h,a)=>{e.pcCheck(a,2,2,b,d);c=e.toString(a[1]);if(e.isFeature(a[0])||a[0]instanceof l)return a[0].hasField(c);if(a[0]instanceof w)return(a=B.geometryMember(a[0],c,null,null,2))&&"notfound"===a.keystate?!1:!0;throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);})};p.hasvalue=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,2,2,b,d);return null!=B.getNestedOptionalValue(a[0],a[1])})};p.indexof=function(b,d){return q(b,d,(c,h,a)=>{e.pcCheck(a,2,2,b,d);c=a[1];if(e.isArray(a[0])){for(h= |
|
0;h<a[0].length;h++)if(e.equalityTest(c,a[0][h]))return h;return-1}if(e.isImmutableArray(a[0])){h=a[0].length();for(let g=0;g<h;g++)if(e.equalityTest(c,a[0].get(g)))return g;return-1}throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);})};p.angle=function(b,d){return q(b,d,(c,h,a)=>{a=e.autoCastFeatureToGeometry(a);e.pcCheck(a,2,3,b,d);if(!(a[0]instanceof r))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);if(!(a[1]instanceof r))throw new f.ArcadeExecutionError(b, |
|
f.ExecutionErrorCodes.InvalidParameter,d);if(2<a.length&&!(a[2]instanceof r))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);return 2===a.length?v.angle2D(a[0],a[1]):v.angleBetween2D(a[0],a[1],a[2])})};p.bearing=function(b,d){return q(b,d,(c,h,a)=>{a=e.autoCastFeatureToGeometry(a);e.pcCheck(a,2,3,b,d);if(!(a[0]instanceof r))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);if(!(a[1]instanceof r))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter, |
|
d);if(2<a.length&&!(a[2]instanceof r))throw new f.ArcadeExecutionError(b,f.ExecutionErrorCodes.InvalidParameter,d);return 2===a.length?v.bearing2D(a[0],a[1]):v.bearingBetween2D(a[0],a[1],a[2])})};p.isselfintersecting=function(b,d){return q(b,d,(c,h,a)=>{a=e.autoCastFeatureToGeometry(a);e.pcCheck(a,1,1,b,d);c=a[0];if(c instanceof y)return c.isSelfIntersecting;if(c instanceof z)return v.pathsSelfIntersecting(c.paths);if(c instanceof x)for(h=c.points,a=0;a<h.length;a++)for(let g=0;g<h.length;g++)if(g!== |
|
a){let m=!0;for(let k=0;k<h[a].length;k++)if(h[a][k]!==h[g][k]){m=!1;break}if(!0===m)return!0}return e.isArray(c)||e.isImmutableArray(c)?(h=e.autoCastArrayOfPointsToPolyline(c,b.spatialReference),null!==h&&(c=h.paths),v.pathsSelfIntersecting(c)):!1})}};Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}); |