@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.4 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import s from"../../../core/Accessor.js";import o from"../../../core/Handles.js";import{isNone as r,unwrapOr as i,isSome as a}from"../../../core/maybe.js";import{watch as l,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{throttle as c}from"../../../core/throttle.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{b as m}from"../../../chunks/vec4f64.js";import f from"../../../geometry/Polyline.js";import{OutlineVisualElement as d}from"../../../views/3d/interactive/visualElements/OutlineVisualElement.js";import{getConfig as u}from"./constants.js";const v=100;let y=class extends s{constructor(e){super(e),this._chartData=null,this._visualElements=[],this._handles=new o}initialize(){const e=c((e=>{this._update(e)}),v);this._handles.add([l((()=>({spatialReference:this.view.spatialReference,chartData:this._chartData})),e,n),e])}destroy(){this._handles.destroy(),this._destroyVisualElements()}remove(){this._destroyVisualElements()}update(e){this._chartData=e}_update(e){const{chartData:s}=e;if(r(s))return this.remove();if(!s.refined)return;const o=this._visualElements,i=s.lines.filter((e=>e.viewVisualizationEnabled)),a=i.length;for(;o.length>a;)o.pop().destroy();const l=u().profileLinesStyle3D;for(;o.length<a;){const e=new d({view:this.view,elevationInfo:{mode:"absolute-height",offset:0},innerWidth:l.width-l.outlineSize,width:l.width,falloff:l.falloff,color:l.outlineColor,renderOccluded:l.renderOccluded});o.push(e)}const n=e.spatialReference;for(let r=0;r<a;++r){const e=o[r],s=i[a-1-r];e.geometry=this._createLineGeometry(s,n),e.innerColor=m(t.toUnitRGBA(s.color))}}_createLineGeometry(e,t){const s=i(e.samples,[]),o=s.length-1,l=[];let n=[];for(let i=0;i<=o;i++){const{x:e,y:t,z:c}=s[i];a(c)&&n.push([e,t,c]),(i===o||r(c))&&n.length&&(l.push(n),n=[])}return new f({paths:l,hasZ:!0,spatialReference:t})}_destroyVisualElements(){this._visualElements.forEach((e=>e.destroy())),this._visualElements.length=0}};e([h()],y.prototype,"view",void 0),e([h()],y.prototype,"_chartData",void 0),y=e([p("esri.widgets.ElevationProfile.support.ProfileLines3D")],y);export{y as ProfileLines3D};