UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.29 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{open as e}from"../../../core/workers/workers.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../ray.js";import{intersectRay as n}from"../triangle.js";import o from"./ElevationSamplerWorker.js";import{ElevationSamplerBase as a}from"../../../layers/support/ElevationSampler.js";async function i(e,t){const r=await l(),n=await u.createIndex(e,r);return m(r),new s(e,n,t)}class s extends a{constructor(e,t,r){super(),this._rindex=t,this.demResolution={min:0,max:0},this.spatialReference=e.spatialReference.clone(),this.extent=e.extent.clone(),this.noDataValue=r?.noDataValue||0}elevationAt(e,t){let o=Number.NEGATIVE_INFINITY;return r([e,t,0],[0,0,-1],I),this._rindex.search({minX:e,maxX:e,minY:t,maxY:t},(e=>{n(e,I,N)&&N[2]>o&&(o=N[2])})),o===Number.NEGATIVE_INFINITY?this.noDataValue:o}}function l(){return++p,c(),f||(f=e("ElevationSamplerWorker").catch((()=>null)),f)}function m(e){--p,null!=e&&0===p&&(x=setTimeout((()=>{e.close(),f=null,x=0}),h))}function c(){x&&(clearTimeout(x),x=0)}const u=new o;let p=0,f=null,x=0;const h=1e4,I=r([0,0,0],[0,0,-1]),N=t();export{i as create};