UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.37 kB
/* 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/Accessor.js";import"../../../core/has.js";import{watch as i}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{equals as o}from"../../../geometry/support/aaBoundingRect.js";import{isTiledLayer as l}from"../../../layers/support/layerUtils.js";import{ViewingMode as n}from"../../ViewingMode.js";import{isSupportedEarthGCS as a,isSupportedGCSOnGlobe as c}from"../support/supportedSpatialReference.js";import{isProjectableRasterLayer as h,getTiledLayerInfo as p}from"./terrainUtils.js";import{TilingScheme as d}from"./TilingScheme.js";let m=class extends t{constructor(e){super(e)}initialize(){this.addHandles([this.layers.on("change",(()=>this._update())),i((()=>this.extentHelper.layerViewsExtent),(()=>this._setAdHocTilingScheme()))]),this._update(),this.tilingSchemeLocked||this._setAdHocTilingScheme()}destroy(){this._waitTask=null,this.layers.destroy()}_update(){if(this._waitTask=null,this.tilingSchemeLocked)return;let e;if(this.layers.some((t=>!(!l(t)||t.isRejected())&&(!(t.isFulfilled()&&!u(t,this.viewSpatialReference,this.viewingMode))&&(e=t,!("vector-tile"===t?.type||h(t)))))),e)if(e.isResolved()){const t=p(e,this.viewSpatialReference,this.viewingMode);if(null!=t){const e=new d(t.tileInfo);this._lockTilingScheme(e)}}else this._updateWhen(e)}_updateWhen(e){const t=e.when().catch((()=>{})).then((()=>{t!==this._waitTask||this.destroyed||this._update()}));this._waitTask=t}_lockTilingScheme(e){if(this.viewingMode===n.Global){const t=e.levels.length-1,i=e.spatialReference;i.isWebMercator?e=d.makeWebMercatorAuxiliarySphere(t):a(i)&&(e=d.makeGCSWithTileSize(e.spatialReference,e.pixelSize,t))}this.tilingSchemeLocked=!0,this.tilingScheme=e,this.extentHelper.tilingScheme=this.tilingScheme,this._updateTiledLayerExtent(),this.removeAllHandles(),this.addHandles(i((()=>this.extentHelper.tiledLayersExtent),(()=>this._updateTiledLayerExtent())))}_updateTiledLayerExtent(){this._set("extent",this.extentHelper.tiledLayersExtent)}_setAdHocTilingScheme(){if(this.viewingMode===n.Global){const e=this.extentHelper.viewSpatialReference;e.isWebMercator?this.tilingScheme=d.WebMercatorAuxiliarySphere:c(e)&&(this.tilingScheme=d.makeGCSWithTileSize(e,256)),this._set("extent",this.extentHelper.layerViewsExtent)}else{const e=this.extentHelper.layerViewsExtent;null==e||o(e,this.extent)||(this.tilingScheme=d.fromExtent(e,this.extentHelper.viewSpatialReference),this._set("extent",e))}}get test(){}};function u(e,t,i){return null!=p(e,t,i)}e([s()],m.prototype,"tilingScheme",void 0),e([s({readOnly:!0})],m.prototype,"extent",void 0),e([s({value:!1})],m.prototype,"tilingSchemeLocked",void 0),e([s({constructOnly:!0})],m.prototype,"viewSpatialReference",void 0),e([s({constructOnly:!0})],m.prototype,"layers",void 0),e([s({constructOnly:!0})],m.prototype,"extentHelper",void 0),e([s({constructOnly:!0})],m.prototype,"viewingMode",void 0),m=e([r("esri.views.3d.terrain.TilingSchemeLogic")],m);export{m as TilingSchemeLogic};