/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{ignoreAbortErrors as t}from"../../core/promiseUtils.js";import{WorkerHandle as e}from"../../core/workers/WorkerHandle.js";import o from"../../geometry/Point.js";import{fromJSON as n}from"../../geometry/support/jsonUtils.js";class i extends e{constructor(t){super("GeometryWorker","geodeticArea",{},void 0,{strategy:"distributed"}),t?.preloadGeodetic&&this._preloadGeodetic()}async geodeticArea(t,e,n){const i=t.toJSON(),{area:r,centroid:s,length:a}=await this.invokeMethod("geodeticArea",{geometryJSON:i,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},n);return{area:r,centroid:s?o.fromJSON(s):void 0,length:a}}geodeticLength(t,e,o){const n=t.toJSON();return this.invokeMethod("geodeticLength",{geometryJSON:n,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},o)}geodeticDistanceBetweenPoints(t,e,o,n){const i=t.toJSON(),r=e.toJSON();return this.invokeMethod("geodeticDistanceBetweenPoints",{geometry1JSON:i,geometry2JSON:r,options:o},n)}geodeticDistanceBetweenPointsMany(t,e,o,n){const i=t.toJSON(),r=e.toJSON();return this.invokeMethod("geodeticDistanceBetweenPointsMany",{geometry1JSON:i,geometry2JSON:r,options:o},n)}_preloadGeodetic(){t(this.broadcast(void 0,"preloadGeodetic"))}async area2D(t,e,n){const i=t.toJSON(),{area:r,centroid:s,length:a}=await this.invokeMethod("area2D",{geometryJSON:i,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},n);return{area:r,centroid:s?o.fromJSON(s):void 0,length:a}}length2D(t,e,o){const n=t.toJSON();return this.invokeMethod("length2D",{geometryJSON:n,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},o)}distance2DBetweenPoints(t,e,o,n){const i=t.toJSON(),r=e.toJSON();return this.invokeMethod("distance2DBetweenPoints",{geometry1JSON:i,geometry2JSON:r,options:o},n)}async areaHorizontal(t,e,n){const i=t.toJSON(),{area:r,centroid:s,length:a}=await this.invokeMethod("areaHorizontal",{geometryJSON:i,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},n);return{area:r,centroid:s?o.fromJSON(s):void 0,length:a}}async autoArea2D(t,e,n){const i=t.toJSON(),{area:r,centroid:s,length:a}=await this.invokeMethod("autoArea2D",{geometryJSON:i,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},n);return{area:r,centroid:s?o.fromJSON(s):void 0,length:a}}async autoLength2D(t,e,o){const n=t.toJSON();return this.invokeMethod("autoLength2D",{geometryJSON:n,options:{...e,stagedPoint:e?.stagedPoint?.toJSON()}},o)}autoDistance2DBetweenPoints(t,e,o,n){const i=t.toJSON(),r=e.toJSON();return this.invokeMethod("autoDistance2DBetweenPoints",{geometry1JSON:i,geometry2JSON:r,options:o},n)}autoSize2D(t,e,o,n,i,r){const s=t.toJSON(),a=e.toJSON(),d=o.toJSON(),g=n.toJSON();return this.invokeMethod("autoSize2D",{topLeftJSON:s,topRightJSON:a,bottomRightJSON:d,bottomLeftJSON:g,options:i},r)}async simplify(t,e){const o=t.toJSON(),i=await this.invokeMethod("simplify",{geometryJSON:o},e);return i?n(i):null}}export{i as GeometryWorkerHandle};
