@npm9912/v-map 0.1.0 → 0.2.0

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 (127) hide show
  1. package/README.md +192 -96
  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-layer-geojson/v-map-layer-geojson.js +1 -1
  32. package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.js +1 -1
  33. package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.js +1 -1
  34. package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.js +1 -1
  35. package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.js +1 -1
  36. package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.js +1 -1
  37. package/dist/collection/components/v-map-layergroup/v-map-layergroup.js +1 -1
  38. package/dist/collection/components/v-map-style/v-map-style.js +1 -1
  39. package/dist/components/cesium-provider.js +1 -1
  40. package/dist/components/deck-provider.js +1 -1
  41. package/dist/components/events.js +1 -1
  42. package/dist/components/geotiff-source.js +1 -1
  43. package/dist/components/leaflet-provider.js +1 -1
  44. package/dist/components/logger.js +1 -0
  45. package/dist/components/openlayers-provider.js +1 -1
  46. package/dist/components/v-map-builder.js +2 -2
  47. package/dist/components/v-map-error.d.ts +11 -0
  48. package/dist/components/v-map-error.js +1 -0
  49. package/dist/components/v-map-layer-geojson2.js +1 -1
  50. package/dist/components/v-map-layer-geotiff2.js +1 -1
  51. package/dist/components/v-map-layer-google2.js +1 -1
  52. package/dist/components/v-map-layer-helper.js +1 -1
  53. package/dist/components/v-map-layer-osm2.js +1 -1
  54. package/dist/components/v-map-layer-scatterplot2.js +1 -1
  55. package/dist/components/v-map-layer-terrain-geotiff.js +1 -1
  56. package/dist/components/v-map-layer-terrain2.js +1 -1
  57. package/dist/components/v-map-layer-tile3d2.js +1 -1
  58. package/dist/components/v-map-layer-wcs2.js +1 -1
  59. package/dist/components/v-map-layer-wfs2.js +1 -1
  60. package/dist/components/v-map-layer-wkt2.js +1 -1
  61. package/dist/components/v-map-layer-wms2.js +1 -1
  62. package/dist/components/v-map-layer-xyz2.js +1 -1
  63. package/dist/components/v-map-layergroup2.js +1 -1
  64. package/dist/components/v-map-style2.js +2 -2
  65. package/dist/components/v-map2.js +1 -1
  66. package/dist/esm/{cesium-provider-BJfAup3w.js → cesium-provider-Bh__cBGf.js} +6 -5
  67. package/dist/esm/{deck-provider-C7U9VDEq.js → deck-provider-DxIpS4lY.js} +9 -9
  68. package/dist/esm/events-CrV_misM.js +9 -0
  69. package/dist/esm/{geotiff-source-esnDnC-u.js → geotiff-source-BRjO-Dvr.js} +1 -1
  70. package/dist/esm/{index-BIEmlzCf.js → index-Bh2gBu9u.js} +5 -5
  71. package/dist/esm/{index-jzneDarq.js → index-BoNyIrdq.js} +1 -1
  72. package/dist/esm/{index-jN06TXUp.js → index-C3mnOs0I.js} +4 -4
  73. package/dist/esm/{index-B1zwA4IC.js → index-C63kfbil.js} +6 -6
  74. package/dist/esm/{index-DbSdn93t.js → index-DxbztwCv.js} +7 -7
  75. package/dist/esm/{layer-extension-CZXK5goK.js → layer-extension-C5Y2UES3.js} +1 -1
  76. package/dist/esm/{leaflet-provider-Q41TB6ku.js → leaflet-provider-k6JSYiYX.js} +6 -5
  77. package/dist/esm/loader.js +3 -3
  78. package/dist/esm/{messages-CMKJzsgL.js → messages-QJHuuz0g.js} +1 -9
  79. package/dist/esm/{openlayers-provider-CMsDsQTQ.js → openlayers-provider-DIquf3Tx.js} +5 -4
  80. package/dist/esm/{polygon-layer-ByhxGhWC.js → polygon-layer-ZIT5mJy5.js} +1 -1
  81. package/dist/esm/{scenegraph-layer-09K_B6DT.js → scenegraph-layer-CNIRd2uu.js} +1 -1
  82. package/dist/esm/v-map-builder.entry.js +3 -2
  83. package/dist/esm/v-map-error.entry.js +119 -0
  84. package/dist/esm/v-map-layer-geojson_12.entry.js +10 -9
  85. package/dist/esm/{v-map-layer-helper-Dys44Cgo.js → v-map-layer-helper-CuHYsU9f.js} +2 -1
  86. package/dist/esm/v-map-layer-terrain-geotiff.entry.js +5 -4
  87. package/dist/esm/v-map-layercontrol.entry.js +1 -1
  88. package/dist/esm/v-map.js +3 -3
  89. 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
  90. package/dist/esm/v-map_3.entry.js +5 -4
  91. package/dist/types/components/v-map-error/v-map-error.d.ts +79 -0
  92. package/dist/types/components.d.ts +128 -0
  93. package/dist/v-map/p-05ee633f.entry.js +1 -0
  94. package/dist/v-map/p-08ad1392.entry.js +1 -0
  95. package/dist/v-map/p-2-mR3oVa.js +1 -0
  96. package/dist/v-map/{p-c21c93fe.entry.js → p-3a57b64a.entry.js} +1 -1
  97. package/dist/v-map/p-58dda864.entry.js +1 -0
  98. package/dist/v-map/p-915314c0.entry.js +10 -0
  99. package/dist/v-map/{p-MyTSFnEk.js → p-9Rt23jlQ.js} +1 -1
  100. package/dist/v-map/p-BSsFEMZP.js +1 -0
  101. package/dist/v-map/{p-jzneDarq.js → p-BoNyIrdq.js} +2 -2
  102. package/dist/v-map/p-BpE6L1g0.js +1 -0
  103. package/dist/v-map/{p-DvHXtWUg.js → p-C0M0-Kvt.js} +1 -1
  104. package/dist/v-map/p-CbiLpFhO.js +1 -0
  105. package/dist/v-map/p-Ci70E1EM.js +1 -0
  106. package/dist/v-map/p-CrV_misM.js +1 -0
  107. package/dist/v-map/{p-DrOQ9V4h.js → p-DAf4itFZ.js} +1 -1
  108. package/dist/v-map/p-DVBtCUtQ.js +1 -0
  109. package/dist/v-map/{p-CZqY0yW4.js → p-DuJ_mTaq.js} +1 -1
  110. package/dist/v-map/p-G6iftXUC.js +1 -0
  111. package/dist/v-map/{p-CMKJzsgL.js → p-QJHuuz0g.js} +1 -1
  112. package/dist/v-map/{p-aa410e64.entry.js → p-e21ea0ce.entry.js} +2 -2
  113. package/dist/v-map/{p-DmICdG34.js → p-rCyRSFJb.js} +2 -2
  114. package/dist/v-map/{p-CafTHT9i.js → p-vhbi5XXi.js} +1 -1
  115. package/dist/v-map/{p-Dckgonw8.js → p-yXLNXXx-.js} +1 -1
  116. package/dist/v-map/v-map.esm.js +1 -1
  117. package/package.json +29 -5
  118. package/dist/v-map/p--vVleK-M.js +0 -1
  119. package/dist/v-map/p-09d10db0.entry.js +0 -1
  120. package/dist/v-map/p-5eba6058.entry.js +0 -10
  121. package/dist/v-map/p-6b102336.entry.js +0 -1
  122. package/dist/v-map/p-BdijL4Av.js +0 -1
  123. package/dist/v-map/p-BeFu0ap4.js +0 -1
  124. package/dist/v-map/p-BxFJezdK.js +0 -1
  125. package/dist/v-map/p-DCTHyf58.js +0 -1
  126. package/dist/v-map/p-WaMDUuAz.js +0 -1
  127. package/dist/v-map/p-uiIP-taz.js +0 -1
