@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.38 kB
JavaScript
import{_ as t}from"../../../../chunks/tslib.es6.js";import{LengthDimensionMeasureType as e}from"../../../../analysis/dimensionUtils.js";import s from"../../../../core/Accessor.js";import o from"../../../../core/Handles.js";import r from"../../../../core/Logger.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as n,syncAndInitial as a}from"../../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../../core/unitUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{getDefaultUnitForView as p}from"../../../../support/getDefaultUnitForView.js";import{isGeodesicDimension as c,GEODESIC_DISTANCE_THRESHOLD as u,computeGeometryFromDimension as h,computeLength as y,computationToGeometryDependencies as f}from"./lengthDimensionUtils.js";let g=class extends s{constructor(t){super(t),this._handles=new o}initialize(){const{computations:t}=this.analysisViewData;for(const e of t)this._addComputation(e);this.addHandles(t.on("change",(({added:t,removed:e})=>{for(const s of e)this._removeComputation(s);for(const s of t)this._addComputation(s)})))}destroy(){this._handles=i(this._handles)}get analysis(){return this.analysisViewData.analysis}get _defaultUnit(){return p(this.view)}_addComputation(t){this._handles.has(t)||this._handles.add(n((()=>f(t)),(s=>{const{measureType:o}=s;if(c(s)&&o!==e.Direct){const e=Math.round(l(u,"meters","kilometers"));return r.getLogger(this.declaredClass).warnOnce(`A ${o} dimension in the analysis (id: '${this.analysis.id}') will not display, because only direct dimensions can measure lengths greater than ${e} km. Update the measureType of the affected dimension to "direct" to display it.`),void(t.geometry=null)}const i=h(s,this.view.renderCoordsHelper,t.geometry);t.geometry=i,t.result.length=y(i,o,this._defaultUnit)}),a),t)}_removeComputation(t){this._handles.remove(t)}};t([m({constructOnly:!0})],g.prototype,"analysisViewData",void 0),t([m({constructOnly:!0})],g.prototype,"view",void 0),t([m()],g.prototype,"analysis",null),t([m()],g.prototype,"_defaultUnit",null),g=t([d("esri.views.3d.analysis.Dimension.support.DimensionController")],g);export{g as DimensionController};