UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.49 kB
import e from"../../../core/Handles.js";import{applySome as t,destroyMaybe as i}from"../../../core/maybe.js";import{watch as o,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{ElevationProfileState as n}from"./constants.js";import{HoveredPoints as r}from"./HoveredPoints.js";import{InputRepresentation3D as h}from"./InputRepresentation3D.js";import{ProfileLines3D as p}from"./ProfileLines3D.js";class a{constructor(i,n){this._handles=new e,this._inputRepresentation=new h({view:i}),this._hoveredPoints=new r({view:i}),this._profileLines=new p({view:i}),this._handles.add([o((()=>n.viewModel.hoveredPoints),(e=>this._hoveredPoints.update(e)),s),o((()=>{const{state:e,editable:i,highlightEnabled:o,viewModel:s}=n,r=s.input;return t(r,(e=>{e.commitProperty("geometry"),e.commitProperty("layer")})),{input:r,state:e,editable:i,highlightEnabled:o}}),(e=>this._updateInputRepresentation(e)),s),o((()=>n.viewModel.chartData),(e=>this._profileLines.update(e)),s),o((()=>t(n.viewModel.input,(e=>e.geometry))),(()=>{this._profileLines.remove()}),s)])}destroy(){this._handles=i(this._handles),this._inputRepresentation=i(this._inputRepresentation),this._hoveredPoints=i(this._hoveredPoints),this._profileLines=i(this._profileLines)}_updateInputRepresentation({input:e,state:t,editable:i,highlightEnabled:o}){const s=this._inputRepresentation;if(!o)return s.remove();t===n.Selected?s.showHighlight(e):t!==n.Created||i?s.remove():s.showReshaping(e)}}export{a as ElevationProfileView3D};