@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.27 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as t}from"../../chunks/tslib.es6.js";import{rad2deg as e,scale as r}from"../../core/mathUtils.js";import{createScreenPoint as o}from"../../core/screenUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{toRadian as i}from"../../core/libs/gl-matrix-2/math/common.js";import a from"../../geometry/Extent.js";import c from"../../geometry/Polygon.js";import{projectOrLoad as l}from"../../geometry/projectionUtils.js";import m from"./GeoreferenceBase.js";let p=class extends m{constructor(t){super(t),this.extent=null,this.rotation=0,this.type="extent-and-rotation"}get coords(){if(null==this.extent)return null;const{xmin:t,ymin:e,xmax:r,ymax:o,spatialReference:n}=this.extent;let s;if(this.rotation){const{x:n,y:i}=this.extent.center,a=x(n,i,this.rotation);s=[a(t,e),a(t,o),a(r,o),a(r,e)],s.push(s[0])}else s=[[t,e],[t,o],[r,o],[r,e],[t,e]];return new c({rings:[s],spatialReference:n})}set coords(t){if(null==t||null==this.extent)return;const r=this.extent.spatialReference;if(t=this.projectOrWarn(t,r),null==t?.extent)return;const{rings:[[o,n,s]],extent:{center:{x:i,y:c}}}=t,l=e(Math.PI/2-Math.atan2(n[1]-o[1],n[0]-o[0])),m=x(i,c,-l),[p,u]=m(o[0],o[1]),[f,h]=m(s[0],s[1]);this.extent=new a({xmin:p,ymin:u,xmax:f,ymax:h,spatialReference:r}),this.rotation=l}toSourceNormalized(t){const{extent:e,rotation:n}=this;if(null==t||null==e)return null;const{xmin:s,ymin:i,xmax:a,ymax:c,center:m,spatialReference:p}=e;t=t.normalize();const u=l(t,p).geometry;if(null==u)return null;let f=u.x,h=u.y;return n&&([f,h]=x(m.x,m.y,-n)(f,h)),o(r(f,s,a,0,1),r(h,c,i,0,1))}};function x(t,e,r){const o=i(r),n=Math.cos(o),s=Math.sin(o);return(r,o)=>[n*(r-t)+s*(o-e)+t,n*(o-e)-s*(r-t)+e]}t([n({clonable:!1})],p.prototype,"coords",null),t([n({type:a})],p.prototype,"extent",void 0),t([n({type:Number})],p.prototype,"rotation",void 0),p=t([s("esri.layers.support.ExtentAndRotationGeoreference")],p);const u=p;export{u as default};