UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.78 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{watch as e,syncAndInitial as t}from"../../../core/reactiveUtils.js";import{intersection as n}from"../../../core/SetUtils.js";import{sqlAnd as r}from"../../../core/sql.js";import{mergeTimeExtents as o}from"../../../core/timeUtils.js";import{s as i}from"../../../chunks/vec32.js";import{makeDehydratedPoint as s}from"../../../layers/graphics/dehydratedPoint.js";import a from"../../../rest/support/Query.js";import{ViewEventPriorities as l}from"../../input/InputManager.js";import{snappingKeys as p}from"../keybindings.js";import{fromAnyMapPoint as c}from"../sketch/normalizedPoint.js";import{isWebMap as m}from"../../../webmap/utils.js";const d=Symbol("grid-placement-graphic");function g(e,t){const n=e.length===t.length&&e[0]===t[0]&&e[1]===t[1];switch(e.length){case 2:return n;case 3:return n&&e[2]===t[2];case 4:return n&&e[2]===t[2]&&e[3]===t[3]}return!1}function u(e,t){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function f(e,t){return Math.sqrt(u(e,t))}function E(e,t){t.sort(((t,n)=>i(t.targetPoint,e)-i(n.targetPoint,e)))}var h;function y({point:e,distance:t,returnEdge:n,vertexMode:i,coordinateHelper:{spatialReference:l},filter:p},c,m){return m=null!=m?m.clone():new a({where:"1=1"}),p&&(m.geometry=p.geometry,m.distance=p.distance,m.spatialRelationship=p.spatialRelationship,m.where=r(m.where,p.where),m.timeExtent=o(m.timeExtent,p.timeExtent),m.objectIds=w(m.objectIds,p.objectIds)),{point:s(e[0],e[1],e[2],l.toJSON()),mode:c,distance:t,returnEdge:n,vertexMode:i,query:m.toJSON()}}function w(e,t){return e||t?t?e?Array.from(n(new Set(e),new Set(t))):t:e:null}function j(e,t,n){return{left:c(e.leftVertex.pos,t,n),right:c(e.rightVertex.pos,t,n)}}!function(e){e[e.TARGET=0]="TARGET",e[e.REFERENCE=1]="REFERENCE",e[e.REFERENCE_EXTENSION=2]="REFERENCE_EXTENSION"}(h||(h={}));const R=Symbol("snapping-toggle");function N(n,r=()=>{}){const o=e((()=>({view:n.view,snappingOptions:n.snappingOptions})),(({view:e,snappingOptions:t})=>{if(n.removeHandles(R),!e||!t)return;const o=l.TOOL,i=[e.on("key-down",(e=>{e.key!==p.toggle||e.repeat||(t.enabledToggled=!0,r())}),o),e.on("key-up",(e=>{e.key===p.toggle&&(t.enabledToggled=!1,r())}),o),e.on("pointer-move",(e=>{const n=e.native.ctrlKey;t.enabledToggled!==n&&(t.enabledToggled=n,r())}),o)];n.addHandles(i,R)}),t);n.addHandles(o)}function b(e){return m(e)&&"utilityNetworks"in e&&!!e.utilityNetworks?.length}export{h as LineSegmentHintType,j as editEdgeToSnappingEdge,d as gridPlacementGraphicSymbol,b as isUtilityNetworkWebMap,y as makeSnappingQuery,g as objectEqual,f as screenDistance,N as setupSnappingToggleHandles,E as sortCandidatesInPlace,u as squaredScreenDistance};