@antv/l7-map 2.21.11-beta.5 → 2.21.11-beta.6

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 (358) hide show
  1. package/README.md +27 -6
  2. package/es/index.d.ts +3 -4
  3. package/es/index.js +2 -4
  4. package/es/map/camera.d.ts +690 -0
  5. package/es/map/camera.js +1138 -0
  6. package/{lib → es/map}/css/l7.css +41 -7
  7. package/es/map/events.d.ts +384 -0
  8. package/es/map/events.js +222 -0
  9. package/es/map/geo/edge_insets.d.ts +97 -0
  10. package/es/{geo → map/geo}/edge_insets.js +55 -33
  11. package/es/map/geo/lng_lat.d.ts +116 -0
  12. package/es/map/geo/lng_lat.js +159 -0
  13. package/es/map/geo/lng_lat_bounds.d.ts +217 -0
  14. package/es/map/geo/lng_lat_bounds.js +334 -0
  15. package/es/map/geo/mercator_coordinate.d.ts +113 -0
  16. package/es/map/geo/mercator_coordinate.js +142 -0
  17. package/es/map/geo/transform.d.ts +262 -0
  18. package/es/map/geo/transform.js +736 -0
  19. package/{lib → es/map}/handler/box_zoom.d.ts +30 -24
  20. package/es/map/handler/box_zoom.js +145 -0
  21. package/es/map/handler/click_zoom.d.ts +24 -0
  22. package/es/map/handler/click_zoom.js +47 -0
  23. package/es/map/handler/cooperative_gestures.d.ts +40 -0
  24. package/es/map/handler/cooperative_gestures.js +94 -0
  25. package/es/map/handler/drag_handler.d.ts +88 -0
  26. package/es/map/handler/drag_handler.js +89 -0
  27. package/es/map/handler/drag_move_state_manager.d.ts +30 -0
  28. package/es/map/handler/drag_move_state_manager.js +94 -0
  29. package/es/map/handler/handler_util.d.ts +3 -0
  30. package/es/{handler → map/handler}/handler_util.js +1 -2
  31. package/es/map/handler/keyboard.d.ts +88 -0
  32. package/es/map/handler/keyboard.js +197 -0
  33. package/es/map/handler/map_event.d.ts +46 -0
  34. package/es/map/handler/map_event.js +131 -0
  35. package/es/map/handler/mouse.d.ts +30 -0
  36. package/es/map/handler/mouse.js +85 -0
  37. package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
  38. package/es/map/handler/one_finger_touch_drag.js +39 -0
  39. package/es/map/handler/scroll_zoom.d.ts +102 -0
  40. package/es/map/handler/scroll_zoom.js +312 -0
  41. package/es/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
  42. package/es/{handler → map/handler}/shim/dblclick_zoom.js +20 -16
  43. package/es/map/handler/shim/drag_pan.d.ts +79 -0
  44. package/es/map/handler/shim/drag_pan.js +77 -0
  45. package/es/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
  46. package/es/map/handler/shim/drag_rotate.js +66 -0
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
  48. package/es/map/handler/shim/two_fingers_touch.js +106 -0
  49. package/es/map/handler/tap_drag_zoom.d.ts +28 -0
  50. package/es/map/handler/tap_drag_zoom.js +92 -0
  51. package/es/map/handler/tap_recognizer.d.ts +35 -0
  52. package/es/map/handler/tap_recognizer.js +107 -0
  53. package/es/map/handler/tap_zoom.d.ts +28 -0
  54. package/es/map/handler/tap_zoom.js +87 -0
  55. package/es/map/handler/touch_pan.d.ts +40 -0
  56. package/es/map/handler/touch_pan.js +85 -0
  57. package/es/map/handler/transform-provider.d.ts +23 -0
  58. package/es/map/handler/transform-provider.js +35 -0
  59. package/es/map/handler/two_fingers_touch.d.ts +107 -0
  60. package/es/map/handler/two_fingers_touch.js +289 -0
  61. package/es/map/handler_inertia.d.ts +20 -0
  62. package/es/{handler → map}/handler_inertia.js +36 -50
  63. package/es/map/handler_manager.d.ts +154 -0
  64. package/es/map/handler_manager.js +466 -0
  65. package/es/map/map.d.ts +625 -0
  66. package/es/map/map.js +972 -0
  67. package/es/map/util/abort_error.d.ts +15 -0
  68. package/es/map/util/abort_error.js +21 -0
  69. package/es/map/util/browser.d.ts +10 -0
  70. package/es/map/util/browser.js +30 -0
  71. package/es/map/util/dom.d.ts +30 -0
  72. package/es/map/util/dom.js +105 -0
  73. package/es/map/util/evented.d.ts +75 -0
  74. package/es/map/util/evented.js +158 -0
  75. package/es/map/util/task_queue.d.ts +18 -0
  76. package/es/map/util/task_queue.js +54 -0
  77. package/es/map/util/util.d.ts +104 -0
  78. package/es/map/util/util.js +155 -0
  79. package/lib/index.d.ts +3 -4
  80. package/lib/index.js +12 -42
  81. package/lib/map/camera.d.ts +690 -0
  82. package/lib/map/camera.js +1145 -0
  83. package/{es → lib/map}/css/l7.css +41 -7
  84. package/lib/map/events.d.ts +384 -0
  85. package/lib/map/events.js +231 -0
  86. package/lib/map/geo/edge_insets.d.ts +97 -0
  87. package/lib/{geo → map/geo}/edge_insets.js +56 -35
  88. package/lib/map/geo/lng_lat.d.ts +116 -0
  89. package/lib/map/geo/lng_lat.js +166 -0
  90. package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
  91. package/lib/map/geo/lng_lat_bounds.js +341 -0
  92. package/lib/map/geo/mercator_coordinate.d.ts +113 -0
  93. package/lib/map/geo/mercator_coordinate.js +157 -0
  94. package/lib/map/geo/transform.d.ts +262 -0
  95. package/lib/map/geo/transform.js +744 -0
  96. package/{es → lib/map}/handler/box_zoom.d.ts +30 -24
  97. package/lib/map/handler/box_zoom.js +153 -0
  98. package/lib/map/handler/click_zoom.d.ts +24 -0
  99. package/lib/map/handler/click_zoom.js +54 -0
  100. package/lib/map/handler/cooperative_gestures.d.ts +40 -0
  101. package/lib/map/handler/cooperative_gestures.js +101 -0
  102. package/lib/map/handler/drag_handler.d.ts +88 -0
  103. package/lib/map/handler/drag_handler.js +97 -0
  104. package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
  105. package/lib/map/handler/drag_move_state_manager.js +103 -0
  106. package/lib/map/handler/handler_util.d.ts +3 -0
  107. package/lib/{handler → map/handler}/handler_util.js +1 -2
  108. package/lib/map/handler/keyboard.d.ts +88 -0
  109. package/lib/map/handler/keyboard.js +205 -0
  110. package/lib/map/handler/map_event.d.ts +46 -0
  111. package/lib/map/handler/map_event.js +140 -0
  112. package/lib/map/handler/mouse.d.ts +30 -0
  113. package/lib/map/handler/mouse.js +93 -0
  114. package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
  115. package/lib/map/handler/one_finger_touch_drag.js +47 -0
  116. package/lib/map/handler/scroll_zoom.d.ts +102 -0
  117. package/lib/map/handler/scroll_zoom.js +320 -0
  118. package/lib/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
  119. package/lib/{handler → map/handler}/shim/dblclick_zoom.js +21 -17
  120. package/lib/map/handler/shim/drag_pan.d.ts +79 -0
  121. package/lib/map/handler/shim/drag_pan.js +85 -0
  122. package/lib/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
  123. package/lib/map/handler/shim/drag_rotate.js +74 -0
  124. package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
  125. package/lib/map/handler/shim/two_fingers_touch.js +114 -0
  126. package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
  127. package/lib/map/handler/tap_drag_zoom.js +99 -0
  128. package/lib/map/handler/tap_recognizer.d.ts +35 -0
  129. package/lib/map/handler/tap_recognizer.js +116 -0
  130. package/lib/map/handler/tap_zoom.d.ts +28 -0
  131. package/lib/map/handler/tap_zoom.js +94 -0
  132. package/lib/map/handler/touch_pan.d.ts +40 -0
  133. package/lib/map/handler/touch_pan.js +92 -0
  134. package/lib/map/handler/transform-provider.d.ts +23 -0
  135. package/lib/map/handler/transform-provider.js +43 -0
  136. package/lib/map/handler/two_fingers_touch.d.ts +107 -0
  137. package/lib/map/handler/two_fingers_touch.js +296 -0
  138. package/lib/map/handler_inertia.d.ts +20 -0
  139. package/lib/{handler → map}/handler_inertia.js +38 -53
  140. package/lib/map/handler_manager.d.ts +154 -0
  141. package/lib/map/handler_manager.js +474 -0
  142. package/lib/map/map.d.ts +625 -0
  143. package/lib/map/map.js +979 -0
  144. package/lib/map/util/abort_error.d.ts +15 -0
  145. package/lib/map/util/abort_error.js +29 -0
  146. package/lib/map/util/browser.d.ts +10 -0
  147. package/lib/map/util/browser.js +36 -0
  148. package/lib/map/util/dom.d.ts +30 -0
  149. package/lib/map/util/dom.js +113 -0
  150. package/lib/map/util/evented.d.ts +75 -0
  151. package/lib/map/util/evented.js +167 -0
  152. package/lib/map/util/task_queue.d.ts +18 -0
  153. package/lib/map/util/task_queue.js +62 -0
  154. package/lib/map/util/util.d.ts +104 -0
  155. package/lib/map/util/util.js +171 -0
  156. package/package.json +6 -3
  157. package/es/camera.d.ts +0 -86
  158. package/es/camera.js +0 -639
  159. package/es/earthmap.d.ts +0 -69
  160. package/es/earthmap.js +0 -445
  161. package/es/geo/edge_insets.d.ts +0 -54
  162. package/es/geo/lng_lat.d.ts +0 -18
  163. package/es/geo/lng_lat.js +0 -59
  164. package/es/geo/lng_lat_bounds.d.ts +0 -25
  165. package/es/geo/lng_lat_bounds.js +0 -118
  166. package/es/geo/mercator.d.ts +0 -30
  167. package/es/geo/mercator.js +0 -72
  168. package/es/geo/point.d.ts +0 -40
  169. package/es/geo/point.js +0 -153
  170. package/es/geo/simple.d.ts +0 -30
  171. package/es/geo/simple.js +0 -75
  172. package/es/geo/transform.d.ts +0 -198
  173. package/es/geo/transform.js +0 -895
  174. package/es/handler/IHandler.d.ts +0 -34
  175. package/es/handler/IHandler.js +0 -1
  176. package/es/handler/blockable_map_event.d.ts +0 -17
  177. package/es/handler/blockable_map_event.js +0 -58
  178. package/es/handler/box_zoom.js +0 -162
  179. package/es/handler/click_zoom.d.ts +0 -16
  180. package/es/handler/click_zoom.js +0 -40
  181. package/es/handler/events/event.d.ts +0 -4
  182. package/es/handler/events/event.js +0 -12
  183. package/es/handler/events/index.d.ts +0 -4
  184. package/es/handler/events/index.js +0 -4
  185. package/es/handler/events/map_mouse_event.d.ts +0 -34
  186. package/es/handler/events/map_mouse_event.js +0 -45
  187. package/es/handler/events/map_touch_event.d.ts +0 -57
  188. package/es/handler/events/map_touch_event.js +0 -75
  189. package/es/handler/events/map_wheel_event.d.ts +0 -33
  190. package/es/handler/events/map_wheel_event.js +0 -33
  191. package/es/handler/events/render_event.d.ts +0 -6
  192. package/es/handler/events/render_event.js +0 -10
  193. package/es/handler/handler_inertia.d.ts +0 -23
  194. package/es/handler/handler_manager.d.ts +0 -61
  195. package/es/handler/handler_manager.js +0 -487
  196. package/es/handler/handler_util.d.ts +0 -4
  197. package/es/handler/keyboard.d.ts +0 -36
  198. package/es/handler/keyboard.js +0 -131
  199. package/es/handler/map_event.d.ts +0 -29
  200. package/es/handler/map_event.js +0 -89
  201. package/es/handler/mouse/index.d.ts +0 -4
  202. package/es/handler/mouse/index.js +0 -4
  203. package/es/handler/mouse/mouse_handler.d.ts +0 -22
  204. package/es/handler/mouse/mouse_handler.js +0 -99
  205. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  206. package/es/handler/mouse/mousepan_handler.js +0 -21
  207. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  208. package/es/handler/mouse/mousepitch_hander.js +0 -24
  209. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  210. package/es/handler/mouse/mouserotate_hander.js +0 -24
  211. package/es/handler/mouse/util.d.ts +0 -6
  212. package/es/handler/mouse/util.js +0 -12
  213. package/es/handler/scroll_zoom.d.ts +0 -93
  214. package/es/handler/scroll_zoom.js +0 -315
  215. package/es/handler/shim/drag_pan.d.ts +0 -61
  216. package/es/handler/shim/drag_pan.js +0 -75
  217. package/es/handler/shim/drag_rotate.js +0 -64
  218. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  219. package/es/handler/shim/touch_zoom_rotate.js +0 -104
  220. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  221. package/es/handler/tap/single_tap_recognizer.js +0 -77
  222. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  223. package/es/handler/tap/tap_drag_zoom.js +0 -89
  224. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  225. package/es/handler/tap/tap_recognizer.js +0 -46
  226. package/es/handler/tap/tap_zoom.d.ts +0 -22
  227. package/es/handler/tap/tap_zoom.js +0 -81
  228. package/es/handler/touch/index.d.ts +0 -5
  229. package/es/handler/touch/index.js +0 -5
  230. package/es/handler/touch/touch_pan.d.ts +0 -30
  231. package/es/handler/touch/touch_pan.js +0 -91
  232. package/es/handler/touch/touch_pitch.d.ts +0 -13
  233. package/es/handler/touch/touch_pitch.js +0 -75
  234. package/es/handler/touch/touch_rotate.d.ts +0 -12
  235. package/es/handler/touch/touch_rotate.js +0 -57
  236. package/es/handler/touch/touch_zoom.d.ts +0 -12
  237. package/es/handler/touch/touch_zoom.js +0 -37
  238. package/es/handler/touch/two_touch.d.ts +0 -23
  239. package/es/handler/touch/two_touch.js +0 -98
  240. package/es/hash.d.ts +0 -14
  241. package/es/hash.js +0 -121
  242. package/es/interface.d.ts +0 -34
  243. package/es/interface.js +0 -1
  244. package/es/map.d.ts +0 -70
  245. package/es/map.js +0 -472
  246. package/es/util.d.ts +0 -25
  247. package/es/util.js +0 -70
  248. package/es/utils/Aabb.d.ts +0 -12
  249. package/es/utils/Aabb.js +0 -72
  250. package/es/utils/dom.d.ts +0 -4
  251. package/es/utils/dom.js +0 -117
  252. package/es/utils/performance.d.ts +0 -17
  253. package/es/utils/performance.js +0 -58
  254. package/es/utils/primitives.d.ts +0 -6
  255. package/es/utils/primitives.js +0 -37
  256. package/es/utils/task_queue.d.ts +0 -13
  257. package/es/utils/task_queue.js +0 -60
  258. package/lib/camera.d.ts +0 -86
  259. package/lib/camera.js +0 -648
  260. package/lib/earthmap.d.ts +0 -69
  261. package/lib/earthmap.js +0 -451
  262. package/lib/geo/edge_insets.d.ts +0 -54
  263. package/lib/geo/lng_lat.d.ts +0 -18
  264. package/lib/geo/lng_lat.js +0 -67
  265. package/lib/geo/lng_lat_bounds.d.ts +0 -25
  266. package/lib/geo/lng_lat_bounds.js +0 -126
  267. package/lib/geo/mercator.d.ts +0 -30
  268. package/lib/geo/mercator.js +0 -88
  269. package/lib/geo/point.d.ts +0 -40
  270. package/lib/geo/point.js +0 -161
  271. package/lib/geo/simple.d.ts +0 -30
  272. package/lib/geo/simple.js +0 -92
  273. package/lib/geo/transform.d.ts +0 -198
  274. package/lib/geo/transform.js +0 -906
  275. package/lib/handler/IHandler.d.ts +0 -34
  276. package/lib/handler/IHandler.js +0 -5
  277. package/lib/handler/blockable_map_event.d.ts +0 -17
  278. package/lib/handler/blockable_map_event.js +0 -66
  279. package/lib/handler/box_zoom.js +0 -168
  280. package/lib/handler/click_zoom.d.ts +0 -16
  281. package/lib/handler/click_zoom.js +0 -48
  282. package/lib/handler/events/event.d.ts +0 -4
  283. package/lib/handler/events/event.js +0 -20
  284. package/lib/handler/events/index.d.ts +0 -4
  285. package/lib/handler/events/index.js +0 -27
  286. package/lib/handler/events/map_mouse_event.d.ts +0 -34
  287. package/lib/handler/events/map_mouse_event.js +0 -53
  288. package/lib/handler/events/map_touch_event.d.ts +0 -57
  289. package/lib/handler/events/map_touch_event.js +0 -83
  290. package/lib/handler/events/map_wheel_event.d.ts +0 -33
  291. package/lib/handler/events/map_wheel_event.js +0 -41
  292. package/lib/handler/events/render_event.d.ts +0 -6
  293. package/lib/handler/events/render_event.js +0 -18
  294. package/lib/handler/handler_inertia.d.ts +0 -23
  295. package/lib/handler/handler_manager.d.ts +0 -61
  296. package/lib/handler/handler_manager.js +0 -495
  297. package/lib/handler/handler_util.d.ts +0 -4
  298. package/lib/handler/keyboard.d.ts +0 -36
  299. package/lib/handler/keyboard.js +0 -138
  300. package/lib/handler/map_event.d.ts +0 -29
  301. package/lib/handler/map_event.js +0 -97
  302. package/lib/handler/mouse/index.d.ts +0 -4
  303. package/lib/handler/mouse/index.js +0 -27
  304. package/lib/handler/mouse/mouse_handler.d.ts +0 -22
  305. package/lib/handler/mouse/mouse_handler.js +0 -107
  306. package/lib/handler/mouse/mousepan_handler.d.ts +0 -10
  307. package/lib/handler/mouse/mousepan_handler.js +0 -29
  308. package/lib/handler/mouse/mousepitch_hander.d.ts +0 -9
  309. package/lib/handler/mouse/mousepitch_hander.js +0 -32
  310. package/lib/handler/mouse/mouserotate_hander.d.ts +0 -9
  311. package/lib/handler/mouse/mouserotate_hander.js +0 -32
  312. package/lib/handler/mouse/util.d.ts +0 -6
  313. package/lib/handler/mouse/util.js +0 -19
  314. package/lib/handler/scroll_zoom.d.ts +0 -93
  315. package/lib/handler/scroll_zoom.js +0 -322
  316. package/lib/handler/shim/drag_pan.d.ts +0 -61
  317. package/lib/handler/shim/drag_pan.js +0 -83
  318. package/lib/handler/shim/drag_rotate.js +0 -72
  319. package/lib/handler/shim/touch_zoom_rotate.d.ts +0 -70
  320. package/lib/handler/shim/touch_zoom_rotate.js +0 -112
  321. package/lib/handler/tap/single_tap_recognizer.d.ts +0 -20
  322. package/lib/handler/tap/single_tap_recognizer.js +0 -86
  323. package/lib/handler/tap/tap_drag_zoom.d.ts +0 -22
  324. package/lib/handler/tap/tap_drag_zoom.js +0 -97
  325. package/lib/handler/tap/tap_recognizer.d.ts +0 -17
  326. package/lib/handler/tap/tap_recognizer.js +0 -56
  327. package/lib/handler/tap/tap_zoom.d.ts +0 -22
  328. package/lib/handler/tap/tap_zoom.js +0 -89
  329. package/lib/handler/touch/index.d.ts +0 -5
  330. package/lib/handler/touch/index.js +0 -34
  331. package/lib/handler/touch/touch_pan.d.ts +0 -30
  332. package/lib/handler/touch/touch_pan.js +0 -100
  333. package/lib/handler/touch/touch_pitch.d.ts +0 -13
  334. package/lib/handler/touch/touch_pitch.js +0 -83
  335. package/lib/handler/touch/touch_rotate.d.ts +0 -12
  336. package/lib/handler/touch/touch_rotate.js +0 -65
  337. package/lib/handler/touch/touch_zoom.d.ts +0 -12
  338. package/lib/handler/touch/touch_zoom.js +0 -45
  339. package/lib/handler/touch/two_touch.d.ts +0 -23
  340. package/lib/handler/touch/two_touch.js +0 -106
  341. package/lib/hash.d.ts +0 -14
  342. package/lib/hash.js +0 -129
  343. package/lib/interface.d.ts +0 -34
  344. package/lib/interface.js +0 -5
  345. package/lib/map.d.ts +0 -70
  346. package/lib/map.js +0 -478
  347. package/lib/util.d.ts +0 -25
  348. package/lib/util.js +0 -89
  349. package/lib/utils/Aabb.d.ts +0 -12
  350. package/lib/utils/Aabb.js +0 -80
  351. package/lib/utils/dom.d.ts +0 -4
  352. package/lib/utils/dom.js +0 -125
  353. package/lib/utils/performance.d.ts +0 -17
  354. package/lib/utils/performance.js +0 -64
  355. package/lib/utils/primitives.d.ts +0 -6
  356. package/lib/utils/primitives.js +0 -45
  357. package/lib/utils/task_queue.d.ts +0 -13
  358. package/lib/utils/task_queue.js +0 -67
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MercatorCoordinate = void 0;
8
+ exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
9
+ exports.latFromMercatorY = latFromMercatorY;
10
+ exports.lngFromMercatorX = lngFromMercatorX;
11
+ exports.mercatorScale = mercatorScale;
12
+ exports.mercatorXfromLng = mercatorXfromLng;
13
+ exports.mercatorYfromLat = mercatorYfromLat;
14
+ exports.mercatorZfromAltitude = mercatorZfromAltitude;
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _lng_lat = require("./lng_lat");
17
+ /*
18
+ * The average circumference of the world in meters.
19
+ */
20
+ const earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius; // meters
21
+
22
+ /*
23
+ * The circumference at a line of latitude in meters.
24
+ */
25
+ function circumferenceAtLatitude(latitude) {
26
+ return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
27
+ }
28
+ function mercatorXfromLng(lng) {
29
+ return (180 + lng) / 360;
30
+ }
31
+ function mercatorYfromLat(lat) {
32
+ return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
33
+ }
34
+ function mercatorZfromAltitude(altitude, lat) {
35
+ return altitude / circumferenceAtLatitude(lat);
36
+ }
37
+ function lngFromMercatorX(x) {
38
+ return x * 360 - 180;
39
+ }
40
+ function latFromMercatorY(y) {
41
+ const y2 = 180 - y * 360;
42
+ return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
43
+ }
44
+ function altitudeFromMercatorZ(z, y) {
45
+ return z * circumferenceAtLatitude(latFromMercatorY(y));
46
+ }
47
+
48
+ /**
49
+ * Determine the Mercator scale factor for a given latitude, see
50
+ * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
51
+ *
52
+ * At the equator the scale factor will be 1, which increases at higher latitudes.
53
+ *
54
+ * @param lat - Latitude
55
+ * @returns scale factor
56
+ */
57
+ function mercatorScale(lat) {
58
+ return 1 / Math.cos(lat * Math.PI / 180);
59
+ }
60
+
61
+ /**
62
+ * A `MercatorCoordinate` object represents a projected three dimensional position.
63
+ *
64
+ * `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:
65
+ *
66
+ * - the size of 1 unit is the width of the projected world instead of the "mercator meter"
67
+ * - the origin of the coordinate space is at the north-west corner instead of the middle
68
+ *
69
+ * For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and
70
+ * `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with
71
+ * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think
72
+ * of the coordinate space as the `0/0/0` tile with an extent of `1`.
73
+ *
74
+ * The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube.
75
+ *
76
+ * @group Geography and Geometry
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * let nullIsland = new MercatorCoordinate(0.5, 0.5, 0);
81
+ * ```
82
+ * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/)
83
+ */
84
+ class MercatorCoordinate {
85
+ /**
86
+ * @param x - The x component of the position.
87
+ * @param y - The y component of the position.
88
+ * @param z - The z component of the position.
89
+ */
90
+ constructor(x, y, z = 0) {
91
+ (0, _defineProperty2.default)(this, "x", void 0);
92
+ (0, _defineProperty2.default)(this, "y", void 0);
93
+ (0, _defineProperty2.default)(this, "z", void 0);
94
+ this.x = +x;
95
+ this.y = +y;
96
+ this.z = +z;
97
+ }
98
+
99
+ /**
100
+ * Project a `LngLat` to a `MercatorCoordinate`.
101
+ *
102
+ * @param lngLatLike - The location to project.
103
+ * @param altitude - The altitude in meters of the position.
104
+ * @returns The projected mercator coordinate.
105
+ * @example
106
+ * ```ts
107
+ * let coord = MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);
108
+ * coord; // MercatorCoordinate(0.5, 0.5, 0)
109
+ * ```
110
+ */
111
+ static fromLngLat(lngLatLike, altitude = 0) {
112
+ const lngLat = _lng_lat.LngLat.convert(lngLatLike);
113
+ return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
114
+ }
115
+
116
+ /**
117
+ * Returns the `LngLat` for the coordinate.
118
+ *
119
+ * @returns The `LngLat` object.
120
+ * @example
121
+ * ```ts
122
+ * let coord = new MercatorCoordinate(0.5, 0.5, 0);
123
+ * let lngLat = coord.toLngLat(); // LngLat(0, 0)
124
+ * ```
125
+ */
126
+ toLngLat() {
127
+ return new _lng_lat.LngLat(lngFromMercatorX(this.x), latFromMercatorY(this.y));
128
+ }
129
+
130
+ /**
131
+ * Returns the altitude in meters of the coordinate.
132
+ *
133
+ * @returns The altitude in meters.
134
+ * @example
135
+ * ```ts
136
+ * let coord = new MercatorCoordinate(0, 0, 0.02);
137
+ * coord.toAltitude(); // 6914.281956295339
138
+ * ```
139
+ */
140
+ toAltitude() {
141
+ return altitudeFromMercatorZ(this.z, this.y);
142
+ }
143
+
144
+ /**
145
+ * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.
146
+ *
147
+ * For coordinates in real world units using meters, this naturally provides the scale
148
+ * to transform into `MercatorCoordinate`s.
149
+ *
150
+ * @returns Distance of 1 meter in `MercatorCoordinate` units.
151
+ */
152
+ meterInMercatorCoordinateUnits() {
153
+ // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude
154
+ return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));
155
+ }
156
+ }
157
+ exports.MercatorCoordinate = MercatorCoordinate;
@@ -0,0 +1,262 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import Point from '@mapbox/point-geometry';
3
+ import { mat2, mat4 } from 'gl-matrix';
4
+ import { EdgeInsets } from './edge_insets';
5
+ import { LngLat } from './lng_lat';
6
+ import { LngLatBounds } from './lng_lat_bounds';
7
+ import { MercatorCoordinate } from './mercator_coordinate';
8
+ import type { PaddingOptions } from './edge_insets';
9
+ export declare const MAX_VALID_LATITUDE = 85.051129;
10
+ /**
11
+ * @internal
12
+ * A single transform, generally used for a single tile to be
13
+ * scaled, rotated, and zoomed.
14
+ */
15
+ export declare class Transform {
16
+ tileSize: number;
17
+ tileZoom: number;
18
+ lngRange: [number, number];
19
+ latRange: [number, number];
20
+ scale: number;
21
+ width: number;
22
+ height: number;
23
+ angle: number;
24
+ rotationMatrix: mat2;
25
+ pixelsToGLUnits: [number, number];
26
+ cameraToCenterDistance: number;
27
+ mercatorMatrix: mat4;
28
+ projMatrix: mat4;
29
+ invProjMatrix: mat4;
30
+ alignedProjMatrix: mat4;
31
+ pixelMatrix: mat4;
32
+ pixelMatrix3D: mat4;
33
+ pixelMatrixInverse: mat4;
34
+ glCoordMatrix: mat4;
35
+ labelPlaneMatrix: mat4;
36
+ minElevationForCurrentTile: number;
37
+ _fov: number;
38
+ _pitch: number;
39
+ _zoom: number;
40
+ _unmodified: boolean;
41
+ _renderWorldCopies: boolean;
42
+ _minZoom: number;
43
+ _maxZoom: number;
44
+ _minPitch: number;
45
+ _maxPitch: number;
46
+ _center: LngLat;
47
+ _elevation: number;
48
+ _pixelPerMeter: number;
49
+ _edgeInsets: EdgeInsets;
50
+ _constraining: boolean;
51
+ _posMatrixCache: {
52
+ [_: string]: mat4;
53
+ };
54
+ _alignedPosMatrixCache: {
55
+ [_: string]: mat4;
56
+ };
57
+ constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean);
58
+ clone(): Transform;
59
+ apply(that: Transform): void;
60
+ get minZoom(): number;
61
+ set minZoom(zoom: number);
62
+ get maxZoom(): number;
63
+ set maxZoom(zoom: number);
64
+ get minPitch(): number;
65
+ set minPitch(pitch: number);
66
+ get maxPitch(): number;
67
+ set maxPitch(pitch: number);
68
+ get renderWorldCopies(): boolean;
69
+ set renderWorldCopies(renderWorldCopies: boolean | null | undefined);
70
+ get worldSize(): number;
71
+ get centerOffset(): Point;
72
+ get size(): Point;
73
+ get bearing(): number;
74
+ set bearing(bearing: number);
75
+ get pitch(): number;
76
+ set pitch(pitch: number);
77
+ get fov(): number;
78
+ set fov(fov: number);
79
+ get zoom(): number;
80
+ set zoom(zoom: number);
81
+ get center(): LngLat;
82
+ set center(center: LngLat);
83
+ /**
84
+ * Elevation at current center point, meters above sea level
85
+ */
86
+ get elevation(): number;
87
+ set elevation(elevation: number);
88
+ get padding(): PaddingOptions;
89
+ set padding(padding: PaddingOptions);
90
+ /**
91
+ * The center of the screen in pixels with the top-left corner being (0,0)
92
+ * and +y axis pointing downwards. This accounts for padding.
93
+ */
94
+ get centerPoint(): Point;
95
+ /**
96
+ * Returns if the padding params match
97
+ *
98
+ * @param padding - the padding to check against
99
+ * @returns true if they are equal, false otherwise
100
+ */
101
+ isPaddingEqual(padding: PaddingOptions): boolean;
102
+ /**
103
+ * Helper method to update edge-insets in place
104
+ *
105
+ * @param start - the starting padding
106
+ * @param target - the target padding
107
+ * @param t - the step/weight
108
+ */
109
+ interpolatePadding(start: PaddingOptions, target: PaddingOptions, t: number): void;
110
+ /**
111
+ * Return a zoom level that will cover all tiles the transform
112
+ * @param options - the options
113
+ * @returns zoom level An integer zoom level at which all tiles will be visible.
114
+ */
115
+ coveringZoomLevel(options: {
116
+ /**
117
+ * Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.
118
+ */
119
+ roundZoom?: boolean;
120
+ /**
121
+ * Tile size, expressed in screen pixels.
122
+ */
123
+ tileSize: number;
124
+ }): number;
125
+ resize(width: number, height: number): void;
126
+ get unmodified(): boolean;
127
+ zoomScale(zoom: number): number;
128
+ scaleZoom(scale: number): number;
129
+ /**
130
+ * Convert from LngLat to world coordinates (Mercator coordinates scaled by 512)
131
+ * @param lnglat - the lngLat
132
+ * @returns Point
133
+ */
134
+ project(lnglat: LngLat): Point;
135
+ /**
136
+ * Convert from world coordinates ([0, 512],[0, 512]) to LngLat ([-180, 180], [-90, 90])
137
+ * @param point - world coordinate
138
+ * @returns LngLat
139
+ */
140
+ unproject(point: Point): LngLat;
141
+ get point(): Point;
142
+ /**
143
+ * get the camera position in LngLat and altitudes in meter
144
+ * @returns An object with lngLat & altitude.
145
+ */
146
+ getCameraPosition(): {
147
+ lngLat: LngLat;
148
+ altitude: number;
149
+ };
150
+ setLocationAtPoint(lnglat: LngLat, point: Point): void;
151
+ /**
152
+ * Given a LngLat location, return the screen point that corresponds to it
153
+ * @param lnglat - location
154
+ * @param terrain - optional terrain
155
+ * @returns screen point
156
+ */
157
+ locationPoint(lnglat: LngLat): Point;
158
+ /**
159
+ * Given a point on screen, return its lnglat
160
+ * @param p - screen point
161
+ * @param terrain - optional terrain
162
+ * @returns lnglat location
163
+ */
164
+ pointLocation(p: Point): LngLat;
165
+ /**
166
+ * Given a geographical lnglat, return an unrounded
167
+ * coordinate that represents it at low zoom level.
168
+ * @param lnglat - the location
169
+ * @returns The mercator coordinate
170
+ */
171
+ locationCoordinate(lnglat: LngLat): MercatorCoordinate;
172
+ /**
173
+ * Given a Coordinate, return its geographical position.
174
+ * @param coord - mercator coordinates
175
+ * @returns lng and lat
176
+ */
177
+ coordinateLocation(coord: MercatorCoordinate): LngLat;
178
+ /**
179
+ * Given a Point, return its mercator coordinate.
180
+ * @param p - the point
181
+ * @param terrain - optional terrain
182
+ * @returns lnglat
183
+ */
184
+ pointCoordinate(p: Point): MercatorCoordinate;
185
+ /**
186
+ * Given a coordinate, return the screen point that corresponds to it
187
+ * @param coord - the coordinates
188
+ * @param elevation - the elevation
189
+ * @param pixelMatrix - the pixel matrix
190
+ * @returns screen point
191
+ */
192
+ coordinatePoint(coord: MercatorCoordinate, elevation?: number, pixelMatrix?: mat4): Point;
193
+ /**
194
+ * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not
195
+ * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.
196
+ * @returns Returns a {@link LngLatBounds} object describing the map's geographical bounds.
197
+ */
198
+ getBounds(): LngLatBounds;
199
+ /**
200
+ * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.
201
+ * @returns max bounds
202
+ */
203
+ getMaxBounds(): LngLatBounds | null;
204
+ /**
205
+ * Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),
206
+ * multiplied by a static factor to simulate the earth-radius.
207
+ * The calculated value is the horizontal line from the camera-height to sea-level.
208
+ * @returns Horizon above center in pixels.
209
+ */
210
+ getHorizon(): number;
211
+ /**
212
+ * Sets or clears the map's geographical constraints.
213
+ * @param bounds - A {@link LngLatBounds} object describing the new geographic boundaries of the map.
214
+ */
215
+ setMaxBounds(bounds?: LngLatBounds | null): void;
216
+ customLayerMatrix(): mat4;
217
+ /**
218
+ * Get center lngLat and zoom to ensure that
219
+ * 1) everything beyond the bounds is excluded
220
+ * 2) a given lngLat is as near the center as possible
221
+ * Bounds are those set by maxBounds or North & South "Poles" and, if only 1 globe is displayed, antimeridian.
222
+ */
223
+ getConstrained(lngLat: LngLat, zoom: number): {
224
+ center: LngLat;
225
+ zoom: number;
226
+ };
227
+ _constrain(): void;
228
+ _calcMatrices(): void;
229
+ maxPitchScaleFactor(): number;
230
+ /**
231
+ * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`
232
+ * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).
233
+ * `cameraPoint` is the projected position of the `cameraLocation`.
234
+ *
235
+ * This point is useful to us because only fill-extrusions that are between `cameraPoint` and
236
+ * the query point on the surface of the earth can extend and intersect the query.
237
+ *
238
+ * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because
239
+ * the camera is right above the center of the map.
240
+ */
241
+ getCameraPoint(): Point;
242
+ /**
243
+ * When the map is pitched, some of the 3D features that intersect a query will not intersect
244
+ * the query at the surface of the earth. Instead the feature may be closer and only intersect
245
+ * the query because it extrudes into the air.
246
+ * @param queryGeometry - For point queries, the line from the query point to the "camera point",
247
+ * for other geometries, the envelope of the query geometry and the "camera point"
248
+ * @returns a geometry that includes all of the original query as well as all possible ares of the
249
+ * screen where the *base* of a visible extrusion could be.
250
+ *
251
+ */
252
+ getCameraQueryGeometry(queryGeometry: Array<Point>): Array<Point>;
253
+ /**
254
+ * Return the distance to the camera in clip space from a LngLat.
255
+ * This can be compared to the value from the depth buffer (terrain.depthAtPoint)
256
+ * to determine whether a point is occluded.
257
+ * @param lngLat - the point
258
+ * @param elevation - the point's elevation
259
+ * @returns depth value in clip space (between 0 and 1)
260
+ */
261
+ lngLatToCameraDepth(lngLat: LngLat, elevation: number): number;
262
+ }