/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{a as r,c as n,G as o,m as a}from"./Geometry.js";import{O as s}from"./OperatorShapePreservingLength.js";import{c as i,a as c}from"./MultiPathImpl.js";import{E as m}from"./Point2D.js";import{Q as l,af as u,ag as g,O as p,Z as f,_ as y,$ as x}from"./SpatialReference.js";import{O as h}from"./OperatorDensify.js";class S{getOperatorType(){return 10311}supportsCurves(){return!0}accelerateGeometry(e,t,r){return!1}canAccelerateGeometry(e){return!1}execute(e,t,f,y){if(4===f)return(new s).execute(e,t,y);if(0===t.getCoordinateSystemType()&&r(""),n(e),e.isEmpty()||e.getDimension()<1)return 0;const S=t.getGCS(),d=x();S.querySpheroidData(d);const P=d.majorSemiAxis,E=d.e2,G=S.getUnit().getUnitToBaseFactor();let j;const v=e.getGeometryType();if(v===o.enumPolygon?j=e.getBoundary():v===o.enumEnvelope?j=i(e):a(v)?(j=new c({vd:e.getDescription()}),j.addSegment(e,!0)):j=e,j.hasNonLinearSegments()){j=(new h).execute(j,0,t.getTolerance(0),0,y)}if(S!==t){const r=t.getSRToGCSTransform();if(t.isPannable()){j=l(j,t),v===o.enumPolyline&&j===e&&(j=e.clone());const r=new m;t.getPannableExtent().queryIntervalX(r);for(let e=0,t=j.getPointCount();e<t;e++){const t=j.getXY(e);t.x=u(t.x,r),j.setXY(e,t)}}const n=j.createInstance();j=g(r,j,n,y)?n:(new p).execute(j,r,y)}return this._ExecuteMultiPathGeodeticLength(j,f,P,E,G)}_ExecuteMultiPathGeodeticLength(r,n,o,a,s){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,new f,!1);let c=0;const m=r.querySegmentIterator();for(;m.nextPath();)for(;m.hasNextSegment();){const e=m.nextSegment(),r=e.getStartXY(),i=e.getEndXY();r.scale(s),i.scale(s),y.geodeticDistance(o,a,r.x,r.y,i.x,i.y,t,null,null,n),c+=t.val}return c}catch(c){i.error=c,i.hasError=!0}finally{t(i)}}}export{S as OperatorGeodeticLength};
