@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.82 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../geometry/Extent.js";import{featureGeometryTypeKebabDictionary as o}from"../../../../geometry/support/typeUtils.js";import{QueryEngine as a}from"../../../../layers/graphics/data/QueryEngine.js";import u from"../../../../layers/support/FieldsIndex.js";import i from"../../../../rest/support/FeatureSet.js";import y from"../../../../rest/support/Query.js";import{QueryEngineCache as c}from"./QueryEngineCache.js";const l=a;let p=class extends t{constructor(e){super(e),this._dataQueryEngineInstance=null}destroy(){this.clear()}get layer(){return this.context.layer}get spatialReference(){return this.context.spatialReference}get _queryGeometryType(){switch(this.layer.geometryType){case"multipoint":case"point":case"polygon":case"polyline":return this.layer.geometryType;case"mesh":return"polygon";default:return}}get defaultQueryJSON(){return new y({outSpatialReference:this.spatialReference}).toJSON()}clear(){return!!this._dataQueryEngineInstance&&(this._dataQueryEngineInstance.destroy(),this._dataQueryEngineInstance=null,!0)}async executeQueryForIdSet(e,t,r){return this._dataQueryEngine.executeQueryForIdSet(this._ensureQueryJSON(e,t),r)}async executeQueryForCount(e,t){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),t)}async executeQueryForExtent(e,t){const{count:r,extent:n}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),t);return{count:r,extent:s.fromJSON(n)}}async executeQueryForIds(e,t){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),t)}async executeQueryForLatestObservations(e,t){const r=await this._dataQueryEngine.executeQueryForLatestObservations(this._ensureQueryJSON(e),t),n=i.fromJSON(r);return n.features.forEach((e=>{e.layer=this.layer,e.sourceLayer=this.layer})),n}async executeQuery(e,t){const r=await this._dataQueryEngine.executeQuery(this._ensureQueryJSON(e),t),n=i.fromJSON(r);return n.features.forEach((e=>{e.layer=this.layer,e.sourceLayer=this.layer})),n}_ensureQueryJSON(e,t){let r=this.defaultQueryJSON;if(null!=e&&("outSpatialReference"in e&&!e.outSpatialReference&&(e.outSpatialReference=this.spatialReference),r=e.toJSON(),r.cacheHint=!0),null!=t){const e=t.geometries.map((e=>e.toJSON())).reduce(((e,t)=>(e.rings=e.rings.concat(t.rings),e)));r={...r,cacheHint:!0,sceneFilter:{...t,geometry:e}}}return r}get _dataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const{priority:e,layer:t}=this,r="timeInfo"in t&&t.timeInfo?.toJSON()||null,n=t.objectIdField,s=o.toJSON(this._queryGeometryType),a=t.fieldsIndex?.toJSON()||new u([]),i=this.spatialReference.toJSON(),{hasZ:y,hasM:p,featureStore:h,scheduler:m,memoryController:d}=this.context,f=new c(d);return this._dataQueryEngineInstance=new l({hasZ:y,hasM:p,geometryType:s,fieldsIndex:a,timeInfo:r,spatialReference:i,objectIdField:n,featureStore:h,scheduler:m,cache:f,priority:e}),this._dataQueryEngineInstance}};e([r({constructOnly:!0})],p.prototype,"context",void 0),e([r({constructOnly:!0})],p.prototype,"priority",void 0),e([r()],p.prototype,"layer",null),e([r()],p.prototype,"spatialReference",null),e([r()],p.prototype,"_queryGeometryType",null),e([r()],p.prototype,"defaultQueryJSON",null),p=e([n("esri.views.3d.layers.graphics.QueryEngine")],p);export{p as QueryEngine};