UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.96 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{dedupeResult as t}from"../../../../core/dedupeResult.js";import{isIterable as r}from"../../../../core/iteratorUtils.js";import{equalsShallow as i}from"../../../../core/lang.js";import{equalsMaybe as o}from"../../../../core/maybe.js";import{notDeepEqual as n}from"../../../../core/object.js";import{watch as s,sync as l}from"../../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as a}from"../../../../core/units.js";import{property as c,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{set as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../../../geometry/ellipsoidUtils.js";import{create as y,fromPoints as f}from"../../../../geometry/support/ray.js";import{GeometryDescriptor as h}from"../../../../layers/support/GeometryDescriptor.js";import{externalToInternalIntersectOptions as v,testGraphicUidFilter as _}from"../../support/hitTest.js";import{Intersector as g}from"../../webgl-engine/lib/Intersector.js";import{toGraphic as w}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{getVisibleLayerIds as b}from"../../../analysis/ElevationProfile/elevationProfileLayerUtils.js";import{ElevationProfileLineComputation as I}from"../../../analysis/ElevationProfile/ElevationProfileLineComputation.js";const j=2e5;let D=class extends I{constructor(){super(...arguments),this.type="scene",this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getStableElevationDependencies=t(()=>{const e=this._view;return e?.ready?{view:e,stationary:e.stationary,geometry:this.controller?.analysis.geometry,visibleLayerIds:this._getStableLayerIds(),maxIntersectionDistance:this._maxIntersectionDistance,intersectOptions:this._getStableIntersectOptions(),spatialReference:this._getStableSpatialReference()}:null},i),this._getStableSpatialReference=t(()=>this._view?.spatialReference,o),this._getStableLayerIds=t(()=>b(this._view),i),this._getStableIntersectOptions=t(()=>{const e=this._view;if(!e?.ready)return{};const{include:t,exclude:i}=this.profile;return v(e,{include:t,exclude:[...this._pointCloudLayers,...r(i)?i:i?[i]:[]]})},(e,t)=>!n(e,t)),this._getStablePointCloudLayers=t(()=>{const e=this._view;return e?.ready?e.allLayerViews.toArray().filter(e=>"point-cloud"===e.layer?.type).map(e=>e.layer):[]},i),this._vecA=m(),this._vecB=m(),this._ray=y()}get minDemResolution(){const e=this._view;if(!e?.ready)return null;const t=e.pointsOfInterest?.focus?.worldUnitsPerContentPixel;return null==t?null:t*a(e.spatialReference)}initialize(){const e=()=>this.onInvalidate(this);return this.addHandles([s(()=>this._queryElevationDependencies,e,l),this.controller.onElevationChange(e)])}async queryElevation(e,{noDataValue:t,signal:r}){const i=this._queryElevationDependencies;if(null==i)throw new Error(`${this.declaredClass}: no dependencies`);const o=this._intersector;if(null==o)throw new Error(`${this.declaredClass}: no view`);const{intersectOptions:n,view:s,spatialReference:l}=i,a=s.renderCoordsHelper,c=s.sceneIntersectionHelper,p=this._vecA,m=this._vecA,d=this._vecB,y=this._ray;if(!l)return{geometry:e,noDataValue:t};const v=await h.fromGeometry(e).project(l,r);if(!v)return{geometry:e,noDataValue:t};const _=v.coordinates,g=_.length;for(let h=0;h<g;++h){const e=_[h];u(d,e.x,e.y,e.z??0),a.toRenderCoords(d,l,d),a.setAltitude(p,j,d);const r=f(p,d,y);c.computeIntersection(r,o,!0,n);const s=C(i,o.results.all);s?(s.getIntersectionPoint(m),a.fromRenderCoords(m,m,l),e.z=m[2]):e.z=t}return{geometry:v.export(),noDataValue:t}}get _queryElevationDependencies(){return this._getStableElevationDependencies()}get _pointCloudLayers(){return this._getStablePointCloudLayers()}get _view(){const e=this.controller.view;return"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return e?.ready&&e.renderCoordsHelper?d(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY}get _intersector(){const e=this._view;if(!e?.ready)return null;const t=new g(e.state.viewingMode),r=t.options;return r.hud=!1,r.invisibleTerrain=!1,r.backfacesTerrain=!1,r.selectionMode=!1,r.store=2,t}};function C({intersectOptions:e,maxIntersectionDistance:t,view:r},i){const o=e.graphics,n=!(!o?.include&&!o?.exclude);for(const s of i)if(s.withinDistance(t)){if(n){const e=w(s,r);if(null!=e&&!_(o,e))continue}return s}return null}e([c({readOnly:!0})],D.prototype,"minDemResolution",null),e([c()],D.prototype,"_queryElevationDependencies",null),e([c()],D.prototype,"_pointCloudLayers",null),e([c()],D.prototype,"_view",null),e([c()],D.prototype,"_maxIntersectionDistance",null),e([c()],D.prototype,"_intersector",null),D=e([p("esri.views.3d.analysis.ElevationProfile.ElevationProfileLineSceneComputation")],D);export{D as ElevationProfileLineSceneComputation};