UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.98 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../Color.js";import{handlesGroup as i}from"../../core/handleUtils.js";import{isIterable as r}from"../../core/iteratorUtils.js";import{memoize as o}from"../../core/memoize.js";import{watch as n,on as s}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as l}from"../../core/units.js";import{property as a,subclass as c}from"../../core/accessorSupport/decorators.js";import{set as u}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../geometry/ellipsoidUtils.js";import{create as m,fromPoints as v}from"../../geometry/support/ray.js";import{GeometryDescriptor as y}from"../../layers/support/GeometryDescriptor.js";import{externalToInternalIntersectOptions as f}from"../../views/3d/support/hitTest.js";import{Intersector as h}from"../../views/3d/webgl-engine/lib/Intersector.js";import{toGraphic as w}from"../../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";import _ from"./ElevationProfileLine.js";const g=2e5;let b=class extends _{constructor(e){super(e),this.type="view",this.color=new t("#cf4ccf"),this.viewVisualizationEnabled=!0,this.include=null,this.exclude=null,this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependencies=o((e,t,i,r,o,n,s)=>({inputGraphicUid:null!=e?j(e):null,visibleLayers:t,maxIntersectionDistance:i,intersectOptions:r,view:o,stationary:n,spatialReference:s})),this._vecA=p(),this._vecB=p(),this._ray=m()}get minDemResolution(){const e=this._viewModel?.view;if(null==e||"3d"!==e.type)return null;const t=e.pointsOfInterest?.focus?.worldUnitsPerContentPixel;return null==t?null:t*l(e.spatialReference)}get queryElevationDependencies(){const e=this._view;return e?this._getQueryElevationDependencies(this._viewModel?.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}get _intersectOptions(){const e=this._view;if(null==e||e.destroyed)return{};return f(e,{include:this.include,exclude:[...this._pointCloudLayers,...r(this.exclude)?this.exclude:this.exclude?[this.exclude]:[]]})}get _pointCloudLayers(){const e=this._view;return null==e?[]:e.allLayerViews.toArray().filter(e=>"point-cloud"===e.layer?.type).map(e=>e.layer)}get _view(){const e=this._viewModel?.view;return null!=e&&"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return e?.renderCoordsHelper?d(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY}get _intersector(){const e=this._view;if(null==e)return null;const t=new h(e.state.viewingMode),i=t.options;return i.hud=!1,i.invisibleTerrain=!1,i.backfacesTerrain=!1,i.selectionMode=!1,i.store=2,t}async queryElevation(e,{noDataValue:t,signal:i}){const r=this.queryElevationDependencies;if(null==r)throw new Error("ElevationProfileLineInput: no dependencies");const o=this._intersector;if(null==o)throw new Error("ElevationProfileLineInput: no view");const{intersectOptions:n,view:s,spatialReference:l}=r,a=s.renderCoordsHelper,c=s.sceneIntersectionHelper,p=this._vecA,d=this._vecA,m=this._vecB,f=this._ray;if(!l)return{geometry:e,noDataValue:t};const h=await y.fromGeometry(e).project(l,i);if(!h)return{geometry:e,noDataValue:t};const w=h.coordinates,_=w.length;for(let y=0;y<_;++y){const e=w[y];u(m,e.x,e.y,e.z??0),a.toRenderCoords(m,l,m),a.setAltitude(p,g,m);const i=v(p,m,f);c.computeIntersection(i,o,!0,n);const s=I(r,o.results.all);s?(s.getIntersectionPoint(d),a.fromRenderCoords(d,d,l),e.z=d[2]):e.z=t}return{geometry:h.export(),noDataValue:t}}attach(e){const t=()=>this._onChange();return i([super.attach(e),n(()=>this.queryElevationDependencies,t),s(()=>e.elevationProvider,"elevation-change",t,{onListenerAdd:t,onListenerRemove:t})])}};function I({view:e,inputGraphicUid:t,maxIntersectionDistance:i},r){for(const o of r){if(!o.withinDistance(i))continue;const r=w(o,e);if(null==r||j(r)!==t)return o}return null}function j(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}e([a({type:t,nonNullable:!0})],b.prototype,"color",void 0),e([a()],b.prototype,"viewVisualizationEnabled",void 0),e([a()],b.prototype,"include",void 0),e([a()],b.prototype,"exclude",void 0),e([a({readOnly:!0})],b.prototype,"minDemResolution",null),e([a()],b.prototype,"queryElevationDependencies",null),e([a()],b.prototype,"_visibleLayers",null),e([a()],b.prototype,"_intersectOptions",null),e([a()],b.prototype,"_pointCloudLayers",null),e([a()],b.prototype,"_view",null),e([a()],b.prototype,"_maxIntersectionDistance",null),e([a()],b.prototype,"_intersector",null),b=e([c("esri.widgets.ElevationProfile.ElevationProfileLineView")],b);const x=b;export{x as default};