@@ -1 +1 @@
1
- import{C as t}from"./p-DvHXtWUg.js";export{A as ArcLayer,P as PointCloudLayer,a as PolygonLayer}from"./p-DvHXtWUg.js";import{G as n,u as o,L as i,p as r,c as s,a as l,U as c,M as u}from"./p-MyTSFnEk.js";export{B as BitmapLayer,e as GeoJsonLayer,I as IconLayer,P as PathLayer,b as ScatterplotLayer,f as SolidPolygonLayer,T as TextLayer,g as _MultiIconLayer,h as _TextBackgroundLayer}from"./p-MyTSFnEk.js";import"./p-B-bAcABs.js";import"./p-DhQAXuA7.js";import"./p-DR9McdNX.js";import"./p-E-ZsRS8r.js";import"./p-CMKJzsgL.js";import"./p-Dckgonw8.js";import"@loaders.gl/core";import"@loaders.gl/images";import"@loaders.gl/loader-utils";import"@loaders.gl/terrain";import"@loaders.gl/schema";class d extends n{constructor(e={}){const{id:t=o("cube-geometry"),indices:n=!0}=e;super(n?{...e,id:t,topology:"triangle-list",indices:{size:1,value:p},attributes:{...S,...e.attributes}}:{...e,id:t,topology:"triangle-list",indices:void 0,attributes:{...C,...e.attributes}})}}const p=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),v=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),_=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),m=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),w=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),x=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),y=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),S={POSITION:{size:3,value:v},NORMAL:{size:3,value:_},TEXCOORD_0:{size:2,value:m}},C={POSITION:{size:3,value:w},TEXCOORD_0:{size:2,value:x},COLOR_0:{size:3,value:y}},L="uniform lineUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float useShortestPath;\n highp int widthUnits;\n} line;\n",z={name:"line",source:"struct LineUniforms {\n widthScale: f32,\n widthMinPixels: f32,\n widthMaxPixels: f32,\n useShortestPath: f32,\n widthUnits: i32,\n};\n\n@group(0) @binding(1)\nvar<uniform> line: LineUniforms;\n",vs:L,fs:L,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}},O={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getColor:{type:"accessor",value:[0,0,0,255]},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class M extends i{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME line-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceSourcePositions;\nin vec3 instanceTargetPositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin float instanceWidths;\nout vec4 vColor;\nout vec2 uv;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nvec3 splitLine(vec3 a, vec3 b, float x) {\nfloat t = (x - a.x) / (b.x - a.x);\nreturn vec3(x, mix(a.yz, b.yz, t));\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nvec3 source_world_64low = instanceSourcePositions64Low;\nvec3 target_world_64low = instanceTargetPositions64Low;\nif (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng * line.useShortestPath > 180.) {\nsource_world.x += 360. * line.useShortestPath;\nsource_world = splitLine(source_world, target_world, 180. * line.useShortestPath);\nsource_world_64low = vec3(0.0);\n} else if (deltaLng * line.useShortestPath < -180.) {\ntarget_world.x += 360. * line.useShortestPath;\ntarget_world = splitLine(source_world, target_world, 180. * line.useShortestPath);\ntarget_world_64low = vec3(0.0);\n} else if (line.useShortestPath < 0.) {\ngl_Position = vec4(0.);\nreturn;\n}\n}\nvec4 source_commonspace;\nvec4 target_commonspace;\nvec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace);\nvec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace);\nfloat segmentIndex = positions.x;\nvec4 p = mix(source, target, segmentIndex);\ngeometry.position = mix(source_commonspace, target_commonspace, segmentIndex);\nuv = positions.xy;\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),\nline.widthMinPixels, line.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset(target.xy - source.xy, positions.y, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(p, geometry);\ngl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME line-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:'// ---------- Helper Structures & Functions ----------\n\n// Placeholder filter functions.\nfn deckgl_filter_size(offset: vec3<f32>, geometry: Geometry) -> vec3<f32> {\n return offset;\n}\nfn deckgl_filter_gl_position(p: vec4<f32>, geometry: Geometry) -> vec4<f32> {\n return p;\n}\nfn deckgl_filter_color(color: vec4<f32>, geometry: Geometry) -> vec4<f32> {\n return color;\n}\n\n// Compute an extrusion offset given a line direction (in clipspace),\n// an offset direction (-1 or 1), and a width in pixels.\n// Assumes a uniform "project" with a viewportSize field is available.\nfn getExtrusionOffset(line_clipspace: vec2<f32>, offset_direction: f32, width: f32) -> vec2<f32> {\n // project.viewportSize should be provided as a uniform (not shown here)\n let dir_screenspace = normalize(line_clipspace * project.viewportSize);\n // Rotate by 90°: (x,y) becomes (-y,x)\n let rotated = vec2<f32>(-dir_screenspace.y, dir_screenspace.x);\n return rotated * offset_direction * width / 2.0;\n}\n\n// Splits the line between two points at a given x coordinate.\n// Interpolates the y and z components.\nfn splitLine(a: vec3<f32>, b: vec3<f32>, x: f32) -> vec3<f32> {\n let t: f32 = (x - a.x) / (b.x - a.x);\n return vec3<f32>(x, a.yz + t * (b.yz - a.yz));\n}\n\n// ---------- Uniforms & Global Structures ----------\n\n// Uniforms for line, color, and project are assumed to be defined elsewhere.\n// For example:\n//\n// @group(0) @binding(0)\n// var<uniform> line: LineUniform;\n//\n// struct ColorUniform {\n// opacity: f32,\n// };\n// @group(0) @binding(1)\n// var<uniform> color: ColorUniform;\n//\n// struct ProjectUniform {\n// viewportSize: vec2<f32>,\n// };\n// @group(0) @binding(2)\n// var<uniform> project: ProjectUniform;\n\n\n\n// ---------- Vertex Output Structure ----------\n\nstruct Varyings {\n @builtin(position) gl_Position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) uv: vec2<f32>,\n};\n\n// ---------- Vertex Shader Entry Point ----------\n\n@vertex\nfn vertexMain(\n @location(0) positions: vec3<f32>,\n @location(1) instanceSourcePositions: vec3<f32>,\n @location(2) instanceTargetPositions: vec3<f32>,\n @location(3) instanceSourcePositions64Low: vec3<f32>,\n @location(4) instanceTargetPositions64Low: vec3<f32>,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instancePickingColors: vec3<f32>,\n @location(7) instanceWidths: f32\n) -> Varyings {\n var geometry: Geometry;\n geometry.worldPosition = instanceSourcePositions;\n geometry.worldPositionAlt = instanceTargetPositions;\n\n var source_world: vec3<f32> = instanceSourcePositions;\n var target_world: vec3<f32> = instanceTargetPositions;\n var source_world_64low: vec3<f32> = instanceSourcePositions64Low;\n var target_world_64low: vec3<f32> = instanceTargetPositions64Low;\n\n // Apply shortest-path adjustments if needed.\n if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {\n source_world.x = (source_world.x + 180.0 % 360.0) - 180.0;\n target_world.x = (target_world.x + 180.0 % 360.0) - 180.0;\n let deltaLng: f32 = target_world.x - source_world.x;\n\n if (deltaLng * line.useShortestPath > 180.0) {\n source_world.x = source_world.x + 360.0 * line.useShortestPath;\n source_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);\n source_world_64low = vec3<f32>(0.0, 0.0, 0.0);\n } else if (deltaLng * line.useShortestPath < -180.0) {\n target_world.x = target_world.x + 360.0 * line.useShortestPath;\n target_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);\n target_world_64low = vec3<f32>(0.0, 0.0, 0.0);\n } else if (line.useShortestPath < 0.0) {\n var abortOut: Varyings;\n abortOut.gl_Position = vec4<f32>(0.0);\n abortOut.vColor = vec4<f32>(0.0);\n abortOut.uv = vec2<f32>(0.0);\n return abortOut;\n }\n }\n\n // Project Pos and target positions to clip space.\n let sourceResult = project_position_to_clipspace_and_commonspace(source_world, source_world_64low, vec3<f32>(0.0));\n let targetResult = project_position_to_clipspace_and_commonspace(target_world, target_world_64low, vec3<f32>(0.0));\n let sourcePos: vec4<f32> = sourceResult.clipPosition;\n let targetPos: vec4<f32> = targetResult.clipPosition;\n let source_commonspace: vec4<f32> = sourceResult.commonPosition;\n let target_commonspace: vec4<f32> = targetResult.commonPosition;\n\n // Interpolate along the line segment.\n let segmentIndex: f32 = positions.x;\n let p: vec4<f32> = sourcePos + segmentIndex * (targetPos - sourcePos);\n geometry.position = source_commonspace + segmentIndex * (target_commonspace - source_commonspace);\n let uv: vec2<f32> = positions.xy;\n geometry.uv = uv;\n geometry.pickingColor = instancePickingColors;\n\n // Determine width in pixels.\n let widthPixels: f32 = clamp(\n project_unit_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),\n line.widthMinPixels, line.widthMaxPixels\n );\n\n // Compute extrusion offset.\n let extrusion: vec2<f32> = getExtrusionOffset(targetPos.xy - sourcePos.xy, positions.y, widthPixels);\n let offset: vec3<f32> = vec3<f32>(extrusion, 0.0);\n\n // Apply deck.gl filter functions.\n let filteredOffset = deckgl_filter_size(offset, geometry);\n let filteredP = deckgl_filter_gl_position(p, geometry);\n\n let clipOffset: vec2<f32> = project_pixel_size_to_clipspace(filteredOffset.xy);\n let finalPosition: vec4<f32> = filteredP + vec4<f32>(clipOffset, 0.0, 0.0);\n\n // Compute color.\n var vColor: vec4<f32> = vec4<f32>(instanceColors.rgb, instanceColors.a * color.opacity);\n // vColor = deckgl_filter_color(vColor, geometry);\n\n var output: Varyings;\n output.gl_Position = finalPosition;\n output.vColor = vColor;\n output.uv = uv;\n return output;\n}\n\n@fragment\nfn fragmentMain(\n @location(0) vColor: vec4<f32>,\n @location(1) uv: vec2<f32>\n) -> @location(0) vec4<f32> {\n // Create and initialize geometry with the provided uv.\n var geometry: Geometry;\n geometry.uv = uv;\n\n // Start with the input color.\n var fragColor: vec4<f32> = vColor;\n\n // Apply the deck.gl filter to the color.\n fragColor = deckgl_filter_color(fragColor, geometry);\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n}\n',modules:[r,s,l,z]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({}){const{widthUnits:e,widthScale:t,widthMinPixels:n,widthMaxPixels:o,wrapLongitude:i}=this.props,r=this.state.model,s={widthUnits:c[e],widthScale:t,widthMinPixels:n,widthMaxPixels:o,useShortestPath:i?1:0};r.shaderInputs.setProps({line:s}),r.draw(this.context.renderPass),i&&(r.shaderInputs.setProps({line:{...s,useShortestPath:-1}}),r.draw(this.context.renderPass))}_getModel(){const e="webgpu"===this.context.device.type?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0;return new u(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new n({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([0,-1,0,0,1,0,1,-1,0,1,1,0])}}}),parameters:e,isInstanced:!0})}}M.layerName="LineLayer",M.defaultProps=O;class j extends t{_updateGeometry(){const e=new d;this.state.fillModel.setGeometry(e)}draw({}){const{elevationScale:e,extruded:t,offset:n,coverage:o,cellSize:i,angle:r,radiusUnits:s}=this.props,a=this.state.fillModel;a.shaderInputs.setProps({column:{radius:i/2,radiusUnits:c[s],angle:r,offset:n,extruded:t,stroked:!1,coverage:o,elevationScale:e,edgeDistance:1,isStroke:!1,widthUnits:0,widthScale:0,widthMinPixels:0,widthMaxPixels:0}}),a.draw(this.context.renderPass)}}j.layerName="GridCellLayer",j.defaultProps={cellSize:{type:"number",min:0,value:1e3},offset:{type:"array",value:[1,1]}};export{t as ColumnLayer,j as GridCellLayer,M as LineLayer}
1
+ import{C as t}from"./p-C0M0-Kvt.js";export{A as ArcLayer,P as PointCloudLayer,a as PolygonLayer}from"./p-C0M0-Kvt.js";import{G as n,u as o,L as i,p as r,c as s,a as l,U as c,M as u}from"./p-9Rt23jlQ.js";export{B as BitmapLayer,e as GeoJsonLayer,I as IconLayer,P as PathLayer,b as ScatterplotLayer,f as SolidPolygonLayer,T as TextLayer,g as _MultiIconLayer,h as _TextBackgroundLayer}from"./p-9Rt23jlQ.js";import"./p-B-bAcABs.js";import"./p-DhQAXuA7.js";import"./p-DR9McdNX.js";import"./p-E-ZsRS8r.js";import"./p-QJHuuz0g.js";import"./p-yXLNXXx-.js";import"@loaders.gl/core";import"@loaders.gl/images";import"@loaders.gl/loader-utils";import"@loaders.gl/terrain";import"@loaders.gl/schema";class d extends n{constructor(e={}){const{id:t=o("cube-geometry"),indices:n=!0}=e;super(n?{...e,id:t,topology:"triangle-list",indices:{size:1,value:p},attributes:{...S,...e.attributes}}:{...e,id:t,topology:"triangle-list",indices:void 0,attributes:{...C,...e.attributes}})}}const p=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),v=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),_=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),m=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),w=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),x=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),y=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),S={POSITION:{size:3,value:v},NORMAL:{size:3,value:_},TEXCOORD_0:{size:2,value:m}},C={POSITION:{size:3,value:w},TEXCOORD_0:{size:2,value:x},COLOR_0:{size:3,value:y}},L="uniform lineUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float useShortestPath;\n highp int widthUnits;\n} line;\n",z={name:"line",source:"struct LineUniforms {\n widthScale: f32,\n widthMinPixels: f32,\n widthMaxPixels: f32,\n useShortestPath: f32,\n widthUnits: i32,\n};\n\n@group(0) @binding(1)\nvar<uniform> line: LineUniforms;\n",vs:L,fs:L,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}},O={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getColor:{type:"accessor",value:[0,0,0,255]},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class j extends i{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME line-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceSourcePositions;\nin vec3 instanceTargetPositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin float instanceWidths;\nout vec4 vColor;\nout vec2 uv;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nvec3 splitLine(vec3 a, vec3 b, float x) {\nfloat t = (x - a.x) / (b.x - a.x);\nreturn vec3(x, mix(a.yz, b.yz, t));\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nvec3 source_world_64low = instanceSourcePositions64Low;\nvec3 target_world_64low = instanceTargetPositions64Low;\nif (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng * line.useShortestPath > 180.) {\nsource_world.x += 360. * line.useShortestPath;\nsource_world = splitLine(source_world, target_world, 180. * line.useShortestPath);\nsource_world_64low = vec3(0.0);\n} else if (deltaLng * line.useShortestPath < -180.) {\ntarget_world.x += 360. * line.useShortestPath;\ntarget_world = splitLine(source_world, target_world, 180. * line.useShortestPath);\ntarget_world_64low = vec3(0.0);\n} else if (line.useShortestPath < 0.) {\ngl_Position = vec4(0.);\nreturn;\n}\n}\nvec4 source_commonspace;\nvec4 target_commonspace;\nvec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace);\nvec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace);\nfloat segmentIndex = positions.x;\nvec4 p = mix(source, target, segmentIndex);\ngeometry.position = mix(source_commonspace, target_commonspace, segmentIndex);\nuv = positions.xy;\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),\nline.widthMinPixels, line.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset(target.xy - source.xy, positions.y, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(p, geometry);\ngl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME line-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:'// ---------- Helper Structures & Functions ----------\n\n// Placeholder filter functions.\nfn deckgl_filter_size(offset: vec3<f32>, geometry: Geometry) -> vec3<f32> {\n return offset;\n}\nfn deckgl_filter_gl_position(p: vec4<f32>, geometry: Geometry) -> vec4<f32> {\n return p;\n}\nfn deckgl_filter_color(color: vec4<f32>, geometry: Geometry) -> vec4<f32> {\n return color;\n}\n\n// Compute an extrusion offset given a line direction (in clipspace),\n// an offset direction (-1 or 1), and a width in pixels.\n// Assumes a uniform "project" with a viewportSize field is available.\nfn getExtrusionOffset(line_clipspace: vec2<f32>, offset_direction: f32, width: f32) -> vec2<f32> {\n // project.viewportSize should be provided as a uniform (not shown here)\n let dir_screenspace = normalize(line_clipspace * project.viewportSize);\n // Rotate by 90°: (x,y) becomes (-y,x)\n let rotated = vec2<f32>(-dir_screenspace.y, dir_screenspace.x);\n return rotated * offset_direction * width / 2.0;\n}\n\n// Splits the line between two points at a given x coordinate.\n// Interpolates the y and z components.\nfn splitLine(a: vec3<f32>, b: vec3<f32>, x: f32) -> vec3<f32> {\n let t: f32 = (x - a.x) / (b.x - a.x);\n return vec3<f32>(x, a.yz + t * (b.yz - a.yz));\n}\n\n// ---------- Uniforms & Global Structures ----------\n\n// Uniforms for line, color, and project are assumed to be defined elsewhere.\n// For example:\n//\n// @group(0) @binding(0)\n// var<uniform> line: LineUniform;\n//\n// struct ColorUniform {\n// opacity: f32,\n// };\n// @group(0) @binding(1)\n// var<uniform> color: ColorUniform;\n//\n// struct ProjectUniform {\n// viewportSize: vec2<f32>,\n// };\n// @group(0) @binding(2)\n// var<uniform> project: ProjectUniform;\n\n\n\n// ---------- Vertex Output Structure ----------\n\nstruct Varyings {\n @builtin(position) gl_Position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) uv: vec2<f32>,\n};\n\n// ---------- Vertex Shader Entry Point ----------\n\n@vertex\nfn vertexMain(\n @location(0) positions: vec3<f32>,\n @location(1) instanceSourcePositions: vec3<f32>,\n @location(2) instanceTargetPositions: vec3<f32>,\n @location(3) instanceSourcePositions64Low: vec3<f32>,\n @location(4) instanceTargetPositions64Low: vec3<f32>,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instancePickingColors: vec3<f32>,\n @location(7) instanceWidths: f32\n) -> Varyings {\n var geometry: Geometry;\n geometry.worldPosition = instanceSourcePositions;\n geometry.worldPositionAlt = instanceTargetPositions;\n\n var source_world: vec3<f32> = instanceSourcePositions;\n var target_world: vec3<f32> = instanceTargetPositions;\n var source_world_64low: vec3<f32> = instanceSourcePositions64Low;\n var target_world_64low: vec3<f32> = instanceTargetPositions64Low;\n\n // Apply shortest-path adjustments if needed.\n if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {\n source_world.x = (source_world.x + 180.0 % 360.0) - 180.0;\n target_world.x = (target_world.x + 180.0 % 360.0) - 180.0;\n let deltaLng: f32 = target_world.x - source_world.x;\n\n if (deltaLng * line.useShortestPath > 180.0) {\n source_world.x = source_world.x + 360.0 * line.useShortestPath;\n source_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);\n source_world_64low = vec3<f32>(0.0, 0.0, 0.0);\n } else if (deltaLng * line.useShortestPath < -180.0) {\n target_world.x = target_world.x + 360.0 * line.useShortestPath;\n target_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);\n target_world_64low = vec3<f32>(0.0, 0.0, 0.0);\n } else if (line.useShortestPath < 0.0) {\n var abortOut: Varyings;\n abortOut.gl_Position = vec4<f32>(0.0);\n abortOut.vColor = vec4<f32>(0.0);\n abortOut.uv = vec2<f32>(0.0);\n return abortOut;\n }\n }\n\n // Project Pos and target positions to clip space.\n let sourceResult = project_position_to_clipspace_and_commonspace(source_world, source_world_64low, vec3<f32>(0.0));\n let targetResult = project_position_to_clipspace_and_commonspace(target_world, target_world_64low, vec3<f32>(0.0));\n let sourcePos: vec4<f32> = sourceResult.clipPosition;\n let targetPos: vec4<f32> = targetResult.clipPosition;\n let source_commonspace: vec4<f32> = sourceResult.commonPosition;\n let target_commonspace: vec4<f32> = targetResult.commonPosition;\n\n // Interpolate along the line segment.\n let segmentIndex: f32 = positions.x;\n let p: vec4<f32> = sourcePos + segmentIndex * (targetPos - sourcePos);\n geometry.position = source_commonspace + segmentIndex * (target_commonspace - source_commonspace);\n let uv: vec2<f32> = positions.xy;\n geometry.uv = uv;\n geometry.pickingColor = instancePickingColors;\n\n // Determine width in pixels.\n let widthPixels: f32 = clamp(\n project_unit_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),\n line.widthMinPixels, line.widthMaxPixels\n );\n\n // Compute extrusion offset.\n let extrusion: vec2<f32> = getExtrusionOffset(targetPos.xy - sourcePos.xy, positions.y, widthPixels);\n let offset: vec3<f32> = vec3<f32>(extrusion, 0.0);\n\n // Apply deck.gl filter functions.\n let filteredOffset = deckgl_filter_size(offset, geometry);\n let filteredP = deckgl_filter_gl_position(p, geometry);\n\n let clipOffset: vec2<f32> = project_pixel_size_to_clipspace(filteredOffset.xy);\n let finalPosition: vec4<f32> = filteredP + vec4<f32>(clipOffset, 0.0, 0.0);\n\n // Compute color.\n var vColor: vec4<f32> = vec4<f32>(instanceColors.rgb, instanceColors.a * color.opacity);\n // vColor = deckgl_filter_color(vColor, geometry);\n\n var output: Varyings;\n output.gl_Position = finalPosition;\n output.vColor = vColor;\n output.uv = uv;\n return output;\n}\n\n@fragment\nfn fragmentMain(\n @location(0) vColor: vec4<f32>,\n @location(1) uv: vec2<f32>\n) -> @location(0) vec4<f32> {\n // Create and initialize geometry with the provided uv.\n var geometry: Geometry;\n geometry.uv = uv;\n\n // Start with the input color.\n var fragColor: vec4<f32> = vColor;\n\n // Apply the deck.gl filter to the color.\n fragColor = deckgl_filter_color(fragColor, geometry);\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n}\n',modules:[r,s,l,z]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({}){const{widthUnits:e,widthScale:t,widthMinPixels:n,widthMaxPixels:o,wrapLongitude:i}=this.props,r=this.state.model,s={widthUnits:c[e],widthScale:t,widthMinPixels:n,widthMaxPixels:o,useShortestPath:i?1:0};r.shaderInputs.setProps({line:s}),r.draw(this.context.renderPass),i&&(r.shaderInputs.setProps({line:{...s,useShortestPath:-1}}),r.draw(this.context.renderPass))}_getModel(){const e="webgpu"===this.context.device.type?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0;return new u(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new n({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([0,-1,0,0,1,0,1,-1,0,1,1,0])}}}),parameters:e,isInstanced:!0})}}j.layerName="LineLayer",j.defaultProps=O;class M extends t{_updateGeometry(){const e=new d;this.state.fillModel.setGeometry(e)}draw({}){const{elevationScale:e,extruded:t,offset:n,coverage:o,cellSize:i,angle:r,radiusUnits:s}=this.props,a=this.state.fillModel;a.shaderInputs.setProps({column:{radius:i/2,radiusUnits:c[s],angle:r,offset:n,extruded:t,stroked:!1,coverage:o,elevationScale:e,edgeDistance:1,isStroke:!1,widthUnits:0,widthScale:0,widthMinPixels:0,widthMaxPixels:0}}),a.draw(this.context.renderPass)}}M.layerName="GridCellLayer",M.defaultProps={cellSize:{type:"number",min:0,value:1e3},offset:{type:"array",value:[1,1]}};export{t as ColumnLayer,M as GridCellLayer,j as LineLayer}
@@ -1 +1 @@
1
- import{w as t,l as e}from"./p-CMKJzsgL.js";const r={grayscale:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}],viridis:[{value:0,color:[68,1,84]},{value:.25,color:[59,82,139]},{value:.5,color:[33,145,140]},{value:.75,color:[94,201,98]},{value:1,color:[253,231,37]}],terrain:[{value:0,color:[0,128,0]},{value:.25,color:[139,195,74]},{value:.5,color:[255,235,59]},{value:.75,color:[255,152,0]},{value:1,color:[255,255,255]}],turbo:[{value:0,color:[48,18,59]},{value:.2,color:[33,102,172]},{value:.4,color:[68,190,112]},{value:.6,color:[253,231,37]},{value:.8,color:[234,51,35]},{value:1,color:[122,4,3]}],rainbow:[{value:0,color:[148,0,211]},{value:.2,color:[0,0,255]},{value:.4,color:[0,255,0]},{value:.6,color:[255,255,0]},{value:.8,color:[255,127,0]},{value:1,color:[255,0,0]}]};function n(t,e){const r=Math.max(0,Math.min(1,t));if(0===e.length)return[0,0,0];if(1===e.length)return e[0].color;let n=0,a=e.length-1;if(r<=e[n].value)return e[n].color;if(r>=e[a].value)return e[a].color;for(;a-n>1;){const t=Math.floor((n+a)/2);e[t].value<=r?n=t:a=t}const i=e[n],o=e[a],s=(r-i.value)/(o.value-i.value);return[Math.round(i.color[0]+s*(o.color[0]-i.color[0])),Math.round(i.color[1]+s*(o.color[1]-i.color[1])),Math.round(i.color[2]+s*(o.color[2]-i.color[2]))]}function a(e,n){if("string"==typeof e){const n=r[e];return n?{stops:n}:(t(`Unknown colormap: ${e}, using grayscale`),{stops:r.grayscale})}return function(e,n){const a=e.colorMapEntries||[];if(0===a.length)return t("GeoStyler ColorMap has no entries, using grayscale"),{stops:r.grayscale};const i=a.map((t=>t.quantity)).filter((t=>"number"==typeof t));let o,s;n?[o,s]=n:i.length>0?(o=Math.min(...i),s=Math.max(...i)):(o=0,s=1),s===o&&(s=o+1);const l=a.map((e=>{const r=(("number"==typeof e.quantity?e.quantity:0)-o)/(s-o),n=function(e){let r=e.trim();if(r.startsWith("#")&&(r=r.slice(1)),3===r.length&&(r=r.split("").map((t=>t+t)).join("")),6!==r.length)return t(`Invalid hex color: ${e}, using black`),[0,0,0];const n=parseInt(r.slice(0,2),16),a=parseInt(r.slice(2,4),16),i=parseInt(r.slice(4,6),16);return isNaN(n)||isNaN(a)||isNaN(i)?(t(`Invalid hex color: ${e}, using black`),[0,0,0]):[n,a,i]}("string"==typeof e.color?e.color:String(e.color));return{value:Math.max(0,Math.min(1,r)),color:n}}));return l.sort(((t,e)=>t.value-e.value)),{stops:l,computedRange:n?void 0:[o,s]}}(e,n)}class i{min;max;constructor(t,e){this.min=t,this.max=e}contains(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}static fromTriangle(t){const e=Math.min(t.a.x,t.b.x,t.c.x),r=Math.min(t.a.y,t.b.y,t.c.y),n=Math.max(t.a.x,t.b.x,t.c.x),a=Math.max(t.a.y,t.b.y,t.c.y);return new i({x:e,y:r},{x:n,y:a})}static union(t,e){return new i({x:Math.min(t.min.x,e.min.x),y:Math.min(t.min.y,e.min.y)},{x:Math.max(t.max.x,e.max.x),y:Math.max(t.max.y,e.max.y)})}}class o{bbox;triangles;left;right;constructor(t,e=[],r=null,n=null){this.bbox=t,this.triangles=e,this.left=r,this.right=n}static build(t,e=0,r=10){if(t.length<=2||e>=r){let e=i.fromTriangle(t[0]);for(let r=1;r<t.length;r++)e=i.union(e,i.fromTriangle(t[r]));return new o(e,t)}const n=t.map((t=>({x:(t.a.x+t.b.x+t.c.x)/3,y:(t.a.y+t.b.y+t.c.y)/3}))),{min:a,max:s}=n.reduce(((t,e)=>({min:{x:Math.min(t.min.x,e.x),y:Math.min(t.min.y,e.y)},max:{x:Math.max(t.max.x,e.x),y:Math.max(t.max.y,e.y)}})),{min:n[0],max:n[0]}),l=s.x-a.x>s.y-a.y?"x":"y";n.sort(((t,e)=>t[l]-e[l]));const h=Math.floor(n.length/2),u=[],c=[];for(let e=0;e<t.length;e++)(e<h?u:c).push(t[e]);const f=o.build(u,e+1,r),d=o.build(c,e+1,r),M=i.union(f.bbox,d.bbox);return new o(M,[],f,d)}findContainingTriangle(t){if(!this.bbox.contains(t))return null;if(this.triangles.length>0){for(const e of this.triangles)if(o.punktInDreieck2D(t,e))return e;return null}return this.left?.findContainingTriangle(t)||this.right?.findContainingTriangle(t)||null}static punktInDreieck2D(t,e){const{a:r,b:n,c:a}=e,i=a.x-r.x,o=a.y-r.y,s=n.x-r.x,l=n.y-r.y,h=t.x-r.x,u=t.y-r.y,c=i*i+o*o,f=i*s+o*l,d=i*h+o*u,M=s*s+l*l,m=s*h+l*u,g=1/(c*M-f*f),p=(M*d-f*m)*g,y=(c*m-f*d)*g;return p>=0&&y>=0&&p+y<=1}static toTriangle2D(t){return{a:{x:t.target[0][0],y:t.target[0][1]},b:{x:t.target[1][0],y:t.target[1][1]},c:{x:t.target[2][0],y:t.target[2][1]},triangle:t,transform:null}}toString(t=""){const e=this.triangles.length>0;let r=`${t}${e?"LEAF":"NODE"} bbox=[${this.bbox.min.x.toFixed(2)}, ${this.bbox.min.y.toFixed(2)}, ${this.bbox.max.x.toFixed(2)}, ${this.bbox.max.y.toFixed(2)}]`;if(e){const t=this.triangles.map((t=>t.a.x.toFixed(2)+","+t.a.y.toFixed(2)+" "+t.b.x.toFixed(2)+","+t.b.y.toFixed(2)+" "+t.c.x.toFixed(2)+","+t.c.y.toFixed(2))).toString();r+=` triangles=${this.triangles.length} - ${t}`}else r+="\n",this.left&&(r+=`${t}├─ left:\n${this.left.toString(t+"│ ")}`),this.right&&(r+=`${t}└─ right:\n${this.right.toString(t+" ")}`);return r}getStats(){const t={depth:1,nodeCount:1,leafCount:0,triangleCount:this.triangles.length,minTrianglesPerLeaf:1/0,maxTrianglesPerLeaf:0};if(this.triangles.length>0)t.leafCount=1,t.minTrianglesPerLeaf=this.triangles.length,t.maxTrianglesPerLeaf=this.triangles.length;else{if(this.left){const e=this.left.getStats();t.depth=Math.max(t.depth,e.depth+1),t.nodeCount+=e.nodeCount,t.leafCount+=e.leafCount,t.triangleCount+=e.triangleCount,t.minTrianglesPerLeaf=Math.min(t.minTrianglesPerLeaf,e.minTrianglesPerLeaf),t.maxTrianglesPerLeaf=Math.max(t.maxTrianglesPerLeaf,e.maxTrianglesPerLeaf)}if(this.right){const e=this.right.getStats();t.depth=Math.max(t.depth,e.depth+1),t.nodeCount+=e.nodeCount,t.leafCount+=e.leafCount,t.triangleCount+=e.triangleCount,t.minTrianglesPerLeaf=Math.min(t.minTrianglesPerLeaf,e.minTrianglesPerLeaf),t.maxTrianglesPerLeaf=Math.max(t.maxTrianglesPerLeaf,e.maxTrianglesPerLeaf)}}return t}}function s(t,e,r,n,a=10){const[i,o,s,l]=r;let h=1/0,u=1/0,c=-1/0,f=-1/0,d=[0,0],M=[0,0],m=[0,0],g=[0,0];const p=(t,e,r)=>{for(let a=0;a<=r;a++){const i=a/r,o=[t[0]+(e[0]-t[0])*i,t[1]+(e[1]-t[1])*i],[s,l]=n(o);s<h&&(h=s,d=o),l<u&&(u=l,M=o),s>c&&(c=s,m=o),l>f&&(f=l,g=o)}};if(p([i,l],[s,l],a),p([s,l],[s,o],a),p([s,o],[i,o],a),p([i,o],[i,l],a),null!=t&&null!=e){const r=Math.floor((h-t[0])/e);h=t[0]+r*e;const n=Math.floor((u-t[1])/e);u=t[1]+n*e;const a=Math.ceil((c-t[0])/e);c=t[0]+a*e;const i=Math.ceil((f-t[1])/e);f=t[1]+i*e}return{source:{minX:h,minY:u,maxX:c,maxY:f},target:{minX:d[0],minY:M[1],maxX:m[0],maxY:g[1]}}}class l{triangles_=[];transformFn_;errorThresholdSquared_;bvh_=null;bounds;constructor(t,e,r=.5,n=null,a=null,i=10){this.transformFn_=t,this.errorThresholdSquared_=r*r;const[o,l,h,u]=e,c=[o,u],f=[h,u],d=[h,l],M=[o,l],m=s(n,a,e,this.transformFn_,i),g=[m.source.minX,m.source.maxY],p=[m.source.maxX,m.source.maxY],y=[m.source.maxX,m.source.minY],b=[m.source.minX,m.source.minY];this.bounds=m.source,this.addQuad_(c,f,d,M,g,p,y,b,10)}getBounds(){return this.bounds}addQuad_(t,e,r,n,a,i,o,s,l){let h=!1;if(l>0){const l=[(e[0]+r[0])/2,(e[1]+r[1])/2],u=[(r[0]+n[0])/2,(r[1]+n[1])/2],c=[(n[0]+t[0])/2,(n[1]+t[1])/2],f=this.transformFn_([(t[0]+e[0])/2,(t[1]+e[1])/2]),d=this.transformFn_(l),M=this.transformFn_(u),m=this.transformFn_(c),g=[(i[0]+o[0])/2,(i[1]+o[1])/2],p=[(o[0]+s[0])/2,(o[1]+s[1])/2],y=[(s[0]+a[0])/2,(s[1]+a[1])/2],b=this.getSquaredError_(f,[(a[0]+i[0])/2,(a[1]+i[1])/2]),v=this.getSquaredError_(d,g),w=this.getSquaredError_(M,p),S=this.getSquaredError_(m,y);(b>this.errorThresholdSquared_||v>this.errorThresholdSquared_||w>this.errorThresholdSquared_||S>this.errorThresholdSquared_)&&(h=!0)}if(h){const h=[(t[0]+e[0]+r[0]+n[0])/4,(t[1]+e[1]+r[1]+n[1])/4],u=this.transformFn_(h),c=[(t[0]+e[0])/2,(t[1]+e[1])/2],f=[(e[0]+r[0])/2,(e[1]+r[1])/2],d=[(r[0]+n[0])/2,(r[1]+n[1])/2],M=[(n[0]+t[0])/2,(n[1]+t[1])/2],m=this.transformFn_(c),g=this.transformFn_(f),p=this.transformFn_(d),y=this.transformFn_(M),b=l-1;this.addQuad_(t,c,h,M,a,m,u,y,b),this.addQuad_(c,e,f,h,m,i,g,u,b),this.addQuad_(h,f,r,d,u,g,o,p,b),this.addQuad_(M,h,d,n,y,u,p,s,b)}else this.addTriangle_(t,e,n,a,i,s),this.addTriangle_(e,r,n,i,o,s)}addTriangle_(t,e,r,n,a,i){isFinite(n[0])&&isFinite(n[1])&&isFinite(a[0])&&isFinite(a[1])&&isFinite(i[0])&&isFinite(i[1])&&this.triangles_.push({source:[n,a,i],target:[t,e,r]})}getSquaredError_(t,e){const r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}getTriangles(){return this.triangles_}calculateSourceExtent(){if(0===this.triangles_.length)return null;let t=1/0,e=1/0,r=-1/0,n=-1/0;for(const a of this.triangles_)for(const[i,o]of a.source)i<t&&(t=i),i>r&&(r=i),o<e&&(e=o),o>n&&(n=o);return[t,e,r,n]}buildBVH(){const t=this.triangles_.map(o.toTriangle2D);this.bvh_=o.build(t)}findSourceTriangleForTargetPoint(t,e=null){this.bvh_||this.buildBVH();const r={x:t[0],y:t[1]};if(e?.tri&&o.punktInDreieck2D(r,o.toTriangle2D(e.tri)))return e;const n=this.bvh_.findContainingTriangle(r);return n&&!n.transform&&(n.transform=this.calculateAffineTransform(n.triangle)),n?{tri:n.triangle,transform:n.transform}:null}calculateAffineTransform(t){const[[e,r],[n,a],[i,o]]=t.target,[[s,l],[h,u],[c,f]]=t.source,d=(n-e)*(o-r)-(i-e)*(a-r);if(Math.abs(d)<1e-10)return{a:1,b:0,c:s,d:0,e:1,f:l};const M=((h-s)*(o-r)-(c-s)*(a-r))/d,m=((c-s)*(n-e)-(h-s)*(i-e))/d,g=((u-l)*(o-r)-(f-l)*(a-r))/d,p=((f-l)*(n-e)-(u-l)*(i-e))/d;return{a:M,b:m,c:s-M*e-m*r,d:g,e:p,f:l-g*e-p*r}}applyAffineTransform(t,e,r){return[r.a*t+r.b*e+r.c,r.d*t+r.e*e+r.f]}}function h(e,r){switch(r){case"Uint8Array":return e;case"Uint16Array":return Math.round(e/65535*255);case"Int16Array":return Math.round((e+32768)/65535*255);case"Uint32Array":return Math.round(e/4294967295*255);case"Int32Array":return Math.round((e+2147483648)/4294967295*255);case"Float32Array":case"Float64Array":const n=Math.max(0,Math.min(1,e));return Math.round(255*n);default:return t(`Unknown array type: ${r}, treating as Uint8`),e}}function u(t){return Math.max(0,Math.min(1,t))}function c(t,e,r,a,i,o,s,l,c){const f=Math.round(t)-s,d=Math.round(e)-l;if(f<0||f>=i||d<0||d>=o)return null;const M=d*i+f,m=r.length;if(1===m){const t=r[0][M];if(c){const e=u(t),[r,a,i]=n(e,c);return[r,a,i,255]}{const e=h(t,a);return[e,e,e,255]}}return 3===m?[h(r[0][M],a),h(r[1][M],a),h(r[2][M],a),255]:m>=4?[h(r[0][M],a),h(r[1][M],a),h(r[2][M],a),h(r[3][M],a)]:null}function f(t,e,r,a,i,o,s,l,c){const f=t-s,d=e-l;if(f<0||f>=i-1||d<0||d>=o-1)return null;const M=Math.floor(f),m=Math.ceil(f),g=Math.floor(d),p=Math.ceil(d),y=f-M,b=d-g,v=r.length,w=[0,0,0,255];if(1===v){const t=r[0],e=(t[g*i+M]*(1-y)+t[g*i+m]*y)*(1-b)+(t[p*i+M]*(1-y)+t[p*i+m]*y)*b;if(c){const t=u(e),[r,a,i]=n(t,c);return[r,a,i,255]}{const t=h(e,a);return[t,t,t,255]}}{const t=Math.min(v,4);for(let e=0;e<t;e++){const t=r[e];w[e]=h((t[g*i+M]*(1-y)+t[g*i+m]*y)*(1-b)+(t[p*i+M]*(1-y)+t[p*i+m]*y)*b,a)}}return w}class d{config;worldSize=40075016.686;globalTriangulation;constructor(t){this.config=t,t.worldSize&&(this.worldSize=t.worldSize)}createGlobalTriangulation(){const t=performance.now(),[r,n,a,i]=this.config.sourceBounds,{source:o}=s(null,null,[r,n,a,i],(t=>this.config.transformSourceMapToViewFn(t))),h=[o.minX,o.minY,o.maxX,o.maxY];e("Creating global triangulation for bounds:",{source:this.config.sourceBounds,mercator:h});const u=this.config.resolution/2,c=Math.min(10,Math.max(this.config.imageWidth,this.config.imageHeight)/256);this.globalTriangulation=new l((t=>this.config.transformViewToSourceMapFn(t)),h,u,this.config.sourceRef,this.config.resolution,c),this.globalTriangulation.findSourceTriangleForTargetPoint([0,0]);const f=this.globalTriangulation.getTriangles();e(`Global triangulation created: ${f.length} triangles in ${(performance.now()-t).toFixed(2)}ms`)}getGlobalTriangulation(){return this.globalTriangulation}sanitizeElevationValue(t){return Number.isFinite(t)?void 0!==this.config.noDataValue&&t===this.config.noDataValue?0:t:0}getTileSizeInMeter(t){return this.worldSize/Math.pow(2,t)}getTileBounds(t,e,r){const n=this.getTileSizeInMeter(r),a=-this.worldSize/2+t*n,i=this.worldSize/2-e*n;return[a,i-n,a+n,i]}selectOverviewImage(t,e){const r=this.config.baseImage.getResolution()[0];if(!this.config.overviewImages||0===this.config.overviewImages.length)return{bestImage:this.config.baseImage,bestResolution:r,imageLevel:0};const n=this.getTileSizeInMeter(t)/e,a=[this.config.baseImage,...this.config.overviewImages],i=a[this.config.overviewImages.length],o=r*Math.pow(2,this.config.overviewImages.length);let s=this.config.overviewImages.length,l=o,h=i,u=0,c=r;for(const t of a){if(n/(2*c)<=1){h=t,l=c,s=u;break}u++,c*=2}return{bestImage:h,bestResolution:l,imageLevel:s}}calculateTileSourceBounds(t){const[e,r,n,a]=t,{source:i}=s(this.config.sourceRef,this.config.resolution,[e,r,n,a],this.config.transformViewToSourceMapFn),o=this.config.transformViewToSourceMapFn([e,r]),l=this.config.transformViewToSourceMapFn([n,a]),h=this.config.transformViewToSourceMapFn([e,a]),u=this.config.transformViewToSourceMapFn([n,r]);return{tileSrcWest:Math.min(i.minX,o[0],l[0],h[0],u[0]),tileSrcEast:Math.max(i.maxX,o[0],l[0],h[0],u[0]),tileSrcSouth:Math.min(i.minY,o[1],l[1],h[1],u[1]),tileSrcNorth:Math.max(i.maxY,o[1],l[1],h[1],u[1])}}calculateReadWindow(e,r,n){const[a,i,o,s]=this.config.sourceBounds,l=o-a,h=s-i,{tileSrcWest:u,tileSrcEast:c,tileSrcSouth:f,tileSrcNorth:d}=e,M=Math.floor((u-a)/l*r),m=Math.ceil((c-a)/l*r),g=Math.floor((s-d)/h*n),p=Math.ceil((s-f)/h*n),y=Math.min(r,Math.max(0,M-2)),b=Math.max(0,Math.min(r,m+2)),v=Math.min(n,Math.max(0,g-2)),w=Math.max(0,Math.min(n,p+2)),S=b-y,x=w-v;return S<=0||x<=0?(t("Invalid read window for tile",{readXMin:y,readXMax:b,readYMin:v,readYMax:w,ovWidth:r,ovHeight:n}),null):{readXMin:y,readXMax:b,readYMin:v,readYMax:w,readWidth:S,readHeight:x}}async loadAndConvertRasterData(r,n){const{readXMin:a,readYMin:i,readXMax:o,readYMax:s}=n;let l=null,h=null;for(let t=0;t<=2;t++){try{l=await r.readRasters({window:[a,i,o,s]})}catch(t){h=t}if(null!=l){h=null;break}}if(null!=h)throw e(h),t("Error - readRasters - read window: ",n),h;const u=[];let c="";for(let e=0;e<l.length;e++){const r=l[e];"number"!=typeof r?(u.push(r),0===e&&(c=r.constructor.name)):t("Unexpected number in rasters array")}return{rasterBands:u,arrayType:c}}renderTilePixels(t){const{sampleSize:e,mercatorBounds:r,triangulation:n,rasterBands:a,arrayType:i,readWindow:o,ovWidth:s,ovHeight:l,resampleMethod:h,colorStops:u}=t,[d,M,m,g]=r,[p,y,b,v]=this.config.sourceBounds,w=b-p,S=v-y,x=new Uint8ClampedArray(e*e*4);let $=null;for(let t=0;t<e;t++)for(let r=0;r<e;r++){const T=4*(t*e+r),P=d+r/e*(m-d),j=g-t/e*(g-M);if($=n.findSourceTriangleForTargetPoint([P,j],$),$){const[t,e]=n.applyAffineTransform(P,j,$.transform);if(t<p||t>b||e<y||e>v)x[T]=0,x[T+1]=0,x[T+2]=0,x[T+3]=0;else{const r=(t-p)/w*s,n=(v-e)/S*l,d="near"===h?c(r,n,a,i,o.readWidth,o.readHeight,o.readXMin,o.readYMin,u):f(r,n,a,i,o.readWidth,o.readHeight,o.readXMin,o.readYMin,u);d?(x[T]=d[0],x[T+1]=d[1],x[T+2]=d[2],x[T+3]=d[3]):(x[T]=0,x[T+1]=0,x[T+2]=0,x[T+3]=0)}}else x[T]=0,x[T+1]=0,x[T+2]=0,x[T+3]=0}return x}tileIntersectsSource(t){const[e,r,n,a]=t,[i,o,s,l]=this.config.sourceBounds,h=this.config.transformViewToSourceMapFn([e,r]),u=this.config.transformViewToSourceMapFn([n,a]),c=this.config.transformViewToSourceMapFn([e,a]),f=this.config.transformViewToSourceMapFn([n,r]),d=Math.min(h[0],u[0],c[0],f[0]),M=Math.max(h[0],u[0],c[0],f[0]),m=Math.min(h[1],u[1],c[1],f[1]),g=Math.max(h[1],u[1],c[1],f[1]);return M>=i&&d<=s&&g>=o&&m<=l}async getTileData(r){const{x:n,y:a,z:i,tileSize:o,resolution:s,resampleMethod:h,colorStops:u}=r,c=this.getTileBounds(n,a,i);if(e(`v-map - geotiff - getTileData(${n},${a},${i}): viewBounds=[${c.map((t=>t.toFixed(0))).join(",")}], sourceBounds=[${this.config.sourceBounds.map((t=>t.toFixed(0))).join(",")}], toProjection=${this.config.toProjection}`),!this.tileIntersectsSource(c)){e(`v-map - geotiff - getTileData(${n},${a},${i}): no intersection, returning transparent`);const t=Math.ceil(o*s);return new Uint8ClampedArray(t*t*4)}const f=Math.ceil(o*s);let d;this.globalTriangulation?d=this.globalTriangulation:(t("Global triangulation not available, creating fallback for tile"),d=new l(this.config.transformViewToSourceMapFn,c,.5));const M=this.calculateTileSourceBounds(c),{bestImage:m,bestResolution:g,imageLevel:p}=this.selectOverviewImage(i,o),y=m.getWidth(),b=m.getHeight(),v=this.calculateReadWindow(M,y,b);if(!v)return new Uint8ClampedArray(f*f*4);const{rasterBands:w,arrayType:S}=await this.loadAndConvertRasterData(m,v);return e(`Read window: [${v.readXMin}, ${v.readYMin}, ${v.readXMax}, ${v.readYMax}] (${v.readWidth}x${v.readHeight} pixels), ${w.length} bands, type: ${S}, imageLevel: ${p}, resolution: ${g}`),this.renderTilePixels({sampleSize:f,mercatorBounds:c,triangulation:d,rasterBands:w,arrayType:S,readWindow:v,ovWidth:y,ovHeight:b,resampleMethod:h,colorStops:u})}async getElevationData(e){const{x:r,y:n,z:a,tileSize:i}=e,o=i+1,s=this.getTileBounds(r,n,a);if(!this.tileIntersectsSource(s))return new Float32Array(o*o);let h;this.globalTriangulation?h=this.globalTriangulation:(t("Global triangulation not available, creating fallback for elevation tile"),h=new l(this.config.transformViewToSourceMapFn,s,.5));const u=this.calculateTileSourceBounds(s),{bestImage:c}=this.selectOverviewImage(a,i),f=c.getWidth(),d=c.getHeight(),M=this.calculateReadWindow(u,f,d);if(!M)return new Float32Array(o*o);const{rasterBands:m}=await this.loadAndConvertRasterData(c,M),[g,p,y,b]=s,[v,w,S,x]=this.config.sourceBounds,$=S-v,T=x-w,P=new Float32Array(o*o);let j=null;for(let t=0;t<i;t++)for(let e=0;e<i;e++){const r=g+e/i*(y-g),n=b-t/i*(b-p);if(j=h.findSourceTriangleForTargetPoint([r,n],j),j){const[a,i]=h.applyAffineTransform(r,n,j.transform);if(a>=v&&a<=S&&i>=w&&i<=x){const r=(x-i)/T*d,n=Math.round((a-v)/$*f)-M.readXMin,s=Math.round(r)-M.readYMin;if(n>=0&&n<M.readWidth&&s>=0&&s<M.readHeight){const r=Number(m[0][s*M.readWidth+n]);P[t*o+e]=this.sanitizeElevationValue(r)}}}}for(let t=0;t<i;t++)P[t*o+i]=P[t*o+i-1];for(let t=0;t<=i;t++)P[i*o+t]=P[(i-1)*o+t];return P}}async function M(t,e){const{default:r}=await import("./p-RpJarvr_.js");return{transformViewToSourceMapFn:n=>{const a=r(e,t.fromProjection,n);return[Number(a[0]),Number(a[1])]},transformSourceMapToViewFn:n=>{const a=r(t.fromProjection,e,n);return[Number(a[0]),Number(a[1])]},sourceBounds:t.sourceBounds,sourceRef:t.sourceRef,resolution:t.resolution,imageWidth:t.width,imageHeight:t.height,fromProjection:t.fromProjection,toProjection:e,baseImage:t.baseImage,overviewImages:t.overviewImages??[],noDataValue:t.noDataValue}}async function m(r,n,a){const{geotiff:i,proj4:o,geokeysToProj4:s}=a,{fromUrl:l}=i,{toProj4:h}=s;let u=null,c=null;for(let t=0;t<=2;t++){try{u=await l(r,{allowFullFile:!0,blockSize:1048576,cacheSize:100})}catch(t){c=t}if(null!=u){c=null;break}}if(null!=c)throw e(c),t("Error - loadGeoTIFFSource - fromUrl: ",r),c;const f=await u.getImage(0),d=await u.getImageCount(),M=[];for(let t=1;t<d;t++)M.push(await u.getImage(t));const m=f.getWidth(),g=f.getHeight(),p=Math.max(1,f.getSamplesPerPixel?.()??1);let y=n.forceProjection&&n.projection?n.projection:n.projection??"EPSG:4326",b=null;if(!n.forceProjection){const e="function"==typeof f.getGeoKeys?f.getGeoKeys()??null:null;if(e)try{const t=h(e),r=e.ProjectedCSTypeGeoKey??e.GeographicTypeGeoKey;if(r&&(y=`EPSG:${r}`),t?.proj4){b=t.proj4;const e=String(r);r&&!o.defs(y)&&o.defs(y,t.proj4),r&&!o.defs(e)&&o.defs(e,t.proj4)}}catch(e){t("v-map - geotiff - failed to parse GeoKeys",e)}}if(!b)switch(y){case"EPSG:4326":b="+proj=longlat +datum=WGS84 +no_defs";break;case"EPSG:3857":b="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs";break;case"EPSG:32632":b="+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs"}y&&""!==y.trim()||(y="EPSG:4326"),b&&!o.defs(y)&&o.defs(y,b);const v=f.getBoundingBox(),w=[v[0],v[1]],S=f.getResolution()[0],x=null!=n.nodata?Number(n.nodata):"function"==typeof f.getGDALNoData?f.getGDALNoData():void 0,$=null!=x?Number(x):void 0,T=t=>Math.max(-180,Math.min(180,Number.isFinite(t)?t:0)),P=t=>Math.max(-90,Math.min(90,Number.isFinite(t)?t:0));let j;j=y&&"EPSG:4326"!==y?e=>{try{const t=o(y,"EPSG:4326",e);return[Number(t[0]),Number(t[1])]}catch(r){return t("v-map - geotiff - transform to WGS84 failed, falling back",r),e}}:t=>t;const[F,I,N,G]=v,k=[j([F,I]),j([N,I]),j([N,G]),j([F,G])],A=T(Math.min(...k.map((t=>t[0])))),E=T(Math.max(...k.map((t=>t[0])))),B=P(Math.min(...k.map((t=>t[1])))),_=P(Math.max(...k.map((t=>t[1]))));return e("v-map - geotiff - loaded source",{url:r,width:m,height:g,samplesPerPixel:p,fromProjection:y,bounds:v}),{tiff:u,baseImage:f,overviewImages:M,width:m,height:g,samplesPerPixel:p,fromProjection:y,sourceBounds:v,sourceRef:w,resolution:S,proj4:o,noDataValue:$,wgs84Bounds:[A,B,E,_],transformToWgs84:j}}async function g(t,e,r,n){const[a,{default:i},o]=await Promise.all([import("./p-Be3r33VF.js").then((function(t){return t.g})),import("./p-RpJarvr_.js"),import("./p-CXfA_q8m.js").then((function(t){return t.m}))]);return await m(t,{projection:e,forceProjection:r,nodata:n},{geotiff:a,proj4:i,geokeysToProj4:o})}export{d as G,g as a,M as b,a as g,m as l}
1
+ import{w as t,l as e}from"./p-QJHuuz0g.js";const r={grayscale:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}],viridis:[{value:0,color:[68,1,84]},{value:.25,color:[59,82,139]},{value:.5,color:[33,145,140]},{value:.75,color:[94,201,98]},{value:1,color:[253,231,37]}],terrain:[{value:0,color:[0,128,0]},{value:.25,color:[139,195,74]},{value:.5,color:[255,235,59]},{value:.75,color:[255,152,0]},{value:1,color:[255,255,255]}],turbo:[{value:0,color:[48,18,59]},{value:.2,color:[33,102,172]},{value:.4,color:[68,190,112]},{value:.6,color:[253,231,37]},{value:.8,color:[234,51,35]},{value:1,color:[122,4,3]}],rainbow:[{value:0,color:[148,0,211]},{value:.2,color:[0,0,255]},{value:.4,color:[0,255,0]},{value:.6,color:[255,255,0]},{value:.8,color:[255,127,0]},{value:1,color:[255,0,0]}]};function n(t,e){const r=Math.max(0,Math.min(1,t));if(0===e.length)return[0,0,0];if(1===e.length)return e[0].color;let n=0,a=e.length-1;if(r<=e[n].value)return e[n].color;if(r>=e[a].value)return e[a].color;for(;a-n>1;){const t=Math.floor((n+a)/2);e[t].value<=r?n=t:a=t}const i=e[n],o=e[a],s=(r-i.value)/(o.value-i.value);return[Math.round(i.color[0]+s*(o.color[0]-i.color[0])),Math.round(i.color[1]+s*(o.color[1]-i.color[1])),Math.round(i.color[2]+s*(o.color[2]-i.color[2]))]}function a(e,n){if("string"==typeof e){const n=r[e];return n?{stops:n}:(t(`Unknown colormap: ${e}, using grayscale`),{stops:r.grayscale})}return function(e,n){const a=e.colorMapEntries||[];if(0===a.length)return t("GeoStyler ColorMap has no entries, using grayscale"),{stops:r.grayscale};const i=a.map((t=>t.quantity)).filter((t=>"number"==typeof t));let o,s;n?[o,s]=n:i.length>0?(o=Math.min(...i),s=Math.max(...i)):(o=0,s=1),s===o&&(s=o+1);const l=a.map((e=>{const r=(("number"==typeof e.quantity?e.quantity:0)-o)/(s-o),n=function(e){let r=e.trim();if(r.startsWith("#")&&(r=r.slice(1)),3===r.length&&(r=r.split("").map((t=>t+t)).join("")),6!==r.length)return t(`Invalid hex color: ${e}, using black`),[0,0,0];const n=parseInt(r.slice(0,2),16),a=parseInt(r.slice(2,4),16),i=parseInt(r.slice(4,6),16);return isNaN(n)||isNaN(a)||isNaN(i)?(t(`Invalid hex color: ${e}, using black`),[0,0,0]):[n,a,i]}("string"==typeof e.color?e.color:String(e.color));return{value:Math.max(0,Math.min(1,r)),color:n}}));return l.sort(((t,e)=>t.value-e.value)),{stops:l,computedRange:n?void 0:[o,s]}}(e,n)}class i{min;max;constructor(t,e){this.min=t,this.max=e}contains(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}static fromTriangle(t){const e=Math.min(t.a.x,t.b.x,t.c.x),r=Math.min(t.a.y,t.b.y,t.c.y),n=Math.max(t.a.x,t.b.x,t.c.x),a=Math.max(t.a.y,t.b.y,t.c.y);return new i({x:e,y:r},{x:n,y:a})}static union(t,e){return new i({x:Math.min(t.min.x,e.min.x),y:Math.min(t.min.y,e.min.y)},{x:Math.max(t.max.x,e.max.x),y:Math.max(t.max.y,e.max.y)})}}class o{bbox;triangles;left;right;constructor(t,e=[],r=null,n=null){this.bbox=t,this.triangles=e,this.left=r,this.right=n}static build(t,e=0,r=10){if(t.length<=2||e>=r){let e=i.fromTriangle(t[0]);for(let r=1;r<t.length;r++)e=i.union(e,i.fromTriangle(t[r]));return new o(e,t)}const n=t.map((t=>({x:(t.a.x+t.b.x+t.c.x)/3,y:(t.a.y+t.b.y+t.c.y)/3}))),{min:a,max:s}=n.reduce(((t,e)=>({min:{x:Math.min(t.min.x,e.x),y:Math.min(t.min.y,e.y)},max:{x:Math.max(t.max.x,e.x),y:Math.max(t.max.y,e.y)}})),{min:n[0],max:n[0]}),l=s.x-a.x>s.y-a.y?"x":"y";n.sort(((t,e)=>t[l]-e[l]));const h=Math.floor(n.length/2),u=[],c=[];for(let e=0;e<t.length;e++)(e<h?u:c).push(t[e]);const f=o.build(u,e+1,r),d=o.build(c,e+1,r),M=i.union(f.bbox,d.bbox);return new o(M,[],f,d)}findContainingTriangle(t){if(!this.bbox.contains(t))return null;if(this.triangles.length>0){for(const e of this.triangles)if(o.punktInDreieck2D(t,e))return e;return null}return this.left?.findContainingTriangle(t)||this.right?.findContainingTriangle(t)||null}static punktInDreieck2D(t,e){const{a:r,b:n,c:a}=e,i=a.x-r.x,o=a.y-r.y,s=n.x-r.x,l=n.y-r.y,h=t.x-r.x,u=t.y-r.y,c=i*i+o*o,f=i*s+o*l,d=i*h+o*u,M=s*s+l*l,m=s*h+l*u,g=1/(c*M-f*f),p=(M*d-f*m)*g,y=(c*m-f*d)*g;return p>=0&&y>=0&&p+y<=1}static toTriangle2D(t){return{a:{x:t.target[0][0],y:t.target[0][1]},b:{x:t.target[1][0],y:t.target[1][1]},c:{x:t.target[2][0],y:t.target[2][1]},triangle:t,transform:null}}toString(t=""){const e=this.triangles.length>0;let r=`${t}${e?"LEAF":"NODE"} bbox=[${this.bbox.min.x.toFixed(2)}, ${this.bbox.min.y.toFixed(2)}, ${this.bbox.max.x.toFixed(2)}, ${this.bbox.max.y.toFixed(2)}]`;if(e){const t=this.triangles.map((t=>t.a.x.toFixed(2)+","+t.a.y.toFixed(2)+" "+t.b.x.toFixed(2)+","+t.b.y.toFixed(2)+" "+t.c.x.toFixed(2)+","+t.c.y.toFixed(2))).toString();r+=` triangles=${this.triangles.length} - ${t}`}else r+="\n",this.left&&(r+=`${t}├─ left:\n${this.left.toString(t+"│ ")}`),this.right&&(r+=`${t}└─ right:\n${this.right.toString(t+" ")}`);return r}getStats(){const t={depth:1,nodeCount:1,leafCount:0,triangleCount:this.triangles.length,minTrianglesPerLeaf:1/0,maxTrianglesPerLeaf:0};if(this.triangles.length>0)t.leafCount=1,t.minTrianglesPerLeaf=this.triangles.length,t.maxTrianglesPerLeaf=this.triangles.length;else{if(this.left){const e=this.left.getStats();t.depth=Math.max(t.depth,e.depth+1),t.nodeCount+=e.nodeCount,t.leafCount+=e.leafCount,t.triangleCount+=e.triangleCount,t.minTrianglesPerLeaf=Math.min(t.minTrianglesPerLeaf,e.minTrianglesPerLeaf),t.maxTrianglesPerLeaf=Math.max(t.maxTrianglesPerLeaf,e.maxTrianglesPerLeaf)}if(this.right){const e=this.right.getStats();t.depth=Math.max(t.depth,e.depth+1),t.nodeCount+=e.nodeCount,t.leafCount+=e.leafCount,t.triangleCount+=e.triangleCount,t.minTrianglesPerLeaf=Math.min(t.minTrianglesPerLeaf,e.minTrianglesPerLeaf),t.maxTrianglesPerLeaf=Math.max(t.maxTrianglesPerLeaf,e.maxTrianglesPerLeaf)}}return t}}function s(t,e,r,n,a=10){const[i,o,s,l]=r;let h=1/0,u=1/0,c=-1/0,f=-1/0,d=[0,0],M=[0,0],m=[0,0],g=[0,0];const p=(t,e,r)=>{for(let a=0;a<=r;a++){const i=a/r,o=[t[0]+(e[0]-t[0])*i,t[1]+(e[1]-t[1])*i],[s,l]=n(o);s<h&&(h=s,d=o),l<u&&(u=l,M=o),s>c&&(c=s,m=o),l>f&&(f=l,g=o)}};if(p([i,l],[s,l],a),p([s,l],[s,o],a),p([s,o],[i,o],a),p([i,o],[i,l],a),null!=t&&null!=e){const r=Math.floor((h-t[0])/e);h=t[0]+r*e;const n=Math.floor((u-t[1])/e);u=t[1]+n*e;const a=Math.ceil((c-t[0])/e);c=t[0]+a*e;const i=Math.ceil((f-t[1])/e);f=t[1]+i*e}return{source:{minX:h,minY:u,maxX:c,maxY:f},target:{minX:d[0],minY:M[1],maxX:m[0],maxY:g[1]}}}class l{triangles_=[];transformFn_;errorThresholdSquared_;bvh_=null;bounds;constructor(t,e,r=.5,n=null,a=null,i=10){this.transformFn_=t,this.errorThresholdSquared_=r*r;const[o,l,h,u]=e,c=[o,u],f=[h,u],d=[h,l],M=[o,l],m=s(n,a,e,this.transformFn_,i),g=[m.source.minX,m.source.maxY],p=[m.source.maxX,m.source.maxY],y=[m.source.maxX,m.source.minY],b=[m.source.minX,m.source.minY];this.bounds=m.source,this.addQuad_(c,f,d,M,g,p,y,b,10)}getBounds(){return this.bounds}addQuad_(t,e,r,n,a,i,o,s,l){let h=!1;if(l>0){const l=[(e[0]+r[0])/2,(e[1]+r[1])/2],u=[(r[0]+n[0])/2,(r[1]+n[1])/2],c=[(n[0]+t[0])/2,(n[1]+t[1])/2],f=this.transformFn_([(t[0]+e[0])/2,(t[1]+e[1])/2]),d=this.transformFn_(l),M=this.transformFn_(u),m=this.transformFn_(c),g=[(i[0]+o[0])/2,(i[1]+o[1])/2],p=[(o[0]+s[0])/2,(o[1]+s[1])/2],y=[(s[0]+a[0])/2,(s[1]+a[1])/2],b=this.getSquaredError_(f,[(a[0]+i[0])/2,(a[1]+i[1])/2]),v=this.getSquaredError_(d,g),w=this.getSquaredError_(M,p),S=this.getSquaredError_(m,y);(b>this.errorThresholdSquared_||v>this.errorThresholdSquared_||w>this.errorThresholdSquared_||S>this.errorThresholdSquared_)&&(h=!0)}if(h){const h=[(t[0]+e[0]+r[0]+n[0])/4,(t[1]+e[1]+r[1]+n[1])/4],u=this.transformFn_(h),c=[(t[0]+e[0])/2,(t[1]+e[1])/2],f=[(e[0]+r[0])/2,(e[1]+r[1])/2],d=[(r[0]+n[0])/2,(r[1]+n[1])/2],M=[(n[0]+t[0])/2,(n[1]+t[1])/2],m=this.transformFn_(c),g=this.transformFn_(f),p=this.transformFn_(d),y=this.transformFn_(M),b=l-1;this.addQuad_(t,c,h,M,a,m,u,y,b),this.addQuad_(c,e,f,h,m,i,g,u,b),this.addQuad_(h,f,r,d,u,g,o,p,b),this.addQuad_(M,h,d,n,y,u,p,s,b)}else this.addTriangle_(t,e,n,a,i,s),this.addTriangle_(e,r,n,i,o,s)}addTriangle_(t,e,r,n,a,i){isFinite(n[0])&&isFinite(n[1])&&isFinite(a[0])&&isFinite(a[1])&&isFinite(i[0])&&isFinite(i[1])&&this.triangles_.push({source:[n,a,i],target:[t,e,r]})}getSquaredError_(t,e){const r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}getTriangles(){return this.triangles_}calculateSourceExtent(){if(0===this.triangles_.length)return null;let t=1/0,e=1/0,r=-1/0,n=-1/0;for(const a of this.triangles_)for(const[i,o]of a.source)i<t&&(t=i),i>r&&(r=i),o<e&&(e=o),o>n&&(n=o);return[t,e,r,n]}buildBVH(){const t=this.triangles_.map(o.toTriangle2D);this.bvh_=o.build(t)}findSourceTriangleForTargetPoint(t,e=null){this.bvh_||this.buildBVH();const r={x:t[0],y:t[1]};if(e?.tri&&o.punktInDreieck2D(r,o.toTriangle2D(e.tri)))return e;const n=this.bvh_.findContainingTriangle(r);return n&&!n.transform&&(n.transform=this.calculateAffineTransform(n.triangle)),n?{tri:n.triangle,transform:n.transform}:null}calculateAffineTransform(t){const[[e,r],[n,a],[i,o]]=t.target,[[s,l],[h,u],[c,f]]=t.source,d=(n-e)*(o-r)-(i-e)*(a-r);if(Math.abs(d)<1e-10)return{a:1,b:0,c:s,d:0,e:1,f:l};const M=((h-s)*(o-r)-(c-s)*(a-r))/d,m=((c-s)*(n-e)-(h-s)*(i-e))/d,g=((u-l)*(o-r)-(f-l)*(a-r))/d,p=((f-l)*(n-e)-(u-l)*(i-e))/d;return{a:M,b:m,c:s-M*e-m*r,d:g,e:p,f:l-g*e-p*r}}applyAffineTransform(t,e,r){return[r.a*t+r.b*e+r.c,r.d*t+r.e*e+r.f]}}function h(e,r){switch(r){case"Uint8Array":return e;case"Uint16Array":return Math.round(e/65535*255);case"Int16Array":return Math.round((e+32768)/65535*255);case"Uint32Array":return Math.round(e/4294967295*255);case"Int32Array":return Math.round((e+2147483648)/4294967295*255);case"Float32Array":case"Float64Array":const n=Math.max(0,Math.min(1,e));return Math.round(255*n);default:return t(`Unknown array type: ${r}, treating as Uint8`),e}}function u(t){return Math.max(0,Math.min(1,t))}function c(t,e,r,a,i,o,s,l,c){const f=Math.round(t)-s,d=Math.round(e)-l;if(f<0||f>=i||d<0||d>=o)return null;const M=d*i+f,m=r.length;if(1===m){const t=r[0][M];if(c){const e=u(t),[r,a,i]=n(e,c);return[r,a,i,255]}{const e=h(t,a);return[e,e,e,255]}}return 3===m?[h(r[0][M],a),h(r[1][M],a),h(r[2][M],a),255]:m>=4?[h(r[0][M],a),h(r[1][M],a),h(r[2][M],a),h(r[3][M],a)]:null}function f(t,e,r,a,i,o,s,l,c){const f=t-s,d=e-l;if(f<0||f>=i-1||d<0||d>=o-1)return null;const M=Math.floor(f),m=Math.ceil(f),g=Math.floor(d),p=Math.ceil(d),y=f-M,b=d-g,v=r.length,w=[0,0,0,255];if(1===v){const t=r[0],e=(t[g*i+M]*(1-y)+t[g*i+m]*y)*(1-b)+(t[p*i+M]*(1-y)+t[p*i+m]*y)*b;if(c){const t=u(e),[r,a,i]=n(t,c);return[r,a,i,255]}{const t=h(e,a);return[t,t,t,255]}}{const t=Math.min(v,4);for(let e=0;e<t;e++){const t=r[e];w[e]=h((t[g*i+M]*(1-y)+t[g*i+m]*y)*(1-b)+(t[p*i+M]*(1-y)+t[p*i+m]*y)*b,a)}}return w}class d{config;worldSize=40075016.686;globalTriangulation;constructor(t){this.config=t,t.worldSize&&(this.worldSize=t.worldSize)}createGlobalTriangulation(){const t=performance.now(),[r,n,a,i]=this.config.sourceBounds,{source:o}=s(null,null,[r,n,a,i],(t=>this.config.transformSourceMapToViewFn(t))),h=[o.minX,o.minY,o.maxX,o.maxY];e("Creating global triangulation for bounds:",{source:this.config.sourceBounds,mercator:h});const u=this.config.resolution/2,c=Math.min(10,Math.max(this.config.imageWidth,this.config.imageHeight)/256);this.globalTriangulation=new l((t=>this.config.transformViewToSourceMapFn(t)),h,u,this.config.sourceRef,this.config.resolution,c),this.globalTriangulation.findSourceTriangleForTargetPoint([0,0]);const f=this.globalTriangulation.getTriangles();e(`Global triangulation created: ${f.length} triangles in ${(performance.now()-t).toFixed(2)}ms`)}getGlobalTriangulation(){return this.globalTriangulation}sanitizeElevationValue(t){return Number.isFinite(t)?void 0!==this.config.noDataValue&&t===this.config.noDataValue?0:t:0}getTileSizeInMeter(t){return this.worldSize/Math.pow(2,t)}getTileBounds(t,e,r){const n=this.getTileSizeInMeter(r),a=-this.worldSize/2+t*n,i=this.worldSize/2-e*n;return[a,i-n,a+n,i]}selectOverviewImage(t,e){const r=this.config.baseImage.getResolution()[0];if(!this.config.overviewImages||0===this.config.overviewImages.length)return{bestImage:this.config.baseImage,bestResolution:r,imageLevel:0};const n=this.getTileSizeInMeter(t)/e,a=[this.config.baseImage,...this.config.overviewImages],i=a[this.config.overviewImages.length],o=r*Math.pow(2,this.config.overviewImages.length);let s=this.config.overviewImages.length,l=o,h=i,u=0,c=r;for(const t of a){if(n/(2*c)<=1){h=t,l=c,s=u;break}u++,c*=2}return{bestImage:h,bestResolution:l,imageLevel:s}}calculateTileSourceBounds(t){const[e,r,n,a]=t,{source:i}=s(this.config.sourceRef,this.config.resolution,[e,r,n,a],this.config.transformViewToSourceMapFn),o=this.config.transformViewToSourceMapFn([e,r]),l=this.config.transformViewToSourceMapFn([n,a]),h=this.config.transformViewToSourceMapFn([e,a]),u=this.config.transformViewToSourceMapFn([n,r]);return{tileSrcWest:Math.min(i.minX,o[0],l[0],h[0],u[0]),tileSrcEast:Math.max(i.maxX,o[0],l[0],h[0],u[0]),tileSrcSouth:Math.min(i.minY,o[1],l[1],h[1],u[1]),tileSrcNorth:Math.max(i.maxY,o[1],l[1],h[1],u[1])}}calculateReadWindow(e,r,n){const[a,i,o,s]=this.config.sourceBounds,l=o-a,h=s-i,{tileSrcWest:u,tileSrcEast:c,tileSrcSouth:f,tileSrcNorth:d}=e,M=Math.floor((u-a)/l*r),m=Math.ceil((c-a)/l*r),g=Math.floor((s-d)/h*n),p=Math.ceil((s-f)/h*n),y=Math.min(r,Math.max(0,M-2)),b=Math.max(0,Math.min(r,m+2)),v=Math.min(n,Math.max(0,g-2)),w=Math.max(0,Math.min(n,p+2)),S=b-y,x=w-v;return S<=0||x<=0?(t("Invalid read window for tile",{readXMin:y,readXMax:b,readYMin:v,readYMax:w,ovWidth:r,ovHeight:n}),null):{readXMin:y,readXMax:b,readYMin:v,readYMax:w,readWidth:S,readHeight:x}}async loadAndConvertRasterData(r,n){const{readXMin:a,readYMin:i,readXMax:o,readYMax:s}=n;let l=null,h=null;for(let t=0;t<=2;t++){try{l=await r.readRasters({window:[a,i,o,s]})}catch(t){h=t}if(null!=l){h=null;break}}if(null!=h)throw e(h),t("Error - readRasters - read window: ",n),h;const u=[];let c="";for(let e=0;e<l.length;e++){const r=l[e];"number"!=typeof r?(u.push(r),0===e&&(c=r.constructor.name)):t("Unexpected number in rasters array")}return{rasterBands:u,arrayType:c}}renderTilePixels(t){const{sampleSize:e,mercatorBounds:r,triangulation:n,rasterBands:a,arrayType:i,readWindow:o,ovWidth:s,ovHeight:l,resampleMethod:h,colorStops:u}=t,[d,M,m,g]=r,[p,y,b,v]=this.config.sourceBounds,w=b-p,S=v-y,x=new Uint8ClampedArray(e*e*4);let $=null;for(let t=0;t<e;t++)for(let r=0;r<e;r++){const T=4*(t*e+r),P=d+r/e*(m-d),j=g-t/e*(g-M);if($=n.findSourceTriangleForTargetPoint([P,j],$),$){const[t,e]=n.applyAffineTransform(P,j,$.transform);if(t<p||t>b||e<y||e>v)x[T]=0,x[T+1]=0,x[T+2]=0,x[T+3]=0;else{const r=(t-p)/w*s,n=(v-e)/S*l,d="near"===h?c(r,n,a,i,o.readWidth,o.readHeight,o.readXMin,o.readYMin,u):f(r,n,a,i,o.readWidth,o.readHeight,o.readXMin,o.readYMin,u);d?(x[T]=d[0],x[T+1]=d[1],x[T+2]=d[2],x[T+3]=d[3]):(x[T]=0,x[T+1]=0,x[T+2]=0,x[T+3]=0)}}else x[T]=0,x[T+1]=0,x[T+2]=0,x[T+3]=0}return x}tileIntersectsSource(t){const[e,r,n,a]=t,[i,o,s,l]=this.config.sourceBounds,h=this.config.transformViewToSourceMapFn([e,r]),u=this.config.transformViewToSourceMapFn([n,a]),c=this.config.transformViewToSourceMapFn([e,a]),f=this.config.transformViewToSourceMapFn([n,r]),d=Math.min(h[0],u[0],c[0],f[0]),M=Math.max(h[0],u[0],c[0],f[0]),m=Math.min(h[1],u[1],c[1],f[1]),g=Math.max(h[1],u[1],c[1],f[1]);return M>=i&&d<=s&&g>=o&&m<=l}async getTileData(r){const{x:n,y:a,z:i,tileSize:o,resolution:s,resampleMethod:h,colorStops:u}=r,c=this.getTileBounds(n,a,i);if(e(`v-map - geotiff - getTileData(${n},${a},${i}): viewBounds=[${c.map((t=>t.toFixed(0))).join(",")}], sourceBounds=[${this.config.sourceBounds.map((t=>t.toFixed(0))).join(",")}], toProjection=${this.config.toProjection}`),!this.tileIntersectsSource(c)){e(`v-map - geotiff - getTileData(${n},${a},${i}): no intersection, returning transparent`);const t=Math.ceil(o*s);return new Uint8ClampedArray(t*t*4)}const f=Math.ceil(o*s);let d;this.globalTriangulation?d=this.globalTriangulation:(t("Global triangulation not available, creating fallback for tile"),d=new l(this.config.transformViewToSourceMapFn,c,.5));const M=this.calculateTileSourceBounds(c),{bestImage:m,bestResolution:g,imageLevel:p}=this.selectOverviewImage(i,o),y=m.getWidth(),b=m.getHeight(),v=this.calculateReadWindow(M,y,b);if(!v)return new Uint8ClampedArray(f*f*4);const{rasterBands:w,arrayType:S}=await this.loadAndConvertRasterData(m,v);return e(`Read window: [${v.readXMin}, ${v.readYMin}, ${v.readXMax}, ${v.readYMax}] (${v.readWidth}x${v.readHeight} pixels), ${w.length} bands, type: ${S}, imageLevel: ${p}, resolution: ${g}`),this.renderTilePixels({sampleSize:f,mercatorBounds:c,triangulation:d,rasterBands:w,arrayType:S,readWindow:v,ovWidth:y,ovHeight:b,resampleMethod:h,colorStops:u})}async getElevationData(e){const{x:r,y:n,z:a,tileSize:i}=e,o=i+1,s=this.getTileBounds(r,n,a);if(!this.tileIntersectsSource(s))return new Float32Array(o*o);let h;this.globalTriangulation?h=this.globalTriangulation:(t("Global triangulation not available, creating fallback for elevation tile"),h=new l(this.config.transformViewToSourceMapFn,s,.5));const u=this.calculateTileSourceBounds(s),{bestImage:c}=this.selectOverviewImage(a,i),f=c.getWidth(),d=c.getHeight(),M=this.calculateReadWindow(u,f,d);if(!M)return new Float32Array(o*o);const{rasterBands:m}=await this.loadAndConvertRasterData(c,M),[g,p,y,b]=s,[v,w,S,x]=this.config.sourceBounds,$=S-v,T=x-w,P=new Float32Array(o*o);let j=null;for(let t=0;t<i;t++)for(let e=0;e<i;e++){const r=g+e/i*(y-g),n=b-t/i*(b-p);if(j=h.findSourceTriangleForTargetPoint([r,n],j),j){const[a,i]=h.applyAffineTransform(r,n,j.transform);if(a>=v&&a<=S&&i>=w&&i<=x){const r=(x-i)/T*d,n=Math.round((a-v)/$*f)-M.readXMin,s=Math.round(r)-M.readYMin;if(n>=0&&n<M.readWidth&&s>=0&&s<M.readHeight){const r=Number(m[0][s*M.readWidth+n]);P[t*o+e]=this.sanitizeElevationValue(r)}}}}for(let t=0;t<i;t++)P[t*o+i]=P[t*o+i-1];for(let t=0;t<=i;t++)P[i*o+t]=P[(i-1)*o+t];return P}}async function M(t,e){const{default:r}=await import("./p-RpJarvr_.js");return{transformViewToSourceMapFn:n=>{const a=r(e,t.fromProjection,n);return[Number(a[0]),Number(a[1])]},transformSourceMapToViewFn:n=>{const a=r(t.fromProjection,e,n);return[Number(a[0]),Number(a[1])]},sourceBounds:t.sourceBounds,sourceRef:t.sourceRef,resolution:t.resolution,imageWidth:t.width,imageHeight:t.height,fromProjection:t.fromProjection,toProjection:e,baseImage:t.baseImage,overviewImages:t.overviewImages??[],noDataValue:t.noDataValue}}async function m(r,n,a){const{geotiff:i,proj4:o,geokeysToProj4:s}=a,{fromUrl:l}=i,{toProj4:h}=s;let u=null,c=null;for(let t=0;t<=2;t++){try{u=await l(r,{allowFullFile:!0,blockSize:1048576,cacheSize:100})}catch(t){c=t}if(null!=u){c=null;break}}if(null!=c)throw e(c),t("Error - loadGeoTIFFSource - fromUrl: ",r),c;const f=await u.getImage(0),d=await u.getImageCount(),M=[];for(let t=1;t<d;t++)M.push(await u.getImage(t));const m=f.getWidth(),g=f.getHeight(),p=Math.max(1,f.getSamplesPerPixel?.()??1);let y=n.forceProjection&&n.projection?n.projection:n.projection??"EPSG:4326",b=null;if(!n.forceProjection){const e="function"==typeof f.getGeoKeys?f.getGeoKeys()??null:null;if(e)try{const t=h(e),r=e.ProjectedCSTypeGeoKey??e.GeographicTypeGeoKey;if(r&&(y=`EPSG:${r}`),t?.proj4){b=t.proj4;const e=String(r);r&&!o.defs(y)&&o.defs(y,t.proj4),r&&!o.defs(e)&&o.defs(e,t.proj4)}}catch(e){t("v-map - geotiff - failed to parse GeoKeys",e)}}if(!b)switch(y){case"EPSG:4326":b="+proj=longlat +datum=WGS84 +no_defs";break;case"EPSG:3857":b="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs";break;case"EPSG:32632":b="+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs"}y&&""!==y.trim()||(y="EPSG:4326"),b&&!o.defs(y)&&o.defs(y,b);const v=f.getBoundingBox(),w=[v[0],v[1]],S=f.getResolution()[0],x=null!=n.nodata?Number(n.nodata):"function"==typeof f.getGDALNoData?f.getGDALNoData():void 0,$=null!=x?Number(x):void 0,T=t=>Math.max(-180,Math.min(180,Number.isFinite(t)?t:0)),P=t=>Math.max(-90,Math.min(90,Number.isFinite(t)?t:0));let j;j=y&&"EPSG:4326"!==y?e=>{try{const t=o(y,"EPSG:4326",e);return[Number(t[0]),Number(t[1])]}catch(r){return t("v-map - geotiff - transform to WGS84 failed, falling back",r),e}}:t=>t;const[F,I,N,G]=v,k=[j([F,I]),j([N,I]),j([N,G]),j([F,G])],A=T(Math.min(...k.map((t=>t[0])))),E=T(Math.max(...k.map((t=>t[0])))),B=P(Math.min(...k.map((t=>t[1])))),_=P(Math.max(...k.map((t=>t[1]))));return e("v-map - geotiff - loaded source",{url:r,width:m,height:g,samplesPerPixel:p,fromProjection:y,bounds:v}),{tiff:u,baseImage:f,overviewImages:M,width:m,height:g,samplesPerPixel:p,fromProjection:y,sourceBounds:v,sourceRef:w,resolution:S,proj4:o,noDataValue:$,wgs84Bounds:[A,B,E,_],transformToWgs84:j}}async function g(t,e,r,n){const[a,{default:i},o]=await Promise.all([import("./p-Be3r33VF.js").then((function(t){return t.g})),import("./p-RpJarvr_.js"),import("./p-CXfA_q8m.js").then((function(t){return t.m}))]);return await m(t,{projection:e,forceProjection:r,nodata:n},{geotiff:a,proj4:i,geokeysToProj4:o})}export{d as G,g as a,M as b,a as g,m as l}
@@ -1 +1 @@
1
- import{p as e,b as o}from"./p-jzneDarq.js";export{s as setNonce}from"./p-jzneDarq.js";import{g as a}from"./p-DQuL1Twl.js";(()=>{const o=import.meta.url,a={};return""!==o&&(a.resourcesUrl=new URL(".",o).href),e(a)})().then((async e=>(await a(),o([["p-aa410e64",[[769,"v-map-builder",{mapconfig:[1040]},null,{mapconfig:[{onMapConfigChanged:0}]}]]],["p-6b102336",[[769,"v-map-layer-terrain-geotiff",{loadState:[1537,"load-state"],url:[1],projection:[1],forceProjection:[4,"force-projection"],visible:[4],opacity:[2],zIndex:[2,"z-index"],nodata:[2],meshMaxError:[2,"mesh-max-error"],wireframe:[4],texture:[1],color:[16],colorMap:[1,"color-map"],valueRange:[16],elevationScale:[2,"elevation-scale"],renderMode:[1,"render-mode"],minZoom:[2,"min-zoom"],maxZoom:[2,"max-zoom"],tileSize:[2,"tile-size"],getError:[64],getLayerId:[64]},null,{url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],projection:[{onPropertyChanged:0}],forceProjection:[{onPropertyChanged:0}],nodata:[{onPropertyChanged:0}],meshMaxError:[{onPropertyChanged:0}],wireframe:[{onPropertyChanged:0}],texture:[{onPropertyChanged:0}],color:[{onPropertyChanged:0}],colorMap:[{onPropertyChanged:0}],valueRange:[{onPropertyChanged:0}],elevationScale:[{onPropertyChanged:0}],renderMode:[{onPropertyChanged:0}],minZoom:[{onPropertyChanged:0}],maxZoom:[{onPropertyChanged:0}],tileSize:[{onPropertyChanged:0}]}]]],["p-c21c93fe",[[513,"v-map-layercontrol",{for:[1],layerGroups:[32]}]]],["p-09d10db0",[[769,"v-map",{flavour:[513],center:[1],zoom:[2],useDefaultImportMap:[4,"use-default-import-map"],cssMode:[1,"css-mode"],isMapProviderReady:[64],setView:[64]},null,{flavour:[{onFlavourChanged:0}]}],[513,"v-map-layer-osm",{loadState:[1537,"load-state"],visible:[516],opacity:[514],zIndex:[514,"z-index"],url:[513],getError:[64],getLayerId:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onUrlChanged:0}]}],[769,"v-map-layergroup",{visible:[516],opacity:[514],basemapid:[513],getGroupId:[64]},null,{visible:[{onVisibleChanged:0}],basemapid:[{onBaseMapIdChanged:0}]}]]],["p-5eba6058",[[769,"v-map-layer-geojson",{loadState:[1537,"load-state"],geojson:[1025],url:[513],visible:[516],zIndex:[514,"z-index"],opacity:[514],fillColor:[513,"fill-color"],fillOpacity:[514,"fill-opacity"],strokeColor:[513,"stroke-color"],strokeWidth:[514,"stroke-width"],strokeOpacity:[514,"stroke-opacity"],pointRadius:[514,"point-radius"],pointColor:[513,"point-color"],iconUrl:[513,"icon-url"],iconSize:[513,"icon-size"],textProperty:[513,"text-property"],textColor:[513,"text-color"],textSize:[514,"text-size"],getLayerId:[64],getError:[64]},[[4,"styleReady","onStyleReady"]],{geojson:[{onGeoJsonChanged:0}],url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],fillColor:[{onStyleChanged:0}],fillOpacity:[{onStyleChanged:0}],strokeColor:[{onStyleChanged:0}],strokeWidth:[{onStyleChanged:0}],strokeOpacity:[{onStyleChanged:0}],pointRadius:[{onStyleChanged:0}],pointColor:[{onStyleChanged:0}],iconUrl:[{onStyleChanged:0}],iconSize:[{onStyleChanged:0}],textProperty:[{onStyleChanged:0}],textColor:[{onStyleChanged:0}],textSize:[{onStyleChanged:0}]}],[513,"v-map-layer-geotiff",{loadState:[1537,"load-state"],url:[1],visible:[4],opacity:[2],zIndex:[2,"z-index"],nodata:[2],colorMap:[1,"color-map"],valueRange:[16],getError:[64],getLayerId:[64]},null,{url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],nodata:[{onNodataChanged:0}],colorMap:[{onColorMapChanged:0}],valueRange:[{onValueRangeChanged:0}]}],[513,"v-map-layer-google",{loadState:[1537,"load-state"],mapType:[513,"map-type"],apiKey:[513,"api-key"],language:[513],region:[513],visible:[516],opacity:[514],scale:[513],maxZoom:[514,"max-zoom"],styles:[1025],libraries:[513],getError:[64]},null,{styles:[{parseStyles:0}]}],[513,"v-map-layer-scatterplot",{loadState:[1537,"load-state"],data:[513],url:[513],getFillColor:[513,"get-fill-color"],getRadius:[514,"get-radius"],opacity:[514],visible:[516],getError:[64]}],[769,"v-map-layer-terrain",{loadState:[1537,"load-state"],elevationData:[513,"elevation-data"],texture:[513],elevationDecoder:[513,"elevation-decoder"],wireframe:[516],color:[513],minZoom:[514,"min-zoom"],maxZoom:[514,"max-zoom"],meshMaxError:[514,"mesh-max-error"],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],getError:[64],isReady:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],elevationData:[{onTerrainConfigChanged:0}],texture:[{onTerrainConfigChanged:0}],elevationDecoder:[{onTerrainConfigChanged:0}],wireframe:[{onTerrainConfigChanged:0}],color:[{onTerrainConfigChanged:0}],minZoom:[{onTerrainConfigChanged:0}],maxZoom:[{onTerrainConfigChanged:0}],meshMaxError:[{onTerrainConfigChanged:0}]}],[769,"v-map-layer-tile3d",{loadState:[1537,"load-state"],url:[513],tilesetOptions:[1,"tileset-options"],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],isReady:[64],getError:[64]},[[4,"styleReady","onStyleReady"]],{url:[{onUrlChanged:0}],tilesetOptions:[{onTilesetOptionsChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}]}],[769,"v-map-layer-wcs",{loadState:[1537,"load-state"],url:[513],coverageName:[513,"coverage-name"],format:[513],version:[513],projection:[513],resolutions:[513],params:[513],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],getError:[64],isReady:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onSourceChanged:0}],coverageName:[{onSourceChanged:0}],format:[{onSourceChanged:0}],version:[{onSourceChanged:0}],projection:[{onSourceChanged:0}],resolutions:[{onSourceChanged:0}],params:[{onSourceChanged:0}]}],[769,"v-map-layer-wfs",{loadState:[1537,"load-state"],url:[513],typeName:[513,"type-name"],version:[513],outputFormat:[513,"output-format"],srsName:[513,"srs-name"],params:[513],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],getError:[64],isReady:[64]},[[4,"styleReady","onStyleReady"]],{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onSourceChanged:0}],typeName:[{onSourceChanged:0}],version:[{onSourceChanged:0}],outputFormat:[{onSourceChanged:0}],srsName:[{onSourceChanged:0}],params:[{onSourceChanged:0}]}],[513,"v-map-layer-wkt",{loadState:[1537,"load-state"],wkt:[513],url:[513],visible:[516],opacity:[514],zIndex:[514,"z-index"],fillColor:[513,"fill-color"],fillOpacity:[514,"fill-opacity"],strokeColor:[513,"stroke-color"],strokeWidth:[514,"stroke-width"],strokeOpacity:[514,"stroke-opacity"],pointRadius:[514,"point-radius"],pointColor:[513,"point-color"],iconUrl:[513,"icon-url"],iconSize:[513,"icon-size"],textProperty:[513,"text-property"],textColor:[513,"text-color"],textSize:[514,"text-size"],getError:[64],getLayerId:[64]},[[4,"styleReady","onStyleReady"]],{wkt:[{onWktChanged:0}],url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],fillColor:[{onStyleChanged:0}],fillOpacity:[{onStyleChanged:0}],strokeColor:[{onStyleChanged:0}],strokeWidth:[{onStyleChanged:0}],strokeOpacity:[{onStyleChanged:0}],pointRadius:[{onStyleChanged:0}],pointColor:[{onStyleChanged:0}],iconUrl:[{onStyleChanged:0}],iconSize:[{onStyleChanged:0}],textProperty:[{onStyleChanged:0}],textColor:[{onStyleChanged:0}],textSize:[{onStyleChanged:0}]}],[513,"v-map-layer-wms",{loadState:[1537,"load-state"],url:[513],layers:[513],styles:[513],format:[513],transparent:[516],tiled:[516],visible:[516],opacity:[514],zIndex:[514,"z-index"],getError:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onUrlChanged:0}],layers:[{onLayersChanged:0}],styles:[{onStylesChanged:0}]}],[513,"v-map-layer-xyz",{loadState:[1537,"load-state"],url:[513],attributions:[513],maxZoom:[514,"max-zoom"],tileSize:[514,"tile-size"],subdomains:[513],visible:[516],opacity:[514],getError:[64]}],[769,"v-map-style",{format:[513],src:[513],content:[513],layerTargets:[513,"layer-targets"],autoApply:[516,"auto-apply"],parsedStyle:[32],isLoading:[32],error:[32],getStyle:[64],getLayerTargetIds:[64]},null,{src:[{onStyleSourceChanged:0}],content:[{onStyleSourceChanged:0}],format:[{onStyleSourceChanged:0}]}]]]],e))));
1
+ import{p as e,b as o}from"./p-BoNyIrdq.js";export{s as setNonce}from"./p-BoNyIrdq.js";import{g as a}from"./p-DQuL1Twl.js";(()=>{const o=import.meta.url,a={};return""!==o&&(a.resourcesUrl=new URL(".",o).href),e(a)})().then((async e=>(await a(),o([["p-e21ea0ce",[[769,"v-map-builder",{mapconfig:[1040]},null,{mapconfig:[{onMapConfigChanged:0}]}]]],["p-58dda864",[[513,"v-map-error",{for:[1],position:[513],autoDismiss:[2,"auto-dismiss"],max:[2],log:[1],toasts:[32]}]]],["p-08ad1392",[[769,"v-map-layer-terrain-geotiff",{loadState:[1537,"load-state"],url:[1],projection:[1],forceProjection:[4,"force-projection"],visible:[4],opacity:[2],zIndex:[2,"z-index"],nodata:[2],meshMaxError:[2,"mesh-max-error"],wireframe:[4],texture:[1],color:[16],colorMap:[1,"color-map"],valueRange:[16],elevationScale:[2,"elevation-scale"],renderMode:[1,"render-mode"],minZoom:[2,"min-zoom"],maxZoom:[2,"max-zoom"],tileSize:[2,"tile-size"],getError:[64],getLayerId:[64]},null,{url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],projection:[{onPropertyChanged:0}],forceProjection:[{onPropertyChanged:0}],nodata:[{onPropertyChanged:0}],meshMaxError:[{onPropertyChanged:0}],wireframe:[{onPropertyChanged:0}],texture:[{onPropertyChanged:0}],color:[{onPropertyChanged:0}],colorMap:[{onPropertyChanged:0}],valueRange:[{onPropertyChanged:0}],elevationScale:[{onPropertyChanged:0}],renderMode:[{onPropertyChanged:0}],minZoom:[{onPropertyChanged:0}],maxZoom:[{onPropertyChanged:0}],tileSize:[{onPropertyChanged:0}]}]]],["p-3a57b64a",[[513,"v-map-layercontrol",{for:[1],layerGroups:[32]}]]],["p-05ee633f",[[769,"v-map",{flavour:[513],center:[1],zoom:[2],useDefaultImportMap:[4,"use-default-import-map"],cssMode:[1,"css-mode"],isMapProviderReady:[64],setView:[64]},null,{flavour:[{onFlavourChanged:0}]}],[513,"v-map-layer-osm",{loadState:[1537,"load-state"],visible:[516],opacity:[514],zIndex:[514,"z-index"],url:[513],getError:[64],getLayerId:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onUrlChanged:0}]}],[769,"v-map-layergroup",{visible:[516],opacity:[514],basemapid:[513],getGroupId:[64]},null,{visible:[{onVisibleChanged:0}],basemapid:[{onBaseMapIdChanged:0}]}]]],["p-915314c0",[[769,"v-map-layer-geojson",{loadState:[1537,"load-state"],geojson:[1025],url:[513],visible:[516],zIndex:[514,"z-index"],opacity:[514],fillColor:[513,"fill-color"],fillOpacity:[514,"fill-opacity"],strokeColor:[513,"stroke-color"],strokeWidth:[514,"stroke-width"],strokeOpacity:[514,"stroke-opacity"],pointRadius:[514,"point-radius"],pointColor:[513,"point-color"],iconUrl:[513,"icon-url"],iconSize:[513,"icon-size"],textProperty:[513,"text-property"],textColor:[513,"text-color"],textSize:[514,"text-size"],getLayerId:[64],getError:[64]},[[4,"styleReady","onStyleReady"]],{geojson:[{onGeoJsonChanged:0}],url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],fillColor:[{onStyleChanged:0}],fillOpacity:[{onStyleChanged:0}],strokeColor:[{onStyleChanged:0}],strokeWidth:[{onStyleChanged:0}],strokeOpacity:[{onStyleChanged:0}],pointRadius:[{onStyleChanged:0}],pointColor:[{onStyleChanged:0}],iconUrl:[{onStyleChanged:0}],iconSize:[{onStyleChanged:0}],textProperty:[{onStyleChanged:0}],textColor:[{onStyleChanged:0}],textSize:[{onStyleChanged:0}]}],[513,"v-map-layer-geotiff",{loadState:[1537,"load-state"],url:[1],visible:[4],opacity:[2],zIndex:[2,"z-index"],nodata:[2],colorMap:[1,"color-map"],valueRange:[16],getError:[64],getLayerId:[64]},null,{url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],nodata:[{onNodataChanged:0}],colorMap:[{onColorMapChanged:0}],valueRange:[{onValueRangeChanged:0}]}],[513,"v-map-layer-google",{loadState:[1537,"load-state"],mapType:[513,"map-type"],apiKey:[513,"api-key"],language:[513],region:[513],visible:[516],opacity:[514],scale:[513],maxZoom:[514,"max-zoom"],styles:[1025],libraries:[513],getError:[64]},null,{styles:[{parseStyles:0}]}],[513,"v-map-layer-scatterplot",{loadState:[1537,"load-state"],data:[513],url:[513],getFillColor:[513,"get-fill-color"],getRadius:[514,"get-radius"],opacity:[514],visible:[516],getError:[64]}],[769,"v-map-layer-terrain",{loadState:[1537,"load-state"],elevationData:[513,"elevation-data"],texture:[513],elevationDecoder:[513,"elevation-decoder"],wireframe:[516],color:[513],minZoom:[514,"min-zoom"],maxZoom:[514,"max-zoom"],meshMaxError:[514,"mesh-max-error"],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],getError:[64],isReady:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],elevationData:[{onTerrainConfigChanged:0}],texture:[{onTerrainConfigChanged:0}],elevationDecoder:[{onTerrainConfigChanged:0}],wireframe:[{onTerrainConfigChanged:0}],color:[{onTerrainConfigChanged:0}],minZoom:[{onTerrainConfigChanged:0}],maxZoom:[{onTerrainConfigChanged:0}],meshMaxError:[{onTerrainConfigChanged:0}]}],[769,"v-map-layer-tile3d",{loadState:[1537,"load-state"],url:[513],tilesetOptions:[1,"tileset-options"],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],isReady:[64],getError:[64]},[[4,"styleReady","onStyleReady"]],{url:[{onUrlChanged:0}],tilesetOptions:[{onTilesetOptionsChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}]}],[769,"v-map-layer-wcs",{loadState:[1537,"load-state"],url:[513],coverageName:[513,"coverage-name"],format:[513],version:[513],projection:[513],resolutions:[513],params:[513],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],getError:[64],isReady:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onSourceChanged:0}],coverageName:[{onSourceChanged:0}],format:[{onSourceChanged:0}],version:[{onSourceChanged:0}],projection:[{onSourceChanged:0}],resolutions:[{onSourceChanged:0}],params:[{onSourceChanged:0}]}],[769,"v-map-layer-wfs",{loadState:[1537,"load-state"],url:[513],typeName:[513,"type-name"],version:[513],outputFormat:[513,"output-format"],srsName:[513,"srs-name"],params:[513],visible:[516],opacity:[514],zIndex:[514,"z-index"],didLoad:[32],getError:[64],isReady:[64]},[[4,"styleReady","onStyleReady"]],{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onSourceChanged:0}],typeName:[{onSourceChanged:0}],version:[{onSourceChanged:0}],outputFormat:[{onSourceChanged:0}],srsName:[{onSourceChanged:0}],params:[{onSourceChanged:0}]}],[513,"v-map-layer-wkt",{loadState:[1537,"load-state"],wkt:[513],url:[513],visible:[516],opacity:[514],zIndex:[514,"z-index"],fillColor:[513,"fill-color"],fillOpacity:[514,"fill-opacity"],strokeColor:[513,"stroke-color"],strokeWidth:[514,"stroke-width"],strokeOpacity:[514,"stroke-opacity"],pointRadius:[514,"point-radius"],pointColor:[513,"point-color"],iconUrl:[513,"icon-url"],iconSize:[513,"icon-size"],textProperty:[513,"text-property"],textColor:[513,"text-color"],textSize:[514,"text-size"],getError:[64],getLayerId:[64]},[[4,"styleReady","onStyleReady"]],{wkt:[{onWktChanged:0}],url:[{onUrlChanged:0}],visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],fillColor:[{onStyleChanged:0}],fillOpacity:[{onStyleChanged:0}],strokeColor:[{onStyleChanged:0}],strokeWidth:[{onStyleChanged:0}],strokeOpacity:[{onStyleChanged:0}],pointRadius:[{onStyleChanged:0}],pointColor:[{onStyleChanged:0}],iconUrl:[{onStyleChanged:0}],iconSize:[{onStyleChanged:0}],textProperty:[{onStyleChanged:0}],textColor:[{onStyleChanged:0}],textSize:[{onStyleChanged:0}]}],[513,"v-map-layer-wms",{loadState:[1537,"load-state"],url:[513],layers:[513],styles:[513],format:[513],transparent:[516],tiled:[516],visible:[516],opacity:[514],zIndex:[514,"z-index"],getError:[64]},null,{visible:[{onVisibleChanged:0}],opacity:[{onOpacityChanged:0}],zIndex:[{onZIndexChanged:0}],url:[{onUrlChanged:0}],layers:[{onLayersChanged:0}],styles:[{onStylesChanged:0}]}],[513,"v-map-layer-xyz",{loadState:[1537,"load-state"],url:[513],attributions:[513],maxZoom:[514,"max-zoom"],tileSize:[514,"tile-size"],subdomains:[513],visible:[516],opacity:[514],getError:[64]}],[769,"v-map-style",{format:[513],src:[513],content:[513],layerTargets:[513,"layer-targets"],autoApply:[516,"auto-apply"],parsedStyle:[32],isLoading:[32],error:[32],getStyle:[64],getLayerTargetIds:[64]},null,{src:[{onStyleSourceChanged:0}],content:[{onStyleSourceChanged:0}],format:[{onStyleSourceChanged:0}]}]]]],e))));
package/package.json CHANGED
@@ -1,7 +1,34 @@
1
1
  {
2
2
  "name": "@npm9912/v-map",
3
- "version": "0.1.0",
4
- "description": "VMap Components",
3
+ "version": "0.2.0",
4
+ "description": "Provider-agnostische Web-Mapping-Komponentenbibliothek auf Basis von Stencil.js — unterstützt OpenLayers, Cesium, Leaflet und Deck.gl über ein einheitliches deklaratives Web-Component-API.",
5
+ "keywords": [
6
+ "map",
7
+ "mapping",
8
+ "web-map",
9
+ "web-mapping",
10
+ "gis",
11
+ "geospatial",
12
+ "cartography",
13
+ "openlayers",
14
+ "leaflet",
15
+ "cesium",
16
+ "deck.gl",
17
+ "deckgl",
18
+ "web-components",
19
+ "custom-elements",
20
+ "stencil",
21
+ "stenciljs",
22
+ "typescript",
23
+ "geojson",
24
+ "wms",
25
+ "wfs",
26
+ "wcs",
27
+ "geotiff",
28
+ "3d-map",
29
+ "terrain",
30
+ "provider-agnostic"
31
+ ],
5
32
  "main": "dist/index.cjs.js",
6
33
  "module": "dist/index.js",
7
34
  "types": "dist/types/index.d.ts",
@@ -23,9 +50,6 @@
23
50
  "require": "./loader/index.cjs"
24
51
  }
