@arcgis/core 4.31.0-next.20240820 → 4.31.0-next.20240821

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.
Files changed (56) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{dc03a639c97a6f99dbc9.js → 1ac47b7a77818c372e1a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{a2c40517266fe420017c.js → 25fa59544c13db8cee30.js} +1 -1
  4. package/assets/esri/core/workers/chunks/40e4224f700206c67053.js +1 -0
  5. package/assets/esri/core/workers/chunks/5c4173205f885cd21422.js +1 -0
  6. package/assets/esri/core/workers/chunks/5cb07fa227b7fd06499f.js +1 -0
  7. package/assets/esri/core/workers/chunks/{44bb9ca79b7eeb605b32.js → 7fda3d3b211b6da5b0e5.js} +1 -1
  8. package/assets/esri/core/workers/chunks/949cbb667531527e6918.js +1 -0
  9. package/assets/esri/core/workers/chunks/9bbf7129579fe04ab268.js +1 -0
  10. package/assets/esri/core/workers/chunks/{1bd48c11947082f8b296.js → cd8d595d577b74817623.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{c27f0a9b14f82feb9792.js → cfc93bbd35cc4bfde7c0.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{07737567079db2a208b3.js → e2a6f77c05d0818e3f74.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{1ee365125c9fb9d9cafe.js → e5474bcde5b8fa037b56.js} +11 -11
  14. package/assets/esri/core/workers/chunks/{bd9c85047ef82c5a8bef.js → ea561b2460e634a643fc.js} +1 -1
  15. package/chunks/BloomComposition.glsl.js +45 -0
  16. package/chunks/OperatorGeodesicBuffer.js +1 -1
  17. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  18. package/chunks/OperatorGeodeticDistance.js +1 -1
  19. package/chunks/OperatorProximity.js +5 -0
  20. package/chunks/Polyline.js +1 -1
  21. package/core/mathUtils.js +1 -1
  22. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  23. package/geometry/operators/gx/operatorCut.js +1 -1
  24. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  25. package/geometry/operators/gx/operatorOffset.js +1 -1
  26. package/geometry/operators/gx/operatorSimplify.js +1 -1
  27. package/geometry/operators/gx/operatorUnion.js +1 -1
  28. package/geometry/operators/operatorProximity.js +5 -0
  29. package/geometry/operators/operatorRelate.js +1 -1
  30. package/geometry/operators/operatorReshape.js +5 -0
  31. package/layers/LinkChartLayer.js +1 -1
  32. package/layers/graphics/sources/geojson/geojson.js +1 -1
  33. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  34. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  35. package/layers/knowledgeGraph/SessionMemoryStorage.js +1 -1
  36. package/layers/knowledgeGraph/layerUtils.js +1 -1
  37. package/package.json +1 -1
  38. package/portal/PortalItem.js +1 -1
  39. package/support/revision.js +1 -1
  40. package/symbols/cim/cimAnalyzer.js +1 -1
  41. package/symbols/support/utils.js +1 -1
  42. package/views/3d/state/ViewStateManager.js +1 -1
  43. package/views/3d/support/cameraUtils.js +1 -1
  44. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  45. package/views/3d/support/viewpointUtils.js +1 -1
  46. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +3 -3
  47. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +5 -0
  48. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +5 -0
  49. package/views/3d/webgl-engine/effects/bloom/BloomTechnique.js +5 -0
  50. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  51. package/widgets/OrientedImageryViewer.js +1 -1
  52. package/assets/esri/core/workers/chunks/2b61de00084c1ca97da6.js +0 -1
  53. package/assets/esri/core/workers/chunks/31f931de94414f13bd13.js +0 -1
  54. package/assets/esri/core/workers/chunks/6f1853ab502bebefd3c3.js +0 -1
  55. package/assets/esri/core/workers/chunks/9661398ce832137461f6.js +0 -1
  56. package/assets/esri/core/workers/chunks/cd737bfb5ff43737a3df.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{n as e,S as t,o as s,p as n,q as i,r,s as o,u as m,v as a,G as h,a as c,w as u,x as l,y as _,b as f,z as d,A as g,P as p,B as P,C as x,D as b,F as y,H as w,I as C,J as v,L as S,N as D,Q as I,R as G,T as M,U as N,V as T,W as k,h as A,m as q,X as E,Y as R,Z as z,_ as X,$ as B,a0 as Y,e as F,a1 as O,a2 as W,a3 as J,a4 as U,a5 as j,a6 as H,a7 as L,a8 as V,a9 as Q,aa as Z,ab as $,ac as K,ad as ee,ae as te,af as se,ag as ne,ah as ie}from"./Polyline.js";function re(e,t,s,n,i,o){n<Number.MAX_VALUE&&n>-Number.MAX_VALUE||r("Geodesic_bufferer.buffer - bad distance"),m(e);const c=e.getGeometryType();if(a(c)){const r=e.getPointCount(),m=8e6;if(Math.abs(n)>m&&(r>50||c!==h.enumMultiPoint&&4===s&&r>2)){let r=e;const a=n>0?1:-1,h=7e6;let c=n,u=1;do{u++,c=(Math.abs(c)-h)*a}while(Math.abs(c)>m);c=n;for(let e=0;e<u-1;e++)r=me(r,t,s,h*a,i,u,o),c=(Math.abs(c)-h)*a;return r=me(r,t,s,c,i,u,o),r}}return me(e,t,s,n,i,1,o)}class oe{constructor(e){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_radTolerance=0,this.m_q90=0,this.m_gcs90=0,this.m_gcs180=0,this.m_gcs360=0,this.m_gcs60=0,this.m_ellipticToGeodesicMaxRatio=0,this.m_curveType=0,this.m_bShapePreserving=!1,this.m_distance=0,this.m_absDistance=0,this.m_convergenceOffset=0,this.m_cornerStep=0,this.m_segmentStep=0,this.m_progressTracker=e}bufferPolygon(e){const t=new c,s=new be(this,e,t);return this.processGnomonicBufferPiecesCursor(!0,s)}bufferPolyline(e){const t=new be(this,e,null);return this.processGnomonicBufferPiecesCursor(!0,t)}bufferMultiPoint(e){const t=new ye(this,e);return this.processGnomonicBufferPiecesCursor(!1,t)}bufferPoint(e){const t=e.getXY();t.scale(this.m_rpu);let s=new c;if(this.bufferPoint2D(t,!1,s)){const e=S(null,s,!0);s=D(s,e,!0,!0,-1,this.m_progressTracker,0,!1)}return s=(new y).foldInto360RangeGeodetic(s,this.m_gcs,2),s}processGnomonicBufferPiecesCursor(t,s){const i=s;let r=i.getGnomonic();const o=I(G()),m=new ie;o.queryPrecisionDescriptor(m),m.setTolerance(0,.001),I(G());let a=new M,h=(new e).executeMany(a,o,this.m_progressTracker,2);const c=N(6,!1),u=T(n,6);this.initializeGrid(c,u);const l=[null,null,null,null,null,null],_=[null,null,null,null,null,null],f=[null,null,null,null,null,null];let g,p,P;for(;null!==(g=i.next());){if(p=i.getGnomonic(),p!==r){if(null!==r){let e=h.next();if(a=null,h=null,null!=e){const s=S(o,e,!0),n=d(s);e=r.unproject(e,n,this.m_progressTracker),this.putInGridCursors(t,e,o,!0,c,u,l,_,f)}}null!==p&&(a=new M,h=(new e).executeMany(a,o,this.m_progressTracker,2)),r=p}if(i.isRunningInGnomonic()){if(p.project(g),i.needsSimplify()){const e=S(null,g,!0);g=D(g,e,!0,!0,-1,this.m_progressTracker,0,!1)}a.tick(Pe(g)),h.tock()}else this.putInGridCursors(t,g,o,!0,c,u,l,_,f)}let x=!1;for(let e=0;e<6;e++)if(null!=f[e]){x=!0;break}if(x){let s=!1;const n=[null,null,null,null,null,null];if(t){const e=i.m_densified;if(i.m_densified=null,null!==e){const i=new k;i.scale(1/this.m_rpu,1/this.m_rpu),e.applyTransformation(i),this.m_distance>0?this.putInGridCursors(t,e,o,!1,c,u,l,_,f):(this.processInGrid(t,e,!1,c,u,l,n),s=!0)}}const m=new M,g=(new e).executeMany(m,this.m_gcs,this.m_progressTracker,2);if(null!==h){let e=h.next();a=null,h=null;const s=S(o,e,!0),n=d(s);e=r.unproject(e,n,this.m_progressTracker),this.putInGridCursors(t,e,o,!0,c,u,l,_,f)}for(let e=0;e<6;e++)if(null!=f[e]){let t=f[e].next();f[e]=null,_[e]=null,s&&null!==n[e]&&(t=(new A).execute(n[e],t,o,this.m_progressTracker));const i=S(o,t,!0),r=d(i);t=l[e].unproject(t,r,this.m_progressTracker),t=(new q).execute(t,this.m_gcs,!0,this.m_progressTracker),m.tick(Pe(t)),g.tock()}P=g.next()}else{let e,s=!1;if(t){let t=i.m_densified;if(i.m_densified=null,null!==t){const n=new k;n.scale(1/this.m_rpu,1/this.m_rpu),t.applyTransformation(n),p.project(t);const i=S(null,t,!0);t=D(t,i,!1,!0,-1,this.m_progressTracker,0,!1),this.m_distance>0?(a.tick(Pe(t)),h.tock()):(e=t,s=!0)}}let n=h.next();a=null,h=null,s&&(n=(new A).execute(e,n,o,this.m_progressTracker));const m=S(o,n,!0),c=d(m);P=r.unproject(n,c,this.m_progressTracker),P=(new q).execute(P,this.m_gcs,!0,this.m_progressTracker)}return P=(new y).foldInto360RangeGeodetic(P,this.m_gcs,2),P}putInGridCursors(t,s,n,i,r,o,m,a,h){const c=[null,null,null,null,null,null];this.processInGrid(t,s,i,r,o,m,c);for(let u=0;u<6;u++)null!==c[u]&&(null===a[u]&&(a[u]=new M,h[u]=(new e).executeMany(a[u],n,this.m_progressTracker,2)),a[u].tick(Pe(c[u])),h[u].tock())}processInGrid(e,t,s,n,i,r,o){const m=.01,a=this.insertGeodeticPointsAlongGrid(t,i,m);for(let h=0;h<6;h++){if(n[h])continue;const e=i[h].clone();e.inflateCoords(m,m);const c=E(t,e),u=g(null,c,!1).total();let l=R(a,e,u,Number.NaN,this.m_progressTracker);if(null!==l&&!l.isEmpty()){if(l===a&&(l=l.clone()),null===r[h]){const e=new F;h<3?e.setCoords(0,1):e.setCoords(0,-1);const t=new F;t.setAdd(i[h].getCenter(),e),r[h]=pe(this.m_gcs,t)}r[h].project(l);const e=S(null,l,!0);l=D(l,e,s,!0,-1,this.m_progressTracker,0,!1),o[h]=l}}}insertGeodeticPointsAlongGrid(e,t,s){const i=n.construct(t[3].xmin,t[3].ymin,t[2].xmax,t[2].ymax),r=z(this.m_gcs,i,e,!0,this.m_progressTracker),o=new X,m=o.addGeometry(r);return B(o,m,this.m_gcs,0,2,!0,t[0].xmax+s),B(o,m,this.m_gcs,0,2,!0,t[1].xmax+s),B(o,m,this.m_gcs,0,2,!1,t[1].ymin+s),0!==s&&(B(o,m,this.m_gcs,0,2,!0,t[0].xmax-s),B(o,m,this.m_gcs,0,2,!0,t[1].xmax-s),B(o,m,this.m_gcs,0,2,!1,t[1].ymin-s)),o.getGeometry(m)}initializeGrid(e,t){for(let s=0;s<6;s++)e[s]=!1;t[0].setCoords({xmin:-this.m_gcs180,ymin:0,xmax:-this.m_gcs60,ymax:this.m_gcs90}),t[1].setCoords({xmin:-this.m_gcs60,ymin:0,xmax:this.m_gcs60,ymax:this.m_gcs90}),t[2].setCoords({xmin:this.m_gcs60,ymin:0,xmax:this.m_gcs180,ymax:this.m_gcs90}),t[3].setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:-this.m_gcs60,ymax:0}),t[4].setCoords({xmin:-this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs60,ymax:0}),t[5].setCoords({xmin:this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:0})}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t,s,n,i,r){const o=e[0],m=e.at(-1),a=o.y<m.y?o.y:m.y,h=o.y>m.y?o.y:m.y,c=l.q(this.m_a,this.m_eSquared,a),u=l.q(this.m_a,this.m_eSquared,h);if(this.m_q90-(c+t+this.m_absDistance)>.001&&this.m_q90+(u-t-this.m_absDistance)>.001)return!1;const _=s-ne,f=n+ne,d=_-Math.PI,g=_+Math.PI,p=f+Math.PI,P=[Number.NaN],x=[Number.NaN],b=[Number.NaN],y=[Number.NaN];let w=!1;if(ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,_,d,m,f,P,x),ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,p,f,o,d,b,y),(f<P[0]&&P[0]<p||f<x[0]&&x[0]<p)&&(w=!0),w||(d<b[0]&&b[0]<_||d<y[0]&&y[0]<_)&&(w=!0),!w&&i)return!1;const C=[];for(let l=e.length-1;l>=0;l--)C.push(e[l]);r.setEmpty(),r.addPathPoint2D(null,0,!0);let v=0;v=ae(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,e,_,f,i,v,r),v=he(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,f,p,this.m_cornerStep,i,v,r,P[0],x[0]),v=ae(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,C,p,g,i,v,r),v=he(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,d,_,this.m_cornerStep,i,v,r,b[0],y[0]);let S=!1;return i||(S=this.checkAndPrepForPole(r)),w||S}bufferPoint2D(e,t,s){s.setEmpty(),s.addPathPoint2D(null,0,!0);const n=0;he(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,e,-this.m_cornerStep,2*Math.PI,this.m_cornerStep,t,n,s);let i=!1;return t||(i=this.checkAndPrepForPole(s)),i}checkAndPrepForPole(e){const t=this.checkAndPrepForPoleTouch(e),s=this.checkAndPrepForPoleWrap(e);return t||s}checkAndPrepForPoleTouch(e){const t=new n;return e.queryEnvelope(t),!(!Y(t.ymax,this.m_gcs90)&&!Y(t.ymin,-this.m_gcs90))&&(this.prepPoleTouch(e),!0)}checkAndPrepForPoleWrap(e){const t=e.getXY(0),s=e.getXY(e.getPointCount()-1);return Math.abs(t.x-s.x)>this.m_gcs180?(this.prepSinglePoleWrap(e),!0):this.checkAndPrepForDoublePoleWrap(e)}checkAndPrepForDoublePoleWrap(e){return e.calculateArea2D()<0&&(this.prepDoublePoleWrap(e),!0)}prepPoleTouch(e){const t=new c;t.insertPath2D(-1,null,0,0,!0);const s=e.getPathStart(0),n=e.getPathEnd(0),i=n-s;let r=-1;for(r=s;r<n;r++){const t=e.getXY(r),s=Y(t.y,this.m_gcs90),n=Y(t.y,-this.m_gcs90);if(!s&&!n)break}let o=r,m=!1,a=Number.NaN;do{const n=e.getXY(o),r=Y(n.y,this.m_gcs90),h=Y(n.y,-this.m_gcs90),c=s+(o+1-s)%i;if(r||h){let s=F.construct(a,n.y);t.insertPoint2D(0,-1,s);const i=e.getXY(c),r=Y(i.y,this.m_gcs90),o=Y(i.y,-this.m_gcs90);r||o||(s=F.construct(i.x,n.y),m?t.setXY(t.getPointCount()-1,s):t.insertPoint2D(0,-1,s)),m=!0}else t.insertPoint2D(0,-1,n),a=n.x,m=!1;o=c}while(o!==r);e.setEmpty(),e.add(t,!1)}prepSinglePoleWrap(e){const t=new c,s=new c,i=new k,r=e.getXY(e.getPathStart(0)),o=e.getXY(e.getPathEnd(0)-1),m=this.m_gcs360,a=this.m_gcs180,h=new n;h.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const u=new n;e.queryEnvelope(u);const l=Math.ceil(u.width()/m);let _,f;r.x>o.x?(_=-m,f=this.m_gcs90):(_=m,f=-this.m_gcs90),i.setShiftCoords(_,0),t.addPath(e,0,!0),s.add(t,!1);const d=new p;for(let n=0;n<l;n++)s.applyTransformation(i),s.getPointByVal(0,d),t.lineToPoint(d),t.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);const P=t.getXY(0),x=t.getXY(t.getPointCount()-1);P.y=f,x.y=f,t.lineTo(x);const b=new F;for(b.setCoordsPoint2D(x),b.x-=.5*_;Math.abs(b.x-P.x)>a;)t.lineTo(b),b.x-=.5*_;t.lineTo(P);const y=h.getCenterX(),w=new n;t.queryEnvelope(w);let C=0;const v=w.getCenter().x;v-y>a?C=-Math.ceil((v-y-a)/m):y-v>a&&(C=Math.ceil((y-v-a)/m)),0!==C&&(i.setShiftCoords(C*m,0),t.applyTransformation(i));const S=new X,D=S.addGeometry(t);B(S,D,this.m_gcs,0,2,!0,h.xmin),B(S,D,this.m_gcs,0,2,!0,h.xmax);const I=S.getGeometry(D),G=E(I,h);G.inflateCoords(0,1);const M=g(null,G,!0).total(),N=R(I,h,M,Number.NaN,this.m_progressTracker);e.setEmpty(),e.add(N,!1)}prepDoublePoleWrap(e){const t=this.m_gcs360,s=this.m_gcs180,i=new n;i.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const r=i.getCenter().x,o=new n;e.queryPathEnvelope(0,o);let m,a=0,h=o.getCenter().x;if(h-r>s?a=-Math.ceil((h-r-s)/t):r-h>s&&(a=Math.ceil((r-h-s)/t)),0!==a){const s=new k;s.setShiftCoords(a*t,0),e.getImpl().applyTransformationToPath(s,0),e.queryPathEnvelope(0,o),h=o.getCenter().x}const c=new n;i.containsExclusiveEnvelope(o)?(m=!1,c.setCoords({env2D:i})):(m=!0,c.setCoords({env2D:i}),c.xmin-=t,c.xmax+=t);let u=e.createInstance();u.addPathPoint2D(null,0,!0);const l=new F;if(l.setCoords(c.xmin,c.ymin),u.insertPoint2D(0,-1,l),l.setCoords(c.xmin,c.ymax),u.insertPoint2D(0,-1,l),l.setCoords(.5*(c.xmin+c.xmax),c.ymax),u.insertPoint2D(0,-1,l),l.setCoords(c.xmax,c.ymax),u.insertPoint2D(0,-1,l),l.setCoords(c.xmax,c.ymin),u.insertPoint2D(0,-1,l),l.setCoords(.5*(c.xmin+c.xmax),c.ymin),u.insertPoint2D(0,-1,l),m){u.addPath(e,0,!0);const s=new k;h<r?s.setShiftCoords(t,0):s.setShiftCoords(-t,0),e.getImpl().applyTransformationToPath(s,0),u.addPath(e,0,!0);const n=new X,o=n.addGeometry(u);B(n,o,this.m_gcs,0,2,!0,i.xmin),B(n,o,this.m_gcs,0,2,!0,i.xmax),u=n.getGeometry(o);const m=E(u,i);m.inflateCoords(0,1);const a=g(null,m,!0).total();u=R(u,i,a,Number.NaN,this.m_progressTracker)}else u.addPath(e,0,!0);e.setEmpty(),e.add(u,!1)}setMinCornerStep(){const e={stack:[],error:void 0,hasError:!1};try{let s=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);s=Math.min(s,.125*this.m_a*Math.PI);const n=new F;n.setCoords(0,10*this.m_rpu);const i=0;let r=45*this.m_rpu;const o=O(e,new W(new J,new J),!1),m=O(e,new W(new J,new J),!1),a=O(e,new W(new J,new J),!1),h=O(e,new W(new J,new J),!1),c=new F,u=new F,l=new F,_=new F;for(U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,i,o.at(0),o.at(1)),c.setCoords(o.at(0).val,o.at(1).val),U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const t=.5*(i+r);U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,t,a.at(0),a.at(1)),l.setCoords(a.at(0).val,a.at(1).val);const o=O(e,new J,!1),f=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,o,f,null,2),U.geodeticCoordinate(this.m_a,this.m_eSquared,c.x,c.y,.5*o.val,f.val,h.at(0),h.at(1),2),_.setCoords(h.at(0).val,h.at(1).val);const d=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,l.x,l.y,_.x,_.y,d,null,null,2);if(d.val<=this.m_convergenceOffset)break;r*=.9,U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{j(e)}}const f=r-i,d=2*Math.PI/Math.ceil(2*Math.PI/f);this.m_cornerStep=d}catch(s){e.error=s,e.hasError=!0}finally{j(e)}}setMinSegmentStep(){const e={stack:[],error:void 0,hasError:!1};try{let n=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);n=Math.min(n,.125*this.m_a*Math.PI);const i=new F,r=new F;i.setCoords(0,10*this.m_rpu),r.setCoords(10*this.m_rpu,10*this.m_rpu);const o=O(e,new J,!1),m=O(e,new J,!1),a=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,a,o,m,this.m_curveType);const h=O(e,new W(new J,new J),!1),c=O(e,new W(new J,new J),!1),u=new F,l=O(e,new J,!1),_=O(e,new W(new J,new J),!1),f=O(e,new W(new J,new J),!1),d=O(e,new W(new J,new J),!1),g=O(e,new W(new J,new J),!1),p=new F,P=new F,x=new F,b=new F,y=0;let w=1;const C=o.val,v=m.val,S=C-.5*Math.PI,D=v+.5*Math.PI,I=a.val;for(U.geodesicCoordinate(this.m_a,this.m_eSquared,i.x,i.y,n,S,_.at(0),_.at(1)),p.setCoords(_.at(0).val,_.at(1).val),U.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,D,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const s=.5*(y+w);U.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,s*I,C,h.at(0),h.at(1),this.m_curveType),u.setCoords(h.at(0).val,h.at(1).val),U.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,u.x,u.y,null,null,l,this.m_curveType);const o=l.val+.5*Math.PI;U.geodesicCoordinate(this.m_a,this.m_eSquared,u.x,u.y,n,o,d.at(0),d.at(1)),x.setCoords(d.at(0).val,d.at(1).val);const m=O(e,new J,!1),a=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,p.x,p.y,P.x,P.y,m,a,null,2),U.geodeticCoordinate(this.m_a,this.m_eSquared,p.x,p.y,.5*m.val,a.val,g.at(0),g.at(1),2),b.setCoords(g.at(0).val,g.at(1).val);const _=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,x.x,x.y,b.x,b.y,_,null,null,2);if(_.val<=this.m_convergenceOffset)break;{const e={stack:[],error:void 0,hasError:!1};try{w*=.9,U.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,w*I,C,c.at(0),c.at(1),this.m_curveType),r.setCoords(c.at(0).val,c.at(1).val);const t=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,null,null,t,this.m_curveType);const s=t.val+.5*Math.PI;U.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,s,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{j(e)}}}catch(s){e.error=s,e.hasError=!0}finally{j(e)}}let G=w*I;G>1e5&&(G=1e5),this.m_segmentStep=G}catch(n){e.error=n,e.hasError=!0}finally{j(e)}}setConvergenceOffset(){let e;e=this.m_absDistance>5e4?100:this.m_absDistance>1e4?10:1,this.m_absDistance/e<500&&(e=this.m_absDistance/500),e<.01&&(e=.01),this.m_convergenceOffset=e}}function me(e,t,s,i,o,m,a){if(e||r("Geometry.Geodesic_bufferer.buffer"),e.isEmpty())return new c({vd:e.getDescription()});const S=new oe(a);S.m_sr=t,S.m_gcs=t.getGCS(),S.m_transform=u(t,S.m_gcs,null);const D=H();S.m_gcs.querySpheroidData(D);const I=new n;e.queryEnvelope(I),S.m_a=D.majorSemiAxis,S.m_eSquared=D.e2,S.m_rpu=S.m_gcs.getUnit().getUnitToBaseFactor(),S.m_gcs90=.5*Math.PI/S.m_rpu,S.m_gcs180=Math.PI/S.m_rpu,S.m_gcs360=2*Math.PI/S.m_rpu,S.m_gcs60=S.m_gcs360/6,S.m_q90=l.q90(S.m_a,S.m_eSquared),S.m_ellipticToGeodesicMaxRatio=.5*S.m_a*Math.PI/S.m_q90;const G=S.m_gcs.getTolerance(0);S.m_radTolerance=G*S.m_rpu,4===s?(S.m_curveType=2,S.m_bShapePreserving=!0):(S.m_curveType=s,S.m_bShapePreserving=!1),S.m_distance=i,S.m_absDistance=Math.abs(i),Number.isNaN(o)||o<=0?S.setConvergenceOffset():S.m_convergenceOffset=Math.max(o,.001),S.m_convergenceOffset/=m;let M,N=e.getGeometryType();if(_(N)){const t=new f({vd:e.getDescription()});t.addSegment(e,!0),M=t,N=h.enumPolyline}else if(N===h.enumEnvelope){const t=e,s=new n;t.queryEnvelope(s);const i=d(g(S.m_sr,I,!0));if(s.minDimension()<=i)if(0===s.maxDimension()){const s=new p({vd:e.getDescription()});t.getCenter(s),M=s,N=h.enumPoint}else{const s=new f({vd:e.getDescription()});s.addEnvelope(t,!1),M=s,N=h.enumPolyline}else{const s=new c({vd:e.getDescription()});s.addEnvelope(t,!1),M=s,N=h.enumPolygon}}else M=e;if(S.setMinCornerStep(),P(N)||S.setMinSegmentStep(),S.m_absDistance<=.5*S.m_convergenceOffset)return N!==h.enumPolygon?new c({vd:M.getDescription()}):S.m_bShapePreserving?M:x(M,S.m_sr,S.m_curveType,S.m_segmentStep,-1,a);if(S.m_distance<0&&N!==h.enumPolygon)return new c({vd:M.getDescription()});if(S.m_bShapePreserving&&b(N)){const e=x(M,t,4,Number.NaN,S.m_convergenceOffset,a);M=(new y).execute(e,S.m_transform,a)}else M=(new y).execute(M,S.m_transform,a);if(M=w(M,S.m_gcs),M.isEmpty())return new c({vd:M.getDescription()});!S.m_bShapePreserving&&b(N)&&(M=C(S.m_rpu,M)),M=le(M,S.m_gcs);let T=new c;switch(N){case h.enumPolygon:T=S.bufferPolygon(M);break;case h.enumPolyline:T=S.bufferPolyline(M);break;case h.enumMultiPoint:T=S.bufferMultiPoint(M);break;case h.enumPoint:T=S.bufferPoint(M);break;default:v("")}const k=(new y).execute(T,S.m_transform.getInverse(),a);return k.mergeVertexDescription(M.getDescription()),k}function ae(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const l=new F;l.setNAN(),a||c.getPointCount()>0&&(l.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),l.scale(s));const _=O(u,new J,!1),f=O(u,new W(new J,new J),!1),d=new F,g=new F,p=r.at(-1),P=1/s;for(let s=0;s<r.length;s++){const u=r[s];let x;0===s?x=o:s===r.length-1?x=m:(U.geodeticDistance(e,t,p.x,p.y,u.x,u.y,null,null,_,i),x=_.val-.5*Math.PI),U.geodesicCoordinate(e,t,u.x,u.y,n,x,f.at(0),f.at(1)),a?g.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=ue(u.x,d.x,l.x,h),g.setCoords(h+d.x,d.y),l.setCoordsPoint2D(g)),g.scale(P),c.insertPoint2D(0,-1,g)}return h}catch(l){u.error=l,u.hasError=!0}finally{j(u)}}function he(e,t,s,n,i,r,o,m,a,h,c,u=Number.NaN,l=Number.NaN){const _={stack:[],error:void 0,hasError:!1};try{if(o-r<m)return h;const f=O(_,new W(new J,new J),!1),d=new F,g=new F,p=new F;g.setNAN(),a||c.getPointCount()>0&&(g.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),g.scale(s));let P=Math.ceil(r/m),x=P++*m;x===r&&(x=P++*m);let b=r;const y=1/s;for(;x<o+m&&(b<u&&u<x?(x=u,P--):b<l&&l<x&&(x=l,P--),!(x>=o));)U.geodesicCoordinate(e,t,i.x,i.y,n,x,f.at(0),f.at(1)),a?p.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=ue(i.x,d.x,g.x,h),p.setCoords(h+d.x,d.y),g.setCoordsPoint2D(p)),p.scale(y),c.insertPoint2D(0,-1,p),b=x,x=P++*m;return h}catch(f){_.error=f,_.hasError=!0}finally{j(_)}}function ce(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const s=new F,l=new F,_=O(u,new W(new J,new J),!1);U.geodesicCoordinate(e,t,i.x,i.y,n,r,_.at(0),_.at(1)),s.setCoords(_.at(0).val,_.at(1).val),U.geodesicCoordinate(e,t,i.x,i.y,n,o,_.at(0),_.at(1)),l.setCoords(_.at(0).val,_.at(1).val);const f=O(u,new J,!1);for(U.geodeticDistance(e,t,m.x,m.y,s.x,s.y,null,f,null,0),h[0]=f.val,U.geodeticDistance(e,t,m.x,m.y,l.x,l.y,null,f,null,0),c[0]=f.val;h[0]<=c[0];)h[0]+=L;for(;h[0]>c[0];)h[0]-=L;for(;h[0]>=a;)h[0]-=L,c[0]-=L;for(;h[0]<a;)h[0]+=L,c[0]+=L}catch(l){u.error=l,u.hasError=!0}finally{j(u)}}function ue(e,t,s,n){if(Number.isNaN(s)){for(;n+t-e>Math.PI;)n-=L;for(;e-(n+t)>Math.PI;)n+=L;return n}return n+t-s>Math.PI?n-=L:s-(n+t)>Math.PI&&(n+=L),n}function le(e,t){const s=e.getGeometryType();let i;if(i=b(s)?e.getPathCount():s===h.enumMultiPoint?e.getPointCount():1,1===i)return e;const r=[],o=[];for(let a=0;a<i;a++){r.push(a);const i=new F;if(b(s)){const t=new n;e.queryPathEnvelope(a,t),i.assign(t.getCenter())}else i.assign(e.getXY(a));const m=t.toGeohash(i);o.push(m)}r.sort(((e,t)=>o[e]<o[t]?-1:o[e]>o[t]?1:0));const m=e.createInstance();for(let n=0;n<i;n++){const t=r[n];b(s)?m.addPath(e,t,!0):m.addPoints(e,t,t+1)}return m}function _e(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=s[0],a=s.at(-1),h=O(o,new J,!1),c=O(o,new J,!1),u=O(o,new J,!1);U.greatEllipticDistance(e,t,i.x,i.y,m.x,m.y,h,null,null),U.greatEllipticDistance(e,t,i.x,i.y,a.x,a.y,c,null,null),U.greatEllipticDistance(e,t,m.x,m.y,a.x,a.y,u,null,null);let l=Math.min(h.val,c.val)+u.val,_=l+n;if(_<r)return!0;const f=O(o,new J,!1);l=Math.max(h.val,c.val);for(let n=1;n<s.length-1;n++){const r=s[n];U.greatEllipticDistance(e,t,i.x,i.y,r.x,r.y,f,null,null),f.val>l&&(l=f.val)}return _=l+n,_<r}catch(m){o.error=m,o.hasError=!0}finally{j(o)}}function fe(e,t,s,n,i,r,o,m){let a;if(n.length%2==0){const e=n.length>>1,t=n[e],s=n[e-1];a=F.lerp(t,s,.5)}else{a=n[n.length-1>>1].clone()}const h=a.clone(),c=$(e,t,h,75/180*Math.PI);return!!_e(e,t,n,i,h,c)&&(null!==r&&(r.setCoordsPoint2D(a),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(h),null!==m&&(m[0]=c),!0)}function de(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=O(o,new J,!1);U.greatEllipticDistance(e,t,i.x,i.y,s.x,s.y,m,null,null);return m.val+n<r}catch(m){o.error=m,o.hasError=!0}finally{j(o)}}function ge(e,t,s,n,i,r,o,m){const a=$(e,t,n,75/180*Math.PI);return!!de(e,t,n,i,n,a)&&(null!==r&&(r.setCoordsPoint2D(n),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(n),null!==m&&(m[0]=a),!0)}function pe(e,t){return new V(e,t)}function Pe(e){return Q(e,0)||Z(e,0),e}class xe{constructor(e){this.m_bRunningInGnomonic=!1,this.m_bNeedsSimplify=!1,this.m_gnomonic=null,this.m_gnomonicCenterRad=new F,this.m_minGnomonicRadius=Number.NaN,this.m_progressTracker=e}isRunningInGnomonic(){return this.m_bRunningInGnomonic}needsSimplify(){return this.m_bNeedsSimplify}getGnomonic(){return this.m_gnomonic}}class be extends xe{constructor(e,t,s){super(e.m_progressTracker),this.m_segIter=null,this.m_bNextSegmentCannotJoin=!1,this.m_currentDensifiedDelta=[0],this.m_currentBufferedDelta=0,this.m_lastAzimuth=0,this.m_startAzimuth=[0],this.m_endAzimuth=[0],this.m_numWinds=0,this.m_debugCounter=0,this.m_bufferHelper=new c,this.m_densifiedPoints=[],this.m_bufferer=e,this.m_multiPath=t,this.m_densified=s,this.m_bNeedsSimplify=!0;const i=new n;this.m_multiPath.queryEnvelope(i);const r=i.getCenter(),o=r.clone();o.scale(this.m_bufferer.m_rpu),this.m_gnomonic=pe(this.m_bufferer.m_gcs,r),this.m_gnomonicCenterRad=o.clone(),this.m_minGnomonicRadius=$(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,o,75/180*Math.PI)}next(){let e;if(this.m_bNextSegmentCannotJoin)return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e;if(null===this.m_segIter){if(this.m_segIter=this.m_multiPath.getImpl().querySegmentIterator(),!this.m_segIter.nextPath())return null;null!==this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}if(!this.m_segIter.hasNextSegment()){if(!this.m_segIter.nextPath())return null;null!=this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}let t=null;this.m_currentBufferedDelta=0,this.m_currentDensifiedDelta=[0],this.m_numWinds=0,this.m_lastAzimuth=Number.NaN,this.m_bNextSegmentCannotJoin=!1,this.m_densifiedPoints.length=0;const s=16;let n=0;const i=new F,r=new F;for(;this.m_segIter.hasNextSegment()&&this.m_numWinds<s;){const e=this.m_segIter.nextSegment();if(i.setCoordsPoint2D(e.getStartXY()),r.setCoordsPoint2D(e.getEndXY()),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),K(i,r))i.x=r.x;else if(ee(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),ee(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),K(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0;const s=te(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,i,r,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta);if(0===n)this.m_bRunningInGnomonic=this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(this.m_densifiedPoints));else if(this.m_bRunningInGnomonic){if(!this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}else{if(fe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_densifiedPoints,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,null,null,null)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}if(0===s||se(i,r)?(this.m_bufferHelper.setEmpty(),this.m_bufferer.bufferPoint2D(i,this.m_bRunningInGnomonic,this.m_bufferHelper),this.m_bNextSegmentCannotJoin=!0):(this.m_bufferHelper.setEmpty(),this.m_bNextSegmentCannotJoin=this.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(s,this.m_bufferHelper)),this.m_bNextSegmentCannotJoin){this.m_segIter.previousSegment(),this.m_segIter.hasPreviousSegment()?(this.m_segIter.previousSegment(),this.m_segIter.nextSegment()):this.m_segIter.resetToFirstSegment(),null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0);break}null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0),null===t&&(t=new c,t.addPathPoint2D(null,0,!0)),this.addJoinAndBufferLeftSide(t),n++}if(this.m_currentDensifiedDelta=[0],n>0){const e=this.m_segIter.getStartPointIndex(),s=this.m_segIter.getPathIndex();for(;n>0;){if(this.m_segIter.previousSegment(),i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),r.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getEndPointIndex())),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic)if(K(i,r))i.x=r.x;else if(ee(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),ee(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),K(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0,te(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,r,i,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta),this.addJoinAndBufferLeftSide(t),n--}return i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),i.scale(this.m_bufferer.m_rpu),this.m_currentBufferedDelta=he(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,i,this.m_lastAzimuth+.5*Math.PI,this.m_lastAzimuth+1.5*Math.PI,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,t),this.m_segIter.resetToVertex(e,s),this.m_segIter.nextSegment(),t}return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e}isSegmentBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&_e(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new F,s=new F,n=[0];return fe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=pe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t){return this.m_bufferer.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(this.m_densifiedPoints,e,this.m_startAzimuth[0],this.m_endAzimuth[0],this.m_bRunningInGnomonic,t)}addJoinAndBufferLeftSide(e){const t=this.m_densifiedPoints[0];let s=Number.NaN,n=this.m_startAzimuth[0]-ne;const i=this.m_endAzimuth[0]+ne;let r=!1;if(!Number.isNaN(this.m_lastAzimuth)){this.m_lastAzimuth>=this.m_startAzimuth[0]?(s=this.m_lastAzimuth+ne,n=s+Math.PI-(this.m_lastAzimuth-this.m_startAzimuth[0])):(s=this.m_lastAzimuth+ne,n=s+Math.PI-(L-(this.m_startAzimuth[0]-this.m_lastAzimuth))),r=!(this.m_lastAzimuth>=this.m_startAzimuth[0]&&this.m_lastAzimuth-this.m_startAzimuth[0]<=Math.PI)&&!(this.m_lastAzimuth<this.m_startAzimuth[0]&&this.m_startAzimuth[0]-this.m_lastAzimuth>=Math.PI);let i=!1;if(Math.abs(n-s)<=.5*this.m_bufferer.m_cornerStep&&(r||(i=!0)),i){if(e.removePointFromPath(0,e.getPointCount()-1),!this.m_bRunningInGnomonic){const t=new F;t.setCoordsPoint2D(e.getXY(e.getPointCount()-1)),t.scale(this.m_bufferer.m_rpu),t.x-this.m_currentBufferedDelta<-Math.PI?this.m_currentBufferedDelta-=L:t.x-this.m_currentBufferedDelta>Math.PI&&(this.m_currentBufferedDelta+=L)}n=.5*(n+s)}else if(r){const s=new F;s.setCoordsPoint2D(t),s.scale(1/this.m_bufferer.m_rpu),e.insertPoint2D(0,-1,s)}else he(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_densifiedPoints[0],s,n,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e)}this.m_startAzimuth[0]!==this.m_lastAzimuth&&this.m_numWinds++,ae(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_bufferer.m_curveType,this.m_densifiedPoints,n,i,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e),this.m_lastAzimuth=this.m_endAzimuth[0]}}class ye extends xe{constructor(e,t){super(e.m_progressTracker),this.m_pointIndex=-1,this.m_bufferer=e,this.m_multiPoint=t,this.m_bNeedsSimplify=!1;const s=new n;this.m_multiPoint.queryEnvelope(s);const i=s.getCenter(),r=i.clone();r.scale(this.m_bufferer.m_rpu),this.m_gnomonic=pe(this.m_bufferer.m_gcs,i),this.m_gnomonicCenterRad=r.clone(),this.m_minGnomonicRadius=$(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,r,75/180*Math.PI)}next(){if(this.m_bNeedsSimplify=!1,++this.m_pointIndex===this.m_multiPoint.getPointCount())return null;const e=this.m_multiPoint.getXY(this.m_pointIndex);e.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic=this.isPointBufferInCurrentGnomonic(e),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(e));const t=new c,s=this.m_bufferer.bufferPoint2D(e,this.m_bRunningInGnomonic,t);return this.m_bNeedsSimplify=s,t}isPointBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&de(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new F,s=new F,n=[0];return ge(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=pe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}}class we{getOperatorType(){return 10110}supportsCurves(){return!1}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(t,s,n,i,r,o,m,a){if(m){const m=new Ce(t,s,n,i,r,!1,o,a);return(new e).executeMany(m,s,a)}return new Ce(t,s,n,i,r,!1,o,a)}execute(e,s,n,i,r,o,m){const a=new t([e]),h=[i];return this.executeMany(a,s,n,h,r,!1,o,m).next()}}class Ce extends s{constructor(e,t,s,o,m,a,h,c){super(),this.m_currentUnionEnvelope2D=new n,this.m_index=-1,this.m_dindex=-1,this.m_progressTracker=c,a&&i(""),t||r("");0===t.getCoordinateSystemType()&&r(""),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=s,this.m_distances=o,this.m_convergenceOffset=m,this.m_bOutlineOnly=a,this.m_bUnion=h}next(){let e;for(;e=this.m_inputGeoms.next();)return o(e),m(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.m_dindex+1<this.m_distances.length&&this.m_dindex++,this.geodesicBuffer(e,this.m_distances[this.m_dindex]);return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodesicBuffer(e,t){return re(e,this.m_spatialReference,this.m_curveType,t,this.m_convergenceOffset,this.m_progressTracker)}}export{we as OperatorGeodesicBuffer};
5
+ import{v as e,S as t,w as s,o as n,n as i,m as r,x as o,y as m,z as a,G as h,a as c,A as u,B as l,r as _,b as f,C as d,D as g,P as p,F as P,H as x,I as b,J as y,L as w,N as C,Q as v,R as S,T as D,U as I,V as G,W as M,X as N,Y as T,Z as k,h as A,u as q,_ as E,$ as R,a0 as z,a1 as X,a2 as B,a3 as Y,e as F,a4 as O,a5 as W,a6 as J,a7 as U,a8 as j,a9 as H,aa as L,ab as V,ac as Q,ad as Z,ae as $,af as K,ag as ee,ah as te,ai as se,aj as ne,ak as ie}from"./Polyline.js";function re(e,t,s,n,i,o){n<Number.MAX_VALUE&&n>-Number.MAX_VALUE||r("Geodesic_bufferer.buffer - bad distance"),m(e);const c=e.getGeometryType();if(a(c)){const r=e.getPointCount(),m=8e6;if(Math.abs(n)>m&&(r>50||c!==h.enumMultiPoint&&4===s&&r>2)){let r=e;const a=n>0?1:-1,h=7e6;let c=n,u=1;do{u++,c=(Math.abs(c)-h)*a}while(Math.abs(c)>m);c=n;for(let e=0;e<u-1;e++)r=me(r,t,s,h*a,i,u,o),c=(Math.abs(c)-h)*a;return r=me(r,t,s,c,i,u,o),r}}return me(e,t,s,n,i,1,o)}class oe{constructor(e){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_radTolerance=0,this.m_q90=0,this.m_gcs90=0,this.m_gcs180=0,this.m_gcs360=0,this.m_gcs60=0,this.m_ellipticToGeodesicMaxRatio=0,this.m_curveType=0,this.m_bShapePreserving=!1,this.m_distance=0,this.m_absDistance=0,this.m_convergenceOffset=0,this.m_cornerStep=0,this.m_segmentStep=0,this.m_progressTracker=e}bufferPolygon(e){const t=new c,s=new be(this,e,t);return this.processGnomonicBufferPiecesCursor(!0,s)}bufferPolyline(e){const t=new be(this,e,null);return this.processGnomonicBufferPiecesCursor(!0,t)}bufferMultiPoint(e){const t=new ye(this,e);return this.processGnomonicBufferPiecesCursor(!1,t)}bufferPoint(e){const t=e.getXY();t.scale(this.m_rpu);let s=new c;if(this.bufferPoint2D(t,!1,s)){const e=S(null,s,!0);s=D(s,e,!0,!0,-1,this.m_progressTracker,0,!1)}return s=(new y).foldInto360RangeGeodetic(s,this.m_gcs,2),s}processGnomonicBufferPiecesCursor(t,s){const i=s;let r=i.getGnomonic();const o=I(G()),m=new ie;o.queryPrecisionDescriptor(m),m.setTolerance(0,.001),I(G());let a=new M,h=(new e).executeMany(a,o,this.m_progressTracker,2);const c=N(6,!1),u=T(n,6);this.initializeGrid(c,u);const l=[null,null,null,null,null,null],_=[null,null,null,null,null,null],f=[null,null,null,null,null,null];let g,p,P;for(;null!==(g=i.next());){if(p=i.getGnomonic(),p!==r){if(null!==r){let e=h.next();if(a=null,h=null,null!=e){const s=S(o,e,!0),n=d(s);e=r.unproject(e,n,this.m_progressTracker),this.putInGridCursors(t,e,o,!0,c,u,l,_,f)}}null!==p&&(a=new M,h=(new e).executeMany(a,o,this.m_progressTracker,2)),r=p}if(i.isRunningInGnomonic()){if(p.project(g),i.needsSimplify()){const e=S(null,g,!0);g=D(g,e,!0,!0,-1,this.m_progressTracker,0,!1)}a.tick(Pe(g)),h.tock()}else this.putInGridCursors(t,g,o,!0,c,u,l,_,f)}let x=!1;for(let e=0;e<6;e++)if(null!=f[e]){x=!0;break}if(x){let s=!1;const n=[null,null,null,null,null,null];if(t){const e=i.m_densified;if(i.m_densified=null,null!==e){const i=new k;i.scale(1/this.m_rpu,1/this.m_rpu),e.applyTransformation(i),this.m_distance>0?this.putInGridCursors(t,e,o,!1,c,u,l,_,f):(this.processInGrid(t,e,!1,c,u,l,n),s=!0)}}const m=new M,g=(new e).executeMany(m,this.m_gcs,this.m_progressTracker,2);if(null!==h){let e=h.next();a=null,h=null;const s=S(o,e,!0),n=d(s);e=r.unproject(e,n,this.m_progressTracker),this.putInGridCursors(t,e,o,!0,c,u,l,_,f)}for(let e=0;e<6;e++)if(null!=f[e]){let t=f[e].next();f[e]=null,_[e]=null,s&&null!==n[e]&&(t=(new A).execute(n[e],t,o,this.m_progressTracker));const i=S(o,t,!0),r=d(i);t=l[e].unproject(t,r,this.m_progressTracker),t=(new q).execute(t,this.m_gcs,!0,this.m_progressTracker),m.tick(Pe(t)),g.tock()}P=g.next()}else{let e,s=!1;if(t){let t=i.m_densified;if(i.m_densified=null,null!==t){const n=new k;n.scale(1/this.m_rpu,1/this.m_rpu),t.applyTransformation(n),p.project(t);const i=S(null,t,!0);t=D(t,i,!1,!0,-1,this.m_progressTracker,0,!1),this.m_distance>0?(a.tick(Pe(t)),h.tock()):(e=t,s=!0)}}let n=h.next();a=null,h=null,s&&(n=(new A).execute(e,n,o,this.m_progressTracker));const m=S(o,n,!0),c=d(m);P=r.unproject(n,c,this.m_progressTracker),P=(new q).execute(P,this.m_gcs,!0,this.m_progressTracker)}return P=(new y).foldInto360RangeGeodetic(P,this.m_gcs,2),P}putInGridCursors(t,s,n,i,r,o,m,a,h){const c=[null,null,null,null,null,null];this.processInGrid(t,s,i,r,o,m,c);for(let u=0;u<6;u++)null!==c[u]&&(null===a[u]&&(a[u]=new M,h[u]=(new e).executeMany(a[u],n,this.m_progressTracker,2)),a[u].tick(Pe(c[u])),h[u].tock())}processInGrid(e,t,s,n,i,r,o){const m=.01,a=this.insertGeodeticPointsAlongGrid(t,i,m);for(let h=0;h<6;h++){if(n[h])continue;const e=i[h].clone();e.inflateCoords(m,m);const c=E(t,e),u=g(null,c,!1).total();let l=R(a,e,u,Number.NaN,this.m_progressTracker);if(null!==l&&!l.isEmpty()){if(l===a&&(l=l.clone()),null===r[h]){const e=new F;h<3?e.setCoords(0,1):e.setCoords(0,-1);const t=new F;t.setAdd(i[h].getCenter(),e),r[h]=pe(this.m_gcs,t)}r[h].project(l);const e=S(null,l,!0);l=D(l,e,s,!0,-1,this.m_progressTracker,0,!1),o[h]=l}}}insertGeodeticPointsAlongGrid(e,t,s){const i=n.construct(t[3].xmin,t[3].ymin,t[2].xmax,t[2].ymax),r=z(this.m_gcs,i,e,!0,this.m_progressTracker),o=new X,m=o.addGeometry(r);return B(o,m,this.m_gcs,0,2,!0,t[0].xmax+s),B(o,m,this.m_gcs,0,2,!0,t[1].xmax+s),B(o,m,this.m_gcs,0,2,!1,t[1].ymin+s),0!==s&&(B(o,m,this.m_gcs,0,2,!0,t[0].xmax-s),B(o,m,this.m_gcs,0,2,!0,t[1].xmax-s),B(o,m,this.m_gcs,0,2,!1,t[1].ymin-s)),o.getGeometry(m)}initializeGrid(e,t){for(let s=0;s<6;s++)e[s]=!1;t[0].setCoords({xmin:-this.m_gcs180,ymin:0,xmax:-this.m_gcs60,ymax:this.m_gcs90}),t[1].setCoords({xmin:-this.m_gcs60,ymin:0,xmax:this.m_gcs60,ymax:this.m_gcs90}),t[2].setCoords({xmin:this.m_gcs60,ymin:0,xmax:this.m_gcs180,ymax:this.m_gcs90}),t[3].setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:-this.m_gcs60,ymax:0}),t[4].setCoords({xmin:-this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs60,ymax:0}),t[5].setCoords({xmin:this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:0})}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t,s,n,i,r){const o=e[0],m=e.at(-1),a=o.y<m.y?o.y:m.y,h=o.y>m.y?o.y:m.y,c=l.q(this.m_a,this.m_eSquared,a),u=l.q(this.m_a,this.m_eSquared,h);if(this.m_q90-(c+t+this.m_absDistance)>.001&&this.m_q90+(u-t-this.m_absDistance)>.001)return!1;const _=s-ne,f=n+ne,d=_-Math.PI,g=_+Math.PI,p=f+Math.PI,P=[Number.NaN],x=[Number.NaN],b=[Number.NaN],y=[Number.NaN];let w=!1;if(ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,_,d,m,f,P,x),ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,p,f,o,d,b,y),(f<P[0]&&P[0]<p||f<x[0]&&x[0]<p)&&(w=!0),w||(d<b[0]&&b[0]<_||d<y[0]&&y[0]<_)&&(w=!0),!w&&i)return!1;const C=[];for(let l=e.length-1;l>=0;l--)C.push(e[l]);r.setEmpty(),r.addPathPoint2D(null,0,!0);let v=0;v=ae(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,e,_,f,i,v,r),v=he(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,f,p,this.m_cornerStep,i,v,r,P[0],x[0]),v=ae(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,C,p,g,i,v,r),v=he(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,d,_,this.m_cornerStep,i,v,r,b[0],y[0]);let S=!1;return i||(S=this.checkAndPrepForPole(r)),w||S}bufferPoint2D(e,t,s){s.setEmpty(),s.addPathPoint2D(null,0,!0);const n=0;he(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,e,-this.m_cornerStep,2*Math.PI,this.m_cornerStep,t,n,s);let i=!1;return t||(i=this.checkAndPrepForPole(s)),i}checkAndPrepForPole(e){const t=this.checkAndPrepForPoleTouch(e),s=this.checkAndPrepForPoleWrap(e);return t||s}checkAndPrepForPoleTouch(e){const t=new n;return e.queryEnvelope(t),!(!Y(t.ymax,this.m_gcs90)&&!Y(t.ymin,-this.m_gcs90))&&(this.prepPoleTouch(e),!0)}checkAndPrepForPoleWrap(e){const t=e.getXY(0),s=e.getXY(e.getPointCount()-1);return Math.abs(t.x-s.x)>this.m_gcs180?(this.prepSinglePoleWrap(e),!0):this.checkAndPrepForDoublePoleWrap(e)}checkAndPrepForDoublePoleWrap(e){return e.calculateArea2D()<0&&(this.prepDoublePoleWrap(e),!0)}prepPoleTouch(e){const t=new c;t.insertPath2D(-1,null,0,0,!0);const s=e.getPathStart(0),n=e.getPathEnd(0),i=n-s;let r=-1;for(r=s;r<n;r++){const t=e.getXY(r),s=Y(t.y,this.m_gcs90),n=Y(t.y,-this.m_gcs90);if(!s&&!n)break}let o=r,m=!1,a=Number.NaN;do{const n=e.getXY(o),r=Y(n.y,this.m_gcs90),h=Y(n.y,-this.m_gcs90),c=s+(o+1-s)%i;if(r||h){let s=F.construct(a,n.y);t.insertPoint2D(0,-1,s);const i=e.getXY(c),r=Y(i.y,this.m_gcs90),o=Y(i.y,-this.m_gcs90);r||o||(s=F.construct(i.x,n.y),m?t.setXY(t.getPointCount()-1,s):t.insertPoint2D(0,-1,s)),m=!0}else t.insertPoint2D(0,-1,n),a=n.x,m=!1;o=c}while(o!==r);e.setEmpty(),e.add(t,!1)}prepSinglePoleWrap(e){const t=new c,s=new c,i=new k,r=e.getXY(e.getPathStart(0)),o=e.getXY(e.getPathEnd(0)-1),m=this.m_gcs360,a=this.m_gcs180,h=new n;h.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const u=new n;e.queryEnvelope(u);const l=Math.ceil(u.width()/m);let _,f;r.x>o.x?(_=-m,f=this.m_gcs90):(_=m,f=-this.m_gcs90),i.setShiftCoords(_,0),t.addPath(e,0,!0),s.add(t,!1);const d=new p;for(let n=0;n<l;n++)s.applyTransformation(i),s.getPointByVal(0,d),t.lineToPoint(d),t.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);const P=t.getXY(0),x=t.getXY(t.getPointCount()-1);P.y=f,x.y=f,t.lineTo(x);const b=new F;for(b.setCoordsPoint2D(x),b.x-=.5*_;Math.abs(b.x-P.x)>a;)t.lineTo(b),b.x-=.5*_;t.lineTo(P);const y=h.getCenterX(),w=new n;t.queryEnvelope(w);let C=0;const v=w.getCenter().x;v-y>a?C=-Math.ceil((v-y-a)/m):y-v>a&&(C=Math.ceil((y-v-a)/m)),0!==C&&(i.setShiftCoords(C*m,0),t.applyTransformation(i));const S=new X,D=S.addGeometry(t);B(S,D,this.m_gcs,0,2,!0,h.xmin),B(S,D,this.m_gcs,0,2,!0,h.xmax);const I=S.getGeometry(D),G=E(I,h);G.inflateCoords(0,1);const M=g(null,G,!0).total(),N=R(I,h,M,Number.NaN,this.m_progressTracker);e.setEmpty(),e.add(N,!1)}prepDoublePoleWrap(e){const t=this.m_gcs360,s=this.m_gcs180,i=new n;i.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const r=i.getCenter().x,o=new n;e.queryPathEnvelope(0,o);let m,a=0,h=o.getCenter().x;if(h-r>s?a=-Math.ceil((h-r-s)/t):r-h>s&&(a=Math.ceil((r-h-s)/t)),0!==a){const s=new k;s.setShiftCoords(a*t,0),e.getImpl().applyTransformationToPath(s,0),e.queryPathEnvelope(0,o),h=o.getCenter().x}const c=new n;i.containsExclusiveEnvelope(o)?(m=!1,c.setCoords({env2D:i})):(m=!0,c.setCoords({env2D:i}),c.xmin-=t,c.xmax+=t);let u=e.createInstance();u.addPathPoint2D(null,0,!0);const l=new F;if(l.setCoords(c.xmin,c.ymin),u.insertPoint2D(0,-1,l),l.setCoords(c.xmin,c.ymax),u.insertPoint2D(0,-1,l),l.setCoords(.5*(c.xmin+c.xmax),c.ymax),u.insertPoint2D(0,-1,l),l.setCoords(c.xmax,c.ymax),u.insertPoint2D(0,-1,l),l.setCoords(c.xmax,c.ymin),u.insertPoint2D(0,-1,l),l.setCoords(.5*(c.xmin+c.xmax),c.ymin),u.insertPoint2D(0,-1,l),m){u.addPath(e,0,!0);const s=new k;h<r?s.setShiftCoords(t,0):s.setShiftCoords(-t,0),e.getImpl().applyTransformationToPath(s,0),u.addPath(e,0,!0);const n=new X,o=n.addGeometry(u);B(n,o,this.m_gcs,0,2,!0,i.xmin),B(n,o,this.m_gcs,0,2,!0,i.xmax),u=n.getGeometry(o);const m=E(u,i);m.inflateCoords(0,1);const a=g(null,m,!0).total();u=R(u,i,a,Number.NaN,this.m_progressTracker)}else u.addPath(e,0,!0);e.setEmpty(),e.add(u,!1)}setMinCornerStep(){const e={stack:[],error:void 0,hasError:!1};try{let s=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);s=Math.min(s,.125*this.m_a*Math.PI);const n=new F;n.setCoords(0,10*this.m_rpu);const i=0;let r=45*this.m_rpu;const o=O(e,new W(new J,new J),!1),m=O(e,new W(new J,new J),!1),a=O(e,new W(new J,new J),!1),h=O(e,new W(new J,new J),!1),c=new F,u=new F,l=new F,_=new F;for(U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,i,o.at(0),o.at(1)),c.setCoords(o.at(0).val,o.at(1).val),U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const t=.5*(i+r);U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,t,a.at(0),a.at(1)),l.setCoords(a.at(0).val,a.at(1).val);const o=O(e,new J,!1),f=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,o,f,null,2),U.geodeticCoordinate(this.m_a,this.m_eSquared,c.x,c.y,.5*o.val,f.val,h.at(0),h.at(1),2),_.setCoords(h.at(0).val,h.at(1).val);const d=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,l.x,l.y,_.x,_.y,d,null,null,2);if(d.val<=this.m_convergenceOffset)break;r*=.9,U.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{j(e)}}const f=r-i,d=2*Math.PI/Math.ceil(2*Math.PI/f);this.m_cornerStep=d}catch(s){e.error=s,e.hasError=!0}finally{j(e)}}setMinSegmentStep(){const e={stack:[],error:void 0,hasError:!1};try{let n=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);n=Math.min(n,.125*this.m_a*Math.PI);const i=new F,r=new F;i.setCoords(0,10*this.m_rpu),r.setCoords(10*this.m_rpu,10*this.m_rpu);const o=O(e,new J,!1),m=O(e,new J,!1),a=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,a,o,m,this.m_curveType);const h=O(e,new W(new J,new J),!1),c=O(e,new W(new J,new J),!1),u=new F,l=O(e,new J,!1),_=O(e,new W(new J,new J),!1),f=O(e,new W(new J,new J),!1),d=O(e,new W(new J,new J),!1),g=O(e,new W(new J,new J),!1),p=new F,P=new F,x=new F,b=new F,y=0;let w=1;const C=o.val,v=m.val,S=C-.5*Math.PI,D=v+.5*Math.PI,I=a.val;for(U.geodesicCoordinate(this.m_a,this.m_eSquared,i.x,i.y,n,S,_.at(0),_.at(1)),p.setCoords(_.at(0).val,_.at(1).val),U.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,D,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const s=.5*(y+w);U.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,s*I,C,h.at(0),h.at(1),this.m_curveType),u.setCoords(h.at(0).val,h.at(1).val),U.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,u.x,u.y,null,null,l,this.m_curveType);const o=l.val+.5*Math.PI;U.geodesicCoordinate(this.m_a,this.m_eSquared,u.x,u.y,n,o,d.at(0),d.at(1)),x.setCoords(d.at(0).val,d.at(1).val);const m=O(e,new J,!1),a=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,p.x,p.y,P.x,P.y,m,a,null,2),U.geodeticCoordinate(this.m_a,this.m_eSquared,p.x,p.y,.5*m.val,a.val,g.at(0),g.at(1),2),b.setCoords(g.at(0).val,g.at(1).val);const _=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,x.x,x.y,b.x,b.y,_,null,null,2);if(_.val<=this.m_convergenceOffset)break;{const e={stack:[],error:void 0,hasError:!1};try{w*=.9,U.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,w*I,C,c.at(0),c.at(1),this.m_curveType),r.setCoords(c.at(0).val,c.at(1).val);const t=O(e,new J,!1);U.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,null,null,t,this.m_curveType);const s=t.val+.5*Math.PI;U.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,s,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{j(e)}}}catch(s){e.error=s,e.hasError=!0}finally{j(e)}}let G=w*I;G>1e5&&(G=1e5),this.m_segmentStep=G}catch(n){e.error=n,e.hasError=!0}finally{j(e)}}setConvergenceOffset(){let e;e=this.m_absDistance>5e4?100:this.m_absDistance>1e4?10:1,this.m_absDistance/e<500&&(e=this.m_absDistance/500),e<.01&&(e=.01),this.m_convergenceOffset=e}}function me(e,t,s,i,o,m,a){if(e||r("Geometry.Geodesic_bufferer.buffer"),e.isEmpty())return new c({vd:e.getDescription()});const S=new oe(a);S.m_sr=t,S.m_gcs=t.getGCS(),S.m_transform=u(t,S.m_gcs,null);const D=H();S.m_gcs.querySpheroidData(D);const I=new n;e.queryEnvelope(I),S.m_a=D.majorSemiAxis,S.m_eSquared=D.e2,S.m_rpu=S.m_gcs.getUnit().getUnitToBaseFactor(),S.m_gcs90=.5*Math.PI/S.m_rpu,S.m_gcs180=Math.PI/S.m_rpu,S.m_gcs360=2*Math.PI/S.m_rpu,S.m_gcs60=S.m_gcs360/6,S.m_q90=l.q90(S.m_a,S.m_eSquared),S.m_ellipticToGeodesicMaxRatio=.5*S.m_a*Math.PI/S.m_q90;const G=S.m_gcs.getTolerance(0);S.m_radTolerance=G*S.m_rpu,4===s?(S.m_curveType=2,S.m_bShapePreserving=!0):(S.m_curveType=s,S.m_bShapePreserving=!1),S.m_distance=i,S.m_absDistance=Math.abs(i),Number.isNaN(o)||o<=0?S.setConvergenceOffset():S.m_convergenceOffset=Math.max(o,.001),S.m_convergenceOffset/=m;let M,N=e.getGeometryType();if(_(N)){const t=new f({vd:e.getDescription()});t.addSegment(e,!0),M=t,N=h.enumPolyline}else if(N===h.enumEnvelope){const t=e,s=new n;t.queryEnvelope(s);const i=d(g(S.m_sr,I,!0));if(s.minDimension()<=i)if(0===s.maxDimension()){const s=new p({vd:e.getDescription()});t.getCenter(s),M=s,N=h.enumPoint}else{const s=new f({vd:e.getDescription()});s.addEnvelope(t,!1),M=s,N=h.enumPolyline}else{const s=new c({vd:e.getDescription()});s.addEnvelope(t,!1),M=s,N=h.enumPolygon}}else M=e;if(S.setMinCornerStep(),P(N)||S.setMinSegmentStep(),S.m_absDistance<=.5*S.m_convergenceOffset)return N!==h.enumPolygon?new c({vd:M.getDescription()}):S.m_bShapePreserving?M:x(M,S.m_sr,S.m_curveType,S.m_segmentStep,-1,a);if(S.m_distance<0&&N!==h.enumPolygon)return new c({vd:M.getDescription()});if(S.m_bShapePreserving&&b(N)){const e=x(M,t,4,Number.NaN,S.m_convergenceOffset,a);M=(new y).execute(e,S.m_transform,a)}else M=(new y).execute(M,S.m_transform,a);if(M=w(M,S.m_gcs),M.isEmpty())return new c({vd:M.getDescription()});!S.m_bShapePreserving&&b(N)&&(M=C(S.m_rpu,M)),M=le(M,S.m_gcs);let T=new c;switch(N){case h.enumPolygon:T=S.bufferPolygon(M);break;case h.enumPolyline:T=S.bufferPolyline(M);break;case h.enumMultiPoint:T=S.bufferMultiPoint(M);break;case h.enumPoint:T=S.bufferPoint(M);break;default:v("")}const k=(new y).execute(T,S.m_transform.getInverse(),a);return k.mergeVertexDescription(M.getDescription()),k}function ae(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const l=new F;l.setNAN(),a||c.getPointCount()>0&&(l.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),l.scale(s));const _=O(u,new J,!1),f=O(u,new W(new J,new J),!1),d=new F,g=new F,p=r.at(-1),P=1/s;for(let s=0;s<r.length;s++){const u=r[s];let x;0===s?x=o:s===r.length-1?x=m:(U.geodeticDistance(e,t,p.x,p.y,u.x,u.y,null,null,_,i),x=_.val-.5*Math.PI),U.geodesicCoordinate(e,t,u.x,u.y,n,x,f.at(0),f.at(1)),a?g.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=ue(u.x,d.x,l.x,h),g.setCoords(h+d.x,d.y),l.setCoordsPoint2D(g)),g.scale(P),c.insertPoint2D(0,-1,g)}return h}catch(l){u.error=l,u.hasError=!0}finally{j(u)}}function he(e,t,s,n,i,r,o,m,a,h,c,u=Number.NaN,l=Number.NaN){const _={stack:[],error:void 0,hasError:!1};try{if(o-r<m)return h;const f=O(_,new W(new J,new J),!1),d=new F,g=new F,p=new F;g.setNAN(),a||c.getPointCount()>0&&(g.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),g.scale(s));let P=Math.ceil(r/m),x=P++*m;x===r&&(x=P++*m);let b=r;const y=1/s;for(;x<o+m&&(b<u&&u<x?(x=u,P--):b<l&&l<x&&(x=l,P--),!(x>=o));)U.geodesicCoordinate(e,t,i.x,i.y,n,x,f.at(0),f.at(1)),a?p.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=ue(i.x,d.x,g.x,h),p.setCoords(h+d.x,d.y),g.setCoordsPoint2D(p)),p.scale(y),c.insertPoint2D(0,-1,p),b=x,x=P++*m;return h}catch(f){_.error=f,_.hasError=!0}finally{j(_)}}function ce(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const s=new F,l=new F,_=O(u,new W(new J,new J),!1);U.geodesicCoordinate(e,t,i.x,i.y,n,r,_.at(0),_.at(1)),s.setCoords(_.at(0).val,_.at(1).val),U.geodesicCoordinate(e,t,i.x,i.y,n,o,_.at(0),_.at(1)),l.setCoords(_.at(0).val,_.at(1).val);const f=O(u,new J,!1);for(U.geodeticDistance(e,t,m.x,m.y,s.x,s.y,null,f,null,0),h[0]=f.val,U.geodeticDistance(e,t,m.x,m.y,l.x,l.y,null,f,null,0),c[0]=f.val;h[0]<=c[0];)h[0]+=L;for(;h[0]>c[0];)h[0]-=L;for(;h[0]>=a;)h[0]-=L,c[0]-=L;for(;h[0]<a;)h[0]+=L,c[0]+=L}catch(l){u.error=l,u.hasError=!0}finally{j(u)}}function ue(e,t,s,n){if(Number.isNaN(s)){for(;n+t-e>Math.PI;)n-=L;for(;e-(n+t)>Math.PI;)n+=L;return n}return n+t-s>Math.PI?n-=L:s-(n+t)>Math.PI&&(n+=L),n}function le(e,t){const s=e.getGeometryType();let i;if(i=b(s)?e.getPathCount():s===h.enumMultiPoint?e.getPointCount():1,1===i)return e;const r=[],o=[];for(let a=0;a<i;a++){r.push(a);const i=new F;if(b(s)){const t=new n;e.queryPathEnvelope(a,t),i.assign(t.getCenter())}else i.assign(e.getXY(a));const m=t.toGeohash(i);o.push(m)}r.sort(((e,t)=>o[e]<o[t]?-1:o[e]>o[t]?1:0));const m=e.createInstance();for(let n=0;n<i;n++){const t=r[n];b(s)?m.addPath(e,t,!0):m.addPoints(e,t,t+1)}return m}function _e(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=s[0],a=s.at(-1),h=O(o,new J,!1),c=O(o,new J,!1),u=O(o,new J,!1);U.greatEllipticDistance(e,t,i.x,i.y,m.x,m.y,h,null,null),U.greatEllipticDistance(e,t,i.x,i.y,a.x,a.y,c,null,null),U.greatEllipticDistance(e,t,m.x,m.y,a.x,a.y,u,null,null);let l=Math.min(h.val,c.val)+u.val,_=l+n;if(_<r)return!0;const f=O(o,new J,!1);l=Math.max(h.val,c.val);for(let n=1;n<s.length-1;n++){const r=s[n];U.greatEllipticDistance(e,t,i.x,i.y,r.x,r.y,f,null,null),f.val>l&&(l=f.val)}return _=l+n,_<r}catch(m){o.error=m,o.hasError=!0}finally{j(o)}}function fe(e,t,s,n,i,r,o,m){let a;if(n.length%2==0){const e=n.length>>1,t=n[e],s=n[e-1];a=F.lerp(t,s,.5)}else{a=n[n.length-1>>1].clone()}const h=a.clone(),c=$(e,t,h,75/180*Math.PI);return!!_e(e,t,n,i,h,c)&&(null!==r&&(r.setCoordsPoint2D(a),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(h),null!==m&&(m[0]=c),!0)}function de(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=O(o,new J,!1);U.greatEllipticDistance(e,t,i.x,i.y,s.x,s.y,m,null,null);return m.val+n<r}catch(m){o.error=m,o.hasError=!0}finally{j(o)}}function ge(e,t,s,n,i,r,o,m){const a=$(e,t,n,75/180*Math.PI);return!!de(e,t,n,i,n,a)&&(null!==r&&(r.setCoordsPoint2D(n),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(n),null!==m&&(m[0]=a),!0)}function pe(e,t){return new V(e,t)}function Pe(e){return Q(e,0)||Z(e,0),e}class xe{constructor(e){this.m_bRunningInGnomonic=!1,this.m_bNeedsSimplify=!1,this.m_gnomonic=null,this.m_gnomonicCenterRad=new F,this.m_minGnomonicRadius=Number.NaN,this.m_progressTracker=e}isRunningInGnomonic(){return this.m_bRunningInGnomonic}needsSimplify(){return this.m_bNeedsSimplify}getGnomonic(){return this.m_gnomonic}}class be extends xe{constructor(e,t,s){super(e.m_progressTracker),this.m_segIter=null,this.m_bNextSegmentCannotJoin=!1,this.m_currentDensifiedDelta=[0],this.m_currentBufferedDelta=0,this.m_lastAzimuth=0,this.m_startAzimuth=[0],this.m_endAzimuth=[0],this.m_numWinds=0,this.m_debugCounter=0,this.m_bufferHelper=new c,this.m_densifiedPoints=[],this.m_bufferer=e,this.m_multiPath=t,this.m_densified=s,this.m_bNeedsSimplify=!0;const i=new n;this.m_multiPath.queryEnvelope(i);const r=i.getCenter(),o=r.clone();o.scale(this.m_bufferer.m_rpu),this.m_gnomonic=pe(this.m_bufferer.m_gcs,r),this.m_gnomonicCenterRad=o.clone(),this.m_minGnomonicRadius=$(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,o,75/180*Math.PI)}next(){let e;if(this.m_bNextSegmentCannotJoin)return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e;if(null===this.m_segIter){if(this.m_segIter=this.m_multiPath.getImpl().querySegmentIterator(),!this.m_segIter.nextPath())return null;null!==this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}if(!this.m_segIter.hasNextSegment()){if(!this.m_segIter.nextPath())return null;null!=this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}let t=null;this.m_currentBufferedDelta=0,this.m_currentDensifiedDelta=[0],this.m_numWinds=0,this.m_lastAzimuth=Number.NaN,this.m_bNextSegmentCannotJoin=!1,this.m_densifiedPoints.length=0;const s=16;let n=0;const i=new F,r=new F;for(;this.m_segIter.hasNextSegment()&&this.m_numWinds<s;){const e=this.m_segIter.nextSegment();if(i.setCoordsPoint2D(e.getStartXY()),r.setCoordsPoint2D(e.getEndXY()),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),K(i,r))i.x=r.x;else if(ee(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),ee(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),K(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0;const s=te(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,i,r,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta);if(0===n)this.m_bRunningInGnomonic=this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(this.m_densifiedPoints));else if(this.m_bRunningInGnomonic){if(!this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}else{if(fe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_densifiedPoints,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,null,null,null)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}if(0===s||se(i,r)?(this.m_bufferHelper.setEmpty(),this.m_bufferer.bufferPoint2D(i,this.m_bRunningInGnomonic,this.m_bufferHelper),this.m_bNextSegmentCannotJoin=!0):(this.m_bufferHelper.setEmpty(),this.m_bNextSegmentCannotJoin=this.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(s,this.m_bufferHelper)),this.m_bNextSegmentCannotJoin){this.m_segIter.previousSegment(),this.m_segIter.hasPreviousSegment()?(this.m_segIter.previousSegment(),this.m_segIter.nextSegment()):this.m_segIter.resetToFirstSegment(),null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0);break}null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0),null===t&&(t=new c,t.addPathPoint2D(null,0,!0)),this.addJoinAndBufferLeftSide(t),n++}if(this.m_currentDensifiedDelta=[0],n>0){const e=this.m_segIter.getStartPointIndex(),s=this.m_segIter.getPathIndex();for(;n>0;){if(this.m_segIter.previousSegment(),i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),r.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getEndPointIndex())),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic)if(K(i,r))i.x=r.x;else if(ee(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),ee(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),K(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0,te(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,r,i,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta),this.addJoinAndBufferLeftSide(t),n--}return i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),i.scale(this.m_bufferer.m_rpu),this.m_currentBufferedDelta=he(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,i,this.m_lastAzimuth+.5*Math.PI,this.m_lastAzimuth+1.5*Math.PI,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,t),this.m_segIter.resetToVertex(e,s),this.m_segIter.nextSegment(),t}return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e}isSegmentBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&_e(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new F,s=new F,n=[0];return fe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=pe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t){return this.m_bufferer.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(this.m_densifiedPoints,e,this.m_startAzimuth[0],this.m_endAzimuth[0],this.m_bRunningInGnomonic,t)}addJoinAndBufferLeftSide(e){const t=this.m_densifiedPoints[0];let s=Number.NaN,n=this.m_startAzimuth[0]-ne;const i=this.m_endAzimuth[0]+ne;let r=!1;if(!Number.isNaN(this.m_lastAzimuth)){this.m_lastAzimuth>=this.m_startAzimuth[0]?(s=this.m_lastAzimuth+ne,n=s+Math.PI-(this.m_lastAzimuth-this.m_startAzimuth[0])):(s=this.m_lastAzimuth+ne,n=s+Math.PI-(L-(this.m_startAzimuth[0]-this.m_lastAzimuth))),r=!(this.m_lastAzimuth>=this.m_startAzimuth[0]&&this.m_lastAzimuth-this.m_startAzimuth[0]<=Math.PI)&&!(this.m_lastAzimuth<this.m_startAzimuth[0]&&this.m_startAzimuth[0]-this.m_lastAzimuth>=Math.PI);let i=!1;if(Math.abs(n-s)<=.5*this.m_bufferer.m_cornerStep&&(r||(i=!0)),i){if(e.removePointFromPath(0,e.getPointCount()-1),!this.m_bRunningInGnomonic){const t=new F;t.setCoordsPoint2D(e.getXY(e.getPointCount()-1)),t.scale(this.m_bufferer.m_rpu),t.x-this.m_currentBufferedDelta<-Math.PI?this.m_currentBufferedDelta-=L:t.x-this.m_currentBufferedDelta>Math.PI&&(this.m_currentBufferedDelta+=L)}n=.5*(n+s)}else if(r){const s=new F;s.setCoordsPoint2D(t),s.scale(1/this.m_bufferer.m_rpu),e.insertPoint2D(0,-1,s)}else he(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_densifiedPoints[0],s,n,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e)}this.m_startAzimuth[0]!==this.m_lastAzimuth&&this.m_numWinds++,ae(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_bufferer.m_curveType,this.m_densifiedPoints,n,i,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e),this.m_lastAzimuth=this.m_endAzimuth[0]}}class ye extends xe{constructor(e,t){super(e.m_progressTracker),this.m_pointIndex=-1,this.m_bufferer=e,this.m_multiPoint=t,this.m_bNeedsSimplify=!1;const s=new n;this.m_multiPoint.queryEnvelope(s);const i=s.getCenter(),r=i.clone();r.scale(this.m_bufferer.m_rpu),this.m_gnomonic=pe(this.m_bufferer.m_gcs,i),this.m_gnomonicCenterRad=r.clone(),this.m_minGnomonicRadius=$(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,r,75/180*Math.PI)}next(){if(this.m_bNeedsSimplify=!1,++this.m_pointIndex===this.m_multiPoint.getPointCount())return null;const e=this.m_multiPoint.getXY(this.m_pointIndex);e.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic=this.isPointBufferInCurrentGnomonic(e),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(e));const t=new c,s=this.m_bufferer.bufferPoint2D(e,this.m_bRunningInGnomonic,t);return this.m_bNeedsSimplify=s,t}isPointBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&de(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new F,s=new F,n=[0];return ge(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=pe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}}class we{getOperatorType(){return 10110}supportsCurves(){return!1}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(t,s,n,i,r,o,m,a){if(m){const m=new Ce(t,s,n,i,r,!1,o,a);return(new e).executeMany(m,s,a)}return new Ce(t,s,n,i,r,!1,o,a)}execute(e,s,n,i,r,o,m){const a=new t([e]),h=[i];return this.executeMany(a,s,n,h,r,!1,o,m).next()}}class Ce extends s{constructor(e,t,s,o,m,a,h,c){super(),this.m_currentUnionEnvelope2D=new n,this.m_index=-1,this.m_dindex=-1,this.m_progressTracker=c,a&&i(""),t||r("");0===t.getCoordinateSystemType()&&r(""),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=s,this.m_distances=o,this.m_convergenceOffset=m,this.m_bOutlineOnly=a,this.m_bUnion=h}next(){let e;for(;e=this.m_inputGeoms.next();)return o(e),m(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.m_dindex+1<this.m_distances.length&&this.m_dindex++,this.geodesicBuffer(e,this.m_distances[this.m_dindex]);return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodesicBuffer(e,t){return re(e,this.m_spatialReference,this.m_curveType,t,this.m_convergenceOffset,this.m_progressTracker)}}export{we as OperatorGeodesicBuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{S as e,o as t,q as r,r as s,u as n,C as i}from"./Polyline.js";class m{getOperatorType(){return 10310}supportsCurves(){return!0}accelerateGeometry(e,t,r){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,r,s,n){return new a(e,r,s,t,-1,-1,n)}execute(t,r,s,n,i){const m=new e([t]);return this.executeMany(m,r,s,n,i).next()}}class a extends t{constructor(e,t,n,i,m,a,o){super(),this.m_progressTracker=o,a>0&&r(""),4!==n&&m>0&&r(""),t||s("");0===t.getCoordinateSystemType()&&s(""),i>0||m>0||s(""),this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=n,this.m_maxLengthMeters=i,this.m_maxDeviationMeters=m,this.m_maxAngle=a}next(){{let e;for(;e=this.m_inputGeoms.next();)return n(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.geodeticDensify(e);return null}}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodeticDensify(e){return i(e,this.m_spatialReference,this.m_curveType,this.m_maxLengthMeters,this.m_maxDeviationMeters,this.m_progressTracker)}}export{m as OperatorGeodeticDensifyByLength,a as OperatorGeodeticDensifyCursor};
5
+ import{S as e,w as t,n as r,m as s,y as n,H as i}from"./Polyline.js";class m{getOperatorType(){return 10310}supportsCurves(){return!0}accelerateGeometry(e,t,r){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,r,s,n){return new a(e,r,s,t,-1,-1,n)}execute(t,r,s,n,i){const m=new e([t]);return this.executeMany(m,r,s,n,i).next()}}class a extends t{constructor(e,t,n,i,m,a,o){super(),this.m_progressTracker=o,a>0&&r(""),4!==n&&m>0&&r(""),t||s("");0===t.getCoordinateSystemType()&&s(""),i>0||m>0||s(""),this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=n,this.m_maxLengthMeters=i,this.m_maxDeviationMeters=m,this.m_maxAngle=a}next(){{let e;for(;e=this.m_inputGeoms.next();)return n(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.geodeticDensify(e);return null}}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodeticDensify(e){return i(e,this.m_spatialReference,this.m_curveType,this.m_maxLengthMeters,this.m_maxDeviationMeters,this.m_progressTracker)}}export{m as OperatorGeodeticDensifyByLength,a as OperatorGeodeticDensifyCursor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{e as t,r as e,u as i,p as n,W as s,F as o,w as a,G as r,a1 as m,a3 as u,a4 as c,a5 as h,ai as l,aj as _,ak as d,al as p,am as g,an as x,ao as y,ap as P,aq as S,ar as f,O as G,as as D,at as v,H as T,au as w,a as b,t as M,av as E,aw as C,D as R,x as B,ax as I,ay as N,az as A,aA as q,a6 as F}from"./Polyline.js";import{OperatorShapePreservingDensify as k}from"./OperatorShapePreservingDensify.js";function X(){return new n}class Y{constructor(t,e,i){void 0!==t?this.reset(t,e,i):this.reset(1,0,1)}reset(t,e,i){this.m_a=t,this.m_e2=e,this.m_b=this.m_a*Math.sqrt(1-this.m_e2),this.m_unitToDegree=i,this.m_unitToRad=.017453292519943295*i,this.m_u180=180/this.m_unitToDegree,this.m_u360=360/this.m_unitToDegree}calculateBbox(t,e,i,n){const s={stack:[],error:void 0,hasError:!1};try{const o=m(s,new u,!1),a=m(s,new u,!1),r=m(s,new u,!1);c.geodeticDistance(this.m_a,this.m_e2,t*this.m_unitToRad,e*this.m_unitToRad,i*this.m_unitToRad,n*this.m_unitToRad,r,o,a,0);const h=Math.cos(o.val),l=Math.cos(a.val+3.141592653589793),_=e*this.m_unitToRad,d=B.phiToEta(this.m_e2,_),p=Math.sin(o.val)*Math.cos(d);let g=e;if(h*l<0){const t=h<0?-1:1,e=Math.acos(Math.abs(p))*t;g=B.etaToPhi(this.m_e2,e)/this.m_unitToRad}let x=I((i-t)*this.m_unitToRad,2*Math.PI);Math.abs(x)>Math.PI&&(x=x>0?x-2*Math.PI:x+2*Math.PI),x/=this.m_unitToRad,i=t+x;const y=X();return y.xmin=Math.min(t,i),y.xmax=Math.max(t,i),y.ymin=Math.min(e,n),y.ymin=Math.min(y.ymin,g),y.ymax=Math.max(e,n),y.ymax=Math.max(y.ymax,g),y}catch(o){s.error=o,s.hasError=!0}finally{h(s)}}minDistanceGeodesic(t,e){const i=O(t),n=O(e);if(i&&n)return this.lowerDistanceGeodetic_(t.xmin,t.ymin,e.xmin,e.ymin);const s=this.normalizeGeodesic_(e,t);return U(t,s)?t.ymin>=s.ymax?this.minDistanceGeodesicUpDown_(t,s):s.ymin>=t.ymax?this.minDistanceGeodesicUpDown_(s,t):t.xmin>s.xmax?this.minDistanceGeodesicLeftRight_(s,t):this.minDistanceGeodesicLeftRight_(t,s):0}sqrMaxMinDistanceGeodesic(t,e){return l(0),0}maxDistanceGeodesic(t,e){return l(0),0}sqrMinDistance(t,e){return l(0),0}sqrMaxDistance(t,e){return l(0),0}sqrMaxMinDistance(t,e){return l(0),0}calculateMaxDim(t){return l(0),0}lowerDistanceGeodesic(t,e,i,n){return l(0),0}upperDistanceGeodesic(t,e,i,n){return l(0),0}normalizeGeodesic_(t,e){const i=t.clone(),n=t.clone();let s=L(i,e);if(0===s)return i;for(;n.xmax>e.xmin;){n.xmin-=this.m_u360,n.xmax-=this.m_u360;const t=L(n,e);if(t<s&&(i.assign(n),s=t,0===s))return i}for(n.assign(t);n.xmin<e.xmax;){n.xmin+=this.m_u360,n.xmax+=this.m_u360;const t=L(n,e);if(t<s&&(i.assign(n),s=t,0===s))return i}return i}lowerDistanceGeodetic_(t,e,i,n){const s={stack:[],error:void 0,hasError:!1};try{const o=m(s,new u,!1);{const s=this.m_b*this.m_b/this.m_a,a=B.phiToPhig(this.m_e2,this.m_unitToRad*e),r=B.phiToPhig(this.m_e2,this.m_unitToRad*n);c.geodeticDistance(s,0,this.m_unitToRad*t,a,this.m_unitToRad*i,r,o,null,null,0)}return o.val}catch(o){s.error=o,s.hasError=!0}finally{h(s)}}upperDistanceGeodetic_(t,e,i,n){return l(0),0}minDistanceGeodesicUpDown_(t,e){if(e.xmin<=t.xmin?e.xmax>=t.xmin:t.xmax>=e.xmin)return this.lowerDistanceGeodetic_(0,t.ymin,0,e.ymax);if(e.xmin>t.xmax){const i=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);if(e.xmax-t.xmin<this.m_u180)return i;const n=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);return Math.min(i,n)}{const i=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);if(t.xmax-e.xmin<this.m_u180)return i;const n=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);return Math.min(i,n)}}minDistanceGeodesicLeftRight_(t,e){let i=Math.abs(t.xmax-e.xmin);for(;i>this.m_u180;)i-=this.m_u360;let n=Math.abs(t.xmin-e.xmax);for(;n>this.m_u180;)n-=this.m_u360;return Math.abs(i)<=Math.abs(n)?this.minDistanceGeodesicLeftRightNormalized_(t,e):this.minDistanceGeodesicLeftRightNormalized_(e,t)}minDistanceGeodesicLeftRightNormalized_(t,e){let i,n;return i=this.lowerDistanceGeodetic_(t.xmax,t.ymin,e.xmin,e.ymin),t.ymin>=e.ymin&&t.ymin<=e.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymin,e.xmin,e.ymin,e.ymax),i=Math.min(i,n)),e.ymin>=t.ymin&&e.ymin<=t.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymin,t.xmax,t.ymin,t.ymax),i=Math.min(i,n)),n=this.lowerDistanceGeodetic_(t.xmax,t.ymax,e.xmin,e.ymax),i=Math.min(i,n),t.ymax>=e.ymin&&t.ymax<=e.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymax,e.xmin,e.ymin,e.ymax),i=Math.min(i,n)),e.ymax>=t.ymin&&e.ymax<=t.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymax,t.xmax,t.ymin,t.ymax),i=Math.min(i,n)),i}normalizeDistance_(t){return l(0),0}lowerDistanceGeodeticSegMeridional_(t,e,i,n,s,o){let a=this.lowerDistanceGeodeticPtMeridional_(t,e,n,s,o);const r=this.lowerDistanceGeodeticPtMeridional_(t,i,n,s,o);let m=this.lowerDistanceGeodeticPtMeridional_(n,s,t,e,i);const u=this.lowerDistanceGeodeticPtMeridional_(n,o,t,e,i);return a=Math.min(a,r),m=Math.min(m,u),Math.min(a,m)}minDistanceGeodesicPointBox_(t,e,i){return l(0),0}lowerDistanceGeodeticPtMeridional_(e,i,n,s,o){const a={stack:[],error:void 0,hasError:!1};try{const l=this.m_b*this.m_b/this.m_a,_=B.phiToPhig(this.m_e2,this.m_unitToRad*i),g=B.phiToPhig(this.m_e2,this.m_unitToRad*s),x=B.phiToPhig(this.m_e2,this.m_unitToRad*o),y=m(a,new u,!1);c.geodeticDistance(l,0,this.m_unitToRad*n,g,this.m_unitToRad*e,_,y,null,null,0);const P=m(a,new u,!1);c.geodeticDistance(l,0,this.m_unitToRad*n,x,this.m_unitToRad*e,_,P,null,null,0);const S=d(1,0,new t(this.m_unitToRad*e,_)),f=d(1,0,new t(this.m_unitToRad*n,g)),G=d(1,0,new t(this.m_unitToRad*n,x));let D=new p;D.setCrossProductVector(f,G);const v=f.dotProduct(G);if(D.length()<1.568e-10)return v>=0?Math.min(y.val,P.val):0;D=D.getUnitVector();let T=new p;if(T.setCrossProductVector(D,S),T.length()<1.568e-10){return Math.min(y.val,P.val)-1e-5*l}T=T.getUnitVector();let w=S.sub(D.mul(S.dotProduct(D)));{const t=new p;t.setCrossProductVector(f,w);const i=new p;i.setCrossProductVector(w,G);let n=D.dotProduct(t)>0&&D.dotProduct(i)>0;if(n||(w.negateThis(),t.setCrossProductVector(f,w),i.setCrossProductVector(w,G),n=D.dotProduct(t)>0&&D.dotProduct(i)>0),n){const t={stack:[],error:void 0,hasError:!1};try{w=w.getUnitVector();const i=N(1,0,w),n=m(t,new u,!1);c.geodeticDistance(l,0,this.m_unitToRad*e,_,i.x,i.y,n,null,null,0);const s=Math.min(y.val,P.val);return Math.min(s,n.val)}catch(r){t.error=r,t.hasError=!0}finally{h(t)}}}return Math.min(y.val,P.val)}catch(l){a.error=l,a.hasError=!0}finally{h(a)}}fixAngle(t){return l(0),0}moveCloser(t,e){return l(0),0}}function O(t){return t.xmin===t.xmax&&t.ymin===t.ymax}function U(t,e){return e.xmax<t.xmin||e.xmin>t.xmax||e.ymax<t.ymin||e.ymin>t.ymax}function L(t,e){let i,n=0;return i=t.xmin-e.xmax,i>n&&(n=i),i=e.xmin-t.xmax,i>n&&(n=i),n}function V(){return{outPoint:new t,index:-1,t:Number.NaN}}function z(t,e,i,n){t.outPoint.assign(e),t.index=i,t.t=n}function H(t,e,i,n,s,o){if(t.getGeometryType()===r.enumPolygon){for(;n.nextPath();)if(n.hasNextSegment()){const e=n.nextSegment();if(0!==A(t,e.getEndXY(),0))return z(s,e.getEndXY(),-1,Number.NaN),z(o,e.getEndXY(),-1,Number.NaN),!0}n.resetToFirstPath()}if(e.getGeometryType()===r.enumPolygon){for(;i.nextPath();)if(i.hasNextSegment()){const t=i.nextSegment();if(0!==A(e,t.getEndXY(),0))return z(s,t.getEndXY(),-1,Number.NaN),z(o,t.getEndXY(),-1,Number.NaN),!0}i.resetToFirstPath()}return!1}function j(t){const e=t.getPathCount(),i=new Array(t.getSegmentCount());let n=0;for(let s=0;s<e;++s){const e=n+t.getSegmentCountPath(s);for(let o=n,a=t.getPathStart(s);o<e;++o,++a)i[o]=a;n=e}return q(i),i}class W{}function J(e){return{outPoint:void 0===e?new t:e.clone()}}function K(t,e){t.outPoint.assign(e.outPoint)}function Q(){return new n}class Z{constructor(e,i,n,s,o=0,a=4){this.m_ptDistFrom=new t,this.m_segStartPt=new t,this.m_segEndPt=new t,this.m_geodeticLength=new u,this.m_az12=new u,this.m_minGeodeticDist=new u,this.m_segStartPt3d=new p,this.m_segEndPt3d=new p,this.m_sr=s,this.m_distCurveType=o,this.m_segCurveType=a,this.m_inputGCS=this.m_sr.getGCS(),this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_bIsPannablePcs=2===this.m_sr.getCoordinateSystemType()&&this.m_sr.isPannable();const r=F();this.m_inputGCS.querySpheroidData(r),this.m_a=r.majorSemiAxis,this.m_eSquared=r.e2,this.setPointDistFrom(e),this.setSegmentEndPoints(i,n)}setSegmentEndPoints(t,e){this.m_segStartPt.assign(t),this.m_segEndPt.assign(e),this.m_bIsPannablePcs||(this.m_segStartPt.mulThis(this.m_rpu),this.m_segEndPt.mulThis(this.m_rpu)),2===this.m_segCurveType&&(this.m_segStartPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segStartPt)),this.m_segEndPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segEndPt))),this.calculateAndUpdateSegmentLength()}setPointDistFrom(t){this.m_ptDistFrom.assign(t),this.m_ptDistFrom.scale(this.m_rpu)}setSegmentCurveType(t){this.m_segCurveType=t}setDistanceCurveType(t){this.m_distCurveType=t}makeFunctor(){return e=>{let i;switch(this.m_segCurveType){case 0:case 1:case 3:{const s={stack:[],error:void 0,hasError:!1};try{const n=m(s,new u,!1),o=m(s,new u,!1);c.geodeticCoordinate(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_geodeticLength.val*e,this.m_az12.val,n,o,this.m_segCurveType),i=new t(n.val,o.val);break}catch(n){s.error=n,s.hasError=!0}finally{h(s)}}case 2:{const t=p.lerp(this.m_segStartPt3d,this.m_segEndPt3d,e);i=N(this.m_a,this.m_eSquared,t);break}case 4:i=t.lerp(this.m_segStartPt,this.m_segEndPt,e),this.m_bIsPannablePcs&&(y(this.m_sr,0,[i],1),i.mulThis(this.m_rpu));break;default:M("Invalid curve type")}return c.geodeticDistance(this.m_a,this.m_eSquared,this.m_ptDistFrom.x,this.m_ptDistFrom.y,i.x,i.y,this.m_minGeodeticDist,null,null,this.m_distCurveType),this.m_minGeodeticDist.val}}calculateAndUpdateSegmentLength(){switch(this.m_segCurveType){case 0:case 2:case 1:case 3:c.geodeticDistance(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_segEndPt.x,this.m_segEndPt.y,this.m_geodeticLength,this.m_az12,null,this.m_segCurveType);break;case 4:this.m_geodeticLength.val=t.distance(this.m_segStartPt,this.m_segEndPt);break;default:M("Invalid curve type")}}[Symbol.dispose](){this.m_geodeticLength[Symbol.dispose](),this.m_az12[Symbol.dispose](),this.m_minGeodeticDist[Symbol.dispose]()}}function $(){return new W}class tt{constructor(t,e,i,o,a){this.m_boxGeomA=Q(),this.m_boxGeomB=Q(),this.m_envGeomA=new n,this.m_envGeomB=new n,this.m_transformPCS2GCS=null,this.m_segmentBoxesA=new Map,this.m_segmentBoxesB=new Map,this.m_boundaryPtsA=[],this.m_boundaryPtsB=[],this.m_scaleToRadians=new s,this.m_scaleToDegrees=new s,this.m_inputSR=t,this.m_distCurveType=e,this.m_progressTracker=i,this.m_maxDistance=o,this.m_maxDeviation=a,this.m_inputGCS=t.getGCS(),this.m_peGeogcs=this.m_inputGCS.getPECoordSys(),this.m_tolerance=0;const r=F();this.m_inputGCS.querySpheroidData(r),this.m_a=r.majorSemiAxis,this.m_eSquared=r.e2,this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_envHelper=new Y(this.m_a,this.m_eSquared,1),4===this.m_distCurveType&&(this.m_distCurveType=0),this.m_boxGeomA.setEmpty(),this.m_boxGeomB.setEmpty(),this.m_envGeomA.setEmpty(),this.m_envGeomB.setEmpty(),this.m_bIsPannablePcs=2===this.m_inputSR.getCoordinateSystemType()&&this.m_inputSR.isPannable()}calculate(t,e,i,n){const s=J(),o=J();if(t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.checkGeometriesIntersect(t,e,s,o))return i&&K(i,s),n&&K(n,o),0;const a=this.prepareGeometry(t);if(a.isEmpty())return Number.NaN;const r=this.prepareGeometry(e);if(r.isEmpty())return Number.NaN;this.m_tolerance=this.computeTolerance(a,r);const m=this._ExecuteBruteForce(a,r,s,o);return m>this.m_maxDistance?Number.NaN:(i&&(this.prepareOutput(s),K(i,s)),n&&(this.prepareOutput(o),K(n,o)),m)}createDistanceFunctor(t,e,i){const n=new Z(t,e,i,this.m_inputSR,this.m_distCurveType);return this.m_bIsPannablePcs||1===this.m_inputSR.getCoordinateSystemType()||n.setSegmentCurveType(2),n}_NormalizeAndProject(t){if(this.m_inputSR.isPannable()&&(t=(new o).foldInto360Range(t,this.m_inputSR)),2===this.m_inputSR.getCoordinateSystemType()){const e=a(this.m_inputSR,this.m_inputGCS,null);t=(new o).execute(t,e,this.m_progressTracker)}return t}_ExecuteBruteForce(t,i,n,s){switch(t.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointGeometry(t,i,n,s);case r.enumMultiPoint:return this.calculateDistanceGeodeticMultipointGeometry(t,i,n,s);case r.enumPolyline:case r.enumPolygon:case r.enumEnvelope:return this.calculateDistanceGeodeticMultipathGeometry(t,i,n,s);default:e("")}}calculateDistanceGeodeticPointGeometry(t,i,n,s){switch(i.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointPoint(t,i,n,s);case r.enumMultiPoint:return this.calculateDistanceGeodeticPointMultipoint(t,i,n,s);case r.enumPolyline:case r.enumPolygon:return this.calculateDistanceGeodeticPointMultipath(t,i,n,s);default:e("")}}calculateDistanceGeodeticPointPoint(t,e,i,n){const s={stack:[],error:void 0,hasError:!1};try{const o=t.getXY();o.scale(this.m_rpu);const a=e.getXY();a.scale(this.m_rpu),i.outPoint.assign(o),n.outPoint.assign(a);const r=m(s,new u,!1);return c.geodeticDistance(this.m_a,this.m_eSquared,o.x,o.y,a.x,a.y,r,null,null,this.m_distCurveType),r.val}catch(o){s.error=o,s.hasError=!0}finally{h(s)}}calculateDistanceGeodeticPointMultipoint(t,e,i,n){return l(0),0}calculateDistanceGeodeticPointMultipath(e,i,n,s){const o={stack:[],error:void 0,hasError:!1};try{const a=new t,r=new t;a.assign(e.getXY()),r.assign(e.getXY()),n.outPoint.assign(r.mul(this.m_rpu)),this.m_bIsPannablePcs&&_(this.m_inputSR,[a],1,!1),this.computeEnvelopesAndBoxes(e,i);const u=this.estimateMinimumDistance(n,s);let c=u<this.m_maxDistance?u:this.m_maxDistance;const h=i.getImpl(),d=new t(0,0),p=new t(0,0),g=[1],x=this.canUseSpatialTree(e,i),y=$();x&&this.buildSpatialTree(y,i);const P=Q();P.setCoords({xmin:r.x,ymin:r.y,xmax:r.x,ymax:r.y});const S=m(o,this.createDistanceFunctor(r,d,p),!1),f=h.querySegmentIterator();f.stripAttributes();if(x)l(0);else for(;f.nextPath();)for(;f.hasNextSegment();){const t=f.nextSegment(),e=this.findOrComputeBoxSegment(f.getStartPointIndex(),t,this.m_segmentBoxesB);if(this.m_envHelper.minDistanceGeodesic(P,e)>c)continue;const i=this.calculateDistanceGeodeticPointSegment(a,r,t,g,S);if(i.second<c&&(this.updateOutputSegment(s,t,i.first),c=i.second,0===c))return 0}return c===this.m_maxDistance?Number.POSITIVE_INFINITY:c}catch(a){o.error=a,o.hasError=!0}finally{h(o)}}calculateDistanceGeodeticMultipointGeometry(t,i,n,s){switch(i.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointMultipoint(i,t,s,n);case r.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipoint(t,i,n,s);case r.enumPolyline:case r.enumPolygon:case r.enumEnvelope:return this.calculateDistanceGeodeticMultipointMultipath(t,i,n,s);default:e("")}}calculateDistanceGeodeticMultipointMultipoint(e,i,n,s){const o={stack:[],error:void 0,hasError:!1};try{const a=m(o,new u,!1);this.computeEnvelopesAndBoxes(e,i);const r=this.estimateMinimumDistance(n,s);let h=r<this.m_maxDistance?r:this.m_maxDistance;const l=new t,_=new t,g=e.getImpl(),x=i.getImpl(),y=Q(),P=g.getPointCount(),S=x.getPointCount();for(let t=0;t<P;++t){if(l.assign(g.getXY(t)),y.setCoords({xmin:l.x,ymin:l.y,xmax:l.x,ymax:l.y}),this.m_envHelper.minDistanceGeodesic(y,this.m_boxGeomB)>h)continue;l.scale(this.m_rpu);const e=d(this.m_a,this.m_eSquared,l);for(let t=0;t<S;++t){_.assign(x.getXY(t)),_.scale(this.m_rpu);const i=d(this.m_a,this.m_eSquared,_);if(!(p.distance(e,i)>=h)&&(c.geodeticDistance(this.m_a,this.m_eSquared,l.x,l.y,_.x,_.y,a,null,null,this.m_distCurveType),a.val<h&&(n.outPoint.assign(l),s.outPoint.assign(_),h=a.val,0===h)))return h}}return h===this.m_maxDistance?Number.POSITIVE_INFINITY:h}catch(a){o.error=a,o.hasError=!0}finally{h(o)}}calculateDistanceGeodeticMultipointMultipath(e,i,n,s){const o={stack:[],error:void 0,hasError:!1};try{const a=i.getImpl().querySegmentIterator();a.stripAttributes(),this.computeEnvelopesAndBoxes(e,i);const r=this.estimateMinimumDistance(n,s);let u=r<this.m_maxDistance?r:this.m_maxDistance;const c=new t,h=new t(0,0),d=new t(0,0),p=new t(0,0),g=[0],x=Q(),y=m(o,this.createDistanceFunctor(h,d,p),!1),P=$(),S=this.canUseSpatialTree(e,i);S&&this.buildSpatialTree(P,i);const f=e.getPointCount();for(let t=0;t<f;++t)if(c.assign(e.getXY(t)),h.assign(e.getXY(t)),this.m_bIsPannablePcs&&_(this.m_inputSR,[c],1,!1),x.setCoords({xmin:h.x,ymin:h.y,xmax:h.x,ymax:h.y}),!(this.m_envHelper.minDistanceGeodesic(x,this.m_boxGeomB)>u))if(y.setPointDistFrom(h),S)l(0);else{for(;a.nextPath();)for(;a.hasNextSegment();){const t=a.nextSegment();if(this.m_envHelper.minDistanceGeodesic(x,this.findOrComputeBoxSegment(a.getStartPointIndex(),t,this.m_segmentBoxesB))>u)continue;const e=this.calculateDistanceGeodeticPointSegment(c,h,t,g,y);if(e.second<u&&(n.outPoint.assign(h.mul(this.m_rpu)),this.updateOutputSegment(s,t,e.first),u=e.second,0===u))return 0}a.resetToFirstPath()}return u===this.m_maxDistance?Number.POSITIVE_INFINITY:u}catch(a){o.error=a,o.hasError=!0}finally{h(o)}}calculateDistanceGeodeticMultipathGeometry(t,i,n,s){switch(i.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointMultipath(i,t,s,n);case r.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipath(i,t,s,n);case r.enumPolyline:case r.enumPolygon:case r.enumEnvelope:return this.calculateDistanceGeodeticMultipathMultipath(t,i,n,s);default:e("")}}calculateDistanceGeodeticMultipathMultipath(t,e,i,n){const s=[t],o=[e],a=this.swapGeometries(s,o),r=s[0],m=o[0];this.computeEnvelopesAndBoxes(s[0],o[0]);const u=this.estimateMinimumDistance(i,n),c=this.calculateDistanceGeodeticMultipathMultipath_(r,m,i,n,u);return a&&(n.outPoint=g(i.outPoint,i.outPoint=n.outPoint)),c}calculateDistanceGeodeticMultipathMultipath_(e,i,n,s,o=Number.MAX_VALUE){const a={stack:[],error:void 0,hasError:!1};try{let r=o;const u=new t(0,0),c=new t,h=new t(0,0),_=new t,d=new t(0,0),p=new t,g=new t,S=new t,f=[new t],G=[0],D=[0],v=Q(),T=Q(),w=m(a,this.createDistanceFunctor(d,u,h),!1),b=$(),M=this.canUseSpatialTree(e,i);M&&this.buildSpatialTree(b,i);const E=i.querySegmentIterator();E.stripAttributes();const C=new x,R=j(e);for(let t=0;t<R.length;++t){const i=R[t];e.getSegmentBuffer(i,C,!0);const o=C.get();if(v.assign(this.findOrComputeBoxSegment(i,o,this.m_segmentBoxesA)),M)l(0);else{if(d.assign(o.getStartXY()),p.assign(o.getStartXY()),g.assign(o.getEndXY()),S.assign(o.getEndXY()),this.m_bIsPannablePcs&&(y(this.m_inputSR,0,[p],1),y(this.m_inputSR,0,[S],1)),this.m_envHelper.minDistanceGeodesic(v,this.m_boxGeomB)>r)continue;for(;E.nextPath();){for(;E.hasNextSegment();){const t=E.nextSegment();if(u.assign(t.getStartXY()),c.assign(t.getStartXY()),h.assign(t.getEndXY()),_.assign(t.getEndXY()),o.intersect(t,f,G,D,this.m_tolerance))return this.updateOutputSegment(n,o,G[0]),this.updateOutputSegment(s,t,D[0]),0;if(this.m_bIsPannablePcs&&(y(this.m_inputSR,0,[c],1),y(this.m_inputSR,0,[_],1)),T.assign(this.findOrComputeBoxPoint(E.getStartPointIndex(),c,_,this.m_segmentBoxesB)),this.m_envHelper.minDistanceGeodesic(v,T)>r)continue;w.setSegmentEndPoints(u,h),w.setPointDistFrom(p);let e=P(w.makeFunctor(),0,1,1e-10);if(e.second<r&&(n.outPoint.assign(p.mul(this.m_rpu)),this.updateOutputSegment(s,t,e.first),r=e.second,0===r))break;if(w.setPointDistFrom(S),e=P(w.makeFunctor(),0,1,1e-10),e.second<r&&(n.outPoint.assign(S.mul(this.m_rpu)),this.updateOutputSegment(s,t,e.first),r=e.second,0===r))break;if(w.setSegmentEndPoints(d,g),w.setPointDistFrom(c),e=P(w.makeFunctor(),0,1,1e-10),e.second<r&&(this.updateOutputSegment(n,o,e.first),s.outPoint.assign(c.mul(this.m_rpu)),r=e.second,0===r))break;if(w.setPointDistFrom(_),e=P(w.makeFunctor(),0,1,1e-10),e.second<r&&(this.updateOutputSegment(n,o,e.first),s.outPoint.assign(_.mul(this.m_rpu)),r=e.second,0===r))break}if(0===r)return 0}E.resetToFirstPath()}}return r===this.m_maxDistance?Number.POSITIVE_INFINITY:r}catch(r){a.error=r,a.hasError=!0}finally{h(a)}}calculateDistanceGeodeticPointSegment(t,e,i,n,s){const o=i.getStartXY(),a=i.getEndXY();return i.intersectPoint(t,n,this.m_tolerance)?S(n[0],0):(s.setPointDistFrom(e),s.setSegmentEndPoints(o,a),P(s.makeFunctor(),0,1,1e-10))}prepareGeometry(t){let e=t.clone();const i=t.getGeometryType();if(i===r.enumPoint||i===r.enumMultiPoint)return this._NormalizeAndProject(e);if(i===r.enumEnvelope&&(e=this.envelopeToPolygon(e)),this.m_inputSR.isPannable())return this.prepareGeometryPannable(e,4);if(2===this.m_inputSR.getCoordinateSystemType()){if(e=f(e,this.m_inputSR,0,null),e.isEmpty())return e;e=(new k).execute(e,this.m_inputSR,5e4,this.m_maxDeviation/2,0,null);const t=this.m_inputSR.getSRToGCSTransform();return(new o).execute(e,t,this.m_progressTracker)}const s=new n;e.queryLooseEnvelope(s);const a=this.m_inputSR.getPannableExtent();if(s.ymin<a.ymin||s.ymax>a.ymax){const t=new n(s.xmin-1,a.ymin,s.xmax+1,a.ymax);if(e=(new G).execute(e,t,this.m_inputSR,this.m_progressTracker),e.isEmpty())return e}return s.width()>2*a.width()?(e=D(e,-2*a.width(),2*a.width(),this.m_inputSR,!0,0,!0,this.m_progressTracker),e):e}prepareGeometryPannable(t,e){const i=new n;t.queryEnvelope(i);const s=this.m_inputSR.getPannableExtent();if(s.containsEnvelope(i))return t;const a=new v;s.queryIntervalX(a);const r=new v;return i.queryIntervalX(r),t=a.contains(r)?T(t,this.m_inputSR):(new o).foldInto360RangeGeodetic(t,this.m_inputSR,e)}prepareOutput(t){t.outPoint.scale(1/this.m_rpu),2===this.m_inputSR.getCoordinateSystemType()&&_(this.m_inputSR,[t.outPoint],1,!1)}updateOutputSegment(t,e,i){e.queryCoord2D(i,t.outPoint),this.m_bIsPannablePcs&&y(this.m_inputSR,0,[t.outPoint],1),t.outPoint.mulThis(this.m_rpu)}updateOutputPoint2D(t,e){l(0)}computeTolerance(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB);const i=new n(this.m_envGeomA);return i.mergeEnvelope2D(this.m_envGeomB),w(null,i)}envelopeToPolygon(t){const e=new b;return e.addEnvelope(t,!1),e}computeEnvelopesAndBoxes(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.m_boxGeomA=this.computeBoxGeometry(t,this.m_boundaryPtsA,this.m_segmentBoxesA),this.m_boxGeomB=this.computeBoxGeometry(e,this.m_boundaryPtsB,this.m_segmentBoxesB)}computeBoxGeometry(t,e,i){switch(t.getGeometryType()){case r.enumPoint:return this.computeBoxPoint(t,e);case r.enumMultiPoint:return this.computeBoxMultiPoint(t,e);case r.enumPolyline:case r.enumPolygon:return this.computeBoxMultiPath(t,e,i);default:M("Invalid geometry type")}}computeBoxPoint(t,e){const i=t.getXY();e.length=1,e[0]=i.mul(this.m_rpu);const n=Q();return n.setCoords({xmin:i.x,ymin:i.y,xmax:i.x,ymax:i.y}),n}computeBoxSegment(t){return l(0),{}}computeBoxMultiPoint(t,e){let i=!0;for(let s=0;s<t.getPointCount();++s){const n=t.getXY(s);if(i){e.length=4;for(let t=0;t<e.length;++t)e[t]=n.clone();i=!1}n.x<e[0].x&&(e[0]=n),n.y>e[1].y&&(e[1]=n),n.x>e[2].x&&(e[2]=n),n.y<e[3].y&&(e[3]=n)}for(let s=0;s<e.length;++s)e[s].mulThis(this.m_rpu);const n=Q();return t.queryEnvelope(n),n}computeBoxMultiPath(t,e,i){let n=!0;const s=Q();s.setEmpty();const o=t.querySegmentIterator();for(o.stripAttributes();o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),a=t.getStartXY(),r=t.getEndXY();if(this.m_bIsPannablePcs&&(y(this.m_inputSR,0,[a],1),y(this.m_inputSR,0,[r],1)),n){e.length=4;for(let t=0;t<e.length;++t)e[t]=a.clone();n=!1}a.x<e[0].x&&e[0].assign(a),a.y>e[1].y&&e[1].assign(a),a.x>e[2].x&&e[2].assign(a),a.y<e[3].y&&e[3].assign(a),r.x<e[0].x&&e[0].assign(r),r.y>e[1].y&&e[1].assign(r),r.x>e[2].x&&e[2].assign(r),r.y<e[3].y&&e[3].assign(r);const m=this.findOrComputeBoxPoint(o.getStartPointIndex(),a,r,i);s.mergeEnvelope2D(m)}for(let a=0;a<e.length;++a)e[a].mulThis(this.m_rpu);return s}findOrComputeBoxSegment(e,i,n){if(!n.has(e)){let s=Q();if(i.queryEnvelope(s),this.m_bIsPannablePcs){const e=t.construct(s.xmin,s.ymin),i=t.construct(s.xmax,s.ymax);y(this.m_inputSR,0,[e],1),y(this.m_inputSR,0,[i],1),s=this.m_envHelper.calculateBbox(e.x,e.y,i.x,i.y)}return n.set(e,s),s}return n.get(e)}findOrComputeBoxPoint(t,e,i,n){if(!n.has(t)){let s=Q();return s.setCoords({xmin:e.x,ymin:e.y,xmax:i.x,ymax:i.y}),this.m_bIsPannablePcs&&(s=this.m_envHelper.calculateBbox(s.xmin,s.ymin,s.xmax,s.ymax)),n.set(t,s),s}return n.get(t)}checkPointInPolygon(t,e){return l(0),!1}estimateMinimumDistance(t,e){const i={stack:[],error:void 0,hasError:!1};try{const n=t=>d(this.m_a,this.m_eSquared,t),s=this.m_boundaryPtsA.map(n),o=this.m_boundaryPtsB.map(n);let a=Number.MAX_VALUE,r=0,h=0;for(let t=0;t<s.length;++t)for(let e=0;e<o.length;++e){const i=p.distance(s[t],o[e]);i<a&&(a=i,r=t,h=e)}t.outPoint.assign(this.m_boundaryPtsA[r]),e.outPoint.assign(this.m_boundaryPtsB[h]);const l=m(i,new u,!1);return c.geodeticDistance(this.m_a,this.m_eSquared,this.m_boundaryPtsA[r].x,this.m_boundaryPtsA[r].y,this.m_boundaryPtsB[h].x,this.m_boundaryPtsB[h].y,l,null,null,this.m_distCurveType),l.val}catch(n){i.error=n,i.hasError=!0}finally{h(i)}}swapGeometries(t,e){return E(t[0])>E(e[0])&&(e[0]=g(t[0],t[0]=e[0]),this.m_envGeomB=g(this.m_envGeomA,this.m_envGeomA=this.m_envGeomB),!0)}canUseSpatialTree(t,e){return!1}checkGeometriesIntersect(t,e,i,n){let s=t.getGeometryType(),o=e.getGeometryType();if(this.m_envGeomA.isIntersecting(this.m_envGeomB)){if(s===r.enumPoint&&2===e.getDimension()){const s=[0],o=[t.getXY()];if(C(e,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}else if(o===r.enumPoint&&2===t.getDimension()){const s=[2],o=[e.getXY()];if(C(t,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}if(s===r.enumMultiPoint&&2===e.getDimension())return this.multipointIntersectsArea(t,e,i,n);if(o===r.enumMultiPoint&&2===t.getDimension())return this.multipointIntersectsArea(e,t,n,i);let a,m,u=t,c=e;if(s===r.enumEnvelope&&(a=this.envelopeToPolygon(t),u=a,s=r.enumPolygon),o===r.enumEnvelope&&(m=this.envelopeToPolygon(e),c=m,o=r.enumPolygon),R(s)&&R(o)){const t=u.querySegmentIterator(),e=c.querySegmentIterator(),s=V();if(H(u,c,t,e,s,V()))return i.outPoint.assign(s.outPoint),n.outPoint.assign(s.outPoint),!0}}return!1}multipointIntersectsArea(t,e,i,n){return l(0),!1}getNearestNeighbourVisitor(t,e,i,n,s,o,a){return l(0),{}}buildSpatialTree(t,e){l(0)}}class et{getOperatorType(){return 10316}supportsCurves(){return!0}accelerateGeometry(t,e,i){return!1}canAccelerateGeometry(t){return!1}execute(t,e,i,n,s){return this.executeEx(t,e,i,n,s,null,null,Number.NaN)}executeEx(t,n,s,o,a,r,m,u){if(s&&0!==s.getCoordinateSystemType()||e(""),i(t),i(n),t.isEmpty()||n.isEmpty())return Number.NaN;Number.isNaN(u)&&(u=Number.MAX_VALUE);const c=new tt(s,o,a,u,1),h=J(),l=J(),_=c.calculate(t,n,h,l);return r&&r.outPoint.assign(h.outPoint),m&&m.outPoint.assign(l.outPoint),_}}export{et as OperatorGeodeticDistance,J as makeOutput};
5
+ import{e as t,m as e,y as i,o as n,Z as s,J as o,A as a,G as r,a4 as m,a6 as u,a7 as c,a8 as h,s as l,al as _,am as d,an as p,ao as g,ap as x,aq as y,ar as P,as as S,at as f,O as G,au as D,av as v,L as T,p as w,a as b,t as M,aw as E,ax as C,I as R,B,ay as I,az as N,q as A,aA as q,a9 as F}from"./Polyline.js";import{OperatorShapePreservingDensify as X}from"./OperatorShapePreservingDensify.js";function k(){return new n}class Y{constructor(t,e,i){void 0!==t?this.reset(t,e,i):this.reset(1,0,1)}reset(t,e,i){this.m_a=t,this.m_e2=e,this.m_b=this.m_a*Math.sqrt(1-this.m_e2),this.m_unitToDegree=i,this.m_unitToRad=.017453292519943295*i,this.m_u180=180/this.m_unitToDegree,this.m_u360=360/this.m_unitToDegree}calculateBbox(t,e,i,n){const s={stack:[],error:void 0,hasError:!1};try{const o=m(s,new u,!1),a=m(s,new u,!1),r=m(s,new u,!1);c.geodeticDistance(this.m_a,this.m_e2,t*this.m_unitToRad,e*this.m_unitToRad,i*this.m_unitToRad,n*this.m_unitToRad,r,o,a,0);const h=Math.cos(o.val),l=Math.cos(a.val+3.141592653589793),_=e*this.m_unitToRad,d=B.phiToEta(this.m_e2,_),p=Math.sin(o.val)*Math.cos(d);let g=e;if(h*l<0){const t=h<0?-1:1,e=Math.acos(Math.abs(p))*t;g=B.etaToPhi(this.m_e2,e)/this.m_unitToRad}let x=I((i-t)*this.m_unitToRad,2*Math.PI);Math.abs(x)>Math.PI&&(x=x>0?x-2*Math.PI:x+2*Math.PI),x/=this.m_unitToRad,i=t+x;const y=k();return y.xmin=Math.min(t,i),y.xmax=Math.max(t,i),y.ymin=Math.min(e,n),y.ymin=Math.min(y.ymin,g),y.ymax=Math.max(e,n),y.ymax=Math.max(y.ymax,g),y}catch(o){s.error=o,s.hasError=!0}finally{h(s)}}minDistanceGeodesic(t,e){const i=O(t),n=O(e);if(i&&n)return this.lowerDistanceGeodetic_(t.xmin,t.ymin,e.xmin,e.ymin);const s=this.normalizeGeodesic_(e,t);return U(t,s)?t.ymin>=s.ymax?this.minDistanceGeodesicUpDown_(t,s):s.ymin>=t.ymax?this.minDistanceGeodesicUpDown_(s,t):t.xmin>s.xmax?this.minDistanceGeodesicLeftRight_(s,t):this.minDistanceGeodesicLeftRight_(t,s):0}sqrMaxMinDistanceGeodesic(t,e){return l(0),0}maxDistanceGeodesic(t,e){return l(0),0}sqrMinDistance(t,e){return l(0),0}sqrMaxDistance(t,e){return l(0),0}sqrMaxMinDistance(t,e){return l(0),0}calculateMaxDim(t){return l(0),0}lowerDistanceGeodesic(t,e,i,n){return l(0),0}upperDistanceGeodesic(t,e,i,n){return l(0),0}normalizeGeodesic_(t,e){const i=t.clone(),n=t.clone();let s=L(i,e);if(0===s)return i;for(;n.xmax>e.xmin;){n.xmin-=this.m_u360,n.xmax-=this.m_u360;const t=L(n,e);if(t<s&&(i.assign(n),s=t,0===s))return i}for(n.assign(t);n.xmin<e.xmax;){n.xmin+=this.m_u360,n.xmax+=this.m_u360;const t=L(n,e);if(t<s&&(i.assign(n),s=t,0===s))return i}return i}lowerDistanceGeodetic_(t,e,i,n){const s={stack:[],error:void 0,hasError:!1};try{const o=m(s,new u,!1);{const s=this.m_b*this.m_b/this.m_a,a=B.phiToPhig(this.m_e2,this.m_unitToRad*e),r=B.phiToPhig(this.m_e2,this.m_unitToRad*n);c.geodeticDistance(s,0,this.m_unitToRad*t,a,this.m_unitToRad*i,r,o,null,null,0)}return o.val}catch(o){s.error=o,s.hasError=!0}finally{h(s)}}upperDistanceGeodetic_(t,e,i,n){return l(0),0}minDistanceGeodesicUpDown_(t,e){if(e.xmin<=t.xmin?e.xmax>=t.xmin:t.xmax>=e.xmin)return this.lowerDistanceGeodetic_(0,t.ymin,0,e.ymax);if(e.xmin>t.xmax){const i=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);if(e.xmax-t.xmin<this.m_u180)return i;const n=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);return Math.min(i,n)}{const i=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);if(t.xmax-e.xmin<this.m_u180)return i;const n=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);return Math.min(i,n)}}minDistanceGeodesicLeftRight_(t,e){let i=Math.abs(t.xmax-e.xmin);for(;i>this.m_u180;)i-=this.m_u360;let n=Math.abs(t.xmin-e.xmax);for(;n>this.m_u180;)n-=this.m_u360;return Math.abs(i)<=Math.abs(n)?this.minDistanceGeodesicLeftRightNormalized_(t,e):this.minDistanceGeodesicLeftRightNormalized_(e,t)}minDistanceGeodesicLeftRightNormalized_(t,e){let i,n;return i=this.lowerDistanceGeodetic_(t.xmax,t.ymin,e.xmin,e.ymin),t.ymin>=e.ymin&&t.ymin<=e.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymin,e.xmin,e.ymin,e.ymax),i=Math.min(i,n)),e.ymin>=t.ymin&&e.ymin<=t.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymin,t.xmax,t.ymin,t.ymax),i=Math.min(i,n)),n=this.lowerDistanceGeodetic_(t.xmax,t.ymax,e.xmin,e.ymax),i=Math.min(i,n),t.ymax>=e.ymin&&t.ymax<=e.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymax,e.xmin,e.ymin,e.ymax),i=Math.min(i,n)),e.ymax>=t.ymin&&e.ymax<=t.ymax&&(n=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymax,t.xmax,t.ymin,t.ymax),i=Math.min(i,n)),i}normalizeDistance_(t){return l(0),0}lowerDistanceGeodeticSegMeridional_(t,e,i,n,s,o){let a=this.lowerDistanceGeodeticPtMeridional_(t,e,n,s,o);const r=this.lowerDistanceGeodeticPtMeridional_(t,i,n,s,o);let m=this.lowerDistanceGeodeticPtMeridional_(n,s,t,e,i);const u=this.lowerDistanceGeodeticPtMeridional_(n,o,t,e,i);return a=Math.min(a,r),m=Math.min(m,u),Math.min(a,m)}minDistanceGeodesicPointBox_(t,e,i){return l(0),0}lowerDistanceGeodeticPtMeridional_(e,i,n,s,o){const a={stack:[],error:void 0,hasError:!1};try{const l=this.m_b*this.m_b/this.m_a,_=B.phiToPhig(this.m_e2,this.m_unitToRad*i),g=B.phiToPhig(this.m_e2,this.m_unitToRad*s),x=B.phiToPhig(this.m_e2,this.m_unitToRad*o),y=m(a,new u,!1);c.geodeticDistance(l,0,this.m_unitToRad*n,g,this.m_unitToRad*e,_,y,null,null,0);const P=m(a,new u,!1);c.geodeticDistance(l,0,this.m_unitToRad*n,x,this.m_unitToRad*e,_,P,null,null,0);const S=d(1,0,new t(this.m_unitToRad*e,_)),f=d(1,0,new t(this.m_unitToRad*n,g)),G=d(1,0,new t(this.m_unitToRad*n,x));let D=new p;D.setCrossProductVector(f,G);const v=f.dotProduct(G);if(D.length()<1.568e-10)return v>=0?Math.min(y.val,P.val):0;D=D.getUnitVector();let T=new p;if(T.setCrossProductVector(D,S),T.length()<1.568e-10){return Math.min(y.val,P.val)-1e-5*l}T=T.getUnitVector();let w=S.sub(D.mul(S.dotProduct(D)));{const t=new p;t.setCrossProductVector(f,w);const i=new p;i.setCrossProductVector(w,G);let n=D.dotProduct(t)>0&&D.dotProduct(i)>0;if(n||(w.negateThis(),t.setCrossProductVector(f,w),i.setCrossProductVector(w,G),n=D.dotProduct(t)>0&&D.dotProduct(i)>0),n){const t={stack:[],error:void 0,hasError:!1};try{w=w.getUnitVector();const i=N(1,0,w),n=m(t,new u,!1);c.geodeticDistance(l,0,this.m_unitToRad*e,_,i.x,i.y,n,null,null,0);const s=Math.min(y.val,P.val);return Math.min(s,n.val)}catch(r){t.error=r,t.hasError=!0}finally{h(t)}}}return Math.min(y.val,P.val)}catch(l){a.error=l,a.hasError=!0}finally{h(a)}}fixAngle(t){return l(0),0}moveCloser(t,e){return l(0),0}}function O(t){return t.xmin===t.xmax&&t.ymin===t.ymax}function U(t,e){return e.xmax<t.xmin||e.xmin>t.xmax||e.ymax<t.ymin||e.ymin>t.ymax}function L(t,e){let i,n=0;return i=t.xmin-e.xmax,i>n&&(n=i),i=e.xmin-t.xmax,i>n&&(n=i),n}function V(){return{outPoint:new t,index:-1,t:Number.NaN}}function z(t,e,i,n){t.outPoint.assign(e),t.index=i,t.t=n}function H(t,e,i,n,s,o){if(t.getGeometryType()===r.enumPolygon){for(;n.nextPath();)if(n.hasNextSegment()){const e=n.nextSegment();if(0!==A(t,e.getEndXY(),0))return z(s,e.getEndXY(),-1,Number.NaN),z(o,e.getEndXY(),-1,Number.NaN),!0}n.resetToFirstPath()}if(e.getGeometryType()===r.enumPolygon){for(;i.nextPath();)if(i.hasNextSegment()){const t=i.nextSegment();if(0!==A(e,t.getEndXY(),0))return z(s,t.getEndXY(),-1,Number.NaN),z(o,t.getEndXY(),-1,Number.NaN),!0}i.resetToFirstPath()}return!1}function j(t){const e=t.getPathCount(),i=new Array(t.getSegmentCount());let n=0;for(let s=0;s<e;++s){const e=n+t.getSegmentCountPath(s);for(let o=n,a=t.getPathStart(s);o<e;++o,++a)i[o]=a;n=e}return q(i),i}class J{}function Z(e){return{outPoint:void 0===e?new t:e.clone()}}function K(t,e){t.outPoint.assign(e.outPoint)}function Q(){return new n}class W{constructor(e,i,n,s,o=0,a=4){this.m_ptDistFrom=new t,this.m_segStartPt=new t,this.m_segEndPt=new t,this.m_geodeticLength=new u,this.m_az12=new u,this.m_minGeodeticDist=new u,this.m_segStartPt3d=new p,this.m_segEndPt3d=new p,this.m_sr=s,this.m_distCurveType=o,this.m_segCurveType=a,this.m_inputGCS=this.m_sr.getGCS(),this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_bIsPannablePcs=2===this.m_sr.getCoordinateSystemType()&&this.m_sr.isPannable();const r=F();this.m_inputGCS.querySpheroidData(r),this.m_a=r.majorSemiAxis,this.m_eSquared=r.e2,this.setPointDistFrom(e),this.setSegmentEndPoints(i,n)}setSegmentEndPoints(t,e){this.m_segStartPt.assign(t),this.m_segEndPt.assign(e),this.m_bIsPannablePcs||(this.m_segStartPt.mulThis(this.m_rpu),this.m_segEndPt.mulThis(this.m_rpu)),2===this.m_segCurveType&&(this.m_segStartPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segStartPt)),this.m_segEndPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segEndPt))),this.calculateAndUpdateSegmentLength()}setPointDistFrom(t){this.m_ptDistFrom.assign(t),this.m_ptDistFrom.scale(this.m_rpu)}setSegmentCurveType(t){this.m_segCurveType=t}setDistanceCurveType(t){this.m_distCurveType=t}makeFunctor(){return e=>{let i;switch(this.m_segCurveType){case 0:case 1:case 3:{const s={stack:[],error:void 0,hasError:!1};try{const n=m(s,new u,!1),o=m(s,new u,!1);c.geodeticCoordinate(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_geodeticLength.val*e,this.m_az12.val,n,o,this.m_segCurveType),i=new t(n.val,o.val);break}catch(n){s.error=n,s.hasError=!0}finally{h(s)}}case 2:{const t=p.lerp(this.m_segStartPt3d,this.m_segEndPt3d,e);i=N(this.m_a,this.m_eSquared,t);break}case 4:i=t.lerp(this.m_segStartPt,this.m_segEndPt,e),this.m_bIsPannablePcs&&(y(this.m_sr,0,[i],1),i.mulThis(this.m_rpu));break;default:M("Invalid curve type")}return c.geodeticDistance(this.m_a,this.m_eSquared,this.m_ptDistFrom.x,this.m_ptDistFrom.y,i.x,i.y,this.m_minGeodeticDist,null,null,this.m_distCurveType),this.m_minGeodeticDist.val}}calculateAndUpdateSegmentLength(){switch(this.m_segCurveType){case 0:case 2:case 1:case 3:c.geodeticDistance(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_segEndPt.x,this.m_segEndPt.y,this.m_geodeticLength,this.m_az12,null,this.m_segCurveType);break;case 4:this.m_geodeticLength.val=t.distance(this.m_segStartPt,this.m_segEndPt);break;default:M("Invalid curve type")}}[Symbol.dispose](){this.m_geodeticLength[Symbol.dispose](),this.m_az12[Symbol.dispose](),this.m_minGeodeticDist[Symbol.dispose]()}}function $(){return new J}class tt{constructor(t,e,i,o,a){this.m_boxGeomA=Q(),this.m_boxGeomB=Q(),this.m_envGeomA=new n,this.m_envGeomB=new n,this.m_transformPCS2GCS=null,this.m_segmentBoxesA=new Map,this.m_segmentBoxesB=new Map,this.m_boundaryPtsA=[],this.m_boundaryPtsB=[],this.m_scaleToRadians=new s,this.m_scaleToDegrees=new s,this.m_inputSR=t,this.m_distCurveType=e,this.m_progressTracker=i,this.m_maxDistance=o,this.m_maxDeviation=a,this.m_inputGCS=t.getGCS(),this.m_peGeogcs=this.m_inputGCS.getPECoordSys(),this.m_tolerance=0;const r=F();this.m_inputGCS.querySpheroidData(r),this.m_a=r.majorSemiAxis,this.m_eSquared=r.e2,this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_envHelper=new Y(this.m_a,this.m_eSquared,1),4===this.m_distCurveType&&(this.m_distCurveType=0),this.m_boxGeomA.setEmpty(),this.m_boxGeomB.setEmpty(),this.m_envGeomA.setEmpty(),this.m_envGeomB.setEmpty(),this.m_bIsPannablePcs=2===this.m_inputSR.getCoordinateSystemType()&&this.m_inputSR.isPannable()}calculate(t,e,i,n){const s=Z(),o=Z();if(t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.checkGeometriesIntersect(t,e,s,o))return i&&K(i,s),n&&K(n,o),0;const a=this.prepareGeometry(t);if(a.isEmpty())return Number.NaN;const r=this.prepareGeometry(e);if(r.isEmpty())return Number.NaN;this.m_tolerance=this.computeTolerance(a,r);const m=this._ExecuteBruteForce(a,r,s,o);return m>this.m_maxDistance?Number.NaN:(i&&(this.prepareOutput(s),K(i,s)),n&&(this.prepareOutput(o),K(n,o)),m)}createDistanceFunctor(t,e,i){const n=new W(t,e,i,this.m_inputSR,this.m_distCurveType);return this.m_bIsPannablePcs||1===this.m_inputSR.getCoordinateSystemType()||n.setSegmentCurveType(2),n}_NormalizeAndProject(t){if(this.m_inputSR.isPannable()&&(t=(new o).foldInto360Range(t,this.m_inputSR)),2===this.m_inputSR.getCoordinateSystemType()){const e=a(this.m_inputSR,this.m_inputGCS,null);t=(new o).execute(t,e,this.m_progressTracker)}return t}_ExecuteBruteForce(t,i,n,s){switch(t.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointGeometry(t,i,n,s);case r.enumMultiPoint:return this.calculateDistanceGeodeticMultipointGeometry(t,i,n,s);case r.enumPolyline:case r.enumPolygon:case r.enumEnvelope:return this.calculateDistanceGeodeticMultipathGeometry(t,i,n,s);default:e("")}}calculateDistanceGeodeticPointGeometry(t,i,n,s){switch(i.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointPoint(t,i,n,s);case r.enumMultiPoint:return this.calculateDistanceGeodeticPointMultipoint(t,i,n,s);case r.enumPolyline:case r.enumPolygon:return this.calculateDistanceGeodeticPointMultipath(t,i,n,s);default:e("")}}calculateDistanceGeodeticPointPoint(t,e,i,n){const s={stack:[],error:void 0,hasError:!1};try{const o=t.getXY();o.scale(this.m_rpu);const a=e.getXY();a.scale(this.m_rpu),i.outPoint.assign(o),n.outPoint.assign(a);const r=m(s,new u,!1);return c.geodeticDistance(this.m_a,this.m_eSquared,o.x,o.y,a.x,a.y,r,null,null,this.m_distCurveType),r.val}catch(o){s.error=o,s.hasError=!0}finally{h(s)}}calculateDistanceGeodeticPointMultipoint(t,e,i,n){return l(0),0}calculateDistanceGeodeticPointMultipath(e,i,n,s){const o={stack:[],error:void 0,hasError:!1};try{const a=new t,r=new t;a.assign(e.getXY()),r.assign(e.getXY()),n.outPoint.assign(r.mul(this.m_rpu)),this.m_bIsPannablePcs&&_(this.m_inputSR,[a],1,!1),this.computeEnvelopesAndBoxes(e,i);const u=this.estimateMinimumDistance(n,s);let c=u<this.m_maxDistance?u:this.m_maxDistance;const h=i.getImpl(),d=new t(0,0),p=new t(0,0),g=[1],x=this.canUseSpatialTree(e,i),y=$();x&&this.buildSpatialTree(y,i);const P=Q();P.setCoords({xmin:r.x,ymin:r.y,xmax:r.x,ymax:r.y});const S=m(o,this.createDistanceFunctor(r,d,p),!1),f=h.querySegmentIterator();f.stripAttributes();if(x)l(0);else for(;f.nextPath();)for(;f.hasNextSegment();){const t=f.nextSegment(),e=this.findOrComputeBoxSegment(f.getStartPointIndex(),t,this.m_segmentBoxesB);if(this.m_envHelper.minDistanceGeodesic(P,e)>c)continue;const i=this.calculateDistanceGeodeticPointSegment(a,r,t,g,S);if(i.second<c&&(this.updateOutputSegment(s,t,i.first),c=i.second,0===c))return 0}return c===this.m_maxDistance?Number.POSITIVE_INFINITY:c}catch(a){o.error=a,o.hasError=!0}finally{h(o)}}calculateDistanceGeodeticMultipointGeometry(t,i,n,s){switch(i.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointMultipoint(i,t,s,n);case r.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipoint(t,i,n,s);case r.enumPolyline:case r.enumPolygon:case r.enumEnvelope:return this.calculateDistanceGeodeticMultipointMultipath(t,i,n,s);default:e("")}}calculateDistanceGeodeticMultipointMultipoint(e,i,n,s){const o={stack:[],error:void 0,hasError:!1};try{const a=m(o,new u,!1);this.computeEnvelopesAndBoxes(e,i);const r=this.estimateMinimumDistance(n,s);let h=r<this.m_maxDistance?r:this.m_maxDistance;const l=new t,_=new t,g=e.getImpl(),x=i.getImpl(),y=Q(),P=g.getPointCount(),S=x.getPointCount();for(let t=0;t<P;++t){if(l.assign(g.getXY(t)),y.setCoords({xmin:l.x,ymin:l.y,xmax:l.x,ymax:l.y}),this.m_envHelper.minDistanceGeodesic(y,this.m_boxGeomB)>h)continue;l.scale(this.m_rpu);const e=d(this.m_a,this.m_eSquared,l);for(let t=0;t<S;++t){_.assign(x.getXY(t)),_.scale(this.m_rpu);const i=d(this.m_a,this.m_eSquared,_);if(!(p.distance(e,i)>=h)&&(c.geodeticDistance(this.m_a,this.m_eSquared,l.x,l.y,_.x,_.y,a,null,null,this.m_distCurveType),a.val<h&&(n.outPoint.assign(l),s.outPoint.assign(_),h=a.val,0===h)))return h}}return h===this.m_maxDistance?Number.POSITIVE_INFINITY:h}catch(a){o.error=a,o.hasError=!0}finally{h(o)}}calculateDistanceGeodeticMultipointMultipath(e,i,n,s){const o={stack:[],error:void 0,hasError:!1};try{const a=i.getImpl().querySegmentIterator();a.stripAttributes(),this.computeEnvelopesAndBoxes(e,i);const r=this.estimateMinimumDistance(n,s);let u=r<this.m_maxDistance?r:this.m_maxDistance;const c=new t,h=new t(0,0),d=new t(0,0),p=new t(0,0),g=[0],x=Q(),y=m(o,this.createDistanceFunctor(h,d,p),!1),P=$(),S=this.canUseSpatialTree(e,i);S&&this.buildSpatialTree(P,i);const f=e.getPointCount();for(let t=0;t<f;++t)if(c.assign(e.getXY(t)),h.assign(e.getXY(t)),this.m_bIsPannablePcs&&_(this.m_inputSR,[c],1,!1),x.setCoords({xmin:h.x,ymin:h.y,xmax:h.x,ymax:h.y}),!(this.m_envHelper.minDistanceGeodesic(x,this.m_boxGeomB)>u))if(y.setPointDistFrom(h),S)l(0);else{for(;a.nextPath();)for(;a.hasNextSegment();){const t=a.nextSegment();if(this.m_envHelper.minDistanceGeodesic(x,this.findOrComputeBoxSegment(a.getStartPointIndex(),t,this.m_segmentBoxesB))>u)continue;const e=this.calculateDistanceGeodeticPointSegment(c,h,t,g,y);if(e.second<u&&(n.outPoint.assign(h.mul(this.m_rpu)),this.updateOutputSegment(s,t,e.first),u=e.second,0===u))return 0}a.resetToFirstPath()}return u===this.m_maxDistance?Number.POSITIVE_INFINITY:u}catch(a){o.error=a,o.hasError=!0}finally{h(o)}}calculateDistanceGeodeticMultipathGeometry(t,i,n,s){switch(i.getGeometryType()){case r.enumPoint:return this.calculateDistanceGeodeticPointMultipath(i,t,s,n);case r.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipath(i,t,s,n);case r.enumPolyline:case r.enumPolygon:case r.enumEnvelope:return this.calculateDistanceGeodeticMultipathMultipath(t,i,n,s);default:e("")}}calculateDistanceGeodeticMultipathMultipath(t,e,i,n){const s=[t],o=[e],a=this.swapGeometries(s,o),r=s[0],m=o[0];this.computeEnvelopesAndBoxes(s[0],o[0]);const u=this.estimateMinimumDistance(i,n),c=this.calculateDistanceGeodeticMultipathMultipath_(r,m,i,n,u);return a&&(n.outPoint=g(i.outPoint,i.outPoint=n.outPoint)),c}calculateDistanceGeodeticMultipathMultipath_(e,i,n,s,o=Number.MAX_VALUE){const a={stack:[],error:void 0,hasError:!1};try{let r=o;const u=new t(0,0),c=new t,h=new t(0,0),_=new t,d=new t(0,0),p=new t,g=new t,S=new t,f=[new t],G=[0],D=[0],v=Q(),T=Q(),w=m(a,this.createDistanceFunctor(d,u,h),!1),b=$(),M=this.canUseSpatialTree(e,i);M&&this.buildSpatialTree(b,i);const E=i.querySegmentIterator();E.stripAttributes();const C=new x,R=j(e);for(let t=0;t<R.length;++t){const i=R[t];e.getSegmentBuffer(i,C,!0);const o=C.get();if(v.assign(this.findOrComputeBoxSegment(i,o,this.m_segmentBoxesA)),M)l(0);else{if(d.assign(o.getStartXY()),p.assign(o.getStartXY()),g.assign(o.getEndXY()),S.assign(o.getEndXY()),this.m_bIsPannablePcs&&(y(this.m_inputSR,0,[p],1),y(this.m_inputSR,0,[S],1)),this.m_envHelper.minDistanceGeodesic(v,this.m_boxGeomB)>r)continue;for(;E.nextPath();){for(;E.hasNextSegment();){const t=E.nextSegment();if(u.assign(t.getStartXY()),c.assign(t.getStartXY()),h.assign(t.getEndXY()),_.assign(t.getEndXY()),o.intersect(t,f,G,D,this.m_tolerance))return this.updateOutputSegment(n,o,G[0]),this.updateOutputSegment(s,t,D[0]),0;if(this.m_bIsPannablePcs&&(y(this.m_inputSR,0,[c],1),y(this.m_inputSR,0,[_],1)),T.assign(this.findOrComputeBoxPoint(E.getStartPointIndex(),c,_,this.m_segmentBoxesB)),this.m_envHelper.minDistanceGeodesic(v,T)>r)continue;w.setSegmentEndPoints(u,h),w.setPointDistFrom(p);let e=P(w.makeFunctor(),0,1,1e-10);if(e.second<r&&(n.outPoint.assign(p.mul(this.m_rpu)),this.updateOutputSegment(s,t,e.first),r=e.second,0===r))break;if(w.setPointDistFrom(S),e=P(w.makeFunctor(),0,1,1e-10),e.second<r&&(n.outPoint.assign(S.mul(this.m_rpu)),this.updateOutputSegment(s,t,e.first),r=e.second,0===r))break;if(w.setSegmentEndPoints(d,g),w.setPointDistFrom(c),e=P(w.makeFunctor(),0,1,1e-10),e.second<r&&(this.updateOutputSegment(n,o,e.first),s.outPoint.assign(c.mul(this.m_rpu)),r=e.second,0===r))break;if(w.setPointDistFrom(_),e=P(w.makeFunctor(),0,1,1e-10),e.second<r&&(this.updateOutputSegment(n,o,e.first),s.outPoint.assign(_.mul(this.m_rpu)),r=e.second,0===r))break}if(0===r)return 0}E.resetToFirstPath()}}return r===this.m_maxDistance?Number.POSITIVE_INFINITY:r}catch(r){a.error=r,a.hasError=!0}finally{h(a)}}calculateDistanceGeodeticPointSegment(t,e,i,n,s){const o=i.getStartXY(),a=i.getEndXY();return i.intersectPoint(t,n,this.m_tolerance)?S(n[0],0):(s.setPointDistFrom(e),s.setSegmentEndPoints(o,a),P(s.makeFunctor(),0,1,1e-10))}prepareGeometry(t){let e=t.clone();const i=t.getGeometryType();if(i===r.enumPoint||i===r.enumMultiPoint)return this._NormalizeAndProject(e);if(i===r.enumEnvelope&&(e=this.envelopeToPolygon(e)),this.m_inputSR.isPannable())return this.prepareGeometryPannable(e,4);if(2===this.m_inputSR.getCoordinateSystemType()){if(e=f(e,this.m_inputSR,0,null),e.isEmpty())return e;e=(new X).execute(e,this.m_inputSR,5e4,this.m_maxDeviation/2,0,null);const t=this.m_inputSR.getSRToGCSTransform();return(new o).execute(e,t,this.m_progressTracker)}const s=new n;e.queryLooseEnvelope(s);const a=this.m_inputSR.getPannableExtent();if(s.ymin<a.ymin||s.ymax>a.ymax){const t=new n(s.xmin-1,a.ymin,s.xmax+1,a.ymax);if(e=(new G).execute(e,t,this.m_inputSR,this.m_progressTracker),e.isEmpty())return e}return s.width()>2*a.width()?(e=D(e,-2*a.width(),2*a.width(),this.m_inputSR,!0,0,!0,this.m_progressTracker),e):e}prepareGeometryPannable(t,e){const i=new n;t.queryEnvelope(i);const s=this.m_inputSR.getPannableExtent();if(s.containsEnvelope(i))return t;const a=new v;s.queryIntervalX(a);const r=new v;return i.queryIntervalX(r),t=a.contains(r)?T(t,this.m_inputSR):(new o).foldInto360RangeGeodetic(t,this.m_inputSR,e)}prepareOutput(t){t.outPoint.scale(1/this.m_rpu),2===this.m_inputSR.getCoordinateSystemType()&&_(this.m_inputSR,[t.outPoint],1,!1)}updateOutputSegment(t,e,i){e.queryCoord2D(i,t.outPoint),this.m_bIsPannablePcs&&y(this.m_inputSR,0,[t.outPoint],1),t.outPoint.mulThis(this.m_rpu)}updateOutputPoint2D(t,e){l(0)}computeTolerance(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB);const i=new n(this.m_envGeomA);return i.mergeEnvelope2D(this.m_envGeomB),w(null,i)}envelopeToPolygon(t){const e=new b;return e.addEnvelope(t,!1),e}computeEnvelopesAndBoxes(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.m_boxGeomA=this.computeBoxGeometry(t,this.m_boundaryPtsA,this.m_segmentBoxesA),this.m_boxGeomB=this.computeBoxGeometry(e,this.m_boundaryPtsB,this.m_segmentBoxesB)}computeBoxGeometry(t,e,i){switch(t.getGeometryType()){case r.enumPoint:return this.computeBoxPoint(t,e);case r.enumMultiPoint:return this.computeBoxMultiPoint(t,e);case r.enumPolyline:case r.enumPolygon:return this.computeBoxMultiPath(t,e,i);default:M("Invalid geometry type")}}computeBoxPoint(t,e){const i=t.getXY();e.length=1,e[0]=i.mul(this.m_rpu);const n=Q();return n.setCoords({xmin:i.x,ymin:i.y,xmax:i.x,ymax:i.y}),n}computeBoxSegment(t){return l(0),{}}computeBoxMultiPoint(t,e){let i=!0;for(let s=0;s<t.getPointCount();++s){const n=t.getXY(s);if(i){e.length=4;for(let t=0;t<e.length;++t)e[t]=n.clone();i=!1}n.x<e[0].x&&(e[0]=n),n.y>e[1].y&&(e[1]=n),n.x>e[2].x&&(e[2]=n),n.y<e[3].y&&(e[3]=n)}for(let s=0;s<e.length;++s)e[s].mulThis(this.m_rpu);const n=Q();return t.queryEnvelope(n),n}computeBoxMultiPath(t,e,i){let n=!0;const s=Q();s.setEmpty();const o=t.querySegmentIterator();for(o.stripAttributes();o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),a=t.getStartXY(),r=t.getEndXY();if(this.m_bIsPannablePcs&&(y(this.m_inputSR,0,[a],1),y(this.m_inputSR,0,[r],1)),n){e.length=4;for(let t=0;t<e.length;++t)e[t]=a.clone();n=!1}a.x<e[0].x&&e[0].assign(a),a.y>e[1].y&&e[1].assign(a),a.x>e[2].x&&e[2].assign(a),a.y<e[3].y&&e[3].assign(a),r.x<e[0].x&&e[0].assign(r),r.y>e[1].y&&e[1].assign(r),r.x>e[2].x&&e[2].assign(r),r.y<e[3].y&&e[3].assign(r);const m=this.findOrComputeBoxPoint(o.getStartPointIndex(),a,r,i);s.mergeEnvelope2D(m)}for(let a=0;a<e.length;++a)e[a].mulThis(this.m_rpu);return s}findOrComputeBoxSegment(e,i,n){if(!n.has(e)){let s=Q();if(i.queryEnvelope(s),this.m_bIsPannablePcs){const e=t.construct(s.xmin,s.ymin),i=t.construct(s.xmax,s.ymax);y(this.m_inputSR,0,[e],1),y(this.m_inputSR,0,[i],1),s=this.m_envHelper.calculateBbox(e.x,e.y,i.x,i.y)}return n.set(e,s),s}return n.get(e)}findOrComputeBoxPoint(t,e,i,n){if(!n.has(t)){let s=Q();return s.setCoords({xmin:e.x,ymin:e.y,xmax:i.x,ymax:i.y}),this.m_bIsPannablePcs&&(s=this.m_envHelper.calculateBbox(s.xmin,s.ymin,s.xmax,s.ymax)),n.set(t,s),s}return n.get(t)}checkPointInPolygon(t,e){return l(0),!1}estimateMinimumDistance(t,e){const i={stack:[],error:void 0,hasError:!1};try{const n=t=>d(this.m_a,this.m_eSquared,t),s=this.m_boundaryPtsA.map(n),o=this.m_boundaryPtsB.map(n);let a=Number.MAX_VALUE,r=0,h=0;for(let t=0;t<s.length;++t)for(let e=0;e<o.length;++e){const i=p.distance(s[t],o[e]);i<a&&(a=i,r=t,h=e)}t.outPoint.assign(this.m_boundaryPtsA[r]),e.outPoint.assign(this.m_boundaryPtsB[h]);const l=m(i,new u,!1);return c.geodeticDistance(this.m_a,this.m_eSquared,this.m_boundaryPtsA[r].x,this.m_boundaryPtsA[r].y,this.m_boundaryPtsB[h].x,this.m_boundaryPtsB[h].y,l,null,null,this.m_distCurveType),l.val}catch(n){i.error=n,i.hasError=!0}finally{h(i)}}swapGeometries(t,e){return E(t[0])>E(e[0])&&(e[0]=g(t[0],t[0]=e[0]),this.m_envGeomB=g(this.m_envGeomA,this.m_envGeomA=this.m_envGeomB),!0)}canUseSpatialTree(t,e){return!1}checkGeometriesIntersect(t,e,i,n){let s=t.getGeometryType(),o=e.getGeometryType();if(this.m_envGeomA.isIntersecting(this.m_envGeomB)){if(s===r.enumPoint&&2===e.getDimension()){const s=[0],o=[t.getXY()];if(C(e,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}else if(o===r.enumPoint&&2===t.getDimension()){const s=[2],o=[e.getXY()];if(C(t,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}if(s===r.enumMultiPoint&&2===e.getDimension())return this.multipointIntersectsArea(t,e,i,n);if(o===r.enumMultiPoint&&2===t.getDimension())return this.multipointIntersectsArea(e,t,n,i);let a,m,u=t,c=e;if(s===r.enumEnvelope&&(a=this.envelopeToPolygon(t),u=a,s=r.enumPolygon),o===r.enumEnvelope&&(m=this.envelopeToPolygon(e),c=m,o=r.enumPolygon),R(s)&&R(o)){const t=u.querySegmentIterator(),e=c.querySegmentIterator(),s=V();if(H(u,c,t,e,s,V()))return i.outPoint.assign(s.outPoint),n.outPoint.assign(s.outPoint),!0}}return!1}multipointIntersectsArea(t,e,i,n){return l(0),!1}getNearestNeighbourVisitor(t,e,i,n,s,o,a){return l(0),{}}buildSpatialTree(t,e){l(0)}}class et{getOperatorType(){return 10316}supportsCurves(){return!0}accelerateGeometry(t,e,i){return!1}canAccelerateGeometry(t){return!1}execute(t,e,i,n,s){return this.executeEx(t,e,i,n,s,null,null,Number.NaN)}executeEx(t,n,s,o,a,r,m,u){if(s&&0!==s.getCoordinateSystemType()||e(""),i(t),i(n),t.isEmpty()||n.isEmpty())return Number.NaN;Number.isNaN(u)&&(u=Number.MAX_VALUE);const c=new tt(s,o,a,u,1),h=Z(),l=Z(),_=c.calculate(t,n,h,l);return r&&r.outPoint.assign(h.outPoint),m&&m.outPoint.assign(l.outPoint),_}}export{et as OperatorGeodeticDistance,Z as makeOutput};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
+ */
5
+ import{e,m as t,n,G as r,o as s,p as o,q as i,r as a,s as u}from"./Polyline.js";function c(e,t,n=-1,o=-1){if(e.isEmpty())return 3;const i=e.getGeometryType();if(a(i))return m(e,t,n,o);if(i===r.enumPolygon)return l();if(i===r.enumPolyline)return g();if(i===r.enumEnvelope){const n=new s;return e.queryEnvelope(n),n.contains(t)?n.containsExclusive(t)?1:2:0}return 3}function m(n,r,s,o){if(s>=0||o>=0)return t("");if(n.isDegenerate(0))return n.getStartXY().equals(r)?2:3;if(!n.isCurve()){const t=e.orientationRobust(r,n.getStartXY(),n.getEndXY());return t<0?1:t>0?0:2}const i=n.getClosestCoordinate(r,!1),a=n.getTangent(i),u=n.getCoord2D(i),c=e.orientationRobust(r,u,u.add(a));return c<0?1:c>0?0:2}function l(e,t,n,r){return u(0),3}function g(e,t,n,r){return u(0),3}const y=N(new e,-1,Number.NaN);function N(e,t,n){return{m_coordinate:e.clone(),m_vertexIndex:t,m_geometryIndex:0,m_distance:n,m_bRightSide:!1,isEmpty:d}}function d(){return Number.isNaN(this.m_distance)}class f{getOperatorType(){return 10500}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}getNearestCoordinate(e,s,o,i){if(s.isNAN()&&t("NAN xy coordinates are not allowed"),e.isEmpty())return y;switch(e.getGeometryType()){case r.enumPoint:return this.pointGetNearestVertex(e,s);case r.enumMultiPoint:return this.multiVertexGetNearestVertex(e,s);case r.enumPolyline:case r.enumPolygon:return this.multiPathGetNearestCoordinate(e,s,o,i);default:n("")}}getNearestVertex(e,s){if(s.isNAN()&&t("NAN xy coordinates are not allowed"),e.isEmpty())return y;switch(e.getGeometryType()){case r.enumPoint:return this.pointGetNearestVertex(e,s);case r.enumMultiPoint:case r.enumPolyline:case r.enumPolygon:return this.multiVertexGetNearestVertex(e,s);default:n("")}}getNearestVertices(e,s,o,i){if(0===i&&t(""),s.isNAN()&&t("NAN xy coordinates are not allowed"),e.isEmpty())return[];switch(e.getGeometryType()){case r.enumPoint:return this.pointGetNearestVertices(e,s,o,i);case r.enumMultiPoint:case r.enumPolyline:case r.enumPolygon:return this.multiVertexGetNearestVertices(e,s,o,i);default:n("")}}multiPathGetNearestCoordinate(n,a,u,m){if(n.getGeometryType()===r.enumPolygon&&u){const e=new s;n.queryEnvelope(e);const t=o(null,e,!1);let r;if(r=i(n,a,m?0:t),0!==r){const e=N(a,-1,0);return m&&(e.m_bRightSide=!0),e}}const l=n.querySegmentIterator(),g=new e;let y=-1,d=-1,f=Number.MAX_VALUE,p=0;for(;l.nextPath();)for(;l.hasNextSegment();){const t=l.nextSegment(),n=t.getClosestCoordinate(a,!1),r=t.getCoord2D(n),s=e.sqrDistance(r,a);s<f?(p=1,g.assign(r),y=l.getStartPointIndex(),d=l.getPathIndex(),f=s):s===f&&p++}-1===y&&t("");const x=N(g,y,Math.sqrt(f));if(m)if(n.getGeometryType()!==r.enumPolygon){let e=!1;if(p>1){const t=c(n,a,y,d);e=0!==t&&3!==t}else{l.resetToVertex(y,d);e=0!==c(l.nextSegment(),a)}x.m_bRightSide=e}else if(!u){0!==i(n,a,0)&&(x.m_bRightSide=!0)}return x}pointGetNearestVertex(t,n){const r=t.getXY();return N(r,0,e.distance(r,n))}multiVertexGetNearestVertex(t,n){const r=t.getAttributeStreamRef(0),s=t.getPointCount();let o=-1;const i=new e;let a=Number.MAX_VALUE;const u=new e;for(let c=0;c<s;c++){r.queryPoint2D(2*c,u);const t=e.sqrDistance(u,n);t<a&&(i.assign(u),o=c,a=t)}return N(i,o,Math.sqrt(a))}pointGetNearestVertices(t,n,r,s){const o=[];if(0!==s){const s=r*r,i=t.getXY(),a=e.sqrDistance(i,n);a<=s&&o.push(N(i,0,Math.sqrt(a)))}return o}multiVertexGetNearestVertices(t,n,r,s){const o=[];if(0!==s){const i=t.getAttributeStreamRef(0),a=t.getPointCount();o.length=s+1;const u=r*r;for(let t=0;t<a;t++){const r=i.read(2*t),s=i.read(2*t+1),a=n.x-r,c=n.y-s,m=a*a+c*c;m<=u&&o.push(N(e.construct(r,s),t,Math.sqrt(m)))}o.sort(((e,t)=>e.m_distance-t.m_distance))}return o.slice(0,s)}}export{f as O};