12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Logger.js";import{isNone as r}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as i}from"../core/accessorSupport/decorators/cast.js";import{reader as o}from"../core/accessorSupport/decorators/reader.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{writer as n}from"../core/accessorSupport/decorators/writer.js";import{ensureNumber as l}from"../core/accessorSupport/ensureType.js";import c from"./Geometry.js";import p from"./SpatialReference.js";import{offsetPoint as u}from"./support/offset.js";import{distance as h}from"./support/pointUtils.js";import{getInfo as d}from"./support/spatialReferenceUtils.js";import{lngLatToXY as m,xyToLngLat as y}from"./support/webMercatorUtils.js";var f;const g=[0,0];function x(e){return e&&("esri.geometry.SpatialReference"===e.declaredClass||null!=e.wkid)}const w=t.getLogger("esri.geometry.Point");let b=f=class extends c{constructor(...e){super(...e),this.x=0,this.y=0,this.z=void 0,this.m=void 0,this.type="point"}static copy(e,t){t._set("x",e._get("x")),t._set("y",e._get("y")),t._set("z",e._get("z")),t._set("m",e._get("m"));const r=e._get("spatialReference");t._set("spatialReference",Object.isFrozen(r)?r:r.clone())}normalizeCtorArgs(e,t,r,s,i){let o;if(Array.isArray(e))o=e,i=t,e=o[0],t=o[1],r=o[2],s=o[3];else if(e&&"object"==typeof e){if(o=e,e=null!=o.x?o.x:o.longitude,t=null!=o.y?o.y:o.latitude,r=o.z,s=o.m,(i=o.spatialReference)&&"esri.geometry.SpatialReference"!==i.declaredClass&&(i=new p(i)),null!=o.longitude||null!=o.latitude)if(null==o.longitude)w.warn(".longitude=","Latitude was defined without longitude");else if(null==o.latitude)w.warn(".latitude=","Longitude was defined without latitude");else if(!o.declaredClass&&i&&i.isWebMercator){const r=m(o.longitude,o.latitude,g);e=r[0],t=r[1]}}else x(r)?(i=r,r=null):x(s)&&(i=s,s=null);const a={x:e,y:t};return null==a.x&&null!=a.y?w.warn(".y=","Y coordinate was defined without an X coordinate"):null==a.y&&null!=a.x&&w.warn(".x=","X coordinate was defined without a Y coordinate"),null!=i&&(a.spatialReference=i),null!=r&&(a.z=r),null!=s&&(a.m=s),a}get cache(){return this.commitProperty("x"),this.commitProperty("y"),this.commitProperty("z"),this.commitProperty("m"),this.commitProperty("spatialReference"),{}}get hasM(){return void 0!==this.m}set hasM(e){e!==(void 0!==this._get("m"))&&(this._set("m",e?0:void 0),this._set("hasM",e))}get hasZ(){return void 0!==this.z}set hasZ(e){e!==(void 0!==this._get("z"))&&(this._set("z",e?0:void 0),this._set("hasZ",e))}get latitude(){const{spatialReference:e,x:t,y:r}=this;if(e){if(e.isWebMercator)return y(t,r,g)[1];if(e.isGeographic)return r}return null}set latitude(e){const{spatialReference:t,x:r}=this;t&&(t.isWebMercator?this._set("y",m(r,e,g)[1]):t.isGeographic&&this._set("y",e),this._set("latitude",e))}get longitude(){const{x:e,y:t,spatialReference:r}=this;if(r){if(r.isWebMercator)return y(e,t,g)[0];if(r.isGeographic)return e}return null}set longitude(e){const{y:t,spatialReference:r}=this;r&&(r.isWebMercator?this._set("x",m(e,t,g)[0]):r.isGeographic&&this._set("x",e),this._set("longitude",e))}writeX(e,t,r){t[r]=isNaN(e)?"NaN":e}readX(e){return"string"==typeof e?NaN:e}clone(){const e=new f;return e.x=this.x,e.y=this.y,e.z=this.z,e.m=this.m,e.spatialReference=this.spatialReference,e}copy(e){return f.copy(e,this),this}equals(e){if(r(e))return!1;const{x:t,y:s,z:i,m:o,spatialReference:a}=this,{z:n,m:l}=e;let{x:c,y:p,spatialReference:u}=e;if(!a.equals(u))if(a.isWebMercator&&u.isWGS84)[c,p]=m(c,p),u=a;else{if(!a.isWGS84||!u.isWebMercator)return!1;[c,p]=y(c,p),u=a}return t===c&&s===p&&i===n&&o===l&&a.wkid===u.wkid}offset(e,t,r){return u(this,e,t,r)}normalize(){if(!this.spatialReference)return this;const e=d(this.spatialReference);if(!e)return this;let t=this.x;const[r,s]=e.valid,i=2*s;let o;return t>s?(o=Math.ceil(Math.abs(t-s)/i),t-=o*i):t<r&&(o=Math.ceil(Math.abs(t-r)/i),t+=o*i),this._set("x",t),this}distance(e){return h(this,e)}toArray(){const e=this.hasZ,t=this.hasM;return e&&t?[this.x,this.y,this.z,this.m]:e?[this.x,this.y,this.z]:t?[this.x,this.y,this.m]:[this.x,this.y]}toJSON(e){return this.write({},e)}};e([s({readOnly:!0})],b.prototype,"cache",null),e([s({type:Boolean,json:{read:!1,write:{enabled:!1,overridePolicy:null}}})],b.prototype,"hasM",null),e([s({type:Boolean,json:{read:!1,write:{enabled:!1,overridePolicy:null}}})],b.prototype,"hasZ",null),e([s({type:Number})],b.prototype,"latitude",null),e([s({type:Number})],b.prototype,"longitude",null),e([s({type:Number,json:{type:[Number,String],write:{isRequired:!0,allowNull:!0}}}),i((e=>isNaN(e)?e:l(e)))],b.prototype,"x",void 0),e([n("x")],b.prototype,"writeX",null),e([o("x")],b.prototype,"readX",null),e([s({type:Number,json:{write:!0}})],b.prototype,"y",void 0),e([s({type:Number,json:{write:{overridePolicy(){return{enabled:this.hasZ}}}}})],b.prototype,"z",void 0),e([s({type:Number,json:{write:{overridePolicy(){return{enabled:this.hasM}}}}})],b.prototype,"m",void 0),b=f=e([a("esri.geometry.Point")],b),b.prototype.toJSON.isDefaultToJSON=!0;const j=b;export{j as default};
|