@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.64 kB
JavaScript
import"../../../geometry.js";import{isSome as t,filterNones as r}from"../../../core/maybe.js";import{c as e}from"../../../chunks/mat2d.js";import{c as s,a}from"../../../chunks/mat2df64.js";import{r as o,i}from"../../../chunks/quat.js";import{a as n}from"../../../chunks/quatf64.js";import{g as l,e as h,b as m,n as c,f,q as p}from"../../../chunks/vec3.js";import{c as d}from"../../../chunks/vec3f64.js";import{Axis as u}from"../../../geometry/support/Axis.js";import w from"../../../geometry/Point.js";function g(r,e,s=null){return t(s)?[r,e,s]:[r,e]}function R(r,e,s=null){return t(s)?{x:r,y:e,z:s}:{x:r,y:e}}class W{constructor(t){this.spatialReference=t}mapToLocalMultiple(t){return r(t.map((t=>this.mapToLocal(t))))}get doUnnormalization(){return!1}}class v extends W{constructor(t,r,o=null){super(r),this._defaultZ=o,this.transform=s(),this.transformInv=s(),this.transform=a(t),e(this.transformInv,this.transform)}makeMapPoint(t,r){return g(t,r,this._defaultZ)}mapToLocal(t){return R(this.transform[0]*t[0]+this.transform[2]*t[1]+this.transform[4],this.transform[1]*t[0]+this.transform[3]*t[1]+this.transform[5])}localToMap(t){return g(this.transformInv[0]*t.x+this.transformInv[2]*t.y+this.transformInv[4],this.transformInv[1]*t.x+this.transformInv[3]*t.y+this.transformInv[5],this._defaultZ)}}class F extends W{constructor(t,r){super(t.spatialReference),this.view=t,this.defaultZ=null,this.pWS=d(),this.tangentFrameUpWS=d(),this.tangentFrameRightWS=d(),this.tangentFrameForwardWS=d(),this.localFrameRightWS=d(),this.localFrameUpWS=d(),this.worldToLocalTransform=n(),this.localToWorldTransform=n(),this.scale=1,this.scale=t.resolution,this.referenceMapPoint=r,this.defaultZ=r.hasZ?r.z:null;const e=t.state.camera.viewRight;this.view.renderCoordsHelper.toRenderCoords(this.referenceMapPoint,this.pWS),this.view.renderCoordsHelper.worldBasisAtPosition(this.pWS,u.X,this.tangentFrameRightWS),this.view.renderCoordsHelper.worldBasisAtPosition(this.pWS,u.Y,this.tangentFrameUpWS),this.view.renderCoordsHelper.worldBasisAtPosition(this.pWS,u.Z,this.tangentFrameForwardWS);const s=d();l(s,this.tangentFrameForwardWS,h(e,this.tangentFrameForwardWS)),m(this.localFrameRightWS,e,s),c(this.localFrameRightWS,this.localFrameRightWS),f(this.localFrameUpWS,this.tangentFrameForwardWS,this.localFrameRightWS),o(this.worldToLocalTransform,this.localFrameRightWS,this.tangentFrameRightWS),i(this.localToWorldTransform,this.worldToLocalTransform)}get doUnnormalization(){return"global"===this.view.viewingMode}makeMapPoint(t,r){return g(t,r,this.defaultZ)}mapToLocal(r){const e=d();this.view.renderCoordsHelper.toRenderCoords(new w({x:r[0],y:r[1],spatialReference:this.spatialReference}),e),p(e,e,this.worldToLocalTransform);const s=this.view.renderCoordsHelper.fromRenderCoords(e,this.view.spatialReference);return t(s)?R(s.x/this.scale,s.y/this.scale):null}localToMap(r){const e=d();this.view.renderCoordsHelper.toRenderCoords(new w({x:r.x*this.scale,y:r.y*this.scale,spatialReference:this.spatialReference}),e),p(e,e,this.localToWorldTransform);const s=this.view.renderCoordsHelper.fromRenderCoords(e,this.view.spatialReference);return t(s)?g(s.x,s.y,this.defaultZ):null}}function S(t,r){if("2d"===t.type)return new v(t.state.transform,t.spatialReference,r.length>2?r[2]:null);if("3d"===t.type){const e=r.length>2?new w({x:r[0],y:r[1],z:r[2],spatialReference:t.spatialReference}):new w({x:r[0],y:r[1],spatialReference:t.spatialReference});return new F(t,e)}return null}export{v as AffineCoordinateSystem,F as SceneViewCoordinateSystem,W as SurfaceCoordinateSystem,S as createViewAlignedCoordinateSystem,g as makeMapPoint,R as makeSurfacePoint};