UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.22 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{destroyMaybe as n,isNone as o}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import u from"../../../../geometry/Extent.js";import{fallbackObjectIDAttribute as y}from"../../../../layers/LayerConstants.js";import{QueryEngine as c}from"../../../../layers/graphics/data/QueryEngine.js";import l from"../../../../rest/support/FeatureSet.js";import p from"../../../../rest/support/Query.js";const d=c;let h=class extends r{get spatialReference(){return this.layerView.view.spatialReference}get layer(){return this.layerView.i3slayer}get defaultQueryJSON(){return new p({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}constructor(e){super(e),this._handles=new s}initialize(){this._handles.add(this.layerView.on("visible-geometry-changed",(()=>this.spatialIndex.events.emit("changed"))))}destroy(){this._dataQueryEngineInstance=n(this._dataQueryEngineInstance),this._handles=n(this._handles),this._set("layerView",null)}async executeQueryForCount(e,r){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),r)}async executeQueryForExtent(e,r){const{count:t,extent:s}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),r);return{count:t,extent:u.fromJSON(s)}}async executeQueryForIds(e,r){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),r)}async executeQuery(e,r){const s=this._ensureQueryJSON(e);if(s.returnGeometry)throw new t("feature-store:unsupported-query","returnGeometry is not yet supported for mesh scene layer queries");if(s.returnCentroid)throw new t("feature-store:unsupported-query","returnCentroid is not yet supported for mesh scene layer queries");const n=await this._dataQueryEngine.executeQuery(s,r),o=l.fromJSON(n);return o.features.forEach((e=>{e.geometry=null})),o}_ensureQueryJSON(e){return o(e)?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const e=this.layer.objectIdField||y,r="esriGeometryPolygon",t=this.layer.fields?.map((e=>e.toJSON()))??[],s=this.layerView.view.resourceController.scheduler,n=this.spatialReference.toJSON(),o=this.priority,i=this.spatialIndex;return this._dataQueryEngineInstance=new d({hasZ:!0,hasM:!1,geometryType:r,fields:t,timeInfo:null,spatialReference:n,objectIdField:e,featureStore:i,scheduler:s,priority:o}),this._dataQueryEngineInstance}};e([i({constructOnly:!0})],h.prototype,"layerView",void 0),e([i({constructOnly:!0})],h.prototype,"priority",void 0),e([i({constructOnly:!0})],h.prototype,"spatialIndex",void 0),e([i()],h.prototype,"spatialReference",null),e([i()],h.prototype,"layer",null),e([i()],h.prototype,"defaultQueryJSON",null),h=e([a("esri.views.3d.layers.i3s.I3SQueryEngine")],h);export{h as I3SQueryEngine};