@npm9912/v-map 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +17 -5
  2. package/dist/cjs/{cesium-provider-BiFFyAl9.js → cesium-provider-CTtu9eTD.js} +6 -5
  3. package/dist/cjs/{deck-provider-Ctq3Q8a1.js → deck-provider-fNa818HH.js} +9 -9
  4. package/dist/cjs/events-BMG7RKne.js +11 -0
  5. package/dist/cjs/{geotiff-source-RaNzzWkC.js → geotiff-source-B9ARUE9z.js} +1 -1
  6. package/dist/cjs/{index-ISOEpMC3.js → index-9APmzoa2.js} +6 -6
  7. package/dist/cjs/{index-CbVT-Con.js → index-BJg0ncfC.js} +4 -4
  8. package/dist/cjs/{index-CJvvX4yx.js → index-C1ubapwF.js} +4 -4
  9. package/dist/cjs/{index-B8LHqjyg.js → index-ChrKyU6i.js} +4 -4
  10. package/dist/cjs/{index-JSwBbvGA.js → index-DmGHwivM.js} +1 -0
  11. package/dist/cjs/{layer-extension-B_olS0rc.js → layer-extension-D3a-1DFI.js} +1 -1
  12. package/dist/cjs/{leaflet-provider-DOqfs7g5.js → leaflet-provider-7Nw-AdV_.js} +6 -5
  13. package/dist/cjs/loader.cjs.js +2 -2
  14. package/dist/cjs/{messages-D7h4m8Tx.js → messages-CFCxeG8p.js} +0 -9
  15. package/dist/cjs/{openlayers-provider-Dfeg6L4n.js → openlayers-provider-DMxYtFkS.js} +5 -4
  16. package/dist/cjs/{polygon-layer-B9PrN7vr.js → polygon-layer-Dx1ZWZP0.js} +1 -1
  17. package/dist/cjs/{scenegraph-layer-DwNoxQdi.js → scenegraph-layer-ctLehP0q.js} +1 -1
  18. package/dist/cjs/v-map-builder.cjs.entry.js +4 -3
  19. package/dist/cjs/v-map-error.cjs.entry.js +121 -0
  20. package/dist/cjs/v-map-layer-geojson_12.cjs.entry.js +11 -10
  21. package/dist/cjs/{v-map-layer-helper-iAzxAg9I.js → v-map-layer-helper-DnWpjZ_Q.js} +7 -6
  22. package/dist/cjs/v-map-layer-terrain-geotiff.cjs.entry.js +5 -4
  23. package/dist/cjs/v-map-layercontrol.cjs.entry.js +1 -1
  24. package/dist/cjs/v-map.cjs.js +2 -2
  25. package/dist/cjs/{v-map.v-map-layer-osm.v-map-layergroup-BsXp3BoL.js → v-map.v-map-layer-osm.v-map-layergroup-BJ3_NqAj.js} +16 -15
  26. package/dist/cjs/v-map_3.cjs.entry.js +5 -4
  27. package/dist/collection/collection-manifest.json +1 -0
  28. package/dist/collection/components/v-map/v-map.css +3 -0
  29. package/dist/collection/components/v-map-error/v-map-error.css +136 -0
  30. package/dist/collection/components/v-map-error/v-map-error.js +277 -0
  31. package/dist/collection/components/v-map-error/v-map-error.test.js +131 -0
  32. package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.js +1 -1
  33. package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.js +1 -1
  34. package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.js +1 -1
  35. package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.js +1 -1
  36. package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.js +1 -1
  37. package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.js +1 -1
  38. package/dist/collection/components/v-map-layergroup/v-map-layergroup.js +1 -1
  39. package/dist/collection/components/v-map-style/v-map-style.js +1 -1
  40. package/dist/components/cesium-provider.js +1 -1
  41. package/dist/components/deck-provider.js +1 -1
  42. package/dist/components/events.js +1 -1
  43. package/dist/components/geotiff-source.js +1 -1
  44. package/dist/components/leaflet-provider.js +1 -1
  45. package/dist/components/logger.js +1 -0
  46. package/dist/components/openlayers-provider.js +1 -1
  47. package/dist/components/v-map-builder.js +2 -2
  48. package/dist/components/v-map-error.d.ts +11 -0
  49. package/dist/components/v-map-error.js +1 -0
  50. package/dist/components/v-map-layer-geojson2.js +1 -1
  51. package/dist/components/v-map-layer-geotiff2.js +1 -1
  52. package/dist/components/v-map-layer-google2.js +1 -1
  53. package/dist/components/v-map-layer-helper.js +1 -1
  54. package/dist/components/v-map-layer-osm2.js +1 -1
  55. package/dist/components/v-map-layer-scatterplot2.js +1 -1
  56. package/dist/components/v-map-layer-terrain-geotiff.js +1 -1
  57. package/dist/components/v-map-layer-terrain2.js +1 -1
  58. package/dist/components/v-map-layer-tile3d2.js +1 -1
  59. package/dist/components/v-map-layer-wcs2.js +1 -1
  60. package/dist/components/v-map-layer-wfs2.js +1 -1
  61. package/dist/components/v-map-layer-wkt2.js +1 -1
  62. package/dist/components/v-map-layer-wms2.js +1 -1
  63. package/dist/components/v-map-layer-xyz2.js +1 -1
  64. package/dist/components/v-map-layergroup2.js +1 -1
  65. package/dist/components/v-map-style2.js +2 -2
  66. package/dist/components/v-map2.js +1 -1
  67. package/dist/esm/{cesium-provider-BJfAup3w.js → cesium-provider-Bh__cBGf.js} +6 -5
  68. package/dist/esm/{deck-provider-C7U9VDEq.js → deck-provider-DxIpS4lY.js} +9 -9
  69. package/dist/esm/events-CrV_misM.js +9 -0
  70. package/dist/esm/{geotiff-source-esnDnC-u.js → geotiff-source-BRjO-Dvr.js} +1 -1
  71. package/dist/esm/{index-BIEmlzCf.js → index-Bh2gBu9u.js} +5 -5
  72. package/dist/esm/{index-jzneDarq.js → index-BoNyIrdq.js} +1 -1
  73. package/dist/esm/{index-jN06TXUp.js → index-C3mnOs0I.js} +4 -4
  74. package/dist/esm/{index-B1zwA4IC.js → index-C63kfbil.js} +6 -6
  75. package/dist/esm/{index-DbSdn93t.js → index-DxbztwCv.js} +7 -7
  76. package/dist/esm/{layer-extension-CZXK5goK.js → layer-extension-C5Y2UES3.js} +1 -1
  77. package/dist/esm/{leaflet-provider-Q41TB6ku.js → leaflet-provider-k6JSYiYX.js} +6 -5
  78. package/dist/esm/loader.js +3 -3
  79. package/dist/esm/{messages-CMKJzsgL.js → messages-QJHuuz0g.js} +1 -9
  80. package/dist/esm/{openlayers-provider-CMsDsQTQ.js → openlayers-provider-DIquf3Tx.js} +5 -4
  81. package/dist/esm/{polygon-layer-ByhxGhWC.js → polygon-layer-ZIT5mJy5.js} +1 -1
  82. package/dist/esm/{scenegraph-layer-09K_B6DT.js → scenegraph-layer-CNIRd2uu.js} +1 -1
  83. package/dist/esm/v-map-builder.entry.js +3 -2
  84. package/dist/esm/v-map-error.entry.js +119 -0
  85. package/dist/esm/v-map-layer-geojson_12.entry.js +10 -9
  86. package/dist/esm/{v-map-layer-helper-Dys44Cgo.js → v-map-layer-helper-CuHYsU9f.js} +2 -1
  87. package/dist/esm/v-map-layer-terrain-geotiff.entry.js +5 -4
  88. package/dist/esm/v-map-layercontrol.entry.js +1 -1
  89. package/dist/esm/v-map.js +3 -3
  90. package/dist/esm/{v-map.v-map-layer-osm.v-map-layergroup-B4pFHuSf.js → v-map.v-map-layer-osm.v-map-layergroup-Zwdvm9PG.js} +10 -9
  91. package/dist/esm/v-map_3.entry.js +5 -4
  92. package/dist/types/components/v-map-error/v-map-error.d.ts +79 -0
  93. package/dist/types/components/v-map-error/v-map-error.test.d.ts +1 -0
  94. package/dist/types/components.d.ts +128 -0
  95. package/dist/v-map/p-05ee633f.entry.js +1 -0
  96. package/dist/v-map/p-08ad1392.entry.js +1 -0
  97. package/dist/v-map/p-2-mR3oVa.js +1 -0
  98. package/dist/v-map/{p-c21c93fe.entry.js → p-3a57b64a.entry.js} +1 -1
  99. package/dist/v-map/p-58dda864.entry.js +1 -0
  100. package/dist/v-map/p-915314c0.entry.js +10 -0
  101. package/dist/v-map/{p-MyTSFnEk.js → p-9Rt23jlQ.js} +1 -1
  102. package/dist/v-map/p-BSsFEMZP.js +1 -0
  103. package/dist/v-map/{p-jzneDarq.js → p-BoNyIrdq.js} +2 -2
  104. package/dist/v-map/p-BpE6L1g0.js +1 -0
  105. package/dist/v-map/{p-DvHXtWUg.js → p-C0M0-Kvt.js} +1 -1
  106. package/dist/v-map/p-CbiLpFhO.js +1 -0
  107. package/dist/v-map/p-Ci70E1EM.js +1 -0
  108. package/dist/v-map/p-CrV_misM.js +1 -0
  109. package/dist/v-map/{p-DrOQ9V4h.js → p-DAf4itFZ.js} +1 -1
  110. package/dist/v-map/p-DVBtCUtQ.js +1 -0
  111. package/dist/v-map/{p-CZqY0yW4.js → p-DuJ_mTaq.js} +1 -1
  112. package/dist/v-map/p-G6iftXUC.js +1 -0
  113. package/dist/v-map/{p-CMKJzsgL.js → p-QJHuuz0g.js} +1 -1
  114. package/dist/v-map/{p-aa410e64.entry.js → p-e21ea0ce.entry.js} +2 -2
  115. package/dist/v-map/{p-DmICdG34.js → p-rCyRSFJb.js} +2 -2
  116. package/dist/v-map/{p-CafTHT9i.js → p-vhbi5XXi.js} +1 -1
  117. package/dist/v-map/{p-Dckgonw8.js → p-yXLNXXx-.js} +1 -1
  118. package/dist/v-map/v-map.esm.js +1 -1
  119. package/package.json +1 -1
  120. package/dist/v-map/p--vVleK-M.js +0 -1
  121. package/dist/v-map/p-09d10db0.entry.js +0 -1
  122. package/dist/v-map/p-5eba6058.entry.js +0 -10
  123. package/dist/v-map/p-6b102336.entry.js +0 -1
  124. package/dist/v-map/p-BdijL4Av.js +0 -1
  125. package/dist/v-map/p-BeFu0ap4.js +0 -1
  126. package/dist/v-map/p-BxFJezdK.js +0 -1
  127. package/dist/v-map/p-DCTHyf58.js +0 -1
  128. package/dist/v-map/p-WaMDUuAz.js +0 -1
  129. package/dist/v-map/p-uiIP-taz.js +0 -1
