@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.05 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{watch as i}from"../../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../../core/accessorSupport/decorators.js";import{equals as o}from"../../../geometry/support/aaBoundingRect.js";import{isTiledLayer as n}from"../../../layers/support/layerUtils.js";import{isSupportedEarthGCS as l,isSupportedGCSOnGlobe as h}from"../support/supportedSpatialReference.js";import{isProjectableRasterLayer as a,getTiledLayerInfo as c}from"./terrainUtils.js";import{TilingScheme as p}from"./TilingScheme.js";let d=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=>!(!n(t)||t.isRejected())&&(!(t.isFulfilled()&&!m(t,this.viewSpatialReference,this.viewingMode))&&(e=t,!("vector-tile"===t?.type||a(t))))),e)if(e.isResolved()){const t=c(e,this.viewSpatialReference,this.viewingMode);if(null!=t){const e=new p(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(1===this.viewingMode){const t=e.levels.length-1,i=e.spatialReference;i.isWebMercator?e=p.makeWebMercatorAuxiliarySphere(t):l(i)&&(e=p.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(1===this.viewingMode){const e=this.extentHelper.viewSpatialReference;e.isWebMercator?this.tilingScheme=p.WebMercatorAuxiliarySphere:h(e)&&(this.tilingScheme=p.makeGCSWithTileSize(e,256)),this._set("extent",this.extentHelper.layerViewsExtent)}else{const e=this.extentHelper.layerViewsExtent;null==e||o(e,this.extent)||(this.tilingScheme=p.fromExtent(e,this.extentHelper.viewSpatialReference),this._set("extent",e))}}get test(){}};function m(e,t,i){return null!=c(e,t,i)}e([s()],d.prototype,"tilingScheme",void 0),e([s({readOnly:!0})],d.prototype,"extent",void 0),e([s({value:!1})],d.prototype,"tilingSchemeLocked",void 0),e([s({constructOnly:!0})],d.prototype,"viewSpatialReference",void 0),e([s({constructOnly:!0})],d.prototype,"layers",void 0),e([s({constructOnly:!0})],d.prototype,"extentHelper",void 0),e([s({constructOnly:!0})],d.prototype,"viewingMode",void 0),d=e([r("esri.views.3d.terrain.TilingSchemeLogic")],d);export{d as TilingSchemeLogic};