UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 5.69 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../chunks/tslib.es6.js";import t from"../request.js";import r from"../core/Error.js";import i from"../core/Logger.js";import{rad2deg as o}from"../core/mathUtils.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as a}from"../core/promiseUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{d as p,g as l,t as c,c as f,A as y,D as h,a as u}from"../chunks/vec32.js";import{fromValues as d,create as x}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{WGS84ECEFSpatialReferenceLike as g}from"../geometry/ellipsoidUtils.js";import v from"../geometry/Extent.js";import j from"../geometry/SpatialReference.js";import{projectBuffer as A}from"../geometry/projection/projectBuffer.js";import b from"./Layer.js";import{APIKeyMixin as L}from"./mixins/APIKeyMixin.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{CustomParametersMixin as _}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as w}from"./mixins/OperationalLayer.js";import{PortalLayer as E}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{elevationInfo as M,url as R}from"./support/commonProperties.js";import{logInvalidElevationInfoWarning as T,elevationModeRequiredMessage as U,featureExpressionUnsupportedMessage as D}from"../support/elevationInfoUtils.js";let N=class extends(S(w(E(I(s(_(L(b)))))))){constructor(e){super(e),this.operationalLayerType="IntegratedMesh3DTilesLayer",this.spatialReference=new j({wkid:4326,vcsWkid:115700}),this.fullExtent=new v(-180,-90,180,90,this.spatialReference),this.url=null,this.type="integrated-mesh-3dtiles",this.path=null,this.minScale=0,this.maxScale=0}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}_verifyArray(e,t){if(!Array.isArray(e)||e.length<t)return!1;for(const r of e)if("number"!=typeof r)return!1;return!0}_initFullExtent(e){const t=e.root?.boundingVolume;if(!t)return;if(t.box){const e=t?.box;if(e[3]>7972671&&e[7]>7972671&&e[11]>7945940)return}const r=e.root?.transform,i=x();if(t.region&&this._verifyArray(t.region,6)){const e=t.region,r=o(e[0]),i=o(e[1]),s=e[4],a=o(e[2]),n=o(e[3]),m=e[5];this.fullExtent=new v({xmin:r,ymin:i,zmin:s,xmax:a,ymax:n,zmax:m,spatialReference:this.spatialReference})}else if(t.sphere&&this._verifyArray(t.sphere,4)){const e=t.sphere,o=d(e[0],e[1],e[2]),s=e[3]/Math.sqrt(3),a=x();p(a,o,d(s,s,s));const n=x();if(l(n,o,d(s,s,s)),r&&this._verifyArray(r,16)){const e=r;c(i,a,e),f(a,i),c(i,n,e),f(n,i)}A(a,g,0,a,j.WGS84,0),A(n,g,0,n,j.WGS84,0);const m=x(),u=x();y(m,a,n),h(u,a,n),this.fullExtent=new v({xmin:m[0],ymin:m[1],zmin:m[2],xmax:u[0],ymax:u[1],zmax:u[2],spatialReference:this.spatialReference})}else if(t.box&&this._verifyArray(t.box,12)){const e=t.box,i=d(e[0],e[1],e[2]),o=d(e[3],e[4],e[5]),s=d(e[6],e[7],e[8]),a=d(e[9],e[10],e[11]),n=[];for(let t=0;t<8;++t)n.push(x());if(l(n[0],i,o),l(n[0],n[0],s),l(n[0],n[0],a),u(n[1],i,o),l(n[1],n[1],s),l(n[1],n[1],a),l(n[2],i,o),u(n[2],n[2],s),l(n[2],n[2],a),u(n[3],i,o),u(n[3],n[3],s),l(n[3],n[3],a),l(n[4],i,o),l(n[4],n[4],s),u(n[4],n[4],a),u(n[5],i,o),l(n[5],n[5],s),u(n[5],n[5],a),l(n[6],i,o),u(n[6],n[6],s),u(n[6],n[6],a),u(n[7],i,o),u(n[7],n[7],s),u(n[7],n[7],a),r&&this._verifyArray(r,16)){const e=r;for(let t=0;t<8;++t)c(n[t],n[t],e)}const m=d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),p=d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let t=0;t<8;++t)A(n[t],g,0,n[t],j.WGS84,0),y(p,p,n[t]),h(m,m,n[t]);this.fullExtent=new v({xmin:p[0],ymin:p[1],zmin:p[2],xmax:m[0],ymax:m[1],zmax:m[2],spatialReference:this.spatialReference})}}async load(e){return this.addResolvingPromise(this._doLoad(e)),this}async _doLoad(e){const i=null!=e?e.signal:null;try{await this.loadFromPortal({supportedTypes:["3DTiles Service"],validateItem:e=>{if(e.typeKeywords?.includes("IntegratedMesh"))return!0;throw new r("portal:invalid-layer-item-type","Invalid layer item, expected '${expectedType}' ",{expectedType:"3DTiles Service containing IntegratedMesh"})}},e)}catch(o){a(o)}if(this.url){const e=t(this.url,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:i}).then((e=>{this._initFullExtent(e.data)}),(e=>{a(e)}));await e}}async fetchAttributionData(){return this.load().then((()=>({})))}_validateElevationInfo(e){const t="Integrated mesh 3d tiles layers";T(i.getLogger(this),U(t,"absolute-height",e)),T(i.getLogger(this),D(t,e))}};e([n({type:["IntegratedMesh3DTilesLayer"]})],N.prototype,"operationalLayerType",void 0),e([n({type:j})],N.prototype,"spatialReference",void 0),e([n({type:v})],N.prototype,"fullExtent",void 0),e([n(M)],N.prototype,"elevationInfo",null),e([n({type:["show","hide"]})],N.prototype,"listMode",void 0),e([n(R)],N.prototype,"url",void 0),e([n({readOnly:!0})],N.prototype,"type",void 0),e([n({type:String,json:{origins:{"web-scene":{read:!0,write:!0},"portal-item":{read:!0,write:!0}},read:!1}})],N.prototype,"path",void 0),e([n({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],N.prototype,"minScale",void 0),e([n({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],N.prototype,"maxScale",void 0),N=e([m("esri.layers.IntegratedMesh3DTilesLayer")],N);const P=N;export{P as default};