@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.32 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 r from"../request.js";import t from"../core/Error.js";import{releaseMaybe as i}from"../core/maybe.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s,throwIfAborted as a}from"../core/promiseUtils.js";import{objectToQuery as p}from"../core/urlUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as n}from"../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"../geometry/HeightModelInfo.js";import y from"./Layer.js";import{ArcGISCachedService as m}from"./mixins/ArcGISCachedService.js";import{ArcGISService as u}from"./mixins/ArcGISService.js";import{OperationalLayer as h}from"./mixins/OperationalLayer.js";import{PortalLayer as v}from"./mixins/PortalLayer.js";import{url as f}from"./support/commonProperties.js";import{ElevationTileData as g}from"./support/ElevationTileData.js";import{acquireDecoder as j}from"./support/LercDecoder.js";let S=class extends(m(u(h(v(o(y)))))){constructor(...e){super(...e),this.capabilities={operations:{supportsTileMap:!1}},this.copyright=null,this.heightModelInfo=null,this.path=null,this.minScale=void 0,this.maxScale=void 0,this.opacity=1,this.operationalLayerType="ArcGISTiledElevationServiceLayer",this.sourceJSON=null,this.type="elevation",this.url=null,this.version=null,this._lercDecoder=j()}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}destroy(){this._lercDecoder=i(this._lercDecoder)}readCapabilities(e,r){const t=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!t)return{operations:{supportsTileMap:!1}};return{operations:{supportsTileMap:t.includes("tilemap")}}}readVersion(e,r){let t=r.currentVersion;return t||(t=9.3),t}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"],supportsData:!1,validateItem:e=>{if(e.typeKeywords)for(let r=0;r<e.typeKeywords.length;r++)if("elevation 3d layer"===e.typeKeywords[r].toLowerCase())return!0;throw new t("portal:invalid-layer-item-type","Invalid layer item type '${type}', expected '${expectedType}' ",{type:"Image Service",expectedType:"Image Service Elevation 3D Layer"})}},e).catch(s).then((()=>this._fetchImageService(r)))),Promise.resolve(this)}fetchTile(e,t,i,o){const s=o?.signal,a={responseType:"array-buffer",signal:s},p={noDataValue:o?.noDataValue,returnFileInfo:!0};return this.load().then((()=>this._fetchTileAvailability(e,t,i,o))).then((()=>r(this.getTileUrl(e,t,i),a))).then((e=>this._lercDecoder.decode(e.data,p,s))).then((e=>new g(e)))}getTileUrl(e,r,t){const i=!this.capabilities.operations.supportsTileMap&&this.supportsBlankTile,o=p({...this.parsedUrl.query,blankTile:!i&&null});return`${this.parsedUrl.path}/tile/${e}/${r}/${t}${o?"?"+o:""}`}async queryElevation(e,r){const{ElevationQuery:t}=await import("./support/ElevationQuery.js");a(r);return(new t).query(this,e,r)}async createElevationSampler(e,r){const{ElevationQuery:t}=await import("./support/ElevationQuery.js");a(r);return(new t).createSampler(this,e,r)}_fetchTileAvailability(e,r,t,i){return this.tilemapCache?this.tilemapCache.fetchAvailability(e,r,t,i):Promise.resolve("unknown")}async _fetchImageService(e){if(this.sourceJSON)return this.sourceJSON;const t={query:{f:"json",...this.parsedUrl.query},responseType:"json",signal:e},i=await r(this.parsedUrl.path,t);i.ssl&&(this.url=this.url?.replace(/^http:/i,"https:")),this.sourceJSON=i.data,this.read(i.data,{origin:"service",url:this.parsedUrl})}get hasOverriddenFetchTile(){return!this.fetchTile[w]}};e([l({readOnly:!0})],S.prototype,"capabilities",void 0),e([n("service","capabilities",["capabilities"])],S.prototype,"readCapabilities",null),e([l({json:{read:{source:"copyrightText"}}})],S.prototype,"copyright",void 0),e([l({readOnly:!0,type:d})],S.prototype,"heightModelInfo",void 0),e([l({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],S.prototype,"path",void 0),e([l({type:["show","hide"]})],S.prototype,"listMode",void 0),e([l({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}},readOnly:!0})],S.prototype,"minScale",void 0),e([l({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}},readOnly:!0})],S.prototype,"maxScale",void 0),e([l({json:{read:!1,write:!1,origins:{"web-document":{read:!1,write:!1}}}})],S.prototype,"opacity",void 0),e([l({type:["ArcGISTiledElevationServiceLayer"]})],S.prototype,"operationalLayerType",void 0),e([l()],S.prototype,"sourceJSON",void 0),e([l({json:{read:!1},value:"elevation",readOnly:!0})],S.prototype,"type",void 0),e([l(f)],S.prototype,"url",void 0),e([l()],S.prototype,"version",void 0),e([n("version",["currentVersion"])],S.prototype,"readVersion",null),S=e([c("esri.layers.ElevationLayer")],S);const w=Symbol("default-fetch-tile");S.prototype.fetchTile[w]=!0;const T=S;export{T as default};