UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.86 kB
import{unwrap as e}from"../../../core/maybe.js";import{l as t,d as i}from"../../../chunks/vec2.js";import{a as s}from"../../../chunks/vec2f64.js";import{c as r}from"../../../chunks/vec3f64.js";import{absoluteHeightElevationInfo as o}from"../../../support/elevationInfoUtils.js";import{SnappingAlgorithm as n}from"./SnappingAlgorithm.js";import{anyMapPointToSnappingPoint as p,asSnappingPoint as a}from"./SnappingPoint.js";import{squaredScreenDistance as d}from"./snappingUtils.js";import{RightAngleTriangleSnappingCandidate as m}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as c}from"../support/viewUtils.js";import{projectPointToCircle as l}from"../../support/geometry2dUtils.js";class h extends n{snapNewVertex(e,t){const i=t.editGeometryOperations.data.components[0],s=[],r=i.vertices.length;if("polygon"!==t.editGeometryOperations.data.type||r<2)return s;const{view:o}=this,n=i.vertices[0],a=i.vertices[r-1],d=p(n.pos,o,t),m=p(a.pos,o,t);return this._processCandidateProposal(d,m,e,t,s),s}snapExistingVertex(t,i){const s=[],r=e(i.vertexHandle),o=r.component;if(o.edges.length<2)return s;if("polyline"===i.editGeometryOperations.data.type&&(0===r.index||r.index===o.vertices.length-1))return s;const{view:n}=this,a=p(r.leftEdge.leftVertex.pos,n,i),d=p(r.rightEdge.rightVertex.pos,n,i);return this._processCandidateProposal(a,d,t,i,s),s}_processCandidateProposal(e,s,n,p,h){if(!this.exceedsShortLineThreshold(e,s,p))return;const g=t(f,e,s,.5),u=.5*i(e,s),v=r();l(v,n,g,u),v[2]=n[2];const x=a(v),{spatialReference:j,pointer:y}=p,w=c(n,j,o,this.view);if(d(w,c(x,j,o,this.view))<this.squaredProximityThreshold(y)){if(this.isVertical(e,x)||this.isVertical(x,s))return;h.push(new m({targetPoint:x,point1:e,point2:s,isDraped:"on-the-ground"===p.elevationInfo?.mode}))}}}const f=s();export{h as RightAngleTriangleSnapper};