UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 5.37 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../core/Accessor.js";import{JSONSupport as i}from"../core/JSONSupport.js";import{clone as r}from"../core/lang.js";import{getMetersPerUnitForSR as s,getUnitString as o}from"../core/units.js";import{Integer as n}from"../core/accessorSupport/ensureType.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../core/accessorSupport/decorators/writer.js";import{isWGS84 as u,isWebMercator as c,isGeographic as y,isWrappable as h,wgs84 as m,webMercator as d,equals as f,plateCarree as w}from"./support/spatialReferenceUtils.js";var k;let S=class extends i{static{k=this}static{this.GCS_NAD_1927=null}static{this.WGS84=null}static{this.WebMercator=null}static{this.PlateCarree=null}static fromJSON(e){if(!e)return null;if(!g.some(t=>null!=e[t])){if(102100===e?.wkid)return k.WebMercator;if(4326===e?.wkid)return k.WGS84}const t=new k;return t.read(e),t}constructor(e){super(e),this.latestWkid=null,this.wkid=null,this.wkt=null,this.wkt2=null,this.vcsWkid=null,this.latestVcsWkid=null,this.falseM=null,this.falseX=null,this.falseY=null,this.falseZ=null,this.mTolerance=null,this.mUnits=null,this.xyTolerance=null,this.xyUnits=null,this.zTolerance=null,this.zUnits=null,this.imageCoordinateSystem=null}normalizeCtorArgs(e){if(e&&"object"==typeof e)return e;const t="string"==typeof e?"wkt":"wkid";return{[t]:e}}get isWGS84(){return u(this)}get isWebMercator(){return c(this)}get isGeographic(){return y(this)}get isWrappable(){return h(this)}get metersPerUnit(){return s(this)}get unit(){return o(this)||(this.isGeographic?"degrees":null)}writeWkt(e,t){this.wkid||(t.wkt=e)}clone(){if(this===k.WGS84)return new k(m);if(this===k.WebMercator)return new k(d);const e=new k;return null!=this.wkid?(e.wkid=this.wkid,null!=this.latestWkid&&(e.latestWkid=this.latestWkid),null!=this.vcsWkid&&(e.vcsWkid=this.vcsWkid),null!=this.latestVcsWkid&&(e.latestVcsWkid=this.latestVcsWkid)):(null!=this.wkt&&(e.wkt=this.wkt),null!=this.wkt2&&(e.wkt2=this.wkt2)),this.imageCoordinateSystem&&(e.imageCoordinateSystem=r(this.imageCoordinateSystem)),null!=this.falseM&&(e.falseM=this.falseM),null!=this.falseX&&(e.falseX=this.falseX),null!=this.falseY&&(e.falseY=this.falseY),null!=this.falseZ&&(e.falseZ=this.falseZ),null!=this.mTolerance&&(e.mTolerance=this.mTolerance),null!=this.mUnits&&(e.mUnits=this.mUnits),null!=this.xyTolerance&&(e.xyTolerance=this.xyTolerance),null!=this.xyUnits&&(e.xyUnits=this.xyUnits),null!=this.zTolerance&&(e.zTolerance=this.zTolerance),null!=this.zUnits&&(e.zUnits=this.zUnits),e}equals(e){if(null==e)return!1;if(this.imageCoordinateSystem||e.imageCoordinateSystem){if(null==this.imageCoordinateSystem||null==e.imageCoordinateSystem)return!1;const{id:t,referenceServiceName:i}=e.imageCoordinateSystem,{geodataXform:r}=e.imageCoordinateSystem,s=this.imageCoordinateSystem;return null==t||r?JSON.stringify(s)===JSON.stringify(e.imageCoordinateSystem):i?s.id===t&&s.referenceServiceName===i:s.id===t}return f(this,e)}toJSON(e){return this.write(void 0,e)}};e([l({readOnly:!0})],S.prototype,"isWGS84",null),e([l({readOnly:!0})],S.prototype,"isWebMercator",null),e([l({readOnly:!0})],S.prototype,"isGeographic",null),e([l({readOnly:!0})],S.prototype,"isWrappable",null),e([l({type:n,json:{write:!0}})],S.prototype,"latestWkid",void 0),e([l({readOnly:!0})],S.prototype,"metersPerUnit",null),e([l({readOnly:!0})],S.prototype,"unit",null),e([l({type:n,json:{write:!0,origins:{"web-scene":{write:{overridePolicy(){return{isRequired:null==this.wkt}}}}}}})],S.prototype,"wkid",void 0),e([l({type:String,json:{origins:{"web-scene":{write:{overridePolicy(){return{isRequired:null==this.wkid}}}}}}})],S.prototype,"wkt",void 0),e([p("wkt"),p("web-scene","wkt")],S.prototype,"writeWkt",null),e([l({type:String,json:{write:!1}})],S.prototype,"wkt2",void 0),e([l({type:n,json:{write:!0}})],S.prototype,"vcsWkid",void 0),e([l({type:n,json:{write:!0}})],S.prototype,"latestVcsWkid",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"falseM",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"falseX",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"falseY",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"falseZ",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"mTolerance",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"mUnits",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"xyTolerance",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"xyUnits",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"zTolerance",void 0),e([l({type:Number,json:{write:!0}})],S.prototype,"zUnits",void 0),e([l()],S.prototype,"imageCoordinateSystem",void 0),S=k=e([a("esri.geometry.SpatialReference")],S),S.prototype.toJSON.isDefaultToJSON=!0,S.GCS_NAD_1927=t.freeze(new S({wkid:4267,wkt:'GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'})),S.WGS84=t.freeze(new S(m)),S.WebMercator=t.freeze(new S(d)),S.PlateCarree=t.freeze(new S(w));const g=["falseM","falseX","falseY","falseZ","mTolerance","mUnits","xyTolerance","xyUnits","zTolerance","zUnits"];export{S as default};