UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.66 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import{isSome as r}from"../../../../core/maybe.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import a from"../../../../geometry/Extent.js";import{QueryEngine as o}from"../../../../layers/graphics/data/QueryEngine.js";import i from"../../../../rest/support/FeatureSet.js";import u from"../../../../rest/support/Query.js";import{featureGeometryTypeKebabDictionary as y}from"../../../../geometry/support/typeUtils.js";const c=o;let p=class extends t{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 u({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}constructor(e){super(e),this._dataQueryEngineInstance=null}destroy(){this.clear()}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:s}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),t);return{count:r,extent:a.fromJSON(s)}}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),s=i.fromJSON(r);return s.features.forEach((e=>{e.layer=this.layer,e.sourceLayer=this.layer})),s}async executeQuery(e,t){const r=await this._dataQueryEngine.executeQuery(this._ensureQueryJSON(e),t),s=i.fromJSON(r);return s.features.forEach((e=>{e.layer=this.layer,e.sourceLayer=this.layer})),s}_ensureQueryJSON(e,t){let s=this.defaultQueryJSON;if(r(e)&&("outSpatialReference"in e&&!e.outSpatialReference&&(e.outSpatialReference=this.spatialReference),s=e.toJSON()),r(t)){const e=t.geometries.map((e=>e.toJSON())).reduce(((e,t)=>(e.rings=e.rings.concat(t.rings),e)));s={...s,sceneFilter:{...t,geometry:e}}}return s}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const e="timeInfo"in this.layer&&this.layer.timeInfo&&this.layer.timeInfo.toJSON()||null,t=this.layer.objectIdField,r=y.toJSON(this._queryGeometryType),s=this.layer.fields?.map((e=>e.toJSON()))??[],n=this.priority,a=this.spatialReference.toJSON(),{hasZ:o,hasM:i,featureStore:u,scheduler:p}=this.context;return this._dataQueryEngineInstance=new c({hasZ:o,hasM:i,geometryType:r,fields:s,timeInfo:e,spatialReference:a,objectIdField:t,featureStore:u,scheduler:p,priority:n}),this._dataQueryEngineInstance}};e([s({constructOnly:!0})],p.prototype,"context",void 0),e([s({constructOnly:!0})],p.prototype,"priority",void 0),e([s()],p.prototype,"layer",null),e([s()],p.prototype,"spatialReference",null),e([s()],p.prototype,"_queryGeometryType",null),e([s()],p.prototype,"defaultQueryJSON",null),p=e([n("esri.views.3d.layers.graphics.QueryEngine")],p);export{p as QueryEngine};