ElevationProfileLineView.js 5.2 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import{handlesGroup as r}from"../../core/handleUtils.js";import{isNone as i,applySome as o,unwrapOr as n,isSome as s}from"../../core/maybe.js";import{memoize as l}from"../../core/memoize.js";import{watch as c,on as a}from"../../core/reactiveUtils.js";import{union as p}from"../../core/SetUtils.js";import{getMetersPerVerticalUnitForSR as u}from"../../core/unitUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{s as v}from"../../chunks/vec3.js";import{c as y}from"../../chunks/vec4f64.js";import{getReferenceEllipsoid as f}from"../../geometry/projectionEllipsoid.js";import{create as h,fromPoints as _}from"../../geometry/support/ray.js";import{GeometryDescriptor as w}from"../../layers/support/ElevationQuery.js";import{newIntersector as I}from"../../views/3d/webgl-engine/lib/Intersector.js";import{StoreResults as g}from"../../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{toGraphic as j}from"../../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";import b from"./ElevationProfileLine.js";const x=2e5;let E=class extends b{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=l(((e,t,r,i,o,n,l)=>({inputGraphicUid:s(e)?D(e):null,visibleLayers:t,maxIntersectionDistance:r,intersectOptions:i,view:o,stationary:n,spatialReference:l}))),this._vecA=y(),this._vecB=y(),this._ray=h()}get minDemResolution(){const e=this._viewModel?.view;if(i(e)||"3d"!==e.type)return null;const t=e.pointsOfInterest?.focus?.renderLocation;if(!t)return null;return e.state.camera.computeRenderPixelSizeAt(t)*u(e.spatialReference)}get queryElevationDependencies(){return o(this._view,(e=>this._getQueryElevationDependencies(this._viewModel.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference)))}get _visibleLayers(){const e=this._view,t=o(e,(e=>e.map?.allLayers?.filter((e=>e.visible)).toArray()));return n(t,[])}get _intersectOptions(){const e=this._view;if(i(e))return{};const t=e.externalToInternalIntersectOptions({include:this.include,exclude:this.exclude}),r=e.externalToInternalIntersectOptions({exclude:this._pointCloudLayers});return t.exclude=p(t.exclude,r.exclude),t}get _pointCloudLayers(){const e=this._view;return i(e)?[]:e.allLayerViews.toArray().filter((e=>"point-cloud"===e.layer?.type)).map((e=>e.layer))}get _view(){const e=this._viewModel.view;return s(e)&&"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return i(e)||!e.renderCoordsHelper?Number.POSITIVE_INFINITY:f(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters}get _intersector(){const e=this._view;if(i(e))return null;const t=I(e.state.viewingMode),r=t.options;return r.hud=!1,r.invisibleTerrain=!1,r.backfacesTerrain=!1,r.selectionMode=!1,r.store=g.ALL,t}async queryElevation(e,{noDataValue:t,signal:r}){const o=this.queryElevationDependencies;if(i(o))throw new Error("ElevationProfileLineInput: no dependencies");const n=this._intersector;if(i(n))throw new Error("ElevationProfileLineInput: no view");const{intersectOptions:s,view:l,spatialReference:c}=o,a=l.renderCoordsHelper,p=l.sceneIntersectionHelper,u=this._vecA,d=this._vecA,m=this._vecB,y=this._ray,f=await w.fromGeometry(e).project(c,r),h=f.coordinates,I=h.length;for(let i=0;i<I;++i){const e=h[i];v(m,e.x,e.y,e.z??0),a.toRenderCoords(m,c,m),a.setAltitude(u,x,m);const r=_(u,m,y);p.computeIntersection(r,n,s);const l=L(o,n.results.all);l?(l.getIntersectionPoint(d),a.fromRenderCoords(d,d,c),e.z=d[2]):e.z=t}return{geometry:f.export(),noDataValue:t}}attach(e){const t=()=>this._onChange();return r([super.attach(e),c((()=>this.queryElevationDependencies),t),a((()=>e.elevationProvider),"elevation-change",t,{onListenerAdd:t,onListenerRemove:t})])}};function L({view:e,inputGraphicUid:t,maxIntersectionDistance:r},o){for(const n of o){if(n.distanceInRenderSpace>r)continue;const o=j(n,e);if(i(o)||D(o)!==t)return n}return null}function D(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([d({type:t,nonNullable:!0})],E.prototype,"color",void 0),e([d()],E.prototype,"viewVisualizationEnabled",void 0),e([d()],E.prototype,"include",void 0),e([d()],E.prototype,"exclude",void 0),e([d({readOnly:!0})],E.prototype,"minDemResolution",null),e([d()],E.prototype,"queryElevationDependencies",null),e([d()],E.prototype,"_visibleLayers",null),e([d()],E.prototype,"_intersectOptions",null),e([d()],E.prototype,"_pointCloudLayers",null),e([d()],E.prototype,"_view",null),e([d()],E.prototype,"_maxIntersectionDistance",null),e([d()],E.prototype,"_intersector",null),E=e([m("esri.widgets.ElevationProfile.ElevationProfileLineView")],E);const C=E;export{C as default};