@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.66 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import a from"./BaseRaster.js";import{isXAxis as o,isYAxis as i,parseGridCoverage as n}from"./covJSONParser.js";import c from"./InMemoryRaster.js";import{computeStatisticsHistograms as l}from"../rasterFunctions/stretchUtils.js";import p from"../../../rest/support/FeatureSet.js";let m=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:o}=await this._fetchData(e),{statistics:i,histograms:n}=l(r[0]),m=o?.map((e=>({BandName:e}))),h={DataType:a?"Thematic":s?"Scientific":"Generic",BandProperties:m},d=new c({source:{extent:t,pixelBlocks:r,attributeTable:a?p.fromJSON(a):null,multidimensionalInfo:s,statistics:i,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:c,values:l}=a[n];if(!("ndarray"===c.toLowerCase()&&l?.length&&e?.length&&r?.length))throw new t(s,"Only ranges with valid NdArray, axisNames, shape, and inline values are supported");if(!(o(e[e.length-1])&&i(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}})],m.prototype,"datasetFormat",void 0),e([r({constructOnly:!0})],m.prototype,"source",void 0),m=e([s("esri.layers.support.rasterDatasets.CovJSONRaster")],m);const h=m;export{h as default};