@npm9912/v-map 0.1.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 (438) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/dist/cjs/_commonjsHelpers-B83fTs8d.js +36 -0
  4. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  5. package/dist/cjs/cesium-provider-BiFFyAl9.js +2598 -0
  6. package/dist/cjs/deck-provider-Ctq3Q8a1.js +47824 -0
  7. package/dist/cjs/geotiff-CEwvF9cG.js +47 -0
  8. package/dist/cjs/geotiff-source-RaNzzWkC.js +1522 -0
  9. package/dist/cjs/index-B1oGO1g-.js +10658 -0
  10. package/dist/cjs/index-B8LHqjyg.js +1765 -0
  11. package/dist/cjs/index-BIL4VsgP.js +310 -0
  12. package/dist/cjs/index-Blku2QY8.js +167 -0
  13. package/dist/cjs/index-CJvvX4yx.js +21 -0
  14. package/dist/cjs/index-CbVT-Con.js +699 -0
  15. package/dist/cjs/index-ISOEpMC3.js +20478 -0
  16. package/dist/cjs/index-JSwBbvGA.js +1621 -0
  17. package/dist/cjs/index.browser-DQhD8Jwl.js +6873 -0
  18. package/dist/cjs/index.cjs.js +2 -0
  19. package/dist/cjs/layer-extension-B_olS0rc.js +65 -0
  20. package/dist/cjs/leaflet-provider-DOqfs7g5.js +1815 -0
  21. package/dist/cjs/loader.cjs.js +13 -0
  22. package/dist/cjs/main-dist-7TykwFci.js +2655 -0
  23. package/dist/cjs/messages-D7h4m8Tx.js +186 -0
  24. package/dist/cjs/openlayers-provider-Dfeg6L4n.js +1604 -0
  25. package/dist/cjs/polygon-layer-B9PrN7vr.js +1300 -0
  26. package/dist/cjs/scenegraph-layer-DwNoxQdi.js +2530 -0
  27. package/dist/cjs/styleconfig-CVRqArk-.js +23 -0
  28. package/dist/cjs/v-map-builder.cjs.entry.js +3786 -0
  29. package/dist/cjs/v-map-layer-geojson_12.cjs.entry.js +40894 -0
  30. package/dist/cjs/v-map-layer-helper-iAzxAg9I.js +285 -0
  31. package/dist/cjs/v-map-layer-terrain-geotiff.cjs.entry.js +258 -0
  32. package/dist/cjs/v-map-layercontrol.cjs.entry.js +247 -0
  33. package/dist/cjs/v-map.cjs.js +25 -0
  34. package/dist/cjs/v-map.v-map-layer-osm.v-map-layergroup-BsXp3BoL.js +582 -0
  35. package/dist/cjs/v-map_3.cjs.entry.js +12 -0
  36. package/dist/collection/collection-manifest.json +30 -0
  37. package/dist/collection/components/v-map/v-map.css +3 -0
  38. package/dist/collection/components/v-map/v-map.js +467 -0
  39. package/dist/collection/components/v-map/v-map.test.js +33 -0
  40. package/dist/collection/components/v-map-builder/v-map-builder.css +1 -0
  41. package/dist/collection/components/v-map-builder/v-map-builder.js +913 -0
  42. package/dist/collection/components/v-map-builder/v-map-builder.test.js +56 -0
  43. package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.js +862 -0
  44. package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.test.js +42 -0
  45. package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.css +4 -0
  46. package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.js +500 -0
  47. package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.test.js +38 -0
  48. package/dist/collection/components/v-map-layer-google/v-map-layer-google.css +1 -0
  49. package/dist/collection/components/v-map-layer-google/v-map-layer-google.js +442 -0
  50. package/dist/collection/components/v-map-layer-osm/error-api.test.js +108 -0
  51. package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.css +4 -0
  52. package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.js +311 -0
  53. package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.test.js +36 -0
  54. package/dist/collection/components/v-map-layer-scatterplot/v-map-layer-scatterplot.css +1 -0
  55. package/dist/collection/components/v-map-layer-scatterplot/v-map-layer-scatterplot.js +305 -0
  56. package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.css +3 -0
  57. package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.js +548 -0
  58. package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.test.js +36 -0
  59. package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.css +3 -0
  60. package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.js +735 -0
  61. package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.test.js +42 -0
  62. package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.css +3 -0
  63. package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.js +449 -0
  64. package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.test.js +50 -0
  65. package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.css +1 -0
  66. package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.js +448 -0
  67. package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.test.js +39 -0
  68. package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.css +1 -0
  69. package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.js +489 -0
  70. package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.test.js +43 -0
  71. package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.css +1 -0
  72. package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.js +811 -0
  73. package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.test.js +34 -0
  74. package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.css +1 -0
  75. package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.js +453 -0
  76. package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.test.js +36 -0
  77. package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.css +1 -0
  78. package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.js +331 -0
  79. package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.test.js +28 -0
  80. package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.css +74 -0
  81. package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.js +277 -0
  82. package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.test.js +134 -0
  83. package/dist/collection/components/v-map-layergroup/v-map-layergroup.css +4 -0
  84. package/dist/collection/components/v-map-layergroup/v-map-layergroup.js +212 -0
  85. package/dist/collection/components/v-map-layergroup/v-map-layergroup.test.js +39 -0
  86. package/dist/collection/components/v-map-style/v-map-style.css +38 -0
  87. package/dist/collection/components/v-map-style/v-map-style.js +492 -0
  88. package/dist/collection/components/v-map-style/v-map-style.unit.js +62 -0
  89. package/dist/collection/index.js +1 -0
  90. package/dist/collection/layer/v-map-layer-helper.js +281 -0
  91. package/dist/collection/layer/v-map-layer-helper.unit.js +234 -0
  92. package/dist/collection/lib/cesium-loader.js +58 -0
  93. package/dist/collection/lib/ensure-importmap.js +12 -0
  94. package/dist/collection/lib/ensure-importmap.unit.js +57 -0
  95. package/dist/collection/lib/versions.gen.js +6 -0
  96. package/dist/collection/lib/vstyle.js +8 -0
  97. package/dist/collection/map-provider/cesium/CesiumGeoTIFFTerrainProvider.js +285 -0
  98. package/dist/collection/map-provider/cesium/CesiumLayerGroups.js +159 -0
  99. package/dist/collection/map-provider/cesium/GeoTIFFImageryProvider.js +192 -0
  100. package/dist/collection/map-provider/cesium/GeoTIFFImageryProvider.test.js +57 -0
  101. package/dist/collection/map-provider/cesium/cesium-provider.js +1408 -0
  102. package/dist/collection/map-provider/cesium/i-layer.js +1 -0
  103. package/dist/collection/map-provider/cesium/layer-manager.js +467 -0
  104. package/dist/collection/map-provider/deck/DeckGLGeoTIFFLayer.js +483 -0
  105. package/dist/collection/map-provider/deck/DeckGLGeoTIFFTerrainLayer.js +410 -0
  106. package/dist/collection/map-provider/deck/LayerGroupWithModel.js +169 -0
  107. package/dist/collection/map-provider/deck/LayerGroups.js +192 -0
  108. package/dist/collection/map-provider/deck/LayerModel.js +1 -0
  109. package/dist/collection/map-provider/deck/RenderableGroup.js +1 -0
  110. package/dist/collection/map-provider/deck/deck-provider.js +1563 -0
  111. package/dist/collection/map-provider/geotiff/geotiff-source.js +172 -0
  112. package/dist/collection/map-provider/geotiff/utils/AABB2D.js +24 -0
  113. package/dist/collection/map-provider/geotiff/utils/BVHNode2D.js +166 -0
  114. package/dist/collection/map-provider/geotiff/utils/GeoTIFFTileProcessor.js +484 -0
  115. package/dist/collection/map-provider/geotiff/utils/Triangle.js +1 -0
  116. package/dist/collection/map-provider/geotiff/utils/Triangulation.js +321 -0
  117. package/dist/collection/map-provider/geotiff/utils/colormap-utils.js +190 -0
  118. package/dist/collection/map-provider/geotiff/utils/normalization-utils.js +122 -0
  119. package/dist/collection/map-provider/geotiff/utils/sampling-utils.js +108 -0
  120. package/dist/collection/map-provider/leaflet/GeoTIFFGridLayer.js +147 -0
  121. package/dist/collection/map-provider/leaflet/WCSGridLayer.js +124 -0
  122. package/dist/collection/map-provider/leaflet/google-map-tiles-layer.js +352 -0
  123. package/dist/collection/map-provider/leaflet/leaflet-helpers.js +94 -0
  124. package/dist/collection/map-provider/leaflet/leaflet-provider.js +1095 -0
  125. package/dist/collection/map-provider/ol/CustomGeoTiff.js +145 -0
  126. package/dist/collection/map-provider/ol/openlayers-helper.js +26 -0
  127. package/dist/collection/map-provider/ol/openlayers-provider.js +1427 -0
  128. package/dist/collection/map-provider/provider-factory.js +44 -0
  129. package/dist/collection/map-provider/provider-factory.unit.js +66 -0
  130. package/dist/collection/testing/browser-test-utils.js +49 -0
  131. package/dist/collection/testing/e2e-testing.js +122 -0
  132. package/dist/collection/testing/e2e-utils.js +70 -0
  133. package/dist/collection/testing/geotiff-test-server.js +100 -0
  134. package/dist/collection/testing/mocks/geostyler-lyrx-parser.js +12 -0
  135. package/dist/collection/testing/mocks/geostyler-mapbox-parser.js +12 -0
  136. package/dist/collection/testing/mocks/geostyler-qgis-parser.js +12 -0
  137. package/dist/collection/testing/mocks/geostyler-sld-parser.js +13 -0
  138. package/dist/collection/testing/mocks/geostyler-style.js +5 -0
  139. package/dist/collection/testing/setupTests.browser.js +1 -0
  140. package/dist/collection/testing/setupTests.stencil.js +20 -0
  141. package/dist/collection/testing/setupTests.vitest.js +59 -0
  142. package/dist/collection/testing/stencil-testing-wrapper.js +43 -0
  143. package/dist/collection/testing/styleMock.js +1 -0
  144. package/dist/collection/types/color.js +1 -0
  145. package/dist/collection/types/cssmode.js +1 -0
  146. package/dist/collection/types/flavour.js +1 -0
  147. package/dist/collection/types/layerconfig.js +1 -0
  148. package/dist/collection/types/lonlat.js +1 -0
  149. package/dist/collection/types/mapinitoptions.js +1 -0
  150. package/dist/collection/types/mapprovider.js +1 -0
  151. package/dist/collection/types/provideroptions.js +1 -0
  152. package/dist/collection/types/styleconfig.js +19 -0
  153. package/dist/collection/types/styling.js +13 -0
  154. package/dist/collection/types/styling.unit.js +37 -0
  155. package/dist/collection/types/vmaplayer.js +1 -0
  156. package/dist/collection/utils/async-mutex.js +28 -0
  157. package/dist/collection/utils/diff.js +142 -0
  158. package/dist/collection/utils/diff.unit.js +59 -0
  159. package/dist/collection/utils/dom-env.js +43 -0
  160. package/dist/collection/utils/dom-env.unit.js +92 -0
  161. package/dist/collection/utils/events.js +8 -0
  162. package/dist/collection/utils/logger.js +183 -0
  163. package/dist/collection/utils/logger.unit.js +98 -0
  164. package/dist/collection/utils/messages.js +12 -0
  165. package/dist/collection/utils/spatial-utils.js +27 -0
  166. package/dist/collection/utils/spatial-utils.unit.js +24 -0
  167. package/dist/components/_commonjsHelpers.js +1 -0
  168. package/dist/components/cesium-provider.js +1 -0
  169. package/dist/components/deck-provider.js +1 -0
  170. package/dist/components/events.js +1 -0
  171. package/dist/components/geotiff-source.js +1 -0
  172. package/dist/components/geotiff.js +4 -0
  173. package/dist/components/index.browser.js +15 -0
  174. package/dist/components/index.d.ts +35 -0
  175. package/dist/components/index.js +1 -0
  176. package/dist/components/index2.js +1 -0
  177. package/dist/components/index3.js +1 -0
  178. package/dist/components/index4.js +1 -0
  179. package/dist/components/index5.js +1 -0
  180. package/dist/components/index6.js +1 -0
  181. package/dist/components/index7.js +1 -0
  182. package/dist/components/index8.js +7 -0
  183. package/dist/components/layer-extension.js +1 -0
  184. package/dist/components/leaflet-provider.js +1 -0
  185. package/dist/components/main-dist.js +1 -0
  186. package/dist/components/messages.js +1 -0
  187. package/dist/components/openlayers-provider.js +1 -0
  188. package/dist/components/polygon-layer.js +1 -0
  189. package/dist/components/scenegraph-layer.js +1 -0
  190. package/dist/components/styleconfig.js +1 -0
  191. package/dist/components/styling.js +1 -0
  192. package/dist/components/v-map-builder.d.ts +11 -0
  193. package/dist/components/v-map-builder.js +2 -0
  194. package/dist/components/v-map-layer-geojson.d.ts +11 -0
  195. package/dist/components/v-map-layer-geojson.js +1 -0
  196. package/dist/components/v-map-layer-geojson2.js +1 -0
  197. package/dist/components/v-map-layer-geotiff.d.ts +11 -0
  198. package/dist/components/v-map-layer-geotiff.js +1 -0
  199. package/dist/components/v-map-layer-geotiff2.js +1 -0
  200. package/dist/components/v-map-layer-google.d.ts +11 -0
  201. package/dist/components/v-map-layer-google.js +1 -0
  202. package/dist/components/v-map-layer-google2.js +1 -0
  203. package/dist/components/v-map-layer-helper.js +1 -0
  204. package/dist/components/v-map-layer-osm.d.ts +11 -0
  205. package/dist/components/v-map-layer-osm.js +1 -0
  206. package/dist/components/v-map-layer-osm2.js +1 -0
  207. package/dist/components/v-map-layer-scatterplot.d.ts +11 -0
  208. package/dist/components/v-map-layer-scatterplot.js +1 -0
  209. package/dist/components/v-map-layer-scatterplot2.js +1 -0
  210. package/dist/components/v-map-layer-terrain-geotiff.d.ts +11 -0
  211. package/dist/components/v-map-layer-terrain-geotiff.js +1 -0
  212. package/dist/components/v-map-layer-terrain.d.ts +11 -0
  213. package/dist/components/v-map-layer-terrain.js +1 -0
  214. package/dist/components/v-map-layer-terrain2.js +1 -0
  215. package/dist/components/v-map-layer-tile3d.d.ts +11 -0
  216. package/dist/components/v-map-layer-tile3d.js +1 -0
  217. package/dist/components/v-map-layer-tile3d2.js +1 -0
  218. package/dist/components/v-map-layer-wcs.d.ts +11 -0
  219. package/dist/components/v-map-layer-wcs.js +1 -0
  220. package/dist/components/v-map-layer-wcs2.js +1 -0
  221. package/dist/components/v-map-layer-wfs.d.ts +11 -0
  222. package/dist/components/v-map-layer-wfs.js +1 -0
  223. package/dist/components/v-map-layer-wfs2.js +1 -0
  224. package/dist/components/v-map-layer-wkt.d.ts +11 -0
  225. package/dist/components/v-map-layer-wkt.js +1 -0
  226. package/dist/components/v-map-layer-wkt2.js +1 -0
  227. package/dist/components/v-map-layer-wms.d.ts +11 -0
  228. package/dist/components/v-map-layer-wms.js +1 -0
  229. package/dist/components/v-map-layer-wms2.js +1 -0
  230. package/dist/components/v-map-layer-xyz.d.ts +11 -0
  231. package/dist/components/v-map-layer-xyz.js +1 -0
  232. package/dist/components/v-map-layer-xyz2.js +1 -0
  233. package/dist/components/v-map-layercontrol.d.ts +11 -0
  234. package/dist/components/v-map-layercontrol.js +1 -0
  235. package/dist/components/v-map-layergroup.d.ts +11 -0
  236. package/dist/components/v-map-layergroup.js +1 -0
  237. package/dist/components/v-map-layergroup2.js +1 -0
  238. package/dist/components/v-map-style.d.ts +11 -0
  239. package/dist/components/v-map-style.js +1 -0
  240. package/dist/components/v-map-style2.js +10 -0
  241. package/dist/components/v-map.d.ts +11 -0
  242. package/dist/components/v-map.js +1 -0
  243. package/dist/components/v-map2.js +1 -0
  244. package/dist/esm/_commonjsHelpers-E-ZsRS8r.js +32 -0
  245. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  246. package/dist/esm/cesium-provider-BJfAup3w.js +2596 -0
  247. package/dist/esm/deck-provider-C7U9VDEq.js +47709 -0
  248. package/dist/esm/geotiff-BEWxTIfH.js +45 -0
  249. package/dist/esm/geotiff-source-esnDnC-u.js +1516 -0
  250. package/dist/esm/index-B1zwA4IC.js +685 -0
  251. package/dist/esm/index-BBpiaTpT.js +165 -0
  252. package/dist/esm/index-BIEmlzCf.js +1697 -0
  253. package/dist/esm/index-BUHa4Jj0.js +307 -0
  254. package/dist/esm/index-DbSdn93t.js +20461 -0
  255. package/dist/esm/index-RpJarvr_.js +10656 -0
  256. package/dist/esm/index-jN06TXUp.js +14 -0
  257. package/dist/esm/index-jzneDarq.js +1613 -0
  258. package/dist/esm/index.browser-DhQAXuA7.js +6860 -0
  259. package/dist/esm/index.js +1 -0
  260. package/dist/esm/layer-extension-CZXK5goK.js +63 -0
  261. package/dist/esm/leaflet-provider-Q41TB6ku.js +1794 -0
  262. package/dist/esm/loader.js +11 -0
  263. package/dist/esm/main-dist-CwnA7_Xn.js +2652 -0
  264. package/dist/esm/messages-CMKJzsgL.js +180 -0
  265. package/dist/esm/openlayers-provider-CMsDsQTQ.js +1602 -0
  266. package/dist/esm/polygon-layer-ByhxGhWC.js +1295 -0
  267. package/dist/esm/scenegraph-layer-09K_B6DT.js +2526 -0
  268. package/dist/esm/styleconfig-B-bAcABs.js +21 -0
  269. package/dist/esm/v-map-builder.entry.js +3784 -0
  270. package/dist/esm/v-map-layer-geojson_12.entry.js +40881 -0
  271. package/dist/esm/v-map-layer-helper-Dys44Cgo.js +283 -0
  272. package/dist/esm/v-map-layer-terrain-geotiff.entry.js +256 -0
  273. package/dist/esm/v-map-layercontrol.entry.js +245 -0
  274. package/dist/esm/v-map.js +21 -0
  275. package/dist/esm/v-map.v-map-layer-osm.v-map-layergroup-B4pFHuSf.js +572 -0
  276. package/dist/esm/v-map_3.entry.js +4 -0
  277. package/dist/index.cjs.js +1 -0
  278. package/dist/index.js +1 -0
  279. package/dist/types/cesium-augment.d.ts +5 -0
  280. package/dist/types/components/v-map/v-map.d.ts +70 -0
  281. package/dist/types/components/v-map/v-map.test.d.ts +1 -0
  282. package/dist/types/components/v-map-builder/v-map-builder.d.ts +48 -0
  283. package/dist/types/components/v-map-builder/v-map-builder.test.d.ts +1 -0
  284. package/dist/types/components/v-map-layer-geojson/v-map-layer-geojson.d.ts +129 -0
  285. package/dist/types/components/v-map-layer-geojson/v-map-layer-geojson.test.d.ts +1 -0
  286. package/dist/types/components/v-map-layer-geotiff/v-map-layer-geotiff.d.ts +74 -0
  287. package/dist/types/components/v-map-layer-geotiff/v-map-layer-geotiff.test.d.ts +1 -0
  288. package/dist/types/components/v-map-layer-google/v-map-layer-google.d.ts +78 -0
  289. package/dist/types/components/v-map-layer-osm/error-api.test.d.ts +1 -0
  290. package/dist/types/components/v-map-layer-osm/v-map-layer-osm.d.ts +50 -0
  291. package/dist/types/components/v-map-layer-osm/v-map-layer-osm.test.d.ts +1 -0
  292. package/dist/types/components/v-map-layer-scatterplot/v-map-layer-scatterplot.d.ts +54 -0
  293. package/dist/types/components/v-map-layer-terrain/v-map-layer-terrain.d.ts +74 -0
  294. package/dist/types/components/v-map-layer-terrain/v-map-layer-terrain.test.d.ts +1 -0
  295. package/dist/types/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.d.ts +117 -0
  296. package/dist/types/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.test.d.ts +1 -0
  297. package/dist/types/components/v-map-layer-tile3d/v-map-layer-tile3d.d.ts +69 -0
  298. package/dist/types/components/v-map-layer-tile3d/v-map-layer-tile3d.test.d.ts +1 -0
  299. package/dist/types/components/v-map-layer-wcs/v-map-layer-wcs.d.ts +47 -0
  300. package/dist/types/components/v-map-layer-wcs/v-map-layer-wcs.test.d.ts +1 -0
  301. package/dist/types/components/v-map-layer-wfs/v-map-layer-wfs.d.ts +59 -0
  302. package/dist/types/components/v-map-layer-wfs/v-map-layer-wfs.test.d.ts +1 -0
  303. package/dist/types/components/v-map-layer-wkt/v-map-layer-wkt.d.ts +132 -0
  304. package/dist/types/components/v-map-layer-wkt/v-map-layer-wkt.test.d.ts +1 -0
  305. package/dist/types/components/v-map-layer-wms/v-map-layer-wms.d.ts +76 -0
  306. package/dist/types/components/v-map-layer-wms/v-map-layer-wms.test.d.ts +1 -0
  307. package/dist/types/components/v-map-layer-xyz/v-map-layer-xyz.d.ts +59 -0
  308. package/dist/types/components/v-map-layer-xyz/v-map-layer-xyz.test.d.ts +1 -0
  309. package/dist/types/components/v-map-layercontrol/v-map-layercontrol.d.ts +44 -0
  310. package/dist/types/components/v-map-layercontrol/v-map-layercontrol.test.d.ts +1 -0
  311. package/dist/types/components/v-map-layergroup/v-map-layergroup.d.ts +31 -0
  312. package/dist/types/components/v-map-layergroup/v-map-layergroup.test.d.ts +1 -0
  313. package/dist/types/components/v-map-style/v-map-style.d.ts +75 -0
  314. package/dist/types/components/v-map-style/v-map-style.unit.d.ts +1 -0
  315. package/dist/types/components.d.ts +2391 -0
  316. package/dist/types/globals.d.ts +16 -0
  317. package/dist/types/index.d.ts +10 -0
  318. package/dist/types/layer/v-map-layer-helper.d.ts +45 -0
  319. package/dist/types/layer/v-map-layer-helper.unit.d.ts +1 -0
  320. package/dist/types/leaflet-augment.d.ts +15 -0
  321. package/dist/types/lib/cesium-loader.d.ts +3 -0
  322. package/dist/types/lib/ensure-importmap.d.ts +3 -0
  323. package/dist/types/lib/ensure-importmap.unit.d.ts +1 -0
  324. package/dist/types/lib/versions.gen.d.ts +5 -0
  325. package/dist/types/lib/vstyle.d.ts +44 -0
  326. package/dist/types/map-provider/cesium/CesiumGeoTIFFTerrainProvider.d.ts +92 -0
  327. package/dist/types/map-provider/cesium/CesiumLayerGroups.d.ts +64 -0
  328. package/dist/types/map-provider/cesium/GeoTIFFImageryProvider.d.ts +75 -0
  329. package/dist/types/map-provider/cesium/GeoTIFFImageryProvider.test.d.ts +1 -0
  330. package/dist/types/map-provider/cesium/cesium-provider.d.ts +87 -0
  331. package/dist/types/map-provider/cesium/i-layer.d.ts +11 -0
  332. package/dist/types/map-provider/cesium/layer-manager.d.ts +31 -0
  333. package/dist/types/map-provider/deck/DeckGLGeoTIFFLayer.d.ts +91 -0
  334. package/dist/types/map-provider/deck/DeckGLGeoTIFFTerrainLayer.d.ts +82 -0
  335. package/dist/types/map-provider/deck/LayerGroupWithModel.d.ts +55 -0
  336. package/dist/types/map-provider/deck/LayerGroups.d.ts +63 -0
  337. package/dist/types/map-provider/deck/LayerModel.d.ts +8 -0
  338. package/dist/types/map-provider/deck/RenderableGroup.d.ts +20 -0
  339. package/dist/types/map-provider/deck/deck-provider.d.ts +92 -0
  340. package/dist/types/map-provider/geotiff/geotiff-source.d.ts +30 -0
  341. package/dist/types/map-provider/geotiff/utils/AABB2D.d.ts +28 -0
  342. package/dist/types/map-provider/geotiff/utils/BVHNode2D.d.ts +36 -0
  343. package/dist/types/map-provider/geotiff/utils/GeoTIFFTileProcessor.d.ts +116 -0
  344. package/dist/types/map-provider/geotiff/utils/Triangle.d.ts +5 -0
  345. package/dist/types/map-provider/geotiff/utils/Triangulation.d.ts +94 -0
  346. package/dist/types/map-provider/geotiff/utils/colormap-utils.d.ts +47 -0
  347. package/dist/types/map-provider/geotiff/utils/normalization-utils.d.ts +39 -0
  348. package/dist/types/map-provider/geotiff/utils/sampling-utils.d.ts +13 -0
  349. package/dist/types/map-provider/leaflet/GeoTIFFGridLayer.d.ts +34 -0
  350. package/dist/types/map-provider/leaflet/WCSGridLayer.d.ts +38 -0
  351. package/dist/types/map-provider/leaflet/google-map-tiles-layer.d.ts +73 -0
  352. package/dist/types/map-provider/leaflet/leaflet-helpers.d.ts +6 -0
  353. package/dist/types/map-provider/leaflet/leaflet-provider.d.ts +73 -0
  354. package/dist/types/map-provider/ol/CustomGeoTiff.d.ts +14 -0
  355. package/dist/types/map-provider/ol/openlayers-helper.d.ts +2 -0
  356. package/dist/types/map-provider/ol/openlayers-provider.d.ts +80 -0
  357. package/dist/types/map-provider/provider-factory.d.ts +12 -0
  358. package/dist/types/map-provider/provider-factory.unit.d.ts +1 -0
  359. package/dist/types/namespaces.d.ts +3 -0
  360. package/dist/types/ol-augment.d.ts +3 -0
  361. package/dist/types/ol-override.d.ts +7 -0
  362. package/dist/types/ol.d.ts +10 -0
  363. package/dist/types/stencil-public-runtime.d.ts +1860 -0
  364. package/dist/types/testing/browser-test-utils.d.ts +6 -0
  365. package/dist/types/testing/e2e-testing.d.ts +5 -0
  366. package/dist/types/testing/e2e-utils.d.ts +4 -0
  367. package/dist/types/testing/geotiff-test-server.d.ts +5 -0
  368. package/dist/types/testing/mocks/geostyler-lyrx-parser.d.ts +11 -0
  369. package/dist/types/testing/mocks/geostyler-mapbox-parser.d.ts +11 -0
  370. package/dist/types/testing/mocks/geostyler-qgis-parser.d.ts +11 -0
  371. package/dist/types/testing/mocks/geostyler-sld-parser.d.ts +11 -0
  372. package/dist/types/testing/mocks/geostyler-style.d.ts +5 -0
  373. package/dist/types/testing/setupTests.browser.d.ts +1 -0
  374. package/dist/types/testing/setupTests.stencil.d.ts +1 -0
  375. package/dist/types/testing/setupTests.vitest.d.ts +1 -0
  376. package/dist/types/testing/stencil-testing-wrapper.d.ts +3 -0
  377. package/dist/types/types/color.d.ts +1 -0
  378. package/dist/types/types/cssmode.d.ts +1 -0
  379. package/dist/types/types/flavour.d.ts +1 -0
  380. package/dist/types/types/layerconfig.d.ts +207 -0
  381. package/dist/types/types/lonlat.d.ts +1 -0
  382. package/dist/types/types/mapinitoptions.d.ts +4 -0
  383. package/dist/types/types/mapprovider.d.ts +46 -0
  384. package/dist/types/types/provideroptions.d.ts +8 -0
  385. package/dist/types/types/styleconfig.d.ts +27 -0
  386. package/dist/types/types/styling.d.ts +24 -0
  387. package/dist/types/types/styling.unit.d.ts +1 -0
  388. package/dist/types/types/vmaplayer.d.ts +10 -0
  389. package/dist/types/utils/async-mutex.d.ts +7 -0
  390. package/dist/types/utils/diff.d.ts +64 -0
  391. package/dist/types/utils/diff.unit.d.ts +1 -0
  392. package/dist/types/utils/dom-env.d.ts +5 -0
  393. package/dist/types/utils/dom-env.unit.d.ts +1 -0
  394. package/dist/types/utils/events.d.ts +29 -0
  395. package/dist/types/utils/logger.d.ts +47 -0
  396. package/dist/types/utils/logger.unit.d.ts +1 -0
  397. package/dist/types/utils/messages.d.ts +12 -0
  398. package/dist/types/utils/spatial-utils.d.ts +6 -0
  399. package/dist/types/utils/spatial-utils.unit.d.ts +1 -0
  400. package/dist/types/versions.d.ts +7 -0
  401. package/dist/v-map/index.esm.js +0 -0
  402. package/dist/v-map/p--vVleK-M.js +1 -0
  403. package/dist/v-map/p-09d10db0.entry.js +1 -0
  404. package/dist/v-map/p-5eba6058.entry.js +10 -0
  405. package/dist/v-map/p-6b102336.entry.js +1 -0
  406. package/dist/v-map/p-B-bAcABs.js +1 -0
  407. package/dist/v-map/p-BBpiaTpT.js +1 -0
  408. package/dist/v-map/p-BdijL4Av.js +1 -0
  409. package/dist/v-map/p-Be3r33VF.js +4 -0
  410. package/dist/v-map/p-BeFu0ap4.js +1 -0
  411. package/dist/v-map/p-BxFJezdK.js +1 -0
  412. package/dist/v-map/p-CMKJzsgL.js +1 -0
  413. package/dist/v-map/p-CXfA_q8m.js +1 -0
  414. package/dist/v-map/p-CZqY0yW4.js +1 -0
  415. package/dist/v-map/p-CafTHT9i.js +1 -0
  416. package/dist/v-map/p-DCTHyf58.js +1 -0
  417. package/dist/v-map/p-DQuL1Twl.js +1 -0
  418. package/dist/v-map/p-DR9McdNX.js +1 -0
  419. package/dist/v-map/p-Dckgonw8.js +1 -0
  420. package/dist/v-map/p-DhQAXuA7.js +15 -0
  421. package/dist/v-map/p-DmICdG34.js +7 -0
  422. package/dist/v-map/p-DrOQ9V4h.js +1 -0
  423. package/dist/v-map/p-DvHXtWUg.js +1 -0
  424. package/dist/v-map/p-E-ZsRS8r.js +1 -0
  425. package/dist/v-map/p-MyTSFnEk.js +1 -0
  426. package/dist/v-map/p-RpJarvr_.js +1 -0
  427. package/dist/v-map/p-WaMDUuAz.js +1 -0
  428. package/dist/v-map/p-aa410e64.entry.js +2 -0
  429. package/dist/v-map/p-c21c93fe.entry.js +1 -0
  430. package/dist/v-map/p-jzneDarq.js +2 -0
  431. package/dist/v-map/p-uiIP-taz.js +1 -0
  432. package/dist/v-map/v-map.esm.js +1 -0
  433. package/loader/cdn.js +1 -0
  434. package/loader/index.cjs.js +1 -0
  435. package/loader/index.d.ts +24 -0
  436. package/loader/index.es2017.js +1 -0
  437. package/loader/index.js +2 -0
  438. package/package.json +193 -0
