UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.54 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../core/Evented.js";import r from"../../core/Logger.js";import{subclass as o}from"../../core/accessorSupport/decorators.js";import s from"../../geometry/Point.js";import{project as n}from"../../geometry/support/webMercatorUtils.js";let i=class extends t{queryElevation(e){const t=this.projectIfRequired(e,this.spatialReference);if(!t)return null;switch(e.type){case"point":return a(e,t,this);case"polyline":return l(e,t,this);case"multipoint":return p(e,t,this);default:return null}}projectIfRequired(e,t){if(null==e)return null;const o=e.spatialReference;if(o.equals(t))return e;const s=n(e,t);return s||r.getLogger(this).error(`Cannot project geometry spatial reference (wkid:${o.wkid}) to elevation sampler spatial reference (wkid:${t.wkid})`),s}};function a(e,t,r){return e.hasZ=!0,e.z=r.elevationAt(t.x,t.y),e}function l(e,t,r){c.spatialReference=t.spatialReference;const o=e.hasM&&!e.hasZ;for(let s=0;s<e.paths.length;s++){const n=e.paths[s],i=t.paths[s];for(let e=0;e<n.length;e++){const t=n[e],s=i[e];c.x=s[0],c.y=s[1],o&&(t[3]=t[2]),t[2]=r.elevationAt(c.x,c.y)}}return e.hasZ=!0,e}function p(e,t,r){c.spatialReference=t.spatialReference;const o=e.hasM&&!e.hasZ;for(let s=0;s<e.points.length;s++){const n=e.points[s],i=t.points[s];c.x=i[0],c.y=i[1],o&&(n[3]=n[2]),n[2]=r.elevationAt(c.x,c.y)}return e.hasZ=!0,e}i=e([o("esri.layers.support.ElevationSampler")],i);const c=new s;export{i as default};