@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 6.65 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import r from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as o}from"../../../../core/promiseUtils.js";import{urlToObject as s}from"../../../../core/urlUtils.js";import{property as i,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{equals as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{getGltfQueryFormat as a}from"../../../support/infoFor3D.js";import{parseUrl as c}from"../../../../rest/utils.js";import p from"../../../../rest/layerSources/DynamicDataLayer.js";import{executeForCount as l}from"../../../../rest/query/executeForCount.js";import{executeForExtent as d}from"../../../../rest/query/executeForExtent.js";import{executeForIds as m}from"../../../../rest/query/executeForIds.js";import{executeRawQueryJSON as y}from"../../../../rest/query/executeQueryJSON.js";import{executeRawQueryPBF as h}from"../../../../rest/query/executeQueryPBF.js";import f from"../../../../rest/support/FeatureSet.js";import F from"../../../../rest/support/Query.js";let S=class extends t{constructor(e){super(e),this.dynamicDataSource=null,this.fieldsIndex=null,this.gdbVersion=null,this.infoFor3D=null,this.pbfSupported=!1,this.pbfSupportedWithCurves=!1,this.queryAttachmentsSupported=!1,this.relativeTimeBinWindow=0,this.sourceSpatialReference=null,this.uniqueIdFields=null,this.url=null}get parsedUrl(){return s(this.url)}async execute(e,t){const r=await this.executeJSON(e,t);return this.featureSetFromJSON(e,r,t)}async executeJSON(e,t){const r=this._normalizeQuery(e),o=null!=e.outStatistics?.[0],s=has("featurelayer-pbf-statistics");let i;if(this.pbfSupported&&(!o||s)&&(!e.returnTrueCurves||this.pbfSupportedWithCurves))try{i=await h(this.url,r,t,{uniqueIdFields:this.uniqueIdFields})}catch(u){if("query:parsing-pbf"!==u.name)throw u;this.pbfSupported=!1}return i??=await y(this.url,r,t,{uniqueIdFields:this.uniqueIdFields}),this._normalizeFields(i.fields),i}async featureSetFromJSON(e,t,r){if(!this._queryGet3DObjectFormat(e)||null==this.infoFor3D||!t.features)return f.fromJSON(t);const{meshFeatureSetFromJSON:s}=await o(import("../../../../rest/support/meshFeatureSet.js"),r);return s(e,this.infoFor3D,t)}executeForCount(e,t){return l(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}executeForExtent(e,t){return d(this.url,this._normalizeQuery(e),t)}executeForIds(e,t){return m(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}async executeRelationshipQuery(e,t){const[{default:r},{executeRelationshipQuery:s}]=await o(Promise.all([import("../../../../rest/support/RelationshipQuery.js"),import("../../../../rest/query/executeRelationshipQuery.js")]),t);let i=r.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(i=i.clone(),i.gdbVersion=i.gdbVersion||this.gdbVersion,i.dynamicDataSource=i.dynamicDataSource||this.dynamicDataSource),s(this.url,i,t)}async executeRelationshipQueryForCount(e,t){const[{default:r},{executeRelationshipQueryForCount:s}]=await o(Promise.all([import("../../../../rest/support/RelationshipQuery.js"),import("../../../../rest/query/executeRelationshipQuery.js")]),t);let i=r.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(i=i.clone(),i.gdbVersion=i.gdbVersion||this.gdbVersion,i.dynamicDataSource=i.dynamicDataSource||this.dynamicDataSource),s(this.url,i,t)}async executeAttachmentQuery(e,t){const{executeAttachmentQuery:r,fetchAttachments:s,processAttachmentQueryResult:i}=await o(import("../../../../rest/query/operations/queryAttachments.js"),t),u=c(this.url);return i(u,await(this.queryAttachmentsSupported?r(u,e,t):s(u,e,t)))}async executeAttributeBinsQuery(e,t){const{executeAttributeBinsQuery:r}=await o(import("../../../../rest/query/executeAttributeBinsQuery.js"),t);return r(this.parsedUrl,e,t)}async executePivotQuery(e,t){const{executePivotQuery:r}=await o(import("../../../../rest/query/executePivotQuery.js"),t);return r(this.parsedUrl,e,t)}async executeTopFeaturesQuery(e,t){const{executeTopFeaturesQuery:r}=await o(import("../../../../rest/query/executeTopFeaturesQuery.js"),t);return r(this.parsedUrl,e,this.sourceSpatialReference,t)}async executeForTopIds(e,t){const{executeForTopIds:r}=await o(import("../../../../rest/query/executeForTopIds.js"),t);return r(this.parsedUrl,e,t)}async executeForTopExtents(e,t){const{executeForTopExtents:r}=await o(import("../../../../rest/query/executeForTopExtents.js"),t);return r(this.parsedUrl,e,t)}async executeForTopCount(e,t){const{executeForTopCount:r}=await o(import("../../../../rest/query/executeForTopCount.js"),t);return r(this.parsedUrl,e,t)}_normalizeQuery(e){let t=F.from(e);t.sourceSpatialReference=t.sourceSpatialReference||this.sourceSpatialReference,(this.gdbVersion||this.dynamicDataSource)&&(t=t===e?t.clone():t,t.gdbVersion=e.gdbVersion||this.gdbVersion,t.dynamicDataSource=e.dynamicDataSource?p.from(e.dynamicDataSource):this.dynamicDataSource);const{infoFor3D:o}=this,s=this._queryGet3DObjectFormat(e);if(null!=o&&s){if(t=t===e?t.clone():t,t.formatOf3DObjects=s,t.outSpatialReference&&!n(t.outSpatialReference,this.sourceSpatialReference))throw new r("query:unsupported-out-spatial-reference","3D object feature services do not support projection of geometries");if(null==t.outFields||!t.outFields.includes("*")){t=t===e?t.clone():t,null==t.outFields&&(t.outFields=[]);const{originX:r,originY:s,originZ:i,translationX:u,translationY:n,translationZ:a,scaleX:c,scaleY:p,scaleZ:l,rotationX:d,rotationY:m,rotationZ:y,rotationDeg:h}=o.transformFieldRoles;t.outFields.push(r,s,i,u,n,a,c,p,l,d,m,y,h)}}return t}_normalizeFields(e){if(null!=this.fieldsIndex&&null!=e)for(const t of e){const e=this.fieldsIndex.get(t.name);e&&Object.assign(t,e.toJSON())}}_queryGet3DObjectFormat({returnGeometry:e,multipatchOption:t,outStatistics:r}){return!0!==e||"xyFootprint"===t||r?null:a(this.infoFor3D)}};e([i({type:p})],S.prototype,"dynamicDataSource",void 0),e([i()],S.prototype,"fieldsIndex",void 0),e([i()],S.prototype,"gdbVersion",void 0),e([i()],S.prototype,"infoFor3D",void 0),e([i({readOnly:!0})],S.prototype,"parsedUrl",null),e([i()],S.prototype,"pbfSupported",void 0),e([i()],S.prototype,"pbfSupportedWithCurves",void 0),e([i()],S.prototype,"queryAttachmentsSupported",void 0),e([i()],S.prototype,"relativeTimeBinWindow",void 0),e([i()],S.prototype,"sourceSpatialReference",void 0),e([i()],S.prototype,"uniqueIdFields",void 0),e([i({type:String})],S.prototype,"url",void 0),S=e([u("esri.layers.graphics.sources.support.QueryTask")],S);export{S as default};