UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 3.58 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{a as e,G as t,f as s,d as n}from"./Geometry.js";import{V as o,g as r,a,U as i,W as m}from"./SpatialReference.js";import{P as c,a as g}from"./MultiPathImpl.js";import{k as u,d as p,P as h}from"./Point2D.js";import{f as l}from"./Envelope.js";import{Envelope2D as y}from"./Envelope2D.js";import{O as f}from"./OperatorDensify.js";import{O as _}from"./OperatorClip.js";function x(){return{m_pGcs:new h,m_xyz:new l,m_factor:Number.NaN,m_geoLength:Number.NaN,setValues:d,setLength:S,assign:P}}function d(e,t,s,n){this.m_factor=e,this.m_pGcs.assign(t),this.m_xyz.assign(n),this.m_geoLength=s}function S(e){this.m_geoLength=e}function P(e){this.m_pGcs.assign(e.m_pGcs),this.m_xyz.assign(e.m_xyz),this.m_factor=e.m_factor,this.m_geoLength=e.m_geoLength}class w{getOperatorType(){return 10315}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}_ExecuteShapePreservingLength(e,t,s,n,a){if(e.hasNonLinearSegments()){e=(new f).execute(e,0,t.getTolerance(0),0,a)}if(t.isPannable()){let n=90,r=-90;if(1===s.getUnit().getUnitToBaseFactor()&&(n*=Math.PI/180,r*=Math.PI/180),2===t.getCoordinateSystemType()){let e=null;const s=[0,0,0,0];e=t.getPECoordSys(),s[0]=0,s[1]=n,s[2]=0,s[3]=r,o.geogToProj(e,2,s),n=s[1],r=s[3]}const i=new y;e.queryEnvelope(i),i.ymin=r,i.ymax=n,e=(new _).execute(e,i,t,a)}else{const s=t.getPCSHorizon();if((e=(new r).execute(e,s,t,a))===s){const t=e.clone();e=t}}return e.isEmpty()?0:this._ExecuteIterativeApproach(e,t,s,n,1,a)}_ExecuteIterativeApproach(e,t,s,r,a,m){const c=i();s.querySpheroidData(c);const g=c.majorSemiAxis,y=c.e2,f=s.getUnit().getUnitToBaseFactor(),_=40,d=u(x,_),S=p(_,Number.NaN),P=x(),w=x();let E;const G=[0,0,0,0],L=t.getPECoordSys(),j=new h,v=new h,T=new h,D=new h,b=new h;let z=0;const I=e.querySegmentIterator();for(;I.nextPath();)for(;I.hasNextSegment();){const e=I.nextSegment();j.assign(e.getStartXY()),v.assign(e.getEndXY()),2===t.getCoordinateSystemType()?(G[0]=j.x,G[1]=j.y,G[2]=v.x,G[3]=v.y,o.projToGeog(L,2,G),T.x=G[0]*f,T.y=G[1]*f,D.x=G[2]*f,D.y=G[3]*f):(T.setCoordsPoint2D(j),D.setCoordsPoint2D(v),T.scale(f),D.scale(f));const s=new l,r=new l;N(g,y,T,s),N(g,y,D,r);let i=C(g,s,r);P.setValues(0,T,Number.NaN,s),w.setValues(1,D,i,r),E=a,d[0].assign(w),S[0]=a;let m=0;for(;;){m>128&&n("iterations exceeded");const s=.5*(P.m_factor+w.m_factor),r=e.getCoord2D(s);2===t.getCoordinateSystemType()?(G[0]=r.x,G[1]=r.y,o.projToGeog(L,1,G),b.x=G[0]*f,b.y=G[1]*f):(b.setCoordsPoint2D(r),b.scale(f)),T.setCoordsPoint2D(P.m_pGcs),D.setCoordsPoint2D(w.m_pGcs);const c=new l;N(g,y,b,c);const u=C(g,P.m_xyz,c),p=C(g,w.m_xyz,c);i=w.m_geoLength,Number.isNaN(i)&&(i=C(g,P.m_xyz,w.m_xyz));const h=u+p,x=E===a&&h>=20&&Math.abs(h-i)>1e-8*(i+h);if(m+2<_&&(x||Math.abs(h-i)>0&&E>0))w.setLength(p),d[m].assign(w),w.setValues(s,b,u,c),d[++m].assign(w),x?(E=a,S[m]=a):(E--,S[m-1]=E,S[m]=E);else{if(z+=h,0===m)break;P.assign(w),w.assign(d[--m]),E=S[m]}}}return z}execute(n,o,r){if(o&&0!==o.getCoordinateSystemType()||e(""),n.isEmpty()||n.getDimension()<1)return 0;let i=null;const m=o.getGCS();m!==o&&(i=a(o,m,null));const u=n.getGeometryType();if(u===t.enumEnvelope){const e=new c;return e.addEnvelope(n,!1),this._ExecuteShapePreservingLength(e,o,m,i,r)}if(s(u)){const e=new g;return e.addSegment(n,!0),this._ExecuteShapePreservingLength(e,o,m,i,r)}return this._ExecuteShapePreservingLength(n,o,m,i,r)}}function N(e,t,s,n){n.assign(m(e,t,s))}function C(e,t,s){const n=e,o=new l;o.setSub(t,s);const r=o.length();return 2*n*Math.asin(r/(2*n))}export{w as O};