@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,1697 @@
1
+ import { o as config, q as formatValue, s as equals, t as degrees, v as radians, w as length, x as clamp, V as Vector3, y as lerp, z as scale, A as add, D as worldToLngLat, E as lngLatToWorld, F as sub, H as scaleToZoom, J as length$1, K as zoomToScale, N as projectPosition, O as COORDINATE_SYSTEM, Q as getUniformsFromViewport, R as DirectionalLight, M as Model, G as Geometry, u as uid, X as Pass, Y as initializeShaderModule, Z as Viewport, _ as fovyToAltitude, $ as pixelsToWorld, a0 as Matrix4, a1 as negate, a2 as getMeterZoom, a3 as Controller, a4 as LinearInterpolator, a5 as ViewState, a6 as mod, a7 as View, a8 as MapState, a9 as MAX_LATITUDE, aa as zoomAdjust, ab as WebMercatorViewport, ac as GlobeViewport, ad as TransitionInterpolator, ae as lerp$1 } from './deck-provider-C7U9VDEq.js';
2
+ export { aj as AmbientLight, ao as Attribute, ap as AttributeManager, C as CompositeLayer, am as Deck, aq as DeckRenderer, L as Layer, an as LayerManager, ai as LightingEffect, au as MapController, at as MapView, ah as OPERATION, av as TRANSITION_EVENTS, ay as Tesselator, U as UNIT, af as VERSION, aH as Widget, aI as _Component, aJ as _ComponentState, ak as _LayersPass, al as _PickLayersPass, aF as _applyStyles, aE as _compareProps, aB as _count, d as _deepEqual, az as _fillArray, aA as _flatten, aC as _memoize, aD as _mergeShaders, aG as _removeStyles, aw as assert, c as color, l as createIterable, ax as fp64LowPart, ag as getShaderAssembler, i as gouraudMaterial, j as log, k as phongMaterial, a as picking, ar as project, p as project32, as as shadow } from './deck-provider-C7U9VDEq.js';
3
+ export { L as LayerExtension } from './layer-extension-CZXK5goK.js';
4
+ import './styleconfig-B-bAcABs.js';
5
+ import './index.browser-DhQAXuA7.js';
6
+ import './index-BUHa4Jj0.js';
7
+ import './_commonjsHelpers-E-ZsRS8r.js';
8
+ import './messages-CMKJzsgL.js';
9
+ import './geotiff-source-esnDnC-u.js';
10
+ import '@loaders.gl/core';
11
+ import '@loaders.gl/images';
12
+ import '@loaders.gl/loader-utils';
13
+ import '@loaders.gl/terrain';
14
+ import '@loaders.gl/schema';
15
+
16
+ // math.gl
17
+ // SPDX-License-Identifier: MIT
18
+ // Copyright (c) vis.gl contributors
19
+ // Copyright (c) 2017 Uber Technologies, Inc.
20
+ // TODO - import epsilon
21
+ const EPSILON$1 = 0.000001;
22
+ const EARTH_RADIUS_METERS = 6371000;
23
+ /**
24
+ * The poles (phi) are at the positive and negative y axis.
25
+ * The equator starts at positive z.
26
+ * @link https://en.wikipedia.org/wiki/Spherical_coordinate_system
27
+ */
28
+ class SphericalCoordinates {
29
+ // bearing: number;
30
+ // pitch: number;
31
+ // altitude: number;
32
+ // lnglatZ coordinates
33
+ // longitude: number;
34
+ // latitude: number;
35
+ // lng: number;
36
+ // lat: number;
37
+ // z: number;
38
+ /**
39
+ * Creates a new SphericalCoordinates object
40
+ * @param options
41
+ * @param [options.phi] =0 - rotation around X (latitude)
42
+ * @param [options.theta] =0 - rotation around Y (longitude)
43
+ * @param [options.radius] =1 - Distance from center
44
+ * @param [options.bearing]
45
+ * @param [options.pitch]
46
+ * @param [options.altitude]
47
+ * @param [options.radiusScale] =1
48
+ */
49
+ // eslint-disable-next-line complexity
50
+ constructor({ phi = 0, theta = 0, radius = 1, bearing, pitch, altitude, radiusScale = EARTH_RADIUS_METERS } = {}) {
51
+ this.phi = phi;
52
+ this.theta = theta;
53
+ // TODO - silently accepts illegal 0
54
+ this.radius = radius || altitude || 1; // radial distance from center
55
+ this.radiusScale = radiusScale || 1; // Used by lngLatZ
56
+ if (bearing !== undefined) {
57
+ this.bearing = bearing; // up / down towards top and bottom pole
58
+ }
59
+ if (pitch !== undefined) {
60
+ this.pitch = pitch; // around the equator of the sphere
61
+ }
62
+ this.check();
63
+ }
64
+ toString() {
65
+ return this.formatString(config);
66
+ }
67
+ formatString({ printTypes = false }) {
68
+ const f = formatValue;
69
+ return `${printTypes ? 'Spherical' : ''}\
70
+ [rho:${f(this.radius)},theta:${f(this.theta)},phi:${f(this.phi)}]`;
71
+ }
72
+ equals(other) {
73
+ return (equals(this.radius, other.radius) &&
74
+ equals(this.theta, other.theta) &&
75
+ equals(this.phi, other.phi));
76
+ }
77
+ exactEquals(other) {
78
+ return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
79
+ }
80
+ /* eslint-disable brace-style */
81
+ // Cartographic (bearing 0 north, pitch 0 look from above)
82
+ get bearing() {
83
+ return 180 - degrees(this.phi);
84
+ }
85
+ set bearing(v) {
86
+ this.phi = Math.PI - radians(v);
87
+ }
88
+ get pitch() {
89
+ return degrees(this.theta);
90
+ }
91
+ set pitch(v) {
92
+ this.theta = radians(v);
93
+ }
94
+ // get pitch() { return 90 - degrees(this.phi); }
95
+ // set pitch(v) { this.phi = radians(v) + Math.PI / 2; }
96
+ // get altitude() { return this.radius - 1; } // relative altitude
97
+ // lnglatZ coordinates
98
+ get longitude() {
99
+ return degrees(this.phi);
100
+ }
101
+ get latitude() {
102
+ return degrees(this.theta);
103
+ }
104
+ get lng() {
105
+ return degrees(this.phi);
106
+ }
107
+ get lat() {
108
+ return degrees(this.theta);
109
+ }
110
+ get z() {
111
+ return (this.radius - 1) * this.radiusScale;
112
+ }
113
+ /* eslint-enable brace-style */
114
+ set(radius, phi, theta) {
115
+ this.radius = radius;
116
+ this.phi = phi;
117
+ this.theta = theta;
118
+ return this.check();
119
+ }
120
+ clone() {
121
+ return new SphericalCoordinates().copy(this);
122
+ }
123
+ copy(other) {
124
+ this.radius = other.radius;
125
+ this.phi = other.phi;
126
+ this.theta = other.theta;
127
+ return this.check();
128
+ }
129
+ fromLngLatZ([lng, lat, z]) {
130
+ this.radius = 1 + z / this.radiusScale;
131
+ this.phi = radians(lat);
132
+ this.theta = radians(lng);
133
+ return this.check();
134
+ }
135
+ fromVector3(v) {
136
+ this.radius = length(v);
137
+ if (this.radius > 0) {
138
+ this.theta = Math.atan2(v[0], v[1]); // equator angle around y-up axis
139
+ this.phi = Math.acos(clamp(v[2] / this.radius, -1, 1)); // polar angle
140
+ }
141
+ return this.check();
142
+ }
143
+ toVector3() {
144
+ return new Vector3(0, 0, this.radius)
145
+ .rotateX({ radians: this.theta })
146
+ .rotateZ({ radians: this.phi });
147
+ }
148
+ // restrict phi to be betwee EPS and PI-EPS
149
+ makeSafe() {
150
+ this.phi = Math.max(EPSILON$1, Math.min(Math.PI - EPSILON$1, this.phi));
151
+ return this;
152
+ }
153
+ check() {
154
+ // this.makeSafe();
155
+ if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
156
+ throw new Error('SphericalCoordinates: some fields set to invalid numbers');
157
+ }
158
+ return this;
159
+ }
160
+ }
161
+
162
+ const EPSILON = 0.01;
163
+ const VIEWPORT_TRANSITION_PROPS = ['longitude', 'latitude', 'zoom'];
164
+ const DEFAULT_OPTS$1 = {
165
+ curve: 1.414,
166
+ speed: 1.2
167
+ // screenSpeed and maxDuration are used only if specified
168
+ };
169
+ /**
170
+ * mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.
171
+ * It implements “Smooth and efficient zooming and panning.” algorithm by
172
+ * "Jarke J. van Wijk and Wim A.A. Nuij"
173
+ */
174
+ function flyToViewport(startProps, endProps, t, options) {
175
+ // Equations from above paper are referred where needed.
176
+ const { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0 } = getFlyToTransitionParams(startProps, endProps, options);
177
+ // If change in center is too small, do linear interpolaiton.
178
+ if (u1 < EPSILON) {
179
+ const viewport = {};
180
+ for (const key of VIEWPORT_TRANSITION_PROPS) {
181
+ const startValue = startProps[key];
182
+ const endValue = endProps[key];
183
+ // @ts-ignore-error properties are populated dynamically
184
+ viewport[key] = lerp(startValue, endValue, t);
185
+ }
186
+ // @ts-expect-error properties are populated dynamically
187
+ return viewport;
188
+ }
189
+ const s = t * S;
190
+ const w = Math.cosh(r0) / Math.cosh(r0 + rho * s);
191
+ const u = (w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2)) / u1;
192
+ const scaleIncrement = 1 / w; // Using w method for scaling.
193
+ const newZoom = startZoom + scaleToZoom(scaleIncrement);
194
+ const newCenterWorld = scale([], uDelta, u);
195
+ add(newCenterWorld, newCenterWorld, startCenterXY);
196
+ const newCenter = worldToLngLat(newCenterWorld);
197
+ return {
198
+ longitude: newCenter[0],
199
+ latitude: newCenter[1],
200
+ zoom: newZoom
201
+ };
202
+ }
203
+ // returns transition duration in milliseconds
204
+ function getFlyToDuration(startProps, endProps, options) {
205
+ const opts = { ...DEFAULT_OPTS$1, ...options };
206
+ const { screenSpeed, speed, maxDuration } = opts;
207
+ const { S, rho } = getFlyToTransitionParams(startProps, endProps, opts);
208
+ const length = 1000 * S;
209
+ let duration;
210
+ if (Number.isFinite(screenSpeed)) {
211
+ duration = length / (screenSpeed / rho);
212
+ }
213
+ else {
214
+ duration = length / speed;
215
+ }
216
+ return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;
217
+ }
218
+ // Private Methods
219
+ // Calculate all parameters that are static for given startProps and endProps
220
+ function getFlyToTransitionParams(startProps, endProps, opts) {
221
+ opts = Object.assign({}, DEFAULT_OPTS$1, opts);
222
+ const rho = opts.curve;
223
+ const startZoom = startProps.zoom;
224
+ const startCenter = [startProps.longitude, startProps.latitude];
225
+ const startScale = zoomToScale(startZoom);
226
+ const endZoom = endProps.zoom;
227
+ const endCenter = [endProps.longitude, endProps.latitude];
228
+ const scale = zoomToScale(endZoom - startZoom);
229
+ const startCenterXY = lngLatToWorld(startCenter);
230
+ const endCenterXY = lngLatToWorld(endCenter);
231
+ const uDelta = sub([], endCenterXY, startCenterXY);
232
+ const w0 = Math.max(startProps.width, startProps.height);
233
+ const w1 = w0 / scale;
234
+ const u1 = length$1(uDelta) * startScale;
235
+ // u0 is treated as '0' in Eq (9).
236
+ // If u1 is too small, will generate invalid number
237
+ const _u1 = Math.max(u1, EPSILON);
238
+ // Implement Equation (9) from above algorithm.
239
+ const rho2 = rho * rho;
240
+ const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);
241
+ const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);
242
+ const r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0);
243
+ const r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
244
+ const S = (r1 - r0) / rho;
245
+ return { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0, r1 };
246
+ }
247
+
248
+ // deck.gl
249
+ // SPDX-License-Identifier: MIT
250
+ // Copyright (c) vis.gl contributors
251
+ const DEFAULT_LIGHT_COLOR = [255, 255, 255];
252
+ const DEFAULT_LIGHT_INTENSITY = 1.0;
253
+ const DEFAULT_ATTENUATION = [1, 0, 0];
254
+ const DEFAULT_LIGHT_POSITION = [0.0, 0.0, 1.0];
255
+ let idCount = 0;
256
+ class PointLight {
257
+ constructor(props = {}) {
258
+ this.type = 'point';
259
+ const { color = DEFAULT_LIGHT_COLOR } = props;
260
+ const { intensity = DEFAULT_LIGHT_INTENSITY } = props;
261
+ const { position = DEFAULT_LIGHT_POSITION } = props;
262
+ this.id = props.id || `point-${idCount++}`;
263
+ this.color = color;
264
+ this.intensity = intensity;
265
+ this.type = 'point';
266
+ this.position = position;
267
+ this.attenuation = getAttenuation(props);
268
+ this.projectedLight = { ...this };
269
+ }
270
+ getProjectedLight({ layer }) {
271
+ const { projectedLight } = this;
272
+ const viewport = layer.context.viewport;
273
+ const { coordinateSystem, coordinateOrigin } = layer.props;
274
+ const position = projectPosition(this.position, {
275
+ viewport,
276
+ coordinateSystem,
277
+ coordinateOrigin,
278
+ fromCoordinateSystem: viewport.isGeospatial
279
+ ? COORDINATE_SYSTEM.LNGLAT
280
+ : COORDINATE_SYSTEM.CARTESIAN,
281
+ fromCoordinateOrigin: [0, 0, 0]
282
+ });
283
+ projectedLight.color = this.color;
284
+ projectedLight.intensity = this.intensity;
285
+ projectedLight.position = position;
286
+ return projectedLight;
287
+ }
288
+ }
289
+ function getAttenuation(props) {
290
+ if (props.attenuation) {
291
+ return props.attenuation;
292
+ }
293
+ return DEFAULT_ATTENUATION;
294
+ }
295
+
296
+ // deck.gl
297
+ // SPDX-License-Identifier: MIT
298
+ // Copyright (c) vis.gl contributors
299
+ class CameraLight extends PointLight {
300
+ getProjectedLight({ layer }) {
301
+ const { projectedLight } = this;
302
+ const viewport = layer.context.viewport;
303
+ const { coordinateSystem, coordinateOrigin, modelMatrix } = layer.props;
304
+ const { cameraPosition } = getUniformsFromViewport({
305
+ viewport,
306
+ modelMatrix: modelMatrix,
307
+ coordinateSystem,
308
+ coordinateOrigin
309
+ });
310
+ projectedLight.color = this.color;
311
+ projectedLight.intensity = this.intensity;
312
+ projectedLight.position = cameraPosition;
313
+ return projectedLight;
314
+ }
315
+ }
316
+
317
+ const DEGREES_TO_RADIANS$1 = Math.PI / 180;
318
+ const DAY_IN_MS = 1000 * 60 * 60 * 24;
319
+ const JD1970 = 2440588; // Julian Day year 1970
320
+ const JD2000 = 2451545; // Julian Day year 2000
321
+ // This angle ε [epsilon] is called the obliquity of the ecliptic and its value at the beginning of 2000 was 23.4397°
322
+ const e = DEGREES_TO_RADIANS$1 * 23.4397; // obliquity of the Earth
323
+ // Refer https://www.aa.quae.nl/en/reken/zonpositie.html
324
+ // "The Mean Anomaly" section for explanation
325
+ const M0 = 357.5291; // Earth mean anomaly on start day
326
+ const M1 = 0.98560028; // Earth angle traverses on average per day seen from the sun
327
+ const THETA0 = 280.147; // The sidereal time (in degrees) at longitude 0° at the instant defined by JD2000
328
+ const THETA1 = 360.9856235; // The rate of change of the sidereal time, in degrees per day.
329
+ /**
330
+ * Calculate sun position
331
+ * based on https://www.aa.quae.nl/en/reken/zonpositie.html
332
+ * inspired by https://github.com/mourner/suncalc/blob/master/suncalc.js
333
+ */
334
+ function getSunPosition(timestamp, latitude, longitude) {
335
+ const longitudeWestInRadians = DEGREES_TO_RADIANS$1 * -longitude;
336
+ const phi = DEGREES_TO_RADIANS$1 * latitude;
337
+ const d = toDays(timestamp);
338
+ const c = getSunCoords(d);
339
+ // hour angle
340
+ const H = getSiderealTime(d, longitudeWestInRadians) - c.rightAscension;
341
+ return {
342
+ azimuth: getAzimuth(H, phi, c.declination),
343
+ altitude: getAltitude(H, phi, c.declination)
344
+ };
345
+ }
346
+ function getSunDirection(timestamp, latitude, longitude) {
347
+ const { azimuth, altitude } = getSunPosition(timestamp, latitude, longitude);
348
+ // solar position to light direction
349
+ return [
350
+ Math.sin(azimuth) * Math.cos(altitude),
351
+ Math.cos(azimuth) * Math.cos(altitude),
352
+ -Math.sin(altitude)
353
+ ];
354
+ }
355
+ function toJulianDay(timestamp) {
356
+ const ts = typeof timestamp === 'number' ? timestamp : timestamp.getTime();
357
+ return ts / DAY_IN_MS - 0.5 + JD1970;
358
+ }
359
+ function toDays(timestamp) {
360
+ return toJulianDay(timestamp) - JD2000;
361
+ }
362
+ function getRightAscension(eclipticLongitude, b) {
363
+ const lambda = eclipticLongitude;
364
+ return Math.atan2(Math.sin(lambda) * Math.cos(e) - Math.tan(b) * Math.sin(e), Math.cos(lambda));
365
+ }
366
+ function getDeclination(eclipticLongitude, b) {
367
+ const lambda = eclipticLongitude;
368
+ return Math.asin(Math.sin(b) * Math.cos(e) + Math.cos(b) * Math.sin(e) * Math.sin(lambda));
369
+ }
370
+ function getAzimuth(hourAngle, latitudeInRadians, declination) {
371
+ const H = hourAngle;
372
+ const phi = latitudeInRadians;
373
+ const delta = declination;
374
+ return Math.atan2(Math.sin(H), Math.cos(H) * Math.sin(phi) - Math.tan(delta) * Math.cos(phi));
375
+ }
376
+ function getAltitude(hourAngle, latitudeInRadians, declination) {
377
+ const H = hourAngle;
378
+ const phi = latitudeInRadians;
379
+ const delta = declination;
380
+ return Math.asin(Math.sin(phi) * Math.sin(delta) + Math.cos(phi) * Math.cos(delta) * Math.cos(H));
381
+ }
382
+ // https://www.aa.quae.nl/en/reken/zonpositie.html
383
+ // "The Observer section"
384
+ function getSiderealTime(dates, longitudeWestInRadians) {
385
+ return DEGREES_TO_RADIANS$1 * (THETA0 + THETA1 * dates) - longitudeWestInRadians;
386
+ }
387
+ function getSolarMeanAnomaly(days) {
388
+ return DEGREES_TO_RADIANS$1 * (M0 + M1 * days);
389
+ }
390
+ function getEclipticLongitude(meanAnomaly) {
391
+ const M = meanAnomaly;
392
+ // equation of center
393
+ const C = DEGREES_TO_RADIANS$1 * (1.9148 * Math.sin(M) + 0.02 * Math.sin(2 * M) + 0.0003 * Math.sin(3 * M));
394
+ // perihelion of the Earth
395
+ const P = DEGREES_TO_RADIANS$1 * 102.9372;
396
+ return M + C + P + Math.PI;
397
+ }
398
+ function getSunCoords(dates) {
399
+ const M = getSolarMeanAnomaly(dates);
400
+ const L = getEclipticLongitude(M);
401
+ return {
402
+ declination: getDeclination(L, 0),
403
+ rightAscension: getRightAscension(L, 0)
404
+ };
405
+ }
406
+
407
+ // deck.gl
408
+ // SPDX-License-Identifier: MIT
409
+ // Copyright (c) vis.gl contributors
410
+ class SunLight extends DirectionalLight {
411
+ constructor(opts) {
412
+ super(opts);
413
+ this.timestamp = opts.timestamp;
414
+ }
415
+ getProjectedLight({ layer }) {
416
+ const { viewport } = layer.context;
417
+ const isGlobe = viewport.resolution && viewport.resolution > 0;
418
+ if (isGlobe) {
419
+ // Rotate vector to align with the direction of the globe projection (up at lon:0,lat:0 is [0, -1, 0])
420
+ const [x, y, z] = getSunDirection(this.timestamp, 0, 0);
421
+ this.direction = [x, -z, y];
422
+ }
423
+ else {
424
+ // @ts-expect-error longitude and latitude are not defined on all viewports
425
+ const { latitude, longitude } = viewport;
426
+ this.direction = getSunDirection(this.timestamp, latitude, longitude);
427
+ }
428
+ return this;
429
+ }
430
+ }
431
+
432
+ // luma.gl
433
+ // SPDX-License-Identifier: MIT
434
+ // Copyright (c) vis.gl contributors
435
+ const CLIPSPACE_VERTEX_SHADER_WGSL = /* wgsl */ `\
436
+ struct VertexInputs {
437
+ @location(0) clipSpacePosition: vec2<f32>,
438
+ @location(1) texCoord: vec2<f32>,
439
+ @location(2) coordinate: vec2<f32>
440
+ }
441
+
442
+ struct FragmentInputs {
443
+ @builtin(position) Position : vec4<f32>,
444
+ @location(0) position : vec2<f32>,
445
+ @location(1) coordinate : vec2<f32>,
446
+ @location(2) uv : vec2<f32>
447
+ };
448
+
449
+ @vertex
450
+ fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
451
+ var outputs: FragmentInputs;
452
+ outputs.Position = vec4(inputs.clipSpacePosition, 0., 1.);
453
+ outputs.position = inputs.clipSpacePosition;
454
+ outputs.coordinate = inputs.coordinate;
455
+ outputs.uv = inputs.texCoord;
456
+ return outputs;
457
+ }
458
+ `;
459
+ const CLIPSPACE_VERTEX_SHADER = /* glsl */ `\
460
+ #version 300 es
461
+ in vec2 clipSpacePositions;
462
+ in vec2 texCoords;
463
+ in vec2 coordinates;
464
+
465
+ out vec2 position;
466
+ out vec2 coordinate;
467
+ out vec2 uv;
468
+
469
+ void main(void) {
470
+ gl_Position = vec4(clipSpacePositions, 0., 1.);
471
+ position = clipSpacePositions;
472
+ coordinate = coordinates;
473
+ uv = texCoords;
474
+ }
475
+ `;
476
+ /* eslint-disable indent, no-multi-spaces */
477
+ const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
478
+ /**
479
+ * A flat geometry that covers the "visible area" that the GPU renders.
480
+ */
481
+ class ClipSpace extends Model {
482
+ constructor(device, props) {
483
+ const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
484
+ // For WGSL we need to append the supplied fragment shader to the default vertex shader source
485
+ if (props.source) {
486
+ props = { ...props, source: `${CLIPSPACE_VERTEX_SHADER_WGSL}\n${props.source}` };
487
+ }
488
+ super(device, {
489
+ id: props.id || uid('clip-space'),
490
+ ...props,
491
+ vs: CLIPSPACE_VERTEX_SHADER,
492
+ vertexCount: 4,
493
+ geometry: new Geometry({
494
+ topology: 'triangle-strip',
495
+ vertexCount: 4,
496
+ attributes: {
497
+ clipSpacePositions: { size: 2, value: new Float32Array(POSITIONS) },
498
+ texCoords: { size: 2, value: new Float32Array(TEX_COORDS) },
499
+ coordinates: { size: 2, value: new Float32Array(TEX_COORDS) }
500
+ }
501
+ })
502
+ });
503
+ }
504
+ }
505
+
506
+ // deck.gl
507
+ // SPDX-License-Identifier: MIT
508
+ // Copyright (c) vis.gl contributors
509
+ const uniformBlock = `\
510
+ uniform screenUniforms {
511
+ vec2 texSize;
512
+ } screen;
513
+ `;
514
+ const screenUniforms = {
515
+ name: 'screen',
516
+ fs: uniformBlock,
517
+ uniformTypes: {
518
+ texSize: 'vec2<f32>'
519
+ }
520
+ };
521
+
522
+ // deck.gl
523
+ // SPDX-License-Identifier: MIT
524
+ // Copyright (c) vis.gl contributors
525
+ /** A base render pass. */
526
+ class ScreenPass extends Pass {
527
+ constructor(device, props) {
528
+ super(device, props);
529
+ const { module, fs, id } = props;
530
+ const parameters = {
531
+ depthWriteEnabled: false,
532
+ depthCompare: 'always',
533
+ depthBias: 0,
534
+ blend: true,
535
+ blendColorSrcFactor: 'one',
536
+ blendColorDstFactor: 'one-minus-src-alpha',
537
+ blendAlphaSrcFactor: 'one',
538
+ blendAlphaDstFactor: 'one-minus-src-alpha',
539
+ blendColorOperation: 'add',
540
+ blendAlphaOperation: 'add'
541
+ };
542
+ this.model = new ClipSpace(device, { id, fs, modules: [module, screenUniforms], parameters });
543
+ }
544
+ render(params) {
545
+ this._renderPass(this.device, params);
546
+ }
547
+ delete() {
548
+ this.model.destroy();
549
+ this.model = null;
550
+ }
551
+ // Private methods
552
+ /**
553
+ * Renders the pass.
554
+ * This is an abstract method that should be overridden.
555
+ * @param inputBuffer - Frame buffer that contains the result of the previous pass
556
+ * @param outputBuffer - Frame buffer that serves as the output render target
557
+ */
558
+ _renderPass(device, options) {
559
+ const { clearCanvas, inputBuffer, outputBuffer } = options;
560
+ const texSize = [inputBuffer.width, inputBuffer.height];
561
+ const screenProps = {
562
+ texSrc: inputBuffer.colorAttachments[0],
563
+ texSize
564
+ };
565
+ this.model.shaderInputs.setProps({
566
+ screen: screenProps,
567
+ ...options.moduleProps
568
+ });
569
+ const renderPass = this.device.beginRenderPass({
570
+ framebuffer: outputBuffer,
571
+ parameters: { viewport: [0, 0, ...texSize] },
572
+ clearColor: clearCanvas ? [0, 0, 0, 0] : false,
573
+ clearDepth: 1,
574
+ clearStencil: false
575
+ });
576
+ this.model.draw(renderPass);
577
+ renderPass.end();
578
+ }
579
+ }
580
+
581
+ // deck.gl
582
+ // SPDX-License-Identifier: MIT
583
+ // Copyright (c) vis.gl contributors
584
+ class PostProcessEffect {
585
+ constructor(module, props) {
586
+ this.id = `${module.name}-pass`;
587
+ this.props = props;
588
+ initializeShaderModule(module);
589
+ this.module = module;
590
+ }
591
+ setup({ device }) {
592
+ this.passes = createPasses(device, this.module, this.id);
593
+ }
594
+ setProps(props) {
595
+ this.props = props;
596
+ }
597
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
598
+ preRender() { }
599
+ postRender(params) {
600
+ const passes = this.passes;
601
+ const { target } = params;
602
+ let inputBuffer = params.inputBuffer;
603
+ let outputBuffer = params.swapBuffer;
604
+ for (let index = 0; index < passes.length; index++) {
605
+ const isLastPass = index === passes.length - 1;
606
+ const renderToTarget = target !== undefined && isLastPass;
607
+ if (renderToTarget) {
608
+ outputBuffer = target;
609
+ }
610
+ const clearCanvas = !renderToTarget || Boolean(params.clearCanvas);
611
+ const moduleProps = {};
612
+ const uniforms = this.module.passes[index].uniforms;
613
+ moduleProps[this.module.name] = { ...this.props, ...uniforms };
614
+ passes[index].render({ clearCanvas, inputBuffer, outputBuffer, moduleProps });
615
+ const switchBuffer = outputBuffer;
616
+ outputBuffer = inputBuffer;
617
+ inputBuffer = switchBuffer;
618
+ }
619
+ return inputBuffer;
620
+ }
621
+ cleanup() {
622
+ if (this.passes) {
623
+ for (const pass of this.passes) {
624
+ pass.delete();
625
+ }
626
+ this.passes = undefined;
627
+ }
628
+ }
629
+ }
630
+ function createPasses(device, module, id) {
631
+ return module.passes.map((pass, index) => {
632
+ const fs = getFragmentShaderForRenderPass(module, pass);
633
+ const idn = `${id}-${index}`;
634
+ return new ScreenPass(device, { id: idn, module, fs });
635
+ });
636
+ }
637
+ const FS_TEMPLATE_INPUTS = `\
638
+ #version 300 es
639
+ uniform sampler2D texSrc;
640
+
641
+ in vec2 position;
642
+ in vec2 coordinate;
643
+ in vec2 uv;
644
+
645
+ out vec4 fragColor;
646
+ `;
647
+ const FILTER_FS_TEMPLATE = (func) => `\
648
+ ${FS_TEMPLATE_INPUTS}
649
+ void main() {
650
+ fragColor = texture(texSrc, coordinate);
651
+ fragColor = ${func}(fragColor, screen.texSize, coordinate);
652
+ }
653
+ `;
654
+ const SAMPLER_FS_TEMPLATE = (func) => `\
655
+ ${FS_TEMPLATE_INPUTS}
656
+ void main() {
657
+ fragColor = ${func}(texSrc, screen.texSize, coordinate);
658
+ }
659
+ `;
660
+ function getFragmentShaderForRenderPass(module, pass) {
661
+ if (pass.filter) {
662
+ const func = typeof pass.filter === 'string' ? pass.filter : `${module.name}_filterColor_ext`;
663
+ return FILTER_FS_TEMPLATE(func);
664
+ }
665
+ if (pass.sampler) {
666
+ const func = typeof pass.sampler === 'string' ? pass.sampler : `${module.name}_sampleColor`;
667
+ return SAMPLER_FS_TEMPLATE(func);
668
+ }
669
+ // console.error(`${module.name} no fragment shader generated`);
670
+ return '';
671
+ }
672
+
673
+ // deck.gl
674
+ // SPDX-License-Identifier: MIT
675
+ // Copyright (c) vis.gl contributors
676
+ const DEGREES_TO_RADIANS = Math.PI / 180;
677
+ function getViewMatrix({ height, focalDistance, orbitAxis, rotationX, rotationOrbit, zoom }) {
678
+ // We position the camera so that one common space unit (world space unit scaled by zoom)
679
+ // at the target maps to one screen pixel.
680
+ // This is a similar technique to that used in web mercator projection
681
+ // By doing so we are able to convert between common space and screen space sizes efficiently
682
+ // in the vertex shader.
683
+ const up = orbitAxis === 'Z' ? [0, 0, 1] : [0, 1, 0];
684
+ const eye = orbitAxis === 'Z' ? [0, -focalDistance, 0] : [0, 0, focalDistance];
685
+ const viewMatrix = new Matrix4().lookAt({ eye, up });
686
+ viewMatrix.rotateX(rotationX * DEGREES_TO_RADIANS);
687
+ if (orbitAxis === 'Z') {
688
+ viewMatrix.rotateZ(rotationOrbit * DEGREES_TO_RADIANS);
689
+ }
690
+ else {
691
+ viewMatrix.rotateY(rotationOrbit * DEGREES_TO_RADIANS);
692
+ }
693
+ // When height increases, we need to increase the distance from the camera to the target to
694
+ // keep the 1:1 mapping. However, this also changes the projected depth of each position by
695
+ // moving them further away between the near/far plane.
696
+ // Without modifying the default near/far planes, we instead scale down the common space to
697
+ // remove the distortion to the depth field.
698
+ const projectionScale = Math.pow(2, zoom) / height;
699
+ viewMatrix.scale(projectionScale);
700
+ return viewMatrix;
701
+ }
702
+ class OrbitViewport extends Viewport {
703
+ constructor(props) {
704
+ const { height, projectionMatrix, fovy = 50, // For setting camera position
705
+ orbitAxis = 'Z', // Orbit axis with 360 degrees rotating freedom, can only be 'Y' or 'Z'
706
+ target = [0, 0, 0], // Which point is camera looking at, default origin
707
+ rotationX = 0, // Rotating angle around X axis
708
+ rotationOrbit = 0, // Rotating angle around orbit axis
709
+ zoom = 0 } = props;
710
+ const focalDistance = projectionMatrix ? projectionMatrix[5] / 2 : fovyToAltitude(fovy);
711
+ super({
712
+ ...props,
713
+ // in case viewState contains longitude/latitude values,
714
+ // make sure that the base Viewport class does not treat this as a geospatial viewport
715
+ longitude: undefined,
716
+ viewMatrix: getViewMatrix({
717
+ height: height || 1,
718
+ focalDistance,
719
+ orbitAxis,
720
+ rotationX,
721
+ rotationOrbit,
722
+ zoom
723
+ }),
724
+ fovy,
725
+ focalDistance,
726
+ position: target,
727
+ zoom
728
+ });
729
+ this.target = target;
730
+ this.orbitAxis = orbitAxis;
731
+ this.rotationX = rotationX;
732
+ this.rotationOrbit = rotationOrbit;
733
+ this.fovy = fovy;
734
+ this.projectedCenter = this.project(this.center);
735
+ }
736
+ unproject(xyz, { topLeft = true } = {}) {
737
+ const [x, y, z = this.projectedCenter[2]] = xyz;
738
+ const y2 = topLeft ? y : this.height - y;
739
+ const [X, Y, Z] = pixelsToWorld([x, y2, z], this.pixelUnprojectionMatrix);
740
+ return [X, Y, Z];
741
+ }
742
+ panByPosition(coords, pixel, startPixel) {
743
+ const p0 = this.project(coords);
744
+ const nextCenter = [
745
+ this.width / 2 + p0[0] - pixel[0],
746
+ this.height / 2 + p0[1] - pixel[1],
747
+ this.projectedCenter[2]
748
+ ];
749
+ return {
750
+ target: this.unproject(nextCenter)
751
+ };
752
+ }
753
+ }
754
+ OrbitViewport.displayName = 'OrbitViewport';
755
+
756
+ // deck.gl
757
+ // SPDX-License-Identifier: MIT
758
+ // Copyright (c) vis.gl contributors
759
+ const viewMatrix = new Matrix4().lookAt({ eye: [0, 0, 1] });
760
+ function getProjectionMatrix({ width, height, near, far, padding }) {
761
+ let left = -width / 2;
762
+ let right = width / 2;
763
+ let bottom = -height / 2;
764
+ let top = height / 2;
765
+ if (padding) {
766
+ const { left: l = 0, right: r = 0, top: t = 0, bottom: b = 0 } = padding;
767
+ const offsetX = clamp((l + width - r) / 2, 0, width) - width / 2;
768
+ const offsetY = clamp((t + height - b) / 2, 0, height) - height / 2;
769
+ left -= offsetX;
770
+ right -= offsetX;
771
+ bottom += offsetY;
772
+ top += offsetY;
773
+ }
774
+ return new Matrix4().ortho({
775
+ left,
776
+ right,
777
+ bottom,
778
+ top,
779
+ near,
780
+ far
781
+ });
782
+ }
783
+ class OrthographicViewport extends Viewport {
784
+ constructor(props) {
785
+ const { width, height, near = 0.1, far = 1000, zoom = 0, target = [0, 0, 0], padding = null, flipY = true } = props;
786
+ const zoomX = props.zoomX ?? (Array.isArray(zoom) ? zoom[0] : zoom);
787
+ const zoomY = props.zoomY ?? (Array.isArray(zoom) ? zoom[1] : zoom);
788
+ const zoom_ = Math.min(zoomX, zoomY);
789
+ const scale = Math.pow(2, zoom_);
790
+ let distanceScales;
791
+ if (zoomX !== zoomY) {
792
+ const scaleX = Math.pow(2, zoomX);
793
+ const scaleY = Math.pow(2, zoomY);
794
+ distanceScales = {
795
+ unitsPerMeter: [scaleX / scale, scaleY / scale, 1],
796
+ metersPerUnit: [scale / scaleX, scale / scaleY, 1]
797
+ };
798
+ }
799
+ super({
800
+ ...props,
801
+ // in case viewState contains longitude/latitude values,
802
+ // make sure that the base Viewport class does not treat this as a geospatial viewport
803
+ longitude: undefined,
804
+ position: target,
805
+ viewMatrix: viewMatrix.clone().scale([scale, scale * (flipY ? -1 : 1), scale]),
806
+ projectionMatrix: getProjectionMatrix({
807
+ width: width || 1,
808
+ height: height || 1,
809
+ padding,
810
+ near,
811
+ far
812
+ }),
813
+ zoom: zoom_,
814
+ distanceScales
815
+ });
816
+ this.target = target;
817
+ this.zoomX = zoomX;
818
+ this.zoomY = zoomY;
819
+ this.flipY = flipY;
820
+ }
821
+ projectFlat([X, Y]) {
822
+ const { unitsPerMeter } = this.distanceScales;
823
+ return [X * unitsPerMeter[0], Y * unitsPerMeter[1]];
824
+ }
825
+ unprojectFlat([x, y]) {
826
+ const { metersPerUnit } = this.distanceScales;
827
+ return [x * metersPerUnit[0], y * metersPerUnit[1]];
828
+ }
829
+ /* Needed by LinearInterpolator */
830
+ panByPosition(coords, pixel, startPixel) {
831
+ const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);
832
+ const toLocation = this.projectFlat(coords);
833
+ const translate = add([], toLocation, negate([], fromLocation));
834
+ const newCenter = add([], this.center, translate);
835
+ return { target: this.unprojectFlat(newCenter) };
836
+ }
837
+ }
838
+ OrthographicViewport.displayName = 'OrthographicViewport';
839
+
840
+ // deck.gl
841
+ // SPDX-License-Identifier: MIT
842
+ // Copyright (c) vis.gl contributors
843
+ class FirstPersonViewport extends Viewport {
844
+ constructor(props) {
845
+ // TODO - push direction handling into Matrix4.lookAt
846
+ const { longitude, latitude, modelMatrix, bearing = 0, pitch = 0, up = [0, 0, 1] } = props;
847
+ // Always calculate direction from bearing and pitch
848
+ const spherical = new SphericalCoordinates({
849
+ bearing,
850
+ // Avoid "pixel project matrix not invertible" error
851
+ pitch: pitch === -90 ? 0.0001 : 90 + pitch
852
+ });
853
+ const dir = spherical.toVector3().normalize();
854
+ // Direction is relative to model coordinates, of course
855
+ const center = modelMatrix ? new Matrix4(modelMatrix).transformAsVector(dir) : dir;
856
+ // Just the direction. All the positioning is done in viewport.js
857
+ const zoom = Number.isFinite(latitude) ? getMeterZoom({ latitude: latitude }) : 0;
858
+ const scale = Math.pow(2, zoom);
859
+ const viewMatrix = new Matrix4().lookAt({ eye: [0, 0, 0], center, up }).scale(scale);
860
+ super({
861
+ ...props,
862
+ zoom,
863
+ viewMatrix
864
+ });
865
+ this.latitude = latitude;
866
+ this.longitude = longitude;
867
+ this.pitch = pitch;
868
+ this.bearing = bearing;
869
+ this.up = up;
870
+ }
871
+ }
872
+ FirstPersonViewport.displayName = 'FirstPersonViewport';
873
+
874
+ // deck.gl
875
+ // SPDX-License-Identifier: MIT
876
+ // Copyright (c) vis.gl contributors
877
+ const MOVEMENT_SPEED = 20;
878
+ const PAN_SPEED = 500;
879
+ class FirstPersonState extends ViewState {
880
+ constructor(options) {
881
+ const {
882
+ /* Viewport arguments */
883
+ width, // Width of viewport
884
+ height, // Height of viewport
885
+ // Position and orientation
886
+ position = [0, 0, 0], // typically in meters from anchor point
887
+ bearing = 0, // Rotation around y axis
888
+ pitch = 0, // Rotation around x axis
889
+ // Geospatial anchor
890
+ longitude = null, latitude = null, maxPitch = 90, minPitch = -90,
891
+ // Model state when the rotate operation first started
892
+ startRotatePos, startBearing, startPitch, startZoomPosition, startPanPos, startPanPosition } = options;
893
+ super({
894
+ width,
895
+ height,
896
+ position,
897
+ bearing,
898
+ pitch,
899
+ longitude,
900
+ latitude,
901
+ maxPitch,
902
+ minPitch
903
+ }, {
904
+ startRotatePos,
905
+ startBearing,
906
+ startPitch,
907
+ startZoomPosition,
908
+ startPanPos,
909
+ startPanPosition
910
+ });
911
+ this.makeViewport = options.makeViewport;
912
+ }
913
+ /* Public API */
914
+ /**
915
+ * Start panning
916
+ * @param {[Number, Number]} pos - position on screen where the pointer grabs
917
+ */
918
+ panStart({ pos }) {
919
+ const { position } = this.getViewportProps();
920
+ return this._getUpdatedState({
921
+ startPanPos: pos,
922
+ startPanPosition: position
923
+ });
924
+ }
925
+ /**
926
+ * Pan
927
+ * @param {[Number, Number]} pos - position on screen where the pointer is
928
+ */
929
+ pan({ pos }) {
930
+ if (!pos) {
931
+ return this;
932
+ }
933
+ const { startPanPos = [0, 0], startPanPosition = [0, 0] } = this.getState();
934
+ const { width, height, bearing, pitch } = this.getViewportProps();
935
+ const deltaScaleX = (PAN_SPEED * (pos[0] - startPanPos[0])) / width;
936
+ const deltaScaleY = (PAN_SPEED * (pos[1] - startPanPos[1])) / height;
937
+ const up = new SphericalCoordinates({ bearing, pitch });
938
+ const forward = new SphericalCoordinates({ bearing, pitch: -90 });
939
+ const yDirection = up.toVector3().normalize();
940
+ const xDirection = forward.toVector3().cross(yDirection).normalize();
941
+ return this._getUpdatedState({
942
+ position: new Vector3(startPanPosition)
943
+ .add(xDirection.scale(deltaScaleX))
944
+ .add(yDirection.scale(deltaScaleY))
945
+ });
946
+ }
947
+ /**
948
+ * End panning
949
+ * Must call if `panStart()` was called
950
+ */
951
+ panEnd() {
952
+ return this._getUpdatedState({
953
+ startPanPos: null,
954
+ startPanPosition: null
955
+ });
956
+ }
957
+ /**
958
+ * Start rotating
959
+ * @param {[Number, Number]} pos - position on screen where the pointer grabs
960
+ */
961
+ rotateStart({ pos }) {
962
+ return this._getUpdatedState({
963
+ startRotatePos: pos,
964
+ startBearing: this.getViewportProps().bearing,
965
+ startPitch: this.getViewportProps().pitch
966
+ });
967
+ }
968
+ /**
969
+ * Rotate
970
+ * @param {[Number, Number]} pos - position on screen where the pointer is
971
+ */
972
+ rotate({ pos, deltaAngleX = 0, deltaAngleY = 0 }) {
973
+ const { startRotatePos, startBearing, startPitch } = this.getState();
974
+ const { width, height } = this.getViewportProps();
975
+ if (!startRotatePos || startBearing === undefined || startPitch === undefined) {
976
+ return this;
977
+ }
978
+ let newRotation;
979
+ if (pos) {
980
+ const deltaScaleX = (pos[0] - startRotatePos[0]) / width;
981
+ const deltaScaleY = (pos[1] - startRotatePos[1]) / height;
982
+ newRotation = {
983
+ bearing: startBearing - deltaScaleX * 180,
984
+ pitch: startPitch - deltaScaleY * 90
985
+ };
986
+ }
987
+ else {
988
+ newRotation = {
989
+ bearing: startBearing - deltaAngleX,
990
+ pitch: startPitch - deltaAngleY
991
+ };
992
+ }
993
+ return this._getUpdatedState(newRotation);
994
+ }
995
+ /**
996
+ * End rotating
997
+ * Must call if `rotateStart()` was called
998
+ */
999
+ rotateEnd() {
1000
+ return this._getUpdatedState({
1001
+ startRotatePos: null,
1002
+ startBearing: null,
1003
+ startPitch: null
1004
+ });
1005
+ }
1006
+ /**
1007
+ * Start zooming
1008
+ * @param {[Number, Number]} pos - position on screen where the pointer grabs
1009
+ */
1010
+ zoomStart() {
1011
+ return this._getUpdatedState({
1012
+ startZoomPosition: this.getViewportProps().position
1013
+ });
1014
+ }
1015
+ /**
1016
+ * Zoom
1017
+ * @param {[Number, Number]} pos - position on screen where the current center is
1018
+ * @param {[Number, Number]} startPos - the center position at
1019
+ * the start of the operation. Must be supplied of `zoomStart()` was not called
1020
+ * @param {Number} scale - a number between [0, 1] specifying the accumulated
1021
+ * relative scale.
1022
+ */
1023
+ zoom({ pos, scale }) {
1024
+ const viewportProps = this.getViewportProps();
1025
+ const startZoomPosition = this.getState().startZoomPosition || viewportProps.position;
1026
+ const viewport = this.makeViewport(viewportProps);
1027
+ const { projectionMatrix, width } = viewport;
1028
+ const fovxRadians = 2.0 * Math.atan(1.0 / projectionMatrix[0]);
1029
+ const angle = fovxRadians * (pos[0] / width - 0.5);
1030
+ const direction = this.getDirection(true);
1031
+ return this._move(direction.rotateZ({ radians: -angle }), Math.log2(scale) * MOVEMENT_SPEED, startZoomPosition);
1032
+ }
1033
+ /**
1034
+ * End zooming
1035
+ * Must call if `zoomStart()` was called
1036
+ */
1037
+ zoomEnd() {
1038
+ return this._getUpdatedState({
1039
+ startZoomPosition: null
1040
+ });
1041
+ }
1042
+ moveLeft(speed = MOVEMENT_SPEED) {
1043
+ const direction = this.getDirection(true);
1044
+ return this._move(direction.rotateZ({ radians: Math.PI / 2 }), speed);
1045
+ }
1046
+ moveRight(speed = MOVEMENT_SPEED) {
1047
+ const direction = this.getDirection(true);
1048
+ return this._move(direction.rotateZ({ radians: -Math.PI / 2 }), speed);
1049
+ }
1050
+ // forward
1051
+ moveUp(speed = MOVEMENT_SPEED) {
1052
+ const direction = this.getDirection(true);
1053
+ return this._move(direction, speed);
1054
+ }
1055
+ // backward
1056
+ moveDown(speed = MOVEMENT_SPEED) {
1057
+ const direction = this.getDirection(true);
1058
+ return this._move(direction.negate(), speed);
1059
+ }
1060
+ rotateLeft(speed = 15) {
1061
+ return this._getUpdatedState({
1062
+ bearing: this.getViewportProps().bearing - speed
1063
+ });
1064
+ }
1065
+ rotateRight(speed = 15) {
1066
+ return this._getUpdatedState({
1067
+ bearing: this.getViewportProps().bearing + speed
1068
+ });
1069
+ }
1070
+ rotateUp(speed = 10) {
1071
+ return this._getUpdatedState({
1072
+ pitch: this.getViewportProps().pitch + speed
1073
+ });
1074
+ }
1075
+ rotateDown(speed = 10) {
1076
+ return this._getUpdatedState({
1077
+ pitch: this.getViewportProps().pitch - speed
1078
+ });
1079
+ }
1080
+ zoomIn(speed = MOVEMENT_SPEED) {
1081
+ return this._move(new Vector3(0, 0, 1), speed);
1082
+ }
1083
+ zoomOut(speed = MOVEMENT_SPEED) {
1084
+ return this._move(new Vector3(0, 0, -1), speed);
1085
+ }
1086
+ // shortest path between two view states
1087
+ shortestPathFrom(viewState) {
1088
+ const fromProps = viewState.getViewportProps();
1089
+ const props = { ...this.getViewportProps() };
1090
+ const { bearing, longitude } = props;
1091
+ if (Math.abs(bearing - fromProps.bearing) > 180) {
1092
+ props.bearing = bearing < 0 ? bearing + 360 : bearing - 360;
1093
+ }
1094
+ if (longitude !== null &&
1095
+ fromProps.longitude !== null &&
1096
+ Math.abs(longitude - fromProps.longitude) > 180) {
1097
+ props.longitude = longitude < 0 ? longitude + 360 : longitude - 360;
1098
+ }
1099
+ return props;
1100
+ }
1101
+ /* Private methods */
1102
+ _move(direction, speed, fromPosition = this.getViewportProps().position) {
1103
+ const delta = direction.scale(speed);
1104
+ return this._getUpdatedState({
1105
+ position: new Vector3(fromPosition).add(delta)
1106
+ });
1107
+ }
1108
+ getDirection(use2D = false) {
1109
+ const spherical = new SphericalCoordinates({
1110
+ bearing: this.getViewportProps().bearing,
1111
+ pitch: use2D ? 90 : 90 + this.getViewportProps().pitch
1112
+ });
1113
+ const direction = spherical.toVector3().normalize();
1114
+ return direction;
1115
+ }
1116
+ _getUpdatedState(newProps) {
1117
+ // Update _viewportProps
1118
+ return new FirstPersonState({
1119
+ makeViewport: this.makeViewport,
1120
+ ...this.getViewportProps(),
1121
+ ...this.getState(),
1122
+ ...newProps
1123
+ });
1124
+ }
1125
+ // Apply any constraints (mathematical or defined by _viewportProps) to map state
1126
+ applyConstraints(props) {
1127
+ // Ensure pitch and zoom are within specified range
1128
+ const { pitch, maxPitch, minPitch, longitude, bearing } = props;
1129
+ props.pitch = clamp(pitch, minPitch, maxPitch);
1130
+ // Normalize degrees
1131
+ if (longitude !== null && (longitude < -180 || longitude > 180)) {
1132
+ props.longitude = mod(longitude + 180, 360) - 180;
1133
+ }
1134
+ if (bearing < -180 || bearing > 180) {
1135
+ props.bearing = mod(bearing + 180, 360) - 180;
1136
+ }
1137
+ return props;
1138
+ }
1139
+ }
1140
+ class FirstPersonController extends Controller {
1141
+ constructor() {
1142
+ super(...arguments);
1143
+ this.ControllerState = FirstPersonState;
1144
+ this.transition = {
1145
+ transitionDuration: 300,
1146
+ transitionInterpolator: new LinearInterpolator(['position', 'pitch', 'bearing'])
1147
+ };
1148
+ }
1149
+ }
1150
+
1151
+ // deck.gl
1152
+ // SPDX-License-Identifier: MIT
1153
+ // Copyright (c) vis.gl contributors
1154
+ class FirstPersonView extends View {
1155
+ constructor(props = {}) {
1156
+ super(props);
1157
+ }
1158
+ getViewportType() {
1159
+ return FirstPersonViewport;
1160
+ }
1161
+ get ControllerType() {
1162
+ return FirstPersonController;
1163
+ }
1164
+ }
1165
+ FirstPersonView.displayName = 'FirstPersonView';
1166
+
1167
+ // deck.gl
1168
+ // SPDX-License-Identifier: MIT
1169
+ // Copyright (c) vis.gl contributors
1170
+ class OrbitState extends ViewState {
1171
+ constructor(options) {
1172
+ const {
1173
+ /* Viewport arguments */
1174
+ width, // Width of viewport
1175
+ height, // Height of viewport
1176
+ rotationX = 0, // Rotation around x axis
1177
+ rotationOrbit = 0, // Rotation around orbit axis
1178
+ target = [0, 0, 0], zoom = 0,
1179
+ /* Viewport constraints */
1180
+ minRotationX = -90, maxRotationX = 90, minZoom = -Infinity, maxZoom = Infinity,
1181
+ /** Interaction states, required to calculate change during transform */
1182
+ // Model state when the pan operation first started
1183
+ startPanPosition,
1184
+ // Model state when the rotate operation first started
1185
+ startRotatePos, startRotationX, startRotationOrbit,
1186
+ // Model state when the zoom operation first started
1187
+ startZoomPosition, startZoom } = options;
1188
+ super({
1189
+ width,
1190
+ height,
1191
+ rotationX,
1192
+ rotationOrbit,
1193
+ target,
1194
+ zoom,
1195
+ minRotationX,
1196
+ maxRotationX,
1197
+ minZoom,
1198
+ maxZoom
1199
+ }, {
1200
+ startPanPosition,
1201
+ startRotatePos,
1202
+ startRotationX,
1203
+ startRotationOrbit,
1204
+ startZoomPosition,
1205
+ startZoom
1206
+ });
1207
+ this.makeViewport = options.makeViewport;
1208
+ }
1209
+ /**
1210
+ * Start panning
1211
+ * @param {[Number, Number]} pos - position on screen where the pointer grabs
1212
+ */
1213
+ panStart({ pos }) {
1214
+ return this._getUpdatedState({
1215
+ startPanPosition: this._unproject(pos)
1216
+ });
1217
+ }
1218
+ /**
1219
+ * Pan
1220
+ * @param {[Number, Number]} pos - position on screen where the pointer is
1221
+ */
1222
+ pan({ pos, startPosition }) {
1223
+ const startPanPosition = this.getState().startPanPosition || startPosition;
1224
+ if (!startPanPosition) {
1225
+ return this;
1226
+ }
1227
+ const viewport = this.makeViewport(this.getViewportProps());
1228
+ const newProps = viewport.panByPosition(startPanPosition, pos);
1229
+ return this._getUpdatedState(newProps);
1230
+ }
1231
+ /**
1232
+ * End panning
1233
+ * Must call if `panStart()` was called
1234
+ */
1235
+ panEnd() {
1236
+ return this._getUpdatedState({
1237
+ startPanPosition: null
1238
+ });
1239
+ }
1240
+ /**
1241
+ * Start rotating
1242
+ * @param {[Number, Number]} pos - position on screen where the pointer grabs
1243
+ */
1244
+ rotateStart({ pos }) {
1245
+ return this._getUpdatedState({
1246
+ startRotatePos: pos,
1247
+ startRotationX: this.getViewportProps().rotationX,
1248
+ startRotationOrbit: this.getViewportProps().rotationOrbit
1249
+ });
1250
+ }
1251
+ /**
1252
+ * Rotate
1253
+ * @param {[Number, Number]} pos - position on screen where the pointer is
1254
+ */
1255
+ rotate({ pos, deltaAngleX = 0, deltaAngleY = 0 }) {
1256
+ const { startRotatePos, startRotationX, startRotationOrbit } = this.getState();
1257
+ const { width, height } = this.getViewportProps();
1258
+ if (!startRotatePos || startRotationX === undefined || startRotationOrbit === undefined) {
1259
+ return this;
1260
+ }
1261
+ let newRotation;
1262
+ if (pos) {
1263
+ let deltaScaleX = (pos[0] - startRotatePos[0]) / width;
1264
+ const deltaScaleY = (pos[1] - startRotatePos[1]) / height;
1265
+ if (startRotationX < -90 || startRotationX > 90) {
1266
+ // When looking at the "back" side of the scene, invert horizontal drag
1267
+ // so that the camera movement follows user input
1268
+ deltaScaleX *= -1;
1269
+ }
1270
+ newRotation = {
1271
+ rotationX: startRotationX + deltaScaleY * 180,
1272
+ rotationOrbit: startRotationOrbit + deltaScaleX * 180
1273
+ };
1274
+ }
1275
+ else {
1276
+ newRotation = {
1277
+ rotationX: startRotationX + deltaAngleY,
1278
+ rotationOrbit: startRotationOrbit + deltaAngleX
1279
+ };
1280
+ }
1281
+ return this._getUpdatedState(newRotation);
1282
+ }
1283
+ /**
1284
+ * End rotating
1285
+ * Must call if `rotateStart()` was called
1286
+ */
1287
+ rotateEnd() {
1288
+ return this._getUpdatedState({
1289
+ startRotationX: null,
1290
+ startRotationOrbit: null
1291
+ });
1292
+ }
1293
+ // shortest path between two view states
1294
+ shortestPathFrom(viewState) {
1295
+ const fromProps = viewState.getViewportProps();
1296
+ const props = { ...this.getViewportProps() };
1297
+ const { rotationOrbit } = props;
1298
+ if (Math.abs(rotationOrbit - fromProps.rotationOrbit) > 180) {
1299
+ props.rotationOrbit = rotationOrbit < 0 ? rotationOrbit + 360 : rotationOrbit - 360;
1300
+ }
1301
+ return props;
1302
+ }
1303
+ /**
1304
+ * Start zooming
1305
+ * @param {[Number, Number]} pos - position on screen where the pointer grabs
1306
+ */
1307
+ zoomStart({ pos }) {
1308
+ return this._getUpdatedState({
1309
+ startZoomPosition: this._unproject(pos),
1310
+ startZoom: this.getViewportProps().zoom
1311
+ });
1312
+ }
1313
+ /**
1314
+ * Zoom
1315
+ * @param {[Number, Number]} pos - position on screen where the current target is
1316
+ * @param {[Number, Number]} startPos - the target position at
1317
+ * the start of the operation. Must be supplied of `zoomStart()` was not called
1318
+ * @param {Number} scale - a number between [0, 1] specifying the accumulated
1319
+ * relative scale.
1320
+ */
1321
+ zoom({ pos, startPos, scale }) {
1322
+ let { startZoom, startZoomPosition } = this.getState();
1323
+ if (!startZoomPosition) {
1324
+ // We have two modes of zoom:
1325
+ // scroll zoom that are discrete events (transform from the current zoom level),
1326
+ // and pinch zoom that are continuous events (transform from the zoom level when
1327
+ // pinch started).
1328
+ // If startZoom state is defined, then use the startZoom state;
1329
+ // otherwise assume discrete zooming
1330
+ startZoom = this.getViewportProps().zoom;
1331
+ startZoomPosition = this._unproject(startPos || pos);
1332
+ }
1333
+ if (!startZoomPosition) {
1334
+ return this;
1335
+ }
1336
+ const newZoom = this._calculateNewZoom({ scale, startZoom });
1337
+ const zoomedViewport = this.makeViewport({ ...this.getViewportProps(), zoom: newZoom });
1338
+ return this._getUpdatedState({
1339
+ zoom: newZoom,
1340
+ ...zoomedViewport.panByPosition(startZoomPosition, pos)
1341
+ });
1342
+ }
1343
+ /**
1344
+ * End zooming
1345
+ * Must call if `zoomStart()` was called
1346
+ */
1347
+ zoomEnd() {
1348
+ return this._getUpdatedState({
1349
+ startZoomPosition: null,
1350
+ startZoom: null
1351
+ });
1352
+ }
1353
+ zoomIn(speed = 2) {
1354
+ return this._getUpdatedState({
1355
+ zoom: this._calculateNewZoom({ scale: speed })
1356
+ });
1357
+ }
1358
+ zoomOut(speed = 2) {
1359
+ return this._getUpdatedState({
1360
+ zoom: this._calculateNewZoom({ scale: 1 / speed })
1361
+ });
1362
+ }
1363
+ moveLeft(speed = 50) {
1364
+ return this._panFromCenter([-speed, 0]);
1365
+ }
1366
+ moveRight(speed = 50) {
1367
+ return this._panFromCenter([speed, 0]);
1368
+ }
1369
+ moveUp(speed = 50) {
1370
+ return this._panFromCenter([0, -speed]);
1371
+ }
1372
+ moveDown(speed = 50) {
1373
+ return this._panFromCenter([0, speed]);
1374
+ }
1375
+ rotateLeft(speed = 15) {
1376
+ return this._getUpdatedState({
1377
+ rotationOrbit: this.getViewportProps().rotationOrbit - speed
1378
+ });
1379
+ }
1380
+ rotateRight(speed = 15) {
1381
+ return this._getUpdatedState({
1382
+ rotationOrbit: this.getViewportProps().rotationOrbit + speed
1383
+ });
1384
+ }
1385
+ rotateUp(speed = 10) {
1386
+ return this._getUpdatedState({
1387
+ rotationX: this.getViewportProps().rotationX - speed
1388
+ });
1389
+ }
1390
+ rotateDown(speed = 10) {
1391
+ return this._getUpdatedState({
1392
+ rotationX: this.getViewportProps().rotationX + speed
1393
+ });
1394
+ }
1395
+ /* Private methods */
1396
+ _project(pos) {
1397
+ const viewport = this.makeViewport(this.getViewportProps());
1398
+ return viewport.project(pos);
1399
+ }
1400
+ _unproject(pos) {
1401
+ const viewport = this.makeViewport(this.getViewportProps());
1402
+ return viewport.unproject(pos);
1403
+ }
1404
+ // Calculates new zoom
1405
+ _calculateNewZoom({ scale, startZoom }) {
1406
+ const { maxZoom, minZoom } = this.getViewportProps();
1407
+ if (startZoom === undefined) {
1408
+ startZoom = this.getViewportProps().zoom;
1409
+ }
1410
+ const zoom = startZoom + Math.log2(scale);
1411
+ return clamp(zoom, minZoom, maxZoom);
1412
+ }
1413
+ _panFromCenter(offset) {
1414
+ const { target } = this.getViewportProps();
1415
+ const center = this._project(target);
1416
+ return this.pan({
1417
+ startPosition: target,
1418
+ pos: [center[0] + offset[0], center[1] + offset[1]]
1419
+ });
1420
+ }
1421
+ _getUpdatedState(newProps) {
1422
+ // @ts-ignore
1423
+ return new this.constructor({
1424
+ makeViewport: this.makeViewport,
1425
+ ...this.getViewportProps(),
1426
+ ...this.getState(),
1427
+ ...newProps
1428
+ });
1429
+ }
1430
+ // Apply any constraints (mathematical or defined by _viewportProps) to map state
1431
+ applyConstraints(props) {
1432
+ // Ensure zoom is within specified range
1433
+ const { maxZoom, minZoom, zoom, maxRotationX, minRotationX, rotationOrbit } = props;
1434
+ props.zoom = Array.isArray(zoom)
1435
+ ? [clamp(zoom[0], minZoom, maxZoom), clamp(zoom[1], minZoom, maxZoom)]
1436
+ : clamp(zoom, minZoom, maxZoom);
1437
+ props.rotationX = clamp(props.rotationX, minRotationX, maxRotationX);
1438
+ if (rotationOrbit < -180 || rotationOrbit > 180) {
1439
+ props.rotationOrbit = mod(rotationOrbit + 180, 360) - 180;
1440
+ }
1441
+ return props;
1442
+ }
1443
+ }
1444
+ class OrbitController extends Controller {
1445
+ constructor() {
1446
+ super(...arguments);
1447
+ this.ControllerState = OrbitState;
1448
+ this.transition = {
1449
+ transitionDuration: 300,
1450
+ transitionInterpolator: new LinearInterpolator({
1451
+ transitionProps: {
1452
+ compare: ['target', 'zoom', 'rotationX', 'rotationOrbit'],
1453
+ required: ['target', 'zoom']
1454
+ }
1455
+ })
1456
+ };
1457
+ }
1458
+ }
1459
+
1460
+ // deck.gl
1461
+ // SPDX-License-Identifier: MIT
1462
+ // Copyright (c) vis.gl contributors
1463
+ class OrbitView extends View {
1464
+ constructor(props = {}) {
1465
+ super(props);
1466
+ this.props.orbitAxis = props.orbitAxis || 'Z';
1467
+ }
1468
+ getViewportType() {
1469
+ return OrbitViewport;
1470
+ }
1471
+ get ControllerType() {
1472
+ return OrbitController;
1473
+ }
1474
+ }
1475
+ OrbitView.displayName = 'OrbitView';
1476
+
1477
+ // deck.gl
1478
+ // SPDX-License-Identifier: MIT
1479
+ // Copyright (c) vis.gl contributors
1480
+ class OrthographicState extends OrbitState {
1481
+ constructor(props) {
1482
+ super(props);
1483
+ this.zoomAxis = props.zoomAxis || 'all';
1484
+ }
1485
+ _calculateNewZoom({ scale, startZoom }) {
1486
+ const { maxZoom, minZoom } = this.getViewportProps();
1487
+ if (startZoom === undefined) {
1488
+ startZoom = this.getViewportProps().zoom;
1489
+ }
1490
+ let deltaZoom = Math.log2(scale);
1491
+ if (Array.isArray(startZoom)) {
1492
+ let [newZoomX, newZoomY] = startZoom;
1493
+ switch (this.zoomAxis) {
1494
+ case 'X':
1495
+ // Scale x only
1496
+ newZoomX = clamp(newZoomX + deltaZoom, minZoom, maxZoom);
1497
+ break;
1498
+ case 'Y':
1499
+ // Scale y only
1500
+ newZoomY = clamp(newZoomY + deltaZoom, minZoom, maxZoom);
1501
+ break;
1502
+ default:
1503
+ // Lock aspect ratio
1504
+ let z = Math.min(newZoomX + deltaZoom, newZoomY + deltaZoom);
1505
+ if (z < minZoom) {
1506
+ deltaZoom += minZoom - z;
1507
+ }
1508
+ z = Math.max(newZoomX + deltaZoom, newZoomY + deltaZoom);
1509
+ if (z > maxZoom) {
1510
+ deltaZoom += maxZoom - z;
1511
+ }
1512
+ newZoomX += deltaZoom;
1513
+ newZoomY += deltaZoom;
1514
+ }
1515
+ return [newZoomX, newZoomY];
1516
+ }
1517
+ // Ignore `zoomAxis`
1518
+ // `LinearTransitionInterpolator` does not support interpolation between a number and an array
1519
+ // So if zoom is a number (legacy use case), new zoom still has to be a number
1520
+ return clamp(startZoom + deltaZoom, minZoom, maxZoom);
1521
+ }
1522
+ }
1523
+ class OrthographicController extends Controller {
1524
+ constructor() {
1525
+ super(...arguments);
1526
+ this.ControllerState = OrthographicState;
1527
+ this.transition = {
1528
+ transitionDuration: 300,
1529
+ transitionInterpolator: new LinearInterpolator(['target', 'zoom'])
1530
+ };
1531
+ this.dragMode = 'pan';
1532
+ }
1533
+ _onPanRotate() {
1534
+ // No rotation in orthographic view
1535
+ return false;
1536
+ }
1537
+ }
1538
+
1539
+ // deck.gl
1540
+ // SPDX-License-Identifier: MIT
1541
+ // Copyright (c) vis.gl contributors
1542
+ class OrthographicView extends View {
1543
+ constructor(props = {}) {
1544
+ super(props);
1545
+ }
1546
+ getViewportType() {
1547
+ return OrthographicViewport;
1548
+ }
1549
+ get ControllerType() {
1550
+ return OrthographicController;
1551
+ }
1552
+ }
1553
+ OrthographicView.displayName = 'OrthographicView';
1554
+
1555
+ // deck.gl
1556
+ // SPDX-License-Identifier: MIT
1557
+ // Copyright (c) vis.gl contributors
1558
+ class GlobeState extends MapState {
1559
+ constructor(options) {
1560
+ const { startPanPos, ...mapStateOptions } = options;
1561
+ super(mapStateOptions);
1562
+ if (startPanPos !== undefined) {
1563
+ this._state.startPanPos = startPanPos;
1564
+ }
1565
+ }
1566
+ panStart({ pos }) {
1567
+ const { latitude, longitude, zoom } = this.getViewportProps();
1568
+ return this._getUpdatedState({
1569
+ startPanLngLat: [longitude, latitude],
1570
+ startPanPos: pos,
1571
+ startZoom: zoom
1572
+ });
1573
+ }
1574
+ pan({ pos, startPos }) {
1575
+ const state = this.getState();
1576
+ const startPanLngLat = state.startPanLngLat || this._unproject(startPos);
1577
+ if (!startPanLngLat)
1578
+ return this;
1579
+ const startZoom = state.startZoom ?? this.getViewportProps().zoom;
1580
+ const startPanPos = state.startPanPos || startPos;
1581
+ const coords = [startPanLngLat[0], startPanLngLat[1], startZoom];
1582
+ const viewport = this.makeViewport(this.getViewportProps());
1583
+ const newProps = viewport.panByPosition(coords, pos, startPanPos);
1584
+ return this._getUpdatedState(newProps);
1585
+ }
1586
+ panEnd() {
1587
+ return this._getUpdatedState({
1588
+ startPanLngLat: null,
1589
+ startPanPos: null,
1590
+ startZoom: null
1591
+ });
1592
+ }
1593
+ zoom({ scale }) {
1594
+ // In Globe view zoom does not take into account the mouse position
1595
+ const startZoom = this.getState().startZoom || this.getViewportProps().zoom;
1596
+ const zoom = startZoom + Math.log2(scale);
1597
+ return this._getUpdatedState({ zoom });
1598
+ }
1599
+ applyConstraints(props) {
1600
+ // Ensure zoom is within specified range
1601
+ const { longitude, latitude, maxZoom, minZoom, zoom } = props;
1602
+ const ZOOM0 = zoomAdjust(0);
1603
+ const zoomAdjustment = zoomAdjust(latitude) - ZOOM0;
1604
+ props.zoom = clamp(zoom, minZoom + zoomAdjustment, maxZoom + zoomAdjustment);
1605
+ if (longitude < -180 || longitude > 180) {
1606
+ props.longitude = mod(longitude + 180, 360) - 180;
1607
+ }
1608
+ props.latitude = clamp(latitude, -MAX_LATITUDE, MAX_LATITUDE);
1609
+ return props;
1610
+ }
1611
+ }
1612
+ class GlobeController extends Controller {
1613
+ constructor() {
1614
+ super(...arguments);
1615
+ this.ControllerState = GlobeState;
1616
+ this.transition = {
1617
+ transitionDuration: 300,
1618
+ transitionInterpolator: new LinearInterpolator(['longitude', 'latitude', 'zoom'])
1619
+ };
1620
+ this.dragMode = 'pan';
1621
+ }
1622
+ setProps(props) {
1623
+ super.setProps(props);
1624
+ // TODO - support pitching?
1625
+ this.dragRotate = false;
1626
+ this.touchRotate = false;
1627
+ }
1628
+ }
1629
+
1630
+ // deck.gl
1631
+ // SPDX-License-Identifier: MIT
1632
+ // Copyright (c) vis.gl contributors
1633
+ class GlobeView extends View {
1634
+ constructor(props = {}) {
1635
+ super(props);
1636
+ }
1637
+ getViewportType(viewState) {
1638
+ return viewState.zoom > 12 ? WebMercatorViewport : GlobeViewport;
1639
+ }
1640
+ get ControllerType() {
1641
+ return GlobeController;
1642
+ }
1643
+ }
1644
+ GlobeView.displayName = 'GlobeView';
1645
+
1646
+ // deck.gl
1647
+ // SPDX-License-Identifier: MIT
1648
+ // Copyright (c) vis.gl contributors
1649
+ const LINEARLY_INTERPOLATED_PROPS = {
1650
+ bearing: 0,
1651
+ pitch: 0,
1652
+ position: [0, 0, 0]
1653
+ };
1654
+ const DEFAULT_OPTS = {
1655
+ speed: 1.2,
1656
+ curve: 1.414
1657
+ };
1658
+ /**
1659
+ * This class adapts mapbox-gl-js Map#flyTo animation so it can be used in
1660
+ * react/redux architecture.
1661
+ * mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.
1662
+ * It implements “Smooth and efficient zooming and panning.” algorithm by
1663
+ * "Jarke J. van Wijk and Wim A.A. Nuij"
1664
+ */
1665
+ class FlyToInterpolator extends TransitionInterpolator {
1666
+ constructor(opts = {}) {
1667
+ super({
1668
+ compare: ['longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],
1669
+ extract: ['width', 'height', 'longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],
1670
+ required: ['width', 'height', 'latitude', 'longitude', 'zoom']
1671
+ });
1672
+ this.opts = { ...DEFAULT_OPTS, ...opts };
1673
+ }
1674
+ interpolateProps(startProps, endProps, t) {
1675
+ const viewport = flyToViewport(startProps, endProps, t, this.opts);
1676
+ // Linearly interpolate 'bearing', 'pitch' and 'position'.
1677
+ // If they are not supplied, they are interpreted as zeros in viewport calculation
1678
+ // (fallback defined in WebMercatorViewport)
1679
+ // Because there is no guarantee that the current controller's ViewState normalizes
1680
+ // these props, safe guard is needed to avoid generating NaNs
1681
+ for (const key in LINEARLY_INTERPOLATED_PROPS) {
1682
+ viewport[key] = lerp$1(startProps[key] || LINEARLY_INTERPOLATED_PROPS[key], endProps[key] || LINEARLY_INTERPOLATED_PROPS[key], t);
1683
+ }
1684
+ return viewport;
1685
+ }
1686
+ // computes the transition duration
1687
+ getDuration(startProps, endProps) {
1688
+ let { transitionDuration } = endProps;
1689
+ if (transitionDuration === 'auto') {
1690
+ // auto calculate duration based on start and end props
1691
+ transitionDuration = getFlyToDuration(startProps, endProps, this.opts);
1692
+ }
1693
+ return transitionDuration;
1694
+ }
1695
+ }
1696
+
1697
+ export { COORDINATE_SYSTEM, Controller, DirectionalLight, FirstPersonController, FirstPersonView, FirstPersonViewport, FlyToInterpolator, LinearInterpolator, OrbitController, OrbitView, OrbitViewport, OrthographicController, OrthographicView, OrthographicViewport, PointLight, PostProcessEffect, TransitionInterpolator, View, Viewport, WebMercatorViewport, CameraLight as _CameraLight, GlobeController as _GlobeController, GlobeView as _GlobeView, GlobeViewport as _GlobeViewport, SunLight as _SunLight };