@juun-roh/cesium-utils 0.2.1 → 0.2.2
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.
- package/README.md +15 -2
- package/dist/chunk-DGHCIGKJ.js +1 -0
- package/dist/chunk-N24M6GYI.js +1 -0
- package/dist/chunk-TUJQL7MC.js +1 -0
- package/dist/{chunk-2JNRK7SN.js → chunk-Z2COOTT4.js} +1 -1
- package/dist/collection/index.cjs +1 -1
- package/dist/collection/index.d.cts +1 -1
- package/dist/collection/index.d.ts +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/dev/index.cjs +1 -0
- package/dist/{utils → dev}/index.d.cts +108 -11
- package/dist/{utils → dev}/index.d.ts +108 -11
- package/dist/dev/index.js +1 -0
- package/dist/{hybrid-terrain-provider-C7Ks0pK6.d.ts → hybrid-terrain-provider-C2V-igd9.d.cts} +2 -150
- package/dist/{hybrid-terrain-provider-C7Ks0pK6.d.cts → hybrid-terrain-provider-C2V-igd9.d.ts} +2 -150
- package/dist/{index-Bd_-DTWl.d.cts → index-C7kPHG5S.d.cts} +5 -1
- package/dist/{index-Bd_-DTWl.d.ts → index-C7kPHG5S.d.ts} +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +1 -2
- package/dist/terrain/index.d.ts +1 -2
- package/dist/terrain/index.js +1 -1
- package/dist/viewer/index.cjs +1 -1
- package/dist/viewer/index.js +1 -1
- package/package.json +13 -12
- package/dist/chunk-64HXTGRV.js +0 -1
- package/dist/chunk-NO7SO2WH.js +0 -1
- package/dist/utils/index.cjs +0 -1
- package/dist/utils/index.js +0 -1
package/README.md
CHANGED
|
@@ -37,15 +37,28 @@ This library supports modular exports, enabling you to import only the functiona
|
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
// Import everything from the main package
|
|
40
|
-
import { Collection, Highlight,
|
|
40
|
+
import { Collection, Highlight, HybridTerrainProvider } from "@juun-roh/cesium-utils";
|
|
41
41
|
|
|
42
42
|
// Or import specific modules to minimize bundle size
|
|
43
43
|
import { Collection } from "@juun-roh/cesium-utils/collection";
|
|
44
44
|
import { Highlight } from "@juun-roh/cesium-utils/highlight";
|
|
45
|
-
import {
|
|
45
|
+
import { HybridTerrainProvider } from "@juun-roh/cesium-utils/terrain";
|
|
46
46
|
import { cloneViewer, syncCamera } from "@juun-roh/cesium-utils/viewer";
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
## Development Utilities
|
|
50
|
+
|
|
51
|
+
For development and testing purposes, this library provides additional utilities through the `/utils` module. These utilities include deprecation warnings, terrain visualization helpers, and type checking functions.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// Import development utilities (not part of main API)
|
|
55
|
+
import { Deprecate, TerrainVisualizer, isGetterOnly } from "@juun-roh/cesium-utils/utils";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Note**: These utilities are intentionally not exported from the main package as they are primarily intended for development, testing, and advanced terrain configuration.
|
|
59
|
+
|
|
60
|
+
For detailed usage and examples, see [Development Utilities Documentation](src/utils/README.md).
|
|
61
|
+
|
|
49
62
|
## Development
|
|
50
63
|
|
|
51
64
|
### Building
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as g}from"./chunk-TUJQL7MC.js";import{EllipsoidTerrainProvider as y,Rectangle as m}from"cesium";var s=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new y,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,n,i){return this._defaultProvider.loadTileDataAvailability(e,n,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,n,i,t){if(this._ready){for(let r of this._regions)if(this._regionContains(r,e,n,i))return r.provider.requestTileGeometry(e,n,i,t);return this._defaultProvider.getTileDataAvailable(e,n,i)?this._defaultProvider.requestTileGeometry(e,n,i,t):this._fallbackProvider.requestTileGeometry(e,n,i,t)}}getTileDataAvailable(e,n,i){for(let t of this._regions)if(this._regionContains(t,e,n,i))return t.provider.getTileDataAvailable(e,n,i);return this._defaultProvider.getTileDataAvailable(e,n,i)}_regionContains(e,n,i,t){if(e.levels&&!e.levels.includes(t))return!1;if(e.tiles){let r=e.tiles.get(t);if(!r)return!1;let[a,o]=Array.isArray(r.x)?r.x:[r.x,r.x],[l,d]=Array.isArray(r.y)?r.y:[r.y,r.y];return n>=a&&n<=o&&i>=l&&i<=d}if(e.bounds){let r=this._tilingScheme.tileXYToRectangle(n,i,t);return m.intersection(r,e.bounds)!==void 0}return!1}};(i=>{function P(t,r,a){return new i({regions:t.map(o=>({...o})),defaultProvider:r,fallbackProvider:a})}i.fromRectangles=P;function e(t,r,a){return new i({regions:t.map(o=>({...o})),defaultProvider:r,fallbackProvider:a})}i.fromTileRanges=e;function n(t,r){if(g.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),r.size===0)return new m;let a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,d=Number.NEGATIVE_INFINITY,h=Array.from(r.keys()),u=Math.min(...h),v=r.get(u);if(v){let{start:b,end:c}=v,T=t.tileXYToRectangle(b.x,b.y,u),f=t.tileXYToRectangle(c.x,c.y,u);a=Math.min(T.west,a),o=Math.min(f.south,o),l=Math.max(f.east,l),d=Math.max(T.north,d)}return new m(a,o,l,d)}i.computeRectangle=n})(s||={});var p=s;export{p as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as L}from"./chunk-TUJQL7MC.js";import{Color as l,Entity as D,HeightReference as V,Rectangle as I,TileCoordinatesImageryProvider as j}from"cesium";import{DataSourceCollection as M,defined as f,EntityCollection as w,ImageryLayerCollection as O,PrimitiveCollection as F}from"cesium";var C=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof w?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof F?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof M?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof O&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof w)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)f(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)f(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)f(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(_(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},T=C;var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.RED],["default",l.BLUE],["fallback",l.GRAY],["grid",l.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new T({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new j({tilingScheme:this._terrainProvider.tilingScheme,color:l.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(a=>{this._collection.add(a.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(I.northwest(e),t),o=i.positionToTileXY(I.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],a=Math.min(e.end.x-e.start.x+1,100),s=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+a;h++)for(let d=e.start.y;d<e.start.y+s;d++)try{let v=this._createTileEntity(h,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${h}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let a=this._getTileColor(e,t,i),s=n.createRectangle(o,a.withAlpha(.3));return s.properties?.addProperty("tileX",e),s.properties?.addProperty("tileY",t),s.properties?.addProperty("tileLevel",i),s}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||l.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||l.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||l.BLUE:this._colors.get("fallback")||l.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new D({rectangle:{coordinates:r,material:o,heightReference:V.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,a){let s=a?.tag||"terrain_region_visualization",h=a?.color||l.RED,d=a?.maxTilesToShow||100,v=a?.show??!0,P=a?.alpha||.7,x=a?.tileAlpha||.2,m=new T({collection:o.entities,tag:s});if(r.bounds&&m.add(i.createRectangle(r.bounds,h.withAlpha(P)),s),v&&r.tiles&&r.tiles.size>0){let R=r.provider.tilingScheme,g=0;r.tiles.forEach((c,S)=>{let b=Array.isArray(c.x)?c.x:[c.x,c.x],E=Array.isArray(c.y)?c.y:[c.y,c.y];for(let p=b[0];p<=b[1]&&g<d;p++)for(let y=E[0];y<=E[1]&&g<d;y++){let A=R.tileXYToRectangle(p,y,S);m.add(e(A,h.withAlpha(x)),`${s}_tile`),g++}})}return m}i.visualize=t})(u||={});function _(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var Q=L.deprecate;export{u as a,_ as b,Q as c,T as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c;(w=>{let n=new Set,u=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function f(e,o={}){if(!u)return;let{once:r=!0,prefix:t="[DEPRECATED]",includeStack:i=!0,removeInVersion:s}=o;if(r&&n.has(e))return;let a=`${t} ${e}`;s&&(a+=` This feature will be removed in ${s}.`),typeof console<"u"&&console.warn&&(i?(console.warn(a),console.trace("Deprecation stack trace:")):console.warn(a)),r&&n.add(e)}w.warn=f;function l(e,o,r={}){let t=(...i)=>(f(o,r),e(...i));return Object.defineProperty(t,"name",{value:e.name,configurable:!0}),t}w.deprecate=l;function p(){n.clear()}w.clear=p;function d(){return n.size}w.getWarningCount=d;function g(e){return n.has(e)}w.hasShown=g})(c||={});var x=c;export{x as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Viewer as p}from"cesium";import{defined as m}from"cesium";function c(e,i){if(m(e)&&m(i)){let{camera:
|
|
1
|
+
import{Viewer as p}from"cesium";import{defined as m}from"cesium";function c(e,i){if(m(e)&&m(i)){let{camera:t}=e;i.camera.position=t.positionWC.clone(),i.camera.direction=t.directionWC.clone(),i.camera.up=t.upWC.clone()}}function y(e,i,t){let d={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p(i,{...d,...t});c(e,n);let l=e.imageryLayers;n.imageryLayers.removeAll();for(let a=0;a<l.length;a++){let s=l.get(a);n.imageryLayers.addImageryProvider(s.imageryProvider,a)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let o=e.scene.screenSpaceCameraController.tiltEventTypes;o&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(o)?[...o]:o);let r=e.scene.screenSpaceCameraController.zoomEventTypes;return r&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(r)?[...r]:r),n}export{c as a,y as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var C=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var M=(n,e)=>{for(var t in e)C(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!A.call(n,r)&&r!==t&&C(n,r,{get:()=>e[r],enumerable:!(i=x(e,r))||i.enumerable});return n};var F=n=>O(C({},"__esModule",{value:!0}),n);var V={};M(V,{Collection:()=>m});module.exports=F(V);var s=require("cesium");var a=require("cesium");var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new m({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),c=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+l;h++)for(let d=e.start.y;d<e.start.y+c;d++)try{let v=this._createTileEntity(h,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${h}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let l=this._getTileColor(e,t,i),c=n.createRectangle(o,l.withAlpha(.3));return c.properties?.addProperty("tileX",e),c.properties?.addProperty("tileY",t),c.properties?.addProperty("tileLevel",i),c}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let c=l?.tag||"terrain_area_visualization",h=l?.color||a.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,E=l?.alpha||.7,w=l?.tileAlpha||.2,p=new m({collection:o.entities,tag:c}),{rectangle:L}=r;if(p.add(i.createRectangle(L,h.withAlpha(E)),c),v&&r.tileRanges.size>0){let{tilingScheme:I}=r.terrainProvider,f=0;r.tileRanges.forEach((g,P)=>{for(let _=g.start.x;_<=g.end.x&&f<d;_++)for(let y=g.start.y;y<=g.end.y&&f<d;y++){let R=I.tileXYToRectangle(_,y,P);p.add(e(R,h.withAlpha(w)),`${c}_tile`),f++}})}return p}i.visualize=t})(u||={});function T(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var b=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof s.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof s.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof s.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof s.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof s.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,s.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,s.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,s.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(T(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},m=b;
|
|
1
|
+
"use strict";var E=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!F.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var N=n=>V(E({},"__esModule",{value:!0}),n);var j={};D(j,{Collection:()=>C});module.exports=N(j);var c=require("cesium");var P;(h=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,d={}){if(!e)return;let{once:v=!0,prefix:m="[DEPRECATED]",includeStack:p=!0,removeInVersion:g}=d;if(v&&n.has(s))return;let f=`${m} ${s}`;g&&(f+=` This feature will be removed in ${g}.`),typeof console<"u"&&console.warn&&(p?(console.warn(f),console.trace("Deprecation stack trace:")):console.warn(f)),v&&n.add(s)}h.warn=t;function i(s,d,v={}){let m=(...p)=>(t(d,v),s(...p));return Object.defineProperty(m,"name",{value:s.name,configurable:!0}),m}h.deprecate=i;function r(){n.clear()}h.clear=r;function o(){return n.size}h.getWarningCount=o;function l(s){return n.has(s)}h.hasShown=l})(P||={});var S=P;var a=require("cesium");var y=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new C({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),h=Math.min(e.end.y-e.start.y+1,100);for(let s=e.start.x;s<e.start.x+l;s++)for(let d=e.start.y;d<e.start.y+h;d++)try{let v=this._createTileEntity(s,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${s}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let l=this._getTileColor(e,t,i),h=n.createRectangle(o,l.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let h=l?.tag||"terrain_region_visualization",s=l?.color||a.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,m=l?.alpha||.7,p=l?.tileAlpha||.2,g=new C({collection:o.entities,tag:h});if(r.bounds&&g.add(i.createRectangle(r.bounds,s.withAlpha(m)),h),v&&r.tiles&&r.tiles.size>0){let f=r.provider.tilingScheme,_=0;r.tiles.forEach((u,R)=>{let x=Array.isArray(u.x)?u.x:[u.x,u.x],I=Array.isArray(u.y)?u.y:[u.y,u.y];for(let T=x[0];T<=x[1]&&_<d;T++)for(let b=I[0];b<=I[1]&&_<d;b++){let A=f.tileXYToRectangle(T,b,R);g.add(e(A,s.withAlpha(p)),`${h}_tile`),_++}})}return g}i.visualize=t})(y||={});function w(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var J=S.deprecate;var L=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof c.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof c.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof c.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof c.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(w(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},C=L;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as Collection } from '../index-
|
|
1
|
+
export { C as Collection } from '../index-C7kPHG5S.cjs';
|
|
2
2
|
import 'cesium';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as Collection } from '../index-
|
|
1
|
+
export { C as Collection } from '../index-C7kPHG5S.js';
|
|
2
2
|
import 'cesium';
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-RXMNSDKR.js";import{
|
|
1
|
+
import"../chunk-RXMNSDKR.js";import{d as a}from"../chunk-N24M6GYI.js";import"../chunk-TUJQL7MC.js";export{a as Collection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!F.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return n};var N=n=>V(E({},"__esModule",{value:!0}),n);var G={};D(G,{Deprecate:()=>w,TerrainVisualizer:()=>p,deprecate:()=>j,isGetterOnly:()=>C});module.exports=N(G);var S;(h=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(s,d={}){if(!e)return;let{once:v=!0,prefix:m="[DEPRECATED]",includeStack:f=!0,removeInVersion:g}=d;if(v&&n.has(s))return;let y=`${m} ${s}`;g&&(y+=` This feature will be removed in ${g}.`),typeof console<"u"&&console.warn&&(f?(console.warn(y),console.trace("Deprecation stack trace:")):console.warn(y)),v&&n.add(s)}h.warn=t;function i(s,d,v={}){let m=(...f)=>(t(d,v),s(...f));return Object.defineProperty(m,"name",{value:s.name,configurable:!0}),m}h.deprecate=i;function r(){n.clear()}h.clear=r;function o(){return n.size}h.getWarningCount=o;function l(s){return n.has(s)}h.hasShown=l})(S||={});var w=S;var a=require("cesium");var c=require("cesium");var L=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof c.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof c.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof c.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof c.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof c.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,c.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(C(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},x=L;var p=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new x({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),h=Math.min(e.end.y-e.start.y+1,100);for(let s=e.start.x;s<e.start.x+l;s++)for(let d=e.start.y;d<e.start.y+h;d++)try{let v=this._createTileEntity(s,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${s}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let l=this._getTileColor(e,t,i),h=n.createRectangle(o,l.withAlpha(.3));return h.properties?.addProperty("tileX",e),h.properties?.addProperty("tileY",t),h.properties?.addProperty("tileLevel",i),h}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let h=l?.tag||"terrain_region_visualization",s=l?.color||a.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,m=l?.alpha||.7,f=l?.tileAlpha||.2,g=new x({collection:o.entities,tag:h});if(r.bounds&&g.add(i.createRectangle(r.bounds,s.withAlpha(m)),h),v&&r.tiles&&r.tiles.size>0){let y=r.provider.tilingScheme,_=0;r.tiles.forEach((u,R)=>{let I=Array.isArray(u.x)?u.x:[u.x,u.x],P=Array.isArray(u.y)?u.y:[u.y,u.y];for(let T=I[0];T<=I[1]&&_<d;T++)for(let b=P[0];b<=P[1]&&_<d;b++){let A=y.tileXYToRectangle(T,b,R);g.add(e(A,s.withAlpha(f)),`${h}_tile`),_++}})}return g}i.visualize=t})(p||={});function C(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var j=w.deprecate;
|
|
@@ -1,7 +1,102 @@
|
|
|
1
|
-
import { Viewer, Color, EntityCollection, Entity
|
|
2
|
-
import { C as Collection } from '../index-
|
|
3
|
-
export { N as NonFunction, i as isGetterOnly } from '../index-
|
|
4
|
-
import { H as HybridTerrainProvider
|
|
1
|
+
import { Viewer, Color, Rectangle, EntityCollection, Entity } from 'cesium';
|
|
2
|
+
import { C as Collection } from '../index-C7kPHG5S.cjs';
|
|
3
|
+
export { N as NonFunction, i as isGetterOnly } from '../index-C7kPHG5S.cjs';
|
|
4
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
8
|
+
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
9
|
+
*/
|
|
10
|
+
declare namespace Deprecate {
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for deprecation warnings.
|
|
13
|
+
*/
|
|
14
|
+
interface Options {
|
|
15
|
+
/**
|
|
16
|
+
* Whether to show the warning only once per deprecation message.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
once?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom prefix for the warning message.
|
|
22
|
+
* @default "[DEPRECATED]"
|
|
23
|
+
*/
|
|
24
|
+
prefix?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to include a stack trace in the warning.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
includeStack?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Version when the feature will be removed.
|
|
32
|
+
*/
|
|
33
|
+
removeInVersion?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Displays a deprecation warning message.
|
|
37
|
+
*
|
|
38
|
+
* @param message - The deprecation message to display
|
|
39
|
+
* @param options - Configuration options for the warning
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Basic usage
|
|
44
|
+
* deprecationWarning("oldFunction() is deprecated. Use newFunction() instead.");
|
|
45
|
+
*
|
|
46
|
+
* // With removal version
|
|
47
|
+
* deprecationWarning("TerrainArea is deprecated.", {
|
|
48
|
+
* removeInVersion: "v0.3.0"
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Allow multiple warnings
|
|
52
|
+
* deprecationWarning("Repeated warning", { once: false });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function warn(message: string, options?: Options): void;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a deprecation wrapper function that shows a warning when called.
|
|
58
|
+
*
|
|
59
|
+
* @param fn - The function to wrap
|
|
60
|
+
* @param message - The deprecation message
|
|
61
|
+
* @param options - Configuration options for the warning
|
|
62
|
+
* @returns A wrapped function that shows a deprecation warning when called
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const oldFunction = deprecate(
|
|
67
|
+
* () => console.log("old implementation"),
|
|
68
|
+
* "oldFunction() is deprecated. Use newFunction() instead."
|
|
69
|
+
* );
|
|
70
|
+
*
|
|
71
|
+
* oldFunction(); // Shows warning and executes function
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
function deprecate<T extends (...args: any[]) => any>(fn: T, message: string, options?: Options): T;
|
|
75
|
+
/**
|
|
76
|
+
* Clears all shown warning messages.
|
|
77
|
+
* Useful for testing or when you want to reset the warning state.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* clearDeprecationWarnings();
|
|
82
|
+
* deprecationWarning("This will show again");
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
function clear(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the count of unique deprecation warnings that have been shown.
|
|
88
|
+
*
|
|
89
|
+
* @returns The number of unique deprecation warnings shown
|
|
90
|
+
*/
|
|
91
|
+
function getWarningCount(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if a specific deprecation warning has been shown.
|
|
94
|
+
*
|
|
95
|
+
* @param message - The deprecation message to check
|
|
96
|
+
* @returns True if the warning has been shown, false otherwise
|
|
97
|
+
*/
|
|
98
|
+
function hasShown(message: string): boolean;
|
|
99
|
+
}
|
|
5
100
|
|
|
6
101
|
/**
|
|
7
102
|
* @class
|
|
@@ -56,11 +151,11 @@ declare class TerrainVisualizer {
|
|
|
56
151
|
*/
|
|
57
152
|
setColors(colors: Record<string, Color>): void;
|
|
58
153
|
/**
|
|
59
|
-
* Flies the camera to focus on a
|
|
60
|
-
* @param
|
|
154
|
+
* Flies the camera to focus on a rectangle.
|
|
155
|
+
* @param rectangle The rectangle to focus on.
|
|
61
156
|
* @param options {@link Viewer.flyTo}
|
|
62
157
|
*/
|
|
63
|
-
flyTo(
|
|
158
|
+
flyTo(rectangle: Rectangle, options?: {
|
|
64
159
|
duration?: number;
|
|
65
160
|
}): void;
|
|
66
161
|
/**
|
|
@@ -124,13 +219,15 @@ declare namespace TerrainVisualizer {
|
|
|
124
219
|
tileAlpha?: number;
|
|
125
220
|
}
|
|
126
221
|
/**
|
|
127
|
-
* Visualizes a
|
|
128
|
-
* @param
|
|
222
|
+
* Visualizes a terrain region in a viewer.
|
|
223
|
+
* @param region The terrain region to visualize.
|
|
129
224
|
* @param viewer The Cesium viewer.
|
|
130
225
|
* @param options Visualization options.
|
|
131
226
|
* @returns Collection of created entities.
|
|
132
227
|
*/
|
|
133
|
-
function visualize(
|
|
228
|
+
function visualize(region: HybridTerrainProvider.TerrainRegion, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
134
229
|
}
|
|
135
230
|
|
|
136
|
-
|
|
231
|
+
declare const deprecate: typeof Deprecate.deprecate;
|
|
232
|
+
|
|
233
|
+
export { Deprecate, TerrainVisualizer, deprecate };
|
|
@@ -1,7 +1,102 @@
|
|
|
1
|
-
import { Viewer, Color, EntityCollection, Entity
|
|
2
|
-
import { C as Collection } from '../index-
|
|
3
|
-
export { N as NonFunction, i as isGetterOnly } from '../index-
|
|
4
|
-
import { H as HybridTerrainProvider
|
|
1
|
+
import { Viewer, Color, Rectangle, EntityCollection, Entity } from 'cesium';
|
|
2
|
+
import { C as Collection } from '../index-C7kPHG5S.js';
|
|
3
|
+
export { N as NonFunction, i as isGetterOnly } from '../index-C7kPHG5S.js';
|
|
4
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Utility for managing deprecation warnings in the cesium-utils library.
|
|
8
|
+
* Provides runtime warnings to help developers identify deprecated API usage.
|
|
9
|
+
*/
|
|
10
|
+
declare namespace Deprecate {
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for deprecation warnings.
|
|
13
|
+
*/
|
|
14
|
+
interface Options {
|
|
15
|
+
/**
|
|
16
|
+
* Whether to show the warning only once per deprecation message.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
once?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom prefix for the warning message.
|
|
22
|
+
* @default "[DEPRECATED]"
|
|
23
|
+
*/
|
|
24
|
+
prefix?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to include a stack trace in the warning.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
includeStack?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Version when the feature will be removed.
|
|
32
|
+
*/
|
|
33
|
+
removeInVersion?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Displays a deprecation warning message.
|
|
37
|
+
*
|
|
38
|
+
* @param message - The deprecation message to display
|
|
39
|
+
* @param options - Configuration options for the warning
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Basic usage
|
|
44
|
+
* deprecationWarning("oldFunction() is deprecated. Use newFunction() instead.");
|
|
45
|
+
*
|
|
46
|
+
* // With removal version
|
|
47
|
+
* deprecationWarning("TerrainArea is deprecated.", {
|
|
48
|
+
* removeInVersion: "v0.3.0"
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Allow multiple warnings
|
|
52
|
+
* deprecationWarning("Repeated warning", { once: false });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function warn(message: string, options?: Options): void;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a deprecation wrapper function that shows a warning when called.
|
|
58
|
+
*
|
|
59
|
+
* @param fn - The function to wrap
|
|
60
|
+
* @param message - The deprecation message
|
|
61
|
+
* @param options - Configuration options for the warning
|
|
62
|
+
* @returns A wrapped function that shows a deprecation warning when called
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const oldFunction = deprecate(
|
|
67
|
+
* () => console.log("old implementation"),
|
|
68
|
+
* "oldFunction() is deprecated. Use newFunction() instead."
|
|
69
|
+
* );
|
|
70
|
+
*
|
|
71
|
+
* oldFunction(); // Shows warning and executes function
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
function deprecate<T extends (...args: any[]) => any>(fn: T, message: string, options?: Options): T;
|
|
75
|
+
/**
|
|
76
|
+
* Clears all shown warning messages.
|
|
77
|
+
* Useful for testing or when you want to reset the warning state.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* clearDeprecationWarnings();
|
|
82
|
+
* deprecationWarning("This will show again");
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
function clear(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the count of unique deprecation warnings that have been shown.
|
|
88
|
+
*
|
|
89
|
+
* @returns The number of unique deprecation warnings shown
|
|
90
|
+
*/
|
|
91
|
+
function getWarningCount(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if a specific deprecation warning has been shown.
|
|
94
|
+
*
|
|
95
|
+
* @param message - The deprecation message to check
|
|
96
|
+
* @returns True if the warning has been shown, false otherwise
|
|
97
|
+
*/
|
|
98
|
+
function hasShown(message: string): boolean;
|
|
99
|
+
}
|
|
5
100
|
|
|
6
101
|
/**
|
|
7
102
|
* @class
|
|
@@ -56,11 +151,11 @@ declare class TerrainVisualizer {
|
|
|
56
151
|
*/
|
|
57
152
|
setColors(colors: Record<string, Color>): void;
|
|
58
153
|
/**
|
|
59
|
-
* Flies the camera to focus on a
|
|
60
|
-
* @param
|
|
154
|
+
* Flies the camera to focus on a rectangle.
|
|
155
|
+
* @param rectangle The rectangle to focus on.
|
|
61
156
|
* @param options {@link Viewer.flyTo}
|
|
62
157
|
*/
|
|
63
|
-
flyTo(
|
|
158
|
+
flyTo(rectangle: Rectangle, options?: {
|
|
64
159
|
duration?: number;
|
|
65
160
|
}): void;
|
|
66
161
|
/**
|
|
@@ -124,13 +219,15 @@ declare namespace TerrainVisualizer {
|
|
|
124
219
|
tileAlpha?: number;
|
|
125
220
|
}
|
|
126
221
|
/**
|
|
127
|
-
* Visualizes a
|
|
128
|
-
* @param
|
|
222
|
+
* Visualizes a terrain region in a viewer.
|
|
223
|
+
* @param region The terrain region to visualize.
|
|
129
224
|
* @param viewer The Cesium viewer.
|
|
130
225
|
* @param options Visualization options.
|
|
131
226
|
* @returns Collection of created entities.
|
|
132
227
|
*/
|
|
133
|
-
function visualize(
|
|
228
|
+
function visualize(region: HybridTerrainProvider.TerrainRegion, viewer: Viewer, options?: Options): Collection<EntityCollection, Entity>;
|
|
134
229
|
}
|
|
135
230
|
|
|
136
|
-
|
|
231
|
+
declare const deprecate: typeof Deprecate.deprecate;
|
|
232
|
+
|
|
233
|
+
export { Deprecate, TerrainVisualizer, deprecate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b,b as c,c as d}from"../chunk-N24M6GYI.js";import{a}from"../chunk-TUJQL7MC.js";export{a as Deprecate,b as TerrainVisualizer,d as deprecate,c as isGetterOnly};
|
package/dist/{hybrid-terrain-provider-C7Ks0pK6.d.ts → hybrid-terrain-provider-C2V-igd9.d.cts}
RENAMED
|
@@ -1,152 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @class
|
|
5
|
-
* @deprecated Use HybridTerrainProvider.TerrainRegion instead.
|
|
6
|
-
* This class is maintained for backward compatibility but will be removed in a future version.
|
|
7
|
-
*
|
|
8
|
-
* For migration:
|
|
9
|
-
* - Replace TerrainArea with HybridTerrainProvider.TerrainRegion
|
|
10
|
-
* - Use Rectangle.fromDegrees() for bounds instead of tile ranges
|
|
11
|
-
* - Simplify HybridTerrainProvider constructor to use regions directly
|
|
12
|
-
*
|
|
13
|
-
* Represents a geographic area with a specific terrain provider.
|
|
14
|
-
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
15
|
-
*/
|
|
16
|
-
declare class TerrainArea {
|
|
17
|
-
private _terrainProvider;
|
|
18
|
-
private _rectangle;
|
|
19
|
-
private _tileRanges;
|
|
20
|
-
private _ready;
|
|
21
|
-
private _credit;
|
|
22
|
-
private _isCustom;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new instance of `TerrainArea`.
|
|
25
|
-
* @param options Object describing initialization options
|
|
26
|
-
*/
|
|
27
|
-
constructor(options: TerrainArea.ConstructorOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
30
|
-
* @param x The tile X coordinate.
|
|
31
|
-
* @param y The tile Y coordinate.
|
|
32
|
-
* @param level The tile level.
|
|
33
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
34
|
-
*/
|
|
35
|
-
contains(x: number, y: number, level: number): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Requests the geometry for a given tile. The result must include terrain data and
|
|
38
|
-
* may optionally include a water mask and an indication of which child tiles are available.
|
|
39
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
40
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
41
|
-
* @param level - The level of the tile for which to request geometry.
|
|
42
|
-
* @param [request] - The request object. Intended for internal use only.
|
|
43
|
-
* @returns A promise for the requested geometry. If this method
|
|
44
|
-
* returns undefined instead of a promise, it is an indication that too many requests are already
|
|
45
|
-
* pending and the request will be retried later.
|
|
46
|
-
*/
|
|
47
|
-
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Determines whether data for a tile is available to be loaded.
|
|
50
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
51
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
52
|
-
* @param level - The level of the tile for which to request geometry.
|
|
53
|
-
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
54
|
-
* @see {@link TerrainProvider.getTileDataAvailable} */
|
|
55
|
-
getTileDataAvailable(x: number, y: number, level: number): boolean;
|
|
56
|
-
/** Checks if this terrain provider is marked as a custom provider. */
|
|
57
|
-
get isCustom(): boolean;
|
|
58
|
-
/** Gets the credit associated with this terrain area. */
|
|
59
|
-
get credit(): string | Credit;
|
|
60
|
-
/** Gets the terrain provider for this terrain area. */
|
|
61
|
-
get terrainProvider(): TerrainProvider;
|
|
62
|
-
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
63
|
-
get tileRanges(): Map<number, TerrainArea.TileRange>;
|
|
64
|
-
/** Gets the rectangle representing this terrain area. */
|
|
65
|
-
get rectangle(): Rectangle;
|
|
66
|
-
/** Gets if this terrain area is ready. */
|
|
67
|
-
get ready(): boolean;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* @namespace
|
|
71
|
-
* Contains types and factory methods for creating `TerrainArea` instances.
|
|
72
|
-
*/
|
|
73
|
-
declare namespace TerrainArea {
|
|
74
|
-
/** Initialization options for `TerrainArea` constructor. */
|
|
75
|
-
interface ConstructorOptions {
|
|
76
|
-
/** The terrain provider for this area or a URL to create one from. */
|
|
77
|
-
terrainProvider: TerrainProvider;
|
|
78
|
-
/**
|
|
79
|
-
* Tile ranges by level when using tileRange type.
|
|
80
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
81
|
-
*/
|
|
82
|
-
tileRanges: Map<number, TileRange>;
|
|
83
|
-
/**
|
|
84
|
-
* Credit to associate with this terrain provider.
|
|
85
|
-
* Used to identify custom terrain providers.
|
|
86
|
-
* @default custom
|
|
87
|
-
*/
|
|
88
|
-
credit?: string | Credit;
|
|
89
|
-
/**
|
|
90
|
-
* Whether this is a custom terrain provider.
|
|
91
|
-
* @default true
|
|
92
|
-
*/
|
|
93
|
-
isCustom?: boolean;
|
|
94
|
-
}
|
|
95
|
-
/** A range of tiles from `start` to `end` */
|
|
96
|
-
type TileRange = {
|
|
97
|
-
/** Top Left tile coordinates */
|
|
98
|
-
start: {
|
|
99
|
-
x: number;
|
|
100
|
-
y: number;
|
|
101
|
-
};
|
|
102
|
-
/** Bottom Right tile coordinates */
|
|
103
|
-
end: {
|
|
104
|
-
x: number;
|
|
105
|
-
y: number;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
110
|
-
* @param url The URL to create the terrain provider from.
|
|
111
|
-
* @param tileRanges Tile ranges by level.
|
|
112
|
-
* @param options: Constructor options for CesiumTerrainProvider.
|
|
113
|
-
* @returns A promise resolving to a new `TerrainArea`
|
|
114
|
-
*/
|
|
115
|
-
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
116
|
-
/**
|
|
117
|
-
* @extends Array
|
|
118
|
-
* @class
|
|
119
|
-
* Collection-like Extended Array Class of `TerrainArea`.
|
|
120
|
-
*/
|
|
121
|
-
class Collection extends Array<TerrainArea> {
|
|
122
|
-
/**
|
|
123
|
-
* Adds a new terrain area to the collection.
|
|
124
|
-
* @param area A TerrainArea instance or constructor options
|
|
125
|
-
* @returns The index of the added item
|
|
126
|
-
*/
|
|
127
|
-
add(area: TerrainArea | TerrainArea.ConstructorOptions): this;
|
|
128
|
-
/**
|
|
129
|
-
* Adds terrain areas to the collection.
|
|
130
|
-
* @param areas An array of TerrainArea instance or constructor options
|
|
131
|
-
* @returns The index of the added item
|
|
132
|
-
*/
|
|
133
|
-
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): this;
|
|
134
|
-
/**
|
|
135
|
-
* Removes a terrain area from the collection.
|
|
136
|
-
* @param area The terrain area to remove.
|
|
137
|
-
*/
|
|
138
|
-
remove(area: TerrainArea): this;
|
|
139
|
-
/**
|
|
140
|
-
* Removes multiple terrain areas from the collection.
|
|
141
|
-
* @param areas The terrain areas to remove.
|
|
142
|
-
*/
|
|
143
|
-
remove(areas: TerrainArea[]): this;
|
|
144
|
-
/**
|
|
145
|
-
* Clears all terrain areas.
|
|
146
|
-
*/
|
|
147
|
-
removeAll(): void;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
1
|
+
import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData, Rectangle } from 'cesium';
|
|
150
2
|
|
|
151
3
|
/**
|
|
152
4
|
* @class
|
|
@@ -347,4 +199,4 @@ declare namespace HybridTerrainProvider {
|
|
|
347
199
|
function computeRectangle(tilingScheme: TilingScheme, from: Map<number, any>): Rectangle;
|
|
348
200
|
}
|
|
349
201
|
|
|
350
|
-
export { HybridTerrainProvider as H
|
|
202
|
+
export { HybridTerrainProvider as H };
|
package/dist/{hybrid-terrain-provider-C7Ks0pK6.d.cts → hybrid-terrain-provider-C2V-igd9.d.ts}
RENAMED
|
@@ -1,152 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @class
|
|
5
|
-
* @deprecated Use HybridTerrainProvider.TerrainRegion instead.
|
|
6
|
-
* This class is maintained for backward compatibility but will be removed in a future version.
|
|
7
|
-
*
|
|
8
|
-
* For migration:
|
|
9
|
-
* - Replace TerrainArea with HybridTerrainProvider.TerrainRegion
|
|
10
|
-
* - Use Rectangle.fromDegrees() for bounds instead of tile ranges
|
|
11
|
-
* - Simplify HybridTerrainProvider constructor to use regions directly
|
|
12
|
-
*
|
|
13
|
-
* Represents a geographic area with a specific terrain provider.
|
|
14
|
-
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
15
|
-
*/
|
|
16
|
-
declare class TerrainArea {
|
|
17
|
-
private _terrainProvider;
|
|
18
|
-
private _rectangle;
|
|
19
|
-
private _tileRanges;
|
|
20
|
-
private _ready;
|
|
21
|
-
private _credit;
|
|
22
|
-
private _isCustom;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new instance of `TerrainArea`.
|
|
25
|
-
* @param options Object describing initialization options
|
|
26
|
-
*/
|
|
27
|
-
constructor(options: TerrainArea.ConstructorOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Checks if the specified tile coordinates are within the bounds.
|
|
30
|
-
* @param x The tile X coordinate.
|
|
31
|
-
* @param y The tile Y coordinate.
|
|
32
|
-
* @param level The tile level.
|
|
33
|
-
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
34
|
-
*/
|
|
35
|
-
contains(x: number, y: number, level: number): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Requests the geometry for a given tile. The result must include terrain data and
|
|
38
|
-
* may optionally include a water mask and an indication of which child tiles are available.
|
|
39
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
40
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
41
|
-
* @param level - The level of the tile for which to request geometry.
|
|
42
|
-
* @param [request] - The request object. Intended for internal use only.
|
|
43
|
-
* @returns A promise for the requested geometry. If this method
|
|
44
|
-
* returns undefined instead of a promise, it is an indication that too many requests are already
|
|
45
|
-
* pending and the request will be retried later.
|
|
46
|
-
*/
|
|
47
|
-
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Determines whether data for a tile is available to be loaded.
|
|
50
|
-
* @param x - The X coordinate of the tile for which to request geometry.
|
|
51
|
-
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
52
|
-
* @param level - The level of the tile for which to request geometry.
|
|
53
|
-
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
54
|
-
* @see {@link TerrainProvider.getTileDataAvailable} */
|
|
55
|
-
getTileDataAvailable(x: number, y: number, level: number): boolean;
|
|
56
|
-
/** Checks if this terrain provider is marked as a custom provider. */
|
|
57
|
-
get isCustom(): boolean;
|
|
58
|
-
/** Gets the credit associated with this terrain area. */
|
|
59
|
-
get credit(): string | Credit;
|
|
60
|
-
/** Gets the terrain provider for this terrain area. */
|
|
61
|
-
get terrainProvider(): TerrainProvider;
|
|
62
|
-
/** Gets available tile ranges with zoom levels set with this terrain area. */
|
|
63
|
-
get tileRanges(): Map<number, TerrainArea.TileRange>;
|
|
64
|
-
/** Gets the rectangle representing this terrain area. */
|
|
65
|
-
get rectangle(): Rectangle;
|
|
66
|
-
/** Gets if this terrain area is ready. */
|
|
67
|
-
get ready(): boolean;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* @namespace
|
|
71
|
-
* Contains types and factory methods for creating `TerrainArea` instances.
|
|
72
|
-
*/
|
|
73
|
-
declare namespace TerrainArea {
|
|
74
|
-
/** Initialization options for `TerrainArea` constructor. */
|
|
75
|
-
interface ConstructorOptions {
|
|
76
|
-
/** The terrain provider for this area or a URL to create one from. */
|
|
77
|
-
terrainProvider: TerrainProvider;
|
|
78
|
-
/**
|
|
79
|
-
* Tile ranges by level when using tileRange type.
|
|
80
|
-
* Keys are zoom levels, values define the range of tiles at that level.
|
|
81
|
-
*/
|
|
82
|
-
tileRanges: Map<number, TileRange>;
|
|
83
|
-
/**
|
|
84
|
-
* Credit to associate with this terrain provider.
|
|
85
|
-
* Used to identify custom terrain providers.
|
|
86
|
-
* @default custom
|
|
87
|
-
*/
|
|
88
|
-
credit?: string | Credit;
|
|
89
|
-
/**
|
|
90
|
-
* Whether this is a custom terrain provider.
|
|
91
|
-
* @default true
|
|
92
|
-
*/
|
|
93
|
-
isCustom?: boolean;
|
|
94
|
-
}
|
|
95
|
-
/** A range of tiles from `start` to `end` */
|
|
96
|
-
type TileRange = {
|
|
97
|
-
/** Top Left tile coordinates */
|
|
98
|
-
start: {
|
|
99
|
-
x: number;
|
|
100
|
-
y: number;
|
|
101
|
-
};
|
|
102
|
-
/** Bottom Right tile coordinates */
|
|
103
|
-
end: {
|
|
104
|
-
x: number;
|
|
105
|
-
y: number;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
110
|
-
* @param url The URL to create the terrain provider from.
|
|
111
|
-
* @param tileRanges Tile ranges by level.
|
|
112
|
-
* @param options: Constructor options for CesiumTerrainProvider.
|
|
113
|
-
* @returns A promise resolving to a new `TerrainArea`
|
|
114
|
-
*/
|
|
115
|
-
function fromUrl(url: string, tileRanges: Map<number, TileRange>, options?: CesiumTerrainProvider.ConstructorOptions): Promise<Awaited<TerrainArea>>;
|
|
116
|
-
/**
|
|
117
|
-
* @extends Array
|
|
118
|
-
* @class
|
|
119
|
-
* Collection-like Extended Array Class of `TerrainArea`.
|
|
120
|
-
*/
|
|
121
|
-
class Collection extends Array<TerrainArea> {
|
|
122
|
-
/**
|
|
123
|
-
* Adds a new terrain area to the collection.
|
|
124
|
-
* @param area A TerrainArea instance or constructor options
|
|
125
|
-
* @returns The index of the added item
|
|
126
|
-
*/
|
|
127
|
-
add(area: TerrainArea | TerrainArea.ConstructorOptions): this;
|
|
128
|
-
/**
|
|
129
|
-
* Adds terrain areas to the collection.
|
|
130
|
-
* @param areas An array of TerrainArea instance or constructor options
|
|
131
|
-
* @returns The index of the added item
|
|
132
|
-
*/
|
|
133
|
-
add(areas: (TerrainArea | TerrainArea.ConstructorOptions)[]): this;
|
|
134
|
-
/**
|
|
135
|
-
* Removes a terrain area from the collection.
|
|
136
|
-
* @param area The terrain area to remove.
|
|
137
|
-
*/
|
|
138
|
-
remove(area: TerrainArea): this;
|
|
139
|
-
/**
|
|
140
|
-
* Removes multiple terrain areas from the collection.
|
|
141
|
-
* @param areas The terrain areas to remove.
|
|
142
|
-
*/
|
|
143
|
-
remove(areas: TerrainArea[]): this;
|
|
144
|
-
/**
|
|
145
|
-
* Clears all terrain areas.
|
|
146
|
-
*/
|
|
147
|
-
removeAll(): void;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
1
|
+
import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData, Rectangle } from 'cesium';
|
|
150
2
|
|
|
151
3
|
/**
|
|
152
4
|
* @class
|
|
@@ -347,4 +199,4 @@ declare namespace HybridTerrainProvider {
|
|
|
347
199
|
function computeRectangle(tilingScheme: TilingScheme, from: Map<number, any>): Rectangle;
|
|
348
200
|
}
|
|
349
201
|
|
|
350
|
-
export { HybridTerrainProvider as H
|
|
202
|
+
export { HybridTerrainProvider as H };
|
|
@@ -106,7 +106,7 @@ type NonFunction<T> = {
|
|
|
106
106
|
* }
|
|
107
107
|
* }
|
|
108
108
|
*/
|
|
109
|
-
declare class Collection<C extends Collection.Base, I extends Collection.
|
|
109
|
+
declare class Collection<C extends Collection.Base, I extends Collection.ItemFor<C>> {
|
|
110
110
|
/**
|
|
111
111
|
* Symbol used as a property key to store tags on collection items.
|
|
112
112
|
* Using a Symbol ensures no property naming conflicts with the item's own properties.
|
|
@@ -499,6 +499,10 @@ declare namespace Collection {
|
|
|
499
499
|
* Cesium item type that can be added to the {@link Collection.Base} instance.
|
|
500
500
|
*/
|
|
501
501
|
export type Item = DataSource | Entity | ImageryLayer | Primitives;
|
|
502
|
+
/**
|
|
503
|
+
* Gets the item type for a given collection type
|
|
504
|
+
*/
|
|
505
|
+
export type ItemFor<C extends Base> = C extends DataSourceCollection ? DataSource : C extends EntityCollection ? Entity : C extends ImageryLayerCollection ? ImageryLayer : C extends PrimitiveCollection ? Primitives : never;
|
|
502
506
|
/**
|
|
503
507
|
* Collection tag type.
|
|
504
508
|
*/
|
|
@@ -106,7 +106,7 @@ type NonFunction<T> = {
|
|
|
106
106
|
* }
|
|
107
107
|
* }
|
|
108
108
|
*/
|
|
109
|
-
declare class Collection<C extends Collection.Base, I extends Collection.
|
|
109
|
+
declare class Collection<C extends Collection.Base, I extends Collection.ItemFor<C>> {
|
|
110
110
|
/**
|
|
111
111
|
* Symbol used as a property key to store tags on collection items.
|
|
112
112
|
* Using a Symbol ensures no property naming conflicts with the item's own properties.
|
|
@@ -499,6 +499,10 @@ declare namespace Collection {
|
|
|
499
499
|
* Cesium item type that can be added to the {@link Collection.Base} instance.
|
|
500
500
|
*/
|
|
501
501
|
export type Item = DataSource | Entity | ImageryLayer | Primitives;
|
|
502
|
+
/**
|
|
503
|
+
* Gets the item type for a given collection type
|
|
504
|
+
*/
|
|
505
|
+
export type ItemFor<C extends Base> = C extends DataSourceCollection ? DataSource : C extends EntityCollection ? Entity : C extends ImageryLayerCollection ? ImageryLayer : C extends PrimitiveCollection ? Primitives : never;
|
|
502
506
|
/**
|
|
503
507
|
* Collection tag type.
|
|
504
508
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var G=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)G(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!X.call(n,r)&&r!==t&&G(n,r,{get:()=>e[r],enumerable:!(i=W(e,r))||i.enumerable});return n};var J=n=>K(G({},"__esModule",{value:!0}),n);var Q={};$(Q,{Collection:()=>C,Highlight:()=>F,HybridTerrainProvider:()=>R,SilhouetteHighlight:()=>f,SurfaceHighlight:()=>p,TerrainArea:()=>M,TerrainVisualizer:()=>_,cloneViewer:()=>j,isGetterOnly:()=>w,syncCamera:()=>O});module.exports=J(Q);var g=require("cesium");var c=require("cesium");var _=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",c.Color.RED],["default",c.Color.BLUE],["fallback",c.Color.GRAY],["grid",c.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new C({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new c.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:c.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(c.Rectangle.northwest(e),t),o=i.positionToTileXY(c.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+s;h++)for(let u=e.start.y;u<e.start.y+l;u++)try{let v=this._createTileEntity(h,u,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${h}, ${u}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,i),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||c.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||c.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||c.Color.BLUE:this._colors.get("fallback")||c.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new c.Entity({rectangle:{coordinates:r,material:o,heightReference:c.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_area_visualization",h=s?.color||c.Color.RED,u=s?.maxTilesToShow||100,v=s?.show??!0,P=s?.alpha||.7,x=s?.tileAlpha||.2,y=new C({collection:o.entities,tag:l}),{rectangle:S}=r;if(y.add(i.createRectangle(S,h.withAlpha(P)),l),v&&r.tileRanges.size>0){let{tilingScheme:L}=r.terrainProvider,T=0;r.tileRanges.forEach((I,z)=>{for(let H=I.start.x;H<=I.end.x&&T<u;H++)for(let V=I.start.y;V<=I.end.y&&T<u;V++){let Y=L.tileXYToRectangle(H,V,z);y.add(e(Y,h.withAlpha(x)),`${l}_tile`),T++}})}return y}i.visualize=t})(_||={});function w(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var D=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof g.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof g.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof g.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof g.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof g.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(w(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},C=D;var m=require("cesium");var d=require("cesium"),f=class{_color=d.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=d.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=d.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if((0,d.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof d.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new d.ConstantProperty(t?.width||2),e.model.silhouetteColor=new d.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&d.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new d.ConstantProperty(d.Color.TRANSPARENT),this._entity.model.silhouetteSize=new d.ConstantProperty(0),this._entity=void 0)}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}};var a=require("cesium"),p=class{_color=a.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&a.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let l=0;l<o.length;l+=3)s.push(new a.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(s),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}};var k=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new p(e),this._silhouette=new f(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,m.defined)(i))return i instanceof m.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof m.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,m.defined)(e)){if(e instanceof m.Entity||e instanceof m.Cesium3DTileFeature||e instanceof m.GroundPrimitive)return e;if(e.id instanceof m.Entity)return e.id;if(e.primitive instanceof m.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}},F=k;var b=require("cesium");var B=require("cesium");var E=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=R.computeRectangle(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((t,i)=>{this._terrainProvider.availability?.addAvailableTileRange(i,t.start.x,t.start.y,t.end.x,t.end.y)}),this._ready=!0}contains(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}requestTileGeometry(e,t,i,r){if(!(!this._ready||!this.contains(e,t,i)))return this._terrainProvider.requestTileGeometry(e,t,i,r)}getTileDataAvailable(e,t,i){if(this._tileRanges.size===0||!this._tileRanges.has(i))return!1;let r=this._tileRanges.get(i);return e>=r.start.x&&e<=r.end.x&&t>=r.start.y&&t<=r.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(t=>{async function n(i,r,o){let s=o?.credit||"custom",l=await B.CesiumTerrainProvider.fromUrl(i,{...o,credit:s});return new t({terrainProvider:l,tileRanges:r,credit:s})}t.fromUrl=n;class e extends Array{add(r){if(Array.isArray(r)){for(let s of r)this.add(s);return this}let o;return r instanceof t?o=r:o=new t(r),this.push(o),this}remove(r){if(Array.isArray(r))return r.forEach(s=>this.remove(s)),this;let o=this.indexOf(r);return o>=0&&this.splice(o,1),this}removeAll(){this.length=0}}t.Collection=e})(E||={});var M=E;var A=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new b.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(this._regionContains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(this._regionContains(r,e,t,i))return r.provider.getTileDataAvailable(e,t,i);return this._defaultProvider.getTileDataAvailable(e,t,i)}_regionContains(e,t,i,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let o=e.tiles.get(r);if(!o)return!1;let[s,l]=Array.isArray(o.x)?o.x:[o.x,o.x],[h,u]=Array.isArray(o.y)?o.y:[o.y,o.y];return t>=s&&t<=l&&i>=h&&i<=u}if(e.bounds){let o=this._tilingScheme.tileXYToRectangle(t,i,r);return b.Rectangle.intersection(o,e.bounds)!==void 0}return!1}};(i=>{function n(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromRectangles=n;function e(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=e;function t(r,o){if(o.size===0)return new b.Rectangle;let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,v=Array.from(o.keys()),P=Math.min(...v),x=o.get(P);if(x){let{start:y,end:S}=x,L=r.tileXYToRectangle(y.x,y.y,P),T=r.tileXYToRectangle(S.x,S.y,P);s=Math.min(L.west,s),l=Math.min(T.south,l),h=Math.max(T.east,h),u=Math.max(L.north,u)}return new b.Rectangle(s,l,h,u)}i.computeRectangle=t})(A||={});var R=A;var q=require("cesium");var N=require("cesium");function O(n,e){if((0,N.defined)(n)&&(0,N.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function j(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new q.Viewer(e,{...i,...t});O(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let h=0;h<o.length;h++){let u=o.get(h);r.imageryLayers.addImageryProvider(u.imageryProvider,h)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
|
1
|
+
"use strict";var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $(e))!U.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(i=q(e,r))||i.enumerable});return n};var J=n=>K(L({},"__esModule",{value:!0}),n);var Q={};X(Q,{Collection:()=>w,Highlight:()=>V,HybridTerrainProvider:()=>G,SilhouetteHighlight:()=>T,SurfaceHighlight:()=>b,cloneViewer:()=>F,syncCamera:()=>R});module.exports=J(Q);var g=require("cesium");var j;(l=>{let n=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function t(c,d={}){if(!e)return;let{once:v=!0,prefix:p="[DEPRECATED]",includeStack:_=!0,removeInVersion:y}=d;if(v&&n.has(c))return;let C=`${p} ${c}`;y&&(C+=` This feature will be removed in ${y}.`),typeof console<"u"&&console.warn&&(_?(console.warn(C),console.trace("Deprecation stack trace:")):console.warn(C)),v&&n.add(c)}l.warn=t;function i(c,d,v={}){let p=(..._)=>(t(d,v),c(..._));return Object.defineProperty(p,"name",{value:c.name,configurable:!0}),p}l.deprecate=i;function r(){n.clear()}l.clear=r;function o(){return n.size}l.getWarningCount=o;function s(c){return n.has(c)}l.hasShown=s})(j||={});var S=j;var h=require("cesium");var O=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",h.Color.RED],["default",h.Color.BLUE],["fallback",h.Color.GRAY],["grid",h.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new w({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new h.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:h.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(s=>{this._collection.add(s.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(h.Rectangle.northwest(e),t),o=i.positionToTileXY(h.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],s=Math.min(e.end.x-e.start.x+1,100),l=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+s;c++)for(let d=e.start.y;d<e.start.y+l;d++)try{let v=this._createTileEntity(c,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${c}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let s=this._getTileColor(e,t,i),l=n.createRectangle(o,s.withAlpha(.3));return l.properties?.addProperty("tileX",e),l.properties?.addProperty("tileY",t),l.properties?.addProperty("tileLevel",i),l}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||h.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||h.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||h.Color.BLUE:this._colors.get("fallback")||h.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){this._viewer.camera.flyTo({destination:e,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new h.Entity({rectangle:{coordinates:r,material:o,heightReference:h.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,s){let l=s?.tag||"terrain_region_visualization",c=s?.color||h.Color.RED,d=s?.maxTilesToShow||100,v=s?.show??!0,p=s?.alpha||.7,_=s?.tileAlpha||.2,y=new w({collection:o.entities,tag:l});if(r.bounds&&y.add(i.createRectangle(r.bounds,c.withAlpha(p)),l),v&&r.tiles&&r.tiles.size>0){let C=r.provider.tilingScheme,P=0;r.tiles.forEach((f,W)=>{let N=Array.isArray(f.x)?f.x:[f.x,f.x],B=Array.isArray(f.y)?f.y:[f.y,f.y];for(let I=N[0];I<=N[1]&&P<d;I++)for(let A=B[0];A<=B[1]&&P<d;A++){let Y=C.tileXYToRectangle(I,A,W);y.add(e(Y,c.withAlpha(_)),`${l}_tile`),P++}})}return y}i.visualize=t})(O||={});function H(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}var de=S.deprecate;var M=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof g.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof g.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof g.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof g.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof g.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,g.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(H(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},w=M;var m=require("cesium");var u=require("cesium"),T=class{_color=u.Color.RED;_silhouette;_composite;_stages;_entity;_currentObject;_currentOptions;constructor(e){this._stages=e.scene.postProcessStages,this._silhouette=u.PostProcessStageLibrary.createEdgeDetectionStage(),this._silhouette.uniforms.color=this._color,this._silhouette.uniforms.length=.01,this._silhouette.selected=[],this._composite=u.PostProcessStageLibrary.createSilhouetteStage([this._silhouette]),this._stages.add(this._composite)}show(e,t){if((0,u.defined)(e)&&!(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))){this._clearHighlights();try{if(e instanceof u.Cesium3DTileFeature)this._silhouette.uniforms.color=t?.color||this._color,this._silhouette.selected.push(e);else{if(!e.model)return;this._entity=e,e.model.silhouetteSize=new u.ConstantProperty(t?.width||2),e.model.silhouetteColor=new u.ConstantProperty(t?.color||this._color)}this._currentObject=e,this._currentOptions=t?{...t}:void 0}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&u.Color.equals(e.color||this._color,t.color||this._color)}_clearHighlights(){this._silhouette.selected.length>0&&(this._silhouette.selected=[]),this._entity?.model&&(this._entity.model.silhouetteColor=new u.ConstantProperty(u.Color.TRANSPARENT),this._entity.model.silhouetteSize=new u.ConstantProperty(0),this._entity=void 0)}hide(){this._clearHighlights(),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this.hide(),this._composite&&this._stages.remove(this._composite),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get currentObject(){return this._currentObject}};var a=require("cesium"),b=class{_color=a.Color.RED;_entity;_entities;_currentObject;_currentOptions;constructor(e){this._entities=e.entities,this._entity=this._entities.add(new a.Entity({id:`highlight-entity-${Math.random().toString(36).substring(2)}`,show:!1}))}show(e,t){if(!(!(0,a.defined)(e)||!this._entity)){if(this._currentObject===e&&this._optionsEqual(this._currentOptions,t))return this._entity;this._clearGeometries();try{if(e instanceof a.Entity&&(e.polygon||e.polyline||e.rectangle))this._update(e,t);else if(e instanceof a.GroundPrimitive)this._update(e,t);else{this._currentObject=void 0,this._currentOptions=void 0;return}return this._currentObject=e,this._currentOptions=t?{...t}:void 0,this._entity.show=!0,this._entity}catch(i){console.error("Failed to highlight object:",i),this._currentObject=void 0,this._currentOptions=void 0;return}}}_optionsEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.outline===t.outline&&e.width===t.width&&a.Color.equals(e.color||this._color,t.color||this._color)}_clearGeometries(){this._entity.polygon=void 0,this._entity.polyline=void 0,this._entity.rectangle=void 0}_update(e,t={color:this._color,outline:!1,width:2}){if(e instanceof a.Entity){if(e.polygon)if(t.outline){let i=e.polygon.hierarchy?.getValue();if(i&&i.positions){let r;i.positions.length>0&&!a.Cartesian3.equals(i.positions[0],i.positions[i.positions.length-1])?r=[...i.positions,i.positions[0]]:r=i.positions,this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.polygon.hierarchy?.getValue();i&&(this._entity.polygon=new a.PolygonGraphics({hierarchy:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:e.polygon.classificationType?.getValue()||a.ClassificationType.BOTH}))}else if(e.polyline){let i=e.polyline.positions?.getValue();if(i){let r=e.polyline.width?.getValue();this._entity.polyline=new a.PolylineGraphics({positions:i,material:t.color,width:r+(t.width||2),clampToGround:!0})}}else if(e.rectangle)if(t.outline){let i=e.rectangle.coordinates?.getValue();if(i){let r=[a.Cartesian3.fromRadians(i.west,i.north),a.Cartesian3.fromRadians(i.east,i.north),a.Cartesian3.fromRadians(i.east,i.south),a.Cartesian3.fromRadians(i.west,i.south),a.Cartesian3.fromRadians(i.west,i.north)];this._entity.polyline=new a.PolylineGraphics({positions:r,material:t.color,width:t.width||2,clampToGround:!0})}}else{let i=e.rectangle.coordinates?.getValue();i&&(this._entity.rectangle=new a.RectangleGraphics({coordinates:i,material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND}))}}else if(e instanceof a.GroundPrimitive){let i=e.geometryInstances,r=Array.isArray(i)?i[0]:i;if(!r.geometry.attributes.position)return;let o=r.geometry.attributes.position.values,s=[];for(let l=0;l<o.length;l+=3)s.push(new a.Cartesian3(o[l],o[l+1],o[l+2]));t.outline?this._entity.polyline=new a.PolylineGraphics({positions:s,material:t.color,width:t.width||2,clampToGround:!0}):this._entity.polygon=new a.PolygonGraphics({hierarchy:new a.PolygonHierarchy(s),material:t.color,heightReference:a.HeightReference.CLAMP_TO_GROUND,classificationType:a.ClassificationType.BOTH})}}hide(){this._entity&&(this._entity.show=!1),this._currentObject=void 0,this._currentOptions=void 0}destroy(){this._entities.contains(this._entity)&&this._entities.remove(this._entity),this._currentObject=void 0,this._currentOptions=void 0}get color(){return this._color}set color(e){this._color=e}get entity(){return this._entity}get currentObject(){return this._currentObject}};var D=class n{static instances=new WeakMap;_surface;_silhouette;_color=m.Color.RED;constructor(e){this._surface=new b(e),this._silhouette=new T(e),this._surface.color=this._color,this._silhouette.color=this._color}static getInstance(e){let t=e.container;return n.instances.has(t)||n.instances.set(t,new n(e)),n.instances.get(t)}static releaseInstance(e){let t=e.container,i=n.instances.get(t);i&&(i.hide(),i._surface&&i._surface.destroy(),i._silhouette&&i._silhouette.destroy(),n.instances.delete(t))}show(e,t={color:this._color}){let i=this._getObject(e);if((0,m.defined)(i))return i instanceof m.Cesium3DTileFeature?this._silhouette.show(i,t):i instanceof m.Entity&&i.model?this._silhouette.show(i,t):this._surface.show(i,t)}_getObject(e){if((0,m.defined)(e)){if(e instanceof m.Entity||e instanceof m.Cesium3DTileFeature||e instanceof m.GroundPrimitive)return e;if(e.id instanceof m.Entity)return e.id;if(e.primitive instanceof m.GroundPrimitive)return e.primitive}}hide(){this._surface.hide(),this._silhouette.hide()}get color(){return this._color}set color(e){this._color=e,this._surface.color=e,this._silhouette.color=e}},V=D;var E=require("cesium");var x=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new E.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,t,i){return this._defaultProvider.loadTileDataAvailability(e,t,i)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,t,i,r){if(this._ready){for(let o of this._regions)if(this._regionContains(o,e,t,i))return o.provider.requestTileGeometry(e,t,i,r);return this._defaultProvider.getTileDataAvailable(e,t,i)?this._defaultProvider.requestTileGeometry(e,t,i,r):this._fallbackProvider.requestTileGeometry(e,t,i,r)}}getTileDataAvailable(e,t,i){for(let r of this._regions)if(this._regionContains(r,e,t,i))return r.provider.getTileDataAvailable(e,t,i);return this._defaultProvider.getTileDataAvailable(e,t,i)}_regionContains(e,t,i,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let o=e.tiles.get(r);if(!o)return!1;let[s,l]=Array.isArray(o.x)?o.x:[o.x,o.x],[c,d]=Array.isArray(o.y)?o.y:[o.y,o.y];return t>=s&&t<=l&&i>=c&&i<=d}if(e.bounds){let o=this._tilingScheme.tileXYToRectangle(t,i,r);return E.Rectangle.intersection(o,e.bounds)!==void 0}return!1}};(i=>{function n(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromRectangles=n;function e(r,o,s){return new i({regions:r.map(l=>({...l})),defaultProvider:o,fallbackProvider:s})}i.fromTileRanges=e;function t(r,o){if(S.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),o.size===0)return new E.Rectangle;let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,d=Number.NEGATIVE_INFINITY,v=Array.from(o.keys()),p=Math.min(...v),_=o.get(p);if(_){let{start:y,end:C}=_,P=r.tileXYToRectangle(y.x,y.y,p),f=r.tileXYToRectangle(C.x,C.y,p);s=Math.min(P.west,s),l=Math.min(f.south,l),c=Math.max(f.east,c),d=Math.max(P.north,d)}return new E.Rectangle(s,l,c,d)}i.computeRectangle=t})(x||={});var G=x;var z=require("cesium");var k=require("cesium");function R(n,e){if((0,k.defined)(n)&&(0,k.defined)(e)){let{camera:t}=n;e.camera.position=t.positionWC.clone(),e.camera.direction=t.directionWC.clone(),e.camera.up=t.upWC.clone()}}function F(n,e,t){let i={baseLayerPicker:n.baseLayerPicker!==void 0,geocoder:n.geocoder!==void 0,homeButton:n.homeButton!==void 0,sceneModePicker:n.sceneModePicker!==void 0,timeline:n.timeline!==void 0,navigationHelpButton:n.navigationHelpButton!==void 0,animation:n.animation!==void 0,fullscreenButton:n.fullscreenButton!==void 0,shouldAnimate:n.clock.shouldAnimate,terrainProvider:n.terrainProvider,requestRenderMode:n.scene.requestRenderMode,infoBox:n.infoBox!==void 0},r=new z.Viewer(e,{...i,...t});R(n,r);let o=n.imageryLayers;r.imageryLayers.removeAll();for(let c=0;c<o.length;c++){let d=o.get(c);r.imageryLayers.addImageryProvider(d.imageryProvider,c)}r.clock.startTime=n.clock.startTime.clone(),r.clock.stopTime=n.clock.stopTime.clone(),r.clock.currentTime=n.clock.currentTime.clone(),r.clock.multiplier=n.clock.multiplier,r.clock.clockStep=n.clock.clockStep,r.clock.clockRange=n.clock.clockRange,r.clock.shouldAnimate=n.clock.shouldAnimate,r.scene.globe.enableLighting=n.scene.globe.enableLighting,r.scene.globe.depthTestAgainstTerrain=n.scene.globe.depthTestAgainstTerrain,r.scene.screenSpaceCameraController.enableCollisionDetection=n.scene.screenSpaceCameraController.enableCollisionDetection;let s=n.scene.screenSpaceCameraController.tiltEventTypes;s&&(r.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(s)?[...s]:s);let l=n.scene.screenSpaceCameraController.zoomEventTypes;return l&&(r.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(l)?[...l]:l),r}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { C as Collection
|
|
1
|
+
export { C as Collection } from './index-C7kPHG5S.cjs';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.cjs';
|
|
3
|
-
export { H as HybridTerrainProvider
|
|
4
|
-
export { TerrainVisualizer } from './utils/index.cjs';
|
|
3
|
+
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2V-igd9.cjs';
|
|
5
4
|
export { cloneViewer, syncCamera } from './viewer/index.cjs';
|
|
6
5
|
import 'cesium';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { C as Collection
|
|
1
|
+
export { C as Collection } from './index-C7kPHG5S.js';
|
|
2
2
|
export { Highlight, SilhouetteHighlight, SurfaceHighlight } from './highlight/index.js';
|
|
3
|
-
export { H as HybridTerrainProvider
|
|
4
|
-
export { TerrainVisualizer } from './utils/index.js';
|
|
3
|
+
export { H as HybridTerrainProvider } from './hybrid-terrain-provider-C2V-igd9.js';
|
|
5
4
|
export { cloneViewer, syncCamera } from './viewer/index.js';
|
|
6
5
|
import 'cesium';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-RXMNSDKR.js";import{
|
|
1
|
+
import"./chunk-RXMNSDKR.js";import{d as r}from"./chunk-N24M6GYI.js";import{a as i,b as o,c as e}from"./chunk-RZ3PTU3G.js";import{a as t}from"./chunk-DGHCIGKJ.js";import"./chunk-TUJQL7MC.js";import{a as m,b as h}from"./chunk-Z2COOTT4.js";export{r as Collection,e as Highlight,t as HybridTerrainProvider,i as SilhouetteHighlight,o as SurfaceHighlight,h as cloneViewer,m as syncCamera};
|
package/dist/terrain/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var A=(a,e)=>{for(var i in e)g(a,i,{get:e[i],enumerable:!0})},w=(a,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!I.call(a,r)&&r!==i&&g(a,r,{get:()=>e[r],enumerable:!(n=x(e,r))||n.enumerable});return a};var E=a=>w(g({},"__esModule",{value:!0}),a);var N={};A(N,{HybridTerrainProvider:()=>_});module.exports=E(N);var b=require("cesium");var P;(l=>{let a=new Set,e=typeof process<"u"?process.env.CESIUM_UTILS_DISABLE_DEPRECATION_WARNINGS!=="true":!0;function i(o,u={}){if(!e)return;let{once:c=!0,prefix:d="[DEPRECATED]",includeStack:m=!0,removeInVersion:f}=u;if(c&&a.has(o))return;let v=`${d} ${o}`;f&&(v+=` This feature will be removed in ${f}.`),typeof console<"u"&&console.warn&&(m?(console.warn(v),console.trace("Deprecation stack trace:")):console.warn(v)),c&&a.add(o)}l.warn=i;function n(o,u,c={}){let d=(...m)=>(i(u,c),o(...m));return Object.defineProperty(d,"name",{value:o.name,configurable:!0}),d}l.deprecate=n;function r(){a.clear()}l.clear=r;function t(){return a.size}l.getWarningCount=t;function s(o){return a.has(o)}l.hasShown=s})(P||={});var y=P;var T=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new b.EllipsoidTerrainProvider,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,i,n){return this._defaultProvider.loadTileDataAvailability(e,i,n)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,i,n,r){if(this._ready){for(let t of this._regions)if(this._regionContains(t,e,i,n))return t.provider.requestTileGeometry(e,i,n,r);return this._defaultProvider.getTileDataAvailable(e,i,n)?this._defaultProvider.requestTileGeometry(e,i,n,r):this._fallbackProvider.requestTileGeometry(e,i,n,r)}}getTileDataAvailable(e,i,n){for(let r of this._regions)if(this._regionContains(r,e,i,n))return r.provider.getTileDataAvailable(e,i,n);return this._defaultProvider.getTileDataAvailable(e,i,n)}_regionContains(e,i,n,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let t=e.tiles.get(r);if(!t)return!1;let[s,l]=Array.isArray(t.x)?t.x:[t.x,t.x],[o,u]=Array.isArray(t.y)?t.y:[t.y,t.y];return i>=s&&i<=l&&n>=o&&n<=u}if(e.bounds){let t=this._tilingScheme.tileXYToRectangle(i,n,r);return b.Rectangle.intersection(t,e.bounds)!==void 0}return!1}};(n=>{function a(r,t,s){return new n({regions:r.map(l=>({...l})),defaultProvider:t,fallbackProvider:s})}n.fromRectangles=a;function e(r,t,s){return new n({regions:r.map(l=>({...l})),defaultProvider:t,fallbackProvider:s})}n.fromTileRanges=e;function i(r,t){if(y.warn("computeRectangle() is deprecated. Use Rectangle.fromDegrees() instead.",{removeInVersion:"v0.3.0"}),t.size===0)return new b.Rectangle;let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,c=Array.from(t.keys()),d=Math.min(...c),m=t.get(d);if(m){let{start:f,end:v}=m,p=r.tileXYToRectangle(f.x,f.y,d),h=r.tileXYToRectangle(v.x,v.y,d);s=Math.min(p.west,s),l=Math.min(h.south,l),o=Math.max(h.east,o),u=Math.max(p.north,u)}return new b.Rectangle(s,l,o,u)}n.computeRectangle=i})(T||={});var _=T;
|
package/dist/terrain/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-
|
|
2
|
-
export { T as TerrainArea } from '../hybrid-terrain-provider-C7Ks0pK6.cjs';
|
|
1
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.cjs';
|
|
3
2
|
import 'cesium';
|
|
4
3
|
|
|
5
4
|
type TerrainRegion = HybridTerrainProvider.TerrainRegion;
|
package/dist/terrain/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-
|
|
2
|
-
export { T as TerrainArea } from '../hybrid-terrain-provider-C7Ks0pK6.js';
|
|
1
|
+
import { H as HybridTerrainProvider } from '../hybrid-terrain-provider-C2V-igd9.js';
|
|
3
2
|
import 'cesium';
|
|
4
3
|
|
|
5
4
|
type TerrainRegion = HybridTerrainProvider.TerrainRegion;
|
package/dist/terrain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"../chunk-DGHCIGKJ.js";import"../chunk-TUJQL7MC.js";export{a as HybridTerrainProvider};
|
package/dist/viewer/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(e,i)=>{for(var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(e,i)=>{for(var t in i)m(e,t,{get:i[t],enumerable:!0})},v=(e,i,t,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of k(i))!C.call(e,n)&&n!==t&&m(e,n,{get:()=>i[n],enumerable:!(o=g(i,n))||o.enumerable});return e};var b=e=>v(m({},"__esModule",{value:!0}),e);var h={};T(h,{cloneViewer:()=>y,syncCamera:()=>l});module.exports=b(h);var p=require("cesium");var d=require("cesium");function l(e,i){if((0,d.defined)(e)&&(0,d.defined)(i)){let{camera:t}=e;i.camera.position=t.positionWC.clone(),i.camera.direction=t.directionWC.clone(),i.camera.up=t.upWC.clone()}}function y(e,i,t){let o={baseLayerPicker:e.baseLayerPicker!==void 0,geocoder:e.geocoder!==void 0,homeButton:e.homeButton!==void 0,sceneModePicker:e.sceneModePicker!==void 0,timeline:e.timeline!==void 0,navigationHelpButton:e.navigationHelpButton!==void 0,animation:e.animation!==void 0,fullscreenButton:e.fullscreenButton!==void 0,shouldAnimate:e.clock.shouldAnimate,terrainProvider:e.terrainProvider,requestRenderMode:e.scene.requestRenderMode,infoBox:e.infoBox!==void 0},n=new p.Viewer(i,{...o,...t});l(e,n);let s=e.imageryLayers;n.imageryLayers.removeAll();for(let c=0;c<s.length;c++){let f=s.get(c);n.imageryLayers.addImageryProvider(f.imageryProvider,c)}n.clock.startTime=e.clock.startTime.clone(),n.clock.stopTime=e.clock.stopTime.clone(),n.clock.currentTime=e.clock.currentTime.clone(),n.clock.multiplier=e.clock.multiplier,n.clock.clockStep=e.clock.clockStep,n.clock.clockRange=e.clock.clockRange,n.clock.shouldAnimate=e.clock.shouldAnimate,n.scene.globe.enableLighting=e.scene.globe.enableLighting,n.scene.globe.depthTestAgainstTerrain=e.scene.globe.depthTestAgainstTerrain,n.scene.screenSpaceCameraController.enableCollisionDetection=e.scene.screenSpaceCameraController.enableCollisionDetection;let r=e.scene.screenSpaceCameraController.tiltEventTypes;r&&(n.scene.screenSpaceCameraController.tiltEventTypes=Array.isArray(r)?[...r]:r);let a=e.scene.screenSpaceCameraController.zoomEventTypes;return a&&(n.scene.screenSpaceCameraController.zoomEventTypes=Array.isArray(a)?[...a]:a),n}
|
package/dist/viewer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-Z2COOTT4.js";export{b as cloneViewer,a as syncCamera};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juun-roh/cesium-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Utilities to handle Cesium classes easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"import": "./dist/terrain/index.js",
|
|
57
57
|
"require": "./dist/terrain/index.cjs"
|
|
58
58
|
},
|
|
59
|
-
"./
|
|
60
|
-
"types": "./dist/
|
|
61
|
-
"import": "./dist/
|
|
62
|
-
"require": "./dist/
|
|
59
|
+
"./dev": {
|
|
60
|
+
"types": "./dist/dev/index.d.ts",
|
|
61
|
+
"import": "./dist/dev/index.js",
|
|
62
|
+
"require": "./dist/dev/index.cjs"
|
|
63
63
|
},
|
|
64
64
|
"./viewer": {
|
|
65
65
|
"types": "./dist/viewer/index.d.ts",
|
|
@@ -88,13 +88,14 @@
|
|
|
88
88
|
"@commitlint/cz-commitlint": "^19.8.1",
|
|
89
89
|
"@commitlint/format": "^19.8.1",
|
|
90
90
|
"@commitlint/types": "^19.8.1",
|
|
91
|
-
"@eslint/js": "^9.
|
|
92
|
-
"@
|
|
93
|
-
"@typescript-eslint/
|
|
91
|
+
"@eslint/js": "^9.32.0",
|
|
92
|
+
"@types/node": "^24.1.0",
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
94
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
94
95
|
"@vitest/coverage-v8": "^3.2.4",
|
|
95
96
|
"cesium": "^1.131.0",
|
|
96
|
-
"eslint": "^9.
|
|
97
|
-
"eslint-plugin-jsdoc": "^
|
|
97
|
+
"eslint": "^9.32.0",
|
|
98
|
+
"eslint-plugin-jsdoc": "^52.0.0",
|
|
98
99
|
"eslint-plugin-prettier": "^5.5.3",
|
|
99
100
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
100
101
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
@@ -102,9 +103,9 @@
|
|
|
102
103
|
"jsdom": "^26.1.0",
|
|
103
104
|
"rimraf": "^6.0.1",
|
|
104
105
|
"tsup": "^8.5.0",
|
|
105
|
-
"typedoc": "^0.28.
|
|
106
|
+
"typedoc": "^0.28.8",
|
|
106
107
|
"typescript": "^5.8.3",
|
|
107
|
-
"vite": "^7.0.
|
|
108
|
+
"vite": "^7.0.6",
|
|
108
109
|
"vitest": "^3.2.4"
|
|
109
110
|
},
|
|
110
111
|
"scripts": {
|
package/dist/chunk-64HXTGRV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{EllipsoidTerrainProvider as A,Rectangle as b}from"cesium";import{CesiumTerrainProvider as p}from"cesium";var u=class{_terrainProvider;_rectangle;_tileRanges;_ready=!1;_credit;_isCustom;constructor(e){this._terrainProvider=e.terrainProvider,this._tileRanges=e.tileRanges,this._credit=e.credit||"custom",this._isCustom=e.isCustom!==void 0?e.isCustom:!0,this._rectangle=v.computeRectangle(e.terrainProvider.tilingScheme,e.tileRanges),e.tileRanges.forEach((i,t)=>{this._terrainProvider.availability?.addAvailableTileRange(t,i.start.x,i.start.y,i.end.x,i.end.y)}),this._ready=!0}contains(e,i,t){if(this._tileRanges.size===0||!this._tileRanges.has(t))return!1;let r=this._tileRanges.get(t);return e>=r.start.x&&e<=r.end.x&&i>=r.start.y&&i<=r.end.y}requestTileGeometry(e,i,t,r){if(!(!this._ready||!this.contains(e,i,t)))return this._terrainProvider.requestTileGeometry(e,i,t,r)}getTileDataAvailable(e,i,t){if(this._tileRanges.size===0||!this._tileRanges.has(t))return!1;let r=this._tileRanges.get(t);return e>=r.start.x&&e<=r.end.x&&i>=r.start.y&&i<=r.end.y}get isCustom(){return this._isCustom}get credit(){return this._credit}get terrainProvider(){return this._terrainProvider}get tileRanges(){return this._tileRanges}get rectangle(){return this._rectangle}get ready(){return this._ready}};(i=>{async function m(t,r,n){let a=n?.credit||"custom",o=await p.fromUrl(t,{...n,credit:a});return new i({terrainProvider:o,tileRanges:r,credit:a})}i.fromUrl=m;class e extends Array{add(r){if(Array.isArray(r)){for(let a of r)this.add(a);return this}let n;return r instanceof i?n=r:n=new i(r),this.push(n),this}remove(r){if(Array.isArray(r))return r.forEach(a=>this.remove(a)),this;let n=this.indexOf(r);return n>=0&&this.splice(n,1),this}removeAll(){this.length=0}}i.Collection=e})(u||={});var _=u;var d=class{_regions;_defaultProvider;_fallbackProvider;_tilingScheme;_ready=!1;_availability;constructor(e){this._defaultProvider=e.defaultProvider,this._fallbackProvider=e.fallbackProvider||new A,this._tilingScheme=e.defaultProvider.tilingScheme,this._regions=e.regions||[],this._availability=e.defaultProvider.availability,this._ready=!0}get ready(){return this._ready}get tilingScheme(){return this._tilingScheme}get availability(){return this._availability}get regions(){return[...this._regions]}get defaultProvider(){return this._defaultProvider}get fallbackProvider(){return this._fallbackProvider}get credit(){return this._defaultProvider?.credit}get errorEvent(){return this._defaultProvider.errorEvent}get hasWaterMask(){return this._defaultProvider.hasWaterMask}get hasVertexNormals(){return this._defaultProvider.hasVertexNormals}loadTileDataAvailability(e,i,t){return this._defaultProvider.loadTileDataAvailability(e,i,t)}getLevelMaximumGeometricError(e){return this._defaultProvider.getLevelMaximumGeometricError(e)}requestTileGeometry(e,i,t,r){if(this._ready){for(let n of this._regions)if(this._regionContains(n,e,i,t))return n.provider.requestTileGeometry(e,i,t,r);return this._defaultProvider.getTileDataAvailable(e,i,t)?this._defaultProvider.requestTileGeometry(e,i,t,r):this._fallbackProvider.requestTileGeometry(e,i,t,r)}}getTileDataAvailable(e,i,t){for(let r of this._regions)if(this._regionContains(r,e,i,t))return r.provider.getTileDataAvailable(e,i,t);return this._defaultProvider.getTileDataAvailable(e,i,t)}_regionContains(e,i,t,r){if(e.levels&&!e.levels.includes(r))return!1;if(e.tiles){let n=e.tiles.get(r);if(!n)return!1;let[a,o]=Array.isArray(n.x)?n.x:[n.x,n.x],[s,l]=Array.isArray(n.y)?n.y:[n.y,n.y];return i>=a&&i<=o&&t>=s&&t<=l}if(e.bounds){let n=this._tilingScheme.tileXYToRectangle(i,t,r);return b.intersection(n,e.bounds)!==void 0}return!1}};(t=>{function m(r,n,a){return new t({regions:r.map(o=>({...o})),defaultProvider:n,fallbackProvider:a})}t.fromRectangles=m;function e(r,n,a){return new t({regions:r.map(o=>({...o})),defaultProvider:n,fallbackProvider:a})}t.fromTileRanges=e;function i(r,n){if(n.size===0)return new b;let a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,y=Array.from(n.keys()),c=Math.min(...y),T=n.get(c);if(T){let{start:g,end:h}=T,f=r.tileXYToRectangle(g.x,g.y,c),P=r.tileXYToRectangle(h.x,h.y,c);a=Math.min(f.west,a),o=Math.min(P.south,o),s=Math.max(P.east,s),l=Math.max(f.north,l)}return new b(a,o,s,l)}t.computeRectangle=i})(d||={});var v=d;export{_ as a,v as b};
|
package/dist/chunk-NO7SO2WH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Color as l,Entity as O,HeightReference as F,Rectangle as E,TileCoordinatesImageryProvider as V}from"cesium";import{DataSourceCollection as S,defined as _,EntityCollection as b,ImageryLayerCollection as A,PrimitiveCollection as M}from"cesium";var y=class o{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(n=>n(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[o.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof b?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof M?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof S?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof A&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,o.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof b)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,o.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)_(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let n of r)if(e in n&&typeof n[e]!="function"){if(C(n,e))throw Error(`Cannot set read-only property '${String(e)}' on ${n.constructor.name}`);n[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,n)=>e(r,n))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},T=y;var v=class o{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",l.RED],["default",l.BLUE],["fallback",l.GRAY],["grid",l.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new T({collection:e.entities,tag:o.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(o.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new V({tilingScheme:this._terrainProvider.tilingScheme,color:l.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(a=>{this._collection.add(a.entity,o.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(E.northwest(e),t),n=i.positionToTileXY(E.southeast(e),t);if(!r||!n)throw new Error("Failed to calculate tile bounds");return{start:r,end:n}}_generateVisibleTiles(e,t,i){let r=[],a=Math.min(e.end.x-e.start.x+1,100),s=Math.min(e.end.y-e.start.y+1,100);for(let c=e.start.x;c<e.start.x+a;c++)for(let h=e.start.y;h<e.start.y+s;h++)try{let d=this._createTileEntity(c,h,t,i);d&&r.push({entity:d})}catch(d){console.warn(`Error creating tile (${c}, ${h}, ${t}):`,d)}return r}_createTileEntity(e,t,i,r){let n=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(n))return null;let a=this._getTileColor(e,t,i),s=o.createRectangle(n,a.withAlpha(.3));return s.properties?.addProperty("tileX",e),s.properties?.addProperty("tileY",t),s.properties?.addProperty("tileLevel",i),s}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||l.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||l.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||l.BLUE:this._colors.get("fallback")||l.GRAY}hide(){this._collection.remove(o.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,n){return new O({rectangle:{coordinates:r,material:n,heightReference:F.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,n,a){let s=a?.tag||"terrain_area_visualization",c=a?.color||l.RED,h=a?.maxTilesToShow||100,d=a?.show??!0,w=a?.alpha||.7,L=a?.tileAlpha||.2,m=new T({collection:n.entities,tag:s}),{rectangle:I}=r;if(m.add(i.createRectangle(I,c.withAlpha(w)),s),d&&r.tileRanges.size>0){let{tilingScheme:P}=r.terrainProvider,g=0;r.tileRanges.forEach((u,R)=>{for(let f=u.start.x;f<=u.end.x&&g<h;f++)for(let p=u.start.y;p<=u.end.y&&g<h;p++){let x=P.tileXYToRectangle(f,p,R);m.add(e(x,c.withAlpha(L)),`${s}_tile`),g++}})}return m}i.visualize=t})(v||={});function C(o,e){let t=!1,i=Object.getOwnPropertyDescriptor(o,e);if(!i){let r=Object.getPrototypeOf(o);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}export{v as a,C as b,T as c};
|
package/dist/utils/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var C=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var M=(n,e)=>{for(var t in e)C(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!A.call(n,r)&&r!==t&&C(n,r,{get:()=>e[r],enumerable:!(i=x(e,r))||i.enumerable});return n};var F=n=>O(C({},"__esModule",{value:!0}),n);var V={};M(V,{TerrainVisualizer:()=>u,isGetterOnly:()=>g});module.exports=F(V);var a=require("cesium");var s=require("cesium");var T=class n{static symbol=Symbol("cesium-item-tag");tag;collection;_valuesCache=null;_tagMap=new Map;_eventListeners=new Map;_eventCleanupFunctions=[];constructor({collection:e,tag:t}){this.tag=t||"default",this.collection=e,this._setupCacheInvalidator(e)}[Symbol.iterator](){return this.values[Symbol.iterator]()}_emit(e,t){let i=this._eventListeners.get(e);if(i){let r={type:e,...t};i.forEach(o=>o(r))}}_addToTagMap(e,t){this._tagMap.has(t)||this._tagMap.set(t,new Set),this._tagMap.get(t)?.add(e)}_removeFromTagMap(e){let t=e[n.symbol],i=this._tagMap.get(t);i&&(i.delete(e),i.size===0&&this._tagMap.delete(t))}_invalidateCache=()=>{this._valuesCache=null};_setupCacheInvalidator(e){e instanceof s.EntityCollection?(e.collectionChanged.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.collectionChanged.removeEventListener(this._invalidateCache))):e instanceof s.PrimitiveCollection?(e.primitiveAdded.addEventListener(this._invalidateCache),e.primitiveRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.primitiveAdded.removeEventListener(this._invalidateCache),()=>e.primitiveRemoved.removeEventListener(this._invalidateCache))):e instanceof s.DataSourceCollection?(e.dataSourceAdded.addEventListener(this._invalidateCache),e.dataSourceMoved.addEventListener(this._invalidateCache),e.dataSourceRemoved.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.dataSourceAdded.removeEventListener(this._invalidateCache),()=>e.dataSourceMoved.removeEventListener(this._invalidateCache),()=>e.dataSourceRemoved.removeEventListener(this._invalidateCache))):e instanceof s.ImageryLayerCollection&&(e.layerAdded.addEventListener(this._invalidateCache),e.layerMoved.addEventListener(this._invalidateCache),e.layerRemoved.addEventListener(this._invalidateCache),e.layerShownOrHidden.addEventListener(this._invalidateCache),this._eventCleanupFunctions.push(()=>e.layerAdded.removeEventListener(this._invalidateCache),()=>e.layerMoved.removeEventListener(this._invalidateCache),()=>e.layerRemoved.removeEventListener(this._invalidateCache),()=>e.layerShownOrHidden.removeEventListener(this._invalidateCache)))}addEventListener(e,t){return this._eventListeners.has(e)||this._eventListeners.set(e,new Set),this._eventListeners.get(e)?.add(t),this}removeEventListener(e,t){return this._eventListeners.get(e)?.delete(t),this}add(e,t=this.tag,i){return Array.isArray(e)?e.forEach(r=>{this.add(r,t)}):(Object.defineProperty(e,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this.collection.add(e,i),this._addToTagMap(e,t),this._invalidateCache(),this._emit("add",{items:[e],tag:t})),this}contains(e){if(typeof e=="object")return this.collection.contains(e);let t=this._tagMap.get(e);return!!t&&t.size>0}remove(e){if(typeof e=="object"&&!Array.isArray(e)&&this.collection.remove(e)&&(this._removeFromTagMap(e),this._invalidateCache(),this._emit("remove",{items:[e]})),Array.isArray(e)){if(e.length===0)return this;for(let i of e)this.remove(i)}let t=this.get(e);if(t.length===0)return this;for(let i of t)this.remove(i);return this}removeAll(){this._tagMap.clear(),this.collection.removeAll(),this._invalidateCache(),this._emit("clear")}destroy(){this._eventCleanupFunctions.forEach(e=>e()),this._eventCleanupFunctions=[],this._tagMap.clear(),this._eventListeners.clear(),this._valuesCache=null}get values(){if(this._valuesCache!==null)return this._valuesCache;let e;if(this.collection instanceof s.EntityCollection)e=this.collection.values;else{e=[];for(let t=0;t<this.collection.length;t++)e.push(this.collection.get(t))}return this._valuesCache=e,e}get length(){return this.values?.length||0}get(e){let t=this._tagMap.get(e);return t?Array.from(t):[]}first(e){let t=this._tagMap.get(e);if(t&&t.size>0)return t.values().next().value}get tags(){return Array.from(this._tagMap.keys())}update(e,t){let i=this.get(e);for(let r of i)this._removeFromTagMap(r),Object.defineProperty(r,n.symbol,{value:t,enumerable:!1,writable:!0,configurable:!0}),this._addToTagMap(r,t);return i.length>0&&this._emit("update",{items:i,tag:t}),i.length}show(e){let t=this.get(e);for(let i of t)(0,s.defined)(i.show)&&(i.show=!0);return this}hide(e){let t=this.get(e);for(let i of t)(0,s.defined)(i.show)&&(i.show=!1);return this}toggle(e){let t=this.get(e);for(let i of t)(0,s.defined)(i.show)&&(i.show=!i.show);return this}setProperty(e,t,i=this.tag){let r=this.get(i);for(let o of r)if(e in o&&typeof o[e]!="function"){if(g(o,e))throw Error(`Cannot set read-only property '${String(e)}' on ${o.constructor.name}`);o[e]=t}return this}filter(e,t){return(t?this.get(t):this.values).filter(e)}forEach(e,t){(t?this.get(t):this.values).forEach((r,o)=>e(r,o))}map(e,t){return(t?this.get(t):this.values).map(e)}find(e,t){return(t?this.get(t):this.values).find(e)}},b=T;var u=class n{_viewer;_collection;_terrainProvider;_visible=!1;_level=15;_tileCoordinatesLayer;_colors=new Map([["custom",a.Color.RED],["default",a.Color.BLUE],["fallback",a.Color.GRAY],["grid",a.Color.YELLOW]]);constructor(e,t){this._viewer=e,this._collection=new b({collection:e.entities,tag:n.tag.default}),t&&(t.colors&&Object.entries(t.colors).forEach(([i,r])=>{this._colors.set(i,r)}),t.tile!==void 0&&(this._visible=t.tile),t.activeLevel!==void 0&&(this._level=t.activeLevel),t.terrainProvider&&this.setTerrainProvider(t.terrainProvider))}setTerrainProvider(e){this._terrainProvider=e,this.update()}update(){this.clear(),this._visible&&this.show(this._level)}clear(){this._collection.remove(this._collection.tags)}show(e=15){if(!this._terrainProvider)return;this._collection.remove(n.tag.grid),this._level=e,this._ensureTileCoordinatesLayer();let t=this._getVisibleRectangle();if(!t||!this._isValidRectangle(t)){console.warn("Invalid visible rectangle detected, skipping grid display");return}this._displayTileGrid(t,e),this._visible=!0}_ensureTileCoordinatesLayer(){this._tileCoordinatesLayer||(this._tileCoordinatesLayer=this._viewer.imageryLayers.addImageryProvider(new a.TileCoordinatesImageryProvider({tilingScheme:this._terrainProvider.tilingScheme,color:a.Color.YELLOW})))}_isValidRectangle(e){return e&&Number.isFinite(e.west)&&Number.isFinite(e.south)&&Number.isFinite(e.east)&&Number.isFinite(e.north)&&e.west<=e.east&&e.south<=e.north}_displayTileGrid(e,t){let i=this._terrainProvider.tilingScheme;try{let r=this._calculateTileBounds(e,t,i);this._generateVisibleTiles(r,t,i).forEach(l=>{this._collection.add(l.entity,n.tag.grid)})}catch(r){console.error("Error displaying tile grid:",r)}}_calculateTileBounds(e,t,i){let r=i.positionToTileXY(a.Rectangle.northwest(e),t),o=i.positionToTileXY(a.Rectangle.southeast(e),t);if(!r||!o)throw new Error("Failed to calculate tile bounds");return{start:r,end:o}}_generateVisibleTiles(e,t,i){let r=[],l=Math.min(e.end.x-e.start.x+1,100),c=Math.min(e.end.y-e.start.y+1,100);for(let h=e.start.x;h<e.start.x+l;h++)for(let d=e.start.y;d<e.start.y+c;d++)try{let v=this._createTileEntity(h,d,t,i);v&&r.push({entity:v})}catch(v){console.warn(`Error creating tile (${h}, ${d}, ${t}):`,v)}return r}_createTileEntity(e,t,i,r){let o=r.tileXYToRectangle(e,t,i);if(!this._isValidRectangle(o))return null;let l=this._getTileColor(e,t,i),c=n.createRectangle(o,l.withAlpha(.3));return c.properties?.addProperty("tileX",e),c.properties?.addProperty("tileY",t),c.properties?.addProperty("tileLevel",i),c}_getTileColor(e,t,i){if(!this._terrainProvider)return this._colors.get("fallback")||a.Color.TRANSPARENT;for(let r of this._terrainProvider.regions)if(this._terrainProvider._regionContains(r,e,t,i))return this._colors.get("custom")||a.Color.RED;return this._terrainProvider.getTileDataAvailable(e,t,i)?this._colors.get("default")||a.Color.BLUE:this._colors.get("fallback")||a.Color.GRAY}hide(){this._collection.remove(n.tag.grid),this._tileCoordinatesLayer&&(this._viewer.imageryLayers.remove(this._tileCoordinatesLayer),this._tileCoordinatesLayer=void 0),this._visible=!1}setColors(e){Object.entries(e).forEach(([t,i])=>{this._colors.set(t,i)}),this.update()}flyTo(e,t){let{rectangle:i}=e;this._viewer.camera.flyTo({destination:i,...t,complete:()=>{this._visible&&this.update()}})}_getVisibleRectangle(){return this._viewer.camera.computeViewRectangle()}get level(){return this._level}set level(e){this._level=e,this._visible&&this.update()}get visible(){return this._visible}get collection(){return this._collection}get viewer(){return this._viewer}get colors(){return this._colors}get terrainProvider(){return this._terrainProvider}};(i=>{i.tag={default:"Terrain Visualizer",boundary:"Terrain Visualizer Boundary",grid:"Terrain Visualizer Tile Grid"};function e(r,o){return new a.Entity({rectangle:{coordinates:r,material:o,heightReference:a.HeightReference.CLAMP_TO_GROUND}})}i.createRectangle=e;function t(r,o,l){let c=l?.tag||"terrain_area_visualization",h=l?.color||a.Color.RED,d=l?.maxTilesToShow||100,v=l?.show??!0,E=l?.alpha||.7,w=l?.tileAlpha||.2,f=new b({collection:o.entities,tag:c}),{rectangle:L}=r;if(f.add(i.createRectangle(L,h.withAlpha(E)),c),v&&r.tileRanges.size>0){let{tilingScheme:I}=r.terrainProvider,p=0;r.tileRanges.forEach((m,P)=>{for(let _=m.start.x;_<=m.end.x&&p<d;_++)for(let y=m.start.y;y<=m.end.y&&p<d;y++){let R=I.tileXYToRectangle(_,y,P);f.add(e(R,h.withAlpha(w)),`${c}_tile`),p++}})}return f}i.visualize=t})(u||={});function g(n,e){let t=!1,i=Object.getOwnPropertyDescriptor(n,e);if(!i){let r=Object.getPrototypeOf(n);for(;r&&!i;)i=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r)}return i&&i.get&&!i.set&&(t=!0),t}
|
package/dist/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"../chunk-NO7SO2WH.js";export{a as TerrainVisualizer,b as isGetterOnly};
|