UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.93 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import e from"../core/Error.js";import{fromExtent as t,create as o}from"../geometry/support/aaBoundingRect.js";import{isSupportedEarthGCS as r}from"../views/3d/support/supportedSpatialReference.js";import{maxRootTiles as l}from"../views/3d/terrain/TerrainConst.js";import{getMissingTileInfoError as n,TilingScheme as i}from"../views/3d/terrain/TilingScheme.js";function s(t,o,l,s){if(null==t)return n();const a=t.spatialReference;if(a.isGeographic&&!r(a))return new e("tilingscheme:local-unsupported-spatial-reference","The tiling scheme spatial reference is not supported in local scenes");const u=i.checkUnsupported(t);if(null!=u)return u;if(null==l)return new e("tilingscheme:extent-not-exist","The layer does not provide a layer extent.");const p=c(t,l);return p||(null==o||a.equals(o)||o.isWGS84&&a.isWebMercator?null:new e("tilingscheme:spatial-reference-mismatch","The tiling scheme does not match the spatial reference of the local scene"))}function c(r,n){const s=r.lods,c=s[0].resolution*2**s[0].level,a=[c*r.size[0],c*r.size[1]],u=[r.origin.x,r.origin.y],p=t(n),f=o();i.computeRowColExtent(p,a,u,f);const m=(f[2]-f[0])*(f[3]-f[1]);if(m>l){const t=s[0].scale*2**s[0].level;let o=Math.max((p[3]-p[1])/r.size[1],(p[2]-p[0])/r.size[0])*t/c;const n=Math.floor(Math.log(o)/Math.log(10));return o=Math.ceil(o/10**n)*10**n,new e("tilingscheme:too-many-root-tiles","Scale of level 0 of the tiling scheme (1:"+Math.floor(t).toLocaleString()+") is too large for the layer's extent. Suggested scale: 1:"+o.toLocaleString()+".",{level0Scale:t,suggestedLevel0Scale:o,requiredNumRootTiles:m,allowedNumRootTiles:l})}return null}const a=Object.freeze(Object.defineProperty({__proto__:null,checkIfTileInfoSupportedForViewSR:s},Symbol.toStringTag,{value:"Module"}));export{s as c,a as t};