UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.01 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{lerp as e,distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{absoluteHeightElevationInfo as r}from"../../../support/elevationInfoUtils.js";import{fromAnyMapPoint as o,asVec2 as s,markAsTarget as n,fromValues as p}from"../sketch/normalizedPoint.js";import{SnappingAlgorithm as a}from"./SnappingAlgorithm.js";import{squaredScreenDistance as d}from"./snappingUtils.js";import{RightAngleTriangleSnappingCandidate as l}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as m}from"../support/viewUtils.js";import{projectPointToCircle as c}from"../../support/geometry2dUtils.js";class h extends a{snapNewVertex(e,t){const i=t.editGeometryOperations.data.components[0],r=[],s=i.vertices.length;if("polygon"!==t.editGeometryOperations.data.type||s<2)return r;const{view:n}=this,p=i.vertices[0],a=i.vertices[s-1],d=o(p.pos,n,t),l=o(a.pos,n,t);return this._processCandidateProposal(d,l,e,t,r),r}snapExistingVertex(e,t){const i=[],r=t.vertexHandle,s=r.component;if(s.edges.length<2)return i;if("polyline"===t.editGeometryOperations.data.type&&(0===r.index||r.index===s.vertices.length-1))return i;const{view:n}=this,p=o(r.leftEdge.leftVertex.pos,n,t),a=o(r.rightEdge.rightVertex.pos,n,t);return this._processCandidateProposal(p,a,e,t,i),i}_processCandidateProposal(i,o,a,h,g){if(!this.exceedsShortLineThreshold(i,o,h))return;const v=e(f,s(i),s(o),.5),x=.5*t(s(i),s(o)),u=c(f,s(a),v,x),j=n(p(u[0],u[1],a[2])),{spatialReference:y,pointer:w}=h,P=m(a,y,r,this.view);if(d(P,m(j,y,r,this.view))<this.squaredProximityThreshold(w)){if(this.isVertical(i,j,h)||this.isVertical(j,o,h))return;g.push(new l({targetPoint:j,point1:i,point2:o,isDraped:"on-the-ground"===h.elevationInfo?.mode}))}}}const f=i();export{h as RightAngleTriangleSnapper};