@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 4.37 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as o}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as r}from"../../../../geometry/projection/projectBuffer.js";import{isDehydratedPoint as i}from"../../../../layers/graphics/dehydratedFeatureUtils.js";import{isSamplePosition as a,getElevationAtPoint as s}from"../../support/ElevationProvider.js";function l(e,t,n,o,i,a,s,l,c,u,f){const d=b[f.mode];let m,g,p=0;if(r(e,t,n,o,c.spatialReference,i,l))return d?.requiresAlignment(f)?(p=d.applyElevationAlignmentBuffer(o,i,a,s,l,c,u,f),m=a,g=s):(m=o,g=i),r(m,c.spatialReference,g,a,u.spatialReference,s,l)?p:void 0}function c(e,t,n,o,r){const l=(i(e)?e.z:a(e)?e.array[e.offset+2]:e[2])||0;switch(n.mode){case"on-the-ground":{const n=s(t,e,"ground")??0;return r.verticalDistanceToGround=0,r.sampledElevation=n,void(r.z=n)}case"relative-to-ground":{const i=s(t,e,"ground")??0,a=n.geometryZWithOffset(l,o);return r.verticalDistanceToGround=a,r.sampledElevation=i,void(r.z=a+i)}case"relative-to-scene":{const i=s(t,e,"scene")??0,a=n.geometryZWithOffset(l,o);return r.verticalDistanceToGround=a,r.sampledElevation=i,void(r.z=a+i)}case"absolute-height":{const i=n.geometryZWithOffset(l,o),a=s(t,e,"ground")??0;return r.verticalDistanceToGround=i-a,r.sampledElevation=a,void(r.z=i)}default:return void(r.z=0)}}function u(e,t,n,o){return c(e,t,n,o,j),j.z}function f(e,t,n){return"on-the-ground"===t&&"on-the-ground"===n?e.staysOnTheGround:t===n||"on-the-ground"!==t&&"on-the-ground"!==n?null==t||null==n?e.definedChanged:1:e.onTheGroundChanged}function d(e){return"relative-to-ground"===e||"relative-to-scene"===e}function m(e){return"absolute-height"!==e}function g(t,n,r,i,a){c(n,r,a,i,j),p(t,j.verticalDistanceToGround);const s=j.sampledElevation,l=e(R,t.transformation);O[0]=n.x,O[1]=n.y,O[2]=j.z;return o(n.spatialReference,O,l,i.spatialReference)?t.transformation=l:console.warn("Could not locate symbol object properly, it might be misplaced"),s}function p(e,t){for(let n=0;n<e.geometries.length;++n){const o=e.geometries[n].getMutableAttribute("centerOffsetAndDistance");o&&o.data[3]!==t&&(o.data[3]=t,e.geometryVertexAttributeUpdated(e.geometries[n],"centerOffsetAndDistance"))}}function v(e,t,n,o,r,i){let a=0;const s=i.spatialReference;t*=3,o*=3;for(let l=0;l<r;++l){const r=e[t],l=e[t+1],c=e[t+2],u=i.getElevation(r,l,c,s,"ground")??0;a+=u,n[o]=r,n[o+1]=l,n[o+2]=u,t+=3,o+=3}return a/r}function h(e,t,n,o,r,i,a,s){let l=0;const c=s.calculateOffsetRenderUnits(a),u=s.featureExpressionInfoContext,f=i.spatialReference;t*=3,o*=3;for(let d=0;d<r;++d){const r=e[t],a=e[t+1],s=e[t+2],d=i.getElevation(r,a,s,f,"ground")??0;l+=d,n[o]=r,n[o+1]=a,n[o+2]=null==u?s+d+c:d+c,t+=3,o+=3}return l/r}function E(e,t,n,o,r,i,a,s){let l=0;const c=s.calculateOffsetRenderUnits(a),u=s.featureExpressionInfoContext,f=i.spatialReference;t*=3,o*=3;for(let d=0;d<r;++d){const r=e[t],a=e[t+1],s=e[t+2],d=i.getElevation(r,a,s,f,"scene")??0;l+=d,n[o]=r,n[o+1]=a,n[o+2]=null==u?s+d+c:d+c,t+=3,o+=3}return l/r}function y(e){const t=e.meterUnitOffset,n=e.featureExpressionInfoContext;return 0!==t||null!=n}function A(e,t,n,o,r,i,a,s){const l=s.calculateOffsetRenderUnits(a),c=s.featureExpressionInfoContext;t*=3,o*=3;for(let u=0;u<r;++u){const r=e[t],i=e[t+1],a=e[t+2];n[o]=r,n[o+1]=i,n[o+2]=null==c?a+l:l,t+=3,o+=3}return 0}class x{constructor(){this.verticalDistanceToGround=0,this.sampledElevation=0,this.z=0}}const b={"absolute-height":{applyElevationAlignmentBuffer:A,requiresAlignment:y},"on-the-ground":{applyElevationAlignmentBuffer:v,requiresAlignment:()=>!0},"relative-to-ground":{applyElevationAlignmentBuffer:h,requiresAlignment:()=>!0},"relative-to-scene":{applyElevationAlignmentBuffer:E,requiresAlignment:()=>!0}},R=t(),j=new x,O=n();export{x as SampleElevationInfo,g as applyElevationAlignmentForHUD,l as applyPerVertexElevationAlignment,f as elevationModeChangeUpdateType,u as evaluateElevationAlignmentAtPoint,c as evaluateElevationInfoAtPoint,d as needsElevationUpdates2D,m as needsElevationUpdates3D,p as updateVertexPointGroundDistance};