UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.55 kB
import{l as e,d as t,c as r,o as a}from"../../chunks/vec2.js";import{a as n,f as s,b as i}from"../../chunks/vec2f64.js";import{s as o,h as u,i as c,c as h,F as p}from"../../chunks/vec3.js";import{c as v,f as y,d as l}from"../../chunks/vec3f64.js";import{l as d,c as f,h as T}from"../../chunks/vec4.js";import{c as Z,f as _,b as m}from"../../chunks/vec4f64.js";import g from"../../geometry/Point.js";var R;!function(e){e[e.Z=0]="Z",e[e.M=1]="M"}(R||(R={}));class x{constructor(e){this.spatialReference=e}createVector(){return this._tag(n())}pointToVector(e){return this._tag(s(e.x,e.y))}arrayToVector(e){return this._tag(s(e[0],e[1]))}vectorToArray(e){return[e[0],e[1]]}pointToArray(e){return[e.x,e.y]}vectorToPoint(e,t=new g){return t.x=e[0],t.y=e[1],t.z=void 0,t.m=void 0,t.spatialReference=this.spatialReference,t}arrayToPoint(e,t=new g){return t.x=e[0],t.y=e[1],t.z=void 0,t.m=void 0,t.spatialReference=this.spatialReference,t}vectorToDehydratedPoint(e,t={x:void 0,y:void 0,z:void 0,m:void 0,hasZ:void 0,hasM:void 0,spatialReference:void 0,type:"point"}){return t.x=e[0],t.y=e[1],t.z=void 0,t.m=void 0,t.hasZ=!1,t.hasM=!1,t.spatialReference=this.spatialReference,t}lerp(t,r,a,n){return e(n,t,r,a)}addDelta(e,t,r){e[0]+=t,e[1]+=r}distance(e,r){return t(e,r)}getZ(e,t){return t}hasZ(){return!1}getM(e,t){return t}hasM(){return!1}clone(e){return this._tag(i(e))}copy(e,t){return r(t,e)}fromXYZ(e){return this._tag(s(e[0],e[1]))}toXYZ(e,t=v()){return o(t,e[0],e[1],0)}pointToXYZ(e,t=v()){return o(t,e.x,e.y,0)}equals(e,t){return a(e,t)}_tag(e){return e}}class M{constructor(e,t){this._valueType=e,this.spatialReference=t}createVector(){return this._tag(v())}pointToVector(e){return this._tag(y(e.x,e.y,this._valueType===R.Z?e.z:e.m))}arrayToVector(e){return this._tag(y(e[0],e[1],e[2]||0))}vectorToArray(e){return[e[0],e[1],e[2]]}pointToArray(e){return this._valueType===R.Z?[e.x,e.y,e.z]:[e.x,e.y,e.m]}vectorToPoint(e,t=new g){return t.x=e[0],t.y=e[1],t.z=this._valueType===R.Z?e[2]:void 0,t.m=this._valueType===R.M?e[2]:void 0,t.spatialReference=this.spatialReference,t}arrayToPoint(e,t=new g){return t.x=e[0],t.y=e[1],t.z=this._valueType===R.Z?e[2]:void 0,t.m=this._valueType===R.M?e[2]:void 0,t.spatialReference=this.spatialReference,t}vectorToDehydratedPoint(e,t={x:void 0,y:void 0,z:void 0,m:void 0,hasZ:void 0,hasM:void 0,spatialReference:void 0,type:"point"}){const r=this._valueType===R.Z,a=this._valueType===R.M;return t.x=e[0],t.y=e[1],t.z=r?e[2]:void 0,t.m=a?e[2]:void 0,t.hasZ=r,t.hasM=a,t.spatialReference=this.spatialReference,t}lerp(e,t,r,a){return u(a,e,t,r)}addDelta(e,t,r,a){e[0]+=t,e[1]+=r,this._valueType===R.Z&&(e[2]+=a)}distance(e,r){return this._valueType===R.Z?c(e,r):t(e,r)}getZ(e,t){return this._valueType===R.Z?e[2]:t}hasZ(){return this._valueType===R.Z}getM(e,t){return this._valueType===R.M?e[2]:t}hasM(){return this._valueType===R.M}clone(e){return this._tag(l(e))}copy(e,t){return h(t,e)}fromXYZ(e,t=0,r=0){return this._tag(y(e[0],e[1],this._valueType===R.Z?e.length>2?e[2]:t:r))}toXYZ(e,t=v()){return o(t,e[0],e[1],this._valueType===R.Z?e[2]:0)}pointToXYZ(e,t=v()){return o(t,e.x,e.y,this._valueType===R.Z?e.z??0:0)}equals(e,t){return p(e,t)}_tag(e){return e}}class z{constructor(e){this.spatialReference=e}createVector(){return this._tag(Z())}pointToVector(e){return this._tag(_(e.x,e.y,e.z,e.m))}arrayToVector(e){return this._tag(_(e[0],e[1],e[2]||0,e[3]||0))}vectorToArray(e){return[e[0],e[1],e[2],e[3]]}pointToArray(e){return[e.x,e.y,e.z,e.m]}vectorToPoint(e,t=new g){return t.x=e[0],t.y=e[1],t.z=e[2],t.m=e[3],t.spatialReference=this.spatialReference,t}arrayToPoint(e,t=new g){return t.x=e[0],t.y=e[1],t.z=e[2],t.m=e[3],t.spatialReference=this.spatialReference,t}vectorToDehydratedPoint(e,t={x:void 0,y:void 0,z:void 0,m:void 0,hasZ:void 0,hasM:void 0,spatialReference:void 0,type:"point"}){return t.x=e[0],t.y=e[1],t.z=e[2],t.m=e[3],t.hasZ=!0,t.hasM=!0,t.spatialReference=this.spatialReference,t}lerp(e,t,r,a){return d(a,e,t,r)}addDelta(e,t,r,a){e[0]+=t,e[1]+=r,e[2]+=a}distance(e,t){return c(e,t)}getZ(e){return e[2]}hasZ(){return!0}getM(e){return e[3]}hasM(){return!0}clone(e){return this._tag(m(e))}copy(e,t){return f(t,e)}fromXYZ(e,t=0,r=0){return this._tag(_(e[0],e[1],e.length>2?e[2]:t,r))}toXYZ(e,t=v()){return o(t,e[0],e[1],e[2])}pointToXYZ(e,t=v()){return o(t,e.x,e.y,e.z??0)}equals(e,t){return T(e,t)}_tag(e){return e}}function w(e,t,r){return e&&t?new z(r):t?new M(R.M,r):e?new M(R.Z,r):new x(r)}export{x as CoordinateHelper2D,M as CoordinateHelper3D,z as CoordinateHelper4D,w as createCoordinateHelper};