@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.37 kB
JavaScript
import{isSome as e}from"../../../core/maybe.js";import{k as t}from"../../../chunks/vec2.js";import{absoluteHeightElevationInfo as s}from"../../../support/elevationInfoUtils.js";import{defaults as r}from"./Settings.js";import{anyMapPointToSnappingPoint as i}from"./SnappingPoint.js";import{squaredScreenDistance as o}from"./snappingUtils.js";import{vectorToScreenPoint as h}from"../support/viewUtils.js";class n{constructor(e,t){this.view=e,this.options=t,this.squaredShortLineThreshold=r.shortLineThreshold*r.shortLineThreshold}snap(t,s){return e(s.vertexHandle)?"vertex"!==s.vertexHandle.type?[]:this.snapExistingVertex(t,s):this.snapNewVertex(t,s)}edgeExceedsShortLineThreshold(e,t){return this.exceedsShortLineThreshold(i(e.leftVertex.pos,this.view,t),i(e.rightVertex.pos,this.view,t),t)}exceedsShortLineThreshold(e,t,{spatialReference:r}){return 0===this.squaredShortLineThreshold||o(h(t,r,s,this.view),h(e,r,s,this.view))>this.squaredShortLineThreshold}isVertical(e,s){return t(e,s)<r.verticalLineThreshold}squaredProximityThreshold(e){return"touch"===e?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:e,touchSensitivityMultiplier:t}=this.options,s=e*t;return s*s}}export{n as SnappingAlgorithm};