UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.95 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import s from"../../../../geometry/Extent.js";import{featureGeometryTypeKebabDictionary as i}from"../../../../geometry/support/typeUtils.js";import{QueryEngine as a}from"../../../../layers/graphics/data/QueryEngine.js";import o from"../../../../layers/support/FieldsIndex.js";import u from"../../../../rest/support/AttributeBinsFeatureSet.js";import y from"../../../../rest/support/FeatureSet.js";import c from"../../../../rest/support/Query.js";import{createFeatureIdInfo as l}from"../../../2d/layers/features/layerAdapters/featureServiceUtils.js";import{QueryEngineCache as p}from"./QueryEngineCache.js";const h=a;let g=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 c({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=y.fromJSON(r);return n.features.forEach(e=>{e.layer=this.layer,e.sourceLayer=this.layer,"graphicOrigin"in this.layer&&(e.origin=this.layer.graphicOrigin)}),n}async executeAttributeBinsQuery(e,t){const r=await this._dataQueryEngine.executeAttributeBinsQuery(e.toJSON(),t);return u.fromJSON(r)}async executeQuery(e,t){const r=await this._dataQueryEngine.executeQuery(this._ensureQueryJSON(e),t),n=y.fromJSON(r);return n.features.forEach(e=>{e.layer=this.layer,e.sourceLayer=this.layer,"graphicOrigin"in this.layer&&(e.origin=this.layer.graphicOrigin)}),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=l(t),s=i.toJSON(this._queryGeometryType),a=t.fieldsIndex?.toJSON()||new o([]),u=this.spatialReference.toJSON(),{hasZ:y,hasM:c,featureStore:g,scheduler:f,memoryController:m}=this.context,Q=new p(m);return this._dataQueryEngineInstance=new h({hasZ:y,hasM:c,geometryType:s,fieldsIndex:a,timeInfo:r,spatialReference:u,featureIdInfo:n,featureStore:g,scheduler:f,cache:Q,priority:e}),this._dataQueryEngineInstance}};e([r({constructOnly:!0})],g.prototype,"context",void 0),e([r({constructOnly:!0})],g.prototype,"priority",void 0),e([r()],g.prototype,"layer",null),e([r()],g.prototype,"spatialReference",null),e([r()],g.prototype,"_queryGeometryType",null),e([r()],g.prototype,"defaultQueryJSON",null),g=e([n("esri.views.3d.layers.graphics.QueryEngine")],g);export{g as QueryEngine};