@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.45 kB
JavaScript
import{unwrap as e}from"../../../core/maybe.js";import{a as t,h as i,v as s,w as r}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{s as n,z as a}from"../../../chunks/vec3.js";import{a as p,c as h}from"../../../chunks/vec3f64.js";import{absoluteHeightElevationInfo as c}from"../../../support/elevationInfoUtils.js";import{SnappingAlgorithm as d}from"./SnappingAlgorithm.js";import{VerticalHalfPlaneConstraint as g}from"./SnappingConstraint.js";import{anyMapPointToSnappingPoint as f,asSnappingPoint as l}from"./SnappingPoint.js";import{squaredScreenDistance as m}from"./snappingUtils.js";import{RightAngleSnappingCandidate as x,OtherVertexType as v}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as E}from"../support/viewUtils.js";class V extends d{snapNewVertex(e,t){const i=t.editGeometryOperations.data.components[0],s=i.vertices.length,r=[];if(s<2)return r;const{view:o}=this,n=E(e,t.spatialReference,c,o),a=i.vertices[s-1];if(this.edgeExceedsShortLineThreshold(a.leftEdge,t)){const i=f(a.pos,o,t),s=f(a.leftEdge.leftVertex.pos,o,t);this._checkForSnappingCandidate(r,s,i,e,n,t)}const p=i.vertices[0];if(this.edgeExceedsShortLineThreshold(p.rightEdge,t)){const i=f(p.pos,o,t),s=f(p.rightEdge.rightVertex.pos,o,t);this._checkForSnappingCandidate(r,s,i,e,n,t)}return r}snapExistingVertex(t,i){const s=[],r=e(i.vertexHandle);if(r.component.vertices.length<3)return s;const{view:o}=this,n=E(t,i.spatialReference,c,o),a=r.leftEdge,p=r.rightEdge;if(a&&a.leftVertex.leftEdge){const e=a.leftVertex.leftEdge;if(this.edgeExceedsShortLineThreshold(e,i)){const r=f(e.rightVertex.pos,o,i),a=f(e.leftVertex.pos,o,i);this._checkForSnappingCandidate(s,a,r,t,n,i)}}if(p&&p.rightVertex.rightEdge){const e=p.rightVertex.rightEdge;if(this.edgeExceedsShortLineThreshold(e,i)){const r=f(e.leftVertex.pos,o,i),a=f(e.rightVertex.pos,o,i);this._checkForSnappingCandidate(s,a,r,t,n,i)}}return s}_checkForSnappingCandidate(e,o,d,f,V,j){const{spatialReference:k,pointer:w}=j;t(u,d,o);const C=n(S,u[1],-u[0],0),T=i(C,t(u,f,d))/s(C),F=l(r(p(f),d,C,T));if(m(V,E(F,k,c,this.view))<this.squaredProximityThreshold(w)){if(this.isVertical(F,d)||this.isVertical(d,o))return;const t=a(h(),d,C,Math.sign(T));e.push(new x({targetPoint:F,constraint:new g(d,l(t)),previousVertex:o,otherVertex:d,otherVertexType:v.CENTER,isDraped:"on-the-ground"===j.elevationInfo?.mode}))}}}const u=o(),S=h();export{V as RightAngleSnapper};