UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.92 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{createScreenPointArray as r,screenPointObjectToArray as i}from"../../../core/screenUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import s from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import{projectVectorToVector as l}from"../../../geometry/projection/projectVectorToVector.js";import{fallbackObjectIDAttribute as c}from"../../../layers/LayerConstants.js";import{isIntegratedMeshLayer as a}from"../../../layers/support/layerUtils.js";import{debugFlags as u}from"./debugFlags.js";import{getElevationAtPoint as d}from"./ElevationProvider.js";import{newIntersector as p}from"../webgl-engine/lib/Intersector.js";import{StoreResults as m,IntersectorType as f}from"../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as g}from"../webgl-engine/lib/intersectorUtils.js";import{toOwner as y,toHit as h}from"../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as E}from"../webgl-engine/lib/verticalOffsetUtils.js";async function U(e,n,i,t){const s=i?R(e,i):t,o=r(n.x,n.y);s.requiresGroundFeedback=!0,s.enableDraped=!0;const l=p(e.state.viewingMode);l.options.selectionMode=!0,l.options.store=m.ALL,e.sceneIntersectionHelper.intersectIntersectorScreen(o,l,s);const c=I(e,l.results.all,s.graphics),d=l.results.ground,f=y(d,e),h=null!=f&&"type"in f&&a(f.type)?f:null,E={screenPoint:n,results:c,ground:{mapPoint:j(e,d),distance:g(d)?d.distanceInRenderSpace:0,layer:h}};return u.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(E.intersector=l),E}function b(e,n,r,t){const s=r?R(e,r):t,o=!(!s.graphics?.include&&!s.graphics?.exclude),l=!(!s.mediaElements?.include&&!s.mediaElements?.exclude),c=i(n);s.enableDraped=s.include&&!s.include.has(E)||s.exclude?.has(E);const a=e.sceneIntersectionHelper,u=p(e.state.viewingMode);if(u.options.selectionMode=!0,u.options.store=o||l?m.ALL:m.MIN,u.options.excludeLabels=r?.excludeLabels??!1,a.intersectIntersectorScreen(c,u,s),o||l){for(const n of u.results.all){const r=h(n,e);if(null==r)return j(e,n);if(o&&("graphic"!==r.type||S(s.graphics,r.graphic)))return j(e,n);if(l&&("media"!==r.type||L(s.mediaElements,r.element)))return j(e,n)}return null}return j(e,u.results.min)}function I(e,n,r){const i=new Array;let t=null;for(let s=0;s<n.length;s++){const o=n[s],l=y(o,e);if(null!=l&&(l===e.map.ground||"type"in l&&a(l.type)))break;const c=h(o,e);if(null==c)continue;if("graphic"===c.type){if(null==t&&s!==n.length-1&&(t=new Set),null!=t){const e=w(c.graphic);if(t.has(e))continue;t.add(e)}if(!S(r,c.graphic))continue}const u=j(e,o),d=o.distanceInRenderSpace;if("media"===c.type){const e=c.element.toSource(u);i.push({...c,mapPoint:u,distance:d,sourcePoint:e})}else i.push({...c,mapPoint:u,distance:d})}return i}function j(e,n,r){return n.getIntersectionPoint(T)?(r=x(e,T,r),n.intersector===f.TERRAIN&&e.basemapTerrain&&(r.z=d(e.basemapTerrain,r)??0),r):null}function w(e){const n=e.sourceLayer,r=e.layer,i=n&&"objectIdField"in n?n:r&&"objectIdField"in r?r:n;if(i){const n=i.objectIdField??c,r=e.attributes?.[n];if(r)return`o-${i.id}-${r}`}return`u-${e.uid}`}function S(e,n){return L(e,w(n))}function L(e,n){return null==e||(null==e.include||e.include.has(n))&&(null==e.exclude||!e.exclude.has(n))}function x(e,n,r){let i=e.spatialReference||o.WGS84;return l(n,e.renderSpatialReference,T,i)?n=T:(i=o.WGS84,l(n,e.renderSpatialReference,T,i)&&(n=T)),r?(r.x=n[0],r.y=n[1],r.z=n[2],r.spatialReference=i):r=new s(n,i),r}function R(e,n){const r=C(e,n.include,P.INCLUDE),i=C(e,n.exclude,P.EXCLUDE);return{include:r.layerUids,exclude:i.layerUids,graphics:{include:r.graphicUids,exclude:i.graphicUids},mediaElements:{include:r.mediaElements,exclude:i.mediaElements}}}function C(r,i,t,s={layerUids:void 0,graphicUids:void 0,mediaElements:void 0}){if(!i)return s;if(i instanceof e)D(s,w(i)),t===P.INCLUDE&&(null!=r.graphicsView&&i.layer===r?v(s,r.graphicsView.processor.layer.id):i.layer&&v(s,i.layer.uid));else if("layer"in i&&"element"in i)N(s,i.element),t===P.INCLUDE&&v(s,i.layer.uid);else if(n(i))for(const e of i)e===r.graphics&&null!=r.graphicsView?v(s,r.graphicsView.processor.layer.id):e===r.map.ground?v(s,E):C(r,e,t,s);else"uid"in i&&v(s,i.uid);return s}function v(e,n){e.layerUids||(e.layerUids=new Set),e.layerUids.add(n)}function D(e,n){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(n)}function N(e,n){e.mediaElements||(e.mediaElements=new Set),e.mediaElements.add(n)}const T=t();var P;!function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(P||(P={}));export{x as computeMapPointFromVec3d,R as externalToInternalIntersectOptions,w as getGraphicFilterUid,U as hitTest,j as intersectResultToMapPoint,b as toMap};