12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import s from"../request.js";import{property as t}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import i from"../layers/graphics/sources/support/QueryTask.js";import{DataLayerSource as o}from"../layers/support/source/DataLayerSource.js";import{fromJSON as a}from"../renderers/support/jsonUtils.js";import n from"../rest/support/Query.js";import l from"../rest/support/StatisticDefinition.js";import u from"./Task.js";let c=class extends u{constructor(e){super(e),this._field=null,this.checkValueRange=null,this.gdbVersion=null,this.source=null}get parsedUrl(){const e=this._parseUrl(this.url);return e.path+="/generateRenderer",e}execute(e,t){const{classificationDefinition:r}=e,i={...e.toJSON(),f:"json"};if("esri.rest.support.ClassBreaksDefinition"===r.declaredClass?this._field=r.classificationField:this._field=r.attributeField,this.source){const e={source:this.source?.toJSON()};i.layer=JSON.stringify(e)}this.gdbVersion&&(i.gdbVersion=this.gdbVersion),i.classificationDef&&(i.classificationDef=JSON.stringify(i.classificationDef));let o={query:i};return(this.requestOptions||t)&&(o={...this.requestOptions,...t,...o}),s(this.parsedUrl.path,o).then((e=>this._handleExecuteResponse(e)))}_handleExecuteResponse(e){const s=e&&e.data;if(!s)return;if(!this.checkValueRange){const e=this._processRendererJSON(s);return Promise.resolve(e)}const t=new i({url:this.url}),r=new l({statisticType:"min",onStatisticField:this._field}),o=new l({statisticType:"max",onStatisticField:this._field}),a=new n({outStatistics:[r,o]});return t.execute(a).then((e=>{const t=e.features[0].attributes;let r=null,i=null;for(const s in t)0===s.toLowerCase().indexOf("min")?r=t[s]:i=t[s];return this._processRendererJSON(s,r,i)}))}_processRendererJSON(e,s,t){if("classBreaks"===e.type){const r=a(e);return{classBreaks:r.classBreakInfos.map(((e,i)=>(0===i&&null!=s&&(e.minValue=s),i===r.classBreakInfos.length-1&&null!=t&&(e.maxValue=t),{minValue:e.minValue,maxValue:e.maxValue,label:e.label}))),normalizationTotal:r.normalizationTotal}}return{uniqueValues:e.uniqueValueInfos.map(((r,i)=>(0===i&&null!=s&&(r.value=s),i===e.uniqueValueInfos.length-1&&null!=t&&(r.value=t),{count:r.count,value:r.value,label:r.label})))}}};e([t()],c.prototype,"checkValueRange",void 0),e([t()],c.prototype,"gdbVersion",void 0),e([t({type:o})],c.prototype,"source",void 0),e([t({readOnly:!0})],c.prototype,"parsedUrl",null),c=e([r("esri.tasks.GenerateRendererTask")],c);const p=c;export{p as default};
|