UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.75 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import e from"../../../core/Error.js";import{extentContainsPoint as r,extentContainsMultipoint as t}from"../../../geometry/support/contains.js";import{getExtentIntersector as i}from"../../../geometry/support/intersects.js";import{isPolygon as o,isExtent as s,getJsonType as n}from"../../../geometry/support/jsonTypeUtils.js";import{isValid as a}from"../../../geometry/support/spatialReferenceUtils.js";import{polygonContainsPoint as l,polygonContainsMultipoint as p}from"../contains.js";import{convertFromPolygon as u}from"../featureConversionUtils.js";import{getGeometry as m}from"./geometryUtils.js";import{checkProjectionSupport as y}from"./projectionSupport.js";const c="unsupported-query",f={spatialRelationship:{esriSpatialRelIntersects:!0,esriSpatialRelContains:!0,esriSpatialRelWithin:!0,esriSpatialRelCrosses:!0,esriSpatialRelDisjoint:!0,esriSpatialRelTouches:!0,esriSpatialRelOverlaps:!0,esriSpatialRelEnvelopeIntersects:!0,esriSpatialRelIndexIntersects:!1,esriSpatialRelRelation:!1},queryGeometry:{esriGeometryPoint:!0,esriGeometryMultiPatch:!1,esriGeometryMultipoint:!0,esriGeometryPolyline:!0,esriGeometryPolygon:!0,esriGeometryEnvelope:!0},layerGeometry:{esriGeometryPoint:!0,esriGeometryMultiPatch:!0,esriGeometryMultipoint:!0,esriGeometryPolyline:!0,esriGeometryPolygon:!0,esriGeometryEnvelope:!1}};function R(e){return null!=e&&!0===f.spatialRelationship[e]}function S(e){return null!=e&&!0===f.queryGeometry[n(e)]}function j(e){return null!=e&&!0===f.layerGeometry[e]}const g={esriSpatialRelIntersects:()=>import("../../../geometry/operators/json/intersectsOperator.js"),esriSpatialRelContains:()=>import("../../../geometry/operators/json/containsOperator.js"),esriSpatialRelCrosses:()=>import("../../../geometry/operators/json/crossesOperator.js"),esriSpatialRelDisjoint:()=>import("../../../geometry/operators/json/disjointOperator.js"),esriSpatialRelEnvelopeIntersects:null,esriSpatialRelIndexIntersects:null,esriSpatialRelOverlaps:()=>import("../../../geometry/operators/json/overlapsOperator.js"),esriSpatialRelTouches:()=>import("../../../geometry/operators/json/touchesOperator.js"),esriSpatialRelWithin:()=>import("../../../geometry/operators/json/withinOperator.js"),esriSpatialRelRelation:null};function G(e){const r=g[e];if(null==r)throw new Error(`Cannot load unsupported spatial operator: ${e}`);return r()}async function h(e,n,a){if(o(n)){if("esriGeometryPoint"===a&&("esriSpatialRelIntersects"===e||"esriSpatialRelContains"===e)){const e=u(n,!1,!1);return r=>l(e,r)}if("esriGeometryMultipoint"===a){const r=u(n,!1,!1);if("esriSpatialRelContains"===e)return e=>p(r,e)}}if(s(n)){if("esriGeometryPoint"===a&&("esriSpatialRelIntersects"===e||"esriSpatialRelContains"===e))return e=>r(n,m(a,e));if("esriGeometryMultipoint"===a&&"esriSpatialRelContains"===e)return e=>t(n,m(a,e));if("esriSpatialRelIntersects"===e){const e=i(a);return r=>e(n,m(a,r))}}"esriSpatialRelEnvelopeIntersects"===e&&(e="esriSpatialRelIntersects");const y=await G(e);return e=>y.execute(n,m(a,e))}async function I(r,t,i){const{spatialRel:o,geometry:s}=r;if(s){if(!R(o))throw new e(c,"Unsupported query spatial relationship",{query:r});if(a(s.spatialReference)&&a(i)){if(!S(s))throw new e(c,"Unsupported query geometry type",{query:r});if(!j(t))throw new e(c,"Unsupported layer geometry type",{query:r});if(r.outSR)return y(r.geometry?.spatialReference,r.outSR)}}}function w(e){if(s(e))return!0;if(o(e)){for(const r of e.rings){if(5!==r.length)return!1;if(r[0][0]!==r[1][0]||r[0][0]!==r[4][0]||r[2][0]!==r[3][0]||r[0][1]!==r[3][1]||r[0][1]!==r[4][1]||r[1][1]!==r[2][1])return!1}return!0}return!1}export{w as canQueryWithRBush,I as checkSpatialQuerySupport,h as getSpatialQueryOperator};