@@ -1 +1 @@
1
- import{w as t,l as e,e as i}from"./events.js";import{C as s}from"./v-map2.js";import{l as r,a,b as n,G as o,g as h}from"./geotiff-source.js";class c{id;_visible=!0;_basemap=null;_layers=new Map;_originalVisible=new Map;_dirty=!0;constructor(t,e=!0){this.id=t,this._visible=e}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._dirty=!0)}get basemap(){return this._basemap}set basemap(t){this._basemap!==t&&(this._basemap=t,this._dirty=!0)}isDirty(){return this._dirty}addLayer(t){this._layers.has(t.id)||(this._layers.set(t.id,t),this._originalVisible.set(t.id,t.layer.getVisible()),this._dirty=!0)}setLayerElementId(t,e){const i=this._layers.get(t);i&&i.elementId!==e&&(i.elementId=e??null,this._dirty=!0)}removeLayer(t){const e=this._layers.delete(t);return this._originalVisible.delete(t),e&&(this._dirty=!0),e}clear(){this._layers.clear(),this._originalVisible.clear(),this._dirty=!0}apply(){if(this._dirty){for(const[t,e]of this._layers){const i=this._originalVisible.get(t)??!0;let s=this._visible&&i;s&&this._basemap&&(s=e.elementId===this._basemap),e.layer.getVisible()!==s&&e.layer.setVisible(s)}this._dirty=!1}}}class l{_groups=[];_dirty=!0;get groups(){return[...this._groups]}getGroup(t){return this._groups.find((e=>e.id===t))}hasGroup(t){return this._groups.some((e=>e.id===t))}ensureGroup(t,e=!0){let i=this.getGroup(t);return i||(i=new c(t,e),this._groups.push(i),this._dirty=!0,i)}addLayerToGroup(t,e,i){this.ensureGroup(t,e).addLayer(i),this._dirty=!0}removeLayer(t,e=!0){let i=!1;for(const s of this._groups)if(s.removeLayer(t)&&(i=!0,!e))break;return i&&(this._dirty=!0),i}setGroupVisible(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.visible=e,this._dirty=!0}setBasemap(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.basemap=e,this._dirty=!0}apply(){if(this._dirty||this._groups.some((t=>t.isDirty()))){for(const t of this._groups)t.apply();this._dirty=!1}}clear(){this._groups=[],this._dirty=!0}}class u{Cesium;layers=new Map;viewer;constructor(t,e){this.viewer=e,this.Cesium=t}replaceLayer(t,e,i){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");const s=e.getZIndex(),r=e.getVisible(),a=e.getOpacity();this.removeLayer(t);const n=this.addLayer(t,i);return n.setZIndex(s),n.setVisible(r),n.setOpacity(a),n}addLayer(t,e){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");e instanceof this.Cesium.GeoJsonDataSource||e instanceof this.Cesium.DataSource?this.viewer.dataSources.add(e):e instanceof this.Cesium.Cesium3DTileset?(this.viewer.scene.primitives.add(e),e.style||(e.style=new this.Cesium.Cesium3DTileStyle)):e instanceof this.Cesium.ImageryLayer&&this.viewer.imageryLayers.add(e),e.id=t;const i=this.wrapLayer(e);return this.layers.set(t,i),i}addCustomLayer(t,e){return this.layers.set(t,e),e}getLayer(t){const e=this.layers.get(t);if(!e)throw new Error(`Layer mit ID "${t}" nicht gefunden.`);return e}getLayerById(t){return this.getLayer(t)}removeLayer(t){this.getLayer(t).remove(),this.layers.delete(t)}setVisible(t,e){this.getLayer(t).setVisible(e)}setOpacity(t,e){this.getLayer(t).setOpacity(e)}async setZIndex(t,e){const i=this.getLayer(t);await i.setZIndex(e)}wrapLayer(t){return t instanceof this.Cesium.ImageryLayer?this.wrapImageryLayer(t):t instanceof this.Cesium.Cesium3DTileset?this.wrapTilesetLayer(t):this.wrapDataSourceLayer(t)}async sortImageryLayers(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((e=>t.add(e)))}async sort3DTileSets(t,e,i){const s=this.sort(t,e,i);t.removeAll(),s.forEach((e=>t.add(e)))}async sortDataSources(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((async e=>await t.add(e)))}sort(t,e,i){t.remove(e,!1);const s=[];for(let e=0;e<t.length;e++)s.push(t.get(e));return s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),e.zIndex=i,s.push(e),s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),s}wrapImageryLayer(t){const e=this.viewer.imageryLayers;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>t.alpha,setOpacity:e=>{t.alpha=e},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortImageryLayers(e,t,i)},remove:()=>e.remove(t)}}wrapTilesetLayer(t){const e=this.viewer.scene.primitives;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>{const e=t.style;if(e.color&&"string"==typeof e.color){const t=e.color.match(/color\(.*?,([\d.]+)\)/);return t?parseFloat(t[1]):1}return 1},setOpacity:e=>{const i=t.style.color;let s;if("string"==typeof i){const t=i.replace(/color\((.*?),[\d.]+\)/,`color($1, ${e})`);s=t.includes("color")?t:`color('white', ${e})`}else s=`color('white', ${e})`;t.style=new this.Cesium.Cesium3DTileStyle({color:s,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},getZIndex:()=>{const e=this.viewer.scene.primitives;for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&this.sort3DTileSets(e,t,i)},setColor:(e,i=1)=>{const s=e instanceof this.Cesium.Color?e.toCssHexString():e.replace(/[#\s]/g,"");t.style=new this.Cesium.Cesium3DTileStyle({color:`color('${s}', ${i})`,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},setStyle:e=>{t.style=e instanceof this.Cesium.Cesium3DTileStyle?e:new this.Cesium.Cesium3DTileStyle(e)},remove:()=>this.viewer.scene.primitives.remove(t)}}wrapDataSourceLayer(t){const e=this.viewer.dataSources;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>1,setOpacity:e=>{t.__vmapLockOpacity||t.entities.values.forEach((t=>{const i=(t,i)=>{const{Color:s,JulianDate:r}=this.Cesium,a=t=>s.fromAlpha(t??i,e,new s);if(!t)return new this.Cesium.ConstantProperty(a(i));const n=t;if(n&&"function"==typeof n.getValue){const t=a(n.getValue(this.viewer?.clock?.currentTime??new r,new s));return"function"==typeof n.setValue?(n.setValue(t),n):new this.Cesium.ConstantProperty(t)}return new this.Cesium.ConstantProperty(a(t instanceof this.Cesium.Color?t:i))};if(t.polygon){const e=t.polygon.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.ImageMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}if(t.polyline){const e=t.polyline.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.PolylineOutlineMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}t.point&&(t.point.color=i(t.point.color,Cesium.Color.WHITE)),t.billboard&&(t.billboard.color=i(t.billboard.color,Cesium.Color.WHITE)),t.label&&(t.label.fillColor=i(t.label.fillColor,Cesium.Color.BLACK),t.label.outlineColor&&(t.label.outlineColor=i(t.label.outlineColor,Cesium.Color.BLACK))),t.model&&(t.model.color=i(t.model.color,Cesium.Color.WHITE))}))},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortDataSources(e,t,i)},remove:()=>e.remove(t)}}}class w{locked=!1;queue=[];async runExclusive(t){await this.acquire();try{return await t()}finally{this.release()}}acquire(){return this.locked?new Promise((t=>this.queue.push(t))):(this.locked=!0,Promise.resolve())}release(){const t=this.queue.shift();t?t():this.locked=!1}}function p(t,e){if(!t)throw new Error(e)}const m=new w;class d{tileWidth;tileHeight;tilingScheme;rectangle;errorEvent;credit=void 0;tileDiscardPolicy=void 0;proxy=void 0;hasAlphaChannel=!0;minimumLevel;maximumLevel;Cesium;tileProcessor;resolution;resampleMethod;colorStops;readyPromiseInternal;ready=!1;constructor(t){const{Cesium:e,rectangleDegrees:i,tileProcessor:s,tileSize:r,resolution:a,resampleMethod:n,colorStops:o,minimumLevel:h,maximumLevel:c}=t;this.Cesium=e,this.tileProcessor=s,this.tileWidth=r,this.tileHeight=r,this.resolution=a,this.resampleMethod=n,this.colorStops=o,this.minimumLevel=h??0,this.maximumLevel=c,this.rectangle=e.Rectangle.fromDegrees(i[0],i[1],i[2],i[3]),this.tilingScheme=new e.WebMercatorTilingScheme,this.errorEvent=new e.Event,this.ready=!0,this.readyPromiseInternal=Promise.resolve(!0)}get tilingSchemeName(){return this.tilingScheme instanceof this.Cesium.WebMercatorTilingScheme?"WebMercator":void 0}get readyPromise(){return this.readyPromiseInternal}get tileCredits(){}getTileCredits(t,e,i){}get url(){}flipCanvasVertically(e,i,s){const r=document.createElement("canvas");r.width=i,r.height=s;const a=r.getContext("2d");return a?(a.translate(0,s),a.scale(1,-1),a.drawImage(e,0,0),r):(t("v-map - cesium - failed to get 2d context for flip"),e)}async createFlippedImageBitmap(e,i){if("function"==typeof createImageBitmap)try{const t=document.createElement("canvas");t.width=i,t.height=i;const s=t.getContext("2d");if(!s)throw new Error("Failed to get 2d context");const r=s.createImageData(i,i);r.data.set(e),s.putImageData(r,0,0);const a=this.flipCanvasVertically(t,i,i);return await createImageBitmap(a)}catch(e){return void t("v-map - cesium - createImageBitmap failed, falling back",e)}}async createFlippedImageFromRGBA(e){const i=Math.ceil(this.tileWidth*this.resolution),s=await this.createFlippedImageBitmap(e,i);if(s)return s;const r=document.createElement("canvas");r.width=i,r.height=i;const a=r.getContext("2d");if(!a)return void t("v-map - cesium - unable to acquire canvas 2d context");const n=a.createImageData(i,i);return n.data.set(e),a.putImageData(n,0,0),this.flipCanvasVertically(r,i,i)}async requestImage(i,s,r){if(!this.ready)return;if(r<this.minimumLevel||void 0!==this.maximumLevel&&r>this.maximumLevel)return;const a={x:i,y:s,z:r,tileSize:this.tileWidth,resolution:this.resolution,resampleMethod:this.resampleMethod,colorStops:this.colorStops};let n=null;try{if(n=await this.tileProcessor.getTileData(a),!n)return void e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): no data returned`);e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): rgba ${n.length} bytes, sampleSize=${Math.ceil(this.tileWidth*this.resolution)}`)}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - getTileData - GeoTIFF tile request failed",e)}try{const t=await this.createFlippedImageFromRGBA(n);return e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): result=${t?.constructor?.name??"undefined"}, size=${t instanceof HTMLCanvasElement||t instanceof ImageBitmap?`${t.width}x${t.height}`:"n/a"}`),t}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - createFlippedImageFromRGBA - GeoTIFF tile request failed",e)}}pickFeatures(){}}const y="v-map - cesium - terrain-geotiff - ";class f{Cesium;image;fromProjection="EPSG:4326";sourceBounds=[0,0,0,0];wgs84Bounds=[0,0,0,0];width=0;height=0;noDataValue=0;ready=!1;_readyPromise;heightmapWidth=65;heightmapHeight=65;proj4;tilingScheme;constructor(t){this.Cesium=t.Cesium,this.tilingScheme=new this.Cesium.GeographicTilingScheme,this._readyPromise=this.initialize(t)}async initialize(t){try{e(`${y}loadGeoTIFF: url=${t.url}`);const[i,{default:s},a]=await Promise.all([import("./geotiff.js").then((function(t){return t.g})),import("./index4.js"),import("./main-dist.js").then((function(t){return t.m}))]),n=await r(t.url,{projection:t.projection,forceProjection:t.forceProjection??!1,nodata:t.nodata},{geotiff:i,proj4:s,geokeysToProj4:a});return this.image=n.baseImage,this.fromProjection=n.fromProjection,this.sourceBounds=n.sourceBounds,this.wgs84Bounds=n.wgs84Bounds,this.width=n.width,this.height=n.height,this.noDataValue=n.noDataValue??0,this.proj4=n.proj4,e(`${y}loaded: projection=${this.fromProjection}, bounds=[${this.sourceBounds.map((t=>t.toFixed(0))).join(",")}], wgs84=[${this.wgs84Bounds.map((t=>t.toFixed(4))).join(",")}], size=${this.width}x${this.height}`),this.ready=!0,!0}catch(t){return i(`${y}failed to load GeoTIFF:`,t),this.ready=!1,!1}}get rectangle(){if(!this.ready||!this.wgs84Bounds)return this.Cesium.Rectangle.MAX_VALUE;const[t,e,i,s]=this.wgs84Bounds;return this.Cesium.Rectangle.fromDegrees(t,e,i,s)}async requestTileGeometry(e,i,s){if(this.ready&&this.image)try{const r=this.tilingScheme.tileXYToRectangle(e,i,s);let a=this.Cesium.Math.toDegrees(r.west),n=this.Cesium.Math.toDegrees(r.south),o=this.Cesium.Math.toDegrees(r.east),h=this.Cesium.Math.toDegrees(r.north);const[c,l,u,w]=this.wgs84Bounds;if(o<c||a>u||h<l||n>w)return this.createFlatHeightmap();a=Math.max(c,Math.min(u,a)),o=Math.max(c,Math.min(u,o)),n=Math.max(l,Math.min(w,n)),h=Math.max(l,Math.min(w,h));const p=e=>{try{return this.proj4("EPSG:4326",this.fromProjection,e)}catch(i){return t(`${y}transform failed:`,i),e}},m=p([a,n]),d=p([o,h]),[f,g,v,b]=this.sourceBounds,S=this.width,C=this.height,$=v-f,L=b-g,G=Math.floor((m[0]-f)/$*S),k=Math.floor((b-d[1])/L*C),M=Math.ceil((d[0]-f)/$*S),x=Math.ceil((b-m[1])/L*C),F=Math.max(0,Math.min(G,S)),E=Math.max(0,Math.min(k,C)),I=Math.max(1,Math.min(M-G,S-F)),T=Math.max(1,Math.min(x-k,C-E)),O=(await this.image.readRasters({window:[F,E,F+I,E+T],width:this.heightmapWidth,height:this.heightmapHeight,resampleMethod:"bilinear"}))[0],A=new Float32Array(this.heightmapWidth*this.heightmapHeight);for(let t=0;t<A.length;t++){let e=O[t];e!==this.noDataValue&&isFinite(e)||(e=0),A[t]=e}return new this.Cesium.HeightmapTerrainData({buffer:A,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0,structure:{heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:1}})}catch(e){return t(`${y}failed to load tile geometry:`,e),this.createFlatHeightmap()}}createFlatHeightmap(){const t=new Float32Array(this.heightmapWidth*this.heightmapHeight);return t.fill(0),new this.Cesium.HeightmapTerrainData({buffer:t,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0})}get availability(){}getTilingScheme(){return this.tilingScheme}getLevelMaximumGeometricError(t){return this.tilingScheme.ellipsoid.maximumRadius/(65*Math.pow(2,t))}loadTileDataAvailability(t,e,i){}getTileDataAvailable(t,e,i){if(!this.ready)return!1;const s=this.tilingScheme.tileXYToRectangle(t,e,i),r=this.Cesium.Math.toDegrees(s.west),a=this.Cesium.Math.toDegrees(s.south),n=this.Cesium.Math.toDegrees(s.east),o=this.Cesium.Math.toDegrees(s.north),[h,c,l,u]=this.wgs84Bounds;return!(n<h||r>l||o<c||a>u)}get readyPromise(){return this._readyPromise}get credit(){return new this.Cesium.Credit("GeoTIFF Terrain")}get hasWaterMask(){return!1}get hasVertexNormals(){return!1}get errorEvent(){return new this.Cesium.Event}}const g="v-map - cesium - terrain-geotiff - ";class v{Cesium;viewer;provider;options;opacity=1;previousProvider;constructor(t,e,i,s){this.Cesium=t,this.viewer=e,this.provider=i,this.options=s??{},this.previousProvider=e.terrainProvider,this.viewer.terrainProvider=this.provider}getOptions(){return this.options}setOptions(t){this.options=t}getVisible(){return this.viewer.scene.globe.show}setVisible(t){this.viewer.scene.globe.show=t}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e;const i=this.viewer.scene.globe;if(!i.translucency)try{i.translucency=new this.Cesium.GlobeTranslucency,i.translucency.enabled=!0}catch(e){return void t("Cesium terrain opacity not supported",e)}i.translucency.enabled=e<1,i.translucency.frontFaceAlpha=e}getZIndex(){return 0}async setZIndex(t){}remove(){try{this.viewer.terrainProvider=this.previousProvider?this.previousProvider:new this.Cesium.EllipsoidTerrainProvider,this.viewer.scene.globe.show=!0}catch(e){t("Cesium terrain reset failed",e)}}}class b{viewer;Cesium;layerManager;shadowRoot;layerGroups=new l;layerManagerMutex=new w;layerErrorCallbacks=new Map;layerErrorCleanups=new Map;async init(t){this.shadowRoot=t.shadowRoot;const e=t.target.getRootNode()instanceof ShadowRoot?t.target.getRootNode():void 0;await async function(t){const e=`https://cdn.jsdelivr.net/npm/cesium@${s.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Widgets/widgets.css`,r=(await(await fetch(i)).text()).replace(/url\((?!['"]?data:)(['"]?)([^'")]+)\1\)/g,((t,i,s)=>`url(${e}/Widgets/${s.replace(/^\.?\//,"")})`));if(t)if("adoptedStyleSheets"in Document.prototype){const e=new CSSStyleSheet;await e.replace(r),t.adoptedStyleSheets=[...t.adoptedStyleSheets??[],e]}else{const e=document.createElement("style");e.textContent=r,t.appendChild(e)}}(e),this.Cesium=await async function(t=s){const e=`https://cdn.jsdelivr.net/npm/cesium@${t.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Cesium.js`;await m.runExclusive((async()=>{globalThis.Cesium||await new Promise(((t,e)=>{const s="cesium-cdn-script";if(document.getElementById(s))return t();const r=document.createElement("script");r.id=s,r.async=!0,r.src=i,r.addEventListener("load",(()=>t()),{once:!0}),r.addEventListener("error",(()=>e(new Error(`Laden fehlgeschlagen: ${i}`))),{once:!0}),document.head.appendChild(r)}))}));const r=globalThis.Cesium;p(r,"globalThis.Cesium nicht verfügbar.");const a=r.VERSION;var n,o;return p((n=String(t),o=a,n.match(/^\d+\.\d+/)?.[0]===o.match(/^\d+\.\d+/)?.[0]),`Cesium-Version abweichend: erwartet ~${t}, geladen ${a}`),globalThis.CESIUM_BASE_URL=e,r}(),Cesium.Ion.defaultAccessToken=null,this.viewer=new this.Cesium.Viewer(t.target,{baseLayer:!1,baseLayerPicker:!1,terrainProvider:new Cesium.EllipsoidTerrainProvider}),this.viewer.scene.primitives.removeAll(),this.viewer.scene.backgroundColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.baseColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.depthTestAgainstTerrain=!1,this.layerManager=new u(this.Cesium,this.viewer)}async destroy(){!function(t){if(!t)return;const i=Array.from(t.querySelectorAll("style"));for(const t of i)if(t.textContent?.includes(".cesium-credit-lightbox-overlay")){t.remove(),e("v-map - provider - cesium - Cesium‑Widget‑CSS entfernt");break}}(this.shadowRoot),this.viewer?.destroy(),this.viewer=void 0}async createLayer(t,e){let i=null;switch(t.type){case"geojson":{const s={},r=t,a=await this.createGeoJSONLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"osm":{const s=await this.createOSMLayer(t);i=this.layerManager.addLayer(e,s);break}case"google":{const s=await this.createGoogleLayer(t);i=this.layerManager.addLayer(e,s);break}case"terrain":{const s=await this.createTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}case"xyz":{const s=await this.createXYZLayer(t);i=this.layerManager.addLayer(e,s);break}case"wms":{const s=await this.addWMSLayer(t);i=this.layerManager.addLayer(e,s);break}case"wcs":{const s=await this.createWCSLayer(t);i=this.layerManager.addLayer(e,s);break}case"arcgis":await this.addArcGISLayer(t);break;case"wfs":{const s={clampToGround:!0},r=t,a=await this.createWFSLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"wkt":{const s={clampToGround:!0},r=t,a=await this.createWKTLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"geotiff":{const s=await this.createGeoTIFFLayer(t);i=this.layerManager.addLayer(e,s);break}case"tile3d":{const s=await this.createTile3DLayer(t);i=this.layerManager.addLayer(e,s);const r=t;i.setOptions(r.tilesetOptions??{}),r.cesiumStyle&&"setStyle"in i&&i.setStyle(r.cesiumStyle);break}case"terrain-geotiff":{const s=await this.createGeoTIFFTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}default:throw new Error(`Unsupported layer type: ${t.type}`)}if(!i)return null;const s=t;return void 0!==s.zIndex&&await i.setZIndex(s.zIndex),void 0!==s.opacity&&i.setOpacity(s.opacity),void 0!==s.visible&&i.setVisible(s.visible),i}async addLayerToGroup(t){return await this.layerManagerMutex.runExclusive((async()=>{const e=crypto.randomUUID(),i=await this.createLayer(t,e);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:e,elementId:t.layerElementId??t.elementId??null,layer:i}),this.layerGroups.apply(),e}))}async setBaseLayer(t,e){await this.layerManagerMutex.runExclusive((async()=>{this.layerGroups.setBasemap(t,e??null),this.layerGroups.apply()}))}async addBaseLayer(t,e,i){return i&&e?await this.layerManagerMutex.runExclusive((async()=>{const s=crypto.randomUUID(),r=await this.createLayer(t,s);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:s,elementId:i,layer:r}),this.layerGroups.setBasemap(t.groupId??"basemap",e),this.layerGroups.apply(),s})):null}async ensureGroup(t,e,i){this.layerGroups.ensureGroup(t,e)}async setGroupVisible(t,e){this.layerGroups.setGroupVisible(t,e),this.layerGroups.apply()}onLayerError(t,e){this.layerErrorCallbacks.set(t,e),this.attachCesiumErrorListeners(t)}offLayerError(t){this.layerErrorCleanups.get(t)?.(),this.layerErrorCleanups.delete(t),this.layerErrorCallbacks.delete(t)}attachCesiumErrorListeners(t){this.layerErrorCleanups.get(t)?.();const e=this.layerErrorCallbacks.get(t);if(!e)return;const i=this.layerManager.getLayer(t);if(!i)return;const s=[],r=()=>{e({type:"network",message:"Tile load error"})},a=i._imageryLayer;if(a?.imageryProvider?.errorEvent){const t=a.imageryProvider.errorEvent.addEventListener(r);s.push(t)}const n=i._tileset;if(n?.tileFailed){const t=n.tileFailed.addEventListener(r);s.push(t)}s.length>0&&this.layerErrorCleanups.set(t,(()=>s.forEach((t=>t()))))}async removeLayer(t){t&&(this.offLayerError(t),await this.layerManagerMutex.runExclusive((async()=>{this.layerManager.removeLayer(t),this.layerGroups.removeLayer(t,!0),this.layerGroups.apply()})))}async setOpacity(t,e){this.layerManager.setOpacity(t,e),this.layerGroups.apply()}async setVisible(t,e){this.layerManager.setVisible(t,e),this.layerGroups.apply()}async setZIndex(t,e){await this.layerManager.setZIndex(t,e),this.layerGroups.apply()}applyGeostylerStyling(t,i){t.__vmapLockOpacity=!0;const s=(t,e)=>null==t||"object"==typeof t&&null!==t&&"name"in t?e:t,r=(t,e)=>{if(null==t)return e;if("number"==typeof t)return t;const i=Number(t);return Number.isFinite(i)?i:e},a=t.entities.values;if(i.rules)for(const t of i.rules)if(t.symbolizers)for(const i of t.symbolizers)for(let t=0;t<a.length;t++){const n=a[t];switch(i.kind){case"Fill":if(n.polygon){const t=s(i.color,"rgba(0,100,255,0.3)"),a=r(s(i.opacity,.3),.3),o=s(i.outlineColor,"rgba(0,100,255,1)"),h=s(i.outlineWidth,1);let c=this.parseCesiumColor(t,this.Cesium.Color.BLUE.withAlpha(.3));null!=a&&(c=this.applyCesiumOpacity(c,a));const l=this.parseCesiumColor(o,this.Cesium.Color.BLUE);e("v-map - provider - cesium - applyGeostylerStyling: Fill",{fillColor:t,fillOpacity:a,computedFill:c?.toString?.(),outlineColor:o,outlineWidth:h}),n.polygon.fill=new this.Cesium.ConstantProperty(!0),n.polygon.material=new this.Cesium.ColorMaterialProperty(c),n.polygon.outline=new this.Cesium.ConstantProperty(!0),n.polygon.outlineColor=new this.Cesium.ConstantProperty(l),n.polygon.outlineWidth=new this.Cesium.ConstantProperty(h),n.polygon.extrudedHeight=void 0,n.polygon.heightReference=new this.Cesium.ConstantProperty(this.Cesium.HeightReference.CLAMP_TO_GROUND),n.polygon.perPositionHeight=new this.Cesium.ConstantProperty(!1),n.polygon.classificationType=new this.Cesium.ConstantProperty(this.Cesium.ClassificationType.BOTH)}break;case"Line":if(n.polyline){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.width,2),2),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Line",{lineColor:t,lineOpacity:o,computedColor:h?.toString?.(),lineWidth:a}),n.polyline.material=new this.Cesium.ColorMaterialProperty(h),n.polyline.width=new this.Cesium.ConstantProperty(a)}break;case"Mark":if(n.point){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.radius,6),6),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Mark",{pointColor:t,pointOpacity:o,computedColor:h?.toString?.(),pointRadius:a}),n.point.color=new this.Cesium.ConstantProperty(h),n.point.pixelSize=new this.Cesium.ConstantProperty(a)}break;case"Icon":if(n.point){const t=s(i.image),a=r(s(i.size,32),32),o=r(s(i.opacity,1),1);t&&"string"==typeof t&&(n.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(t),width:new this.Cesium.ConstantProperty(a),height:new this.Cesium.ConstantProperty(a),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),color:null!=o?new this.Cesium.ConstantProperty(this.Cesium.Color.WHITE.withAlpha(o)):void 0}),n.point.show=new this.Cesium.ConstantProperty(!1),e("v-map - provider - cesium - applyGeostylerStyling: Icon",{iconSrc:t,iconSize:a,iconOpacity:o}))}break;case"Text":const t=i.label,a="string"==typeof t?t:void 0;if(a&&n.properties&&n.properties[a]){const t=s(i.color,"#000000"),o=r(s(i.size,12),12),h=r(s(i.opacity,1),1);let c=this.parseCesiumColor(t,this.Cesium.Color.WHITE);null!=h&&(c=this.applyCesiumOpacity(c,h)),e("v-map - provider - cesium - applyGeostylerStyling: Text",{labelProp:a,textColor:t,textOpacity:h,computedColor:c?.toString?.(),textSize:o});const l=n.properties[a]?.getValue?.(this.viewer.clock.currentTime)??n.properties[a]?._value??"";n.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(l)),font:new this.Cesium.ConstantProperty(`${o}px Arial`),fillColor:new this.Cesium.ConstantProperty(c),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}}parseCesiumColor(t,e){if(!t)return e;if(t.startsWith("#"))return this.Cesium.Color.fromCssColorString(t);if(t.includes("rgb"))return this.Cesium.Color.fromCssColorString(t);try{return this.Cesium.Color.fromCssColorString(t)}catch{return e}}applyCesiumOpacity(t,e){return t?t.withAlpha(e):t}createCesiumStyle(t={}){const e=this.Cesium.Color.BLUE.withAlpha(.3),i=this.Cesium.Color.BLUE,s=this.Cesium.Color.BLUE,r=this.parseCesiumColor(t.fillColor,e),a=this.parseCesiumColor(t.strokeColor,i),n=this.parseCesiumColor(t.pointColor,s),o=void 0!==t.fillOpacity?this.applyCesiumOpacity(r,t.fillOpacity):r,h=void 0!==t.strokeOpacity?this.applyCesiumOpacity(a,t.strokeOpacity):a,c=void 0!==t.pointOpacity?this.applyCesiumOpacity(n,t.pointOpacity):n;return{fill:!0,fillColor:o,outline:!0,outlineColor:h,outlineWidth:t.strokeWidth??2,extrudedHeight:t.extrudeHeight,heightReference:t.zOffset?this.Cesium.HeightReference.RELATIVE_TO_GROUND:this.Cesium.HeightReference.CLAMP_TO_GROUND,pixelSize:t.pointRadius??8,color:c,scaleByDistance:t.pointRadius?new this.Cesium.NearFarScalar(150,2,15e6,.5):void 0,width:t.strokeWidth??2,clampToGround:!t.zOffset,labelText:t.textProperty,labelFont:t.textSize?`${t.textSize}pt monospace`:"12pt monospace",labelFillColor:t.textColor?this.parseCesiumColor(t.textColor,this.Cesium.Color.WHITE):this.Cesium.Color.WHITE,labelOutlineColor:t.textHaloColor?this.parseCesiumColor(t.textHaloColor,this.Cesium.Color.BLACK):this.Cesium.Color.BLACK,labelOutlineWidth:t.textHaloWidth??1,labelPixelOffset:t.textOffset?new this.Cesium.Cartesian2(t.textOffset[0],t.textOffset[1]):this.Cesium.Cartesian2.ZERO,height:t.zOffset??0}}applyEnhancedStyling(t,e={}){const i=this.createCesiumStyle(e),s=t.entities.values;for(let t=0;t<s.length;t++){const r=s[t];let a=i;if(e.styleFunction&&r.properties){const t={properties:r.properties._propertyNames.reduce(((t,e)=>(t[e]=r.properties[e]?._value,t)),{}),geometry:r},s=e.styleFunction(t);s&&(a={...i,...this.createCesiumStyle(s)})}if(r.polygon&&(r.polygon.fill=new this.Cesium.ConstantProperty(a.fill),r.polygon.material=new this.Cesium.ColorMaterialProperty(a.fillColor),r.polygon.outline=new this.Cesium.ConstantProperty(a.outline),r.polygon.outlineColor=new this.Cesium.ConstantProperty(a.outlineColor),r.polygon.outlineWidth=new this.Cesium.ConstantProperty(a.outlineWidth),r.polygon.height=void 0!==a.height?new this.Cesium.ConstantProperty(a.height):void 0,r.polygon.extrudedHeight=void 0!==a.extrudedHeight?new this.Cesium.ConstantProperty(a.extrudedHeight):void 0,r.polygon.heightReference=void 0!==a.heightReference?new this.Cesium.ConstantProperty(a.heightReference):void 0),r.polyline&&(r.polyline.material=new this.Cesium.ColorMaterialProperty(a.outlineColor),r.polyline.width=new this.Cesium.ConstantProperty(a.width),r.polyline.clampToGround=new this.Cesium.ConstantProperty(a.clampToGround)),r.point){r.point.pixelSize=new this.Cesium.ConstantProperty(a.pixelSize),r.point.color=new this.Cesium.ConstantProperty(a.color);const t=a.scaleByDistance;r.point.scaleByDistance=t?new this.Cesium.ConstantProperty(t):void 0,e.iconUrl&&(r.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(e.iconUrl),width:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[0]:32),height:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[1]:32),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),scaleByDistance:t?new this.Cesium.ConstantProperty(t):void 0}),r.point.show=new this.Cesium.ConstantProperty(!1))}if(e.textProperty&&r.properties&&r.properties[e.textProperty]){const t=r.properties[e.textProperty]?.getValue?.(this.viewer.clock.currentTime)??r.properties[e.textProperty]?._value??"";r.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(t)),font:new this.Cesium.ConstantProperty(a.labelFont),fillColor:new this.Cesium.ConstantProperty(a.labelFillColor),outlineColor:new this.Cesium.ConstantProperty(a.labelOutlineColor),outlineWidth:new this.Cesium.ConstantProperty(a.labelOutlineWidth),pixelOffset:new this.Cesium.ConstantProperty(a.labelPixelOffset),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}async createWKTLayer(t,e){const i=await this.wktToGeoJSON(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async wktToGeoJSON(t){const e=await this.resolveWktText(t),i=await import("./index5.js").then((function(t){return t.i})),s="function"==typeof i.default?i.default:i.parse;if("function"!=typeof s)throw new Error("wellknown parser not available");const r=s(e);if(!r)throw new Error("Failed to parse WKT");return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:r}]}}async resolveWktText(t){if(t.wkt)return t.wkt;if(t.url){const e=await fetch(t.url);if(!e.ok)throw new Error(`Failed to fetch WKT: ${e.status}`);return await e.text()}throw new Error("Either wkt or url must be provided")}async createGeoJSONLayer(t,e){let i=null;i=t.geojson?JSON.parse(t.geojson):t.url;const s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createWFSLayer(t,e){const i=await this.fetchWFSFromUrl(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createOSMLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:t.url||"https://a.tile.openstreetmap.org"}))}async createGoogleLayer(t){if(!t.apiKey)throw new Error("Google-Layer benötigt 'apiKey' (Google Maps Platform).");await this.loadGoogleMapsApi(t.apiKey,{language:t.language,region:t.region,libraries:t.libraries});const e=this.getGoogleMapTypeId(t.mapType||"roadmap"),i=this.Cesium,s=new i.UrlTemplateImageryProvider({url:"https://maps.googleapis.com/maps/api/staticmap?template",maximumLevel:t.maxZoom||19,minimumLevel:0,tilingScheme:new i.WebMercatorTilingScheme,credit:"Google Maps",urlSchemeZeroPadding:{"{x}":"","{y}":"","{z}":""}});return s.buildImageResource=function(s,r,a){const n=(new i.WebMercatorTilingScheme).tileXYToRectangle(s,r,a),o=i.Math.toDegrees(n.west),h=i.Math.toDegrees(n.south),c=i.Math.toDegrees(n.east),l=i.Math.toDegrees(n.north),u=new URLSearchParams({center:`${(h+l)/2},${(o+c)/2}`,zoom:a.toString(),size:"256x256",scale:"scaleFactor1x"===t.scale?"1":"2",maptype:e,key:t.apiKey,format:"png"});t.language&&u.set("language",t.language),t.region&&u.set("region",t.region);const w=`https://maps.googleapis.com/maps/api/staticmap?${u.toString()}`;return new i.Resource({url:w})},this.ensureGoogleLogo(),new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}getGoogleMapTypeId(t){switch(t){case"roadmap":default:return"roadmap";case"satellite":return"satellite";case"terrain":return"terrain";case"hybrid":return"hybrid"}}async loadGoogleMapsApi(t,e){const i=window,s=i.__mockGoogleMapsApi;"function"!=typeof s?i.google?.maps||await new Promise(((s,r)=>{const a="___cesiumGoogleInit___"+Math.random().toString(36).slice(2);i[a]=()=>s();const n=document.createElement("script"),o=new URLSearchParams({key:t,callback:a,v:"weekly"});e?.language&&o.set("language",e.language),e?.region&&o.set("region",e.region),e?.libraries?.length&&o.set("libraries",e.libraries.join(",")),n.src=`https://maps.googleapis.com/maps/api/js?${o.toString()}`,n.async=!0,n.onerror=()=>r(new Error("Google Maps JS API failed to load")),document.head.appendChild(n)})):await s(t,e)}ensureGoogleLogo(){if(!this.viewer?.container||this.viewer.container._googleLogoAdded)return;const t=document.createElement("img");t.src="https://developers.google.com/static/maps/documentation/images/google_on_white.png",t.alt="Google",t.style.position="absolute",t.style.bottom="6px",t.style.left="6px",t.style.height="18px",t.style.pointerEvents="none",t.style.zIndex="1000",this.viewer.container.appendChild(t),this.viewer.container._googleLogoAdded=!0}async createXYZLayer(t){if(!t.url)throw new Error("XYZ layer requires a url");const e=Array.isArray(t.attributions)?t.attributions.join(", "):t.attributions,i={url:t.url,credit:e,maximumLevel:t.maxZoom,...t.options||{}},s=new this.Cesium.UrlTemplateImageryProvider(i);return new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}async createTerrainLayer(t){let e;e=t.elevationData?await this.Cesium.CesiumTerrainProvider.fromUrl(t.elevationData):await this.Cesium.createWorldTerrainAsync();const i=new v(this.Cesium,this.viewer,e,t);return void 0!==t.visible&&i.setVisible(t.visible),void 0!==t.opacity&&i.setOpacity(t.opacity),i}async createGeoTIFFTerrainLayer(t){if(!t.url){e(`${g}layer created without URL, waiting for URL to load`);const i=new this.Cesium.EllipsoidTerrainProvider,s=new v(this.Cesium,this.viewer,i,t);return s.setVisible(!1),s}try{e(`${g}create layer: url=${t.url}`);const i=await async function(t){const e=new f(t);return await e.readyPromise,e}({url:t.url,projection:t.projection,forceProjection:t.forceProjection,nodata:t.nodata,Cesium:this.Cesium}),s=new v(this.Cesium,this.viewer,i,t);return void 0!==t.visible&&s.setVisible(t.visible),void 0!==t.opacity&&s.setOpacity(t.opacity),e(`${g}layer created successfully`),s}catch(e){i(`${g}failed to create terrain layer:`,e);const s=new this.Cesium.EllipsoidTerrainProvider;return new v(this.Cesium,this.viewer,s,t)}}async addWMSLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.WebMapServiceImageryProvider({url:t.url,layers:t.layers,parameters:t.extraParams}))}async createWCSLayer(t){if(!t.url||!t.coverageName)throw new Error("WCS layer requires url and coverageName");const e=t.version??"2.0.1",i=t.format??"image/tiff",s=t.projection??"EPSG:4326",r=t.tileSize??256,a=this.Cesium,n=new a.UrlTemplateImageryProvider({url:`${t.url}?wcs_placeholder`,maximumLevel:t.maxZoom??18,minimumLevel:t.minZoom??0,tileWidth:r,tileHeight:r,tilingScheme:new a.GeographicTilingScheme,credit:"WCS"});return n.buildImageResource=function(n,o,h){const c=(new a.GeographicTilingScheme).tileXYToRectangle(n,o,h),l=a.Math.toDegrees(c.west),u=a.Math.toDegrees(c.south),w=a.Math.toDegrees(c.east),p=a.Math.toDegrees(c.north),m={SERVICE:"WCS",REQUEST:"GetCoverage",VERSION:e,FORMAT:i};let d;if(e.startsWith("2.0")){const e={...m,coverageId:t.coverageName,...t.params||{}};(i.includes("tiff")||i.includes("geotiff"))&&(e["geotiff:compression"]="LZW");const s=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&s.set(t,String(e))}));const r=s.toString(),a=`subset=X(${l},${w})`,n=`subset=Y(${u},${p})`;d=`${t.url}${t.url.includes("?")?"&":"?"}${r}&${a}&${n}`}else{const e={...m,COVERAGE:t.coverageName,BBOX:`${l},${u},${w},${p}`,CRS:s,WIDTH:String(r),HEIGHT:String(r),...t.params||{}},i=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),d=`${t.url}${t.url.includes("?")?"&":"?"}${i.toString()}`}return new a.Resource({url:d})},new this.Cesium.ImageryLayer(n,{alpha:t.opacity??1,show:t.visible??!0})}async addArcGISLayer(t){const e=await this.Cesium.ArcGisMapServerImageryProvider.fromUrl(t.url);this.viewer.imageryLayers.addImageryProvider(e)}async createGeoTIFFLayer(t){if(!t.url)throw new Error("GeoTIFF layer requires a URL");try{const e=t,i=await a(t.url,e.projection,e.forceProjection,t.nodata),s=await n(i,"EPSG:3857"),r=new o(s);let c;if(r.createGlobalTriangulation(),t.colorMap){const{stops:e}=h(t.colorMap,t.valueRange);c=e}const l=new d({Cesium:this.Cesium,rectangleDegrees:i.wgs84Bounds,tileProcessor:r,tileSize:t.tileSize??256,resolution:t.resolution??1,resampleMethod:t.resampleMethod??"bilinear",colorStops:c}),u=new this.Cesium.ImageryLayer(l,{alpha:t.opacity??1,show:t.visible??!0});return u.__vmapGeoTIFFMeta={url:t.url,width:i.width,height:i.height,samplesPerPixel:i.samplesPerPixel,noData:i.noDataValue},u}catch(t){i("v-map - provider - cesium - Failed to create GeoTIFF layer",t);const e=new this.Cesium.SingleTileImageryProvider({url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",rectangle:this.Cesium.Rectangle.fromDegrees(-180,-90,180,90)});return new this.Cesium.ImageryLayer(e,{alpha:0,show:!1})}}async createTile3DLayer(t){if(!t.url)throw new Error("Tile3D layer requires a URL");const e=await this.Cesium.Cesium3DTileset.fromUrl(t.url,t.tilesetOptions??{});return t.cesiumStyle&&(e.style=new this.Cesium.Cesium3DTileStyle(t.cesiumStyle)),e}async updateLayer(t,e){return await this.layerManagerMutex.runExclusive((async()=>{const i=this.layerErrorCallbacks.has(t);i&&this.offLayerError(t);const s=this.layerManager.getLayer(t);switch(e.type){case"geojson":{const i=e.data,r=s.getOptions(),a=await this.createGeoJSONLayer({geojson:i.geojson,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"wfs":{const i=e.data,r=s.getOptions(),a=await this.createWFSLayer(i,r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"osm":{const i=s.getOptions(),r=new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:e.data.url||"https://a.tile.openstreetmap.org"}));this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"google":{const i=s.getOptions(),r=await this.createGoogleLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"xyz":{const i=s.getOptions(),r=await this.createXYZLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wcs":{const i=s.getOptions(),r=await this.createWCSLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wkt":{const i=e.data,r=s.getOptions(),a=await this.createWKTLayer({wkt:i.wkt,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"geotiff":{const i=e.data,r=await this.createGeoTIFFLayer({url:i.url});this.layerManager.replaceLayer(t,s,r)}break;case"tile3d":{const i=e.data??{};if(!i.url)throw new Error("tile3d update requires a url");const r=await this.createTile3DLayer({type:"tile3d",url:i.url,tilesetOptions:i.tilesetOptions,cesiumStyle:i.cesiumStyle}),a=this.layerManager.replaceLayer(t,s,r);a.setOptions(i.tilesetOptions??{}),i.cesiumStyle&&"setStyle"in a&&a.setStyle(i.cesiumStyle)}break;case"tile3d-style":"setStyle"in s&&s.setStyle((e.data??{}).style??{});break;case"terrain":{const i=s.getOptions(),r=s.getVisible(),a=s.getOpacity();s.remove();const n=await this.createTerrainLayer({type:"terrain",...i,...e.data??{}}),o=this.layerManager.addCustomLayer(t,n);o.setVisible(r),o.setOpacity(a)}break;case"terrain-geotiff":{s.remove();const i=await this.createGeoTIFFTerrainLayer({type:"terrain-geotiff",...e.data??{}});this.layerManager.addCustomLayer(t,i)}}i&&this.attachCesiumErrorListeners(t)}))}async setView(i,s){if(!this.viewer)return;const[r,a]=i;this.viewer.camera.flyTo({destination:this.Cesium.Cartesian3.fromDegrees(r,a,1e6/s),duration:2,orientation:{heading:this.Cesium.Math.toRadians(0),pitch:this.Cesium.Math.toRadians(-30),roll:0},complete:()=>e("v-map - provider - cesium - Fly‑to finished"),cancel:()=>t("v-map - provider - cesium - Fly‑to cancelled")})}async fetchWFSFromUrl(t){const e={service:"WFS",request:"GetFeature",version:t.version??"1.1.0",typeName:t.typeName,outputFormat:t.outputFormat??"application/json",srsName:t.srsName??"EPSG:4326",...t.params??{}},i=this.appendParams(t.url,e),s=await fetch(i);if(!s.ok)throw new Error(`WFS request failed (${s.status} ${s.statusText})`);const r=(t.outputFormat??"application/json").toLowerCase();if(r.includes("json")||r.includes("geojson")||"application/json"===r){const t=s.headers.get("content-type");if(t?.includes("application/json"))return await s.json();const e=await s.text();return JSON.parse(e)}if(r.includes("gml")||r.includes("xml")){const t=await s.text(),{GmlParser:e}=await import("./index.browser.js"),i=new e;return await i.parse(t)}return await s.json()}appendParams(t,e){const i=new URLSearchParams;return Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),i.toString()?`${t}${t.includes("?")?"&":"?"}${i.toString()}`:t}}export{b as CesiumProvider}
1
+ import{w as t,l as e,e as i}from"./logger.js";import{C as s}from"./v-map2.js";import{l as r,a,b as n,G as o,g as h}from"./geotiff-source.js";class c{id;_visible=!0;_basemap=null;_layers=new Map;_originalVisible=new Map;_dirty=!0;constructor(t,e=!0){this.id=t,this._visible=e}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._dirty=!0)}get basemap(){return this._basemap}set basemap(t){this._basemap!==t&&(this._basemap=t,this._dirty=!0)}isDirty(){return this._dirty}addLayer(t){this._layers.has(t.id)||(this._layers.set(t.id,t),this._originalVisible.set(t.id,t.layer.getVisible()),this._dirty=!0)}setLayerElementId(t,e){const i=this._layers.get(t);i&&i.elementId!==e&&(i.elementId=e??null,this._dirty=!0)}removeLayer(t){const e=this._layers.delete(t);return this._originalVisible.delete(t),e&&(this._dirty=!0),e}clear(){this._layers.clear(),this._originalVisible.clear(),this._dirty=!0}apply(){if(this._dirty){for(const[t,e]of this._layers){const i=this._originalVisible.get(t)??!0;let s=this._visible&&i;s&&this._basemap&&(s=e.elementId===this._basemap),e.layer.getVisible()!==s&&e.layer.setVisible(s)}this._dirty=!1}}}class l{_groups=[];_dirty=!0;get groups(){return[...this._groups]}getGroup(t){return this._groups.find((e=>e.id===t))}hasGroup(t){return this._groups.some((e=>e.id===t))}ensureGroup(t,e=!0){let i=this.getGroup(t);return i||(i=new c(t,e),this._groups.push(i),this._dirty=!0,i)}addLayerToGroup(t,e,i){this.ensureGroup(t,e).addLayer(i),this._dirty=!0}removeLayer(t,e=!0){let i=!1;for(const s of this._groups)if(s.removeLayer(t)&&(i=!0,!e))break;return i&&(this._dirty=!0),i}setGroupVisible(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.visible=e,this._dirty=!0}setBasemap(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.basemap=e,this._dirty=!0}apply(){if(this._dirty||this._groups.some((t=>t.isDirty()))){for(const t of this._groups)t.apply();this._dirty=!1}}clear(){this._groups=[],this._dirty=!0}}class u{Cesium;layers=new Map;viewer;constructor(t,e){this.viewer=e,this.Cesium=t}replaceLayer(t,e,i){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");const s=e.getZIndex(),r=e.getVisible(),a=e.getOpacity();this.removeLayer(t);const n=this.addLayer(t,i);return n.setZIndex(s),n.setVisible(r),n.setOpacity(a),n}addLayer(t,e){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");e instanceof this.Cesium.GeoJsonDataSource||e instanceof this.Cesium.DataSource?this.viewer.dataSources.add(e):e instanceof this.Cesium.Cesium3DTileset?(this.viewer.scene.primitives.add(e),e.style||(e.style=new this.Cesium.Cesium3DTileStyle)):e instanceof this.Cesium.ImageryLayer&&this.viewer.imageryLayers.add(e),e.id=t;const i=this.wrapLayer(e);return this.layers.set(t,i),i}addCustomLayer(t,e){return this.layers.set(t,e),e}getLayer(t){const e=this.layers.get(t);if(!e)throw new Error(`Layer mit ID "${t}" nicht gefunden.`);return e}getLayerById(t){return this.getLayer(t)}removeLayer(t){this.getLayer(t).remove(),this.layers.delete(t)}setVisible(t,e){this.getLayer(t).setVisible(e)}setOpacity(t,e){this.getLayer(t).setOpacity(e)}async setZIndex(t,e){const i=this.getLayer(t);await i.setZIndex(e)}wrapLayer(t){return t instanceof this.Cesium.ImageryLayer?this.wrapImageryLayer(t):t instanceof this.Cesium.Cesium3DTileset?this.wrapTilesetLayer(t):this.wrapDataSourceLayer(t)}async sortImageryLayers(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((e=>t.add(e)))}async sort3DTileSets(t,e,i){const s=this.sort(t,e,i);t.removeAll(),s.forEach((e=>t.add(e)))}async sortDataSources(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((async e=>await t.add(e)))}sort(t,e,i){t.remove(e,!1);const s=[];for(let e=0;e<t.length;e++)s.push(t.get(e));return s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),e.zIndex=i,s.push(e),s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),s}wrapImageryLayer(t){const e=this.viewer.imageryLayers;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>t.alpha,setOpacity:e=>{t.alpha=e},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortImageryLayers(e,t,i)},remove:()=>e.remove(t)}}wrapTilesetLayer(t){const e=this.viewer.scene.primitives;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>{const e=t.style;if(e.color&&"string"==typeof e.color){const t=e.color.match(/color\(.*?,([\d.]+)\)/);return t?parseFloat(t[1]):1}return 1},setOpacity:e=>{const i=t.style.color;let s;if("string"==typeof i){const t=i.replace(/color\((.*?),[\d.]+\)/,`color($1, ${e})`);s=t.includes("color")?t:`color('white', ${e})`}else s=`color('white', ${e})`;t.style=new this.Cesium.Cesium3DTileStyle({color:s,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},getZIndex:()=>{const e=this.viewer.scene.primitives;for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&this.sort3DTileSets(e,t,i)},setColor:(e,i=1)=>{const s=e instanceof this.Cesium.Color?e.toCssHexString():e.replace(/[#\s]/g,"");t.style=new this.Cesium.Cesium3DTileStyle({color:`color('${s}', ${i})`,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},setStyle:e=>{t.style=e instanceof this.Cesium.Cesium3DTileStyle?e:new this.Cesium.Cesium3DTileStyle(e)},remove:()=>this.viewer.scene.primitives.remove(t)}}wrapDataSourceLayer(t){const e=this.viewer.dataSources;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>1,setOpacity:e=>{t.__vmapLockOpacity||t.entities.values.forEach((t=>{const i=(t,i)=>{const{Color:s,JulianDate:r}=this.Cesium,a=t=>s.fromAlpha(t??i,e,new s);if(!t)return new this.Cesium.ConstantProperty(a(i));const n=t;if(n&&"function"==typeof n.getValue){const t=a(n.getValue(this.viewer?.clock?.currentTime??new r,new s));return"function"==typeof n.setValue?(n.setValue(t),n):new this.Cesium.ConstantProperty(t)}return new this.Cesium.ConstantProperty(a(t instanceof this.Cesium.Color?t:i))};if(t.polygon){const e=t.polygon.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.ImageMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}if(t.polyline){const e=t.polyline.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.PolylineOutlineMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}t.point&&(t.point.color=i(t.point.color,Cesium.Color.WHITE)),t.billboard&&(t.billboard.color=i(t.billboard.color,Cesium.Color.WHITE)),t.label&&(t.label.fillColor=i(t.label.fillColor,Cesium.Color.BLACK),t.label.outlineColor&&(t.label.outlineColor=i(t.label.outlineColor,Cesium.Color.BLACK))),t.model&&(t.model.color=i(t.model.color,Cesium.Color.WHITE))}))},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortDataSources(e,t,i)},remove:()=>e.remove(t)}}}class w{locked=!1;queue=[];async runExclusive(t){await this.acquire();try{return await t()}finally{this.release()}}acquire(){return this.locked?new Promise((t=>this.queue.push(t))):(this.locked=!0,Promise.resolve())}release(){const t=this.queue.shift();t?t():this.locked=!1}}function p(t,e){if(!t)throw new Error(e)}const m=new w;class d{tileWidth;tileHeight;tilingScheme;rectangle;errorEvent;credit=void 0;tileDiscardPolicy=void 0;proxy=void 0;hasAlphaChannel=!0;minimumLevel;maximumLevel;Cesium;tileProcessor;resolution;resampleMethod;colorStops;readyPromiseInternal;ready=!1;constructor(t){const{Cesium:e,rectangleDegrees:i,tileProcessor:s,tileSize:r,resolution:a,resampleMethod:n,colorStops:o,minimumLevel:h,maximumLevel:c}=t;this.Cesium=e,this.tileProcessor=s,this.tileWidth=r,this.tileHeight=r,this.resolution=a,this.resampleMethod=n,this.colorStops=o,this.minimumLevel=h??0,this.maximumLevel=c,this.rectangle=e.Rectangle.fromDegrees(i[0],i[1],i[2],i[3]),this.tilingScheme=new e.WebMercatorTilingScheme,this.errorEvent=new e.Event,this.ready=!0,this.readyPromiseInternal=Promise.resolve(!0)}get tilingSchemeName(){return this.tilingScheme instanceof this.Cesium.WebMercatorTilingScheme?"WebMercator":void 0}get readyPromise(){return this.readyPromiseInternal}get tileCredits(){}getTileCredits(t,e,i){}get url(){}flipCanvasVertically(e,i,s){const r=document.createElement("canvas");r.width=i,r.height=s;const a=r.getContext("2d");return a?(a.translate(0,s),a.scale(1,-1),a.drawImage(e,0,0),r):(t("v-map - cesium - failed to get 2d context for flip"),e)}async createFlippedImageBitmap(e,i){if("function"==typeof createImageBitmap)try{const t=document.createElement("canvas");t.width=i,t.height=i;const s=t.getContext("2d");if(!s)throw new Error("Failed to get 2d context");const r=s.createImageData(i,i);r.data.set(e),s.putImageData(r,0,0);const a=this.flipCanvasVertically(t,i,i);return await createImageBitmap(a)}catch(e){return void t("v-map - cesium - createImageBitmap failed, falling back",e)}}async createFlippedImageFromRGBA(e){const i=Math.ceil(this.tileWidth*this.resolution),s=await this.createFlippedImageBitmap(e,i);if(s)return s;const r=document.createElement("canvas");r.width=i,r.height=i;const a=r.getContext("2d");if(!a)return void t("v-map - cesium - unable to acquire canvas 2d context");const n=a.createImageData(i,i);return n.data.set(e),a.putImageData(n,0,0),this.flipCanvasVertically(r,i,i)}async requestImage(i,s,r){if(!this.ready)return;if(r<this.minimumLevel||void 0!==this.maximumLevel&&r>this.maximumLevel)return;const a={x:i,y:s,z:r,tileSize:this.tileWidth,resolution:this.resolution,resampleMethod:this.resampleMethod,colorStops:this.colorStops};let n=null;try{if(n=await this.tileProcessor.getTileData(a),!n)return void e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): no data returned`);e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): rgba ${n.length} bytes, sampleSize=${Math.ceil(this.tileWidth*this.resolution)}`)}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - getTileData - GeoTIFF tile request failed",e)}try{const t=await this.createFlippedImageFromRGBA(n);return e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): result=${t?.constructor?.name??"undefined"}, size=${t instanceof HTMLCanvasElement||t instanceof ImageBitmap?`${t.width}x${t.height}`:"n/a"}`),t}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - createFlippedImageFromRGBA - GeoTIFF tile request failed",e)}}pickFeatures(){}}const y="v-map - cesium - terrain-geotiff - ";class f{Cesium;image;fromProjection="EPSG:4326";sourceBounds=[0,0,0,0];wgs84Bounds=[0,0,0,0];width=0;height=0;noDataValue=0;ready=!1;_readyPromise;heightmapWidth=65;heightmapHeight=65;proj4;tilingScheme;constructor(t){this.Cesium=t.Cesium,this.tilingScheme=new this.Cesium.GeographicTilingScheme,this._readyPromise=this.initialize(t)}async initialize(t){try{e(`${y}loadGeoTIFF: url=${t.url}`);const[i,{default:s},a]=await Promise.all([import("./geotiff.js").then((function(t){return t.g})),import("./index4.js"),import("./main-dist.js").then((function(t){return t.m}))]),n=await r(t.url,{projection:t.projection,forceProjection:t.forceProjection??!1,nodata:t.nodata},{geotiff:i,proj4:s,geokeysToProj4:a});return this.image=n.baseImage,this.fromProjection=n.fromProjection,this.sourceBounds=n.sourceBounds,this.wgs84Bounds=n.wgs84Bounds,this.width=n.width,this.height=n.height,this.noDataValue=n.noDataValue??0,this.proj4=n.proj4,e(`${y}loaded: projection=${this.fromProjection}, bounds=[${this.sourceBounds.map((t=>t.toFixed(0))).join(",")}], wgs84=[${this.wgs84Bounds.map((t=>t.toFixed(4))).join(",")}], size=${this.width}x${this.height}`),this.ready=!0,!0}catch(t){return i(`${y}failed to load GeoTIFF:`,t),this.ready=!1,!1}}get rectangle(){if(!this.ready||!this.wgs84Bounds)return this.Cesium.Rectangle.MAX_VALUE;const[t,e,i,s]=this.wgs84Bounds;return this.Cesium.Rectangle.fromDegrees(t,e,i,s)}async requestTileGeometry(e,i,s){if(this.ready&&this.image)try{const r=this.tilingScheme.tileXYToRectangle(e,i,s);let a=this.Cesium.Math.toDegrees(r.west),n=this.Cesium.Math.toDegrees(r.south),o=this.Cesium.Math.toDegrees(r.east),h=this.Cesium.Math.toDegrees(r.north);const[c,l,u,w]=this.wgs84Bounds;if(o<c||a>u||h<l||n>w)return this.createFlatHeightmap();a=Math.max(c,Math.min(u,a)),o=Math.max(c,Math.min(u,o)),n=Math.max(l,Math.min(w,n)),h=Math.max(l,Math.min(w,h));const p=e=>{try{return this.proj4("EPSG:4326",this.fromProjection,e)}catch(i){return t(`${y}transform failed:`,i),e}},m=p([a,n]),d=p([o,h]),[f,g,v,b]=this.sourceBounds,S=this.width,C=this.height,$=v-f,L=b-g,G=Math.floor((m[0]-f)/$*S),k=Math.floor((b-d[1])/L*C),M=Math.ceil((d[0]-f)/$*S),x=Math.ceil((b-m[1])/L*C),F=Math.max(0,Math.min(G,S)),E=Math.max(0,Math.min(k,C)),I=Math.max(1,Math.min(M-G,S-F)),T=Math.max(1,Math.min(x-k,C-E)),O=(await this.image.readRasters({window:[F,E,F+I,E+T],width:this.heightmapWidth,height:this.heightmapHeight,resampleMethod:"bilinear"}))[0],A=new Float32Array(this.heightmapWidth*this.heightmapHeight);for(let t=0;t<A.length;t++){let e=O[t];e!==this.noDataValue&&isFinite(e)||(e=0),A[t]=e}return new this.Cesium.HeightmapTerrainData({buffer:A,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0,structure:{heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:1}})}catch(e){return t(`${y}failed to load tile geometry:`,e),this.createFlatHeightmap()}}createFlatHeightmap(){const t=new Float32Array(this.heightmapWidth*this.heightmapHeight);return t.fill(0),new this.Cesium.HeightmapTerrainData({buffer:t,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0})}get availability(){}getTilingScheme(){return this.tilingScheme}getLevelMaximumGeometricError(t){return this.tilingScheme.ellipsoid.maximumRadius/(65*Math.pow(2,t))}loadTileDataAvailability(t,e,i){}getTileDataAvailable(t,e,i){if(!this.ready)return!1;const s=this.tilingScheme.tileXYToRectangle(t,e,i),r=this.Cesium.Math.toDegrees(s.west),a=this.Cesium.Math.toDegrees(s.south),n=this.Cesium.Math.toDegrees(s.east),o=this.Cesium.Math.toDegrees(s.north),[h,c,l,u]=this.wgs84Bounds;return!(n<h||r>l||o<c||a>u)}get readyPromise(){return this._readyPromise}get credit(){return new this.Cesium.Credit("GeoTIFF Terrain")}get hasWaterMask(){return!1}get hasVertexNormals(){return!1}get errorEvent(){return new this.Cesium.Event}}const g="v-map - cesium - terrain-geotiff - ";class v{Cesium;viewer;provider;options;opacity=1;previousProvider;constructor(t,e,i,s){this.Cesium=t,this.viewer=e,this.provider=i,this.options=s??{},this.previousProvider=e.terrainProvider,this.viewer.terrainProvider=this.provider}getOptions(){return this.options}setOptions(t){this.options=t}getVisible(){return this.viewer.scene.globe.show}setVisible(t){this.viewer.scene.globe.show=t}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e;const i=this.viewer.scene.globe;if(!i.translucency)try{i.translucency=new this.Cesium.GlobeTranslucency,i.translucency.enabled=!0}catch(e){return void t("Cesium terrain opacity not supported",e)}i.translucency.enabled=e<1,i.translucency.frontFaceAlpha=e}getZIndex(){return 0}async setZIndex(t){}remove(){try{this.viewer.terrainProvider=this.previousProvider?this.previousProvider:new this.Cesium.EllipsoidTerrainProvider,this.viewer.scene.globe.show=!0}catch(e){t("Cesium terrain reset failed",e)}}}class b{viewer;Cesium;layerManager;shadowRoot;layerGroups=new l;layerManagerMutex=new w;layerErrorCallbacks=new Map;layerErrorCleanups=new Map;async init(t){this.shadowRoot=t.shadowRoot;const e=t.target.getRootNode()instanceof ShadowRoot?t.target.getRootNode():void 0;await async function(t){const e=`https://cdn.jsdelivr.net/npm/cesium@${s.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Widgets/widgets.css`,r=(await(await fetch(i)).text()).replace(/url\((?!['"]?data:)(['"]?)([^'")]+)\1\)/g,((t,i,s)=>`url(${e}/Widgets/${s.replace(/^\.?\//,"")})`));if(t)if("adoptedStyleSheets"in Document.prototype){const e=new CSSStyleSheet;await e.replace(r),t.adoptedStyleSheets=[...t.adoptedStyleSheets??[],e]}else{const e=document.createElement("style");e.textContent=r,t.appendChild(e)}}(e),this.Cesium=await async function(t=s){const e=`https://cdn.jsdelivr.net/npm/cesium@${t.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Cesium.js`;await m.runExclusive((async()=>{globalThis.Cesium||await new Promise(((t,e)=>{const s="cesium-cdn-script";if(document.getElementById(s))return t();const r=document.createElement("script");r.id=s,r.async=!0,r.src=i,r.addEventListener("load",(()=>t()),{once:!0}),r.addEventListener("error",(()=>e(new Error(`Laden fehlgeschlagen: ${i}`))),{once:!0}),document.head.appendChild(r)}))}));const r=globalThis.Cesium;p(r,"globalThis.Cesium nicht verfügbar.");const a=r.VERSION;var n,o;return p((n=String(t),o=a,n.match(/^\d+\.\d+/)?.[0]===o.match(/^\d+\.\d+/)?.[0]),`Cesium-Version abweichend: erwartet ~${t}, geladen ${a}`),globalThis.CESIUM_BASE_URL=e,r}(),Cesium.Ion.defaultAccessToken=null,this.viewer=new this.Cesium.Viewer(t.target,{baseLayer:!1,baseLayerPicker:!1,terrainProvider:new Cesium.EllipsoidTerrainProvider}),this.viewer.scene.primitives.removeAll(),this.viewer.scene.backgroundColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.baseColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.depthTestAgainstTerrain=!1,this.layerManager=new u(this.Cesium,this.viewer)}async destroy(){!function(t){if(!t)return;const i=Array.from(t.querySelectorAll("style"));for(const t of i)if(t.textContent?.includes(".cesium-credit-lightbox-overlay")){t.remove(),e("v-map - provider - cesium - Cesium‑Widget‑CSS entfernt");break}}(this.shadowRoot),this.viewer?.destroy(),this.viewer=void 0}async createLayer(t,e){let i=null;switch(t.type){case"geojson":{const s={},r=t,a=await this.createGeoJSONLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"osm":{const s=await this.createOSMLayer(t);i=this.layerManager.addLayer(e,s);break}case"google":{const s=await this.createGoogleLayer(t);i=this.layerManager.addLayer(e,s);break}case"terrain":{const s=await this.createTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}case"xyz":{const s=await this.createXYZLayer(t);i=this.layerManager.addLayer(e,s);break}case"wms":{const s=await this.addWMSLayer(t);i=this.layerManager.addLayer(e,s);break}case"wcs":{const s=await this.createWCSLayer(t);i=this.layerManager.addLayer(e,s);break}case"arcgis":await this.addArcGISLayer(t);break;case"wfs":{const s={clampToGround:!0},r=t,a=await this.createWFSLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"wkt":{const s={clampToGround:!0},r=t,a=await this.createWKTLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"geotiff":{const s=await this.createGeoTIFFLayer(t);i=this.layerManager.addLayer(e,s);break}case"tile3d":{const s=await this.createTile3DLayer(t);i=this.layerManager.addLayer(e,s);const r=t;i.setOptions(r.tilesetOptions??{}),r.cesiumStyle&&"setStyle"in i&&i.setStyle(r.cesiumStyle);break}case"terrain-geotiff":{const s=await this.createGeoTIFFTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}default:throw new Error(`Unsupported layer type: ${t.type}`)}if(!i)return null;const s=t;return void 0!==s.zIndex&&await i.setZIndex(s.zIndex),void 0!==s.opacity&&i.setOpacity(s.opacity),void 0!==s.visible&&i.setVisible(s.visible),i}async addLayerToGroup(t){return await this.layerManagerMutex.runExclusive((async()=>{const e=crypto.randomUUID(),i=await this.createLayer(t,e);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:e,elementId:t.layerElementId??t.elementId??null,layer:i}),this.layerGroups.apply(),e}))}async setBaseLayer(t,e){await this.layerManagerMutex.runExclusive((async()=>{this.layerGroups.setBasemap(t,e??null),this.layerGroups.apply()}))}async addBaseLayer(t,e,i){return i&&e?await this.layerManagerMutex.runExclusive((async()=>{const s=crypto.randomUUID(),r=await this.createLayer(t,s);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:s,elementId:i,layer:r}),this.layerGroups.setBasemap(t.groupId??"basemap",e),this.layerGroups.apply(),s})):null}async ensureGroup(t,e,i){this.layerGroups.ensureGroup(t,e)}async setGroupVisible(t,e){this.layerGroups.setGroupVisible(t,e),this.layerGroups.apply()}onLayerError(t,e){this.layerErrorCallbacks.set(t,e),this.attachCesiumErrorListeners(t)}offLayerError(t){this.layerErrorCleanups.get(t)?.(),this.layerErrorCleanups.delete(t),this.layerErrorCallbacks.delete(t)}attachCesiumErrorListeners(t){this.layerErrorCleanups.get(t)?.();const e=this.layerErrorCallbacks.get(t);if(!e)return;const i=this.layerManager.getLayer(t);if(!i)return;const s=[],r=()=>{e({type:"network",message:"Tile load error"})},a=i._imageryLayer;if(a?.imageryProvider?.errorEvent){const t=a.imageryProvider.errorEvent.addEventListener(r);s.push(t)}const n=i._tileset;if(n?.tileFailed){const t=n.tileFailed.addEventListener(r);s.push(t)}s.length>0&&this.layerErrorCleanups.set(t,(()=>s.forEach((t=>t()))))}async removeLayer(t){t&&(this.offLayerError(t),await this.layerManagerMutex.runExclusive((async()=>{this.layerManager.removeLayer(t),this.layerGroups.removeLayer(t,!0),this.layerGroups.apply()})))}async setOpacity(t,e){this.layerManager.setOpacity(t,e),this.layerGroups.apply()}async setVisible(t,e){this.layerManager.setVisible(t,e),this.layerGroups.apply()}async setZIndex(t,e){await this.layerManager.setZIndex(t,e),this.layerGroups.apply()}applyGeostylerStyling(t,i){t.__vmapLockOpacity=!0;const s=(t,e)=>null==t||"object"==typeof t&&null!==t&&"name"in t?e:t,r=(t,e)=>{if(null==t)return e;if("number"==typeof t)return t;const i=Number(t);return Number.isFinite(i)?i:e},a=t.entities.values;if(i.rules)for(const t of i.rules)if(t.symbolizers)for(const i of t.symbolizers)for(let t=0;t<a.length;t++){const n=a[t];switch(i.kind){case"Fill":if(n.polygon){const t=s(i.color,"rgba(0,100,255,0.3)"),a=r(s(i.opacity,.3),.3),o=s(i.outlineColor,"rgba(0,100,255,1)"),h=s(i.outlineWidth,1);let c=this.parseCesiumColor(t,this.Cesium.Color.BLUE.withAlpha(.3));null!=a&&(c=this.applyCesiumOpacity(c,a));const l=this.parseCesiumColor(o,this.Cesium.Color.BLUE);e("v-map - provider - cesium - applyGeostylerStyling: Fill",{fillColor:t,fillOpacity:a,computedFill:c?.toString?.(),outlineColor:o,outlineWidth:h}),n.polygon.fill=new this.Cesium.ConstantProperty(!0),n.polygon.material=new this.Cesium.ColorMaterialProperty(c),n.polygon.outline=new this.Cesium.ConstantProperty(!0),n.polygon.outlineColor=new this.Cesium.ConstantProperty(l),n.polygon.outlineWidth=new this.Cesium.ConstantProperty(h),n.polygon.extrudedHeight=void 0,n.polygon.heightReference=new this.Cesium.ConstantProperty(this.Cesium.HeightReference.CLAMP_TO_GROUND),n.polygon.perPositionHeight=new this.Cesium.ConstantProperty(!1),n.polygon.classificationType=new this.Cesium.ConstantProperty(this.Cesium.ClassificationType.BOTH)}break;case"Line":if(n.polyline){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.width,2),2),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Line",{lineColor:t,lineOpacity:o,computedColor:h?.toString?.(),lineWidth:a}),n.polyline.material=new this.Cesium.ColorMaterialProperty(h),n.polyline.width=new this.Cesium.ConstantProperty(a)}break;case"Mark":if(n.point){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.radius,6),6),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Mark",{pointColor:t,pointOpacity:o,computedColor:h?.toString?.(),pointRadius:a}),n.point.color=new this.Cesium.ConstantProperty(h),n.point.pixelSize=new this.Cesium.ConstantProperty(a)}break;case"Icon":if(n.point){const t=s(i.image),a=r(s(i.size,32),32),o=r(s(i.opacity,1),1);t&&"string"==typeof t&&(n.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(t),width:new this.Cesium.ConstantProperty(a),height:new this.Cesium.ConstantProperty(a),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),color:null!=o?new this.Cesium.ConstantProperty(this.Cesium.Color.WHITE.withAlpha(o)):void 0}),n.point.show=new this.Cesium.ConstantProperty(!1),e("v-map - provider - cesium - applyGeostylerStyling: Icon",{iconSrc:t,iconSize:a,iconOpacity:o}))}break;case"Text":const t=i.label,a="string"==typeof t?t:void 0;if(a&&n.properties&&n.properties[a]){const t=s(i.color,"#000000"),o=r(s(i.size,12),12),h=r(s(i.opacity,1),1);let c=this.parseCesiumColor(t,this.Cesium.Color.WHITE);null!=h&&(c=this.applyCesiumOpacity(c,h)),e("v-map - provider - cesium - applyGeostylerStyling: Text",{labelProp:a,textColor:t,textOpacity:h,computedColor:c?.toString?.(),textSize:o});const l=n.properties[a]?.getValue?.(this.viewer.clock.currentTime)??n.properties[a]?._value??"";n.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(l)),font:new this.Cesium.ConstantProperty(`${o}px Arial`),fillColor:new this.Cesium.ConstantProperty(c),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}}parseCesiumColor(t,e){if(!t)return e;if(t.startsWith("#"))return this.Cesium.Color.fromCssColorString(t);if(t.includes("rgb"))return this.Cesium.Color.fromCssColorString(t);try{return this.Cesium.Color.fromCssColorString(t)}catch{return e}}applyCesiumOpacity(t,e){return t?t.withAlpha(e):t}createCesiumStyle(t={}){const e=this.Cesium.Color.BLUE.withAlpha(.3),i=this.Cesium.Color.BLUE,s=this.Cesium.Color.BLUE,r=this.parseCesiumColor(t.fillColor,e),a=this.parseCesiumColor(t.strokeColor,i),n=this.parseCesiumColor(t.pointColor,s),o=void 0!==t.fillOpacity?this.applyCesiumOpacity(r,t.fillOpacity):r,h=void 0!==t.strokeOpacity?this.applyCesiumOpacity(a,t.strokeOpacity):a,c=void 0!==t.pointOpacity?this.applyCesiumOpacity(n,t.pointOpacity):n;return{fill:!0,fillColor:o,outline:!0,outlineColor:h,outlineWidth:t.strokeWidth??2,extrudedHeight:t.extrudeHeight,heightReference:t.zOffset?this.Cesium.HeightReference.RELATIVE_TO_GROUND:this.Cesium.HeightReference.CLAMP_TO_GROUND,pixelSize:t.pointRadius??8,color:c,scaleByDistance:t.pointRadius?new this.Cesium.NearFarScalar(150,2,15e6,.5):void 0,width:t.strokeWidth??2,clampToGround:!t.zOffset,labelText:t.textProperty,labelFont:t.textSize?`${t.textSize}pt monospace`:"12pt monospace",labelFillColor:t.textColor?this.parseCesiumColor(t.textColor,this.Cesium.Color.WHITE):this.Cesium.Color.WHITE,labelOutlineColor:t.textHaloColor?this.parseCesiumColor(t.textHaloColor,this.Cesium.Color.BLACK):this.Cesium.Color.BLACK,labelOutlineWidth:t.textHaloWidth??1,labelPixelOffset:t.textOffset?new this.Cesium.Cartesian2(t.textOffset[0],t.textOffset[1]):this.Cesium.Cartesian2.ZERO,height:t.zOffset??0}}applyEnhancedStyling(t,e={}){const i=this.createCesiumStyle(e),s=t.entities.values;for(let t=0;t<s.length;t++){const r=s[t];let a=i;if(e.styleFunction&&r.properties){const t={properties:r.properties._propertyNames.reduce(((t,e)=>(t[e]=r.properties[e]?._value,t)),{}),geometry:r},s=e.styleFunction(t);s&&(a={...i,...this.createCesiumStyle(s)})}if(r.polygon&&(r.polygon.fill=new this.Cesium.ConstantProperty(a.fill),r.polygon.material=new this.Cesium.ColorMaterialProperty(a.fillColor),r.polygon.outline=new this.Cesium.ConstantProperty(a.outline),r.polygon.outlineColor=new this.Cesium.ConstantProperty(a.outlineColor),r.polygon.outlineWidth=new this.Cesium.ConstantProperty(a.outlineWidth),r.polygon.height=void 0!==a.height?new this.Cesium.ConstantProperty(a.height):void 0,r.polygon.extrudedHeight=void 0!==a.extrudedHeight?new this.Cesium.ConstantProperty(a.extrudedHeight):void 0,r.polygon.heightReference=void 0!==a.heightReference?new this.Cesium.ConstantProperty(a.heightReference):void 0),r.polyline&&(r.polyline.material=new this.Cesium.ColorMaterialProperty(a.outlineColor),r.polyline.width=new this.Cesium.ConstantProperty(a.width),r.polyline.clampToGround=new this.Cesium.ConstantProperty(a.clampToGround)),r.point){r.point.pixelSize=new this.Cesium.ConstantProperty(a.pixelSize),r.point.color=new this.Cesium.ConstantProperty(a.color);const t=a.scaleByDistance;r.point.scaleByDistance=t?new this.Cesium.ConstantProperty(t):void 0,e.iconUrl&&(r.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(e.iconUrl),width:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[0]:32),height:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[1]:32),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),scaleByDistance:t?new this.Cesium.ConstantProperty(t):void 0}),r.point.show=new this.Cesium.ConstantProperty(!1))}if(e.textProperty&&r.properties&&r.properties[e.textProperty]){const t=r.properties[e.textProperty]?.getValue?.(this.viewer.clock.currentTime)??r.properties[e.textProperty]?._value??"";r.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(t)),font:new this.Cesium.ConstantProperty(a.labelFont),fillColor:new this.Cesium.ConstantProperty(a.labelFillColor),outlineColor:new this.Cesium.ConstantProperty(a.labelOutlineColor),outlineWidth:new this.Cesium.ConstantProperty(a.labelOutlineWidth),pixelOffset:new this.Cesium.ConstantProperty(a.labelPixelOffset),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}async createWKTLayer(t,e){const i=await this.wktToGeoJSON(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async wktToGeoJSON(t){const e=await this.resolveWktText(t),i=await import("./index5.js").then((function(t){return t.i})),s="function"==typeof i.default?i.default:i.parse;if("function"!=typeof s)throw new Error("wellknown parser not available");const r=s(e);if(!r)throw new Error("Failed to parse WKT");return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:r}]}}async resolveWktText(t){if(t.wkt)return t.wkt;if(t.url){const e=await fetch(t.url);if(!e.ok)throw new Error(`Failed to fetch WKT: ${e.status}`);return await e.text()}throw new Error("Either wkt or url must be provided")}async createGeoJSONLayer(t,e){let i=null;i=t.geojson?JSON.parse(t.geojson):t.url;const s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createWFSLayer(t,e){const i=await this.fetchWFSFromUrl(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createOSMLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:t.url||"https://a.tile.openstreetmap.org"}))}async createGoogleLayer(t){if(!t.apiKey)throw new Error("Google-Layer benötigt 'apiKey' (Google Maps Platform).");await this.loadGoogleMapsApi(t.apiKey,{language:t.language,region:t.region,libraries:t.libraries});const e=this.getGoogleMapTypeId(t.mapType||"roadmap"),i=this.Cesium,s=new i.UrlTemplateImageryProvider({url:"https://maps.googleapis.com/maps/api/staticmap?template",maximumLevel:t.maxZoom||19,minimumLevel:0,tilingScheme:new i.WebMercatorTilingScheme,credit:"Google Maps",urlSchemeZeroPadding:{"{x}":"","{y}":"","{z}":""}});return s.buildImageResource=function(s,r,a){const n=(new i.WebMercatorTilingScheme).tileXYToRectangle(s,r,a),o=i.Math.toDegrees(n.west),h=i.Math.toDegrees(n.south),c=i.Math.toDegrees(n.east),l=i.Math.toDegrees(n.north),u=new URLSearchParams({center:`${(h+l)/2},${(o+c)/2}`,zoom:a.toString(),size:"256x256",scale:"scaleFactor1x"===t.scale?"1":"2",maptype:e,key:t.apiKey,format:"png"});t.language&&u.set("language",t.language),t.region&&u.set("region",t.region);const w=`https://maps.googleapis.com/maps/api/staticmap?${u.toString()}`;return new i.Resource({url:w})},this.ensureGoogleLogo(),new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}getGoogleMapTypeId(t){switch(t){case"roadmap":default:return"roadmap";case"satellite":return"satellite";case"terrain":return"terrain";case"hybrid":return"hybrid"}}async loadGoogleMapsApi(t,e){const i=window,s=i.__mockGoogleMapsApi;"function"!=typeof s?i.google?.maps||await new Promise(((s,r)=>{const a="___cesiumGoogleInit___"+Math.random().toString(36).slice(2);i[a]=()=>s();const n=document.createElement("script"),o=new URLSearchParams({key:t,callback:a,v:"weekly"});e?.language&&o.set("language",e.language),e?.region&&o.set("region",e.region),e?.libraries?.length&&o.set("libraries",e.libraries.join(",")),n.src=`https://maps.googleapis.com/maps/api/js?${o.toString()}`,n.async=!0,n.onerror=()=>r(new Error("Google Maps JS API failed to load")),document.head.appendChild(n)})):await s(t,e)}ensureGoogleLogo(){if(!this.viewer?.container||this.viewer.container._googleLogoAdded)return;const t=document.createElement("img");t.src="https://developers.google.com/static/maps/documentation/images/google_on_white.png",t.alt="Google",t.style.position="absolute",t.style.bottom="6px",t.style.left="6px",t.style.height="18px",t.style.pointerEvents="none",t.style.zIndex="1000",this.viewer.container.appendChild(t),this.viewer.container._googleLogoAdded=!0}async createXYZLayer(t){if(!t.url)throw new Error("XYZ layer requires a url");const e=Array.isArray(t.attributions)?t.attributions.join(", "):t.attributions,i={url:t.url,credit:e,maximumLevel:t.maxZoom,...t.options||{}},s=new this.Cesium.UrlTemplateImageryProvider(i);return new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}async createTerrainLayer(t){let e;e=t.elevationData?await this.Cesium.CesiumTerrainProvider.fromUrl(t.elevationData):await this.Cesium.createWorldTerrainAsync();const i=new v(this.Cesium,this.viewer,e,t);return void 0!==t.visible&&i.setVisible(t.visible),void 0!==t.opacity&&i.setOpacity(t.opacity),i}async createGeoTIFFTerrainLayer(t){if(!t.url){e(`${g}layer created without URL, waiting for URL to load`);const i=new this.Cesium.EllipsoidTerrainProvider,s=new v(this.Cesium,this.viewer,i,t);return s.setVisible(!1),s}try{e(`${g}create layer: url=${t.url}`);const i=await async function(t){const e=new f(t);return await e.readyPromise,e}({url:t.url,projection:t.projection,forceProjection:t.forceProjection,nodata:t.nodata,Cesium:this.Cesium}),s=new v(this.Cesium,this.viewer,i,t);return void 0!==t.visible&&s.setVisible(t.visible),void 0!==t.opacity&&s.setOpacity(t.opacity),e(`${g}layer created successfully`),s}catch(e){i(`${g}failed to create terrain layer:`,e);const s=new this.Cesium.EllipsoidTerrainProvider;return new v(this.Cesium,this.viewer,s,t)}}async addWMSLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.WebMapServiceImageryProvider({url:t.url,layers:t.layers,parameters:t.extraParams}))}async createWCSLayer(t){if(!t.url||!t.coverageName)throw new Error("WCS layer requires url and coverageName");const e=t.version??"2.0.1",i=t.format??"image/tiff",s=t.projection??"EPSG:4326",r=t.tileSize??256,a=this.Cesium,n=new a.UrlTemplateImageryProvider({url:`${t.url}?wcs_placeholder`,maximumLevel:t.maxZoom??18,minimumLevel:t.minZoom??0,tileWidth:r,tileHeight:r,tilingScheme:new a.GeographicTilingScheme,credit:"WCS"});return n.buildImageResource=function(n,o,h){const c=(new a.GeographicTilingScheme).tileXYToRectangle(n,o,h),l=a.Math.toDegrees(c.west),u=a.Math.toDegrees(c.south),w=a.Math.toDegrees(c.east),p=a.Math.toDegrees(c.north),m={SERVICE:"WCS",REQUEST:"GetCoverage",VERSION:e,FORMAT:i};let d;if(e.startsWith("2.0")){const e={...m,coverageId:t.coverageName,...t.params||{}};(i.includes("tiff")||i.includes("geotiff"))&&(e["geotiff:compression"]="LZW");const s=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&s.set(t,String(e))}));const r=s.toString(),a=`subset=X(${l},${w})`,n=`subset=Y(${u},${p})`;d=`${t.url}${t.url.includes("?")?"&":"?"}${r}&${a}&${n}`}else{const e={...m,COVERAGE:t.coverageName,BBOX:`${l},${u},${w},${p}`,CRS:s,WIDTH:String(r),HEIGHT:String(r),...t.params||{}},i=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),d=`${t.url}${t.url.includes("?")?"&":"?"}${i.toString()}`}return new a.Resource({url:d})},new this.Cesium.ImageryLayer(n,{alpha:t.opacity??1,show:t.visible??!0})}async addArcGISLayer(t){const e=await this.Cesium.ArcGisMapServerImageryProvider.fromUrl(t.url);this.viewer.imageryLayers.addImageryProvider(e)}async createGeoTIFFLayer(t){if(!t.url)throw new Error("GeoTIFF layer requires a URL");try{const e=t,i=await a(t.url,e.projection,e.forceProjection,t.nodata),s=await n(i,"EPSG:3857"),r=new o(s);let c;if(r.createGlobalTriangulation(),t.colorMap){const{stops:e}=h(t.colorMap,t.valueRange);c=e}const l=new d({Cesium:this.Cesium,rectangleDegrees:i.wgs84Bounds,tileProcessor:r,tileSize:t.tileSize??256,resolution:t.resolution??1,resampleMethod:t.resampleMethod??"bilinear",colorStops:c}),u=new this.Cesium.ImageryLayer(l,{alpha:t.opacity??1,show:t.visible??!0});return u.__vmapGeoTIFFMeta={url:t.url,width:i.width,height:i.height,samplesPerPixel:i.samplesPerPixel,noData:i.noDataValue},u}catch(t){i("v-map - provider - cesium - Failed to create GeoTIFF layer",t);const e=new this.Cesium.SingleTileImageryProvider({url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",rectangle:this.Cesium.Rectangle.fromDegrees(-180,-90,180,90)});return new this.Cesium.ImageryLayer(e,{alpha:0,show:!1})}}async createTile3DLayer(t){if(!t.url)throw new Error("Tile3D layer requires a URL");const e=await this.Cesium.Cesium3DTileset.fromUrl(t.url,t.tilesetOptions??{});return t.cesiumStyle&&(e.style=new this.Cesium.Cesium3DTileStyle(t.cesiumStyle)),e}async updateLayer(t,e){return await this.layerManagerMutex.runExclusive((async()=>{const i=this.layerErrorCallbacks.has(t);i&&this.offLayerError(t);const s=this.layerManager.getLayer(t);switch(e.type){case"geojson":{const i=e.data,r=s.getOptions(),a=await this.createGeoJSONLayer({geojson:i.geojson,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"wfs":{const i=e.data,r=s.getOptions(),a=await this.createWFSLayer(i,r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"osm":{const i=s.getOptions(),r=new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:e.data.url||"https://a.tile.openstreetmap.org"}));this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"google":{const i=s.getOptions(),r=await this.createGoogleLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"xyz":{const i=s.getOptions(),r=await this.createXYZLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wcs":{const i=s.getOptions(),r=await this.createWCSLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wkt":{const i=e.data,r=s.getOptions(),a=await this.createWKTLayer({wkt:i.wkt,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"geotiff":{const i=e.data,r=await this.createGeoTIFFLayer({url:i.url});this.layerManager.replaceLayer(t,s,r)}break;case"tile3d":{const i=e.data??{};if(!i.url)throw new Error("tile3d update requires a url");const r=await this.createTile3DLayer({type:"tile3d",url:i.url,tilesetOptions:i.tilesetOptions,cesiumStyle:i.cesiumStyle}),a=this.layerManager.replaceLayer(t,s,r);a.setOptions(i.tilesetOptions??{}),i.cesiumStyle&&"setStyle"in a&&a.setStyle(i.cesiumStyle)}break;case"tile3d-style":"setStyle"in s&&s.setStyle((e.data??{}).style??{});break;case"terrain":{const i=s.getOptions(),r=s.getVisible(),a=s.getOpacity();s.remove();const n=await this.createTerrainLayer({type:"terrain",...i,...e.data??{}}),o=this.layerManager.addCustomLayer(t,n);o.setVisible(r),o.setOpacity(a)}break;case"terrain-geotiff":{s.remove();const i=await this.createGeoTIFFTerrainLayer({type:"terrain-geotiff",...e.data??{}});this.layerManager.addCustomLayer(t,i)}}i&&this.attachCesiumErrorListeners(t)}))}async setView(i,s){if(!this.viewer)return;const[r,a]=i;this.viewer.camera.flyTo({destination:this.Cesium.Cartesian3.fromDegrees(r,a,1e6/s),duration:2,orientation:{heading:this.Cesium.Math.toRadians(0),pitch:this.Cesium.Math.toRadians(-30),roll:0},complete:()=>e("v-map - provider - cesium - Fly‑to finished"),cancel:()=>t("v-map - provider - cesium - Fly‑to cancelled")})}async fetchWFSFromUrl(t){const e={service:"WFS",request:"GetFeature",version:t.version??"1.1.0",typeName:t.typeName,outputFormat:t.outputFormat??"application/json",srsName:t.srsName??"EPSG:4326",...t.params??{}},i=this.appendParams(t.url,e),s=await fetch(i);if(!s.ok)throw new Error(`WFS request failed (${s.status} ${s.statusText})`);const r=(t.outputFormat??"application/json").toLowerCase();if(r.includes("json")||r.includes("geojson")||"application/json"===r){const t=s.headers.get("content-type");if(t?.includes("application/json"))return await s.json();const e=await s.text();return JSON.parse(e)}if(r.includes("gml")||r.includes("xml")){const t=await s.text(),{GmlParser:e}=await import("./index.browser.js"),i=new e;return await i.parse(t)}return await s.json()}appendParams(t,e){const i=new URLSearchParams;return Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),i.toString()?`${t}${t.includes("?")?"&":"?"}${i.toString()}`:t}}export{b as CesiumProvider}