elevationInfoUtils.js 3.2 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{isNone as e,isSome as t,unwrapOr as n}from"../core/maybe.js";import{getMetersPerUnit as o}from"../symbols/support/unitConversionUtils.js";function r(e){return e?E:Z}function u(t,n){return e(n)||!n.mode?r(t).mode:n.mode}function s(e,n){return t(n)?n:r(e)}function i(e,n){return u(!!t(e)&&e.hasZ,n)}function a(e,n){return s(!!t(e)&&e.hasZ,n)}function l(e){const t=v(e);return i(e.geometry,t)}function f(e){const r=v(e),u=i(e.geometry,r);return{mode:u,offset:t(r)&&"on-the-ground"!==u?n(r.offset,0)*o(n(r.unit,"meters")):0}}function c(e){if("on-the-ground"===l(e))return!1;const n=v(e),o=t(n)&&n.featureExpressionInfo?n.featureExpressionInfo.expression:null;return!(!o||"0"===o)}function v(e){return e.layer&&"elevationInfo"in e.layer?e.layer.elevationInfo:null}function d(o,r,u){if(e(u)||!u.mode)return;const s=o.hasZ?o.z:0,i=t(u.offset)?u.offset:0;switch(u.mode){case"absolute-height":return s-i;case"on-the-ground":return 0;case"relative-to-ground":return s-(n(r.elevationProvider.getElevation(o.x,o.y,o.z,o.spatialReference,"ground"),0)+i);case"relative-to-scene":return s-(n(r.elevationProvider.getElevation(o.x,o.y,o.z,o.spatialReference,"scene"),0)+i)}}function g(e,t,n,o=null){return m(e,t.x,t.y,t.hasZ?t.z:0,t.spatialReference,n,o)}function h(e,t,n,o,r=null){return m(e,t[0],t[1],t.length>2?t[2]:0,n,o,r)}function m(n,o,r,u,s,i,a=null){if(e(i))return;const l=t(a)?a.mode:"absolute-height";if("on-the-ground"===l)return 0;const{absoluteZ:f}=b(o,r,u,s,n,i);return p(f,o,r,u,s,n,a,l)}function b(e,o,r,u,s,i){const a=t(i.offset)?i.offset:0;switch(i.mode){case"absolute-height":return{absoluteZ:r+a,elevation:0};case"on-the-ground":{const t=n(s.elevationProvider.getElevation(e,o,0,u,"ground"),0);return{absoluteZ:t,elevation:t}}case"relative-to-ground":{const t=n(s.elevationProvider.getElevation(e,o,r,u,"ground"),0);return{absoluteZ:r+t+a,elevation:t}}case"relative-to-scene":{const t=n(s.elevationProvider.getElevation(e,o,r,u,"scene"),0);return{absoluteZ:r+t+a,elevation:t}}}}function p(e,o,r,u,s,i,a,l){const f=t(a)&&t(a.offset)?a.offset:0;switch(l){case"absolute-height":return e-f;case"relative-to-ground":return e-(n(i.elevationProvider.getElevation(o,r,u,s,"ground"),0)+f);case"relative-to-scene":return e-(n(i.elevationProvider.getElevation(o,r,u,s,"scene"),0)+f)}}function y(n,o){if(e(o))return!1;const{mode:r}=o;return t(r)&&("scene"===n&&"relative-to-scene"===r||"ground"===n&&"absolute-height"!==r)}const E={mode:"absolute-height",offset:0},Z={mode:"on-the-ground",offset:null};function x(e,n){return e===n||t(e)&&t(n)&&e.mode===n.mode&&e.offset===n.offset}export{E as absoluteHeightElevationInfo,y as elevationContextAffectsAlignment,x as elevationInfoLikeEquals,g as getConvertedElevation,h as getConvertedElevationFromVector,s as getEffectiveElevationInfo,u as getEffectiveElevationMode,a as getGeometryEffectiveElevationInfo,i as getGeometryEffectiveElevationMode,f as getGraphicEffectiveElevationInfo,l as getGraphicEffectiveElevationMode,d as getZForElevationMode,c as hasGraphicFeatureExpressionInfo,Z as onTheGroundElevationInfo,b as zValueInAbsoluteHeightMode};