@@ -0,0 +1,1427 @@
1
+ import Map from "ol/Map";
2
+ import View from "ol/View";
3
+ import VectorLayer from "ol/layer/Vector";
4
+ import LayerGroup from "ol/layer/Group";
5
+ import TileLayer from "ol/layer/Tile";
6
+ import ImageLayer from "ol/layer/Image";
7
+ import VectorSource from "ol/source/Vector";
8
+ import TileWMS from "ol/source/TileWMS";
9
+ import OSM from "ol/source/OSM";
10
+ import XYZ from "ol/source/XYZ";
11
+ import Google from "ol/source/Google";
12
+ import TileArcGISRest from "ol/source/TileArcGISRest";
13
+ import OlImageWrapper from "ol/Image";
14
+ import ImageSource from "ol/source/Image";
15
+ import GeoJSON from "ol/format/GeoJSON";
16
+ import GML2 from "ol/format/GML2";
17
+ import GML3 from "ol/format/GML3";
18
+ import GML32 from "ol/format/GML32";
19
+ import WKT from "ol/format/WKT";
20
+ import Control from "ol/control/Control";
21
+ import OlStyle from "ol/style/Style";
22
+ import OlFill from "ol/style/Fill";
23
+ import OlStroke from "ol/style/Stroke";
24
+ import OlCircle from "ol/style/Circle";
25
+ import OlIcon from "ol/style/Icon";
26
+ import OlText from "ol/style/Text";
27
+ import { bbox as bboxStrategy } from "ol/loadingstrategy";
28
+ import { fromLonLat } from "ol/proj";
29
+ import { DEFAULT_STYLE } from "../../types/styleconfig";
30
+ import { log, error } from "../../utils/logger";
31
+ import { injectOlCss } from "./openlayers-helper";
32
+ import { createCustomGeoTiff } from "./CustomGeoTiff";
33
+ import WebGLTileLayer from "ol/layer/WebGLTile";
34
+ export class OpenLayersProvider {
35
+ map;
36
+ layers = [];
37
+ baseLayers = [];
38
+ googleLogoAdded = false;
39
+ projection = 'EPSG:3857';
40
+ layerErrorCallbacks = new globalThis.Map();
41
+ layerErrorCleanups = new globalThis.Map();
42
+ async init(options) {
43
+ await injectOlCss(options.shadowRoot);
44
+ Object.assign(options.target.style, {
45
+ width: '100%',
46
+ height: '100%',
47
+ position: 'relative',
48
+ background: '#fff',
49
+ });
50
+ this.map = new Map({
51
+ target: options.target,
52
+ // layers: [new TileLayer({ source: new OSM() })],
53
+ layers: [],
54
+ view: new View({
55
+ projection: this.projection,
56
+ center: fromLonLat(options?.mapInitOptions?.center ?? [0, 0]),
57
+ zoom: options?.mapInitOptions?.zoom ?? 2,
58
+ }),
59
+ });
60
+ new ResizeObserver(() => this.map?.updateSize()).observe(options.target);
61
+ }
62
+ async destroy() {
63
+ this.map?.setTarget(undefined);
64
+ this.map = undefined;
65
+ }
66
+ async updateLayer(layerId, update) {
67
+ const layer = await this._getLayerById(layerId);
68
+ switch (update.type) {
69
+ case 'geojson':
70
+ await this.updateGeoJSONLayer(layer, update.data);
71
+ break;
72
+ case 'osm':
73
+ await this.updateOSMLayer(layer, update.data);
74
+ break;
75
+ case 'wms':
76
+ await this.updateWMSLayer(layer, update.data);
77
+ break;
78
+ case 'wfs':
79
+ await this.updateWFSLayer(layer, update.data);
80
+ break;
81
+ case 'wcs':
82
+ await this.updateWCSLayer(layer, update.data);
83
+ break;
84
+ case 'arcgis':
85
+ await this.updateArcGISLayer(layer, update.data);
86
+ break;
87
+ case 'wkt':
88
+ await this.updateWKTLayer(layer, update.data);
89
+ break;
90
+ case 'geotiff':
91
+ await this.updateGeoTIFFLayer(layer, update.data);
92
+ break;
93
+ }
94
+ }
95
+ async ensureGroup(groupId, visible, _opts) {
96
+ await this._ensureGroup(groupId, visible);
97
+ }
98
+ async _ensureGroup(groupId, visible) {
99
+ if (!this.map) {
100
+ return null;
101
+ }
102
+ let group = this.layers.find(l => l.get?.('groupId') === groupId);
103
+ if (!group) {
104
+ group = new LayerGroup({
105
+ layers: [],
106
+ properties: {
107
+ groupId: groupId,
108
+ visible: typeof visible !== undefined ? visible : true,
109
+ },
110
+ });
111
+ this.map.addLayer(group);
112
+ this.layers.push(group);
113
+ }
114
+ return group;
115
+ }
116
+ async setBaseLayer(groupId, layerElementId) {
117
+ if (layerElementId === null) {
118
+ log('ol - setBaseLayer - layerElementId is null.');
119
+ return;
120
+ }
121
+ const group = this.layers.find(l => l.get?.('groupId') === groupId);
122
+ const layer = this.baseLayers.find(l => l.get('layerElementId') === layerElementId);
123
+ if (layer === undefined) {
124
+ log('ol - setBaseLayer - layer not found. layerElementId: ' +
125
+ layerElementId);
126
+ return;
127
+ }
128
+ group.getLayers().clear();
129
+ group.getLayers().push(layer);
130
+ //group.set('layerId', layerId, false);
131
+ }
132
+ async addBaseLayer(layerConfig, basemapid, layerElementId) {
133
+ if (layerElementId === undefined || layerElementId === null) {
134
+ log('ol - addBaseLayer - layerElementId not set.');
135
+ return null;
136
+ }
137
+ if (basemapid === undefined || basemapid === null) {
138
+ log('ol - addBaseLayer - basemapid not set.');
139
+ }
140
+ const group = await this._ensureGroup(layerConfig.groupId, layerConfig.groupVisible);
141
+ if (group == null) {
142
+ return null;
143
+ }
144
+ group.set('basemap', true, false);
145
+ const layer = await this.createLayer(layerConfig);
146
+ if (layer == null) {
147
+ return null;
148
+ }
149
+ layer.set('group', group);
150
+ this.baseLayers.push(layer);
151
+ let layerId = null;
152
+ if (layer) {
153
+ layerId = crypto.randomUUID();
154
+ layer.set('id', layerId, false);
155
+ layer.set('layerElementId', layerElementId, false);
156
+ const common = layerConfig;
157
+ if (common.opacity !== undefined) {
158
+ layer.setOpacity(common.opacity);
159
+ }
160
+ if (common.zIndex !== undefined) {
161
+ layer.setZIndex(common.zIndex);
162
+ }
163
+ if (common.visible) {
164
+ layer.setVisible(true);
165
+ }
166
+ else if (common.visible === false) {
167
+ layer.setVisible(false);
168
+ }
169
+ if (basemapid === layerElementId) {
170
+ group.getLayers().clear();
171
+ group.getLayers().push(layer);
172
+ //group.set('layerId', layerId, false);
173
+ }
174
+ }
175
+ return layerId;
176
+ }
177
+ async addLayerToGroup(layerConfig) {
178
+ const group = await this._ensureGroup(layerConfig.groupId, layerConfig.groupVisible);
179
+ if (group == null) {
180
+ return null;
181
+ }
182
+ const layer = await this.createLayer(layerConfig);
183
+ if (layer === null) {
184
+ return null;
185
+ }
186
+ layer.set('group', group);
187
+ group.getLayers().push(layer);
188
+ const layerId = crypto.randomUUID();
189
+ layer.set('id', layerId, false);
190
+ const common = layerConfig;
191
+ if (common.opacity !== undefined) {
192
+ layer.setOpacity(common.opacity);
193
+ }
194
+ if (common.zIndex !== undefined) {
195
+ layer.setZIndex(common.zIndex);
196
+ }
197
+ if (common.visible) {
198
+ layer.setVisible(true);
199
+ }
200
+ else if (common.visible === false) {
201
+ layer.setVisible(false);
202
+ }
203
+ return layerId;
204
+ }
205
+ async createLayer(layerConfig) {
206
+ switch (layerConfig.type) {
207
+ case 'geojson':
208
+ return this.createGeoJSONLayer(layerConfig);
209
+ case 'xyz':
210
+ return this.createXYZLayer(layerConfig);
211
+ case 'google':
212
+ return this.createGoogleLayer(layerConfig);
213
+ case 'osm':
214
+ return this.createOSMLayer(layerConfig);
215
+ case 'wms':
216
+ return this.createWMSLayer(layerConfig);
217
+ case 'wfs':
218
+ return this.createWFSLayer(layerConfig);
219
+ case 'wcs':
220
+ return this.createWCSLayer(layerConfig);
221
+ case 'arcgis':
222
+ return this.createArcGISLayer(layerConfig);
223
+ case 'wkt':
224
+ return this.createWKTLayer(layerConfig);
225
+ case 'geotiff':
226
+ return this.createGeoTIFFLayer(layerConfig);
227
+ default:
228
+ throw new Error(`Unsupported layer type: ${layerConfig.type}`);
229
+ }
230
+ }
231
+ async updateWMSLayer(layer, data) {
232
+ layer.setSource(new TileWMS({
233
+ url: data.url,
234
+ params: {
235
+ LAYERS: data.layers,
236
+ TILED: true,
237
+ ...(data.extraParams ?? {}),
238
+ },
239
+ }));
240
+ }
241
+ async updateOSMLayer(layer, data) {
242
+ let url = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
243
+ if (data.url) {
244
+ url = data.url + '/{z}/{x}/{y}.png';
245
+ }
246
+ layer.setSource(new OSM({
247
+ url: url,
248
+ }));
249
+ }
250
+ async updateGeoJSONLayer(layer, data) {
251
+ let vectorSource = null;
252
+ const geojsonOptions = {
253
+ featureProjection: this.projection,
254
+ };
255
+ if (data.geojson) {
256
+ const geojsonObject = JSON.parse(data.geojson);
257
+ vectorSource = new VectorSource({
258
+ features: new GeoJSON(geojsonOptions).readFeatures(geojsonObject),
259
+ });
260
+ }
261
+ else {
262
+ vectorSource = new VectorSource({
263
+ url: data.url,
264
+ format: new GeoJSON(geojsonOptions),
265
+ });
266
+ }
267
+ layer.setSource(vectorSource);
268
+ let layerStyle;
269
+ if (data.geostylerStyle) {
270
+ layerStyle = await this.createGeostylerStyleFunction(data.geostylerStyle);
271
+ }
272
+ else if (data.style) {
273
+ layerStyle = await this.createEnhancedStyleFunction(data.style);
274
+ }
275
+ if (layerStyle) {
276
+ layer.setStyle(layerStyle);
277
+ }
278
+ }
279
+ async updateWFSLayer(layer, data) {
280
+ const merged = this.mergeLayerConfig(layer, 'wfsConfig', data);
281
+ const vectorSource = await this.createWFSSpource(merged);
282
+ layer.setSource(vectorSource);
283
+ // Apply style if provided
284
+ let layerStyle;
285
+ if (merged.geostylerStyle) {
286
+ layerStyle = await this.createGeostylerStyleFunction(merged.geostylerStyle);
287
+ }
288
+ else if (merged.style) {
289
+ layerStyle = await this.createEnhancedStyleFunction(merged.style);
290
+ }
291
+ if (layerStyle) {
292
+ layer.setStyle(layerStyle);
293
+ }
294
+ }
295
+ async updateWCSLayer(layer, data) {
296
+ const merged = this.mergeLayerConfig(layer, 'wcsConfig', data);
297
+ const source = await this.createWcsSource(merged);
298
+ layer.setSource(source);
299
+ }
300
+ async updateArcGISLayer(layer, data) {
301
+ const tileLayer = layer;
302
+ const currentSource = tileLayer.getSource();
303
+ const params = {
304
+ ...(currentSource?.getParams?.() ?? {}),
305
+ ...(data?.params ?? {}),
306
+ };
307
+ if (data?.token) {
308
+ params.token = data.token;
309
+ }
310
+ const sourceOptions = {
311
+ url: data?.url ??
312
+ currentSource?.getUrls?.()?.[0],
313
+ params,
314
+ ...(data?.options ?? {}),
315
+ };
316
+ const arcgisSource = new TileArcGISRest(sourceOptions);
317
+ tileLayer.setSource(arcgisSource);
318
+ }
319
+ async createEnhancedStyleFunction(style) {
320
+ // Helper method to apply opacity to colors
321
+ function applyOpacity(color, opacity) {
322
+ if (color.startsWith('rgba')) {
323
+ // Extract rgb values and apply new opacity
324
+ const rgbMatch = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
325
+ if (rgbMatch) {
326
+ const [, r, g, b] = rgbMatch;
327
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
328
+ }
329
+ }
330
+ else if (color.startsWith('rgb')) {
331
+ const rgbMatch = color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
332
+ if (rgbMatch) {
333
+ const [, r, g, b] = rgbMatch;
334
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
335
+ }
336
+ }
337
+ else if (color.startsWith('#')) {
338
+ // Convert hex to rgba
339
+ const hex = color.slice(1);
340
+ const r = parseInt(hex.slice(0, 2), 16);
341
+ const g = parseInt(hex.slice(2, 4), 16);
342
+ const b = parseInt(hex.slice(4, 6), 16);
343
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
344
+ }
345
+ return color; // Return original if can't parse
346
+ }
347
+ return (feature) => {
348
+ const styles = [];
349
+ const geometry = feature.getGeometry();
350
+ const geometryType = geometry.getType();
351
+ // Create fill style
352
+ const fillColor = style.fillColor ?? 'rgba(0,100,255,0.3)';
353
+ const fillOpacity = style.fillOpacity ?? 0.3;
354
+ const fill = new OlFill({
355
+ color: applyOpacity(fillColor, fillOpacity),
356
+ });
357
+ // Create stroke style
358
+ const strokeColor = style.strokeColor ?? 'rgba(0,100,255,1)';
359
+ const strokeOpacity = style.strokeOpacity ?? 1;
360
+ const strokeWidth = style.strokeWidth ?? 2;
361
+ const stroke = new OlStroke({
362
+ color: applyOpacity(strokeColor, strokeOpacity),
363
+ width: strokeWidth,
364
+ lineDash: style.strokeDashArray,
365
+ });
366
+ // Point styling
367
+ if (geometryType === 'Point') {
368
+ if (style.iconUrl) {
369
+ // Icon style for points
370
+ styles.push(new OlStyle({
371
+ image: new OlIcon({
372
+ src: style.iconUrl,
373
+ size: style.iconSize || [32, 32],
374
+ anchor: style.iconAnchor || [0.5, 1],
375
+ }),
376
+ }));
377
+ }
378
+ else {
379
+ // Circle style for points
380
+ const pointColor = style.pointColor ?? 'rgba(0,100,255,1)';
381
+ const pointOpacity = style.pointOpacity ?? 1;
382
+ const pointRadius = style.pointRadius ?? 6;
383
+ styles.push(new OlStyle({
384
+ image: new OlCircle({
385
+ radius: pointRadius,
386
+ fill: new OlFill({
387
+ color: applyOpacity(pointColor, pointOpacity),
388
+ }),
389
+ stroke: stroke,
390
+ }),
391
+ }));
392
+ }
393
+ }
394
+ else {
395
+ // Polygon and line styling
396
+ styles.push(new OlStyle({
397
+ fill: geometryType.includes('Polygon') ? fill : undefined,
398
+ stroke: stroke,
399
+ }));
400
+ }
401
+ // Text labeling
402
+ if (style.textProperty && feature.get(style.textProperty)) {
403
+ const textColor = style.textColor ?? '#000000';
404
+ const textSize = style.textSize ?? 12;
405
+ const textHaloColor = style.textHaloColor;
406
+ const textHaloWidth = style.textHaloWidth ?? 2;
407
+ const textOffset = style.textOffset || [0, 0];
408
+ styles.push(new OlStyle({
409
+ text: new OlText({
410
+ text: String(feature.get(style.textProperty)),
411
+ font: `${textSize}px Arial`,
412
+ fill: new OlFill({ color: textColor }),
413
+ stroke: textHaloColor
414
+ ? new OlStroke({
415
+ color: textHaloColor,
416
+ width: textHaloWidth,
417
+ })
418
+ : undefined,
419
+ offsetX: textOffset[0],
420
+ offsetY: textOffset[1],
421
+ }),
422
+ }));
423
+ }
424
+ return styles;
425
+ };
426
+ }
427
+ async createGeoJSONLayer(config) {
428
+ let vectorSource = null;
429
+ const geojsonOptions = {
430
+ featureProjection: this.projection,
431
+ };
432
+ if (config.geojson) {
433
+ const geojsonObject = JSON.parse(config.geojson);
434
+ vectorSource = new VectorSource({
435
+ features: new GeoJSON(geojsonOptions).readFeatures(geojsonObject),
436
+ });
437
+ }
438
+ else {
439
+ vectorSource = new VectorSource({
440
+ url: config.url,
441
+ format: new GeoJSON(geojsonOptions),
442
+ });
443
+ }
444
+ // // Create enhanced style function
445
+ // const styleFunction = (feature: any) => {
446
+ // const styles = [];
447
+ // const geometry = feature.getGeometry();
448
+ // const geometryType = geometry.getType();
449
+ // // Base style configuration
450
+ // const style = config.style || {};
451
+ // // Create fill style
452
+ // const fillColor = style.fillColor ?? 'rgba(0,100,255,0.3)';
453
+ // const fillOpacity = style.fillOpacity ?? 0.3;
454
+ // const fill = new Fill({
455
+ // color: this.applyOpacity(fillColor, fillOpacity),
456
+ // });
457
+ // // Create stroke style
458
+ // const strokeColor = style.strokeColor ?? 'rgba(0,100,255,1)';
459
+ // const strokeOpacity = style.strokeOpacity ?? 1;
460
+ // const strokeWidth = style.strokeWidth ?? 2;
461
+ // const stroke = new Stroke({
462
+ // color: this.applyOpacity(strokeColor, strokeOpacity),
463
+ // width: strokeWidth,
464
+ // lineDash: style.strokeDashArray,
465
+ // });
466
+ // // Point styling
467
+ // if (geometryType === 'Point') {
468
+ // if (style.iconUrl) {
469
+ // // Icon style for points
470
+ // styles.push(
471
+ // new Style({
472
+ // image: new Icon({
473
+ // src: style.iconUrl,
474
+ // size: style.iconSize || [32, 32],
475
+ // anchor: style.iconAnchor || [0.5, 1],
476
+ // }),
477
+ // }),
478
+ // );
479
+ // } else {
480
+ // // Circle style for points
481
+ // const pointColor = style.pointColor ?? 'rgba(0,100,255,1)';
482
+ // const pointOpacity = style.pointOpacity ?? 1;
483
+ // const pointRadius = style.pointRadius ?? 6;
484
+ // styles.push(
485
+ // new Style({
486
+ // image: new Circle({
487
+ // radius: pointRadius,
488
+ // fill: new Fill({
489
+ // color: this.applyOpacity(pointColor, pointOpacity),
490
+ // }),
491
+ // stroke: stroke,
492
+ // }),
493
+ // }),
494
+ // );
495
+ // }
496
+ // } else {
497
+ // // Polygon and line styling
498
+ // styles.push(
499
+ // new Style({
500
+ // fill: geometryType.includes('Polygon') ? fill : undefined,
501
+ // stroke: stroke,
502
+ // }),
503
+ // );
504
+ // }
505
+ // // Text labeling
506
+ // if (style.textProperty && feature.get(style.textProperty)) {
507
+ // const textColor = style.textColor ?? '#000000';
508
+ // const textSize = style.textSize ?? 12;
509
+ // const textHaloColor = style.textHaloColor;
510
+ // const textHaloWidth = style.textHaloWidth ?? 2;
511
+ // const textOffset = style.textOffset || [0, 0];
512
+ // styles.push(
513
+ // new Style({
514
+ // text: new Text({
515
+ // text: String(feature.get(style.textProperty)),
516
+ // font: `${textSize}px Arial`,
517
+ // fill: new Fill({ color: textColor }),
518
+ // stroke: textHaloColor
519
+ // ? new Stroke({
520
+ // color: textHaloColor,
521
+ // width: textHaloWidth,
522
+ // })
523
+ // : undefined,
524
+ // offsetX: textOffset[0],
525
+ // offsetY: textOffset[1],
526
+ // }),
527
+ // }),
528
+ // );
529
+ // }
530
+ // return styles;
531
+ // };
532
+ // Use geostyler style if available, otherwise use default style function
533
+ let layerStyle;
534
+ if (config.geostylerStyle) {
535
+ layerStyle = await this.createGeostylerStyleFunction(config.geostylerStyle);
536
+ }
537
+ else {
538
+ const style = config.style
539
+ ? { ...DEFAULT_STYLE, ...config.style }
540
+ : DEFAULT_STYLE;
541
+ layerStyle = await this.createEnhancedStyleFunction(style);
542
+ }
543
+ const layer = new VectorLayer({
544
+ source: vectorSource,
545
+ style: layerStyle,
546
+ });
547
+ return layer;
548
+ }
549
+ async createWFSSpource(config) {
550
+ const outputFormat = (config.outputFormat ?? 'application/json').toLowerCase();
551
+ let format = new GeoJSON();
552
+ switch (outputFormat) {
553
+ case 'gml2':
554
+ format = new GML2();
555
+ break;
556
+ case 'gml3':
557
+ format = new GML3();
558
+ break;
559
+ case 'gml32':
560
+ format = new GML32();
561
+ break;
562
+ }
563
+ const urlFunction = this.getWFSGetFeatureUrl(config);
564
+ const vectorSource = new VectorSource({
565
+ format: format,
566
+ url: urlFunction,
567
+ strategy: bboxStrategy,
568
+ });
569
+ return vectorSource;
570
+ }
571
+ async createWFSLayer(config) {
572
+ const vectorSource = await this.createWFSSpource(config);
573
+ // Use geostyler style if available, otherwise use default style function
574
+ let layerStyle;
575
+ if (config.geostylerStyle) {
576
+ layerStyle = await this.createGeostylerStyleFunction(config.geostylerStyle);
577
+ }
578
+ else {
579
+ const style = config.style
580
+ ? { ...DEFAULT_STYLE, ...config.style }
581
+ : DEFAULT_STYLE;
582
+ layerStyle = await this.createEnhancedStyleFunction(style);
583
+ }
584
+ const layer = new VectorLayer({
585
+ source: vectorSource,
586
+ style: layerStyle,
587
+ });
588
+ layer.set('wfsConfig', config, false);
589
+ return layer;
590
+ }
591
+ // private async createWFSLayer2(
592
+ // config: Extract<LayerConfig, { type: 'wfs' }>,
593
+ // ): Promise<Layer> {
594
+ // const [{ default: VectorLayer }] = await Promise.all([
595
+ // import('ol/layer/Vector'),
596
+ // ]);
597
+ // const geojson = await this.fetchWFSFromUrl(config);
598
+ // const vectorSource = await this.createVectorSourceFromGeoJSON(geojson);
599
+ // // Use geostyler style if available, otherwise use default style function
600
+ // let layerStyle;
601
+ // if (config.geostylerStyle) {
602
+ // layerStyle = await this.createGeostylerStyleFunction(
603
+ // config.geostylerStyle,
604
+ // );
605
+ // } else {
606
+ // const style = config.style
607
+ // ? { ...DEFAULT_STYLE, ...config.style }
608
+ // : DEFAULT_STYLE;
609
+ // layerStyle = await this.createEnhancedStyleFunction(style);
610
+ // }
611
+ // const layer = new VectorLayer({
612
+ // source: vectorSource,
613
+ // style: layerStyle,
614
+ // visible: config.visible ?? true,
615
+ // });
616
+ // layer.set('wfsConfig', config, false);
617
+ // return layer as unknown as Layer;
618
+ // }
619
+ /**
620
+ * Convert a GeoStyler style to an OpenLayers style function.
621
+ *
622
+ * TODO: Replace this hand-rolled conversion (~200 lines) with
623
+ * geostyler-openlayers-parser's writeStyle(). The official parser
624
+ * covers more symbolizer types, handles filters, and stays in sync
625
+ * with the GeoStyler spec. See:
626
+ * https://github.com/geostyler/geostyler-openlayers-parser
627
+ */
628
+ async createGeostylerStyleFunction(geostylerStyle) {
629
+ // Helper to extract static value from GeoStyler property (could be function or value)
630
+ const getValue = (prop, defaultValue = undefined) => {
631
+ if (prop === undefined || prop === null)
632
+ return defaultValue;
633
+ // If it's a GeoStyler function object, we can't evaluate it here - return default
634
+ if (typeof prop === 'object' && prop.name)
635
+ return defaultValue;
636
+ return prop;
637
+ };
638
+ return (feature) => {
639
+ const styles = [];
640
+ const geometry = feature.getGeometry();
641
+ const geometryType = geometry.getType();
642
+ // Process each rule in the geostyler style
643
+ if (geostylerStyle.rules) {
644
+ for (const rule of geostylerStyle.rules) {
645
+ // TODO: Add filter evaluation for rule.filter
646
+ if (rule.symbolizers) {
647
+ for (const symbolizer of rule.symbolizers) {
648
+ switch (symbolizer.kind) {
649
+ case 'Fill':
650
+ if (geometryType.includes('Polygon')) {
651
+ const fillColor = getValue(symbolizer.color, 'rgba(0,100,255,0.3)');
652
+ const outlineColor = getValue(symbolizer.outlineColor);
653
+ const outlineWidth = getValue(symbolizer.outlineWidth, 1);
654
+ styles.push(new OlStyle({
655
+ fill: new OlFill({
656
+ color: fillColor,
657
+ }),
658
+ stroke: outlineColor
659
+ ? new OlStroke({
660
+ color: outlineColor,
661
+ width: outlineWidth,
662
+ })
663
+ : undefined,
664
+ }));
665
+ }
666
+ break;
667
+ case 'Line':
668
+ {
669
+ const lineColor = getValue(symbolizer.color, 'rgba(0,100,255,1)');
670
+ const lineWidth = getValue(symbolizer.width, 1);
671
+ const dashArray = symbolizer.dasharray
672
+ ? Array.isArray(symbolizer.dasharray)
673
+ ? symbolizer.dasharray.map(v => getValue(v, 0))
674
+ : undefined
675
+ : undefined;
676
+ styles.push(new OlStyle({
677
+ stroke: new OlStroke({
678
+ color: lineColor,
679
+ width: lineWidth,
680
+ lineDash: dashArray,
681
+ }),
682
+ }));
683
+ }
684
+ break;
685
+ case 'Mark':
686
+ if (geometryType === 'Point') {
687
+ const markColor = getValue(symbolizer.color, 'rgba(0,100,255,1)');
688
+ const markRadius = getValue(symbolizer.radius, 6);
689
+ const strokeColor = getValue(symbolizer.strokeColor);
690
+ const strokeWidth = getValue(symbolizer.strokeWidth, 1);
691
+ styles.push(new OlStyle({
692
+ image: new OlCircle({
693
+ radius: markRadius,
694
+ fill: new OlFill({
695
+ color: markColor,
696
+ }),
697
+ stroke: strokeColor
698
+ ? new OlStroke({
699
+ color: strokeColor,
700
+ width: strokeWidth,
701
+ })
702
+ : undefined,
703
+ }),
704
+ }));
705
+ }
706
+ break;
707
+ case 'Icon':
708
+ if (geometryType === 'Point') {
709
+ const iconSrc = getValue(symbolizer.image);
710
+ const iconSize = getValue(symbolizer.size, 32);
711
+ const iconOpacity = getValue(symbolizer.opacity, 1);
712
+ if (iconSrc && typeof iconSrc === 'string') {
713
+ styles.push(new OlStyle({
714
+ image: new OlIcon({
715
+ src: iconSrc,
716
+ size: [iconSize, iconSize],
717
+ opacity: iconOpacity,
718
+ }),
719
+ }));
720
+ }
721
+ }
722
+ break;
723
+ case 'Text':
724
+ {
725
+ const textSym = symbolizer;
726
+ const labelProp = getValue(textSym.label);
727
+ if (labelProp && feature.get(labelProp)) {
728
+ const textColor = getValue(textSym.color, '#000000');
729
+ const textSize = getValue(textSym.size, 12);
730
+ const textFont = getValue(textSym.font?.[0], 'Arial');
731
+ const haloColor = getValue(textSym.haloColor);
732
+ const haloWidth = getValue(textSym.haloWidth, 1);
733
+ const offset = textSym.offset;
734
+ const offsetX = offset && Array.isArray(offset)
735
+ ? getValue(offset[0], 0)
736
+ : 0;
737
+ const offsetY = offset && Array.isArray(offset)
738
+ ? getValue(offset[1], 0)
739
+ : 0;
740
+ styles.push(new OlStyle({
741
+ text: new OlText({
742
+ text: String(feature.get(labelProp)),
743
+ font: `${textSize}px ${textFont}`,
744
+ fill: new OlFill({
745
+ color: textColor,
746
+ }),
747
+ stroke: haloColor
748
+ ? new OlStroke({
749
+ color: haloColor,
750
+ width: haloWidth,
751
+ })
752
+ : undefined,
753
+ offsetX: offsetX,
754
+ offsetY: offsetY,
755
+ }),
756
+ }));
757
+ }
758
+ }
759
+ break;
760
+ }
761
+ }
762
+ }
763
+ }
764
+ }
765
+ return styles.length > 0 ? styles : undefined;
766
+ };
767
+ }
768
+ async createXYZLayer(config) {
769
+ return new TileLayer({
770
+ source: new XYZ({
771
+ url: config.url,
772
+ attributions: config.attributions,
773
+ maxZoom: config.maxZoom ?? 19,
774
+ ...(config.options ?? {}),
775
+ }),
776
+ });
777
+ }
778
+ async createGoogleLayer(config) {
779
+ if (!config.apiKey) {
780
+ throw new Error("Google-Layer benötigt 'apiKey' (Google Maps Platform).");
781
+ }
782
+ // Optionen auf ol/source/Google abbilden
783
+ const source = new Google({
784
+ key: config.apiKey,
785
+ mapType: config.mapType ?? 'roadmap', // roadmap | satellite | terrain | hybrid
786
+ // optional:
787
+ scale: config.scale ?? 'scaleFactor2x', // 'scaleFactor1x' | 'scaleFactor2x' | 'scaleFactor4x'
788
+ highDpi: config.highDpi ?? true,
789
+ language: config.language,
790
+ region: config.region,
791
+ imageFormat: config.imageFormat,
792
+ styles: config.styles,
793
+ layerTypes: config.layerTypes,
794
+ });
795
+ source.on('change', () => {
796
+ if (source.getState() === 'error') {
797
+ // Fehler transparent machen (z.B. ungültiger Key / Billing)
798
+ const err = source.getError();
799
+ error('Google source error', err);
800
+ this.map.getTargetElement()?.dispatchEvent(new CustomEvent('google-source-error', {
801
+ detail: { message: err ?? 'Google source error' },
802
+ bubbles: true,
803
+ composed: true,
804
+ }));
805
+ }
806
+ });
807
+ const layer = new TileLayer({ source });
808
+ // Google Logo/Branding: als Control ergänzen (unten links)
809
+ if (!this.googleLogoAdded) {
810
+ class GoogleLogoControl extends Control {
811
+ constructor() {
812
+ const el = document.createElement('img');
813
+ el.style.pointerEvents = 'none';
814
+ el.style.position = 'absolute';
815
+ el.style.bottom = '5px';
816
+ el.style.left = '5px';
817
+ el.style.height = '18px';
818
+ el.alt = 'Google';
819
+ el.src =
820
+ 'https://developers.google.com/static/maps/documentation/images/google_on_white.png';
821
+ super({ element: el });
822
+ }
823
+ }
824
+ this.map.addControl(new GoogleLogoControl());
825
+ this.googleLogoAdded = true;
826
+ }
827
+ return layer;
828
+ }
829
+ async createOSMLayer(config) {
830
+ let url = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
831
+ if (config.url) {
832
+ url = config.url + '/{z}/{x}/{y}.png';
833
+ }
834
+ const layer = new TileLayer({
835
+ source: new OSM({
836
+ url: url,
837
+ }),
838
+ });
839
+ return layer;
840
+ }
841
+ async createWMSLayer(config) {
842
+ return new TileLayer({
843
+ source: new TileWMS({
844
+ url: config.url,
845
+ params: {
846
+ LAYERS: config.layers,
847
+ TILED: true,
848
+ ...(config.extraParams ?? {}),
849
+ },
850
+ }),
851
+ });
852
+ }
853
+ // ── Runtime error listeners ──────────────────────────────────────
854
+ onLayerError(layerId, callback) {
855
+ this.layerErrorCallbacks.set(layerId, callback);
856
+ this._getLayerById(layerId).then(layer => {
857
+ if (!layer)
858
+ return;
859
+ this.attachSourceErrorListeners(layerId, layer);
860
+ });
861
+ }
862
+ offLayerError(layerId) {
863
+ this.layerErrorCleanups.get(layerId)?.();
864
+ this.layerErrorCleanups.delete(layerId);
865
+ this.layerErrorCallbacks.delete(layerId);
866
+ }
867
+ attachSourceErrorListeners(layerId, layer) {
868
+ // Clean up previous listeners for this layer (e.g. after source replacement)
869
+ this.layerErrorCleanups.get(layerId)?.();
870
+ const cb = this.layerErrorCallbacks.get(layerId);
871
+ if (!cb)
872
+ return;
873
+ const source = layer.getSource?.();
874
+ if (!source)
875
+ return;
876
+ const cleanups = [];
877
+ // Tile sources (OSM, XYZ, WMS, ArcGIS, Google)
878
+ if ('getTile' in source || source instanceof TileWMS || source instanceof OSM || source instanceof XYZ || source instanceof Google || source instanceof TileArcGISRest) {
879
+ const handler = () => { cb({ type: 'network', message: 'Tile load error' }); };
880
+ source.on('tileloaderror', handler);
881
+ cleanups.push(() => source.un('tileloaderror', handler));
882
+ }
883
+ // Vector sources (GeoJSON URL, WFS)
884
+ if (source instanceof VectorSource) {
885
+ const handler = () => { cb({ type: 'network', message: 'Feature load error' }); };
886
+ source.on('featuresloaderror', handler);
887
+ cleanups.push(() => source.un('featuresloaderror', handler));
888
+ }
889
+ // Image sources (WCS)
890
+ if (source instanceof ImageSource) {
891
+ const handler = () => { cb({ type: 'network', message: 'Image load error' }); };
892
+ source.on('imageloaderror', handler);
893
+ cleanups.push(() => source.un('imageloaderror', handler));
894
+ }
895
+ // Re-attach on source replacement (e.g. updateWMSLayer)
896
+ const sourceChangeHandler = () => {
897
+ this.attachSourceErrorListeners(layerId, layer);
898
+ };
899
+ layer.on('change:source', sourceChangeHandler);
900
+ cleanups.push(() => layer.un('change:source', sourceChangeHandler));
901
+ this.layerErrorCleanups.set(layerId, () => cleanups.forEach(fn => fn()));
902
+ }
903
+ async setView(center, zoom) {
904
+ if (!this.map)
905
+ return;
906
+ this.map
907
+ .getView()
908
+ .animate({ center: fromLonLat(center), zoom, duration: 0 });
909
+ }
910
+ async _forEachLayer(layerOrGroup, callback) {
911
+ // Wenn das aktuelle Objekt eine LayerGroup ist, rufen wir die Funktion für jedes Kind erneut auf
912
+ if (layerOrGroup instanceof LayerGroup) {
913
+ const layers = layerOrGroup.getLayers().getArray(); // Array der Unter‑Layer
914
+ for (const child of layers) {
915
+ if (await this._forEachLayer(child, callback)) {
916
+ return true;
917
+ }
918
+ }
919
+ }
920
+ else {
921
+ // Es handelt sich um einen normalen Layer → Callback ausführen
922
+ if (callback(layerOrGroup)) {
923
+ return true;
924
+ }
925
+ }
926
+ return false;
927
+ }
928
+ async _getLayerById(layerId) {
929
+ if (!this.map) {
930
+ return null;
931
+ }
932
+ let layerFound = null;
933
+ await this._forEachLayer(this.map.getLayerGroup(), layer => {
934
+ if (layer.get('id') === layerId) {
935
+ layerFound = layer;
936
+ return true;
937
+ }
938
+ });
939
+ if (layerFound)
940
+ return layerFound;
941
+ layerFound = this.baseLayers.find(l => l.get('id') === layerId);
942
+ if (layerFound === undefined)
943
+ return null;
944
+ return layerFound;
945
+ }
946
+ async _getLayerGroupById(groupId) {
947
+ if (!this.map) {
948
+ return null;
949
+ }
950
+ const group = this.layers.find(l => l.get?.('groupId') === groupId);
951
+ if (group !== undefined)
952
+ return group;
953
+ return null;
954
+ }
955
+ async removeLayer(layerId) {
956
+ if (!layerId) {
957
+ return;
958
+ }
959
+ this.offLayerError(layerId);
960
+ const layer = await this._getLayerById(layerId);
961
+ if (layer) {
962
+ const group = layer.get('group');
963
+ if (group)
964
+ group.getLayers().remove(layer);
965
+ }
966
+ }
967
+ async setOpacity(layerId, opacity) {
968
+ if (!layerId) {
969
+ return;
970
+ }
971
+ const layer = await this._getLayerById(layerId);
972
+ if (layer) {
973
+ layer.setOpacity(opacity);
974
+ }
975
+ }
976
+ async setZIndex(layerId, zIndex) {
977
+ if (!layerId) {
978
+ return;
979
+ }
980
+ const layer = await this._getLayerById(layerId);
981
+ if (layer) {
982
+ layer.setZIndex(zIndex);
983
+ }
984
+ }
985
+ async setVisible(layerId, visible) {
986
+ const layer = await this._getLayerById(layerId);
987
+ if (layer) {
988
+ layer.setVisible(visible);
989
+ }
990
+ }
991
+ async setGroupVisible(groupId, visible) {
992
+ const layer = await this._getLayerGroupById(groupId);
993
+ if (layer) {
994
+ layer.setVisible(visible);
995
+ }
996
+ }
997
+ async updateWKTLayer(layer, data) {
998
+ const wktFormat = new WKT();
999
+ let vectorSource = null;
1000
+ // Get the view's projection to ensure correct coordinate transformation
1001
+ const viewProjection = this.map?.getView()?.getProjection();
1002
+ if (data.wkt) {
1003
+ // Parse WKT string directly
1004
+ const feature = wktFormat.readFeature(data.wkt, {
1005
+ dataProjection: 'EPSG:4326',
1006
+ featureProjection: viewProjection,
1007
+ });
1008
+ vectorSource = new VectorSource({
1009
+ features: [feature],
1010
+ });
1011
+ }
1012
+ else if (data.url) {
1013
+ // Fetch WKT from URL
1014
+ const response = await fetch(data.url);
1015
+ if (!response.ok)
1016
+ throw new Error(`Failed to fetch WKT: ${response.status}`);
1017
+ const wktText = await response.text();
1018
+ const feature = wktFormat.readFeature(wktText, {
1019
+ dataProjection: 'EPSG:4326',
1020
+ featureProjection: viewProjection,
1021
+ });
1022
+ vectorSource = new VectorSource({
1023
+ features: [feature],
1024
+ });
1025
+ }
1026
+ if (vectorSource) {
1027
+ layer.setSource(vectorSource);
1028
+ }
1029
+ let layerStyle;
1030
+ if (data.geostylerStyle) {
1031
+ layerStyle = await this.createGeostylerStyleFunction(data.geostylerStyle);
1032
+ }
1033
+ else if (data.style) {
1034
+ layerStyle = await this.createEnhancedStyleFunction(data.style);
1035
+ }
1036
+ if (layerStyle) {
1037
+ layer.setStyle(layerStyle);
1038
+ }
1039
+ }
1040
+ async createWKTLayer(config) {
1041
+ const wktFormat = new WKT();
1042
+ let vectorSource = null;
1043
+ // Get the view's projection to ensure correct coordinate transformation
1044
+ const viewProjection = this.map?.getView()?.getProjection();
1045
+ if (config.wkt) {
1046
+ // Parse WKT string directly
1047
+ try {
1048
+ const feature = wktFormat.readFeature(config.wkt, {
1049
+ dataProjection: 'EPSG:4326',
1050
+ featureProjection: viewProjection,
1051
+ });
1052
+ vectorSource = new VectorSource({
1053
+ features: [feature],
1054
+ });
1055
+ }
1056
+ catch (e) {
1057
+ error('Failed to parse WKT:', e);
1058
+ vectorSource = new VectorSource({ features: [] });
1059
+ }
1060
+ }
1061
+ else if (config.url) {
1062
+ // Fetch WKT from URL
1063
+ try {
1064
+ const response = await fetch(config.url);
1065
+ if (!response.ok)
1066
+ throw new Error(`Failed to fetch WKT: ${response.status}`);
1067
+ const wktText = await response.text();
1068
+ const feature = wktFormat.readFeature(wktText, {
1069
+ dataProjection: 'EPSG:4326',
1070
+ featureProjection: viewProjection,
1071
+ });
1072
+ vectorSource = new VectorSource({
1073
+ features: [feature],
1074
+ });
1075
+ }
1076
+ catch (e) {
1077
+ error('Failed to load WKT from URL:', e);
1078
+ vectorSource = new VectorSource({ features: [] });
1079
+ }
1080
+ }
1081
+ else {
1082
+ vectorSource = new VectorSource({ features: [] });
1083
+ }
1084
+ // Use geostyler style if available, otherwise use default style function
1085
+ let layerStyle;
1086
+ if (config.geostylerStyle) {
1087
+ layerStyle = await this.createGeostylerStyleFunction(config.geostylerStyle);
1088
+ }
1089
+ else {
1090
+ const style = config.style
1091
+ ? { ...DEFAULT_STYLE, ...config.style }
1092
+ : DEFAULT_STYLE;
1093
+ layerStyle = await this.createEnhancedStyleFunction(style);
1094
+ }
1095
+ const layer = new VectorLayer({
1096
+ source: vectorSource,
1097
+ style: layerStyle,
1098
+ opacity: config.opacity ?? 1,
1099
+ visible: config.visible ?? true,
1100
+ zIndex: config.zIndex ?? 1000,
1101
+ });
1102
+ return layer;
1103
+ }
1104
+ async createGeoTIFFLayer(config) {
1105
+ if (!config.url) {
1106
+ throw new Error('GeoTIFF layer requires a URL');
1107
+ }
1108
+ const srcInfo = {
1109
+ url: config.url,
1110
+ };
1111
+ if (config.nodata !== null && !isNaN(config.nodata)) {
1112
+ srcInfo.nodata = config.nodata;
1113
+ }
1114
+ const CustomGeoTiff = await createCustomGeoTiff({
1115
+ sources: [srcInfo],
1116
+ wrapX: false, // Prevent rendering tiles beyond extent
1117
+ });
1118
+ const source = new CustomGeoTiff();
1119
+ await source.registerProjectionIfNeeded();
1120
+ const layer = new WebGLTileLayer({
1121
+ source,
1122
+ opacity: config.opacity ?? 1,
1123
+ visible: config.visible ?? true,
1124
+ zIndex: config.zIndex ?? 100,
1125
+ });
1126
+ return layer;
1127
+ }
1128
+ // private async createGeoTIFFLayer(
1129
+ // config: Extract<LayerConfig, { type: 'geotiff' }>,
1130
+ // ): Promise<Layer> {
1131
+ // if (!config.url) {
1132
+ // throw new Error('GeoTIFF layer requires a URL');
1133
+ // }
1134
+ // createCustomGeoTiff;
1135
+ // const source = new GeoTIFF({
1136
+ // sources: [
1137
+ // {
1138
+ // url: config.url,
1139
+ // },
1140
+ // ],
1141
+ // });
1142
+ // const layer = new TileLayer({
1143
+ // source,
1144
+ // opacity: config.opacity ?? 1,
1145
+ // visible: config.visible ?? true,
1146
+ // zIndex: config.zIndex ?? 1000,
1147
+ // });
1148
+ // return layer;
1149
+ // }
1150
+ async createWCSLayer(config) {
1151
+ const source = await this.createWcsSource(config);
1152
+ const layer = new ImageLayer({
1153
+ source,
1154
+ visible: config.visible ?? true,
1155
+ opacity: config.opacity ?? 1,
1156
+ });
1157
+ layer.set('wcsConfig', config, false);
1158
+ return layer;
1159
+ }
1160
+ getWFSGetFeatureUrl(config) {
1161
+ return (extent) => {
1162
+ const wfsVersion = config.version ?? '1.1.0';
1163
+ const baseParams = {
1164
+ service: 'WFS',
1165
+ request: 'GetFeature',
1166
+ version: wfsVersion,
1167
+ typeName: config.typeName,
1168
+ outputFormat: config.outputFormat ?? 'application/json',
1169
+ bbox: extent.join(','),
1170
+ srsName: config.srsName ?? this.projection,
1171
+ };
1172
+ const params = { ...baseParams, ...(config.params ?? {}) };
1173
+ const requestUrl = this.appendParams(config.url, params);
1174
+ return requestUrl;
1175
+ };
1176
+ }
1177
+ /**
1178
+ * Erstellt eine WCS GetCoverage URL mit dynamischem BBOX für WCS 2.0.1 und 1.x.x
1179
+ */
1180
+ getWCSGetCoverageUrl(config, resolution) {
1181
+ return (extent) => {
1182
+ const wcsVersion = config.version ?? '2.0.1';
1183
+ const format = config.format ?? 'image/tiff';
1184
+ const projection = config.projection ?? this.projection;
1185
+ const params = {
1186
+ SERVICE: 'WCS',
1187
+ REQUEST: 'GetCoverage',
1188
+ VERSION: wcsVersion,
1189
+ FORMAT: format,
1190
+ };
1191
+ // WCS 2.0.1 verwendet andere Parameter als 1.x.x
1192
+ if (wcsVersion.startsWith('2.0')) {
1193
+ // WCS 2.0.1: coverageId und subset Parameter
1194
+ params.coverageId = config.coverageName;
1195
+ // BBOX als subset Parameter für WCS 2.0.1
1196
+ // subset=X(minx,maxx)&subset=Y(miny,maxy)
1197
+ const [minx, miny, maxx, maxy] = extent;
1198
+ params['subset'] = `X(${minx},${maxx})`;
1199
+ params['subset2'] = `Y(${miny},${maxy})`;
1200
+ // Ausgabeformat-Optionen für GeoTIFF FLOAT32
1201
+ if (format.includes('tiff') || format.includes('geotiff')) {
1202
+ // Für GeoTIFF können wir geotiff:compression etc. in params übergeben
1203
+ params['geotiff:compression'] = 'LZW';
1204
+ }
1205
+ }
1206
+ else {
1207
+ // WCS 1.x.x: COVERAGE und BBOX Parameter
1208
+ params.COVERAGE = config.coverageName;
1209
+ params.BBOX = extent.join(',');
1210
+ params.CRS = projection;
1211
+ // Width und Height für 1.x.x berechnen
1212
+ const width = Math.round((extent[2] - extent[0]) / resolution);
1213
+ const height = Math.round((extent[3] - extent[1]) / resolution);
1214
+ params.WIDTH = width;
1215
+ params.HEIGHT = height;
1216
+ }
1217
+ // Zusätzliche Parameter aus config hinzufügen (nur string/number)
1218
+ if (config.params) {
1219
+ Object.entries(config.params).forEach(([key, value]) => {
1220
+ if (typeof value === 'string' || typeof value === 'number') {
1221
+ params[key] = value;
1222
+ }
1223
+ });
1224
+ }
1225
+ // Für WCS 2.0.1 müssen subset Parameter speziell behandelt werden
1226
+ if (wcsVersion.startsWith('2.0')) {
1227
+ const subset2 = params['subset2'];
1228
+ delete params['subset2'];
1229
+ const query = new URLSearchParams();
1230
+ Object.entries(params).forEach(([key, value]) => {
1231
+ if (value !== undefined && value !== null) {
1232
+ query.append(key, String(value));
1233
+ }
1234
+ });
1235
+ // Zweiten subset Parameter hinzufügen
1236
+ if (subset2) {
1237
+ query.append('subset', String(subset2));
1238
+ }
1239
+ const baseUrl = config.url;
1240
+ return `${baseUrl}${baseUrl.includes('?') ? '&' : '?'}${query.toString()}`;
1241
+ }
1242
+ else {
1243
+ return this.appendParams(config.url, params);
1244
+ }
1245
+ };
1246
+ }
1247
+ // private async fetchWFSFromUrl(
1248
+ // config: Extract<LayerConfig, { type: 'wfs' }>,
1249
+ // ): Promise<any> {
1250
+ // const wfsVersion = config.version ?? '1.1.0';
1251
+ // const baseParams = {
1252
+ // service: 'WFS',
1253
+ // request: 'GetFeature',
1254
+ // version: wfsVersion,
1255
+ // typeName: config.typeName,
1256
+ // outputFormat: config.outputFormat ?? 'application/json',
1257
+ // srsName: config.srsName ?? (this.projection as string),
1258
+ // };
1259
+ // const params = { ...baseParams, ...(config.params ?? {}) };
1260
+ // const requestUrl = this.appendParams(config.url, params);
1261
+ // const response = await fetch(requestUrl);
1262
+ // if (!response.ok) {
1263
+ // throw new Error(
1264
+ // `WFS request failed (${response.status} ${response.statusText})`,
1265
+ // );
1266
+ // }
1267
+ // const outputFormat = (
1268
+ // config.outputFormat ?? 'application/json'
1269
+ // ).toLowerCase();
1270
+ // // Handle JSON formats
1271
+ // if (
1272
+ // outputFormat.includes('json') ||
1273
+ // outputFormat.includes('geojson') ||
1274
+ // outputFormat === 'application/json'
1275
+ // ) {
1276
+ // return await response.json();
1277
+ // }
1278
+ // // Handle GML formats using OpenLayers WFS parser
1279
+ // if (outputFormat.includes('gml') || outputFormat.includes('xml')) {
1280
+ // const text = await response.text();
1281
+ // const [
1282
+ // { default: WFS },
1283
+ // { default: GeoJSON },
1284
+ // { default: GML2 },
1285
+ // { default: GML3 },
1286
+ // { default: GML32 },
1287
+ // ] = await Promise.all([
1288
+ // import('ol/format/WFS'),
1289
+ // import('ol/format/GeoJSON'),
1290
+ // import('ol/format/GML2'),
1291
+ // import('ol/format/GML3'),
1292
+ // import('ol/format/GML32'),
1293
+ // ]);
1294
+ // const wfsOptions: any = {};
1295
+ // wfsOptions.version = wfsVersion;
1296
+ // switch (outputFormat) {
1297
+ // case 'gml2':
1298
+ // wfsOptions.gmlFormat = new GML2();
1299
+ // break;
1300
+ // case 'gml3':
1301
+ // wfsOptions.gmlFormat = new GML3();
1302
+ // break;
1303
+ // case 'gml32':
1304
+ // wfsOptions.gmlFormat = new GML32();
1305
+ // break;
1306
+ // }
1307
+ // const wfsFormat = new WFS(wfsOptions);
1308
+ // const features = wfsFormat.readFeatures(text);
1309
+ // // Convert features to GeoJSON
1310
+ // const geojsonFormat = new GeoJSON();
1311
+ // const geojson = JSON.parse(
1312
+ // geojsonFormat.writeFeatures(features, {
1313
+ // featureProjection: this.projection,
1314
+ // dataProjection: config.srsName ?? (this.projection as string),
1315
+ // }),
1316
+ // );
1317
+ // return geojson;
1318
+ // }
1319
+ // // Default: try to parse as JSON
1320
+ // return await response.json();
1321
+ // }
1322
+ // private async createVectorSourceFromGeoJSON(
1323
+ // geojson: any,
1324
+ // ): Promise<VectorSource> {
1325
+ // const [{ default: VectorSource }, { default: GeoJSON }] = await Promise.all(
1326
+ // [import('ol/source/Vector'), import('ol/format/GeoJSON')],
1327
+ // );
1328
+ // const format = new GeoJSON({ featureProjection: this.projection });
1329
+ // return new VectorSource({
1330
+ // features: format.readFeatures(geojson),
1331
+ // });
1332
+ // }
1333
+ mergeLayerConfig(layer, key, data) {
1334
+ const previous = layer.get(key) ?? {};
1335
+ const merged = { ...previous, ...data };
1336
+ layer.set(key, merged, false);
1337
+ return merged;
1338
+ }
1339
+ appendParams(baseUrl, params) {
1340
+ const query = new URLSearchParams();
1341
+ Object.entries(params).forEach(([key, value]) => {
1342
+ if (value !== undefined && value !== null) {
1343
+ query.set(key, String(value));
1344
+ }
1345
+ });
1346
+ if (!query.toString())
1347
+ return baseUrl;
1348
+ return `${baseUrl}${baseUrl.includes('?') ? '&' : '?'}${query.toString()}`;
1349
+ }
1350
+ /**
1351
+ * Erstellt eine WCS Image Source mit dynamischem BBOX-basierten Loading
1352
+ * Unterstützt WCS 2.0.1 und 1.x.x mit GeoTIFF FLOAT32
1353
+ */
1354
+ async createWcsSource(config) {
1355
+ const projection = config.projection ?? this.projection;
1356
+ const resolution = this.map?.getView()?.getResolution() ?? 1;
1357
+ const urlFunction = this.getWCSGetCoverageUrl(config, resolution);
1358
+ // Custom Image Source für WCS mit dynamischem BBOX
1359
+ class WCSImageSource extends ImageSource {
1360
+ urlFunction_;
1361
+ constructor(urlFunction) {
1362
+ super({
1363
+ projection: projection,
1364
+ resolutions: config.resolutions,
1365
+ // imageLoadFunction wird automatisch verwendet wenn url() implementiert ist
1366
+ });
1367
+ this.urlFunction_ = urlFunction;
1368
+ }
1369
+ // Überschreibe url()-Methode für dynamische URL-Generierung
1370
+ getImageInternal(extent, resolution, pixelRatio, _projection) {
1371
+ const url = this.urlFunction_(extent);
1372
+ // Erstelle Image mit der generierten URL
1373
+ const image = new OlImageWrapper(extent, resolution, pixelRatio, url);
1374
+ // Setze Custom Loader für CORS
1375
+ image.load = () => {
1376
+ const img = image.getImage();
1377
+ if (img.src !== url) {
1378
+ img.crossOrigin = 'anonymous';
1379
+ img.src = url;
1380
+ }
1381
+ };
1382
+ return image;
1383
+ }
1384
+ }
1385
+ return new WCSImageSource(urlFunction);
1386
+ }
1387
+ async createArcGISLayer(config) {
1388
+ const params = {
1389
+ ...(config.params ?? {}),
1390
+ };
1391
+ if (config.token) {
1392
+ params.token = config.token;
1393
+ }
1394
+ const sourceOptions = {
1395
+ url: config.url,
1396
+ params,
1397
+ ...(config.options ?? {}),
1398
+ };
1399
+ const layer = new TileLayer({
1400
+ source: new TileArcGISRest(sourceOptions),
1401
+ visible: config.visible ?? true,
1402
+ });
1403
+ return layer;
1404
+ }
1405
+ async updateGeoTIFFLayer(layer, data) {
1406
+ if (!data.url) {
1407
+ throw new Error('GeoTIFF update requires a URL');
1408
+ }
1409
+ const srcInfo = {
1410
+ url: data.url,
1411
+ };
1412
+ if (data.nodata !== null && data.nodata !== undefined && !isNaN(data.nodata)) {
1413
+ srcInfo.nodata = data.nodata;
1414
+ }
1415
+ const CustomGeoTiff = await createCustomGeoTiff({
1416
+ sources: [srcInfo],
1417
+ wrapX: false, // Prevent rendering tiles beyond extent
1418
+ });
1419
+ const source = new CustomGeoTiff();
1420
+ await source.registerProjectionIfNeeded();
1421
+ // Update source on the layer
1422
+ layer.setSource(source);
1423
+ }
1424
+ getMap() {
1425
+ return this.map;
1426
+ }
1427
+ }