@nsc-earth-2/layer 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{defaultValue as e,Terrain as t,CesiumTerrainProvider as s,EllipsoidTerrainProvider as r,Rectangle as i,Cesium3DTileset as n,Matrix4 as o,Cartographic as a,Cartesian3 as h,Transforms as l,Matrix3 as c,Math as d,ArcGisMapServerImageryProvider as w,ImageryLayer as y,GeographicTilingScheme as _,Ellipsoid as v,UrlTemplateImageryProvider as m,WebMapServiceImageryProvider as u,WebMapTileServiceImageryProvider as p,KmlDataSource as f}from"cesium";import{GeoJsonPrimitiveLayer as g}from"@nsc-earth-2/primitive-geojson";class R{constructor(e){this._viewer=e}load(r){r=e(r,{});if("TERRAIN"!==e(r.type,void 0))throw new Error("the layer type is not 'TERRAIN'");const i=e(r.url,void 0),n=new t(s.fromUrl(i));return this._viewer.scene.setTerrain(n),this._viewer.scene.requestRender(),Promise.resolve(n)}remove(e){const t=new r;this._viewer.terrainProvider=t,this._viewer.scene.requestRender()}locate(t,s){t=e(t,{});const r=e(t.url,void 0);fetch(`${r}/layer.json`).then((e=>e.json())).then((e=>{e.valid_bounds&&Array.isArray(e.valid_bounds)&&4===e.valid_bounds.length?this._viewer.camera.flyTo({destination:i.fromDegrees(e.valid_bounds[0],e.valid_bounds[1],e.valid_bounds[2],e.valid_bounds[3])}):e.bounds&&Array.isArray(e.bounds)&&4==e.bounds.length&&this._viewer.camera.flyTo({destination:i.fromDegrees(e.bounds[0],e.bounds[1],e.bounds[2],e.bounds[3])})}))}show(e,s){if(e instanceof t){if(s)this._viewer.scene.setTerrain(e);else{const e=new r;this._viewer.terrainProvider=e}this._viewer.scene.requestRender()}}}class E{constructor(e){this._viewer=e}async load(t){t=e(t,{});if("3DTILES"!==e(t.type,void 0))throw new Error("the layer type is not '3DTILES'");const s=t.url;if(!s)throw new Error("the url is needed");const r={longitude:e(t.longitude,0),latitude:e(t.latitude,0),altitude:e(t.altitude,0),azimuth:e(t.azimuth,0)},i=await n.fromUrl(s,{dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:.00278,dynamicScreenSpaceErrorFactor:4,dynamicScreenSpaceErrorHeightFalloff:.25});return this.transferTileSet(i,r),this._viewer.scene.primitives.add(i),this._viewer.scene.requestRender(),i}transferTileSet(e,t){const{longitude:s,latitude:r,altitude:i,azimuth:n}=t;let w=new o;if(s&&r){let e=i;0==i&&(e=this._viewer.scene.globe.getHeight(a.fromDegrees(s,r))||0);const t=h.fromDegrees(s,r,e),y=l.eastNorthUpToFixedFrame(t),_=new c(1,0,0,0,1,0,0,0,1),v=c.fromRotationZ(d.toRadians(n));c.multiply(_,v,_),w=o.multiplyByMatrix3(y,_,new o)}else if(i){const t=new h;o.getTranslation(e.root.transform,t);const s=a.fromCartesian(t);if(s){const e=d.toDegrees(s.latitude),t=d.toDegrees(s.longitude),r=h.fromDegrees(t,e,i),a=l.eastNorthUpToFixedFrame(r),y=new c(1,0,0,0,1,0,0,0,1),_=c.fromRotationZ(d.toRadians(n));c.multiply(y,_,y),w=o.multiplyByMatrix3(a,y,new o)}}else if(n){const t=new c(1,0,0,0,1,0,0,0,1),s=c.fromRotationZ(d.toRadians(n));c.multiply(t,s,t),w=o.multiplyByMatrix3(e.root.transform,t,new o)}else w=e.root.transform;e.root.transform=w}remove(e){e instanceof n&&(this._viewer.scene.primitives.remove(e),this._viewer.scene.requestRender())}locate(e,t){t instanceof n&&this._viewer.flyTo(t)}show(e,t){e instanceof n&&(e.show=t,this._viewer.scene.requestRender())}}class T{constructor(e){this._viewer=e}async load(t){t=e(t,{});if("ARCGIS"!==e(t.type,void 0))throw new Error("the layer type is not 'ARCGIS'");const{url:s,alpha:r,token:n}=t;if(!s)throw new Error("the url is needed");let o=s;o=n?s+"/info/iteminfo?f=pjson&token="+n:s+"/info/iteminfo?f=pjson";const a=await fetch(o,{method:"GET"}).then((e=>e.json())).then((e=>{const t={};return n&&(t.token=n),e&&e.extent&&Array.isArray(e.extent)&&(t.rectangle=i.fromDegrees(e.extent[0][0],e.extent[0][1],e.extent[1][0],e.extent[1][1])),t})),h=w.fromUrl(s,a),l=y.fromProviderAsync(h,{});return r&&(l.alpha=r),this._viewer.imageryLayers.add(l),this._viewer.scene.requestRender(),l}async remove(e){e instanceof y&&(this._viewer.imageryLayers.remove(e,!0),this._viewer.scene.requestRender())}locate(e,t){if(t instanceof y)if(t.ready){const e=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:e})}else t.readyEvent.addEventListener((e=>{const s=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:s})}))}show(e,t){e instanceof y&&(e.show=t,this._viewer.scene.requestRender())}}class S{constructor(e){this._viewer=e}async load(t){t=e(t,{});if("URLTemplate"!==e(t.type,void 0))throw new Error("the layer type is not 'URLTemplate'");const{url:s,alpha:r}=t;if(!s)throw new Error("the url is needed");let n=s.substr(0,s.indexOf("{z}/{x}/{y}.png"))+"meta.json";const o=await fetch(n,{method:"GET"}).then((e=>e.json())).then((e=>{const t={url:s};return e&&e.bounds&&(t.rectangle=i.fromDegrees(e.bounds.west,e.bounds.south,e.bounds.east,e.bounds.north)),e&&4326==e.proj&&(t.tilingScheme=new _({ellipsoid:v.WGS84})),e&&e.maxzoom&&(t.maximumLevel=e.maxzoom),e&&e.minzoom&&(t.minimumLevel=e.minzoom),e&&e.tilesize&&(t.tileWidth=t.tileHeight=e.tilesize),t})),a=new m(o),h=new y(a,{});return r&&(h.alpha=r),this._viewer.imageryLayers.add(h),this._viewer.scene.requestRender(),h}async remove(e){e instanceof y&&(this._viewer.imageryLayers.remove(e,!0),this._viewer.scene.requestRender())}locate(e,t){if(t instanceof y)if(t.ready){const e=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:e})}else t.readyEvent.addEventListener((e=>{const s=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:s})}))}show(e,t){e instanceof y&&(e.show=t,this._viewer.scene.requestRender())}}class M{constructor(e){this._viewer=e}async load(t){t=e(t,{});if("GEOJSON"!==e(t.type,void 0))throw new Error("the layer type is not 'GEOJSON'");const{url:s,clampToGround:r}=t;if(!s)throw new Error("the url is needed");const i=new g({options:{useGroundGeometry:r??!1,clampToGround:r??!1,scene:this._viewer.scene}});return await i.load(s),this._viewer.scene.primitives.add(i.primitiveCollection),this._viewer.scene.requestRender(),i}async remove(e){e instanceof g&&(this._viewer.scene.primitives.remove(e.primitiveCollection),this._viewer.scene.requestRender())}locate(e,t){t instanceof g&&t.flyTo(this._viewer,{tolerance:.015})}show(e,t){e instanceof g&&(e.primitiveCollection.show=t,this._viewer.scene.requestRender())}}class L{constructor(e){this._viewer=e}async load(t){t=e(t,{});if("WMS"!==e(t.type,void 0))throw new Error("the layer type is not 'WMS'");const{url:s,layers:r}=t;if(!s)throw new Error("the url is needed");if(!r)throw new Error("the layers is needed");const i=new u({url:s}),n=new y(i,{});return this._viewer.imageryLayers.add(n),this._viewer.scene.requestRender(),n}async remove(e){e instanceof y&&(this._viewer.imageryLayers.remove(e,!0),this._viewer.scene.requestRender())}locate(e,t){if(t instanceof y)if(t.ready){const e=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:e})}else t.readyEvent.addEventListener((e=>{const s=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:s})}))}show(e,t){e instanceof y&&(e.show=t,this._viewer.scene.requestRender())}}class b{constructor(e){this._viewer=e}async load(t){t=e(t,{});if("WMTS"!==e(t.type,void 0))throw new Error("the layer type is not 'WMTS'");const{url:s,layer:r,style:i,tileMatrixSetID:n,subdomains:o,format:a,tilingScheme:h,tileMatrixLabels:l}=t;if(!s)throw new Error("the url is needed");if(!r)throw new Error("the layer is needed");if(!i)throw new Error("the style is needed");if(!n)throw new Error("the tileMatrixSetID is needed");const c={url:s,layer:r,style:i,tileMatrixSetID:n};o&&(c.subdomains=o),a&&(c.format=a),h&&(c.tilingScheme=h),l&&(c.tileMatrixLabels=l);const d=new p(c),w=new y(d,{});return this._viewer.imageryLayers.add(w),this._viewer.scene.requestRender(),w}async remove(e){e instanceof y&&(this._viewer.imageryLayers.remove(e,!0),this._viewer.scene.requestRender())}locate(e,t){if(t instanceof y)if(t.ready){const e=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:e})}else t.readyEvent.addEventListener((e=>{const s=t.getImageryRectangle();this._viewer.scene.camera.flyTo({destination:s})}))}show(e,t){e instanceof y&&(e.show=t,this._viewer.scene.requestRender())}}class C{constructor(e){this._viewer=e}async load(t){t=e(t,{});const s=e(t.type,void 0);if("KML"!==s&&"KMZ"!==s)throw new Error("the layer type is not 'KML' or 'KMZ");const{url:r,clampToGround:i}=t;if(!r)throw new Error("the url is needed");return this._viewer.dataSources.add(f.load(r,{camera:this._viewer.scene.camera,canvas:this._viewer.scene.canvas,clampToGround:i??!1}))}async remove(e){e instanceof Promise&&e.then((e=>{this._viewer.dataSources.remove(e),this._viewer.scene.requestRender()})),e instanceof f&&(this._viewer.dataSources.remove(e),this._viewer.scene.requestRender())}locate(e,t){t instanceof Promise&&t.then((e=>{this._viewer.flyTo(e)})),t instanceof f&&this._viewer.flyTo(t)}show(e,t){e instanceof Promise&&e.then((e=>{e.show=t,this._viewer.scene.requestRender()})),e instanceof f&&(e.show=t,this._viewer.scene.requestRender())}}class I{constructor(e){if(!e)throw new Error("请输入Viewer对象!");this._viewer=e,this._layersMap=new Map,this._typeClassMap=new Map}_initLoader(){const e=this._typeClassMap.get(this._type);e?this._typeClass=e:("TERRAIN"===this._type?this._typeClass=new R(this._viewer):"3DTILES"===this._type?this._typeClass=new E(this._viewer):"ARCGIS"===this._type?this._typeClass=new T(this._viewer):"URLTemplate"===this._type?this._typeClass=new S(this._viewer):"WMS"===this._type?this._typeClass=new L(this._viewer):"WMTS"===this._type?this._typeClass=new b(this._viewer):"KML"===this._type?this._typeClass=new C(this._viewer):"GEOJSON"===this._type&&(this._typeClass=new M(this._viewer)),this._typeClassMap.set(this._type,this._typeClass)),this._load=this._typeClass.load.bind(this._typeClass),this._remove=this._typeClass.remove.bind(this._typeClass),this._locate=this._typeClass.locate.bind(this._typeClass),this._show=this._typeClass.show.bind(this._typeClass)}async loadAsync(t){if(t=e(t,{}),this._id=e(t.id,void 0),this._layersMap.has(this._id))throw new Error(`the layer with id '${this._id}' is already loaded`);if(this._url=e(t.url,void 0),!this._url)throw new Error("the url is needed");if(this._type=e(t.type,void 0),!this._isSupport(t.type))throw new Error(`the type '${t.type}' is not support`);if(this._initLoader(),"KML"===t.type){const e=this._load(t);e instanceof Promise&&this._layersMap.set(t.id,{options:t,layer:e})}else{const e=await this._load(t);this._layersMap.set(t.id,{options:t,layer:e})}}_isSupport(e){return["TERRAIN","3DTILES","ARCGIS","URLTemplate","WMS","WMTS","KML","GEOJSON"].includes(e)}removeById(e){const t=this._layersMap.get(e);if(this._layersMap.delete(e),!t)return;const{options:s,layer:r}=t;r&&(this._type=s.type,this._initLoader(),this._remove(r))}locateById(e){const t=this._layersMap.get(e);if(!t)return;const{options:s,layer:r}=t;r&&(this._type=s.type,this._initLoader(),this._locate(s,r))}showById(e,t){const s=this._layersMap.get(e);if(!s)return;const{options:r,layer:i}=s;i&&(this._type=r.type,this._initLoader(),this._show(i,t))}destroy(){}}export{I as default};
1
+ import{defaultValue as t,Terrain as e,CesiumTerrainProvider as n,EllipsoidTerrainProvider as s,Rectangle as r,Cesium3DTileset as i,Matrix4 as o,Cartographic as a,Cartesian3 as c,Transforms as h,Matrix3 as u,Math as p,ArcGisMapServerImageryProvider as f,ImageryLayer as l,GeographicTilingScheme as d,Ellipsoid as y,UrlTemplateImageryProvider as w,WebMapServiceImageryProvider as m,WebMapTileServiceImageryProvider as I,KmlDataSource as v}from"cesium";import{GeoJsonPrimitiveLayer as g}from"@nsc-earth-2/primitive-geojson";function E(){const t=["14fBGubX","28tektUt","628795jsfFwd","scene","1514984JDWPnC","then","type","17954UaRBLc","bounds","3820482sthlwC","flyTo","show","valid_bounds","resolve","11qPAGGF","json","setTerrain","fromUrl","requestRender","202490hkiYSO","isArray","camera","/layer.json","21YBIncj","_viewer","TERRAIN","10PvMWow","locate","the layer type is not 'TERRAIN'","remove","url","2667654ObugcV","terrainProvider","24171564ozmmvw","fromDegrees","load","length"];return(E=function(){return t})()}const _=T;function T(t,e){const n=E();return(T=function(t,e){return n[t-=223]})(t,e)}!function(){const t=T,e=E();for(;;)try{if(783274===parseInt(t(257))/1+parseInt(t(245))/2*(-parseInt(t(224))/3)+-parseInt(t(239))/4*(parseInt(t(240))/5)+-parseInt(t(232))/6+parseInt(t(238))/7*(parseInt(t(242))/8)+-parseInt(t(247))/9*(parseInt(t(227))/10)+-parseInt(t(252))/11*(-parseInt(t(234))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class R{constructor(t){this[T(225)]=t}[_(236)](s){const r=_;s=t(s,{});if(t(s[r(244)],void 0)!==r(226))throw new Error(r(229));const i=t(s[r(231)],void 0),o=new e(n[r(255)](i));return this[r(225)][r(241)].setTerrain(o),this[r(225)][r(241)].requestRender(),Promise[r(251)](o)}[_(230)](t){const e=_,n=new s;this._viewer[e(233)]=n,this._viewer.scene.requestRender()}[_(228)](e,n){const s=_;e=t(e,{});const i=t(e[s(231)],void 0);fetch(i+s(223))[s(243)]((t=>t[s(253)]()))[s(243)]((t=>{const e=s;t[e(250)]&&Array[e(258)](t[e(250)])&&4===t[e(250)].length?this[e(225)][e(259)][e(248)]({destination:r[e(235)](t[e(250)][0],t[e(250)][1],t.valid_bounds[2],t[e(250)][3])}):t.bounds&&Array[e(258)](t.bounds)&&4==t[e(246)][e(237)]&&this[e(225)][e(259)][e(248)]({destination:r[e(235)](t[e(246)][0],t[e(246)][1],t[e(246)][2],t.bounds[3])})}))}[_(249)](t,n){const r=_;if(t instanceof e){if(n)this[r(225)].scene[r(254)](t);else{const t=new s;this[r(225)][r(233)]=t}this[r(225)][r(241)][r(256)]()}}}function S(){const t=["show","type","latitude","flyTo","longitude","fromUrl","155laggFT","getHeight","fromCartesian","multiply","15704MTvtCA","412342RqZFIr","toRadians","164871XCtIze","azimuth","_viewer","getTranslation","eastNorthUpToFixedFrame","globe","transferTileSet","10UwNBZv","4YGbMbu","root","713745VRTOaP","fromRotationZ","2394064brtVuk","multiplyByMatrix3","toDegrees","scene","requestRender","fromDegrees","3340579lJXiqY","primitives","transform","31852wBvRue","the layer type is not '3DTILES'","18lfUFDN"];return(S=function(){return t})()}const b=L;function L(t,e){const n=S();return(L=function(t,e){return n[t-=430]})(t,e)}!function(){const t=L,e=S();for(;;)try{if(159122===parseInt(t(443))/1*(-parseInt(t(432))/2)+parseInt(t(445))/3+parseInt(t(456))/4*(-parseInt(t(465))/5)+-parseInt(t(458))/6*(-parseInt(t(433))/7)+-parseInt(t(447))/8+parseInt(t(435))/9*(parseInt(t(442))/10)+parseInt(t(453))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class M{constructor(t){this._viewer=t}async load(e){const n=L;e=t(e,{});if("3DTILES"!==t(e[n(460)],void 0))throw new Error(n(457));const s=e.url;if(!s)throw new Error("the url is needed");const r={longitude:t(e[n(463)],0),latitude:t(e.latitude,0),altitude:t(e.altitude,0),azimuth:t(e[n(436)],0)},o=await i[n(464)](s,{dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:.00278,dynamicScreenSpaceErrorFactor:4,dynamicScreenSpaceErrorHeightFalloff:.25});return this[n(441)](o,r),this[n(437)][n(450)][n(454)].add(o),this[n(437)].scene[n(451)](),o}[b(441)](t,e){const n=b,{longitude:s,latitude:r,altitude:i,azimuth:f}=e;let l=new o;if(s&&r){let t=i;0==i&&(t=this[n(437)][n(450)][n(440)][n(466)](a[n(452)](s,r))||0);const e=c[n(452)](s,r,t),d=h[n(439)](e),y=new u(1,0,0,0,1,0,0,0,1),w=u[n(446)](p[n(434)](f));u[n(431)](y,w,y),l=o.multiplyByMatrix3(d,y,new o)}else if(i){const e=new c;o[n(438)](t[n(444)].transform,e);const s=a[n(430)](e);if(s){const t=p[n(449)](s[n(461)]),e=p[n(449)](s[n(463)]),r=c.fromDegrees(e,t,i),a=h[n(439)](r),d=new u(1,0,0,0,1,0,0,0,1),y=u[n(446)](p[n(434)](f));u[n(431)](d,y,d),l=o[n(448)](a,d,new o)}}else if(f){const e=new u(1,0,0,0,1,0,0,0,1),s=u[n(446)](p[n(434)](f));u[n(431)](e,s,e),l=o[n(448)](t[n(444)][n(455)],e,new o)}else l=t[n(444)].transform;t[n(444)][n(455)]=l}remove(t){const e=b;t instanceof i&&(this[e(437)][e(450)][e(454)].remove(t),this[e(437)].scene[e(451)]())}locate(t,e){const n=b;e instanceof i&&this._viewer[n(462)](e)}show(t,e){const n=b;t instanceof i&&(t[n(459)]=e,this._viewer[n(450)][n(451)]())}}const G=k;function k(t,e){const n=q();return(k=function(t,e){return n[t-=279]})(t,e)}function q(){const t=["extent","2024840RlQRvZ","/info/iteminfo?f=pjson&token=","token","349444kCOFkP","ready","the url is needed","_viewer","the layer type is not 'ARCGIS'","readyEvent","flyTo","type","fromDegrees","camera","then","10889748jCgyGO","alpha","fromProviderAsync","ARCGIS","remove","448rbEQJx","rectangle","show","requestRender","/info/iteminfo?f=pjson","51tZYXyH","6163056mqeouT","431836gyNPHp","98952NDmbEi","imageryLayers","getImageryRectangle","json","38888FyHTGe","isArray","scene"];return(q=function(){return t})()}!function(){const t=k,e=q();for(;;)try{if(611738===parseInt(t(312))/1+-parseInt(t(289))/2+parseInt(t(310))/3*(-parseInt(t(282))/4)+-parseInt(t(286))/5+parseInt(t(313))/6*(-parseInt(t(305))/7)+parseInt(t(311))/8+parseInt(t(300))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class x{constructor(t){this[k(292)]=t}async load(e){const n=k;e=t(e,{});if(t(e[n(296)],void 0)!==n(303))throw new Error(n(293));const{url:s,alpha:i,token:o}=e;if(!s)throw new Error(n(291));let a=s;a=o?s+n(287)+o:s+n(309);const c=await fetch(a,{method:"GET"})[n(299)]((t=>t[n(281)]()))[n(299)]((t=>{const e=n,s={};return o&&(s[e(288)]=o),t&&t[e(285)]&&Array[e(283)](t[e(285)])&&(s[e(306)]=r[e(297)](t.extent[0][0],t[e(285)][0][1],t[e(285)][1][0],t[e(285)][1][1])),s})),h=f.fromUrl(s,c),u=l[n(302)](h,{});return i&&(u[n(301)]=i),this[n(292)][n(279)].add(u),this[n(292)][n(284)][n(308)](),u}async[G(304)](t){const e=G;t instanceof l&&(this[e(292)][e(279)].remove(t,!0),this[e(292)][e(284)][e(308)]())}locate(t,e){const n=G;if(e instanceof l)if(e[n(290)]){const t=e[n(280)]();this[n(292)][n(284)][n(298)][n(295)]({destination:t})}else e[n(294)].addEventListener((t=>{const s=n,r=e[s(280)]();this[s(292)][s(284)].camera[s(295)]({destination:r})}))}[G(307)](t,e){const n=G;t instanceof l&&(t.show=e,this[n(292)][n(284)][n(308)]())}}const D=O;function N(){const t=["getImageryRectangle","fromDegrees","south","GET","1109808BuDIal","rectangle","remove","minimumLevel","meta.json","131349RWOEMk","the layer type is not 'URLTemplate'","north","bounds","ready","west","tilingScheme","52716zDJSaZ","locate","east","WGS84","readyEvent","URLTemplate","minzoom","then","980315ziomZW","the url is needed","282924QRcHeZ","2sYIevO","4Ytmkcb","requestRender","imageryLayers","6257339ufTITy","alpha","addEventListener","264102KoHuGI","flyTo","json","tilesize","indexOf","add","type","tileWidth","camera","maximumLevel","proj","maxzoom","scene","14puecpU","load","_viewer","10yLRJKP"];return(N=function(){return t})()}function O(t,e){const n=N();return(O=function(t,e){return n[t-=100]})(t,e)}!function(){const t=O,e=N();for(;;)try{if(105657===parseInt(t(136))/1*(-parseInt(t(147))/2)+-parseInt(t(129))/3*(-parseInt(t(148))/4)+-parseInt(t(144))/5+parseInt(t(103))/6*(-parseInt(t(116))/7)+-parseInt(t(124))/8+-parseInt(t(146))/9+parseInt(t(119))/10*(parseInt(t(100))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class z{constructor(t){this[O(118)]=t}async[D(117)](e){const n=D;e=t(e,{});if(t(e[n(109)],void 0)!==n(141))throw new Error(n(130));const{url:s,alpha:i}=e;if(!s)throw new Error(n(145));let o=s.substr(0,s[n(107)]("{z}/{x}/{y}.png"))+n(128);const a=await fetch(o,{method:n(123)})[n(143)]((t=>t[n(105)]()))[n(143)]((t=>{const e=n,i={url:s};return t&&t[e(132)]&&(i[e(125)]=r[e(121)](t.bounds[e(134)],t[e(132)][e(122)],t[e(132)][e(138)],t.bounds[e(131)])),t&&4326==t[e(113)]&&(i[e(135)]=new d({ellipsoid:y[e(139)]})),t&&t[e(114)]&&(i[e(112)]=t.maxzoom),t&&t.minzoom&&(i[e(127)]=t[e(142)]),t&&t.tilesize&&(i[e(110)]=i.tileHeight=t[e(106)]),i})),c=new w(a),h=new l(c,{});return i&&(h[n(101)]=i),this[n(118)].imageryLayers[n(108)](h),this._viewer[n(115)][n(149)](),h}async[D(126)](t){const e=D;t instanceof l&&(this._viewer[e(150)].remove(t,!0),this[e(118)].scene[e(149)]())}[D(137)](t,e){const n=D;if(e instanceof l)if(e[n(133)]){const t=e.getImageryRectangle();this[n(118)][n(115)][n(111)][n(104)]({destination:t})}else e[n(140)][n(102)]((t=>{const s=n,r=e[s(120)]();this._viewer[s(115)].camera[s(104)]({destination:r})}))}show(t,e){const n=D;t instanceof l&&(t.show=e,this[n(118)][n(115)][n(149)]())}}function A(t,e){const n=P();return(A=function(t,e){return n[t-=499]})(t,e)}const C=A;function P(){const t=["remove","locate","45nDetuG","GEOJSON","1463670giUels","_viewer","primitiveCollection","8OjnmpE","945381wlozPl","type","show","3289430waZuIV","add","scene","57372RnYuik","646104BZOheN","primitives","requestRender","load","the layer type is not 'GEOJSON'","189yQyofq","1839512VdaZuj","127769tEwYJU"];return(P=function(){return t})()}!function(){const t=A,e=P();for(;;)try{if(496879===parseInt(t(501))/1+-parseInt(t(500))/2+-parseInt(t(510))/3*(-parseInt(t(509))/4)+parseInt(t(513))/5+parseInt(t(516))/6*(parseInt(t(499))/7)+-parseInt(t(517))/8*(parseInt(t(504))/9)+parseInt(t(506))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class U{constructor(t){this[A(507)]=t}async load(e){const n=A;e=t(e,{});if(t(e[n(511)],void 0)!==n(505))throw new Error(n(521));const{url:s,clampToGround:r}=e;if(!s)throw new Error("the url is needed");const i=new g({options:{useGroundGeometry:r??!1,clampToGround:r??!1,scene:this._viewer.scene}});return await i[n(520)](s),this[n(507)].scene[n(518)][n(514)](i[n(508)]),this[n(507)][n(515)][n(519)](),i}async[C(502)](t){const e=C;t instanceof g&&(this[e(507)].scene[e(518)].remove(t[e(508)]),this[e(507)][e(515)][e(519)]())}[C(503)](t,e){const n=C;e instanceof g&&e.flyTo(this[n(507)],{tolerance:.015})}[C(512)](t,e){const n=C;t instanceof g&&(t[n(508)][n(512)]=e,this[n(507)][n(515)][n(519)]())}}const B=F;function F(t,e){const n=Z();return(F=function(t,e){return n[t-=418]})(t,e)}function Z(){const t=["camera","26PTFNgn","add","load","the url is needed","4327675gXniQi","show","requestRender","imageryLayers","readyEvent","7pIriCK","type","59621aNcHBz","the layers is needed","5942132tjZpFn","8589789gndTXd","locate","remove","270Quualg","1145001foEZYD","the layer type is not 'WMS'","_viewer","1979802QBNKgv","scene","12061864YQFfQs","6QsOjER","getImageryRectangle"];return(Z=function(){return t})()}!function(){const t=F,e=Z();for(;;)try{if(897562===parseInt(t(442))/1*(-parseInt(t(431))/2)+parseInt(t(425))/3+-parseInt(t(444))/4+-parseInt(t(435))/5*(parseInt(t(428))/6)+-parseInt(t(440))/7*(-parseInt(t(427))/8)+-parseInt(t(418))/9+parseInt(t(421))/10*(parseInt(t(422))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class j{constructor(t){this[F(424)]=t}async[B(433)](e){const n=B;e=t(e,{});if("WMS"!==t(e[n(441)],void 0))throw new Error(n(423));const{url:s,layers:r}=e;if(!s)throw new Error(n(434));if(!r)throw new Error(n(443));const i=new m({url:s}),o=new l(i,{});return this[n(424)].imageryLayers[n(432)](o),this[n(424)].scene.requestRender(),o}async remove(t){const e=B;t instanceof l&&(this._viewer[e(438)][e(420)](t,!0),this._viewer.scene[e(437)]())}[B(419)](t,e){const n=B;if(e instanceof l)if(e.ready){const t=e.getImageryRectangle();this[n(424)].scene[n(430)].flyTo({destination:t})}else e[n(439)].addEventListener((t=>{const s=n,r=e[s(429)]();this[s(424)][s(426)][s(430)].flyTo({destination:r})}))}[B(436)](t,e){const n=B;t instanceof l&&(t[n(436)]=e,this[n(424)][n(426)][n(437)]())}}function Q(t,e){const n=K();return(Q=function(t,e){return n[t-=213]})(t,e)}const W=Q;!function(){const t=Q,e=K();for(;;)try{if(660435===parseInt(t(241))/1+-parseInt(t(221))/2+parseInt(t(236))/3*(-parseInt(t(229))/4)+-parseInt(t(239))/5+-parseInt(t(240))/6+parseInt(t(226))/7*(parseInt(t(215))/8)+parseInt(t(238))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class J{constructor(t){this[Q(237)]=t}async[W(228)](e){const n=W;e=t(e,{});if("WMTS"!==t(e[n(230)],void 0))throw new Error(n(233));const{url:s,layer:r,style:i,tileMatrixSetID:o,subdomains:a,format:c,tilingScheme:h,tileMatrixLabels:u}=e;if(!s)throw new Error("the url is needed");if(!r)throw new Error(n(222));if(!i)throw new Error("the style is needed");if(!o)throw new Error(n(232));const p={url:s,layer:r,style:i,tileMatrixSetID:o};a&&(p[n(243)]=a),c&&(p[n(227)]=c),h&&(p.tilingScheme=h),u&&(p[n(224)]=u);const f=new I(p),d=new l(f,{});return this[n(237)][n(231)][n(242)](d),this[n(237)][n(220)].requestRender(),d}async remove(t){const e=W;t instanceof l&&(this[e(237)][e(231)][e(213)](t,!0),this[e(237)].scene[e(235)]())}[W(219)](t,e){const n=W;if(e instanceof l)if(e[n(225)]){const t=e.getImageryRectangle();this._viewer[n(220)][n(216)].flyTo({destination:t})}else e[n(214)][n(223)]((t=>{const s=n,r=e[s(217)]();this[s(237)][s(220)][s(216)][s(218)]({destination:r})}))}[W(234)](t,e){const n=W;t instanceof l&&(t[n(234)]=e,this[n(237)].scene[n(235)]())}}function K(){const t=["28xQnVmW","type","imageryLayers","the tileMatrixSetID is needed","the layer type is not 'WMTS'","show","requestRender","150882bdhQDp","_viewer","6893316XtPQoQ","1842000pfhFVK","4306392mUhCLg","582502XKhxqN","add","subdomains","remove","readyEvent","698056wiXZRQ","camera","getImageryRectangle","flyTo","locate","scene","70228xBfbfB","the layer is needed","addEventListener","tileMatrixLabels","ready","63gowJTE","format","load"];return(K=function(){return t})()}const H=V;function V(t,e){const n=X();return(V=function(t,e){return n[t-=233]})(t,e)}function X(){const t=["10xtTbpw","canvas","2271576UymTNv","the url is needed","locate","2989251VLAUGM","878899ppNLbr","3NvmJBO","3039512ggAPqX","24GKKmcW","_viewer","scene","add","show","flyTo","53587eHbALw","then","3081160krwctf","type","871035FvMahT","the layer type is not 'KML' or 'KMZ","requestRender","remove","dataSources","load"];return(X=function(){return t})()}!function(){const t=V,e=X();for(;;)try{if(526304===-parseInt(t(254))/1*(-parseInt(t(239))/2)+-parseInt(t(246))/3*(parseInt(t(247))/4)+-parseInt(t(233))/5+parseInt(t(241))/6+parseInt(t(245))/7+parseInt(t(248))/8*(parseInt(t(244))/9)+-parseInt(t(256))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Y{constructor(t){this[V(249)]=t}async[H(238)](e){const n=H;e=t(e,{});const s=t(e[n(257)],void 0);if("KML"!==s&&"KMZ"!==s)throw new Error(n(234));const{url:r,clampToGround:i}=e;if(!r)throw new Error(n(242));return this[n(249)].dataSources[n(251)](v.load(r,{camera:this[n(249)][n(250)].camera,canvas:this[n(249)][n(250)][n(240)],clampToGround:i??!1}))}async remove(t){const e=H;t instanceof Promise&&t[e(255)]((t=>{const n=e;this[n(249)][n(237)][n(236)](t),this[n(249)][n(250)][n(235)]()})),t instanceof v&&(this[e(249)].dataSources[e(236)](t),this[e(249)][e(250)].requestRender())}[H(243)](t,e){const n=H;e instanceof Promise&&e[n(255)]((t=>{const e=n;this._viewer[e(253)](t)})),e instanceof v&&this[n(249)].flyTo(e)}show(t,e){const n=H;t instanceof Promise&&t[n(255)]((t=>{const s=n;t[s(252)]=e,this._viewer[s(250)][s(235)]()})),t instanceof v&&(t[n(252)]=e,this[n(249)][n(250)][n(235)]())}}function $(t,e){const n=et();return($=function(t,e){return n[t-=267]})(t,e)}const tt=$;function et(){const t=["1608rQqocc","the url is needed","show","_viewer","_layersMap","WMTS","load","_isSupport","_initLoader","locate","GEOJSON","loadAsync","1512189wuHrEp","_load","3lzOgDs","removeById","_remove","URLTemplate","KML","3DTILES","TERRAIN","请输入Viewer对象!","delete","_typeClass","' is already loaded","' is not support","5824430LzhFMn","1632VZHSWN","811694rqVnul","8442yzhdkT","the type '","bind","includes","10970xJpVuJ","set","_type","get","581156sygPLk","remove","_url","the layer with id '","_id","_locate","_typeClassMap","1sxXdSa","type","18776384qrsbXL","WMS"];return(et=function(){return t})()}!function(){const t=$,e=et();for(;;)try{if(300626===-parseInt(t(286))/1*(parseInt(t(270))/2)+-parseInt(t(304))/3*(-parseInt(t(279))/4)+parseInt(t(275))/5*(-parseInt(t(290))/6)+parseInt(t(302))/7+-parseInt(t(269))/8*(parseInt(t(271))/9)+-parseInt(t(268))/10+parseInt(t(288))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class nt{constructor(t){const e=$;if(!t)throw new Error(e(311));this[e(293)]=t,this._layersMap=new Map,this[e(285)]=new Map}_initLoader(){const t=$,e=this[t(285)][t(278)](this._type);e?this._typeClass=e:(this[t(277)]===t(310)?this[t(313)]=new R(this[t(293)]):this._type===t(309)?this[t(313)]=new M(this[t(293)]):"ARCGIS"===this[t(277)]?this._typeClass=new x(this._viewer):this[t(277)]===t(307)?this[t(313)]=new z(this[t(293)]):"WMS"===this[t(277)]?this[t(313)]=new j(this[t(293)]):this[t(277)]===t(295)?this[t(313)]=new J(this[t(293)]):this[t(277)]===t(308)?this._typeClass=new Y(this[t(293)]):"GEOJSON"===this[t(277)]&&(this[t(313)]=new U(this[t(293)])),this[t(285)][t(276)](this[t(277)],this[t(313)])),this._load=this[t(313)][t(296)][t(273)](this[t(313)]),this[t(306)]=this[t(313)][t(280)][t(273)](this[t(313)]),this._locate=this[t(313)][t(299)].bind(this[t(313)]),this._show=this[t(313)][t(292)][t(273)](this[t(313)])}async[tt(301)](e){const n=tt;if(e=t(e,{}),this[n(283)]=t(e.id,void 0),this[n(294)].has(this[n(283)]))throw new Error(n(282)+this[n(283)]+n(314));if(this[n(281)]=t(e.url,void 0),!this[n(281)])throw new Error(n(291));if(this[n(277)]=t(e[n(287)],void 0),!this[n(297)](e.type))throw new Error(n(272)+e[n(287)]+n(267));if(this._initLoader(),e[n(287)]===n(308)){const t=this._load(e);t instanceof Promise&&this[n(294)].set(e.id,{options:e,layer:t})}else{const t=await this[n(303)](e);this[n(294)][n(276)](e.id,{options:e,layer:t})}}_isSupport(t){const e=tt;return[e(310),e(309),"ARCGIS","URLTemplate",e(289),e(295),"KML",e(300)][e(274)](t)}[tt(305)](t){const e=tt,n=this[e(294)][e(278)](t);if(this[e(294)][e(312)](t),!n)return;const{options:s,layer:r}=n;r&&(this._type=s[e(287)],this[e(298)](),this[e(306)](r))}locateById(t){const e=tt,n=this._layersMap[e(278)](t);if(!n)return;const{options:s,layer:r}=n;r&&(this._type=s[e(287)],this[e(298)](),this[e(284)](s,r))}showById(t,e){const n=tt,s=this[n(294)].get(t);if(!s)return;const{options:r,layer:i}=s;i&&(this[n(277)]=r[n(287)],this._initLoader(),this._show(i,e))}destroy(){}}export{nt as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsc-earth-2/layer",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -31,6 +31,6 @@
31
31
  "cesium": "^1.104.0"
32
32
  },
33
33
  "dependencies": {
34
- "@nsc-earth-2/primitive-geojson": "1.0.7"
34
+ "@nsc-earth-2/primitive-geojson": "1.0.8"
35
35
  }
36
36
  }