25
52
  },
26
- "branches": [
27
- "main"
28
- ],
29
53
  "publishConfig": {
30
54
  "access": "public"
31
55
  },
@@ -1 +0,0 @@
1
- import{i as t,L as e,s,w as i}from"./p-BxFJezdK.js";import*as r from"leaflet";import{e as o,l as a}from"./p-CMKJzsgL.js";import{D as n}from"./p-B-bAcABs.js";import{l as c,G as l,g as h}from"./p-Dckgonw8.js";import{w as u}from"./p-DR9McdNX.js";import{GmlParser as f}from"./p-DhQAXuA7.js";import"./p-jzneDarq.js";import"./p-BdijL4Av.js";import"./p-E-ZsRS8r.js";const p=256;class y extends r.GridLayer{apiKey;highDpi;sessionRequest;scaleFactor;sessionToken;sessionPromise;sessionRefreshId;previousViewport;currentAttribution;mapInstance;onMoveEnd;constructor(t){super(),this.applyInitialGridOptions(t);const{apiKey:e,mapType:s,language:i,region:r,imageFormat:o,scale:a,highDpi:n,layerTypes:c,overlay:l,styles:h,apiOptions:u}=t;if(!e)throw new Error("Google Map Tiles layer requires an apiKey");this.apiKey=e,this.highDpi=n??(void 0===a||"scaleFactor1x"!==a),this.scaleFactor=this.mapScaleToFactor(a,this.highDpi);const f={mapType:s??"roadmap",language:i??"en-US",region:r??"US"};o&&(f.imageFormat=o),c?.length&&(f.layerTypes=c),u?.length&&(f.apiOptions=u),Array.isArray(h)&&h.length>0&&(f.styles=h),!0===l&&(f.overlay=!0);const p=a??(this.scaleFactor>1?this.factorToScale(this.scaleFactor):void 0);p&&(f.scale=p),this.highDpi&&(f.highDpi=!0),this.sessionRequest=f,this.onMoveEnd=()=>{this.updateAttribution()},this.sessionPromise=this.startSessionFetch()}onAdd(t){return this.mapInstance=t,t.on("moveend",this.onMoveEnd),t.on("zoomend",this.onMoveEnd),this.ensureSession().then((()=>this.updateAttribution())),super.onAdd(t)}onRemove(t){return t.off("moveend",this.onMoveEnd),t.off("zoomend",this.onMoveEnd),this.clearSessionRefresh(),this.removeCurrentAttribution(),this.mapInstance=void 0,super.onRemove(t)}createTile(t,e){const s=document.createElement("img");s.decoding="async",s.alt="",s.crossOrigin="anonymous";const i=this.resolveTileSize();s.width=i.x,s.height=i.y;const r=t=>{const i=t instanceof Error?t.message:"Google tile load error";e(new Error(i),s)};return s.onload=()=>e(null,s),s.onerror=t=>{const e=t instanceof ErrorEvent?t.error??new Error(t.message):new Error("Google tile failed to load");r(e)},this.ensureSession().then((()=>{this.sessionToken?s.src=this.buildTileUrl(t):r(new Error("Google Maps session unavailable"))})).catch((t=>{r(t)})),s}ensureSession(){return this.sessionToken?Promise.resolve():(this.sessionPromise||(this.sessionPromise=this.startSessionFetch()),this.sessionPromise)}startSessionFetch(t=!1){if(this.sessionPromise&&!t)return this.sessionPromise;const e=this.fetchAndApplySession().catch((t=>{const e=t instanceof Error?t:new Error("Failed to create Google Maps session");throw o("Google Map Tiles session error",e),this.sessionToken=void 0,e})).finally((()=>{this.sessionPromise===e&&(this.sessionPromise=void 0)}));return this.sessionPromise=e,e}async fetchAndApplySession(){const t=`https://tile.googleapis.com/v1/createSession?key=${this.apiKey}`,e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.sessionRequest)});if(!e.ok){let t;try{const s=await e.json();t=s?.error?.message}catch{}throw new Error(t??`Google Maps session request failed (${e.status})`)}const s=await e.json();this.sessionToken=s.session,this.applyTileSize(s),this.scheduleSessionRefresh(this.parseExpiry(s.expiry)),this.mapInstance&&(this.updateAttribution(),this.redrawLayer()),a("Google Map Tiles session established")}scheduleSessionRefresh(t){if(!isFinite(t))return;const e=Math.max(t-Date.now()-6e4,1e3);this.clearSessionRefresh(),this.sessionRefreshId=setTimeout((()=>{this.startSessionFetch(!0).then((()=>{this.mapInstance&&(this.updateAttribution(),this.redrawLayer())}))}),e)}clearSessionRefresh(){void 0!==this.sessionRefreshId&&(clearTimeout(this.sessionRefreshId),this.sessionRefreshId=void 0)}async updateAttribution(){if(!this.mapInstance||!this.sessionToken)return;const t=this.mapInstance.getBounds();if(!t?.isValid())return;const e=`zoom=${this.mapInstance.getZoom()}&north=${t.getNorth()}&south=${t.getSouth()}&east=${t.getEast()}&west=${t.getWest()}`;if(this.previousViewport!==e){this.previousViewport=e;try{const t=await fetch(`https://tile.googleapis.com/tile/v1/viewport?session=${this.sessionToken}&key=${this.apiKey}&${e}`);if(!t.ok)throw new Error(`Attribution request failed (${t.status})`);const s=await t.json(),i=s?.copyright;"string"==typeof i&&i.length>0&&this.applyAttribution(i)}catch(t){o("Failed to fetch Google attribution",t)}}}applyAttribution(t){const e=this.mapInstance;e?.attributionControl&&(this.currentAttribution&&this.currentAttribution!==t&&e.attributionControl.removeAttribution(this.currentAttribution),this.currentAttribution&&this.currentAttribution===t||(e.attributionControl.addAttribution(t),this.currentAttribution=t))}removeCurrentAttribution(){const t=this.mapInstance;t?.attributionControl&&this.currentAttribution&&(t.attributionControl.removeAttribution(this.currentAttribution),this.currentAttribution=void 0)}applyTileSize(t){const e=Math.max(1,Math.round(t.tileWidth/this.scaleFactor)),s=Math.max(1,Math.round(t.tileHeight/this.scaleFactor)),i=r.point(e,s);this.setGridOptions({tileSize:i})}parseExpiry(t){const e=parseInt(t,10);return Number.isFinite(e)?1e3*e:Number.NaN}buildTileUrl(t){if(!this.sessionToken)throw new Error("Google Maps session missing");return`https://tile.googleapis.com/v1/2dtiles/${t.z}/${t.x}/${t.y}?session=${this.sessionToken}&key=${this.apiKey}`}mapScaleToFactor(t,e){switch(t){case"scaleFactor4x":return 4;case"scaleFactor2x":return 2;case"scaleFactor1x":return 1;default:return e?2:1}}factorToScale(t){switch(t){case 4:return"scaleFactor4x";case 2:return"scaleFactor2x";case 1:return"scaleFactor1x";default:return}}applyInitialGridOptions(t){const e={},s=["attribution","bounds","className","detectRetina","errorTileUrl","keepBuffer","maxNativeZoom","maxZoom","minNativeZoom","minZoom","noWrap","opacity","pane","reuseTiles","subdomains","tileSize","tms","updateInterval","updateWhenIdle","updateWhenZooming","zIndex","zoomOffset"];for(const i of s){const s=t[i];void 0!==s&&(e[i]=s)}void 0===e.maxZoom&&(e.maxZoom=22),this.setGridOptions(e)}setGridOptions(t){const e=r.Util?.setOptions;if("function"==typeof e)e(this,t);else{const e=this;e.options={...e.options,...t}}}resolveTileSize(){const t=this.options?.tileSize;if(t&&"object"==typeof t){if(Array.isArray(t)&&2===t.length){const[e,s]=t;return r.point(Number(e)||p,Number(s)||p)}if("x"in t&&"y"in t){const e=t;return r.point(Number(e.x)||p,Number(e.y)||p)}}return"number"==typeof t&&Number.isFinite(t)?r.point(t,t):r.point(p,p)}redrawLayer(){this.redraw()}}class d extends r.GridLayer{geotiffOptions;tileProcessor=null;colorStops;loadingPromise;defaultResolution=1;defaultResample="bilinear";constructor(t){super(t),this.geotiffOptions={...t}}onAdd(t){return super.onAdd(t),this.ensureReady().then((()=>this.redraw())),this}createTile(t,e){const s=this.getTileSize(),i=r.DomUtil.create("canvas","leaflet-tile");return i.width=s.x,i.height=s.y,this.ensureReady().then((async()=>{if(this.tileProcessor)try{const r=await this.tileProcessor.getTileData({x:t.x,y:t.y,z:t.z,tileSize:s.x,resolution:this.geotiffOptions.resolution??this.defaultResolution,resampleMethod:this.geotiffOptions.resampleMethod??this.defaultResample,colorStops:this.colorStops});if(!r)return void e(null,i);const o=i.getContext("2d");if(o){const t=o.createImageData(s.x,s.y);t.data.set(r),o.putImageData(t,0,0)}e(null,i)}catch(t){e(t,i)}else e(null,i)})).catch((t=>{e(t,i)})),i}async ensureReady(){return this.loadingPromise||(this.loadingPromise=this.initializeProcessor()),this.loadingPromise}async updateSource(t){Object.assign(this.geotiffOptions,t),this.tileProcessor=null,this.colorStops=void 0,this.loadingPromise=void 0,await this.ensureReady(),this.redraw()}async initializeProcessor(){if(this.tileProcessor)return;const[t,{default:e},s]=await Promise.all([import("./p-Be3r33VF.js").then((function(t){return t.g})),import("./p-RpJarvr_.js"),import("./p-CXfA_q8m.js").then((function(t){return t.m}))]),i=await c(this.geotiffOptions.url,{projection:void 0,forceProjection:!1,nodata:this.geotiffOptions.nodata},{geotiff:t,proj4:e,geokeysToProj4:s}),r=t=>{const e=i.proj4(i.fromProjection,this.geotiffOptions.viewProjection,t);return[Number(e[0]),Number(e[1])]};if(this.tileProcessor=new l({transformViewToSourceMapFn:t=>{const e=i.proj4(this.geotiffOptions.viewProjection,i.fromProjection,t);return[Number(e[0]),Number(e[1])]},transformSourceMapToViewFn:r,sourceBounds:i.sourceBounds,sourceRef:i.sourceRef,resolution:i.resolution,imageWidth:i.width,imageHeight:i.height,fromProjection:i.fromProjection,toProjection:this.geotiffOptions.viewProjection,baseImage:i.baseImage,overviewImages:i.overviewImages??[]}),this.tileProcessor.createGlobalTriangulation(),this.setViewBounds(i.sourceBounds,r),this.geotiffOptions.colorMap){const{stops:t}=h(this.geotiffOptions.colorMap,this.geotiffOptions.valueRange);this.colorStops=t}}setViewBounds(t,e){const[s,i,o,a]=t,n=e([s,i]),c=e([o,i]),l=e([s,a]),h=e([o,a]),u=Math.min(n[0],c[0],l[0],h[0]),f=Math.max(n[0],c[0],l[0],h[0]),p=Math.min(n[1],c[1],l[1],h[1]),y=Math.max(n[1],c[1],l[1],h[1]),d=r.CRS.EPSG3857.unproject(r.point(u,y)),m=r.CRS.EPSG3857.unproject(r.point(f,p));this.options.bounds=r.latLngBounds(d,m)}}const m="v-map - leaflet - wcs - tile - ";class w extends r.GridLayer{wcsOptions;constructor(t){super(t),this.wcsOptions={...t,version:t.version??"2.0.1",format:t.format??"image/tiff",projection:t.projection??"EPSG:4326"}}buildWCSUrl(t){const{url:e,coverageName:s,version:i,format:r,projection:o,params:a}=this.wcsOptions,n=this._tileCoordsToBounds(t),c=n.getSouthWest(),l=n.getNorthEast(),h=c.lng,u=c.lat,f=l.lng,p=l.lat,y={SERVICE:"WCS",REQUEST:"GetCoverage",VERSION:i,FORMAT:r};if(i.startsWith("2.0")){y.coverageId=s;const t=a?{...a}:{},i={...y,...t};(r.includes("tiff")||r.includes("geotiff"))&&(i["geotiff:compression"]="LZW");const o=new URLSearchParams;Object.entries(i).forEach((([t,e])=>{null!=e&&o.set(t,String(e))}));const n=o.toString(),c=`subset=X(${h},${f})`,l=`subset=Y(${u},${p})`;return`${e}${e.includes("?")?"&":"?"}${n}&${c}&${l}`}{y.COVERAGE=s,y.BBOX=`${h},${u},${f},${p}`,y.CRS=o;const t=this.getTileSize();y.WIDTH="number"==typeof t?t:t.x,y.HEIGHT="number"==typeof t?t:t.y;const i=a?{...a}:{},r={...y,...i},n=new URLSearchParams;return Object.entries(r).forEach((([t,e])=>{null!=e&&n.set(t,String(e))})),`${e}${e.includes("?")?"&":"?"}${n.toString()}`}}createTile(t,e){const s=document.createElement("img"),i=this.buildWCSUrl(t);return a(`${m}load: coords=(${t.x},${t.y},${t.z})`),a(`${m}url: ${i}`),s.onload=()=>{e(null,s)},s.onerror=t=>{o(`${m}failed to load tile:`,t),e(t instanceof Error?t:new Error(String(t)),s)},s.crossOrigin="anonymous",s.src=i,s}updateOptions(t){this.wcsOptions={...this.wcsOptions,...t},this.redraw()}}class g{map;layers=[];baseLayers=[];hiddenLayerGroups=[];googleLogoAdded=!1;unsubscribeResize;shadowRoot;injectedStyle;layerErrorCallbacks=new Map;layerErrorCleanups=new Map;async init(o){if(!t())return;this.shadowRoot=o.shadowRoot,this.injectedStyle=function(i,o){if(t()){switch(i){case"cdn":return function(s,i=e,o="jsdelivr"){if(!t())return;const a="unpkg"===o?`https://unpkg.com/leaflet@${i}/dist/leaflet.css`:`https://cdn.jsdelivr.net/npm/leaflet@${i}/dist/leaflet.css`;r.Icon.Default.imagePath="unpkg"===o?`https://unpkg.com/npm/leaflet@${i}/dist/images/`:`https://cdn.jsdelivr.net/npm/leaflet@${i}/dist/images/`;const n=s??document;if(n.querySelector?.(`link[rel="stylesheet"][href="${a}"]`)||document.head.querySelector(`link[rel="stylesheet"][href="${a}"]`))return null;const c=document.createElement("link");return c.rel="stylesheet",c.href=a,(s??document.head).appendChild(c),c}(o);case"inline-min":return function(e){if(!t())return;const i="\n :host { display:block; }\n #map { width:100%; height:100%; display:block; }\n ";if(s()){const t=new CSSStyleSheet;t.replaceSync(i);const s=e??document;return s.adoptedStyleSheets=[...s.adoptedStyleSheets??[],t],null}{const t=document.createElement("style");return t.textContent=i,(e??document.head).appendChild(t),t}}(o)}return null}}(o.cssMode,this.shadowRoot);const[a,n]=o?.mapInitOptions?.center??[0,0];this.map=r.map(o.target,{zoomControl:!0,attributionControl:!0}).setView([n,a],o?.mapInitOptions?.zoom??2),this.unsubscribeResize=i(o.target,(()=>{this.map?.invalidateSize()}),{attributes:!0,attributeFilter:["style","class"]})}async updateLayer(t,e){const s=await this._getLayerById(t);switch(e.type){case"geojson":await this.updateGeoJSONLayer(s,e.data);break;case"osm":await this.updateOSMLayer(s,e.data);break;case"arcgis":await this.updateArcGISLayer(s,e.data);break;case"wkt":await this.updateWKTLayer(s,e.data);break;case"geotiff":await this.updateGeoTIFFLayer(s,e.data);break;case"wcs":await this.updateWCSLayer(s,e.data);break;case"wfs":s instanceof r.GeoJSON&&await this.updateWFSLayer(s,e.data)}}async addLayerToGroup(t){const e=await this._ensureGroup(t.groupId,t.groupVisible),s=await this.createLayer(t);if(null==s)return null;e.addLayer(s);const i=this.getLayerId(s);return s.vmapVisible=!0,s.vmapOpacity=1,void 0!==t.opacity&&this.setOpacityByLayer(s,t.opacity),void 0!==t.zIndex&&s.setZIndex?.(t.zIndex),t.visible?this.setVisibleByLayer(s,!0):!1===t.visible&&this.setVisibleByLayer(s,!1),i}async addBaseLayer(t,e,s){if(null==s)return a("leaflet - addBaseLayer - layerElementId not set."),null;null==e&&a("leaflet - addBaseLayer - basemapid not set.");const i=await this._ensureGroup(t.groupId,t.groupVisible);i.basemap=!0;const r=await this.createLayer(t);if(this.baseLayers.push(r),null==r)return null;r.layerElementId=s;const o=this.getLayerId(r);if(r.vmapVisible=!0,r.vmapOpacity=1,void 0!==t.opacity&&this.setOpacityByLayer(r,t.opacity),void 0!==t.zIndex&&r.setZIndex?.(t.zIndex),t.visible?this.setVisibleByLayer(r,!0):!1===t.visible&&this.setVisibleByLayer(r,!1),e===s){const t=i.getLayers()[0];t&&(this.map.removeLayer(t),i.clearLayers()),i.addLayer(r),i.visible&&r.addTo(this.map)}return o}async setBaseLayer(t,e){if(null===e)return void a("leaflet - setBaseLayer - layerElementId is null.");const s=this.layers.find((e=>e._groupId===t)),i=this.baseLayers.find((t=>t.layerElementId===e));if(void 0===i)return void a("leaflet - setBaseLayer - layer not found. layerElementId: "+e);if(!s)return;const r=s.getLayers()[0];r&&(this.map.removeLayer(r),s.clearLayers()),s.addLayer(i)}getLayerId(t){return String(r.Util.stamp(t))}normalizeAttribution(t){return Array.isArray(t)?t.join(", "):t}async _getLayerById(t){let e=null;return this.map?.eachLayer((s=>{this.getLayerId(s)===t&&(e=s)})),e||(e=this.baseLayers.find((e=>this.getLayerId(e)===t))??null,void 0===e?null:e)}async createLayer(t){switch(t.type){case"geojson":return this.createGeoJSONLayer(t);case"xyz":return this.createXYZLayer(t);case"osm":return this.createOSMLayer(t);case"wms":return this.createWMSLayer(t);case"wcs":return this.createWCSLayer(t);case"wfs":return this.createWFSLayer(t);case"arcgis":return this.createArcGISLayer(t);case"google":return this.createGoogleLayer(t);case"wkt":return this.createWKTLayer(t);case"geotiff":return this.createGeoTIFFLayer(t);default:throw new Error(`Unsupported layer type: ${t.type}`)}}async updateGeoJSONLayer(t,e){if(!(t instanceof r.GeoJSON))return;let s=null;if(e.geojson)s=JSON.parse(e.geojson);else if(e.url){const t=await fetch(e.url);if(!t.ok)throw new Error(`GeoJSON fetch failed: ${t.status} ${t.statusText}`);s=await t.json()}t.clearLayers(),t.addData(s)}async createGeoJSONLayer(t){let e=null;if(t.geojson)e=JSON.parse(t.geojson);else if(t.url){const s=await fetch(t.url);if(!s.ok)throw new Error(`GeoJSON fetch failed: ${s.status} ${s.statusText}`);e=await s.json()}if(e){let s={};if(t.geostylerStyle)s=await this.createGeostylerLeafletOptions(t.geostylerStyle);else{const e=t.style?{...n,...t.style}:n;s={style:this.createLeafletStyle(e),pointToLayer:(t,s)=>this.createLeafletPoint(t,s,e),onEachFeature:(t,s)=>this.bindLeafletPopup(t,s,e)}}return r.geoJSON(e,s)}return null}async createXYZLayer(t){return r.tileLayer(t.url,{attribution:this.normalizeAttribution(t.attributions),maxZoom:t.maxZoom??19,...t.options??{}})}async updateOSMLayer(t,e){if(!("setUrl"in t)||"function"!=typeof t.setUrl)return;let s="https://tile.openstreetmap.org/{z}/{x}/{y}.png";e.url&&(s=e.url+"/{z}/{x}/{y}.png"),t.setUrl(s)}async createOSMLayer(t){let e="https://tile.openstreetmap.org/{z}/{x}/{y}.png";return t.url&&(e=t.url+"/{z}/{x}/{y}.png"),r.tileLayer(e,{attribution:"© OpenStreetMap contributors",maxZoom:19})}async createWMSLayer(t){return r.tileLayer.wms(t.url,{layers:t.layers,format:t.format??"image/png",transparent:t.transparent??!0,...t.extraParams??{}})}buildArcGISUrl(t,e){if(!e||0===Object.keys(e).length)return t;const s=new URLSearchParams;return Object.entries(e).forEach((([t,e])=>{null!=e&&s.set(t,String(e))})),0===s.toString().length?t:`${t}${t.includes("?")?"&":"?"}${s.toString()}`}async createArcGISLayer(t){const e={...t.params??{}};t.token&&(e.token=t.token);const s=this.buildArcGISUrl(t.url,e),i={attribution:this.normalizeAttribution(t.attributions),minZoom:t.minZoom,maxZoom:t.maxZoom,...t.options??{}};return r.tileLayer(s,i)}async updateArcGISLayer(t,e){const s={...e?.params??{}};e?.token&&(s.token=e.token);const i=t,r=this.buildArcGISUrl(e?.url??i.options?.url??"",s);"setUrl"in i&&"function"==typeof i.setUrl&&i.setUrl(r)}async createGoogleLayer(t){if(!this.map)throw new Error("Map not initialized");if(!t.apiKey)throw new Error("Google-Layer benötigt 'apiKey' (Google Maps Platform).");const e="string"==typeof t.styles?this.tryParseStyles(t.styles):t.styles,s=new y({apiKey:t.apiKey,mapType:t.mapType??"roadmap",language:t.language,region:t.region,scale:t.scale,highDpi:t.highDpi,layerTypes:t.layerTypes,overlay:t.overlay,styles:Array.isArray(e)?e:void 0,imageFormat:t.imageFormat,apiOptions:t.apiOptions,maxZoom:t.maxZoom??22});return o=()=>{this.googleLogoAdded=!0,a("v-map - provider - leaflet - googleLogoAdded: ",this.googleLogoAdded)},(i=this.map)._googleLogoAdded||(new(r.Control.extend({onAdd(){const t=r.DomUtil.create("img");return t.src="https://developers.google.com/static/maps/documentation/images/google_on_white.png",t.alt="Google",t.style.pointerEvents="none",t.style.height="18px",t.style.margin="0 0 6px 6px",t},onRemove(){}}))({position:"bottomleft"}).addTo(i),i._googleLogoAdded=!0,o()),s;var i,o}tryParseStyles(t){try{const e=JSON.parse(t);return Array.isArray(e)?e:void 0}catch{return void o("Failed to parse Google styles JSON")}}async destroy(){var t;this.unsubscribeResize?.(),t=this.injectedStyle,this.shadowRoot&&t&&t.remove();for(const t of this.layers)this.map?.removeLayer(t);this.layers=[],this.map?.remove(),this.map=void 0}async setView([t,e],s){this.map?.setView([e,t],s,{animate:!1})}onLayerError(t,e){this.layerErrorCallbacks.set(t,e),this._getLayerById(t).then((s=>{if(!s)return;const i=()=>{e({type:"network",message:"Tile load error"})};s.on("tileerror",i),this.layerErrorCleanups.set(t,(()=>s.off("tileerror",i)))}))}offLayerError(t){this.layerErrorCleanups.get(t)?.(),this.layerErrorCleanups.delete(t),this.layerErrorCallbacks.delete(t)}async removeLayer(t){if(!t)return;this.offLayerError(t);const e=await this._getLayerById(t);e&&this.map.removeLayer(e)}async setZIndex(t,e){if(!t)return;const s=await this._getLayerById(t);s&&"function"==typeof s.setZIndex&&s.setZIndex(e)}async setOpacity(t,e){if(!t)return;const s=await this._getLayerById(t);this.setOpacityByLayer(s,e)}setOpacityByLayer(t,e){t&&(t.vmapOpacity=e,void 0===t.vmapVisible&&(t.vmapVisible=!0),!1!==t.vmapVisible&&this.setLayerOpacity(t,e))}async setVisible(t,e){if(!t)return;const s=await this._getLayerById(t);this.setVisibleByLayer(s,e)}setVisibleByLayer(t,e){t&&(t.vmapVisible=e,void 0===t.vmapOpacity&&(t.vmapOpacity=1),this.setLayerOpacity(t,e?t.vmapOpacity:0))}setLayerOpacity(t,e){if(!t)return;const s="number"==typeof e?e:e.opacity??1,i="number"==typeof e?e:e.fillOpacity??s,o=(t,e)=>{if(!(e in r))return!1;const s=r[e];return"function"==typeof s&&t instanceof s};var a;o(a=t,"GeoJSON")||o(a,"LayerGroup")?t.eachLayer((t=>this.setLayerOpacity(t,e))):(t=>o(t,"Path"))(t)?t.setStyle({opacity:s,fillOpacity:i}):((t=>o(t,"Marker"))(t)||"setOpacity"in t)&&t.setOpacity(s)}async ensureGroup(t,e,s){await this._ensureGroup(t,e)}async _ensureGroup(t,e){let s=await this._getLayerGroupById(t);return s||(s=r.layerGroup(),s._groupId=t,s.visible=!0,s.addTo(this.map),this.layers.push(s)),this.setGroupVisible(t,void 0===e||e),s}async _getLayerGroupById(t){if(!this.map)return null;let e=this.layers.find((e=>e instanceof r.LayerGroup&&e._groupId===t));return e||(e=this.hiddenLayerGroups.find((e=>e._groupId===t)),e)?e:null}async setGroupVisible(t,e){const s=await this._getLayerGroupById(t);if(s){if(s.visible===e)return;!1===s.visible?(s.addTo(this.map),this.hiddenLayerGroups=this.hiddenLayerGroups.filter((e=>e._groupId!==t)),s.visible=e):!0===s.visible&&(this.map.removeLayer(s),s.visible=e,this.hiddenLayerGroups.push(s))}}async updateWKTLayer(t,e){if(!(t instanceof r.GeoJSON))return;let s=null;if(e.wkt)s=await this.wktToGeoJSON(e.wkt);else if(e.url)try{const t=await fetch(e.url);if(!t.ok)throw new Error(`Failed to fetch WKT: ${t.status}`);const i=await t.text();s=await this.wktToGeoJSON(i)}catch(t){return void o("Failed to load WKT from URL:",t)}if(s){t.clearLayers();const i=t;i.options.style=this.createLeafletStyle(e.style),i.options.pointToLayer=(t,s)=>this.createLeafletPoint(t,s,e.style),i.options.onEachFeature=(t,s)=>this.bindLeafletPopup(t,s,e.style),i.addData(s)}}async createWKTLayer(t){let e=null;const s={type:"FeatureCollection",features:[]};if(t.wkt)e=await this.wktToGeoJSON(t.wkt);else if(t.url)try{const s=await fetch(t.url);if(!s.ok)throw new Error(`Failed to fetch WKT: ${s.status}`);const i=await s.text();e=await this.wktToGeoJSON(i)}catch(t){o("Failed to load WKT from URL:",t),e=s}else e=s;a("[Leaflet WKT] Creating layer with GeoJSON data:",e),a("[Leaflet WKT] Config:",t);let i={};if(t.geostylerStyle)i=await this.createGeostylerLeafletOptions(t.geostylerStyle);else{const e=t.style?{...n,...t.style}:n;i={style:this.createLeafletStyle(e),pointToLayer:(t,s)=>this.createLeafletPoint(t,s,e),onEachFeature:(t,s)=>this.bindLeafletPopup(t,s,e)}}a("[Leaflet WKT] Layer options:",i);const c=r.geoJSON(e,i);return a("[Leaflet WKT] Created layer:",c),"function"==typeof c.getBounds&&a("[Leaflet WKT] Layer bounds:",c.getBounds()),c}async wktToGeoJSON(t){try{const e=u.wellknown.parse(t);if(!e)throw new Error("Failed to parse WKT - returned null");const s={type:"Feature",geometry:e,properties:{}};return a("[Leaflet WKT] Input WKT:",t),a("[Leaflet WKT] Generated GeoJSON:",JSON.stringify(s,null,2)),{type:"FeatureCollection",features:[s]}}catch(e){return o("[Leaflet WKT] Failed to parse WKT:",t,e),{type:"FeatureCollection",features:[]}}}async createGeoTIFFLayer(t){if(!t.url)throw new Error("GeoTIFF layer requires a URL");try{const e=new d({url:t.url,tileSize:256,colorMap:t.colorMap,valueRange:t.valueRange,nodata:t.nodata,resolution:t.resolution,resampleMethod:t.resampleMethod,viewProjection:this.map.options.crs.code});return void 0!==t.opacity&&e.setOpacity?.(t.opacity),void 0!==t.zIndex&&e.setZIndex?.(t.zIndex),e}catch(t){return o("Failed to create GeoTIFF layer:",t),r.layerGroup([])}}async updateGeoTIFFLayer(t,e){if(!e.url)throw new Error("GeoTIFF update requires a URL");if(!t)return;if(!(t instanceof d))return;const s=e;await t.updateSource({url:e.url,colorMap:e.colorMap,valueRange:e.valueRange,nodata:e.nodata,resolution:s.resolution,resampleMethod:s.resampleMethod})}async createWCSLayer(t){if(!t.url)throw new Error("WCS layer requires a URL");if(!t.coverageName)throw new Error("WCS layer requires a coverageName");try{const e={url:t.url,coverageName:t.coverageName,version:t.version??"2.0.1",format:t.format??"image/tiff",projection:t.projection??"EPSG:4326",params:t.params};t.tileSize&&(e.tileSize=t.tileSize),void 0!==t.minZoom&&(e.minZoom=t.minZoom),void 0!==t.maxZoom&&(e.maxZoom=t.maxZoom);const s=new w(e);return void 0!==t.opacity&&s.setOpacity?.(t.opacity),void 0!==t.zIndex&&s.setZIndex?.(t.zIndex),s}catch(t){return o("[Leaflet WCS] Failed to create WCS layer:",t),r.layerGroup([])}}async updateWCSLayer(t,e){if(t&&t instanceof w){const s={};e.url&&(s.url=e.url),e.coverageName&&(s.coverageName=e.coverageName),e.version&&(s.version=e.version),e.format&&(s.format=e.format),e.projection&&(s.projection=e.projection),e.params&&(s.params=e.params),t.updateOptions(s)}}async createGeostylerLeafletOptions(t){const e=(t,e)=>null==t||"object"==typeof t&&t.name?e:t;return{style:s=>{const i=s?.geometry?.type;let r={};if(t.rules)for(const s of t.rules)if(s.symbolizers)for(const t of s.symbolizers)switch(t.kind){case"Fill":if("Polygon"===i||"MultiPolygon"===i){const s=e(t.color,"rgba(0,100,255,0.3)"),i=e(t.opacity,.3),o=e(t.outlineColor,"rgba(0,100,255,1)"),a=e(t.outlineWidth,1);r={...r,fillColor:s,fillOpacity:i,color:o,weight:a}}break;case"Line":const s=e(t.color,"rgba(0,100,255,1)"),o=e(t.width,2),a=t.dasharray&&Array.isArray(t.dasharray)?t.dasharray.map((t=>e(t,0))).join(","):void 0;r={...r,color:s,weight:o,dashArray:a}}return r},pointToLayer:(s,i)=>{if(t.rules)for(const s of t.rules)if(s.symbolizers)for(const t of s.symbolizers)switch(t.kind){case"Mark":const s=e(t.color,"rgba(0,100,255,1)"),o=e(t.radius,6),a=e(t.strokeColor,"rgba(0,100,255,1)"),n=e(t.strokeWidth,2);return r.circleMarker(i,{radius:o,fillColor:s,fillOpacity:1,color:a,weight:n});case"Icon":const c=e(t.image),l=e(t.size,32);if(c&&"string"==typeof c){const t=r.icon({iconUrl:c,iconSize:[l,l],iconAnchor:[l/2,l]});return r.marker(i,{icon:t})}}return r.circleMarker(i,{radius:6,fillColor:"rgba(0,100,255,1)",fillOpacity:1,color:"rgba(0,100,255,1)",weight:2})},onEachFeature:(s,i)=>{if(t.rules)for(const r of t.rules)if(r.symbolizers)for(const t of r.symbolizers)if("Text"===t.kind){const r=t.label;if(r&&"string"==typeof r&&s.properties&&s.properties[r]){const o=String(s.properties[r]),a=e(t.color,"#000000"),n=e(t.size,12);i.bindTooltip(`<div style="color: ${a}; font-size: ${n}px; font-family: Arial, sans-serif;">${o}</div>`,{permanent:!0,direction:"center",className:"leaflet-tooltip-custom"})}}}}}createLeafletStyle(t){return e=>{const s=e?.geometry?.type,i=t?.fillColor??"rgba(0,100,255,0.3)",r=t?.fillOpacity??.3,o=t?.strokeColor??"rgba(0,100,255,1)",a=t?.strokeOpacity??1,n=t?.strokeWidth??2;return"Polygon"===s||"MultiPolygon"===s?{fillColor:i,fillOpacity:r,color:o,opacity:a,weight:n,dashArray:t?.strokeDashArray?t.strokeDashArray.join(","):void 0}:"LineString"===s||"MultiLineString"===s?{color:o,opacity:a,weight:n,dashArray:t?.strokeDashArray?t.strokeDashArray.join(","):void 0}:{}}}createLeafletPoint(t,e,s){let i={...s??{}};if(s?.styleFunction){const e=s.styleFunction(t);e&&(i={...s,...e})}if(i?.iconUrl){const t=i.iconSize||[32,32],s=r.icon({iconUrl:i.iconUrl,iconSize:t,iconAnchor:i.iconAnchor||[t[0]/2,t[1]]});return r.marker(e,{icon:s})}{const t=i?.pointColor??"rgba(0,100,255,1)",s=i?.pointOpacity??1;return r.circleMarker(e,{radius:i?.pointRadius??6,fillColor:t,fillOpacity:s,color:i?.strokeColor??"rgba(0,100,255,1)",opacity:i?.strokeOpacity??1,weight:i?.strokeWidth??2})}}bindLeafletPopup(t,e,s){if(s?.textProperty&&t.properties&&t.properties[s.textProperty]){const i=String(t.properties[s.textProperty]);e.bindTooltip(`<div style="color: ${s?.textColor??"#000000"}; font-size: ${s?.textSize??12}px; font-family: Arial, sans-serif;">${i}</div>`,{permanent:!0,direction:"center",className:"leaflet-tooltip-custom"})}}async createWFSLayer(t){const e=await this.fetchWFSFromUrl(t);let s={};if(t.geostylerStyle)s=await this.createGeostylerLeafletOptions(t.geostylerStyle);else{const e=t.style?{...n,...t.style}:n;s={style:this.createLeafletStyle(e),pointToLayer:(t,s)=>this.createLeafletPoint(t,s,e),onEachFeature:(t,s)=>this.bindLeafletPopup(t,s,e)}}return r.geoJSON(e,s)}async updateWFSLayer(t,e){const s=await this.fetchWFSFromUrl(e);t.clearLayers(),t.addData(s)}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??{}},s=this.appendParams(t.url,e),i=await fetch(s);if(!i.ok)throw new Error(`WFS request failed (${i.status} ${i.statusText})`);const r=(t.outputFormat??"application/json").toLowerCase();if(r.includes("json")||r.includes("geojson")||"application/json"===r)return await i.json();if(r.includes("gml")||r.includes("xml")){const t=await i.text(),e=new f;return await e.parse(t)}return await i.json()}appendParams(t,e){const s=new URLSearchParams;return Object.entries(e).forEach((([t,e])=>{null!=e&&s.set(t,String(e))})),s.toString()?`${t}${t.includes("?")?"&":"?"}${s.toString()}`:t}getMap(){return this.map}}export{g as LeafletProvider}
@@ -1 +0,0 @@
1
- export{V as v_map,a as v_map_layer_osm,b as v_map_layergroup}from"./p-BxFJezdK.js";import"./p-jzneDarq.js";import"./p-CMKJzsgL.js";import"./p-BdijL4Av.js";