@arcgis/core 4.33.0-next.20250501 → 4.33.0-next.20250502
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{de16b771d2c8d816c738.js → 05c80002c37002ac99e8.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d40c4783f58af1ae0dc.js → 0e8181e7fc1386d08ffc.js} +1 -1
- package/assets/esri/core/workers/chunks/{96e5d192c8d23c1e324f.js → 13e68c43acc8916520db.js} +1 -1
- package/assets/esri/core/workers/chunks/{e6a5911ea21bef32834b.js → 1bc22af4cc4effcbcf2b.js} +1 -1
- package/assets/esri/core/workers/chunks/{9b2ab27159500315fbc1.js → 26850ec0917ee355ddb7.js} +1 -1
- package/assets/esri/core/workers/chunks/{1bd4fe77ba6fb25322e7.js → 29e2b105f55adafc3a6d.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d63dfa5a60c88e03b28.js → 2c77a543a174e5bc736a.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0ddf4f1c6a351b447c7.js → 30d7d2c7d6e9e5e2ecb9.js} +1 -1
- package/assets/esri/core/workers/chunks/{febae745a29a17ca130a.js → 4480e4b61affb3b2e9d6.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d4a271351fd288277d2.js → 49085a0b3a74e158f32f.js} +1 -1
- package/assets/esri/core/workers/chunks/{392e64a573f67817db02.js → 4cb199b547e5b97e65fb.js} +1 -1
- package/assets/esri/core/workers/chunks/4df36ee2406861c7afa8.js +1 -0
- package/assets/esri/core/workers/chunks/{ba917175ca2a6681501e.js → 563594357f3648652a5c.js} +1 -1
- package/assets/esri/core/workers/chunks/{abfc5f9ac16c3e885c5f.js → 56db71ea7eb8a5652d98.js} +1 -1
- package/assets/esri/core/workers/chunks/{e56647e61296643c5f84.js → 5719471414810b6a9aec.js} +1 -1
- package/assets/esri/core/workers/chunks/{235efd948ae470a6f238.js → 60b1365d25581ccf0485.js} +1 -1
- package/assets/esri/core/workers/chunks/{3795793643f4db64af0e.js → 63c25455b9cf1b3df76a.js} +1 -1
- package/assets/esri/core/workers/chunks/{909be86782af3deb448e.js → 654fe135d41af81daa13.js} +1 -1
- package/assets/esri/core/workers/chunks/{cd9343c78a7c3acdbbcd.js → 681b2662f6ce936afd7e.js} +1 -1
- package/assets/esri/core/workers/chunks/{65f2b22d8fc12e6d4a87.js → 7000d9158da929a16071.js} +1 -1
- package/assets/esri/core/workers/chunks/{7551011117c3d36ff3db.js → 743cdbff5c4616ddc2b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{968956284f44187f0622.js → 8540fb31bd0b29ff1906.js} +1 -1
- package/assets/esri/core/workers/chunks/8c5cea49e48f8858f115.js +1 -0
- package/assets/esri/core/workers/chunks/{237a965bd41ba8903e03.js → 921c040d0497031fd8ff.js} +1 -1
- package/assets/esri/core/workers/chunks/{96d2a0777f5c418055fb.js → 92b48e3365d1cc933113.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d485c07848164099859.js → 95a4da3150ad8e8e36d8.js} +1 -1
- package/assets/esri/core/workers/chunks/{46fb6ba8900286d18b6f.js → 9d564f79b82d427fc1da.js} +1 -1
- package/assets/esri/core/workers/chunks/{00612d6e05b1c8647668.js → 9fff43ffcd5602ccc50f.js} +1 -1
- package/assets/esri/core/workers/chunks/{1cc5c566e68f2255d035.js → a6ca68ef6311ffc365b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{5a51c75a2932d9da001a.js → a8d043b73e087bee7c40.js} +1 -1
- package/assets/esri/core/workers/chunks/{ebfa4a0334401f5e004a.js → c12765e0c8b44e349c2a.js} +1 -1
- package/assets/esri/core/workers/chunks/{afddb94ff4e1a70022c7.js → c3b2b05996e2008adbe3.js} +1 -1
- package/assets/esri/core/workers/chunks/{4fb4884d2de42792abe3.js → d1a9e8db5ba403abe721.js} +1 -1
- package/assets/esri/core/workers/chunks/d35cd309ba7bb8968a22.js +1 -0
- package/assets/esri/core/workers/chunks/{6e6422eda398774acbc7.js → d60da671aba70485050e.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a8df1225abd54ff68ed.js → db298b292a4e43cba72d.js} +1 -1
- package/assets/esri/core/workers/chunks/{2bda2cfc6e81818d7d33.js → dcaeb57c69d432118604.js} +1 -1
- package/assets/esri/core/workers/chunks/{fb455fd89b74b70a6a2b.js → e613df03ceb39e29befa.js} +1 -1
- package/assets/esri/core/workers/chunks/{05d7d8ff3e4cbad32580.js → e8dcaa7837b6fe7bff20.js} +1 -1
- package/assets/esri/core/workers/chunks/ec1a4b82cbc44ba45f83.js +1 -0
- package/assets/esri/core/workers/chunks/ec778cc7a55068f51937.js +1 -0
- package/assets/esri/core/workers/chunks/{51339193abddfe37745d.js → f2b63597ae956db74eb3.js} +1 -1
- package/chunks/Bufferer-CicaNej1.js +1 -1
- package/chunks/Distance2DCalculator-C1KHhZwD.js +1 -1
- package/chunks/Envelope.js +1 -1
- package/chunks/Envelope2D.js +1 -1
- package/chunks/GeodeticDistanceCalculator-CcF1gMZX.js +1 -1
- package/chunks/Geometry.js +1 -1
- package/chunks/GeometryCleaner-BEJM7I4l.js +1 -1
- package/chunks/OperatorClip.js +1 -1
- package/chunks/OperatorCrosses.js +1 -1
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorGeneralize.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticDistance.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorIntersects.js +1 -1
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorOverlaps.js +1 -1
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/OperatorSimplifyOGC.js +1 -1
- package/chunks/OperatorTouches.js +1 -1
- package/chunks/OperatorWithin.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/ProjectionTransformation.js +1 -1
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
- package/chunks/Transformation2D.js +1 -1
- package/chunks/containsOperator.js +1 -1
- package/chunks/disjointOperator.js +1 -1
- package/chunks/equalsOperator.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorDifference.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorLocateBetween.js +1 -1
- package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
- package/geometry/operators/gx/operatorSimplify.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/gx/operatorUnion.js +1 -1
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/json/containsOperator.js +1 -1
- package/geometry/operators/json/disjointOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/support/apiConverter.js +1 -1
- package/geometry/operators/support/initNoPeFactory.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/interfaces.d.ts +31 -0
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
- package/widgets/Directions/css.js +5 -0
- package/widgets/Directions.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/assets/esri/core/workers/chunks/11b55e7e76e50fe11bbe.js +0 -1
- package/assets/esri/core/workers/chunks/7bfa18dd8771d4932533.js +0 -1
- package/assets/esri/core/workers/chunks/84d7ed2cf5fe23a0888f.js +0 -1
- package/assets/esri/core/workers/chunks/86931186095c23e47c0c.js +0 -1
- package/assets/esri/core/workers/chunks/a79511b926a2830bb160.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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{b as t,c as e}from"./tslib.es6.js";import{t as i,G as s,g as n,c as o,v as a,h as m}from"./Geometry.js";import{S as r,a as u}from"./QuadraticBezier.js";import{y as c,v as h,G as l,H as _,S as p,U as d,V as g,W as x,X as y,Y as P,z as S,Z as f,w as D,_ as G,I as v}from"./ProjectionTransformation.js";import{h as T,c as b}from"./Envelope.js";import{Envelope2D as w}from"./Envelope2D.js";import{P as M,b as E,n as R,E as C,o as I}from"./Point2D.js";import{T as B}from"./Transformation2D.js";import{s as A,w as q,m as N}from"./Distance2DCalculator-C1KHhZwD.js";import{O as F}from"./OperatorShapePreservingDensify.js";import{O as Y}from"./OperatorClip.js";function X(){return new w}class k{[Symbol.dispose](){this.m_peR1.destroy(),this.m_peR2.destroy(),this.m_peR3.destroy(),this.m_peR1=null,this.m_peR2=null,this.m_peR3=null}constructor(t,e,i){this.m_peR1=new l,this.m_peR2=new l,this.m_peR3=new l,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,s){const n=this.m_peR1,o=this.m_peR2,a=this.m_peR3;_.geodeticDistance(this.m_a,this.m_e2,t*this.m_unitToRad,e*this.m_unitToRad,i*this.m_unitToRad,s*this.m_unitToRad,a,n,o,0);const m=Math.cos(n.val),r=Math.cos(o.val+3.141592653589793),u=e*this.m_unitToRad,c=D.phiToEta(this.m_e2,u),h=Math.sin(n.val)*Math.cos(c);let l=e;if(m*r<0){const t=m<0?-1:1,e=Math.acos(Math.abs(h))*t;l=D.etaToPhi(this.m_e2,e)/this.m_unitToRad}let p=I((i-t)*this.m_unitToRad,2*Math.PI);Math.abs(p)>Math.PI&&(p=p>0?p-2*Math.PI:p+2*Math.PI),p/=this.m_unitToRad,i=t+p;const d=X();return d.xmin=Math.min(t,i),d.xmax=Math.max(t,i),d.ymin=Math.min(e,s),d.ymin=Math.min(d.ymin,l),d.ymax=Math.max(e,s),d.ymax=Math.max(d.ymax,l),d}minDistanceGeodesic(t,e){const i=O(t),s=O(e);if(i&&s)return this.lowerDistanceGeodetic_(t.xmin,t.ymin,e.xmin,e.ymin);const n=this.normalizeGeodesic_(e,t);return U(t,n)?t.ymin>=n.ymax?this.minDistanceGeodesicUpDown_(t,n):n.ymin>=t.ymax?this.minDistanceGeodesicUpDown_(n,t):t.xmin>n.xmax?this.minDistanceGeodesicLeftRight_(n,t):this.minDistanceGeodesicLeftRight_(t,n):0}normalizeGeodesic_(t,e){const i=t.clone(),s=t.clone();let n=V(i,e);if(0===n)return i;for(;s.xmax>e.xmin;){s.xmin-=this.m_u360,s.xmax-=this.m_u360;const t=V(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}for(s.assign(t);s.xmin<e.xmax;){s.xmin+=this.m_u360,s.xmax+=this.m_u360;const t=V(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}return i}lowerDistanceGeodetic_(t,e,i,s){const n=this.m_peR1;{const o=this.m_b*this.m_b/this.m_a,a=D.phiToPhig(this.m_e2,this.m_unitToRad*e),m=D.phiToPhig(this.m_e2,this.m_unitToRad*s);_.geodeticDistance(o,0,this.m_unitToRad*t,a,this.m_unitToRad*i,m,n,null,null,0)}return n.val}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 s=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);return Math.min(i,s)}{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 s=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);return Math.min(i,s)}}minDistanceGeodesicLeftRight_(t,e){let i=Math.abs(t.xmax-e.xmin);for(;i>this.m_u180;)i-=this.m_u360;let s=Math.abs(t.xmin-e.xmax);for(;s>this.m_u180;)s-=this.m_u360;return Math.abs(i)<=Math.abs(s)?this.minDistanceGeodesicLeftRightNormalized_(t,e):this.minDistanceGeodesicLeftRightNormalized_(e,t)}minDistanceGeodesicLeftRightNormalized_(t,e){let i,s;return i=this.lowerDistanceGeodetic_(t.xmax,t.ymin,e.xmin,e.ymin),t.ymin>=e.ymin&&t.ymin<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymin,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymin>=t.ymin&&e.ymin<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymin,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),s=this.lowerDistanceGeodetic_(t.xmax,t.ymax,e.xmin,e.ymax),i=Math.min(i,s),t.ymax>=e.ymin&&t.ymax<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymax,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymax>=t.ymin&&e.ymax<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymax,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),i}lowerDistanceGeodeticSegMeridional_(t,e,i,s,n,o){let a=this.lowerDistanceGeodeticPtMeridional_(t,e,s,n,o);const m=this.lowerDistanceGeodeticPtMeridional_(t,i,s,n,o);let r=this.lowerDistanceGeodeticPtMeridional_(s,n,t,e,i);const u=this.lowerDistanceGeodeticPtMeridional_(s,o,t,e,i);return a=Math.min(a,m),r=Math.min(r,u),Math.min(a,r)}lowerDistanceGeodeticPtMeridional_(t,e,i,s,n){const o=this.m_b*this.m_b/this.m_a,a=D.phiToPhig(this.m_e2,this.m_unitToRad*e),m=D.phiToPhig(this.m_e2,this.m_unitToRad*s),r=D.phiToPhig(this.m_e2,this.m_unitToRad*n),u=this.m_peR1,c=this.m_peR2;_.geodeticDistance(o,0,this.m_unitToRad*i,m,this.m_unitToRad*t,a,u,null,null,0),_.geodeticDistance(o,0,this.m_unitToRad*i,r,this.m_unitToRad*t,a,c,null,null,0);const h=p(1,0,new M(this.m_unitToRad*t,a)),l=p(1,0,new M(this.m_unitToRad*i,m)),d=p(1,0,new M(this.m_unitToRad*i,r));let g=new T;g.setCrossProductVector(l,d);const x=l.dotProduct(d);if(g.length()<1.568e-10)return x>=0?Math.min(u.val,c.val):0;g=g.getUnitVector();let y=new T;if(y.setCrossProductVector(g,h),y.length()<1.568e-10){return Math.min(u.val,c.val)-1e-5*o}y=y.getUnitVector();let P=h.sub(g.mul(h.dotProduct(g)));{const e=new T;e.setCrossProductVector(l,P);const i=new T;i.setCrossProductVector(P,d);let s=g.dotProduct(e)>0&&g.dotProduct(i)>0;if(s||(P.negateThis(),e.setCrossProductVector(l,P),i.setCrossProductVector(P,d),s=g.dotProduct(e)>0&&g.dotProduct(i)>0),s){P=P.getUnitVector();const e=G(1,0,P),i=this.m_peR3;_.geodeticDistance(o,0,this.m_unitToRad*t,a,e.x,e.y,i,null,null,0);const s=Math.min(u.val,c.val);return Math.min(s,i.val)}}return Math.min(u.val,c.val)}}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 V(t,e){let i,s=0;return i=t.xmin-e.xmax,i>s&&(s=i),i=e.xmin-t.xmax,i>s&&(s=i),s}class j{}function L(t){return{outPoint:void 0===t?new M:t.clone()}}function z(t,e){t.outPoint.assign(e.outPoint)}function H(){return new w}class Z{constructor(t,e,i,s,n=0,o=4){this.m_ptDistFrom=new M,this.m_segStartPt=new M,this.m_segEndPt=new M,this.m_geodeticLength=new l,this.m_az12=new l,this.m_minGeodeticDist=new l,this.m_segStartPt3d=new T,this.m_segEndPt3d=new T,this.m_sr=s,this.m_distCurveType=n,this.m_segCurveType=o,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 a=v();this.m_inputGCS.querySpheroidData(a),this.m_a=a.majorSemiAxis,this.m_eSquared=a.e2,this.setPointDistFrom(t),this.setSegmentEndPoints(e,i)}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(p(this.m_a,this.m_eSquared,this.m_segStartPt)),this.m_segEndPt3d.assign(p(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 i=>{let s;switch(this.m_segCurveType){case 0:case 1:case 3:{const o={stack:[],error:void 0,hasError:!1};try{const e=t(o,new l,!1),n=t(o,new l,!1);_.geodeticCoordinate(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_geodeticLength.val*i,this.m_az12.val,e,n,this.m_segCurveType),s=new M(e.val,n.val);break}catch(n){o.error=n,o.hasError=!0}finally{e(o)}}case 2:{const t=T.lerp(this.m_segStartPt3d,this.m_segEndPt3d,i);s=G(this.m_a,this.m_eSquared,t);break}case 4:s=M.lerp(this.m_segStartPt,this.m_segEndPt,i),this.m_bIsPannablePcs&&(g(this.m_sr,0,[s],1),s.mulThis(this.m_rpu));break;default:o("Invalid curve type")}return _.geodeticDistance(this.m_a,this.m_eSquared,this.m_ptDistFrom.x,this.m_ptDistFrom.y,s.x,s.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:_.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=M.distance(this.m_segStartPt,this.m_segEndPt);break;default:o("Invalid curve type")}}[Symbol.dispose](){this.m_geodeticLength[Symbol.dispose](),this.m_az12[Symbol.dispose](),this.m_minGeodeticDist[Symbol.dispose]()}}function K(){return new j}class Q{[Symbol.dispose](){this.m_envHelper[Symbol.dispose]()}constructor(t,e,i,s,n){this.m_boxGeomA=H(),this.m_boxGeomB=H(),this.m_envGeomA=new w,this.m_envGeomB=new w,this.m_progressCounter=0,this.m_transformPCS2GCS=null,this.m_segmentBoxesA=new Map,this.m_segmentBoxesB=new Map,this.m_boundaryPtsA=[],this.m_boundaryPtsB=[],this.m_scaleToRadians=new B,this.m_scaleToDegrees=new B,this.m_inputSR=t,this.m_distCurveType=e,this.m_progressTracker=i,this.m_maxDistance=s,this.m_maxDeviation=n,this.m_inputGCS=t.getGCS(),this.m_peGeogcs=this.m_inputGCS.getPECoordSys(),this.m_tolerance=0;const o=v();this.m_inputGCS.querySpheroidData(o),this.m_a=o.majorSemiAxis,this.m_eSquared=o.e2,this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_envHelper=new k(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()}progress(t=!1){}calculate(t,e,i,s){const n=L(),o=L();if(t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.checkGeometriesIntersect(t,e,n,o))return i&&z(i,n),s&&z(s,o),0;const a=this.prepareGeometry(t);if(a.isEmpty())return Number.NaN;const m=this.prepareGeometry(e);if(m.isEmpty())return Number.NaN;this.m_tolerance=this.computeTolerance(a,m);const r=this._ExecuteBruteForce(a,m,n,o);return r>=this.m_maxDistance?Number.NaN:(i&&(this.prepareOutput(n),z(i,n)),s&&(this.prepareOutput(o),z(s,o)),r)}createDistanceFunctor(t,e,i){const s=new Z(t,e,i,this.m_inputSR,this.m_distCurveType);return this.m_bIsPannablePcs||1===this.m_inputSR.getCoordinateSystemType()||s.setSegmentCurveType(2),s}_NormalizeAndProject(t){if(this.m_inputSR.isPannable()&&(t=(new c).foldInto360Range(t,this.m_inputSR)),2===this.m_inputSR.getCoordinateSystemType()){const e=h(this.m_inputSR,this.m_inputGCS,null);t=(new c).execute(t,e,this.m_progressTracker)}return t}_ExecuteBruteForce(t,e,n,o){switch(t.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointGeometry(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointGeometry(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathGeometry(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointPoint(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticPointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:return this.calculateDistanceGeodeticPointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointPoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=i.getXY();e.scale(this.m_rpu);const m=s.getXY();m.scale(this.m_rpu),n.outPoint.assign(e),o.outPoint.assign(m);const r=t(a,new l,!1);return _.geodeticDistance(this.m_a,this.m_eSquared,e.x,e.y,m.x,m.y,r,null,null,this.m_distCurveType),r.val}catch(m){a.error=m,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticPointMultipoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{this.computeEnvelopesAndBoxes(i,s);const e=this.estimateMinimumDistance(n,o);let m=e<this.m_maxDistance?e:this.m_maxDistance;const r=i.getXY();r.scale(this.m_rpu),n.outPoint.assign(r);const u=p(this.m_a,this.m_eSquared,r),c=new M,h=s.getImpl(),d=t(a,new l,!1),g=h.getPointCount();for(let t=0;t<g;++t){h.queryXY(t,c),c.scale(this.m_rpu);const e=p(this.m_a,this.m_eSquared,c);if(!(T.distance(u,e)>m)&&(!(this.m_envHelper.minDistanceGeodesic(this.m_boxGeomA,this.m_boxGeomB)>m)&&(_.geodeticDistance(this.m_a,this.m_eSquared,r.x,r.y,c.x,c.y,d,null,null,this.m_distCurveType),d.val<m&&(m=d.val,o.outPoint=c,0===m))))return m}return m===this.m_maxDistance?Number.POSITIVE_INFINITY:m}catch(m){a.error=m,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticPointMultipath(i,s,o,a){const m={stack:[],error:void 0,hasError:!1};try{const e=new M,r=new M;e.assign(i.getXY()),r.assign(i.getXY()),o.outPoint.assign(r.mul(this.m_rpu)),this.m_bIsPannablePcs&&d(this.m_inputSR,[e],1,!1),this.computeEnvelopesAndBoxes(i,s);const u=this.estimateMinimumDistance(o,a);let c=u<this.m_maxDistance?u:this.m_maxDistance;const h=s.getImpl(),l=new M(0,0),_=new M(0,0),p=[1],g=this.canUseSpatialTree(i,s),x=K();g&&this.buildSpatialTree(x,s);const y=H();y.setCoords({xmin:r.x,ymin:r.y,xmax:r.x,ymax:r.y});const P=t(m,this.createDistanceFunctor(r,l,_),!1),S=h.querySegmentIterator();if(S.stripAttributes(),g)n(0);else for(;S.nextPath();)for(;S.hasNextSegment();){const t=S.nextSegment(),i=this.findOrComputeBoxSegment(S.getStartPointIndex(),t,this.m_segmentBoxesB);if(this.m_envHelper.minDistanceGeodesic(y,i)>c)continue;const s=this.calculateDistanceGeodeticPointSegment(e,r,t,p,P);if(s.second<c&&(this.updateOutputSegment(a,t,s.first),c=s.second,0===c))return 0}return c===this.m_maxDistance?Number.POSITIVE_INFINITY:c}catch(r){m.error=r,m.hasError=!0}finally{e(m)}}calculateDistanceGeodeticMultipointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipoint(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipointMultipoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new l,!1);this.computeEnvelopesAndBoxes(i,s);const m=this.estimateMinimumDistance(n,o);let r=m<this.m_maxDistance?m:this.m_maxDistance;const u=new M,c=new M,h=i.getImpl(),d=s.getImpl(),g=H(),x=h.getPointCount(),y=d.getPointCount();for(let t=0;t<x;++t){if(u.assign(h.getXY(t)),g.setCoords({xmin:u.x,ymin:u.y,xmax:u.x,ymax:u.y}),this.m_envHelper.minDistanceGeodesic(g,this.m_boxGeomB)>r)continue;u.scale(this.m_rpu);const i=p(this.m_a,this.m_eSquared,u);for(let t=0;t<y;++t){c.assign(d.getXY(t)),c.scale(this.m_rpu);const s=p(this.m_a,this.m_eSquared,c);if(!(T.distance(i,s)>=r)&&(_.geodeticDistance(this.m_a,this.m_eSquared,u.x,u.y,c.x,c.y,e,null,null,this.m_distCurveType),e.val<r&&(n.outPoint.assign(u),o.outPoint.assign(c),r=e.val,0===r)))return r}}return r===this.m_maxDistance?Number.POSITIVE_INFINITY:r}catch(m){a.error=m,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticMultipointMultipath(i,s,o,a){const m={stack:[],error:void 0,hasError:!1};try{const e=s.getImpl().querySegmentIterator();e.stripAttributes(),this.computeEnvelopesAndBoxes(i,s);const r=this.estimateMinimumDistance(o,a);let u=r<this.m_maxDistance?r:this.m_maxDistance;const c=new M,h=new M(0,0),l=new M(0,0),_=new M(0,0),p=[0],g=H(),x=t(m,this.createDistanceFunctor(h,l,_),!1),y=K(),P=this.canUseSpatialTree(i,s);P&&this.buildSpatialTree(y,s);const S=i.getPointCount();for(let t=0;t<S;++t)if(c.assign(i.getXY(t)),h.assign(i.getXY(t)),this.m_bIsPannablePcs&&d(this.m_inputSR,[c],1,!1),g.setCoords({xmin:h.x,ymin:h.y,xmax:h.x,ymax:h.y}),!(this.m_envHelper.minDistanceGeodesic(g,this.m_boxGeomB)>u))if(x.setPointDistFrom(h),P)n(0);else{for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(this.m_envHelper.minDistanceGeodesic(g,this.findOrComputeBoxSegment(e.getStartPointIndex(),t,this.m_segmentBoxesB))>u)continue;const i=this.calculateDistanceGeodeticPointSegment(c,h,t,p,x);if(i.second<u&&(o.outPoint.assign(h.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),u=i.second,0===u))return 0}e.resetToFirstPath()}return u===this.m_maxDistance?Number.POSITIVE_INFINITY:u}catch(r){m.error=r,m.hasError=!0}finally{e(m)}}calculateDistanceGeodeticMultipathGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipath(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipath(e,t,o,n);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipathMultipath(t,e,i,s){const n=[t],o=[e],a=this.swapGeometries(n,o),m=n[0],r=o[0];this.computeEnvelopesAndBoxes(n[0],o[0]);const u=this.estimateMinimumDistance(i,s),c=this.calculateDistanceGeodeticMultipathMultipath_(m,r,i,s,u);return a&&(s.outPoint=E(i.outPoint,i.outPoint=s.outPoint)),c}calculateDistanceGeodeticMultipathMultipath_(i,s,o,a,m=Number.MAX_VALUE){const u={stack:[],error:void 0,hasError:!1};try{let e=m;const c=new M(0,0),h=new M,l=new M(0,0),_=new M,p=new M(0,0),d=new M,y=new M,P=new M,S=[new M],f=[0],D=[0],G=H(),v=H(),T=t(u,this.createDistanceFunctor(p,c,l),!1),b=K(),w=this.canUseSpatialTree(i,s);w&&this.buildSpatialTree(b,s);const E=s.querySegmentIterator();E.stripAttributes();const R=new r,C=A(i);for(let t=0;t<C.length;++t){const s=C[t];i.getSegmentBuffer(s,R,!0);const m=R.get();if(G.assign(this.findOrComputeBoxSegment(s,m,this.m_segmentBoxesA)),w)n(0);else{if(p.assign(m.getStartXY()),d.assign(m.getStartXY()),y.assign(m.getEndXY()),P.assign(m.getEndXY()),this.m_bIsPannablePcs&&(g(this.m_inputSR,0,[d],1),g(this.m_inputSR,0,[P],1)),this.m_envHelper.minDistanceGeodesic(G,this.m_boxGeomB)>e)continue;for(;E.nextPath();){for(;E.hasNextSegment();){const t=E.nextSegment();if(c.assign(t.getStartXY()),h.assign(t.getStartXY()),l.assign(t.getEndXY()),_.assign(t.getEndXY()),m.intersect(t,S,f,D,this.m_tolerance))return this.updateOutputSegment(o,m,f[0]),this.updateOutputSegment(a,t,D[0]),0;if(this.m_bIsPannablePcs&&(g(this.m_inputSR,0,[h],1),g(this.m_inputSR,0,[_],1)),v.assign(this.findOrComputeBoxPoint(E.getStartPointIndex(),h,_,this.m_segmentBoxesB)),this.m_envHelper.minDistanceGeodesic(G,v)>e)continue;T.setSegmentEndPoints(c,l),T.setPointDistFrom(d);let i=x(T.makeFunctor(),0,1,1e-10);if(i.second<e&&(o.outPoint.assign(d.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setPointDistFrom(P),i=x(T.makeFunctor(),0,1,1e-10),i.second<e&&(o.outPoint.assign(P.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setSegmentEndPoints(p,y),T.setPointDistFrom(h),i=x(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,m,i.first),a.outPoint.assign(h.mul(this.m_rpu)),e=i.second,0===e))break;if(T.setPointDistFrom(_),i=x(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,m,i.first),a.outPoint.assign(_.mul(this.m_rpu)),e=i.second,0===e))break}if(0===e)return 0}E.resetToFirstPath()}}return e===this.m_maxDistance?Number.POSITIVE_INFINITY:e}catch(c){u.error=c,u.hasError=!0}finally{e(u)}}calculateDistanceGeodeticPointSegment(t,e,i,s,n){const o=i.getStartXY(),a=i.getEndXY();return i.intersectPoint(t,s,this.m_tolerance)?R(s[0],0):(n.setPointDistFrom(e),n.setSegmentEndPoints(o,a),x(n.makeFunctor(),0,1,1e-10))}prepareGeometry(t){let e=t.clone();const i=t.getGeometryType();if(i===s.enumPoint||i===s.enumMultiPoint)return this._NormalizeAndProject(e);if(i===s.enumEnvelope&&(e=this.envelopeToPolygon(e)),this.m_inputSR.isPannable())return this.prepareGeometryPannable(e,4);if(2===this.m_inputSR.getCoordinateSystemType()){if(e=y(e,this.m_inputSR,0,null),e.isEmpty())return e;e=(new F).execute(e,this.m_inputSR,5e4,this.m_maxDeviation/2,0,null);const t=this.m_inputSR.getSRToGCSTransform();return(new c).execute(e,t,this.m_progressTracker)}const n=new w;e.queryLooseEnvelope(n);const o=this.m_inputSR.getPannableExtent();if(n.ymin<o.ymin||n.ymax>o.ymax){const t=new w(n.xmin-1,o.ymin,n.xmax+1,o.ymax);if(e=(new Y).execute(e,t,this.m_inputSR,this.m_progressTracker),e.isEmpty())return e}return n.width()>2*o.width()?(e=P(e,-2*o.width(),2*o.width(),this.m_inputSR,!0,0,!0,this.m_progressTracker),e):e}prepareGeometryPannable(t,e){const i=new w;t.queryEnvelope(i);const s=this.m_inputSR.getPannableExtent();if(s.containsEnvelope(i))return t;const n=new C;s.queryIntervalX(n);const o=new C;return i.queryIntervalX(o),t=n.contains(o)?S(t,this.m_inputSR):(new c).foldInto360RangeGeodetic(t,this.m_inputSR,e)}prepareOutput(t){t.outPoint.scale(1/this.m_rpu),2===this.m_inputSR.getCoordinateSystemType()&&d(this.m_inputSR,[t.outPoint],1,!1)}updateOutputSegment(t,e,i){e.queryCoord2D(i,t.outPoint),this.m_bIsPannablePcs&&g(this.m_inputSR,0,[t.outPoint],1),t.outPoint.mulThis(this.m_rpu)}computeTolerance(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB);const i=new w(this.m_envGeomA);return i.mergeEnvelope2D(this.m_envGeomB),b(null,i)}envelopeToPolygon(t){const e=new u;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 s.enumPoint:return this.computeBoxPoint(t,e);case s.enumMultiPoint:return this.computeBoxMultiPoint(t,e);case s.enumPolyline:case s.enumPolygon:return this.computeBoxMultiPath(t,e,i);default:o("Invalid geometry type")}}computeBoxPoint(t,e){const i=t.getXY();e.length=0,e.push(i.mul(this.m_rpu));const s=H();return s.setCoords({xmin:i.x,ymin:i.y,xmax:i.x,ymax:i.y}),s}computeBoxMultiPoint(t,e){let i=!0;for(let n=0;n<t.getPointCount();++n){const s=t.getXY(n);if(i){e.length=0;for(let t=0;t<4;++t)e.push(s.clone());i=!1}s.x<e[0].x&&e[0].assign(s),s.y>e[1].y&&e[1].assign(s),s.x>e[2].x&&e[2].assign(s),s.y<e[3].y&&e[3].assign(s)}for(let n=0;n<e.length;++n)e[n].mulThis(this.m_rpu);const s=H();return t.queryEnvelope(s),s}computeBoxMultiPath(t,e,i){let s=!0;const n=H();n.setEmpty();const o=t.querySegmentIterator();for(o.stripAttributes();o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),a=t.getStartXY(),m=t.getEndXY();if(this.m_bIsPannablePcs&&(g(this.m_inputSR,0,[a],1),g(this.m_inputSR,0,[m],1)),s){for(let t=0;t<4;++t)e.push(a.clone());s=!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),m.x<e[0].x&&e[0].assign(m),m.y>e[1].y&&e[1].assign(m),m.x>e[2].x&&e[2].assign(m),m.y<e[3].y&&e[3].assign(m);const r=this.findOrComputeBoxPoint(o.getStartPointIndex(),a,m,i);n.mergeEnvelope2D(r)}for(let a=0;a<e.length;++a)e[a].mulThis(this.m_rpu);return n}findOrComputeBoxSegment(t,e,i){if(!i.has(t)){let s=H();if(e.queryEnvelope(s),this.m_bIsPannablePcs){const t=M.construct(s.xmin,s.ymin),e=M.construct(s.xmax,s.ymax);g(this.m_inputSR,0,[t],1),g(this.m_inputSR,0,[e],1),s=this.m_envHelper.calculateBbox(t.x,t.y,e.x,e.y)}return i.set(t,s),s}return i.get(t)}findOrComputeBoxPoint(t,e,i,s){if(!s.has(t)){let n=H();return n.setCoords({xmin:e.x,ymin:e.y,xmax:i.x,ymax:i.y}),this.m_bIsPannablePcs&&(n=this.m_envHelper.calculateBbox(n.xmin,n.ymin,n.xmax,n.ymax)),s.set(t,n),n}return s.get(t)}estimateMinimumDistance(i,s){const n={stack:[],error:void 0,hasError:!1};try{const e=t=>p(this.m_a,this.m_eSquared,t),o=this.m_boundaryPtsA.map(e),a=this.m_boundaryPtsB.map(e);let m=Number.MAX_VALUE,r=0,u=0;for(let t=0;t<o.length;++t)for(let e=0;e<a.length;++e){const i=T.distance(o[t],a[e]);i<m&&(m=i,r=t,u=e)}i.outPoint.assign(this.m_boundaryPtsA[r]),s.outPoint.assign(this.m_boundaryPtsB[u]);const c=t(n,new l,!1);return _.geodeticDistance(this.m_a,this.m_eSquared,this.m_boundaryPtsA[r].x,this.m_boundaryPtsA[r].y,this.m_boundaryPtsB[u].x,this.m_boundaryPtsB[u].y,c,null,null,this.m_distCurveType),c.val}catch(o){n.error=o,n.hasError=!0}finally{e(n)}}swapGeometries(t,e){return a(t[0])>a(e[0])&&(e[0]=E(t[0],t[0]=e[0]),this.m_envGeomB=E(this.m_envGeomA,this.m_envGeomA=this.m_envGeomB),!0)}canUseSpatialTree(t,e){return!1}checkGeometriesIntersect(t,e,i,n){let o=t.getGeometryType(),a=e.getGeometryType();if(this.m_envGeomA.isIntersecting(this.m_envGeomB)){if(o===s.enumPoint&&2===e.getDimension()){const s=[0],o=[t.getXY()];if(f(e,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}else if(a===s.enumPoint&&2===t.getDimension()){const s=[2],o=[e.getXY()];if(f(t,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}if(o===s.enumMultiPoint&&2===e.getDimension())return this.multipointIntersectsArea(t,e,i,n);if(a===s.enumMultiPoint&&2===t.getDimension())return this.multipointIntersectsArea(e,t,n,i);let r,u,c=t,h=e;if(o===s.enumEnvelope&&(r=this.envelopeToPolygon(t),c=r,o=s.enumPolygon),a===s.enumEnvelope&&(u=this.envelopeToPolygon(e),h=u,a=s.enumPolygon),m(o)&&m(a)){const t=c.querySegmentIterator(),e=h.querySegmentIterator(),s=N(),o=N();if(q(c,h,t,e,s,o))return i.outPoint.assign(s.outPoint),n.outPoint.assign(s.outPoint),!0}}return!1}multipointIntersectsArea(t,e,i,s){const n=t.getPointCount();for(let o=0;o<n;++o){const n=[2],a=t.getXY(o);if(f(e,[a],1,this.m_tolerance,n),0!==n[0])return i.outPoint.assign(a),s.outPoint.assign(a),!0}return!1}getNearestNeighbourVisitor(t,e,i,s,o,a,m){return n(0),{}}buildSpatialTree(t,e){n(0)}}export{Q as G,Z as a,L as m};
|
|
5
|
+
import{b as t,c as e}from"./tslib.es6.js";import{a as i,G as s,g as n,c as o,v as a,h as m}from"./Geometry.js";import{S as r,a as u}from"./QuadraticBezier.js";import{v as c,w as h,P as l,x as _,y as p,z as d,A as g,B as x,D as y,E as P,F as S,G as f,H as D,I as G,J as v}from"./ProjectionTransformation.js";import{d as T,a as b}from"./Envelope.js";import{Envelope2D as w}from"./Envelope2D.js";import{P as M,c as E,k as R,E as C,l as I}from"./Point2D.js";import{T as B}from"./Transformation2D.js";import{s as A,w as q,m as N}from"./Distance2DCalculator-C1KHhZwD.js";import{O as F}from"./OperatorShapePreservingDensify.js";import{O as Y}from"./OperatorClip.js";function k(){return new w}class X{[Symbol.dispose](){this.m_peR1.destroy(),this.m_peR2.destroy(),this.m_peR3.destroy(),this.m_peR1=null,this.m_peR2=null,this.m_peR3=null}constructor(t,e,i){this.m_peR1=new l,this.m_peR2=new l,this.m_peR3=new l,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,s){const n=this.m_peR1,o=this.m_peR2,a=this.m_peR3;_.geodeticDistance(this.m_a,this.m_e2,t*this.m_unitToRad,e*this.m_unitToRad,i*this.m_unitToRad,s*this.m_unitToRad,a,n,o,0);const m=Math.cos(n.val),r=Math.cos(o.val+3.141592653589793),u=e*this.m_unitToRad,c=D.phiToEta(this.m_e2,u),h=Math.sin(n.val)*Math.cos(c);let l=e;if(m*r<0){const t=m<0?-1:1,e=Math.acos(Math.abs(h))*t;l=D.etaToPhi(this.m_e2,e)/this.m_unitToRad}let p=I((i-t)*this.m_unitToRad,2*Math.PI);Math.abs(p)>Math.PI&&(p=p>0?p-2*Math.PI:p+2*Math.PI),p/=this.m_unitToRad,i=t+p;const d=k();return d.xmin=Math.min(t,i),d.xmax=Math.max(t,i),d.ymin=Math.min(e,s),d.ymin=Math.min(d.ymin,l),d.ymax=Math.max(e,s),d.ymax=Math.max(d.ymax,l),d}minDistanceGeodesic(t,e){const i=O(t),s=O(e);if(i&&s)return this.lowerDistanceGeodetic_(t.xmin,t.ymin,e.xmin,e.ymin);const n=this.normalizeGeodesic_(e,t);return U(t,n)?t.ymin>=n.ymax?this.minDistanceGeodesicUpDown_(t,n):n.ymin>=t.ymax?this.minDistanceGeodesicUpDown_(n,t):t.xmin>n.xmax?this.minDistanceGeodesicLeftRight_(n,t):this.minDistanceGeodesicLeftRight_(t,n):0}normalizeGeodesic_(t,e){const i=t.clone(),s=t.clone();let n=V(i,e);if(0===n)return i;for(;s.xmax>e.xmin;){s.xmin-=this.m_u360,s.xmax-=this.m_u360;const t=V(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}for(s.assign(t);s.xmin<e.xmax;){s.xmin+=this.m_u360,s.xmax+=this.m_u360;const t=V(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}return i}lowerDistanceGeodetic_(t,e,i,s){const n=this.m_peR1;{const o=this.m_b*this.m_b/this.m_a,a=D.phiToPhig(this.m_e2,this.m_unitToRad*e),m=D.phiToPhig(this.m_e2,this.m_unitToRad*s);_.geodeticDistance(o,0,this.m_unitToRad*t,a,this.m_unitToRad*i,m,n,null,null,0)}return n.val}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 s=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);return Math.min(i,s)}{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 s=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);return Math.min(i,s)}}minDistanceGeodesicLeftRight_(t,e){let i=Math.abs(t.xmax-e.xmin);for(;i>this.m_u180;)i-=this.m_u360;let s=Math.abs(t.xmin-e.xmax);for(;s>this.m_u180;)s-=this.m_u360;return Math.abs(i)<=Math.abs(s)?this.minDistanceGeodesicLeftRightNormalized_(t,e):this.minDistanceGeodesicLeftRightNormalized_(e,t)}minDistanceGeodesicLeftRightNormalized_(t,e){let i,s;return i=this.lowerDistanceGeodetic_(t.xmax,t.ymin,e.xmin,e.ymin),t.ymin>=e.ymin&&t.ymin<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymin,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymin>=t.ymin&&e.ymin<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymin,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),s=this.lowerDistanceGeodetic_(t.xmax,t.ymax,e.xmin,e.ymax),i=Math.min(i,s),t.ymax>=e.ymin&&t.ymax<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymax,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymax>=t.ymin&&e.ymax<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymax,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),i}lowerDistanceGeodeticSegMeridional_(t,e,i,s,n,o){let a=this.lowerDistanceGeodeticPtMeridional_(t,e,s,n,o);const m=this.lowerDistanceGeodeticPtMeridional_(t,i,s,n,o);let r=this.lowerDistanceGeodeticPtMeridional_(s,n,t,e,i);const u=this.lowerDistanceGeodeticPtMeridional_(s,o,t,e,i);return a=Math.min(a,m),r=Math.min(r,u),Math.min(a,r)}lowerDistanceGeodeticPtMeridional_(t,e,i,s,n){const o=this.m_b*this.m_b/this.m_a,a=D.phiToPhig(this.m_e2,this.m_unitToRad*e),m=D.phiToPhig(this.m_e2,this.m_unitToRad*s),r=D.phiToPhig(this.m_e2,this.m_unitToRad*n),u=this.m_peR1,c=this.m_peR2;_.geodeticDistance(o,0,this.m_unitToRad*i,m,this.m_unitToRad*t,a,u,null,null,0),_.geodeticDistance(o,0,this.m_unitToRad*i,r,this.m_unitToRad*t,a,c,null,null,0);const h=p(1,0,new M(this.m_unitToRad*t,a)),l=p(1,0,new M(this.m_unitToRad*i,m)),d=p(1,0,new M(this.m_unitToRad*i,r));let g=new T;g.setCrossProductVector(l,d);const x=l.dotProduct(d);if(g.length()<1.568e-10)return x>=0?Math.min(u.val,c.val):0;g=g.getUnitVector();let y=new T;if(y.setCrossProductVector(g,h),y.length()<1.568e-10){return Math.min(u.val,c.val)-1e-5*o}y=y.getUnitVector();let P=h.sub(g.mul(h.dotProduct(g)));{const e=new T;e.setCrossProductVector(l,P);const i=new T;i.setCrossProductVector(P,d);let s=g.dotProduct(e)>0&&g.dotProduct(i)>0;if(s||(P.negateThis(),e.setCrossProductVector(l,P),i.setCrossProductVector(P,d),s=g.dotProduct(e)>0&&g.dotProduct(i)>0),s){P=P.getUnitVector();const e=G(1,0,P),i=this.m_peR3;_.geodeticDistance(o,0,this.m_unitToRad*t,a,e.x,e.y,i,null,null,0);const s=Math.min(u.val,c.val);return Math.min(s,i.val)}}return Math.min(u.val,c.val)}}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 V(t,e){let i,s=0;return i=t.xmin-e.xmax,i>s&&(s=i),i=e.xmin-t.xmax,i>s&&(s=i),s}class j{}function L(t){return{outPoint:void 0===t?new M:t.clone()}}function z(t,e){t.outPoint.assign(e.outPoint)}function H(){return new w}class J{constructor(t,e,i,s,n=0,o=4){this.m_ptDistFrom=new M,this.m_segStartPt=new M,this.m_segEndPt=new M,this.m_geodeticLength=new l,this.m_az12=new l,this.m_minGeodeticDist=new l,this.m_segStartPt3d=new T,this.m_segEndPt3d=new T,this.m_sr=s,this.m_distCurveType=n,this.m_segCurveType=o,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 a=v();this.m_inputGCS.querySpheroidData(a),this.m_a=a.majorSemiAxis,this.m_eSquared=a.e2,this.setPointDistFrom(t),this.setSegmentEndPoints(e,i)}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(p(this.m_a,this.m_eSquared,this.m_segStartPt)),this.m_segEndPt3d.assign(p(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 i=>{let s;switch(this.m_segCurveType){case 0:case 1:case 3:{const o={stack:[],error:void 0,hasError:!1};try{const e=t(o,new l,!1),n=t(o,new l,!1);_.geodeticCoordinate(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_geodeticLength.val*i,this.m_az12.val,e,n,this.m_segCurveType),s=new M(e.val,n.val);break}catch(n){o.error=n,o.hasError=!0}finally{e(o)}}case 2:{const t=T.lerp(this.m_segStartPt3d,this.m_segEndPt3d,i);s=G(this.m_a,this.m_eSquared,t);break}case 4:s=M.lerp(this.m_segStartPt,this.m_segEndPt,i),this.m_bIsPannablePcs&&(g(this.m_sr,0,[s],1),s.mulThis(this.m_rpu));break;default:o("Invalid curve type")}return _.geodeticDistance(this.m_a,this.m_eSquared,this.m_ptDistFrom.x,this.m_ptDistFrom.y,s.x,s.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:_.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=M.distance(this.m_segStartPt,this.m_segEndPt);break;default:o("Invalid curve type")}}[Symbol.dispose](){this.m_geodeticLength[Symbol.dispose](),this.m_az12[Symbol.dispose](),this.m_minGeodeticDist[Symbol.dispose]()}}function K(){return new j}class Q{[Symbol.dispose](){this.m_envHelper[Symbol.dispose]()}constructor(t,e,i,s,n){this.m_boxGeomA=H(),this.m_boxGeomB=H(),this.m_envGeomA=new w,this.m_envGeomB=new w,this.m_progressCounter=0,this.m_transformPCS2GCS=null,this.m_segmentBoxesA=new Map,this.m_segmentBoxesB=new Map,this.m_boundaryPtsA=[],this.m_boundaryPtsB=[],this.m_scaleToRadians=new B,this.m_scaleToDegrees=new B,this.m_inputSR=t,this.m_distCurveType=e,this.m_progressTracker=i,this.m_maxDistance=s,this.m_maxDeviation=n,this.m_inputGCS=t.getGCS(),this.m_peGeogcs=this.m_inputGCS.getPECoordSys(),this.m_tolerance=0;const o=v();this.m_inputGCS.querySpheroidData(o),this.m_a=o.majorSemiAxis,this.m_eSquared=o.e2,this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_envHelper=new X(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()}progress(t=!1){}calculate(t,e,i,s){const n=L(),o=L();if(t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.checkGeometriesIntersect(t,e,n,o))return i&&z(i,n),s&&z(s,o),0;const a=this.prepareGeometry(t);if(a.isEmpty())return Number.NaN;const m=this.prepareGeometry(e);if(m.isEmpty())return Number.NaN;this.m_tolerance=this.computeTolerance(a,m);const r=this._ExecuteBruteForce(a,m,n,o);return r>=this.m_maxDistance?Number.NaN:(i&&(this.prepareOutput(n),z(i,n)),s&&(this.prepareOutput(o),z(s,o)),r)}createDistanceFunctor(t,e,i){const s=new J(t,e,i,this.m_inputSR,this.m_distCurveType);return this.m_bIsPannablePcs||1===this.m_inputSR.getCoordinateSystemType()||s.setSegmentCurveType(2),s}_NormalizeAndProject(t){if(this.m_inputSR.isPannable()&&(t=(new c).foldInto360Range(t,this.m_inputSR)),2===this.m_inputSR.getCoordinateSystemType()){const e=h(this.m_inputSR,this.m_inputGCS,null);t=(new c).execute(t,e,this.m_progressTracker)}return t}_ExecuteBruteForce(t,e,n,o){switch(t.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointGeometry(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointGeometry(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathGeometry(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointPoint(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticPointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:return this.calculateDistanceGeodeticPointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointPoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=i.getXY();e.scale(this.m_rpu);const m=s.getXY();m.scale(this.m_rpu),n.outPoint.assign(e),o.outPoint.assign(m);const r=t(a,new l,!1);return _.geodeticDistance(this.m_a,this.m_eSquared,e.x,e.y,m.x,m.y,r,null,null,this.m_distCurveType),r.val}catch(m){a.error=m,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticPointMultipoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{this.computeEnvelopesAndBoxes(i,s);const e=this.estimateMinimumDistance(n,o);let m=e<this.m_maxDistance?e:this.m_maxDistance;const r=i.getXY();r.scale(this.m_rpu),n.outPoint.assign(r);const u=p(this.m_a,this.m_eSquared,r),c=new M,h=s.getImpl(),d=t(a,new l,!1),g=h.getPointCount();for(let t=0;t<g;++t){h.queryXY(t,c),c.scale(this.m_rpu);const e=p(this.m_a,this.m_eSquared,c);if(!(T.distance(u,e)>m)&&(!(this.m_envHelper.minDistanceGeodesic(this.m_boxGeomA,this.m_boxGeomB)>m)&&(_.geodeticDistance(this.m_a,this.m_eSquared,r.x,r.y,c.x,c.y,d,null,null,this.m_distCurveType),d.val<m&&(m=d.val,o.outPoint=c,0===m))))return m}return m===this.m_maxDistance?Number.POSITIVE_INFINITY:m}catch(m){a.error=m,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticPointMultipath(i,s,o,a){const m={stack:[],error:void 0,hasError:!1};try{const e=new M,r=new M;e.assign(i.getXY()),r.assign(i.getXY()),o.outPoint.assign(r.mul(this.m_rpu)),this.m_bIsPannablePcs&&d(this.m_inputSR,[e],1,!1),this.computeEnvelopesAndBoxes(i,s);const u=this.estimateMinimumDistance(o,a);let c=u<this.m_maxDistance?u:this.m_maxDistance;const h=s.getImpl(),l=new M(0,0),_=new M(0,0),p=[1],g=this.canUseSpatialTree(i,s),x=K();g&&this.buildSpatialTree(x,s);const y=H();y.setCoords({xmin:r.x,ymin:r.y,xmax:r.x,ymax:r.y});const P=t(m,this.createDistanceFunctor(r,l,_),!1),S=h.querySegmentIterator();if(S.stripAttributes(),g)n(0);else for(;S.nextPath();)for(;S.hasNextSegment();){const t=S.nextSegment(),i=this.findOrComputeBoxSegment(S.getStartPointIndex(),t,this.m_segmentBoxesB);if(this.m_envHelper.minDistanceGeodesic(y,i)>c)continue;const s=this.calculateDistanceGeodeticPointSegment(e,r,t,p,P);if(s.second<c&&(this.updateOutputSegment(a,t,s.first),c=s.second,0===c))return 0}return c===this.m_maxDistance?Number.POSITIVE_INFINITY:c}catch(r){m.error=r,m.hasError=!0}finally{e(m)}}calculateDistanceGeodeticMultipointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipoint(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipointMultipoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new l,!1);this.computeEnvelopesAndBoxes(i,s);const m=this.estimateMinimumDistance(n,o);let r=m<this.m_maxDistance?m:this.m_maxDistance;const u=new M,c=new M,h=i.getImpl(),d=s.getImpl(),g=H(),x=h.getPointCount(),y=d.getPointCount();for(let t=0;t<x;++t){if(u.assign(h.getXY(t)),g.setCoords({xmin:u.x,ymin:u.y,xmax:u.x,ymax:u.y}),this.m_envHelper.minDistanceGeodesic(g,this.m_boxGeomB)>r)continue;u.scale(this.m_rpu);const i=p(this.m_a,this.m_eSquared,u);for(let t=0;t<y;++t){c.assign(d.getXY(t)),c.scale(this.m_rpu);const s=p(this.m_a,this.m_eSquared,c);if(!(T.distance(i,s)>=r)&&(_.geodeticDistance(this.m_a,this.m_eSquared,u.x,u.y,c.x,c.y,e,null,null,this.m_distCurveType),e.val<r&&(n.outPoint.assign(u),o.outPoint.assign(c),r=e.val,0===r)))return r}}return r===this.m_maxDistance?Number.POSITIVE_INFINITY:r}catch(m){a.error=m,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticMultipointMultipath(i,s,o,a){const m={stack:[],error:void 0,hasError:!1};try{const e=s.getImpl().querySegmentIterator();e.stripAttributes(),this.computeEnvelopesAndBoxes(i,s);const r=this.estimateMinimumDistance(o,a);let u=r<this.m_maxDistance?r:this.m_maxDistance;const c=new M,h=new M(0,0),l=new M(0,0),_=new M(0,0),p=[0],g=H(),x=t(m,this.createDistanceFunctor(h,l,_),!1),y=K(),P=this.canUseSpatialTree(i,s);P&&this.buildSpatialTree(y,s);const S=i.getPointCount();for(let t=0;t<S;++t)if(c.assign(i.getXY(t)),h.assign(i.getXY(t)),this.m_bIsPannablePcs&&d(this.m_inputSR,[c],1,!1),g.setCoords({xmin:h.x,ymin:h.y,xmax:h.x,ymax:h.y}),!(this.m_envHelper.minDistanceGeodesic(g,this.m_boxGeomB)>u))if(x.setPointDistFrom(h),P)n(0);else{for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(this.m_envHelper.minDistanceGeodesic(g,this.findOrComputeBoxSegment(e.getStartPointIndex(),t,this.m_segmentBoxesB))>u)continue;const i=this.calculateDistanceGeodeticPointSegment(c,h,t,p,x);if(i.second<u&&(o.outPoint.assign(h.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),u=i.second,0===u))return 0}e.resetToFirstPath()}return u===this.m_maxDistance?Number.POSITIVE_INFINITY:u}catch(r){m.error=r,m.hasError=!0}finally{e(m)}}calculateDistanceGeodeticMultipathGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipath(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipath(e,t,o,n);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipathMultipath(t,e,i,s){const n=[t],o=[e],a=this.swapGeometries(n,o),m=n[0],r=o[0];this.computeEnvelopesAndBoxes(n[0],o[0]);const u=this.estimateMinimumDistance(i,s),c=this.calculateDistanceGeodeticMultipathMultipath_(m,r,i,s,u);return a&&(s.outPoint=E(i.outPoint,i.outPoint=s.outPoint)),c}calculateDistanceGeodeticMultipathMultipath_(i,s,o,a,m=Number.MAX_VALUE){const u={stack:[],error:void 0,hasError:!1};try{let e=m;const c=new M(0,0),h=new M,l=new M(0,0),_=new M,p=new M(0,0),d=new M,y=new M,P=new M,S=[new M],f=[0],D=[0],G=H(),v=H(),T=t(u,this.createDistanceFunctor(p,c,l),!1),b=K(),w=this.canUseSpatialTree(i,s);w&&this.buildSpatialTree(b,s);const E=s.querySegmentIterator();E.stripAttributes();const R=new r,C=A(i);for(let t=0;t<C.length;++t){const s=C[t];i.getSegmentBuffer(s,R,!0);const m=R.get();if(G.assign(this.findOrComputeBoxSegment(s,m,this.m_segmentBoxesA)),w)n(0);else{if(p.assign(m.getStartXY()),d.assign(m.getStartXY()),y.assign(m.getEndXY()),P.assign(m.getEndXY()),this.m_bIsPannablePcs&&(g(this.m_inputSR,0,[d],1),g(this.m_inputSR,0,[P],1)),this.m_envHelper.minDistanceGeodesic(G,this.m_boxGeomB)>e)continue;for(;E.nextPath();){for(;E.hasNextSegment();){const t=E.nextSegment();if(c.assign(t.getStartXY()),h.assign(t.getStartXY()),l.assign(t.getEndXY()),_.assign(t.getEndXY()),m.intersect(t,S,f,D,this.m_tolerance))return this.updateOutputSegment(o,m,f[0]),this.updateOutputSegment(a,t,D[0]),0;if(this.m_bIsPannablePcs&&(g(this.m_inputSR,0,[h],1),g(this.m_inputSR,0,[_],1)),v.assign(this.findOrComputeBoxPoint(E.getStartPointIndex(),h,_,this.m_segmentBoxesB)),this.m_envHelper.minDistanceGeodesic(G,v)>e)continue;T.setSegmentEndPoints(c,l),T.setPointDistFrom(d);let i=x(T.makeFunctor(),0,1,1e-10);if(i.second<e&&(o.outPoint.assign(d.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setPointDistFrom(P),i=x(T.makeFunctor(),0,1,1e-10),i.second<e&&(o.outPoint.assign(P.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setSegmentEndPoints(p,y),T.setPointDistFrom(h),i=x(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,m,i.first),a.outPoint.assign(h.mul(this.m_rpu)),e=i.second,0===e))break;if(T.setPointDistFrom(_),i=x(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,m,i.first),a.outPoint.assign(_.mul(this.m_rpu)),e=i.second,0===e))break}if(0===e)return 0}E.resetToFirstPath()}}return e===this.m_maxDistance?Number.POSITIVE_INFINITY:e}catch(c){u.error=c,u.hasError=!0}finally{e(u)}}calculateDistanceGeodeticPointSegment(t,e,i,s,n){const o=i.getStartXY(),a=i.getEndXY();return i.intersectPoint(t,s,this.m_tolerance)?R(s[0],0):(n.setPointDistFrom(e),n.setSegmentEndPoints(o,a),x(n.makeFunctor(),0,1,1e-10))}prepareGeometry(t){let e=t.clone();const i=t.getGeometryType();if(i===s.enumPoint||i===s.enumMultiPoint)return this._NormalizeAndProject(e);if(i===s.enumEnvelope&&(e=this.envelopeToPolygon(e)),this.m_inputSR.isPannable())return this.prepareGeometryPannable(e,4);if(2===this.m_inputSR.getCoordinateSystemType()){if(e=y(e,this.m_inputSR,0,null),e.isEmpty())return e;e=(new F).execute(e,this.m_inputSR,5e4,this.m_maxDeviation/2,0,null);const t=this.m_inputSR.getSRToGCSTransform();return(new c).execute(e,t,this.m_progressTracker)}const n=new w;e.queryLooseEnvelope(n);const o=this.m_inputSR.getPannableExtent();if(n.ymin<o.ymin||n.ymax>o.ymax){const t=new w(n.xmin-1,o.ymin,n.xmax+1,o.ymax);if(e=(new Y).execute(e,t,this.m_inputSR,this.m_progressTracker),e.isEmpty())return e}return n.width()>2*o.width()?(e=P(e,-2*o.width(),2*o.width(),this.m_inputSR,!0,0,!0,this.m_progressTracker),e):e}prepareGeometryPannable(t,e){const i=new w;t.queryEnvelope(i);const s=this.m_inputSR.getPannableExtent();if(s.containsEnvelope(i))return t;const n=new C;s.queryIntervalX(n);const o=new C;return i.queryIntervalX(o),t=n.contains(o)?S(t,this.m_inputSR):(new c).foldInto360RangeGeodetic(t,this.m_inputSR,e)}prepareOutput(t){t.outPoint.scale(1/this.m_rpu),2===this.m_inputSR.getCoordinateSystemType()&&d(this.m_inputSR,[t.outPoint],1,!1)}updateOutputSegment(t,e,i){e.queryCoord2D(i,t.outPoint),this.m_bIsPannablePcs&&g(this.m_inputSR,0,[t.outPoint],1),t.outPoint.mulThis(this.m_rpu)}computeTolerance(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB);const i=new w(this.m_envGeomA);return i.mergeEnvelope2D(this.m_envGeomB),b(null,i)}envelopeToPolygon(t){const e=new u;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 s.enumPoint:return this.computeBoxPoint(t,e);case s.enumMultiPoint:return this.computeBoxMultiPoint(t,e);case s.enumPolyline:case s.enumPolygon:return this.computeBoxMultiPath(t,e,i);default:o("Invalid geometry type")}}computeBoxPoint(t,e){const i=t.getXY();e.length=0,e.push(i.mul(this.m_rpu));const s=H();return s.setCoords({xmin:i.x,ymin:i.y,xmax:i.x,ymax:i.y}),s}computeBoxMultiPoint(t,e){let i=!0;for(let n=0;n<t.getPointCount();++n){const s=t.getXY(n);if(i){e.length=0;for(let t=0;t<4;++t)e.push(s.clone());i=!1}s.x<e[0].x&&e[0].assign(s),s.y>e[1].y&&e[1].assign(s),s.x>e[2].x&&e[2].assign(s),s.y<e[3].y&&e[3].assign(s)}for(let n=0;n<e.length;++n)e[n].mulThis(this.m_rpu);const s=H();return t.queryEnvelope(s),s}computeBoxMultiPath(t,e,i){let s=!0;const n=H();n.setEmpty();const o=t.querySegmentIterator();for(o.stripAttributes();o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),a=t.getStartXY(),m=t.getEndXY();if(this.m_bIsPannablePcs&&(g(this.m_inputSR,0,[a],1),g(this.m_inputSR,0,[m],1)),s){for(let t=0;t<4;++t)e.push(a.clone());s=!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),m.x<e[0].x&&e[0].assign(m),m.y>e[1].y&&e[1].assign(m),m.x>e[2].x&&e[2].assign(m),m.y<e[3].y&&e[3].assign(m);const r=this.findOrComputeBoxPoint(o.getStartPointIndex(),a,m,i);n.mergeEnvelope2D(r)}for(let a=0;a<e.length;++a)e[a].mulThis(this.m_rpu);return n}findOrComputeBoxSegment(t,e,i){if(!i.has(t)){let s=H();if(e.queryEnvelope(s),this.m_bIsPannablePcs){const t=M.construct(s.xmin,s.ymin),e=M.construct(s.xmax,s.ymax);g(this.m_inputSR,0,[t],1),g(this.m_inputSR,0,[e],1),s=this.m_envHelper.calculateBbox(t.x,t.y,e.x,e.y)}return i.set(t,s),s}return i.get(t)}findOrComputeBoxPoint(t,e,i,s){if(!s.has(t)){let n=H();return n.setCoords({xmin:e.x,ymin:e.y,xmax:i.x,ymax:i.y}),this.m_bIsPannablePcs&&(n=this.m_envHelper.calculateBbox(n.xmin,n.ymin,n.xmax,n.ymax)),s.set(t,n),n}return s.get(t)}estimateMinimumDistance(i,s){const n={stack:[],error:void 0,hasError:!1};try{const e=t=>p(this.m_a,this.m_eSquared,t),o=this.m_boundaryPtsA.map(e),a=this.m_boundaryPtsB.map(e);let m=Number.MAX_VALUE,r=0,u=0;for(let t=0;t<o.length;++t)for(let e=0;e<a.length;++e){const i=T.distance(o[t],a[e]);i<m&&(m=i,r=t,u=e)}i.outPoint.assign(this.m_boundaryPtsA[r]),s.outPoint.assign(this.m_boundaryPtsB[u]);const c=t(n,new l,!1);return _.geodeticDistance(this.m_a,this.m_eSquared,this.m_boundaryPtsA[r].x,this.m_boundaryPtsA[r].y,this.m_boundaryPtsB[u].x,this.m_boundaryPtsB[u].y,c,null,null,this.m_distCurveType),c.val}catch(o){n.error=o,n.hasError=!0}finally{e(n)}}swapGeometries(t,e){return a(t[0])>a(e[0])&&(e[0]=E(t[0],t[0]=e[0]),this.m_envGeomB=E(this.m_envGeomA,this.m_envGeomA=this.m_envGeomB),!0)}canUseSpatialTree(t,e){return!1}checkGeometriesIntersect(t,e,i,n){let o=t.getGeometryType(),a=e.getGeometryType();if(this.m_envGeomA.isIntersecting(this.m_envGeomB)){if(o===s.enumPoint&&2===e.getDimension()){const s=[0],o=[t.getXY()];if(f(e,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}else if(a===s.enumPoint&&2===t.getDimension()){const s=[2],o=[e.getXY()];if(f(t,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}if(o===s.enumMultiPoint&&2===e.getDimension())return this.multipointIntersectsArea(t,e,i,n);if(a===s.enumMultiPoint&&2===t.getDimension())return this.multipointIntersectsArea(e,t,n,i);let r,u,c=t,h=e;if(o===s.enumEnvelope&&(r=this.envelopeToPolygon(t),c=r,o=s.enumPolygon),a===s.enumEnvelope&&(u=this.envelopeToPolygon(e),h=u,a=s.enumPolygon),m(o)&&m(a)){const t=c.querySegmentIterator(),e=h.querySegmentIterator(),s=N(),o=N();if(q(c,h,t,e,s,o))return i.outPoint.assign(s.outPoint),n.outPoint.assign(s.outPoint),!0}}return!1}multipointIntersectsArea(t,e,i,s){const n=t.getPointCount();for(let o=0;o<n;++o){const n=[2],a=t.getXY(o);if(f(e,[a],1,this.m_tolerance,n),0!==n[0])return i.outPoint.assign(a),s.outPoint.assign(a),!0}return!1}getNearestNeighbourVisitor(t,e,i,s,o,a,m){return n(0),{}}buildSpatialTree(t,e){n(0)}}export{Q as G,J as a,L as m};
|
package/chunks/Geometry.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function e(e){switch(e){case 1:return"Unknown error";case 2:return"Corrupted geometry";case 3:return"Empty geometry";case 4:return"Math singularity";case 5:return"Buffer is too small";case 6:return"Invalid shape type";case 7:return"Projection out of supported range";case 8:return"Non simple geometry";case 9:return"Cannot calculate geodesic";case 10:return"Notation conversion";case 11:return"Missing grid file";case 12:return"Invalid call";case 13:return"Internal error";case 14:return"Not implemented";case 15:return"IO error";case 16:return"Invalid 3D";case 17:return"An ambiguous geography edge with antipodal points";case 18:return"Geocentric coordinates require ellipsoidal height";case 19:return"Geography cannot be projected into a gnomonic plane or a result of an operation cannot fit into a gnomonic plane";case 20:return"Geometry is too large to be exported in to a given format";case 22:return"Operation is canceled by the user";case 21:return"The operation, such as projection or geodetic computation, cannot be performed without pe-wasm loaded";default:return"unknown error"}}function n(e,n){try{if(!e)throw new Error(n)}catch(t){throw t}}class t extends Error{constructor(e,n){super(n),this.m_AdditionalMessage=n,this.m_ErrorType=e,this.name="GeometryError"}what(){return e(this.m_ErrorType)}additionalMessage(){return this.m_AdditionalMessage?this.m_AdditionalMessage:""}code(){return this.m_ErrorType}}class r extends t{constructor(e){super(2,e),this.name="CorruptedGeometryError"}}class o extends t{constructor(e){super(3,e),this.name="EmptyGeometryError"}}class i extends t{constructor(e){super(4,e),this.name="MathSingularityError"}}class u extends t{constructor(e){super(21,e),this.name="ProjectionEngineNotLoadedError"}}class s extends t{constructor(e){super(8,e),this.name="NonSimpleGeometryError"}}var a;!function(e){e[e.enumUnknown=0]="enumUnknown",e[e.enumPoint=513]="enumPoint",e[e.enumLine=5122]="enumLine",e[e.enumBezier=5123]="enumBezier",e[e.enumEllipticArc=5124]="enumEllipticArc",e[e.enumEnvelope=3077]="enumEnvelope",e[e.enumMultiPoint=8710]="enumMultiPoint",e[e.enumPolyline=25607]="enumPolyline",e[e.enumPolygon=27656]="enumPolygon",e[e.enumMultipatch=40969]="enumMultipatch",e[e.enumGeometryCollection=3594]="enumGeometryCollection",e[e.enumRationalBezier2=5134]="enumRationalBezier2",e[e.enumBezier2=5135]="enumBezier2",e[e.enumRationalBezier23d=5392]="enumRationalBezier23d",e[e.enumGreatArc3d=5393]="enumGreatArc3d"}(a||(a={}));const c=[0,0,1,1,1,2,0,1,2,3,-1,-1,-1,-1,1,1];function m(e){return c[15&e]}function l(e){return!!(512&e)}function p(e){return!!(1024&e)}function d(e){return!!(2048&e)}function f(e){return!!(4096&e)}function y(e){return!!(8192&e)}function h(e){return!!(16384&e)}function g(e){return!!(32768&e)}function w(e){const n=e.getGeometryType();return y(n)?e.getPointCount():e.isEmpty()?0:n===a.enumEnvelope?4:n===a.enumPoint?1:f(n)?2:void b("missing type")}function E(e){const n=e.getGeometryType();if(h(n))return e.hasNonLinearSegments();if(n===a.enumGeometryCollection){const n=e;for(let e=0,t=n.getGeometryCount();e<t;e++)if(E(n.getGeometry(e)))return!0;return!1}return!!f(n)&&n!==a.enumLine}function G(e){throw new u(e)}function v(e){throw new r(e)}function P(e){throw new Error(e)}function M(e){throw new i(e)}function B(){P("Geometry type is not supported for 3D operations.")}function C(e){throw new t(12,e)}function x(e){throw new o(e)}function z(e){throw new t(14,e)}function A(e){throw new Error(e)}function b(e){throw new t(13,e)}function T(e){throw new Error(e)}function k(e){throw new s(e)}function _(){z("Operation does not support curves.")}function N(e){e&&E(e)&&_()}function j(e){e&&g(e.getGeometryType())&&z("Unsupported geometry type.")}function I(e){e===a.enumGeometryCollection&&P("Geometry_collection instances are not supported in this operation")}function L(e){I(e.getGeometryType())}function R(e){P(`bad wkid: ${e}`)}function U(e){let n="bad wkt: ";n+=e,n+="...",P(n)}function D(e,n){e||P(n)}export{m as A,L as B,I as C,k as D,a as G,
|
|
5
|
+
function e(e){switch(e){case 1:return"Unknown error";case 2:return"Corrupted geometry";case 3:return"Empty geometry";case 4:return"Math singularity";case 5:return"Buffer is too small";case 6:return"Invalid shape type";case 7:return"Projection out of supported range";case 8:return"Non simple geometry";case 9:return"Cannot calculate geodesic";case 10:return"Notation conversion";case 11:return"Missing grid file";case 12:return"Invalid call";case 13:return"Internal error";case 14:return"Not implemented";case 15:return"IO error";case 16:return"Invalid 3D";case 17:return"An ambiguous geography edge with antipodal points";case 18:return"Geocentric coordinates require ellipsoidal height";case 19:return"Geography cannot be projected into a gnomonic plane or a result of an operation cannot fit into a gnomonic plane";case 20:return"Geometry is too large to be exported in to a given format";case 22:return"Operation is canceled by the user";case 21:return"The operation, such as projection or geodetic computation, cannot be performed without pe-wasm loaded";default:return"unknown error"}}function n(e,n){try{if(!e)throw new Error(n)}catch(t){throw t}}class t extends Error{constructor(e,n){super(n),this.m_AdditionalMessage=n,this.m_ErrorType=e,this.name="GeometryError"}what(){return e(this.m_ErrorType)}additionalMessage(){return this.m_AdditionalMessage?this.m_AdditionalMessage:""}code(){return this.m_ErrorType}}class r extends t{constructor(e){super(2,e),this.name="CorruptedGeometryError"}}class o extends t{constructor(e){super(3,e),this.name="EmptyGeometryError"}}class i extends t{constructor(e){super(4,e),this.name="MathSingularityError"}}class u extends t{constructor(e){super(21,e),this.name="ProjectionEngineNotLoadedError"}}class s extends t{constructor(e){super(8,e),this.name="NonSimpleGeometryError"}}var a;!function(e){e[e.enumUnknown=0]="enumUnknown",e[e.enumPoint=513]="enumPoint",e[e.enumLine=5122]="enumLine",e[e.enumBezier=5123]="enumBezier",e[e.enumEllipticArc=5124]="enumEllipticArc",e[e.enumEnvelope=3077]="enumEnvelope",e[e.enumMultiPoint=8710]="enumMultiPoint",e[e.enumPolyline=25607]="enumPolyline",e[e.enumPolygon=27656]="enumPolygon",e[e.enumMultipatch=40969]="enumMultipatch",e[e.enumGeometryCollection=3594]="enumGeometryCollection",e[e.enumRationalBezier2=5134]="enumRationalBezier2",e[e.enumBezier2=5135]="enumBezier2",e[e.enumRationalBezier23d=5392]="enumRationalBezier23d",e[e.enumGreatArc3d=5393]="enumGreatArc3d"}(a||(a={}));const c=[0,0,1,1,1,2,0,1,2,3,-1,-1,-1,-1,1,1];function m(e){return c[15&e]}function l(e){return!!(512&e)}function p(e){return!!(1024&e)}function d(e){return!!(2048&e)}function f(e){return!!(4096&e)}function y(e){return!!(8192&e)}function h(e){return!!(16384&e)}function g(e){return!!(32768&e)}function w(e){const n=e.getGeometryType();return y(n)?e.getPointCount():e.isEmpty()?0:n===a.enumEnvelope?4:n===a.enumPoint?1:f(n)?2:void b("missing type")}function E(e){const n=e.getGeometryType();if(h(n))return e.hasNonLinearSegments();if(n===a.enumGeometryCollection){const n=e;for(let e=0,t=n.getGeometryCount();e<t;e++)if(E(n.getGeometry(e)))return!0;return!1}return!!f(n)&&n!==a.enumLine}function G(e){throw new u(e)}function v(e){throw new r(e)}function P(e){throw new Error(e)}function M(e){throw new i(e)}function B(){P("Geometry type is not supported for 3D operations.")}function C(e){throw new t(12,e)}function x(e){throw new o(e)}function z(e){throw new t(14,e)}function A(e){throw new Error(e)}function b(e){throw new t(13,e)}function T(e){throw new Error(e)}function k(e){throw new s(e)}function _(){z("Operation does not support curves.")}function N(e){e&&E(e)&&_()}function j(e){e&&g(e.getGeometryType())&&z("Unsupported geometry type.")}function I(e){e===a.enumGeometryCollection&&P("Geometry_collection instances are not supported in this operation")}function L(e){I(e.getGeometryType())}function R(e){P(`bad wkid: ${e}`)}function U(e){let n="bad wkt: ";n+=e,n+="...",P(n)}function D(e,n){e||P(n)}export{m as A,L as B,I as C,k as D,a as G,P as a,M as b,b as c,j as d,l as e,f,n as g,h,y as i,g as j,d as k,p as l,E as m,v as n,N as o,C as p,A as q,G as r,T as s,z as t,x as u,w as v,D as w,B as x,R as y,U as z};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{G as t,h as e,
|
|
5
|
+
import{G as t,h as e,t as n}from"./Geometry.js";function i(i,a){const f=i.getGeometryType();return f===t.enumPoint?r(i):e(f)?u(i):f===t.enumMultiPoint?o(i):f===t.enumEnvelope?i:f===t.enumMultipatch?(n("not implemented for multipatch"),i):i}function r(t){return t}function u(e){if(a(e))return e;const n=e.createInstance();for(let i=0,r=e.getPathCount();i<r;i++){const r=e.getPathSize(i);if(0!==r){if(1===r){if(0===e.getSegmentCountPath(i))continue;if(e.getSegmentType(e.getPathStart(i))===t.enumLine)continue;if(!e.isClosedPath(i))continue}n.addPath(e,i,!0)}}return n}function o(t){return t}function a(e){for(let n=0,i=e.getPathCount();n<i;n++){const i=e.getPathSize(n);if(0===i)return!1;if(1===i){if(0===e.getSegmentCountPath(n))return!1;if(e.getSegmentType(e.getPathStart(n))===t.enumLine)return!1;if(!e.isClosedPath(n))return!1}}return!0}export{i as c};
|
package/chunks/OperatorClip.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{G as e}from"./SimpleGeometryCursor.js";import{G as t,i as s,t as i,g as n,c as r,d as h}from"./Geometry.js";import{a as m}from"./Envelope.js";import{Envelope2D as a}from"./Envelope2D.js";import{E as o,n as x,L as p,S as c}from"./QuadraticBezier.js";import{d as l,m as _,P as u,e as g,f as y}from"./Point2D.js";function f(e,t,s,i,n){return v(e,t,null,s,i,n)}function v(e,h,o,x,p,c){const l=e.getGeometryType();if(l===t.enumPoint){const t=e.getXY();return h.contains(t)?e:e.createInstance()}if(l===t.enumEnvelope){const t=a.constructEmpty();if(e.queryEnvelope(t),t.intersect(h)){const s=e.clone();return s.setEnvelope(t),s}return e.createInstance()}if(e.isEmpty())return e;if(h.isEmpty())return e.createInstance();const _=h.clone();{const t=new a;if(e.queryLooseEnvelope(t),_.containsEnvelope(t))return e;if(!_.isIntersecting(t))return e.createInstance();0===p&&(t.intersect(_),t.inflate(Math.max(.1*t.maxDimension(),1)),t.intersect(_),_.assign(t))}let u=x;if((null!==o||Number.isNaN(u))&&(u=m(o,_,!1).total()),l===t.enumGeometryCollection){const t=e,s=e.createInstance();for(let e=0,i=t.getGeometryCount();e<i;e++){const i=t.getGeometry(e);if(i.isEmpty())continue;const n=f(i,_,u,p,c);n.isEmpty()||(n===i?s.addGeometry(n.clone()):s.addGeometry(n))}return s}s(l)||i("Clip: geometry not supported");const g=e.getImpl().getAccelerators();if(null!==g){const e=g.getRasterizedGeometry();n(null===e)}switch(l){case t.enumMultiPoint:{const t=e;let s;const i=t.getPointCount(),r=t.getImpl().getAttributeStreamRef(0);let h=0;for(let e=0;e<i;e++){const i=r.readPoint2D(2*e);_.contains(i)||(0===h&&(s=t.createInstance()),h<e&&s.addPoints(t,h,e),h=e+1)}return h>0&&s.addPoints(t,h,i),0===h?t:(n(null!==s),s)}case t.enumPolygon:case t.enumPolyline:return P(e,_,u,p,c);default:r("")}}function d(e,t,s,i,n,r){const h=new E(t,r),m=new a;return e.queryLooseEnvelope(m),t.containsEnvelope(m)?e:t.isIntersecting(m)?h.clipPolesOut(e,n):e.createInstance()}function P(e,t,s,i,n){return new E(t,n).clipMultiPath2(e,s,i)}class E{constructor(e,t){this.m_shape=new o,this.m_geometry=x,this.m_verticesOnExtentIndex=-1,this.m_verticesOnExtent=[],this.m_progressCounter=0,this.m_extent=new a(e),this.m_progressTracker=t}progress_(){}clipMultiPath2(e,s,i){return e.getGeometryType()===t.enumPolygon?this.clipPolygonOrProjectedPolyline2(e,i):this.clipPolyline(e,s)}clipPolygonOrProjectedPolyline2(e,s){const i=e.getGeometryType()===t.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return e.createInstance();const r=a.constructEmpty();e.queryLooseEnvelope(r),this.m_geometry=i?this.m_shape.addGeometry(e):this.m_shape.addGeometry(e,this.m_extent);const h=a.constructEmpty(),m=a.constructEmpty(),o=new u,c=new u,g=l(9,Number.NaN),y=l(9,Number.NaN),f=_(u,9);let v=null;const d=new p,P=[];let I=!1;for(let t=0;!I&&t<4;t++){let e=!1;const s=!!(1&t);let a=0;switch(t){case 0:a=this.m_extent.xmin,e=r.xmin<=a&&r.xmax>=a;break;case 1:a=this.m_extent.ymin,e=r.ymin<=a&&r.ymax>=a;break;case 2:a=this.m_extent.xmax,e=r.xmin<=a&&r.xmax>=a;break;case 3:a=this.m_extent.ymax,e=r.ymin<=a&&r.ymax>=a}if(e){I=!0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==x;){let r=!0,p=-1,l=-1;const _=this.m_shape.getFirstVertex(e);let u=_;do{this.progress_(),v=this.m_shape.getSegment(u);let e=v;if(null===e){const t=this.m_shape.getNextVertex(u);if(t===x){n(i),0===p&&P.push(u);break}this.m_shape.queryXY(u,o),d.setStartXY(o),this.m_shape.queryXY(t,c),d.setEndXY(c),e=d}e.queryLooseEnvelope(h);let _=E.checkSegmentIntersection(h,t,a);e.isCurve()&&0===_&&e.isCurve()&&(d.setStartXY(e.getStartXY()),d.setEndXY(e.getEndXY()),this.m_shape.replaceCurveWithLine(u),e=d,d.queryEnvelope(h),_=E.checkSegmentIntersection(h,t,a));let V=0,X=x;if(-1===_){const i=e.intersectionWithAxis2D(s,a,g,y);if(i>0){let t=null;if(e.isCurve()){t=f,n(i<=9);for(let e=0;e<i;e++)s?f[e].setCoords(g[e],a):f[e].setCoords(a,g[e]);V=this.m_shape.splitSegmentAxisAware(u,y,i,t,s?1:0)}else V=this.m_shape.splitSegmentAxisAware(u,y,i,null,-1)}else V=0;V+=1;let h=u,x=this.m_shape.getNextVertex(h);e=null;for(let e=0;e<V;e++){this.m_shape.queryXY(h,o),this.m_shape.queryXY(x,c),v=this.m_shape.getSegment(h);let e=v;null===e&&(d.setStartXY(o),d.setEndXY(c),e=d),e.queryEnvelope(m);let i=E.checkSegmentIntersection(m,t,a);if(e.isCurve()&&0===i&&(this.m_shape.replaceCurveWithLine(h),d.setStartXY(o),d.setEndXY(c),e=d,e.queryEnvelope(m),i=E.checkSegmentIntersection(m,t,a)),-1===i){if(s){Math.abs(o.y-a)<Math.abs(c.y-a)?(o.y=a,this.m_shape.setXY(h,o)):(c.y=a,this.m_shape.setXY(x,c))}else{Math.abs(o.x-a)<Math.abs(c.x-a)?(o.x=a,this.m_shape.setXY(h,o)):(c.x=a,this.m_shape.setXY(x,c))}v=this.m_shape.getSegment(h),e=v,null===e&&(d.setStartXY(o),d.setEndXY(c),e=d),e.queryEnvelope(m),i=E.checkSegmentIntersection(m,t,a),-1===i&&(i=E.checkSegmentIntersectionLoose(m,t,a))}const n=p;p=i,-1===l&&(l=p),0===n&&1===p||1===n&&0===p||0===n&&0===p&&P.push(h),1===p&&(I=!1,r=!1),h=x,X=h,x=this.m_shape.getNextVertex(x)}}if(0===V){const e=p;p=_,-1===l&&(l=p),0===e&&p>=1||e>=1&&0===p||0===e&&0===p&&P.push(u),1===p&&(I=!1,r=!1),X=this.m_shape.getNextVertex(u)}if(u=X,P.length>=256){for(let e=1,t=P.length-1;e<t;e++){const t=P[e];i?this.m_shape.snapVertexForPoleClipping(t,a):this.m_shape.removeVertex(t,!1)}P[1]=P.at(-1),P.length=2}}while(u!==_);if(!r){0!==l||!i&&0!==p&&2!==p||P.push(_);for(let e=0,t=P.length;e<t;e++){const t=P[e];i?this.m_shape.snapVertexForPoleClipping(t,a):this.m_shape.removeVertex(t,!1)}}P.length=0,e=r||0===this.m_shape.getPathSize(e)?this.m_shape.removePath(e):this.m_shape.getNextPath(e)}}}if(I)return e.createInstance();v=null,i?this.removeSpikesAlongPoles():this.resolveBoundaryOverlaps(),s>0&&this.densifyAlongClipExtent(s);const V=this.m_shape.getGeometry(this.m_geometry);if(V.getGeometryType()===t.enumPolygon){V.setFillRule(e.getFillRule())}return V}clipPolyline(e,t){const s=a.constructEmpty(),i=a.constructEmpty(),n=l(9,Number.NaN),r=l(9,Number.NaN),h=new c;let m=e;const o=a.constructEmpty();e.queryLooseEnvelope(o);for(let a=0;a<4;a++){let t=!1;const x=!!(1&a);let p=0;switch(a){case 0:p=this.m_extent.xmin,t=o.xmin<=p&&o.xmax>=p;break;case 1:p=this.m_extent.ymin,t=o.ymin<=p&&o.ymax>=p;break;case 2:p=this.m_extent.xmax,t=o.xmin<=p&&o.xmax>=p;break;case 3:p=this.m_extent.ymax,t=o.ymin<=p&&o.ymax>=p}if(!t)continue;const c=m;m=e.createInstance();const l=c.getImpl().querySegmentIterator();l.resetToFirstPath();const _=new u,g=new u;for(;l.nextPath();){let e=-1,t=!0;for(;l.hasNextSegment();){this.progress_();const o=l.nextSegment(),c=o.isDegenerate(0);o.queryLooseEnvelope(s);const u=E.checkSegmentIntersection(s,a,p);if(-1===u){const s=o.intersectionWithAxis2D(x,p,n,r);let l=0;_.assign(o.getStartXY());for(let u=0;u<=s;u++){const y=u<s?r[u]:1;if(l===y)continue;o.queryCut(l,y,h,!1);const f=h.get();let v=!1;if(f.getStartXY().equals(_)||(f.setStartXY(_),v=!0),u<s&&(x?(g.x=n[u],g.y=p):(g.x=p,g.y=n[u]),f.getEndXY().equals(g)||(f.setEndXY(g),v=!0)),v&&f.normalizeAfterEndpointChange(),!c&&f.isDegenerate(0))continue;f.queryEnvelope(i);let d=E.checkSegmentIntersection(i,a,p);if(-1===d){const e=f.getStartXY(),t=f.getEndXY();if(v=!1,x){Math.abs(e.y-p)<Math.abs(t.y-p)?(e.y=p,f.setStartXY(e),e.equals(f.getStartXY())||(f.setStartXY(e),v=!0)):(t.y=p,t.equals(f.getEndXY())||(f.setEndXY(t),v=!0))}else{Math.abs(e.x-p)<Math.abs(t.x-p)?(e.x=p,e.equals(f.getStartXY())||(f.setStartXY(e),v=!0)):(t.x=p,t.equals(f.getEndXY())||(f.setEndXY(t),v=!0))}v&&f.normalizeAfterEndpointChange(),f.queryEnvelope(i),d=E.checkSegmentIntersection(i,a,p),-1===d&&(d=E.checkSegmentIntersectionLoose(i,a,p))}_.assign(f.getEndXY()),l=y,e=d,e>=1?(m.addSegment(f,t),t=!1):t=!0}}else e=u,e>=1?(m.addSegment(o,t),t=!1):t=!0}}}return m}static checkSegmentIntersection(e,t,s){switch(t){case 0:return e.xmin<s&&e.xmax<=s?0:e.xmin>=s?e.xmax===s?2:1:-1;case 1:return e.ymin<s&&e.ymax<=s?0:e.ymin>=s?e.ymax===s?2:1:-1;case 2:return e.xmin>=s&&e.xmax>s?0:e.xmax<=s?e.xmin===s?2:1:-1;case 3:return e.ymin>=s&&e.ymax>s?0:e.ymax<=s?e.ymin===s?2:1:-1}return r(""),0}static checkSegmentIntersectionLoose(e,t,s){switch(t){case 0:{const t=Math.abs(e.xmin-s),i=Math.abs(e.xmax-s);return e.xmin<s?t>i?0:1:(r(""),1)}case 1:{const t=Math.abs(e.ymin-s),i=Math.abs(e.ymax-s);return e.ymin<s?t>i?0:1:(r(""),1)}case 2:{const t=Math.abs(e.xmin-s),i=Math.abs(e.xmax-s);return e.xmax>s?t<i?0:1:(r(""),1)}case 3:{const t=Math.abs(e.ymin-s),i=Math.abs(e.ymax-s);return e.ymax>s?t<i?0:1:(r(""),1)}}return r(""),0}resolveBoundaryOverlaps(){this.m_verticesOnExtentIndex=-1,this.splitSegments(!1,this.m_extent.xmin),this.splitSegments(!1,this.m_extent.xmax),this.splitSegments(!0,this.m_extent.ymin),this.splitSegments(!0,this.m_extent.ymax),this.m_verticesOnExtent.length=0,this.m_verticesOnExtentIndex=this.m_shape.createUserIndex();const e=new u;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==x;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let i=0,n=this.m_shape.getPathSize(t);i<n;i++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,e),this.m_extent.xmin!==e.x&&this.m_extent.xmax!==e.x&&this.m_extent.ymin!==e.y&&this.m_extent.ymax!==e.y||(this.m_shape.setUserIndex(s,this.m_verticesOnExtentIndex,this.m_verticesOnExtent.length),this.m_verticesOnExtent.push(s))}this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmin),this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmax),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymin),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymax),this.fixPaths()}densifyAlongClipExtent(e){const t=new u(0,0),s=new u(0,0),i=l(2048,Number.NaN);for(let h=this.m_shape.getFirstPath(this.m_geometry);h!==x;h=this.m_shape.getNextPath(h)){const m=this.m_shape.getFirstVertex(h);let a=m;do{const h=this.m_shape.getNextVertex(a);this.m_shape.queryXY(a,t);let m=-1;if(t.x===this.m_extent.xmin?(this.m_shape.queryXY(h,s),s.x===this.m_extent.xmin&&(m=1)):t.x===this.m_extent.xmax&&(this.m_shape.queryXY(h,s),s.x===this.m_extent.xmax&&(m=1)),t.y===this.m_extent.ymin?(this.m_shape.queryXY(h,s),s.y===this.m_extent.ymin&&(m=0)):t.y===this.m_extent.ymax&&(this.m_shape.queryXY(h,s),s.y===this.m_extent.ymax&&(m=0)),-1===m){a=h;continue}if(this.isCurve(a)){a=h;continue}const o=t.clone(),x=new u(0,0);if(m){const i=t.y-this.m_extent.ymin;x.y=g(s.y-t.y),o.y=e*y(Math.floor(Math.abs(i)/e),i)+this.m_extent.ymin,x.y<0&&(o.y+=e)}else{const i=t.x-this.m_extent.xmin;x.x=g(s.x-t.x),o.x=e*y(Math.floor(Math.abs(i)/e),i)+this.m_extent.xmin,x.x<0&&(o.x+=e)}const p=m?s.y-t.y:s.x-t.x,c=Math.abs(p);if(c/e>65536&&r(""),c>0){const s=Math.trunc(c/e)+2;i.length<s&&(i.length=s);let r=0;for(let h=0;;h++){const s=o.add(x.mul(h*e)),a=(m?s.y-t.y:s.x-t.x)/p;if(a>=1)break;a<=0||(n(r<=i.length),i[r]=a,r++)}0!==r&&this.m_shape.splitSegment(a,i,r)}a=h}while(a!==m)}}splitSegments(e,t){let s=-1;const i=new u,n=[];for(let _=this.m_shape.getFirstPath(this.m_geometry);_!==x;_=this.m_shape.getNextPath(_)){let r=this.m_shape.getFirstVertex(_),h=x;for(let m=0,a=this.m_shape.getPathSize(_);m<a;m++,r=h)if(this.progress_(),h=this.m_shape.getNextVertex(r),this.m_shape.queryXY(r,i),(e?i.y===t:i.x===t)&&(this.m_shape.queryXY(h,i),e?i.y===t:i.x===t)){if(this.isCurve(r))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(r,s)&&(n.push(r),this.m_shape.setUserIndex(r,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(n.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),n.length<3)return;n.sort(((e,t)=>this.compareVertices(e,t)));const r=new u,h=new u,m=new u;h.setNAN();let a=-1;let o=[],p=[];const c=this.m_shape.createUserIndex(),l=this.m_shape.createUserIndex();for(let x=0,_=n.length;x<_;x++){const s=n[x];if(this.m_shape.queryXY(s,i),!i.isEqualPoint2D(h)){if(-1===a){a=x,h.setCoordsPoint2D(i);continue}for(let i=a;i<x;i++){const s=n[i],m=this.m_shape.getNextVertex(s),a=this.m_shape.getPrevVertex(s);let x=!1;this.m_shape.queryXY(m,r),h.compare(r)<0&&(e?r.y===t:r.x===t)&&(this.isCurve(s)||(o.push(s),x=!0,this.m_shape.setUserIndex(s,l,1))),this.m_shape.queryXY(a,r),h.compare(r)<0&&(e?r.y===t:r.x===t)&&(this.isCurve(a)||(x||o.push(s),this.m_shape.setUserIndex(s,c,1)))}for(let e=0,t=o.length;e<t;e++){const t=o[e],s=this.m_shape.getUserIndex(t,c),n=this.m_shape.getUserIndex(t,l);if(1===s){const e=this.m_shape.getPrevVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(i)){const n=u.distance(h,m);s=u.distance(m,i)/n,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const r=this.m_shape.getPrevVertex(t);this.m_shape.setXY(r,i),p.push(r),this.m_shape.setUserIndex(r,c,1),this.m_shape.setUserIndex(r,l,-1)}}if(1===n){const e=this.m_shape.getNextVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(i)){const e=u.distance(h,m);s=u.distance(h,i)/e,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(t,[s],1);const n=this.m_shape.getNextVertex(t);this.m_shape.setXY(n,i),p.push(n),this.m_shape.setUserIndex(n,c,-1),this.m_shape.setUserIndex(n,l,1)}}}const s=o;o=p,p=s,p.length=0,a=x,h.setCoordsPoint2D(i)}}this.m_shape.removeUserIndex(c),this.m_shape.removeUserIndex(l)}resolveOverlaps(e,t){const s=new u,i=[];let r=-1;for(let n=0,o=this.m_verticesOnExtent.length;n<o;n++){this.progress_();const h=this.m_verticesOnExtent[n];if(h===x)continue;const m=this.m_shape.getNextVertex(h);if(this.m_shape.queryXY(h,s),(e?s.y===t:s.x===t)&&(this.m_shape.queryXY(m,s),e?s.y===t:s.x===t)){if(this.isCurve(h))continue;-1===r&&(r=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(h,r)&&(i.push(h),this.m_shape.setUserIndex(h,r,-2)),-2!==this.m_shape.getUserIndex(m,r)&&(i.push(m),this.m_shape.setUserIndex(m,r,-2))}}if(0===i.length)return void(-1!==r&&this.m_shape.removeUserIndex(r));n(-1!==r),i.sort(((e,t)=>this.compareVertices(e,t)));for(let n=0,o=i.length;n<o;n++){const e=i[n];this.m_shape.setUserIndex(e,r,n)}const h=new u,m=new u;m.setNAN();let a=-1;for(let n=0,o=i.length;n<o;n++){this.progress_();const o=i[n];if(o!==x&&(this.m_shape.queryXY(o,s),!s.isEqualPoint2D(m))){if(-1!==a)for(;;){let s=!1;const o=n;for(let p=a;p<o;p++){const a=i[p];if(a===x)continue;let o=x;const c=this.m_shape.getNextVertex(a);this.m_shape.queryXY(c,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(a)||(o=c));let l=x;const _=this.m_shape.getPrevVertex(a);if(this.m_shape.queryXY(_,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(_)||(l=_)),o===x||l===x){if(o!==x||l!==x){for(let c=p+1;c<n;c++){const n=i[c];if(n===x)continue;const p=this.m_shape.getNextVertex(n);let _=x;this.m_shape.queryXY(p,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(n)||(_=p));const u=this.m_shape.getPrevVertex(n);let g=x;if(this.m_shape.queryXY(u,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(u)||(g=u)),_!==x&&g!==x){this.beforeRemoveVertex(n,i,r),this.m_shape.removeVertex(n,!1),this.beforeRemoveVertex(_,i,r),this.m_shape.removeVertex(_,!1),s=!0;break}if(o!==x&&g!==x){this.removeOverlap(i,a,o,n,g,r),s=!0;break}if(l!==x&&_!==x){this.removeOverlap(i,n,_,a,l,r),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(a,i,r),this.m_shape.removeVertex(a,!1),this.beforeRemoveVertex(o,i,r),this.m_shape.removeVertex(o,!1),s=!0}if(!s)break}a=n,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(r)}beforeRemoveVertex(e,t,s){let i=this.m_shape.getUserIndex(e,s);n(i>=0),t[i]=x,i=this.m_shape.getUserIndex(e,this.m_verticesOnExtentIndex),n(i>=0),this.m_verticesOnExtent[i]=x;const r=this.m_shape.getPathFromVertex(e);if(r!==x){this.m_shape.getFirstVertex(r)===e&&(this.m_shape.setFirstVertex(r,x),this.m_shape.setLastVertex(r,x))}}removeOverlap(e,t,s,i,n,r){this.m_shape.setNextVertex(t,i),this.m_shape.setPrevVertex(i,t),this.m_shape.setPrevVertex(s,n),this.m_shape.setNextVertex(n,s),this.beforeRemoveVertex(i,e,r),this.m_shape.removeVertexInternal(i,!1),this.beforeRemoveVertex(n,e,r),this.m_shape.removeVertexInternal(n,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(e){for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==x;t=this.m_shape.getNextPath(t)){const s=this.m_shape.getPathSize(t);if(s<3)continue;let i=this.m_shape.getFirstVertex(t);const n=new u;this.m_shape.queryXY(i,n);let r=n.y===e&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const h=new u;this.m_shape.queryXY(i,h);let m=h.y===e&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const a=new u;for(let t=0,o=s-2;t<o;t++,i=this.m_shape.getNextVertex(i)){this.progress_(),this.m_shape.queryXY(i,a);const t=a.y===e;if(m&&r&&t){if((h.x-n.x)*(a.x-h.x)<=0){this.m_shape.removeVertex(this.m_shape.getPrevVertex(i),!1),h.setCoordsPoint2D(a),m=t&&!this.isCurve(i);continue}}n.setCoordsPoint2D(h),r=m,h.setCoordsPoint2D(a),m=t&&!this.isCurve(i)}}}fixPaths(){for(let n=0,r=this.m_verticesOnExtent.length;n<r;n++){const e=this.m_verticesOnExtent[n];e!==x&&this.m_shape.setPathToVertex(e,x)}const e=this.m_shape.hasCurves();let t=0,s=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==x;){const e=this.m_shape.getFirstVertex(n);if(e===x||n!==this.m_shape.getPathFromVertex(e)){const e=n;n=this.m_shape.getNextPath(n),this.m_shape.setFirstVertex(e,x),this.m_shape.removePathOnly(e);continue}let i=e,r=0;do{this.m_shape.setPathToVertex(i,n),r++,i=this.m_shape.getNextVertex(i)}while(i!==e);this.m_shape.setRingAreaValid(n,!1),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(e)),this.m_shape.setPathSize(n,r),s+=r,t++,n=this.m_shape.getNextPath(n)}for(let r=0,h=this.m_verticesOnExtent.length;r<h;r++){let i=this.m_verticesOnExtent[r];if(i===x)continue;let h=this.m_shape.getPathFromVertex(i);if(h!==x)continue;h=this.m_shape.insertPath(this.m_geometry,x);let m=!1,a=0;const o=i;do{this.m_shape.setPathToVertex(i,h),a++,e&&a<=2&&(m||=this.isCurve(i)),i=this.m_shape.getNextVertex(i)}while(i!==o);if(m?0===a:a<=2){let e=this.m_shape.getUserIndex(o,this.m_verticesOnExtentIndex);n(e>=0),this.m_verticesOnExtent[e]=x;const t=this.m_shape.removeVertex(o,!1);2===a&&(e=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),e>=0&&(this.m_verticesOnExtent[e]=x),this.m_shape.removeVertex(t,!1));const s=h;h=this.m_shape.getNextPath(h),this.m_shape.setFirstVertex(s,x),this.m_shape.removePathOnly(s)}else this.m_shape.setClosedPath(h,!0),this.m_shape.setPathSize(h,a),this.m_shape.setFirstVertex(h,o),this.m_shape.setLastVertex(h,this.m_shape.getPrevVertex(o)),this.m_shape.setRingAreaValid(h,!1),s+=a,t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let i=0;for(let n=this.m_shape.getFirstGeometry();n!==x;n=this.m_shape.getNextGeometry(n))i+=this.m_shape.getPointCount(n);this.m_shape.setTotalPointCount(i)}dbgCheckPathFirst(){}isCurve(e){return null!==this.m_shape.getSegment(e)}compareVertices(e,t){const s=new u;this.m_shape.queryXY(e,s);const i=new u;this.m_shape.queryXY(t,i);return s.compare(i)}clipPolesOut(e,t){return this.clipPolygonOrProjectedPolyline2(e,t)}}class I{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,i){return new V(e,t,s,i)}execute(e,t,s,i){return X(e,t,s,i)}}class V extends e{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,e||i(""),this.m_envelope=t,this.m_inputGeometryCursor=e,this.m_spatialRefImpl=s,this.m_tolerance=m(s,t,!1).total()}next(){let e;return(e=this.m_inputGeometryCursor.next())?(h(e),this.m_index=this.m_inputGeometryCursor.getGeometryID(),f(e,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function X(e,t,s,i){return v(e,t,s,Number.NaN,0,i)}export{I as O,d as a,f as c};
|
|
5
|
+
import{G as e}from"./SimpleGeometryCursor.js";import{G as t,i as s,a as i,g as n,c as r,d as h}from"./Geometry.js";import{c as m}from"./Envelope.js";import{Envelope2D as a}from"./Envelope2D.js";import{E as o,n as x,L as p,S as c}from"./QuadraticBezier.js";import{d as l,m as _,P as u,e as g,f as y}from"./Point2D.js";function f(e,t,s,i,n){return v(e,t,null,s,i,n)}function v(e,h,o,x,p,c){const l=e.getGeometryType();if(l===t.enumPoint){const t=e.getXY();return h.contains(t)?e:e.createInstance()}if(l===t.enumEnvelope){const t=a.constructEmpty();if(e.queryEnvelope(t),t.intersect(h)){const s=e.clone();return s.setEnvelope(t),s}return e.createInstance()}if(e.isEmpty())return e;if(h.isEmpty())return e.createInstance();const _=h.clone();{const t=new a;if(e.queryLooseEnvelope(t),_.containsEnvelope(t))return e;if(!_.isIntersecting(t))return e.createInstance();0===p&&(t.intersect(_),t.inflate(Math.max(.1*t.maxDimension(),1)),t.intersect(_),_.assign(t))}let u=x;if((null!==o||Number.isNaN(u))&&(u=m(o,_,!1).total()),l===t.enumGeometryCollection){const t=e,s=e.createInstance();for(let e=0,i=t.getGeometryCount();e<i;e++){const i=t.getGeometry(e);if(i.isEmpty())continue;const n=f(i,_,u,p,c);n.isEmpty()||(n===i?s.addGeometry(n.clone()):s.addGeometry(n))}return s}s(l)||i("Clip: geometry not supported");const g=e.getImpl().getAccelerators();if(null!==g){const e=g.getRasterizedGeometry();n(null===e)}switch(l){case t.enumMultiPoint:{const t=e;let s;const i=t.getPointCount(),r=t.getImpl().getAttributeStreamRef(0);let h=0;for(let e=0;e<i;e++){const i=r.readPoint2D(2*e);_.contains(i)||(0===h&&(s=t.createInstance()),h<e&&s.addPoints(t,h,e),h=e+1)}return h>0&&s.addPoints(t,h,i),0===h?t:(n(null!==s),s)}case t.enumPolygon:case t.enumPolyline:return P(e,_,u,p,c);default:r("")}}function d(e,t,s,i,n,r){const h=new E(t,r),m=new a;return e.queryLooseEnvelope(m),t.containsEnvelope(m)?e:t.isIntersecting(m)?h.clipPolesOut(e,n):e.createInstance()}function P(e,t,s,i,n){return new E(t,n).clipMultiPath2(e,s,i)}class E{constructor(e,t){this.m_shape=new o,this.m_geometry=x,this.m_verticesOnExtentIndex=-1,this.m_verticesOnExtent=[],this.m_progressCounter=0,this.m_extent=new a(e),this.m_progressTracker=t}progress_(){}clipMultiPath2(e,s,i){return e.getGeometryType()===t.enumPolygon?this.clipPolygonOrProjectedPolyline2(e,i):this.clipPolyline(e,s)}clipPolygonOrProjectedPolyline2(e,s){const i=e.getGeometryType()===t.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return e.createInstance();const r=a.constructEmpty();e.queryLooseEnvelope(r),this.m_geometry=i?this.m_shape.addGeometry(e):this.m_shape.addGeometry(e,this.m_extent);const h=a.constructEmpty(),m=a.constructEmpty(),o=new u,c=new u,g=l(9,Number.NaN),y=l(9,Number.NaN),f=_(u,9);let v=null;const d=new p,P=[];let I=!1;for(let t=0;!I&&t<4;t++){let e=!1;const s=!!(1&t);let a=0;switch(t){case 0:a=this.m_extent.xmin,e=r.xmin<=a&&r.xmax>=a;break;case 1:a=this.m_extent.ymin,e=r.ymin<=a&&r.ymax>=a;break;case 2:a=this.m_extent.xmax,e=r.xmin<=a&&r.xmax>=a;break;case 3:a=this.m_extent.ymax,e=r.ymin<=a&&r.ymax>=a}if(e){I=!0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==x;){let r=!0,p=-1,l=-1;const _=this.m_shape.getFirstVertex(e);let u=_;do{this.progress_(),v=this.m_shape.getSegment(u);let e=v;if(null===e){const t=this.m_shape.getNextVertex(u);if(t===x){n(i),0===p&&P.push(u);break}this.m_shape.queryXY(u,o),d.setStartXY(o),this.m_shape.queryXY(t,c),d.setEndXY(c),e=d}e.queryLooseEnvelope(h);let _=E.checkSegmentIntersection(h,t,a);e.isCurve()&&0===_&&e.isCurve()&&(d.setStartXY(e.getStartXY()),d.setEndXY(e.getEndXY()),this.m_shape.replaceCurveWithLine(u),e=d,d.queryEnvelope(h),_=E.checkSegmentIntersection(h,t,a));let V=0,X=x;if(-1===_){const i=e.intersectionWithAxis2D(s,a,g,y);if(i>0){let t=null;if(e.isCurve()){t=f,n(i<=9);for(let e=0;e<i;e++)s?f[e].setCoords(g[e],a):f[e].setCoords(a,g[e]);V=this.m_shape.splitSegmentAxisAware(u,y,i,t,s?1:0)}else V=this.m_shape.splitSegmentAxisAware(u,y,i,null,-1)}else V=0;V+=1;let h=u,x=this.m_shape.getNextVertex(h);e=null;for(let e=0;e<V;e++){this.m_shape.queryXY(h,o),this.m_shape.queryXY(x,c),v=this.m_shape.getSegment(h);let e=v;null===e&&(d.setStartXY(o),d.setEndXY(c),e=d),e.queryEnvelope(m);let i=E.checkSegmentIntersection(m,t,a);if(e.isCurve()&&0===i&&(this.m_shape.replaceCurveWithLine(h),d.setStartXY(o),d.setEndXY(c),e=d,e.queryEnvelope(m),i=E.checkSegmentIntersection(m,t,a)),-1===i){if(s){Math.abs(o.y-a)<Math.abs(c.y-a)?(o.y=a,this.m_shape.setXY(h,o)):(c.y=a,this.m_shape.setXY(x,c))}else{Math.abs(o.x-a)<Math.abs(c.x-a)?(o.x=a,this.m_shape.setXY(h,o)):(c.x=a,this.m_shape.setXY(x,c))}v=this.m_shape.getSegment(h),e=v,null===e&&(d.setStartXY(o),d.setEndXY(c),e=d),e.queryEnvelope(m),i=E.checkSegmentIntersection(m,t,a),-1===i&&(i=E.checkSegmentIntersectionLoose(m,t,a))}const n=p;p=i,-1===l&&(l=p),0===n&&1===p||1===n&&0===p||0===n&&0===p&&P.push(h),1===p&&(I=!1,r=!1),h=x,X=h,x=this.m_shape.getNextVertex(x)}}if(0===V){const e=p;p=_,-1===l&&(l=p),0===e&&p>=1||e>=1&&0===p||0===e&&0===p&&P.push(u),1===p&&(I=!1,r=!1),X=this.m_shape.getNextVertex(u)}if(u=X,P.length>=256){for(let e=1,t=P.length-1;e<t;e++){const t=P[e];i?this.m_shape.snapVertexForPoleClipping(t,a):this.m_shape.removeVertex(t,!1)}P[1]=P.at(-1),P.length=2}}while(u!==_);if(!r){0!==l||!i&&0!==p&&2!==p||P.push(_);for(let e=0,t=P.length;e<t;e++){const t=P[e];i?this.m_shape.snapVertexForPoleClipping(t,a):this.m_shape.removeVertex(t,!1)}}P.length=0,e=r||0===this.m_shape.getPathSize(e)?this.m_shape.removePath(e):this.m_shape.getNextPath(e)}}}if(I)return e.createInstance();v=null,i?this.removeSpikesAlongPoles():this.resolveBoundaryOverlaps(),s>0&&this.densifyAlongClipExtent(s);const V=this.m_shape.getGeometry(this.m_geometry);if(V.getGeometryType()===t.enumPolygon){V.setFillRule(e.getFillRule())}return V}clipPolyline(e,t){const s=a.constructEmpty(),i=a.constructEmpty(),n=l(9,Number.NaN),r=l(9,Number.NaN),h=new c;let m=e;const o=a.constructEmpty();e.queryLooseEnvelope(o);for(let a=0;a<4;a++){let t=!1;const x=!!(1&a);let p=0;switch(a){case 0:p=this.m_extent.xmin,t=o.xmin<=p&&o.xmax>=p;break;case 1:p=this.m_extent.ymin,t=o.ymin<=p&&o.ymax>=p;break;case 2:p=this.m_extent.xmax,t=o.xmin<=p&&o.xmax>=p;break;case 3:p=this.m_extent.ymax,t=o.ymin<=p&&o.ymax>=p}if(!t)continue;const c=m;m=e.createInstance();const l=c.getImpl().querySegmentIterator();l.resetToFirstPath();const _=new u,g=new u;for(;l.nextPath();){let e=-1,t=!0;for(;l.hasNextSegment();){this.progress_();const o=l.nextSegment(),c=o.isDegenerate(0);o.queryLooseEnvelope(s);const u=E.checkSegmentIntersection(s,a,p);if(-1===u){const s=o.intersectionWithAxis2D(x,p,n,r);let l=0;_.assign(o.getStartXY());for(let u=0;u<=s;u++){const y=u<s?r[u]:1;if(l===y)continue;o.queryCut(l,y,h,!1);const f=h.get();let v=!1;if(f.getStartXY().equals(_)||(f.setStartXY(_),v=!0),u<s&&(x?(g.x=n[u],g.y=p):(g.x=p,g.y=n[u]),f.getEndXY().equals(g)||(f.setEndXY(g),v=!0)),v&&f.normalizeAfterEndpointChange(),!c&&f.isDegenerate(0))continue;f.queryEnvelope(i);let d=E.checkSegmentIntersection(i,a,p);if(-1===d){const e=f.getStartXY(),t=f.getEndXY();if(v=!1,x){Math.abs(e.y-p)<Math.abs(t.y-p)?(e.y=p,f.setStartXY(e),e.equals(f.getStartXY())||(f.setStartXY(e),v=!0)):(t.y=p,t.equals(f.getEndXY())||(f.setEndXY(t),v=!0))}else{Math.abs(e.x-p)<Math.abs(t.x-p)?(e.x=p,e.equals(f.getStartXY())||(f.setStartXY(e),v=!0)):(t.x=p,t.equals(f.getEndXY())||(f.setEndXY(t),v=!0))}v&&f.normalizeAfterEndpointChange(),f.queryEnvelope(i),d=E.checkSegmentIntersection(i,a,p),-1===d&&(d=E.checkSegmentIntersectionLoose(i,a,p))}_.assign(f.getEndXY()),l=y,e=d,e>=1?(m.addSegment(f,t),t=!1):t=!0}}else e=u,e>=1?(m.addSegment(o,t),t=!1):t=!0}}}return m}static checkSegmentIntersection(e,t,s){switch(t){case 0:return e.xmin<s&&e.xmax<=s?0:e.xmin>=s?e.xmax===s?2:1:-1;case 1:return e.ymin<s&&e.ymax<=s?0:e.ymin>=s?e.ymax===s?2:1:-1;case 2:return e.xmin>=s&&e.xmax>s?0:e.xmax<=s?e.xmin===s?2:1:-1;case 3:return e.ymin>=s&&e.ymax>s?0:e.ymax<=s?e.ymin===s?2:1:-1}return r(""),0}static checkSegmentIntersectionLoose(e,t,s){switch(t){case 0:{const t=Math.abs(e.xmin-s),i=Math.abs(e.xmax-s);return e.xmin<s?t>i?0:1:(r(""),1)}case 1:{const t=Math.abs(e.ymin-s),i=Math.abs(e.ymax-s);return e.ymin<s?t>i?0:1:(r(""),1)}case 2:{const t=Math.abs(e.xmin-s),i=Math.abs(e.xmax-s);return e.xmax>s?t<i?0:1:(r(""),1)}case 3:{const t=Math.abs(e.ymin-s),i=Math.abs(e.ymax-s);return e.ymax>s?t<i?0:1:(r(""),1)}}return r(""),0}resolveBoundaryOverlaps(){this.m_verticesOnExtentIndex=-1,this.splitSegments(!1,this.m_extent.xmin),this.splitSegments(!1,this.m_extent.xmax),this.splitSegments(!0,this.m_extent.ymin),this.splitSegments(!0,this.m_extent.ymax),this.m_verticesOnExtent.length=0,this.m_verticesOnExtentIndex=this.m_shape.createUserIndex();const e=new u;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==x;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let i=0,n=this.m_shape.getPathSize(t);i<n;i++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,e),this.m_extent.xmin!==e.x&&this.m_extent.xmax!==e.x&&this.m_extent.ymin!==e.y&&this.m_extent.ymax!==e.y||(this.m_shape.setUserIndex(s,this.m_verticesOnExtentIndex,this.m_verticesOnExtent.length),this.m_verticesOnExtent.push(s))}this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmin),this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmax),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymin),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymax),this.fixPaths()}densifyAlongClipExtent(e){const t=new u(0,0),s=new u(0,0),i=l(2048,Number.NaN);for(let h=this.m_shape.getFirstPath(this.m_geometry);h!==x;h=this.m_shape.getNextPath(h)){const m=this.m_shape.getFirstVertex(h);let a=m;do{const h=this.m_shape.getNextVertex(a);this.m_shape.queryXY(a,t);let m=-1;if(t.x===this.m_extent.xmin?(this.m_shape.queryXY(h,s),s.x===this.m_extent.xmin&&(m=1)):t.x===this.m_extent.xmax&&(this.m_shape.queryXY(h,s),s.x===this.m_extent.xmax&&(m=1)),t.y===this.m_extent.ymin?(this.m_shape.queryXY(h,s),s.y===this.m_extent.ymin&&(m=0)):t.y===this.m_extent.ymax&&(this.m_shape.queryXY(h,s),s.y===this.m_extent.ymax&&(m=0)),-1===m){a=h;continue}if(this.isCurve(a)){a=h;continue}const o=t.clone(),x=new u(0,0);if(m){const i=t.y-this.m_extent.ymin;x.y=g(s.y-t.y),o.y=e*y(Math.floor(Math.abs(i)/e),i)+this.m_extent.ymin,x.y<0&&(o.y+=e)}else{const i=t.x-this.m_extent.xmin;x.x=g(s.x-t.x),o.x=e*y(Math.floor(Math.abs(i)/e),i)+this.m_extent.xmin,x.x<0&&(o.x+=e)}const p=m?s.y-t.y:s.x-t.x,c=Math.abs(p);if(c/e>65536&&r(""),c>0){const s=Math.trunc(c/e)+2;i.length<s&&(i.length=s);let r=0;for(let h=0;;h++){const s=o.add(x.mul(h*e)),a=(m?s.y-t.y:s.x-t.x)/p;if(a>=1)break;a<=0||(n(r<=i.length),i[r]=a,r++)}0!==r&&this.m_shape.splitSegment(a,i,r)}a=h}while(a!==m)}}splitSegments(e,t){let s=-1;const i=new u,n=[];for(let _=this.m_shape.getFirstPath(this.m_geometry);_!==x;_=this.m_shape.getNextPath(_)){let r=this.m_shape.getFirstVertex(_),h=x;for(let m=0,a=this.m_shape.getPathSize(_);m<a;m++,r=h)if(this.progress_(),h=this.m_shape.getNextVertex(r),this.m_shape.queryXY(r,i),(e?i.y===t:i.x===t)&&(this.m_shape.queryXY(h,i),e?i.y===t:i.x===t)){if(this.isCurve(r))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(r,s)&&(n.push(r),this.m_shape.setUserIndex(r,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(n.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),n.length<3)return;n.sort(((e,t)=>this.compareVertices(e,t)));const r=new u,h=new u,m=new u;h.setNAN();let a=-1;let o=[],p=[];const c=this.m_shape.createUserIndex(),l=this.m_shape.createUserIndex();for(let x=0,_=n.length;x<_;x++){const s=n[x];if(this.m_shape.queryXY(s,i),!i.isEqualPoint2D(h)){if(-1===a){a=x,h.setCoordsPoint2D(i);continue}for(let i=a;i<x;i++){const s=n[i],m=this.m_shape.getNextVertex(s),a=this.m_shape.getPrevVertex(s);let x=!1;this.m_shape.queryXY(m,r),h.compare(r)<0&&(e?r.y===t:r.x===t)&&(this.isCurve(s)||(o.push(s),x=!0,this.m_shape.setUserIndex(s,l,1))),this.m_shape.queryXY(a,r),h.compare(r)<0&&(e?r.y===t:r.x===t)&&(this.isCurve(a)||(x||o.push(s),this.m_shape.setUserIndex(s,c,1)))}for(let e=0,t=o.length;e<t;e++){const t=o[e],s=this.m_shape.getUserIndex(t,c),n=this.m_shape.getUserIndex(t,l);if(1===s){const e=this.m_shape.getPrevVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(i)){const n=u.distance(h,m);s=u.distance(m,i)/n,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const r=this.m_shape.getPrevVertex(t);this.m_shape.setXY(r,i),p.push(r),this.m_shape.setUserIndex(r,c,1),this.m_shape.setUserIndex(r,l,-1)}}if(1===n){const e=this.m_shape.getNextVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(i)){const e=u.distance(h,m);s=u.distance(h,i)/e,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(t,[s],1);const n=this.m_shape.getNextVertex(t);this.m_shape.setXY(n,i),p.push(n),this.m_shape.setUserIndex(n,c,-1),this.m_shape.setUserIndex(n,l,1)}}}const s=o;o=p,p=s,p.length=0,a=x,h.setCoordsPoint2D(i)}}this.m_shape.removeUserIndex(c),this.m_shape.removeUserIndex(l)}resolveOverlaps(e,t){const s=new u,i=[];let r=-1;for(let n=0,o=this.m_verticesOnExtent.length;n<o;n++){this.progress_();const h=this.m_verticesOnExtent[n];if(h===x)continue;const m=this.m_shape.getNextVertex(h);if(this.m_shape.queryXY(h,s),(e?s.y===t:s.x===t)&&(this.m_shape.queryXY(m,s),e?s.y===t:s.x===t)){if(this.isCurve(h))continue;-1===r&&(r=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(h,r)&&(i.push(h),this.m_shape.setUserIndex(h,r,-2)),-2!==this.m_shape.getUserIndex(m,r)&&(i.push(m),this.m_shape.setUserIndex(m,r,-2))}}if(0===i.length)return void(-1!==r&&this.m_shape.removeUserIndex(r));n(-1!==r),i.sort(((e,t)=>this.compareVertices(e,t)));for(let n=0,o=i.length;n<o;n++){const e=i[n];this.m_shape.setUserIndex(e,r,n)}const h=new u,m=new u;m.setNAN();let a=-1;for(let n=0,o=i.length;n<o;n++){this.progress_();const o=i[n];if(o!==x&&(this.m_shape.queryXY(o,s),!s.isEqualPoint2D(m))){if(-1!==a)for(;;){let s=!1;const o=n;for(let p=a;p<o;p++){const a=i[p];if(a===x)continue;let o=x;const c=this.m_shape.getNextVertex(a);this.m_shape.queryXY(c,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(a)||(o=c));let l=x;const _=this.m_shape.getPrevVertex(a);if(this.m_shape.queryXY(_,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(_)||(l=_)),o===x||l===x){if(o!==x||l!==x){for(let c=p+1;c<n;c++){const n=i[c];if(n===x)continue;const p=this.m_shape.getNextVertex(n);let _=x;this.m_shape.queryXY(p,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(n)||(_=p));const u=this.m_shape.getPrevVertex(n);let g=x;if(this.m_shape.queryXY(u,h),m.compare(h)<0&&(e?h.y===t:h.x===t)&&(this.isCurve(u)||(g=u)),_!==x&&g!==x){this.beforeRemoveVertex(n,i,r),this.m_shape.removeVertex(n,!1),this.beforeRemoveVertex(_,i,r),this.m_shape.removeVertex(_,!1),s=!0;break}if(o!==x&&g!==x){this.removeOverlap(i,a,o,n,g,r),s=!0;break}if(l!==x&&_!==x){this.removeOverlap(i,n,_,a,l,r),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(a,i,r),this.m_shape.removeVertex(a,!1),this.beforeRemoveVertex(o,i,r),this.m_shape.removeVertex(o,!1),s=!0}if(!s)break}a=n,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(r)}beforeRemoveVertex(e,t,s){let i=this.m_shape.getUserIndex(e,s);n(i>=0),t[i]=x,i=this.m_shape.getUserIndex(e,this.m_verticesOnExtentIndex),n(i>=0),this.m_verticesOnExtent[i]=x;const r=this.m_shape.getPathFromVertex(e);if(r!==x){this.m_shape.getFirstVertex(r)===e&&(this.m_shape.setFirstVertex(r,x),this.m_shape.setLastVertex(r,x))}}removeOverlap(e,t,s,i,n,r){this.m_shape.setNextVertex(t,i),this.m_shape.setPrevVertex(i,t),this.m_shape.setPrevVertex(s,n),this.m_shape.setNextVertex(n,s),this.beforeRemoveVertex(i,e,r),this.m_shape.removeVertexInternal(i,!1),this.beforeRemoveVertex(n,e,r),this.m_shape.removeVertexInternal(n,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(e){for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==x;t=this.m_shape.getNextPath(t)){const s=this.m_shape.getPathSize(t);if(s<3)continue;let i=this.m_shape.getFirstVertex(t);const n=new u;this.m_shape.queryXY(i,n);let r=n.y===e&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const h=new u;this.m_shape.queryXY(i,h);let m=h.y===e&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const a=new u;for(let t=0,o=s-2;t<o;t++,i=this.m_shape.getNextVertex(i)){this.progress_(),this.m_shape.queryXY(i,a);const t=a.y===e;if(m&&r&&t){if((h.x-n.x)*(a.x-h.x)<=0){this.m_shape.removeVertex(this.m_shape.getPrevVertex(i),!1),h.setCoordsPoint2D(a),m=t&&!this.isCurve(i);continue}}n.setCoordsPoint2D(h),r=m,h.setCoordsPoint2D(a),m=t&&!this.isCurve(i)}}}fixPaths(){for(let n=0,r=this.m_verticesOnExtent.length;n<r;n++){const e=this.m_verticesOnExtent[n];e!==x&&this.m_shape.setPathToVertex(e,x)}const e=this.m_shape.hasCurves();let t=0,s=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==x;){const e=this.m_shape.getFirstVertex(n);if(e===x||n!==this.m_shape.getPathFromVertex(e)){const e=n;n=this.m_shape.getNextPath(n),this.m_shape.setFirstVertex(e,x),this.m_shape.removePathOnly(e);continue}let i=e,r=0;do{this.m_shape.setPathToVertex(i,n),r++,i=this.m_shape.getNextVertex(i)}while(i!==e);this.m_shape.setRingAreaValid(n,!1),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(e)),this.m_shape.setPathSize(n,r),s+=r,t++,n=this.m_shape.getNextPath(n)}for(let r=0,h=this.m_verticesOnExtent.length;r<h;r++){let i=this.m_verticesOnExtent[r];if(i===x)continue;let h=this.m_shape.getPathFromVertex(i);if(h!==x)continue;h=this.m_shape.insertPath(this.m_geometry,x);let m=!1,a=0;const o=i;do{this.m_shape.setPathToVertex(i,h),a++,e&&a<=2&&(m||=this.isCurve(i)),i=this.m_shape.getNextVertex(i)}while(i!==o);if(m?0===a:a<=2){let e=this.m_shape.getUserIndex(o,this.m_verticesOnExtentIndex);n(e>=0),this.m_verticesOnExtent[e]=x;const t=this.m_shape.removeVertex(o,!1);2===a&&(e=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),e>=0&&(this.m_verticesOnExtent[e]=x),this.m_shape.removeVertex(t,!1));const s=h;h=this.m_shape.getNextPath(h),this.m_shape.setFirstVertex(s,x),this.m_shape.removePathOnly(s)}else this.m_shape.setClosedPath(h,!0),this.m_shape.setPathSize(h,a),this.m_shape.setFirstVertex(h,o),this.m_shape.setLastVertex(h,this.m_shape.getPrevVertex(o)),this.m_shape.setRingAreaValid(h,!1),s+=a,t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let i=0;for(let n=this.m_shape.getFirstGeometry();n!==x;n=this.m_shape.getNextGeometry(n))i+=this.m_shape.getPointCount(n);this.m_shape.setTotalPointCount(i)}dbgCheckPathFirst(){}isCurve(e){return null!==this.m_shape.getSegment(e)}compareVertices(e,t){const s=new u;this.m_shape.queryXY(e,s);const i=new u;this.m_shape.queryXY(t,i);return s.compare(i)}clipPolesOut(e,t){return this.clipPolygonOrProjectedPolyline2(e,t)}}class I{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,i){return new V(e,t,s,i)}execute(e,t,s,i){return X(e,t,s,i)}}class V extends e{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,e||i(""),this.m_envelope=t,this.m_inputGeometryCursor=e,this.m_spatialRefImpl=s,this.m_tolerance=m(s,t,!1).total()}next(){let e;return(e=this.m_inputGeometryCursor.next())?(h(e),this.m_index=this.m_inputGeometryCursor.getGeometryID(),f(e,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function X(e,t,s,i){return v(e,t,s,Number.NaN,0,i)}export{I as O,d as a,f as c};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{e,r}from"./ProjectionTransformation.js";class t extends e{getOperatorType(){return 6}execute(e,t,o,s){return r(e,t,o,16,s)}}export{t as O};
|
package/chunks/OperatorCut.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{G as t}from"./SimpleGeometryCursor.js";import{G as e,c as s,g as r}from"./Geometry.js";import{P as n,a as o,E as m,n as i}from"./QuadraticBezier.js";import{g as
|
|
5
|
+
import{G as t}from"./SimpleGeometryCursor.js";import{G as e,c as s,g as r}from"./Geometry.js";import{P as n,a as o,E as m,n as i}from"./QuadraticBezier.js";import{g as c,c as u}from"./Envelope.js";import{T as a,s as h,k as l,l as d,m as y,C as p}from"./ProjectionTransformation.js";var _=p;function g(t,e){return{m_geometry:t,m_side:e}}function f(t,e,s,r,n,o){if(e.isEmpty()){const t=g(e,0);return void n.push(t)}if(s.isEmpty()){const t=g(e,0);return void n.push(t)}const i=[],c=new m;{const m=c.createGeometryUserIndex(),u=c.addGeometry(e),p=c.addGeometry(s),f=new a(o);let C=0,E=null;if(c.hasCurves()){E=new _;const t=c.getEnvelope2D(o);C=h(r.total());const e=l(r.total(),t);d(c,e,r.total(),12e3,E,null,o)}c.dbgVerifyCurves(),f.setEditShapeCrackAndCluster(c,r),f.cut(t,m,u,p,i);for(const t of i){null!==E&&E.stitchCurves(c,t,C,!1);const e=g(c.getGeometry(t),y(c.getGeometryUserIndex(t,m)));n.push(e)}null!==E&&E.clearStitcher(c)}}function C(t,e,s,r,n,c){if(e.isEmpty()){const t=g(e,0);return void n.push(t)}if(s.isEmpty()){const t=g(e,0);return void n.push(t)}const u=[],y=new m;{const t=y.createGeometryUserIndex(),p=y.addGeometry(e),f=y.addGeometry(s),C=new a(c);let E=0,G=null;if(y.hasCurves()){G=new _;const t=y.getEnvelope2D(c);E=h(r.total());const e=l(r.total(),t);d(y,e,r.total(),12e3,G,null,c)}y.dbgVerifyCurves(),C.setEditShapeCrackAndCluster(y,r),C.cut(!1,t,p,f,u),null!==G&&G.stitchCurves(y,i,E,!0);let v=y.getGeometry(p);const w=new o,x=new o,k=[];for(let e=0;e<u.length;e++){let s=null;{const n=new m,o=n.addGeometry(v),a=n.addGeometry(y.getGeometry(u[e]));if(n.hasCurves()){const t=n.getEnvelope2D(c);E=h(r.total());const e=l(r.total(),t);d(n,e,r.total(),12e3,G,null,c)}C.setEditShapeCrackAndCluster(n,r);const p=C.intersection(o,a);if(null!==G&&G.stitchCurves(n,i,E,!0),s=n.getGeometry(p),s.isEmpty())continue;const _=y.getGeometryUserIndex(u[e],t);2===_?w.add(s,!1):1===_?x.add(s,!1):k.push(s)}{const t=new m,s=t.addGeometry(v),n=t.addGeometry(y.getGeometry(u[e]));if(t.hasCurves()){const e=t.getEnvelope2D(c);E=h(r.total());const s=l(r.total(),e);d(t,s,r.total(),12e3,G,null,c)}C.setEditShapeCrackAndCluster(t,r);const o=C.difference(s,n);null!==G&&G.stitchCurves(t,i,E,!0);v=t.getGeometry(o)}}if(!v.isEmpty()&&u.length>0&&k.push(v),w.isEmpty()&&x.isEmpty())return;if(!w.isEmpty()){const t=g(w,1);n.push(t)}if(!x.isEmpty()){const t=g(x,2);n.push(t)}for(let e=0,s=k.length;e<s;++e){const t=g(k[e],3);n.push(t)}}}class E{getOperatorType(){return 10005}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}execute(t,e,s,r,n){return new G(t,e,s,r,n)}}class G extends t{constructor(t,e,s,r,o){super(),this.m_cutIndex=-1,this.m_cuts=[],this.m_progressTracker=o,this.m_cuttee=e.clone(),this.m_cutter=new n({copy:s}),this.m_bConsiderTouch=t;const m=c(e,s);this.m_tolerance=u(r,m,!0)}next(){return-1===this.m_cutIndex&&this.generateCuts(),++this.m_cutIndex<this.m_cuts.length?this.m_cuts[this.m_cutIndex]:null}getGeometryID(){return this.m_cutIndex}tock(){return!0}getRank(){return 1}generateCuts(){switch(this.m_cuttee.getGeometryType()){case e.enumPolyline:this.generatePolylineCuts();break;case e.enumPolygon:this.generatePolygonCuts()}}generatePolylineCuts(){const t=new n,e=new n,r=new n;this.m_cuts.length=0,this.m_cuts.push(t),this.m_cuts.push(e);const o=[];f(this.m_bConsiderTouch,this.m_cuttee,this.m_cutter,this.m_tolerance,o,this.m_progressTracker);for(let n=0;n<o.length;n++){const m=o[n];1===m.m_side?t.add(m.m_geometry,!1):2===m.m_side||4===m.m_side?e.add(m.m_geometry,!1):3===m.m_side?this.m_cuts.push(m.m_geometry):0===m.m_side?r.add(m.m_geometry,!1):s("")}r.isEmpty()||t.isEmpty()&&e.isEmpty()&&!(this.m_cuts.length>=3)||this.m_cuts.push(r),t.isEmpty()&&e.isEmpty()&&this.m_cuts.length<3&&(this.m_cuts.length=0)}generatePolygonCuts(){const t=new o,e=new o,n=new o;this.m_cuts.length=0,this.m_cuts.push(t),this.m_cuts.push(e);const m=[];C(this.m_bConsiderTouch,this.m_cuttee,this.m_cutter,this.m_tolerance,m,this.m_progressTracker);for(let r=0;r<m.length;r++){const o=m[r];1===o.m_side?t.add(o.m_geometry,!1):2===o.m_side?e.add(o.m_geometry,!1):3===o.m_side?this.m_cuts.push(o.m_geometry):0===o.m_side?n.add(o.m_geometry,!1):s("")}r(n.isEmpty()||1===m.length),t.isEmpty()&&e.isEmpty()&&this.m_cuts.length<3&&(this.m_cuts.length=0)}}export{E as O};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{b as t,c as e}from"./tslib.es6.js";import{G as s}from"./SimpleGeometryCursor.js";import{
|
|
5
|
+
import{b as t,c as e}from"./tslib.es6.js";import{G as s}from"./SimpleGeometryCursor.js";import{a as i,d as r,e as a,G as n,f as h,h as m,t as l}from"./Geometry.js";import{a as o,P as c,L as u}from"./QuadraticBezier.js";import{P as _}from"./Envelope.js";import{h as g,P as p,c as k}from"./Point2D.js";import{O as f}from"./OperatorDensify.js";class P{getOperatorType(){return 10204}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i){return new y(t,e,s,i)}execute(t,e,s,r){t||i("null param is not allowed.");return new y(null,e,s,r).generalize(t)}}class y extends s{constructor(t,e,s,i){super(),this.m_pline=null,this.m_point=new _,this.m_stack=[],this.m_resultstack=[],this.m_callCount=0,this.m_progressTracker=i,this.m_geoms=t,this.m_maxDeviation=e,this.m_bRemoveDegenerateParts=s}tock(){return!0}getRank(){return 1}next(){const t=this.m_geoms.next();return null===t?null:(r(t),this.generalize(t))}getGeometryID(){return this.m_geoms.getGeometryID()}generalize(s){const i=s.getGeometryType();if(a(i))return s;if(i===n.enumEnvelope){const t=new o({vd:s.getDescription()});return t.addEnvelope(s,!1),this.generalize(t)}if(h(i)){const t=new c({vd:s.getDescription()});return t.addSegment(s,!0),this.generalize(t)}if(m(i)||l(""),s.isEmpty()||this.m_maxDeviation<=0)return s;const r=(new f).execute(s,0,.05*this.m_maxDeviation,0,this.m_progressTracker);s.hasNonLinearSegments()&&(this.m_maxDeviation*=.95);const _=r,p=s.createInstance();if(p.getGeometryType()===n.enumPolygon){p.setFillRule(s.getFillRule())}this.m_xy=_.getAttributeStreamRef(0);{const s={stack:[],error:void 0,hasError:!1};try{const e=new u;this.m_pline=e,t(s,g((()=>{this.m_pline=null}),!1),!1);for(let t=0,s=_.getPathCount();t<s;t++)this.generalizePath(_.getImpl(),t,p.getImpl())}catch(k){s.error=k,s.hasError=!0}finally{e(s)}}return this.m_resultstack.length=0,this.m_stack.length=0,p}generalizePath(t,e,s){if(t.getPathSize(e)<2)return;this.m_resultstack.length=0,this.m_stack.length=0;const i=t.getPathStart(e),r=t.getPathEnd(e)-1,a=t.isClosedPath(e),n=t.isClosedPathInXYPlane(e);let h=0,m=-1;this.m_stack.push(a?i:r),this.m_stack.push(i);let l=!1,o=!1;for(!this.m_bRemoveDegenerateParts&&n&&(l=!0,o=!0);this.m_stack.length>1;){const e=this.m_stack.at(-1);this.m_stack.pop();const s=this.m_stack.at(-1);let i=t.getXY(e);this.m_pline.setStartXY(i),i=t.getXY(s),this.m_pline.setEndXY(i);const a=[Number.NaN];let n=this.findGreatestDistance(e,s,r,a);n>=0&&(l?l=!1:(o&&a[0]>h&&(h=a[0],m=n),a[0]<=this.m_maxDeviation&&(n=-1))),n>=0?(this.m_stack.push(n),this.m_stack.push(e)):this.m_resultstack.push(e)}a||this.m_resultstack.push(this.m_stack[0]);const c=this.m_resultstack.length;if(c===t.getPathSize(e)&&c===this.m_stack.length)s.addPath(t,e,!0);else if(this.m_resultstack.length>0){if(this.m_bRemoveDegenerateParts&&this.m_resultstack.length<=2){if(a||1===this.m_resultstack.length)return;if(p.distance(t.getXY(this.m_resultstack[0]),t.getXY(this.m_resultstack[1]))<=this.m_maxDeviation)return}if(o&&m>=0&&h<=this.m_maxDeviation){const t=this.m_resultstack.at(-1)>m;this.m_resultstack.push(m),t&&(this.m_resultstack[this.m_resultstack.length-2]=k(this.m_resultstack[this.m_resultstack.length-1],this.m_resultstack[this.m_resultstack.length-1]=this.m_resultstack[this.m_resultstack.length-2]))}for(let e=0,i=this.m_resultstack.length;e<i;e++)t.getPointByVal(this.m_resultstack[e],this.m_point),0===e?s.startPathPoint(this.m_point):s.lineToPoint(this.m_point);if(a){for(let t=this.m_resultstack.length;t<3;t++)s.lineToPoint(this.m_point);s.closePathWithLine()}}}findGreatestDistance(t,e,s,i){let r=e-1;e<=t&&(r=s);let a=-1,n=0;const h=new p;for(let m=t+1;m<=r;m++){this.m_xy.queryPoint2D(2*m,h);const t=h.x,e=h.y,s=this.m_pline.getClosestCoordinate(h,!1);h.assign(this.m_pline.getCoord2D(s)),h.x-=t,h.y-=e;const i=h.length();i>n&&(a=m,n=i),this.m_callCount++}return i[0]=n,a}}export{P as O};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{S as e,G as t}from"./SimpleGeometryCursor.js";import{c as s,b as n,t as i,d as r,i as o,G as m,m as a,f as h,e as c,h as u,n as l}from"./Geometry.js";import{Envelope2D as _}from"./Envelope2D.js";import{h as f,v as d,w as g,x as p,y as P,z as x,A as b,p as y,B as w,D as C,L as v,e as S,g as D,E as I,F as G,P as M,G as T,H as N,I as k,J as A,K as E,M as q,N as R,Q as z,R as B}from"./ProjectionTransformation.js";import{b as X,c as Y}from"./tslib.es6.js";import{a as O,P as j,E as F}from"./QuadraticBezier.js";import{d as W,a as J,P as U,b as H,e as L,f as V,s as Q}from"./Envelope.js";import{T as K}from"./Transformation2D.js";import{d as Z,m as $,P as ee,S as te,k as se,l as ne}from"./Point2D.js";import{c as ie}from"./OperatorClip.js";import{c as re}from"./GeometryCleaner-BEJM7I4l.js";import{O as oe}from"./OperatorDensify.js";function me(e,t,s,n,a,h){n<Number.MAX_VALUE&&n>-Number.MAX_VALUE||i("Geodesic_bufferer.buffer - bad distance"),r(e);const c=re(e),u=c.getGeometryType();if(o(u)){const e=c.getPointCount(),i=8e6;if(Math.abs(n)>i&&(e>50||u!==m.enumMultiPoint&&4===s&&e>2)){let e=c;const r=n>0?1:-1,o=7e6;let m=n,u=1;do{u++,m=(Math.abs(m)-o)*r}while(Math.abs(m)>i);m=n;for(let n=0;n<u-1;n++)e=he(e,t,s,o*r,a,u,h),m=(Math.abs(m)-o)*r;return e=he(e,t,s,m,a,u,h),e}}return he(c,t,s,n,a,1,h)}class ae{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 O,s=new we(this,e,t);return this.processGnomonicBufferPiecesCursor(!0,s)}bufferPolyline(e){const t=new we(this,e,null);return this.processGnomonicBufferPiecesCursor(!0,t)}bufferMultiPoint(e){const t=new Ce(this,e);return this.processGnomonicBufferPiecesCursor(!1,t)}bufferPoint(e){const t=e.getXY();t.scale(this.m_rpu);let s=new O;if(this.bufferPoint2D(t,!1,s)){const e=H(null,s,!0);s=y(s,e,!0,!0,-1,this.m_progressTracker,0,!1)}return s=(new P).foldInto360RangeGeodetic(s,this.m_gcs,2),s}processGnomonicBufferPiecesCursor(e,t){const s=t;let n=s.getGnomonic();const i=w(C());let r=new v,o=(new f).executeMany(r,i,this.m_progressTracker,2);const m=Z(6,!1),a=$(_,6);this.initializeGrid(m,a);const h=[null,null,null,null,null,null],c=[null,null,null,null,null,null],u=[null,null,null,null,null,null];let l,d,g;for(;null!==(l=s.next());){if(d=s.getGnomonic(),d!==n){if(null!==n){let t=o.next();if(r=null,o=null,null!=t){const s=H(i,t,!0),r=W(s);t=n.unproject(t,r,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,m,a,h,c,u)}}null!==d&&(r=new v,o=(new f).executeMany(r,i,this.m_progressTracker,2)),n=d}if(s.isRunningInGnomonic()){if(d.project(l),s.needsSimplify()){const e=H(null,l,!0);l=y(l,e,!0,!0,-1,this.m_progressTracker,0,!1)}r.tick(be(l)),o.tock()}else this.putInGridCursors(e,l,i,!0,m,a,h,c,u)}let p=!1;for(let _=0;_<6;_++)if(null!=u[_]){p=!0;break}if(p){let t=!1;const l=[null,null,null,null,null,null];if(e){const n=s.m_densified;if(s.m_densified=null,null!==n){const s=new K;s.scale(1/this.m_rpu,1/this.m_rpu),n.applyTransformation(s),this.m_distance>0?this.putInGridCursors(e,n,i,!1,m,a,h,c,u):(this.processInGrid(e,n,!1,m,a,h,l),t=!0)}}const _=new v,d=(new f).executeMany(_,this.m_gcs,this.m_progressTracker,2);if(null!==o){let t=o.next();r=null,o=null;const s=H(i,t,!0),l=W(s);t=n.unproject(t,l,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,m,a,h,c,u)}for(let e=0;e<6;e++)if(null!=u[e]){let s=u[e].next();u[e]=null,c[e]=null,t&&null!==l[e]&&(s=(new S).execute(l[e],s,i,this.m_progressTracker));const n=H(i,s,!0),r=W(n);s=h[e].unproject(s,r,this.m_progressTracker),s=(new D).execute(s,this.m_gcs,!0,this.m_progressTracker),_.tick(be(s)),d.tock()}g=d.next()}else{let t,m=!1;if(e){let e=s.m_densified;if(s.m_densified=null,null!==e){const s=new K;s.scale(1/this.m_rpu,1/this.m_rpu),e.applyTransformation(s),d.project(e);const n=H(null,e,!0);e=y(e,n,!1,!0,-1,this.m_progressTracker,0,!1),this.m_distance>0?(r.tick(be(e)),o.tock()):(t=e,m=!0)}}let a=o.next();r=null,o=null,m&&(a=(new S).execute(t,a,i,this.m_progressTracker));const h=H(i,a,!0),c=W(h);g=n.unproject(a,c,this.m_progressTracker),g=(new D).execute(g,this.m_gcs,!0,this.m_progressTracker)}return g=(new P).foldInto360RangeGeodetic(g,this.m_gcs,2),g}putInGridCursors(e,t,s,n,i,r,o,m,a){const h=[null,null,null,null,null,null];this.processInGrid(e,t,n,i,r,o,h);for(let c=0;c<6;c++)null!==h[c]&&(null===m[c]&&(m[c]=new v,a[c]=(new f).executeMany(m[c],s,this.m_progressTracker,2)),m[c].tick(be(h[c])),a[c].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=L(t,e),u=J(null,c,!1).total();let l=ie(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 ee;h<3?e.setCoords(0,1):e.setCoords(0,-1);const t=new ee;t.setAdd(i[h].getCenter(),e),r[h]=xe(this.m_gcs,t)}r[h].project(l);const e=H(null,l,!0);l=y(l,e,s,!0,-1,this.m_progressTracker,0,!1),o[h]=l}}}insertGeodeticPointsAlongGrid(e,t,s){const n=_.construct(t[3].xmin,t[3].ymin,t[2].xmax,t[2].ymax),i=I(this.m_gcs,n,e,!0,this.m_progressTracker),r=new F,o=r.addGeometry(i);return G(r,o,this.m_gcs,0,2,!0,t[0].xmax+s),G(r,o,this.m_gcs,0,2,!0,t[1].xmax+s),G(r,o,this.m_gcs,0,2,!1,t[1].ymin+s),0!==s&&(G(r,o,this.m_gcs,0,2,!0,t[0].xmax-s),G(r,o,this.m_gcs,0,2,!0,t[1].xmax-s),G(r,o,this.m_gcs,0,2,!1,t[1].ymin-s)),r.getGeometry(o)}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=g.q(this.m_a,this.m_eSquared,a),u=g.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 l=s-ne,_=n+ne,f=l-Math.PI,d=l+Math.PI,p=_+Math.PI,P=[Number.NaN],x=[Number.NaN],b=[Number.NaN],y=[Number.NaN];let w=!1;if(le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,l,f,m,_,P,x),le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,p,_,o,f,b,y),(_<P[0]&&P[0]<p||_<x[0]&&x[0]<p)&&(w=!0),w||(f<b[0]&&b[0]<l||f<y[0]&&y[0]<l)&&(w=!0),!w&&i)return!1;const C=[];for(let g=e.length-1;g>=0;g--)C.push(e[g]);r.setEmpty(),r.addPathPoint2D(null,0,!0);let v=0;v=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,e,l,_,i,v,r),v=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,_,p,this.m_cornerStep,i,v,r,P[0],x[0]),v=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,C,p,d,i,v,r),v=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,f,l,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;ue(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 _;return e.queryEnvelope(t),!(!M(t.ymax,this.m_gcs90)&&!M(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 O;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=M(t.y,this.m_gcs90),n=M(t.y,-this.m_gcs90);if(!s&&!n)break}let o=r,m=!1,a=Number.NaN;do{const n=e.getXY(o),r=M(n.y,this.m_gcs90),h=M(n.y,-this.m_gcs90),c=s+(o+1-s)%i;if(r||h){let s=ee.construct(a,n.y);t.insertPoint2D(0,-1,s);const i=e.getXY(c),r=M(i.y,this.m_gcs90),o=M(i.y,-this.m_gcs90);r||o||(s=ee.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 O,s=new O,n=new K,i=e.getXY(e.getPathStart(0)),r=e.getXY(e.getPathEnd(0)-1),o=this.m_gcs360,m=this.m_gcs180,a=new _;a.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const h=new _;e.queryEnvelope(h);const c=Math.ceil(h.width()/o);let u,l;i.x>r.x?(u=-o,l=this.m_gcs90):(u=o,l=-this.m_gcs90),n.setShiftCoords(u,0),t.addPath(e,0,!0),s.add(t,!1);const f=new U;for(let _=0;_<c;_++)s.applyTransformation(n),s.getPointByVal(0,f),t.lineToPoint(f),t.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);const d=t.getXY(0),g=t.getXY(t.getPointCount()-1);d.y=l,g.y=l,t.lineTo(g);const p=new ee;for(p.setCoordsPoint2D(g),p.x-=.5*u;Math.abs(p.x-d.x)>m;)t.lineTo(p),p.x-=.5*u;t.lineTo(d);const P=a.getCenterX(),x=new _;t.queryEnvelope(x);let b=0;const y=x.getCenter().x;y-P>m?b=-Math.ceil((y-P-m)/o):P-y>m&&(b=Math.ceil((P-y-m)/o)),0!==b&&(n.setShiftCoords(b*o,0),t.applyTransformation(n));const w=new F,C=w.addGeometry(t);G(w,C,this.m_gcs,0,2,!0,a.xmin),G(w,C,this.m_gcs,0,2,!0,a.xmax);const v=w.getGeometry(C),S=L(v,a);S.inflateCoords(0,1);const D=J(null,S,!0).total(),I=ie(v,a,D,Number.NaN,this.m_progressTracker);e.setEmpty(),e.add(I,!1)}prepDoublePoleWrap(e){const t=this.m_gcs360,s=this.m_gcs180,n=new _;n.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const i=n.getCenter().x,r=new _;e.queryPathEnvelope(0,r);let o,m=0,a=r.getCenter().x;if(a-i>s?m=-Math.ceil((a-i-s)/t):i-a>s&&(m=Math.ceil((i-a-s)/t)),0!==m){const s=new K;s.setShiftCoords(m*t,0),e.getImpl().applyTransformationToPath(s,0),e.queryPathEnvelope(0,r),a=r.getCenter().x}const h=new _;n.containsExclusiveEnvelope(r)?(o=!1,h.setCoords({env2D:n})):(o=!0,h.setCoords({env2D:n}),h.xmin-=t,h.xmax+=t);let c=e.createInstance();c.addPathPoint2D(null,0,!0);const u=new ee;if(u.setCoords(h.xmin,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(h.xmin,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymin),c.insertPoint2D(0,-1,u),o){c.addPath(e,0,!0);const s=new K;a<i?s.setShiftCoords(t,0):s.setShiftCoords(-t,0),e.getImpl().applyTransformationToPath(s,0),c.addPath(e,0,!0);const r=new F,o=r.addGeometry(c);G(r,o,this.m_gcs,0,2,!0,n.xmin),G(r,o,this.m_gcs,0,2,!0,n.xmax),c=r.getGeometry(o);const m=L(c,n);m.inflateCoords(0,1);const h=J(null,m,!0).total();c=ie(c,n,h,Number.NaN,this.m_progressTracker)}else c.addPath(e,0,!0);e.setEmpty(),e.add(c,!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 ee;n.setCoords(0,10*this.m_rpu);const i=0;let r=45*this.m_rpu;const o=X(e,new te(new T,new T),!1),m=X(e,new te(new T,new T),!1),a=X(e,new te(new T,new T),!1),h=X(e,new te(new T,new T),!1),c=new ee,u=new ee,l=new ee,_=new ee;for(N.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),N.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);N.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=X(e,new T,!1),f=X(e,new T,!1);N.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,o,f,null,2),N.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=X(e,new T,!1);N.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,N.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{Y(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{Y(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 ee,r=new ee;i.setCoords(0,10*this.m_rpu),r.setCoords(10*this.m_rpu,10*this.m_rpu);const o=X(e,new T,!1),m=X(e,new T,!1),a=X(e,new T,!1);N.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,a,o,m,this.m_curveType);const h=X(e,new te(new T,new T),!1),c=X(e,new te(new T,new T),!1),u=new ee,l=X(e,new T,!1),_=X(e,new te(new T,new T),!1),f=X(e,new te(new T,new T),!1),d=X(e,new te(new T,new T),!1),g=X(e,new te(new T,new T),!1),p=new ee,P=new ee,x=new ee,b=new ee,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(N.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),N.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);N.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),N.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;N.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=X(e,new T,!1),a=X(e,new T,!1);N.geodeticDistance(this.m_a,this.m_eSquared,p.x,p.y,P.x,P.y,m,a,null,2),N.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 _=X(e,new T,!1);N.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,N.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=X(e,new T,!1);N.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;N.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{Y(e)}}}catch(s){e.error=s,e.hasError=!0}finally{Y(e)}}let G=w*I;G>1e5&&(G=1e5),this.m_segmentStep=G}catch(n){e.error=n,e.hasError=!0}finally{Y(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 he(e,t,s,n,i,r,o){if(e.isEmpty())return new O({vd:e.getDescription()});let f=e;if(a(f)){const e=10*t.getTolerance(0);f=(new oe).execute(f,0,e,0,o,12e3)}const y=new ae(o);y.m_sr=t,y.m_gcs=t.getGCS(),y.m_transform=d(t,y.m_gcs,null);const w=k();y.m_gcs.querySpheroidData(w);const C=new _;f.queryEnvelope(C),y.m_a=w.majorSemiAxis,y.m_eSquared=w.e2,y.m_rpu=y.m_gcs.getUnit().getUnitToBaseFactor(),y.m_gcs90=.5*Math.PI/y.m_rpu,y.m_gcs180=Math.PI/y.m_rpu,y.m_gcs360=2*Math.PI/y.m_rpu,y.m_gcs60=y.m_gcs360/6,y.m_q90=g.q90(y.m_a,y.m_eSquared),y.m_ellipticToGeodesicMaxRatio=.5*y.m_a*Math.PI/y.m_q90;const v=y.m_gcs.getTolerance(0);y.m_radTolerance=v*y.m_rpu,4===s?(y.m_curveType=2,y.m_bShapePreserving=!0):(y.m_curveType=s,y.m_bShapePreserving=!1),y.m_distance=n,y.m_absDistance=Math.abs(n),Number.isNaN(i)||i<=0?y.setConvergenceOffset():y.m_convergenceOffset=Math.max(i,.001),y.m_convergenceOffset/=r;let S,D=f.getGeometryType();if(h(D)){const e=new j({vd:f.getDescription()});e.addSegment(f,!0),S=e,D=m.enumPolyline}else if(D===m.enumEnvelope){const e=f,t=new _;e.queryEnvelope(t);const s=W(J(y.m_sr,C,!0));if(t.minDimension()<=s)if(0===t.maxDimension()){const t=new U({vd:f.getDescription()});e.getCenter(t),S=t,D=m.enumPoint}else{const t=new j({vd:f.getDescription()});t.addEnvelope(e,!1),S=t,D=m.enumPolyline}else{const t=new O({vd:f.getDescription()});t.addEnvelope(e,!1),S=t,D=m.enumPolygon}}else S=f;if(y.setMinCornerStep(),c(D)||y.setMinSegmentStep(),y.m_absDistance<=.5*y.m_convergenceOffset)return D!==m.enumPolygon?new O({vd:S.getDescription()}):y.m_bShapePreserving?S:p(S,y.m_sr,y.m_curveType,y.m_segmentStep,-1,o);if(y.m_distance<0&&D!==m.enumPolygon)return new O({vd:S.getDescription()});if(y.m_bShapePreserving&&u(D)){const e=p(S,t,4,Number.NaN,y.m_convergenceOffset,o);S=(new P).execute(e,y.m_transform,o)}else S=(new P).execute(S,y.m_transform,o);if(S=x(S,y.m_gcs),S.isEmpty())return new O({vd:S.getDescription()});!y.m_bShapePreserving&&u(D)&&(S=b(y.m_rpu,S)),S=fe(S,y.m_gcs);let I=new O;switch(D){case m.enumPolygon:I=y.bufferPolygon(S);break;case m.enumPolyline:I=y.bufferPolyline(S);break;case m.enumMultiPoint:I=y.bufferMultiPoint(S);break;case m.enumPoint:I=y.bufferPoint(S);break;default:l("")}const G=(new P).execute(I,y.m_transform.getInverse(),o);return G.mergeVertexDescription(S.getDescription()),G}function ce(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const l=new ee;l.setNAN(),a||c.getPointCount()>0&&(l.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),l.scale(s));const _=X(u,new T,!1),f=X(u,new te(new T,new T),!1),d=new ee,g=new ee,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:(N.geodeticDistance(e,t,p.x,p.y,u.x,u.y,null,null,_,i),x=_.val-.5*Math.PI),N.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=_e(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{Y(u)}}function ue(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=X(_,new te(new T,new T),!1),d=new ee,g=new ee,p=new ee;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));)N.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=_e(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{Y(_)}}function le(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const s=new ee,l=new ee,_=X(u,new te(new T,new T),!1);N.geodesicCoordinate(e,t,i.x,i.y,n,r,_.at(0),_.at(1)),s.setCoords(_.at(0).val,_.at(1).val),N.geodesicCoordinate(e,t,i.x,i.y,n,o,_.at(0),_.at(1)),l.setCoords(_.at(0).val,_.at(1).val);const f=X(u,new T,!1);for(N.geodeticDistance(e,t,m.x,m.y,s.x,s.y,null,f,null,0),h[0]=f.val,N.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]+=se;for(;h[0]>c[0];)h[0]-=se;for(;h[0]>=a;)h[0]-=se,c[0]-=se;for(;h[0]<a;)h[0]+=se,c[0]+=se}catch(l){u.error=l,u.hasError=!0}finally{Y(u)}}function _e(e,t,s,n){if(Number.isNaN(s)){for(;n+t-e>Math.PI;)n-=se;for(;e-(n+t)>Math.PI;)n+=se;return n}return n+t-s>Math.PI?n-=se:s-(n+t)>Math.PI&&(n+=se),n}function fe(e,t){const s=e.getGeometryType();let n;if(n=u(s)?e.getPathCount():s===m.enumMultiPoint?e.getPointCount():1,1===n)return e;const i=[],r=[];for(let m=0;m<n;m++){i.push(m);const n=new ee;if(u(s)){const t=new _;e.queryPathEnvelope(m,t),n.assign(t.getCenter())}else n.assign(e.getXY(m));const o=t.toGeohash(n);r.push(o)}i.sort(((e,t)=>r[e]<r[t]?-1:r[e]>r[t]?1:0));const o=e.createInstance();for(let m=0;m<n;m++){const t=i[m];u(s)?o.addPath(e,t,!0):o.addPoints(e,t,t+1)}return o}function de(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=X(o,new T,!1),c=X(o,new T,!1),u=X(o,new T,!1);N.greatEllipticDistance(e,t,i.x,i.y,m.x,m.y,h,null,null),N.greatEllipticDistance(e,t,i.x,i.y,a.x,a.y,c,null,null),N.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=X(o,new T,!1);l=Math.max(h.val,c.val);for(let n=1;n<s.length-1;n++){const r=s[n];N.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{Y(o)}}function ge(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=ee.lerp(t,s,.5)}else{a=n[n.length-1>>1].clone()}const h=a.clone(),c=E(e,t,h,75/180*Math.PI);return!!de(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 pe(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=X(o,new T,!1);N.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{Y(o)}}function Pe(e,t,s,n,i,r,o,m){const a=E(e,t,n,75/180*Math.PI);return!!pe(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 xe(e,t){return new A(e,t)}function be(e){return V(e,0)||Q(e,0),e}class ye{constructor(e){this.m_bRunningInGnomonic=!1,this.m_bNeedsSimplify=!1,this.m_gnomonic=null,this.m_gnomonicCenterRad=new ee,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 we extends ye{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 O,this.m_densifiedPoints=[],this.m_bufferer=e,this.m_multiPath=t,this.m_densified=s,this.m_bNeedsSimplify=!0;const n=new _;this.m_multiPath.queryEnvelope(n);const i=n.getCenter(),r=i.clone();r.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,i),this.m_gnomonicCenterRad=r.clone(),this.m_minGnomonicRadius=E(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,r,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 ee,r=new ee;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),q(i,r))i.x=r.x;else if(R(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),R(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),q(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0;const s=z(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(ge(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||B(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 O,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(q(i,r))i.x=r.x;else if(R(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),R(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),q(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0,z(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=ue(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&&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 ee,s=new ee,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=xe(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-(se-(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 ee;t.setCoordsPoint2D(e.getXY(e.getPointCount()-1)),t.scale(this.m_bufferer.m_rpu),t.x-this.m_currentBufferedDelta<-Math.PI?this.m_currentBufferedDelta-=se:t.x-this.m_currentBufferedDelta>Math.PI&&(this.m_currentBufferedDelta+=se)}n=.5*(n+s)}else if(r){const s=new ee;s.setCoordsPoint2D(t),s.scale(1/this.m_bufferer.m_rpu),e.insertPoint2D(0,-1,s)}else ue(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++,ce(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 Ce extends ye{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 _;this.m_multiPoint.queryEnvelope(s);const n=s.getCenter(),i=n.clone();i.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,n),this.m_gnomonicCenterRad=i.clone(),this.m_minGnomonicRadius=E(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,i,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 O,s=this.m_bufferer.bufferPoint2D(e,this.m_bRunningInGnomonic,t);return this.m_bNeedsSimplify=s,t}isPointBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&pe(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 ee,s=new ee,n=[0];return Pe(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=xe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}}class ve{getOperatorType(){return 10110}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n,i,r,o,m){if(o){const o=new Se(e,t,s,n,i,!1,r,m);return(new f).executeMany(o,t,m)}return new Se(e,t,s,n,i,!1,r,m)}execute(t,n,i,r,o,m,a){const h=new e([t]),c=[r],u=this.executeMany(h,n,i,c,o,!1,m,a).next();return u||s("geodesic buffer null output"),u}}class Se extends t{constructor(e,t,s,r,o,m,a,h){super(),this.m_currentUnionEnvelope2D=new _,this.m_index=-1,this.m_dindex=-1,this.m_progressTracker=h,m&&n(""),t||i("");0===t.getCoordinateSystemType()&&i(""),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=s,this.m_distances=r,this.m_convergenceOffset=o,this.m_bOutlineOnly=m,this.m_bUnion=a}next(){let e;for(;e=this.m_inputGeoms.next();)return r(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 me(e,this.m_spatialReference,this.m_curveType,t,this.m_convergenceOffset,this.m_progressTracker)}}export{ve as OperatorGeodesicBuffer};
|
|
5
|
+
import{S as e,G as t}from"./SimpleGeometryCursor.js";import{c as s,t as n,a as i,d as r,i as o,G as m,m as a,f as h,e as c,h as u,n as l}from"./Geometry.js";import{Envelope2D as _}from"./Envelope2D.js";import{j as f,w as d,H as g,L as p,v as P,F as x,Q as b,p as y,R as w,S as C,U as v,f as S,O as D,V as I,W as G,X as M,P as T,x as N,J as k,Y as A,Z as E,_ as q,$ as R,a0 as z,a1 as X}from"./ProjectionTransformation.js";import{b as B,c as Y}from"./tslib.es6.js";import{a as O,P as j,E as F}from"./QuadraticBezier.js";import{e as W,c as J,P as U,b as H,f as L,h as V,s as Q}from"./Envelope.js";import{T as Z}from"./Transformation2D.js";import{d as $,m as K,P as ee,S as te,o as se,p as ne}from"./Point2D.js";import{c as ie}from"./OperatorClip.js";import{c as re}from"./GeometryCleaner-BEJM7I4l.js";import{O as oe}from"./OperatorDensify.js";function me(e,t,s,n,a,h){n<Number.MAX_VALUE&&n>-Number.MAX_VALUE||i("Geodesic_bufferer.buffer - bad distance"),r(e);const c=re(e),u=c.getGeometryType();if(o(u)){const e=c.getPointCount(),i=8e6;if(Math.abs(n)>i&&(e>50||u!==m.enumMultiPoint&&4===s&&e>2)){let e=c;const r=n>0?1:-1,o=7e6;let m=n,u=1;do{u++,m=(Math.abs(m)-o)*r}while(Math.abs(m)>i);m=n;for(let n=0;n<u-1;n++)e=he(e,t,s,o*r,a,u,h),m=(Math.abs(m)-o)*r;return e=he(e,t,s,m,a,u,h),e}}return he(c,t,s,n,a,1,h)}class ae{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 O,s=new we(this,e,t);return this.processGnomonicBufferPiecesCursor(!0,s)}bufferPolyline(e){const t=new we(this,e,null);return this.processGnomonicBufferPiecesCursor(!0,t)}bufferMultiPoint(e){const t=new Ce(this,e);return this.processGnomonicBufferPiecesCursor(!1,t)}bufferPoint(e){const t=e.getXY();t.scale(this.m_rpu);let s=new O;if(this.bufferPoint2D(t,!1,s)){const e=H(null,s,!0);s=y(s,e,!0,!0,-1,this.m_progressTracker,0,!1)}return s=(new P).foldInto360RangeGeodetic(s,this.m_gcs,2),s}processGnomonicBufferPiecesCursor(e,t){const s=t;let n=s.getGnomonic();const i=w(C());let r=new v,o=(new f).executeMany(r,i,this.m_progressTracker,2);const m=$(6,!1),a=K(_,6);this.initializeGrid(m,a);const h=[null,null,null,null,null,null],c=[null,null,null,null,null,null],u=[null,null,null,null,null,null];let l,d,g;for(;null!==(l=s.next());){if(d=s.getGnomonic(),d!==n){if(null!==n){let t=o.next();if(r=null,o=null,null!=t){const s=H(i,t,!0),r=W(s);t=n.unproject(t,r,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,m,a,h,c,u)}}null!==d&&(r=new v,o=(new f).executeMany(r,i,this.m_progressTracker,2)),n=d}if(s.isRunningInGnomonic()){if(d.project(l),s.needsSimplify()){const e=H(null,l,!0);l=y(l,e,!0,!0,-1,this.m_progressTracker,0,!1)}r.tick(be(l)),o.tock()}else this.putInGridCursors(e,l,i,!0,m,a,h,c,u)}let p=!1;for(let _=0;_<6;_++)if(null!=u[_]){p=!0;break}if(p){let t=!1;const l=[null,null,null,null,null,null];if(e){const n=s.m_densified;if(s.m_densified=null,null!==n){const s=new Z;s.scale(1/this.m_rpu,1/this.m_rpu),n.applyTransformation(s),this.m_distance>0?this.putInGridCursors(e,n,i,!1,m,a,h,c,u):(this.processInGrid(e,n,!1,m,a,h,l),t=!0)}}const _=new v,d=(new f).executeMany(_,this.m_gcs,this.m_progressTracker,2);if(null!==o){let t=o.next();r=null,o=null;const s=H(i,t,!0),l=W(s);t=n.unproject(t,l,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,m,a,h,c,u)}for(let e=0;e<6;e++)if(null!=u[e]){let s=u[e].next();u[e]=null,c[e]=null,t&&null!==l[e]&&(s=(new S).execute(l[e],s,i,this.m_progressTracker));const n=H(i,s,!0),r=W(n);s=h[e].unproject(s,r,this.m_progressTracker),s=(new D).execute(s,this.m_gcs,!0,this.m_progressTracker),_.tick(be(s)),d.tock()}g=d.next()}else{let t,m=!1;if(e){let e=s.m_densified;if(s.m_densified=null,null!==e){const s=new Z;s.scale(1/this.m_rpu,1/this.m_rpu),e.applyTransformation(s),d.project(e);const n=H(null,e,!0);e=y(e,n,!1,!0,-1,this.m_progressTracker,0,!1),this.m_distance>0?(r.tick(be(e)),o.tock()):(t=e,m=!0)}}let a=o.next();r=null,o=null,m&&(a=(new S).execute(t,a,i,this.m_progressTracker));const h=H(i,a,!0),c=W(h);g=n.unproject(a,c,this.m_progressTracker),g=(new D).execute(g,this.m_gcs,!0,this.m_progressTracker)}return g=(new P).foldInto360RangeGeodetic(g,this.m_gcs,2),g}putInGridCursors(e,t,s,n,i,r,o,m,a){const h=[null,null,null,null,null,null];this.processInGrid(e,t,n,i,r,o,h);for(let c=0;c<6;c++)null!==h[c]&&(null===m[c]&&(m[c]=new v,a[c]=(new f).executeMany(m[c],s,this.m_progressTracker,2)),m[c].tick(be(h[c])),a[c].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=L(t,e),u=J(null,c,!1).total();let l=ie(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 ee;h<3?e.setCoords(0,1):e.setCoords(0,-1);const t=new ee;t.setAdd(i[h].getCenter(),e),r[h]=xe(this.m_gcs,t)}r[h].project(l);const e=H(null,l,!0);l=y(l,e,s,!0,-1,this.m_progressTracker,0,!1),o[h]=l}}}insertGeodeticPointsAlongGrid(e,t,s){const n=_.construct(t[3].xmin,t[3].ymin,t[2].xmax,t[2].ymax),i=I(this.m_gcs,n,e,!0,this.m_progressTracker),r=new F,o=r.addGeometry(i);return G(r,o,this.m_gcs,0,2,!0,t[0].xmax+s),G(r,o,this.m_gcs,0,2,!0,t[1].xmax+s),G(r,o,this.m_gcs,0,2,!1,t[1].ymin+s),0!==s&&(G(r,o,this.m_gcs,0,2,!0,t[0].xmax-s),G(r,o,this.m_gcs,0,2,!0,t[1].xmax-s),G(r,o,this.m_gcs,0,2,!1,t[1].ymin-s)),r.getGeometry(o)}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=g.q(this.m_a,this.m_eSquared,a),u=g.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 l=s-ne,_=n+ne,f=l-Math.PI,d=l+Math.PI,p=_+Math.PI,P=[Number.NaN],x=[Number.NaN],b=[Number.NaN],y=[Number.NaN];let w=!1;if(le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,l,f,m,_,P,x),le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,p,_,o,f,b,y),(_<P[0]&&P[0]<p||_<x[0]&&x[0]<p)&&(w=!0),w||(f<b[0]&&b[0]<l||f<y[0]&&y[0]<l)&&(w=!0),!w&&i)return!1;const C=[];for(let g=e.length-1;g>=0;g--)C.push(e[g]);r.setEmpty(),r.addPathPoint2D(null,0,!0);let v=0;v=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,e,l,_,i,v,r),v=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,_,p,this.m_cornerStep,i,v,r,P[0],x[0]),v=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,C,p,d,i,v,r),v=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,f,l,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;ue(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 _;return e.queryEnvelope(t),!(!M(t.ymax,this.m_gcs90)&&!M(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 O;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=M(t.y,this.m_gcs90),n=M(t.y,-this.m_gcs90);if(!s&&!n)break}let o=r,m=!1,a=Number.NaN;do{const n=e.getXY(o),r=M(n.y,this.m_gcs90),h=M(n.y,-this.m_gcs90),c=s+(o+1-s)%i;if(r||h){let s=ee.construct(a,n.y);t.insertPoint2D(0,-1,s);const i=e.getXY(c),r=M(i.y,this.m_gcs90),o=M(i.y,-this.m_gcs90);r||o||(s=ee.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 O,s=new O,n=new Z,i=e.getXY(e.getPathStart(0)),r=e.getXY(e.getPathEnd(0)-1),o=this.m_gcs360,m=this.m_gcs180,a=new _;a.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const h=new _;e.queryEnvelope(h);const c=Math.ceil(h.width()/o);let u,l;i.x>r.x?(u=-o,l=this.m_gcs90):(u=o,l=-this.m_gcs90),n.setShiftCoords(u,0),t.addPath(e,0,!0),s.add(t,!1);const f=new U;for(let _=0;_<c;_++)s.applyTransformation(n),s.getPointByVal(0,f),t.lineToPoint(f),t.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);const d=t.getXY(0),g=t.getXY(t.getPointCount()-1);d.y=l,g.y=l,t.lineTo(g);const p=new ee;for(p.setCoordsPoint2D(g),p.x-=.5*u;Math.abs(p.x-d.x)>m;)t.lineTo(p),p.x-=.5*u;t.lineTo(d);const P=a.getCenterX(),x=new _;t.queryEnvelope(x);let b=0;const y=x.getCenter().x;y-P>m?b=-Math.ceil((y-P-m)/o):P-y>m&&(b=Math.ceil((P-y-m)/o)),0!==b&&(n.setShiftCoords(b*o,0),t.applyTransformation(n));const w=new F,C=w.addGeometry(t);G(w,C,this.m_gcs,0,2,!0,a.xmin),G(w,C,this.m_gcs,0,2,!0,a.xmax);const v=w.getGeometry(C),S=L(v,a);S.inflateCoords(0,1);const D=J(null,S,!0).total(),I=ie(v,a,D,Number.NaN,this.m_progressTracker);e.setEmpty(),e.add(I,!1)}prepDoublePoleWrap(e){const t=this.m_gcs360,s=this.m_gcs180,n=new _;n.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const i=n.getCenter().x,r=new _;e.queryPathEnvelope(0,r);let o,m=0,a=r.getCenter().x;if(a-i>s?m=-Math.ceil((a-i-s)/t):i-a>s&&(m=Math.ceil((i-a-s)/t)),0!==m){const s=new Z;s.setShiftCoords(m*t,0),e.getImpl().applyTransformationToPath(s,0),e.queryPathEnvelope(0,r),a=r.getCenter().x}const h=new _;n.containsExclusiveEnvelope(r)?(o=!1,h.setCoords({env2D:n})):(o=!0,h.setCoords({env2D:n}),h.xmin-=t,h.xmax+=t);let c=e.createInstance();c.addPathPoint2D(null,0,!0);const u=new ee;if(u.setCoords(h.xmin,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(h.xmin,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymin),c.insertPoint2D(0,-1,u),o){c.addPath(e,0,!0);const s=new Z;a<i?s.setShiftCoords(t,0):s.setShiftCoords(-t,0),e.getImpl().applyTransformationToPath(s,0),c.addPath(e,0,!0);const r=new F,o=r.addGeometry(c);G(r,o,this.m_gcs,0,2,!0,n.xmin),G(r,o,this.m_gcs,0,2,!0,n.xmax),c=r.getGeometry(o);const m=L(c,n);m.inflateCoords(0,1);const h=J(null,m,!0).total();c=ie(c,n,h,Number.NaN,this.m_progressTracker)}else c.addPath(e,0,!0);e.setEmpty(),e.add(c,!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 ee;n.setCoords(0,10*this.m_rpu);const i=0;let r=45*this.m_rpu;const o=B(e,new te(new T,new T),!1),m=B(e,new te(new T,new T),!1),a=B(e,new te(new T,new T),!1),h=B(e,new te(new T,new T),!1),c=new ee,u=new ee,l=new ee,_=new ee;for(N.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),N.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);N.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=B(e,new T,!1),f=B(e,new T,!1);N.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,o,f,null,2),N.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=B(e,new T,!1);N.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,N.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{Y(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{Y(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 ee,r=new ee;i.setCoords(0,10*this.m_rpu),r.setCoords(10*this.m_rpu,10*this.m_rpu);const o=B(e,new T,!1),m=B(e,new T,!1),a=B(e,new T,!1);N.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,a,o,m,this.m_curveType);const h=B(e,new te(new T,new T),!1),c=B(e,new te(new T,new T),!1),u=new ee,l=B(e,new T,!1),_=B(e,new te(new T,new T),!1),f=B(e,new te(new T,new T),!1),d=B(e,new te(new T,new T),!1),g=B(e,new te(new T,new T),!1),p=new ee,P=new ee,x=new ee,b=new ee,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(N.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),N.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);N.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),N.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;N.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=B(e,new T,!1),a=B(e,new T,!1);N.geodeticDistance(this.m_a,this.m_eSquared,p.x,p.y,P.x,P.y,m,a,null,2),N.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 _=B(e,new T,!1);N.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,N.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=B(e,new T,!1);N.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;N.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{Y(e)}}}catch(s){e.error=s,e.hasError=!0}finally{Y(e)}}let G=w*I;G>1e5&&(G=1e5),this.m_segmentStep=G}catch(n){e.error=n,e.hasError=!0}finally{Y(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 he(e,t,s,n,i,r,o){if(e.isEmpty())return new O({vd:e.getDescription()});let f=e;if(a(f)){const e=10*t.getTolerance(0);f=(new oe).execute(f,0,e,0,o,12e3)}const y=new ae(o);y.m_sr=t,y.m_gcs=t.getGCS(),y.m_transform=d(t,y.m_gcs,null);const w=k();y.m_gcs.querySpheroidData(w);const C=new _;f.queryEnvelope(C),y.m_a=w.majorSemiAxis,y.m_eSquared=w.e2,y.m_rpu=y.m_gcs.getUnit().getUnitToBaseFactor(),y.m_gcs90=.5*Math.PI/y.m_rpu,y.m_gcs180=Math.PI/y.m_rpu,y.m_gcs360=2*Math.PI/y.m_rpu,y.m_gcs60=y.m_gcs360/6,y.m_q90=g.q90(y.m_a,y.m_eSquared),y.m_ellipticToGeodesicMaxRatio=.5*y.m_a*Math.PI/y.m_q90;const v=y.m_gcs.getTolerance(0);y.m_radTolerance=v*y.m_rpu,4===s?(y.m_curveType=2,y.m_bShapePreserving=!0):(y.m_curveType=s,y.m_bShapePreserving=!1),y.m_distance=n,y.m_absDistance=Math.abs(n),Number.isNaN(i)||i<=0?y.setConvergenceOffset():y.m_convergenceOffset=Math.max(i,.001),y.m_convergenceOffset/=r;let S,D=f.getGeometryType();if(h(D)){const e=new j({vd:f.getDescription()});e.addSegment(f,!0),S=e,D=m.enumPolyline}else if(D===m.enumEnvelope){const e=f,t=new _;e.queryEnvelope(t);const s=W(J(y.m_sr,C,!0));if(t.minDimension()<=s)if(0===t.maxDimension()){const t=new U({vd:f.getDescription()});e.getCenter(t),S=t,D=m.enumPoint}else{const t=new j({vd:f.getDescription()});t.addEnvelope(e,!1),S=t,D=m.enumPolyline}else{const t=new O({vd:f.getDescription()});t.addEnvelope(e,!1),S=t,D=m.enumPolygon}}else S=f;if(y.setMinCornerStep(),c(D)||y.setMinSegmentStep(),y.m_absDistance<=.5*y.m_convergenceOffset)return D!==m.enumPolygon?new O({vd:S.getDescription()}):y.m_bShapePreserving?S:p(S,y.m_sr,y.m_curveType,y.m_segmentStep,-1,o);if(y.m_distance<0&&D!==m.enumPolygon)return new O({vd:S.getDescription()});if(y.m_bShapePreserving&&u(D)){const e=p(S,t,4,Number.NaN,y.m_convergenceOffset,o);S=(new P).execute(e,y.m_transform,o)}else S=(new P).execute(S,y.m_transform,o);if(S=x(S,y.m_gcs),S.isEmpty())return new O({vd:S.getDescription()});!y.m_bShapePreserving&&u(D)&&(S=b(y.m_rpu,S)),S=fe(S,y.m_gcs);let I=new O;switch(D){case m.enumPolygon:I=y.bufferPolygon(S);break;case m.enumPolyline:I=y.bufferPolyline(S);break;case m.enumMultiPoint:I=y.bufferMultiPoint(S);break;case m.enumPoint:I=y.bufferPoint(S);break;default:l("")}const G=(new P).execute(I,y.m_transform.getInverse(),o);return G.mergeVertexDescription(S.getDescription()),G}function ce(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const l=new ee;l.setNAN(),a||c.getPointCount()>0&&(l.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),l.scale(s));const _=B(u,new T,!1),f=B(u,new te(new T,new T),!1),d=new ee,g=new ee,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:(N.geodeticDistance(e,t,p.x,p.y,u.x,u.y,null,null,_,i),x=_.val-.5*Math.PI),N.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=_e(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{Y(u)}}function ue(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=B(_,new te(new T,new T),!1),d=new ee,g=new ee,p=new ee;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));)N.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=_e(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{Y(_)}}function le(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const s=new ee,l=new ee,_=B(u,new te(new T,new T),!1);N.geodesicCoordinate(e,t,i.x,i.y,n,r,_.at(0),_.at(1)),s.setCoords(_.at(0).val,_.at(1).val),N.geodesicCoordinate(e,t,i.x,i.y,n,o,_.at(0),_.at(1)),l.setCoords(_.at(0).val,_.at(1).val);const f=B(u,new T,!1);for(N.geodeticDistance(e,t,m.x,m.y,s.x,s.y,null,f,null,0),h[0]=f.val,N.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]+=se;for(;h[0]>c[0];)h[0]-=se;for(;h[0]>=a;)h[0]-=se,c[0]-=se;for(;h[0]<a;)h[0]+=se,c[0]+=se}catch(l){u.error=l,u.hasError=!0}finally{Y(u)}}function _e(e,t,s,n){if(Number.isNaN(s)){for(;n+t-e>Math.PI;)n-=se;for(;e-(n+t)>Math.PI;)n+=se;return n}return n+t-s>Math.PI?n-=se:s-(n+t)>Math.PI&&(n+=se),n}function fe(e,t){const s=e.getGeometryType();let n;if(n=u(s)?e.getPathCount():s===m.enumMultiPoint?e.getPointCount():1,1===n)return e;const i=[],r=[];for(let m=0;m<n;m++){i.push(m);const n=new ee;if(u(s)){const t=new _;e.queryPathEnvelope(m,t),n.assign(t.getCenter())}else n.assign(e.getXY(m));const o=t.toGeohash(n);r.push(o)}i.sort(((e,t)=>r[e]<r[t]?-1:r[e]>r[t]?1:0));const o=e.createInstance();for(let m=0;m<n;m++){const t=i[m];u(s)?o.addPath(e,t,!0):o.addPoints(e,t,t+1)}return o}function de(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=B(o,new T,!1),c=B(o,new T,!1),u=B(o,new T,!1);N.greatEllipticDistance(e,t,i.x,i.y,m.x,m.y,h,null,null),N.greatEllipticDistance(e,t,i.x,i.y,a.x,a.y,c,null,null),N.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=B(o,new T,!1);l=Math.max(h.val,c.val);for(let n=1;n<s.length-1;n++){const r=s[n];N.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{Y(o)}}function ge(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=ee.lerp(t,s,.5)}else{a=n[n.length-1>>1].clone()}const h=a.clone(),c=E(e,t,h,75/180*Math.PI);return!!de(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 pe(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=B(o,new T,!1);N.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{Y(o)}}function Pe(e,t,s,n,i,r,o,m){const a=E(e,t,n,75/180*Math.PI);return!!pe(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 xe(e,t){return new A(e,t)}function be(e){return V(e,0)||Q(e,0),e}class ye{constructor(e){this.m_bRunningInGnomonic=!1,this.m_bNeedsSimplify=!1,this.m_gnomonic=null,this.m_gnomonicCenterRad=new ee,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 we extends ye{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 O,this.m_densifiedPoints=[],this.m_bufferer=e,this.m_multiPath=t,this.m_densified=s,this.m_bNeedsSimplify=!0;const n=new _;this.m_multiPath.queryEnvelope(n);const i=n.getCenter(),r=i.clone();r.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,i),this.m_gnomonicCenterRad=r.clone(),this.m_minGnomonicRadius=E(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,r,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 ee,r=new ee;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),q(i,r))i.x=r.x;else if(R(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),R(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),q(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0;const s=z(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(ge(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||X(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 O,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(q(i,r))i.x=r.x;else if(R(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),R(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),q(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0,z(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=ue(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&&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 ee,s=new ee,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=xe(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-(se-(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 ee;t.setCoordsPoint2D(e.getXY(e.getPointCount()-1)),t.scale(this.m_bufferer.m_rpu),t.x-this.m_currentBufferedDelta<-Math.PI?this.m_currentBufferedDelta-=se:t.x-this.m_currentBufferedDelta>Math.PI&&(this.m_currentBufferedDelta+=se)}n=.5*(n+s)}else if(r){const s=new ee;s.setCoordsPoint2D(t),s.scale(1/this.m_bufferer.m_rpu),e.insertPoint2D(0,-1,s)}else ue(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++,ce(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 Ce extends ye{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 _;this.m_multiPoint.queryEnvelope(s);const n=s.getCenter(),i=n.clone();i.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,n),this.m_gnomonicCenterRad=i.clone(),this.m_minGnomonicRadius=E(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,i,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 O,s=this.m_bufferer.bufferPoint2D(e,this.m_bRunningInGnomonic,t);return this.m_bNeedsSimplify=s,t}isPointBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&pe(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 ee,s=new ee,n=[0];return Pe(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=xe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}}class ve{getOperatorType(){return 10110}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n,i,r,o,m){if(o){const o=new Se(e,t,s,n,i,!1,r,m);return(new f).executeMany(o,t,m)}return new Se(e,t,s,n,i,!1,r,m)}execute(t,n,i,r,o,m,a){const h=new e([t]),c=[r],u=this.executeMany(h,n,i,c,o,!1,m,a).next();return u||s("geodesic buffer null output"),u}}class Se extends t{constructor(e,t,s,r,o,m,a,h){super(),this.m_currentUnionEnvelope2D=new _,this.m_index=-1,this.m_dindex=-1,this.m_progressTracker=h,m&&n(""),t||i("");0===t.getCoordinateSystemType()&&i(""),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=s,this.m_distances=r,this.m_convergenceOffset=o,this.m_bOutlineOnly=m,this.m_bUnion=a}next(){let e;for(;e=this.m_inputGeoms.next();)return r(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 me(e,this.m_spatialReference,this.m_curveType,t,this.m_convergenceOffset,this.m_progressTracker)}}export{ve as OperatorGeodesicBuffer};
|