UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 2.38 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as r,subclass as s}from"../../../core/accessorSupport/decorators.js";import a from"./BaseRaster.js";import{isXAxis as i,isYAxis as o,parseGridCoverage as n}from"./covJSONParser.js";import l from"./InMemoryRaster.js";import{computeStatisticsHistograms as c}from"../functions/stretchUtils.js";import m from"../../../rest/support/FeatureSet.js";let p=class extends a{constructor(){super(...arguments),this.datasetFormat="CovJSON"}fetchRawTile(e,t,r,s={}){return this._inMemoryRaster.fetchRawTile(e,t,r,s)}async _open(e){const{extent:t,pixelBlocks:r,multidimensionalInfo:s,attributeTable:a,bandNames:i}=await this._fetchData(e),{statistics:o,histograms:n}=c(r[0]),p=i?.map(e=>({BandName:e})),h={DataType:a?"Thematic":s?"Scientific":"Generic",BandProperties:p},d=new l({source:{extent:t,pixelBlocks:r,attributeTable:a?m.fromJSON(a):null,multidimensionalInfo:s,statistics:o,histograms:n,keyProperties:h,isPseudoSpatialReference:!1}});await d.open(),this._inMemoryRaster=d;const u=this.source?"":this.url.slice(this.url.lastIndexOf("/")+1);this._set("datasetName",u.slice(0,u.indexOf("."))),this._set("rasterInfo",d.rasterInfo)}async _fetchData(e){const r=this.source??(await this.request(this.url,{signal:e?.signal})).data,s="imagery-tile-layer:open-coverage-json";if("coverage"!==r.type?.toLowerCase()||"grid"!==r.domain?.domainType?.toLowerCase())throw new t(s,"Only coverage with Grid domain type is supported");if(!r.ranges)throw new t(s,"Missing ranges in the grid coverage data");if(!r.domain.referencing?.length)throw new t(s,"Missing domain referencing in the grid coverage data");const a=Object.values(r.ranges);for(let n=0;n<a.length;n++){const{axisNames:e,shape:r,type:l,values:c}=a[n];if(!("ndarray"===l.toLowerCase()&&c?.length&&e?.length&&r?.length))throw new t(s,"Only ranges with valid NdArray, axisNames, shape, and inline values are supported");if(!(i(e[e.length-1])&&o(e[e.length-2])))throw new t(s,"Only row-major ordered pixel values are supported. X axis must be the last axis.")}return n(r)}};e([r({type:String,json:{write:!0}})],p.prototype,"datasetFormat",void 0),e([r({constructOnly:!0})],p.prototype,"source",void 0),p=e([s("esri.layers.raster.datasets.CovJSONRaster")],p);const h=p;export{h as default};