@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
@@ -1,906 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.EXTENT = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _glMatrix = require("gl-matrix");
10
- var _point = _interopRequireDefault(require("../geo/point"));
11
- var _util = require("../util");
12
- var _edge_insets = _interopRequireDefault(require("./edge_insets"));
13
- var _lng_lat = _interopRequireDefault(require("./lng_lat"));
14
- var _lng_lat_bounds = _interopRequireDefault(require("./lng_lat_bounds"));
15
- var _mercator = _interopRequireWildcard(require("./mercator"));
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- // @ts-ignore
19
-
20
- const EXTENT = exports.EXTENT = 8192;
21
- class Transform {
22
- get minZoom() {
23
- return this._minZoom;
24
- }
25
- set minZoom(zoom) {
26
- if (this._minZoom === zoom) {
27
- return;
28
- }
29
- this._minZoom = zoom;
30
- this.zoom = Math.max(this.zoom, zoom);
31
- }
32
- get maxZoom() {
33
- return this._maxZoom;
34
- }
35
- set maxZoom(zoom) {
36
- if (this._maxZoom === zoom) {
37
- return;
38
- }
39
- this._maxZoom = zoom;
40
- this.zoom = Math.min(this.zoom, zoom);
41
- }
42
- get minPitch() {
43
- return this._minPitch;
44
- }
45
- set minPitch(pitch) {
46
- if (this._minPitch === pitch) {
47
- return;
48
- }
49
- this._minPitch = pitch;
50
- this._pitch = Math.max(this._pitch, pitch);
51
- }
52
- get maxPitch() {
53
- return this._maxPitch;
54
- }
55
- set maxPitch(pitch) {
56
- if (this._maxPitch === pitch) {
57
- return;
58
- }
59
- this._maxPitch = pitch;
60
- this._pitch = Math.min(this._pitch, pitch);
61
- }
62
- get renderWorldCopies() {
63
- return this._renderWorldCopies;
64
- }
65
- set renderWorldCopies(renderWorldCopies) {
66
- if (renderWorldCopies === undefined) {
67
- renderWorldCopies = true;
68
- } else if (renderWorldCopies === null) {
69
- renderWorldCopies = false;
70
- }
71
- this._renderWorldCopies = renderWorldCopies;
72
- }
73
- get worldSize() {
74
- return this.tileSize * this.scale;
75
- }
76
- get centerOffset() {
77
- return this.centerPoint._sub(this.size._div(2));
78
- }
79
- get size() {
80
- return new _point.default(this.width, this.height);
81
- }
82
- get bearing() {
83
- return -this.angle / Math.PI * 180;
84
- }
85
- set bearing(bearing) {
86
- const b = -(0, _util.wrap)(bearing, -180, 180) * Math.PI / 180;
87
- if (this.angle === b) {
88
- return;
89
- }
90
- this.unmodified = false;
91
- this.angle = b;
92
- this.calcMatrices();
93
-
94
- // 2x2 matrix for rotating points
95
- this.rotationMatrix = _glMatrix.mat2.create();
96
- _glMatrix.mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);
97
- }
98
- get pitch() {
99
- return this._pitch / Math.PI * 180;
100
- }
101
- set pitch(pitch) {
102
- const p = (0, _util.clamp)(pitch, this._minPitch, this._maxPitch) / 180 * Math.PI;
103
- if (this._pitch === p) {
104
- return;
105
- }
106
- this.unmodified = false;
107
- this._pitch = p;
108
- this.calcMatrices();
109
- }
110
- get fov() {
111
- return this._fov / Math.PI * 180;
112
- }
113
- set fov(fov) {
114
- fov = Math.max(0.01, Math.min(60, fov));
115
- if (this._fov === fov) {
116
- return;
117
- }
118
- this.unmodified = false;
119
- this._fov = fov / 180 * Math.PI;
120
- this.calcMatrices();
121
- }
122
- get zoom() {
123
- return this._zoom;
124
- }
125
- set zoom(zoom) {
126
- const z = Math.min(Math.max(zoom, this._minZoom), this._maxZoom);
127
- if (this._zoom === z) {
128
- return;
129
- }
130
- this.unmodified = false;
131
- this._zoom = z;
132
- this.scale = this.zoomScale(z);
133
- this.tileZoom = Math.floor(z);
134
- this.zoomFraction = z - this.tileZoom;
135
- this.constrain();
136
- this.calcMatrices();
137
- }
138
- get center() {
139
- return this._center;
140
- }
141
- set center(center) {
142
- if (center.lat === this._center.lat && center.lng === this._center.lng) {
143
- return;
144
- }
145
- this.unmodified = false;
146
- this._center = center;
147
- this.constrain();
148
- this.calcMatrices();
149
- }
150
- get padding() {
151
- return this.edgeInsets.toJSON();
152
- }
153
- set padding(padding) {
154
- if (this.edgeInsets.equals(padding)) {
155
- return;
156
- }
157
- this.unmodified = false;
158
- // Update edge-insets inplace
159
- this.edgeInsets.interpolate(this.edgeInsets, padding, 1);
160
- this.calcMatrices();
161
- }
162
-
163
- /**
164
- * The center of the screen in pixels with the top-left corner being (0,0)
165
- * and +y axis pointing downwards. This accounts for padding.
166
- *
167
- * @readonly
168
- * @type {Point}
169
- * @memberof Transform
170
- */
171
- get centerPoint() {
172
- return this.edgeInsets.getCenter(this.width, this.height);
173
- }
174
- get point() {
175
- return this.project(this.center);
176
- }
177
- constructor(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies) {
178
- (0, _defineProperty2.default)(this, "tileSize", void 0);
179
- (0, _defineProperty2.default)(this, "tileZoom", void 0);
180
- (0, _defineProperty2.default)(this, "lngRange", void 0);
181
- (0, _defineProperty2.default)(this, "latRange", void 0);
182
- (0, _defineProperty2.default)(this, "maxValidLatitude", void 0);
183
- (0, _defineProperty2.default)(this, "scale", void 0);
184
- (0, _defineProperty2.default)(this, "width", void 0);
185
- (0, _defineProperty2.default)(this, "height", void 0);
186
- (0, _defineProperty2.default)(this, "angle", void 0);
187
- (0, _defineProperty2.default)(this, "rotationMatrix", void 0);
188
- (0, _defineProperty2.default)(this, "pixelsToGLUnits", void 0);
189
- (0, _defineProperty2.default)(this, "cameraToCenterDistance", void 0);
190
- (0, _defineProperty2.default)(this, "mercatorMatrix", void 0);
191
- (0, _defineProperty2.default)(this, "projMatrix", void 0);
192
- (0, _defineProperty2.default)(this, "invProjMatrix", void 0);
193
- (0, _defineProperty2.default)(this, "alignedProjMatrix", void 0);
194
- (0, _defineProperty2.default)(this, "pixelMatrix", void 0);
195
- (0, _defineProperty2.default)(this, "pixelMatrixInverse", void 0);
196
- (0, _defineProperty2.default)(this, "glCoordMatrix", void 0);
197
- (0, _defineProperty2.default)(this, "labelPlaneMatrix", void 0);
198
- // tslint:disable:variable-name
199
- (0, _defineProperty2.default)(this, "_fov", void 0);
200
- (0, _defineProperty2.default)(this, "_pitch", void 0);
201
- (0, _defineProperty2.default)(this, "_zoom", void 0);
202
- (0, _defineProperty2.default)(this, "_renderWorldCopies", void 0);
203
- (0, _defineProperty2.default)(this, "_minZoom", void 0);
204
- (0, _defineProperty2.default)(this, "_maxZoom", void 0);
205
- (0, _defineProperty2.default)(this, "_minPitch", void 0);
206
- (0, _defineProperty2.default)(this, "_maxPitch", void 0);
207
- (0, _defineProperty2.default)(this, "_center", void 0);
208
- // tslint:enable
209
- (0, _defineProperty2.default)(this, "zoomFraction", void 0);
210
- (0, _defineProperty2.default)(this, "unmodified", void 0);
211
- (0, _defineProperty2.default)(this, "edgeInsets", void 0);
212
- (0, _defineProperty2.default)(this, "constraining", void 0);
213
- (0, _defineProperty2.default)(this, "posMatrixCache", void 0);
214
- (0, _defineProperty2.default)(this, "alignedPosMatrixCache", void 0);
215
- this.tileSize = 512; // constant
216
- this.maxValidLatitude = 85.051129; // constant
217
-
218
- this._renderWorldCopies = renderWorldCopies === undefined ? true : renderWorldCopies;
219
- this._minZoom = minZoom || 0;
220
- this._maxZoom = maxZoom || 22;
221
- this._minPitch = minPitch === undefined || minPitch === null ? 0 : minPitch;
222
- this._maxPitch = maxPitch === undefined || maxPitch === null ? 60 : maxPitch;
223
- this.setMaxBounds();
224
- this.width = 0;
225
- this.height = 0;
226
- this._center = new _lng_lat.default(0, 0);
227
- this.zoom = 0;
228
- this.angle = 0;
229
- this._fov = 0.6435011087932844;
230
- this._pitch = 0;
231
- this.unmodified = true;
232
- this.edgeInsets = new _edge_insets.default();
233
- this.posMatrixCache = {};
234
- this.alignedPosMatrixCache = {};
235
- }
236
- clone() {
237
- const clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this._maxPitch, this._renderWorldCopies);
238
- clone.tileSize = this.tileSize;
239
- clone.latRange = this.latRange;
240
- clone.width = this.width;
241
- clone.height = this.height;
242
- clone.center = this._center;
243
- clone.zoom = this.zoom;
244
- clone.angle = this.angle;
245
- clone.fov = this._fov;
246
- clone.pitch = this._pitch;
247
- clone.unmodified = this.unmodified;
248
- clone.edgeInsets = this.edgeInsets.clone();
249
- clone.calcMatrices();
250
- return clone;
251
- }
252
-
253
- /**
254
- * Returns if the padding params match
255
- *
256
- * @param {IPaddingOptions} padding
257
- * @returns {boolean}
258
- * @memberof Transform
259
- */
260
- isPaddingEqual(padding) {
261
- return this.edgeInsets.equals(padding);
262
- }
263
-
264
- /**
265
- * Helper method to upadte edge-insets inplace
266
- *
267
- * @param {IPaddingOptions} target
268
- * @param {number} t
269
- * @memberof Transform
270
- */
271
- interpolatePadding(start, target, t) {
272
- this.unmodified = false;
273
- this.edgeInsets.interpolate(start, target, t);
274
- this.constrain();
275
- this.calcMatrices();
276
- }
277
-
278
- /**
279
- * Return a zoom level that will cover all tiles the transform
280
- * @param {Object} options options
281
- * @param {number} options.tileSize Tile size, expressed in screen pixels.
282
- * @param {boolean} options.roundZoom Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.
283
- * @returns {number} zoom level An integer zoom level at which all tiles will be visible.
284
- */
285
- coveringZoomLevel(options) {
286
- const z = (options.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / options.tileSize));
287
- // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.
288
- return Math.max(0, z);
289
- }
290
-
291
- /**
292
- * Return any "wrapped" copies of a given tile coordinate that are visible
293
- * in the current view.
294
- *
295
- * @private
296
- */
297
- // public getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) {
298
- // const result = [new UnwrappedTileID(0, tileID)];
299
- // if (this._renderWorldCopies) {
300
- // const utl = this.pointCoordinate(new Point(0, 0));
301
- // const utr = this.pointCoordinate(new Point(this.width, 0));
302
- // const ubl = this.pointCoordinate(new Point(this.width, this.height));
303
- // const ubr = this.pointCoordinate(new Point(0, this.height));
304
- // const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));
305
- // const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));
306
-
307
- // // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.
308
- // // Both sources draw outside the tile boundaries of the tile that "contains them" so we need
309
- // // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.
310
- // const extraWorldCopy = 1;
311
-
312
- // for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {
313
- // if (w === 0) {
314
- // continue;
315
- // }
316
- // result.push(new UnwrappedTileID(w, tileID));
317
- // }
318
- // }
319
- // return result;
320
- // }
321
-
322
- /**
323
- * Return all coordinates that could cover this transform for a covering
324
- * zoom level.
325
- * @param {Object} options
326
- * @param {number} options.tileSize
327
- * @param {number} options.minzoom
328
- * @param {number} options.maxzoom
329
- * @param {boolean} options.roundZoom
330
- * @param {boolean} options.reparseOverscaled
331
- * @param {boolean} options.renderWorldCopies
332
- * @returns {Array<OverscaledTileID>} OverscaledTileIDs
333
- * @private
334
- */
335
- // public coveringTiles(options: {
336
- // tileSize: number;
337
- // minzoom?: number;
338
- // maxzoom?: number;
339
- // roundZoom?: boolean;
340
- // reparseOverscaled?: boolean;
341
- // renderWorldCopies?: boolean;
342
- // }): OverscaledTileID[] {
343
- // let z = this.coveringZoomLevel(options);
344
- // const actualZ = z;
345
-
346
- // if (options.minzoom !== undefined && z < options.minzoom) {
347
- // return [];
348
- // }
349
- // if (options.maxzoom !== undefined && z > options.maxzoom) {
350
- // z = options.maxzoom;
351
- // }
352
-
353
- // const centerCoord = MercatorCoordinate.fromLngLat(this.center);
354
- // const numTiles = Math.pow(2, z);
355
- // const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];
356
- // const cameraFrustum = Frustum.fromInvProjectionMatrix(
357
- // this.invProjMatrix,
358
- // this.worldSize,
359
- // z,
360
- // );
361
-
362
- // // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level
363
- // let minZoom = options.minzoom || 0;
364
- // // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks
365
- // if (this._pitch <= 60.0 && this.edgeInsets.top < 0.1) {
366
- // minZoom = z;
367
- // }
368
-
369
- // // There should always be a certain number of maximum zoom level tiles surrounding the center location
370
- // const radiusOfMaxLvlLodInTiles = 3;
371
-
372
- // const newRootTile = (wrap: number): any => {
373
- // return {
374
- // // All tiles are on zero elevation plane => z difference is zero
375
- // aabb: new Aabb(
376
- // [wrap * numTiles, 0, 0],
377
- // [(wrap + 1) * numTiles, numTiles, 0],
378
- // ),
379
- // zoom: 0,
380
- // x: 0,
381
- // y: 0,
382
- // wrap,
383
- // fullyVisible: false,
384
- // };
385
- // };
386
-
387
- // // Do a depth-first traversal to find visible tiles and proper levels of detail
388
- // const stack = [];
389
- // const result = [];
390
- // const maxZoom = z;
391
- // const overscaledZ = options.reparseOverscaled ? actualZ : z;
392
-
393
- // if (this._renderWorldCopies) {
394
- // // Render copy of the globe thrice on both sides
395
- // for (let i = 1; i <= 3; i++) {
396
- // stack.push(newRootTile(-i));
397
- // stack.push(newRootTile(i));
398
- // }
399
- // }
400
-
401
- // stack.push(newRootTile(0));
402
-
403
- // while (stack.length > 0) {
404
- // const it = stack.pop();
405
- // const x = it.x;
406
- // const y = it.y;
407
- // let fullyVisible = it.fullyVisible;
408
-
409
- // // Visibility of a tile is not required if any of its ancestor if fully inside the frustum
410
- // if (!fullyVisible) {
411
- // const intersectResult = it.aabb.intersects(cameraFrustum);
412
-
413
- // if (intersectResult === 0) {
414
- // continue;
415
- // }
416
-
417
- // fullyVisible = intersectResult === 2;
418
- // }
419
-
420
- // const distanceX = it.aabb.distanceX(centerPoint);
421
- // const distanceY = it.aabb.distanceY(centerPoint);
422
- // const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));
423
-
424
- // // We're using distance based heuristics to determine if a tile should be split into quadrants or not.
425
- // // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.
426
- // // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)
427
- // // we can define distance thresholds for each relative level:
428
- // // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as "offset+2^(k+1)-2"
429
- // const distToSplit =
430
- // radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;
431
-
432
- // // Have we reached the target depth or is the tile too far away to be any split further?
433
- // if (
434
- // it.zoom === maxZoom ||
435
- // (longestDim > distToSplit && it.zoom >= minZoom)
436
- // ) {
437
- // result.push({
438
- // tileID: new OverscaledTileID(
439
- // it.zoom === maxZoom ? overscaledZ : it.zoom,
440
- // it.wrap,
441
- // it.zoom,
442
- // x,
443
- // y,
444
- // ),
445
- // distanceSq: vec2.sqrLen([
446
- // centerPoint[0] - 0.5 - x,
447
- // centerPoint[1] - 0.5 - y,
448
- // ]),
449
- // });
450
- // continue;
451
- // }
452
-
453
- // for (let i = 0; i < 4; i++) {
454
- // const childX = (x << 1) + (i % 2);
455
- // const childY = (y << 1) + (i >> 1);
456
-
457
- // stack.push({
458
- // aabb: it.aabb.quadrant(i),
459
- // zoom: it.zoom + 1,
460
- // x: childX,
461
- // y: childY,
462
- // wrap: it.wrap,
463
- // fullyVisible,
464
- // });
465
- // }
466
- // }
467
-
468
- // return result
469
- // .sort((a, b) => a.distanceSq - b.distanceSq)
470
- // .map((a) => a.tileID);
471
- // }
472
-
473
- resize(width, height) {
474
- this.width = width;
475
- this.height = height;
476
- this.pixelsToGLUnits = [2 / width, -2 / height];
477
- this.constrain();
478
- this.calcMatrices();
479
- }
480
- zoomScale(zoom) {
481
- return Math.pow(2, zoom);
482
- }
483
- scaleZoom(scale) {
484
- return Math.log(scale) / Math.LN2;
485
- }
486
- project(lnglat) {
487
- const lat = (0, _util.clamp)(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude);
488
- return new _point.default((0, _mercator.mercatorXfromLng)(lnglat.lng) * this.worldSize, (0, _mercator.mercatorYfromLat)(lat) * this.worldSize);
489
- }
490
- unproject(point) {
491
- return new _mercator.default(point.x / this.worldSize, point.y / this.worldSize).toLngLat();
492
- }
493
- setLocationAtPoint(lnglat, point) {
494
- const a = this.pointCoordinate(point);
495
- const b = this.pointCoordinate(this.centerPoint);
496
- const loc = this.locationCoordinate(lnglat);
497
- const newCenter = new _mercator.default(loc.x - (a.x - b.x), loc.y - (a.y - b.y));
498
- this.center = this.coordinateLocation(newCenter);
499
- if (this._renderWorldCopies) {
500
- this.center = this.center.wrap();
501
- }
502
- }
503
- pointCoordinate(p) {
504
- const targetZ = 0;
505
- // since we don't know the correct projected z value for the point,
506
- // unproject two points to get a line and then find the point on that
507
- // line with z=0
508
-
509
- const coord0 = new Float64Array([p.x, p.y, 0, 1]);
510
- const coord1 = new Float64Array([p.x, p.y, 1, 1]);
511
-
512
- // @ts-ignore
513
- _glMatrix.vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);
514
- // @ts-ignore
515
- _glMatrix.vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);
516
- const w0 = coord0[3];
517
- const w1 = coord1[3];
518
- const x0 = coord0[0] / w0;
519
- const x1 = coord1[0] / w1;
520
- const y0 = coord0[1] / w0;
521
- const y1 = coord1[1] / w1;
522
- const z0 = coord0[2] / w0;
523
- const z1 = coord1[2] / w1;
524
- const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);
525
- return new _mercator.default((0, _util.interpolate)(x0, x1, t) / this.worldSize, (0, _util.interpolate)(y0, y1, t) / this.worldSize);
526
- }
527
-
528
- /**
529
- * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not
530
- * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.
531
- * @returns {LngLatBounds} Returns a {@link LngLatBounds} object describing the map's geographical bounds.
532
- */
533
- getBounds() {
534
- return new _lng_lat_bounds.default().extend(this.pointLocation(new _point.default(0, 0))).extend(this.pointLocation(new _point.default(this.width, 0))).extend(this.pointLocation(new _point.default(this.width, this.height))).extend(this.pointLocation(new _point.default(0, this.height)));
535
- }
536
-
537
- /**
538
- * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.
539
- * @returns {LngLatBounds} {@link LngLatBounds}
540
- */
541
- getMaxBounds() {
542
- if (!this.latRange || this.latRange.length !== 2 || !this.lngRange || this.lngRange.length !== 2) {
543
- return null;
544
- }
545
- return new _lng_lat_bounds.default([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]);
546
- }
547
-
548
- /**
549
- * Sets or clears the map's geographical constraints.
550
- * @param {LngLatBounds} bounds A {@link LngLatBounds} object describing the new geographic boundaries of the map.
551
- */
552
- setMaxBounds(bounds) {
553
- if (bounds) {
554
- this.lngRange = [bounds.getWest(), bounds.getEast()];
555
- this.latRange = [bounds.getSouth(), bounds.getNorth()];
556
- this.constrain();
557
- } else {
558
- this.lngRange = undefined;
559
- this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];
560
- }
561
- }
562
- customLayerMatrix() {
563
- return this.mercatorMatrix.slice();
564
- }
565
- maxPitchScaleFactor() {
566
- // calcMatrices hasn't run yet
567
- if (!this.pixelMatrixInverse) {
568
- return 1;
569
- }
570
- const coord = this.pointCoordinate(new _point.default(0, 0));
571
- const p = new Float32Array([coord.x * this.worldSize, coord.y * this.worldSize, 0, 1]);
572
- const topPoint = _glMatrix.vec4.transformMat4(p, p, this.pixelMatrix);
573
- return topPoint[3] / this.cameraToCenterDistance;
574
- }
575
-
576
- /*
577
- * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`
578
- * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).
579
- * `cameraPoint` is the projected position of the `cameraLocation`.
580
- *
581
- * This point is useful to us because only fill-extrusions that are between `cameraPoint` and
582
- * the query point on the surface of the earth can extend and intersect the query.
583
- *
584
- * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because
585
- * the camera is right above the center of the map.
586
- */
587
- getCameraPoint() {
588
- const pitch = this._pitch;
589
- const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);
590
- return this.centerPoint.add(new _point.default(0, yOffset));
591
- }
592
-
593
- /*
594
- * When the map is pitched, some of the 3D features that intersect a query will not intersect
595
- * the query at the surface of the earth. Instead the feature may be closer and only intersect
596
- * the query because it extrudes into the air.
597
- *
598
- * This returns a geometry that includes all of the original query as well as all possible ares of the
599
- * screen where the *base* of a visible extrusion could be.
600
- * - For point queries, the line from the query point to the "camera point"
601
- * - For other geometries, the envelope of the query geometry and the "camera point"
602
- */
603
- getCameraQueryGeometry(queryGeometry) {
604
- const c = this.getCameraPoint();
605
- if (queryGeometry.length === 1) {
606
- return [queryGeometry[0], c];
607
- } else {
608
- let minX = c.x;
609
- let minY = c.y;
610
- let maxX = c.x;
611
- let maxY = c.y;
612
- for (const p of queryGeometry) {
613
- minX = Math.min(minX, p.x);
614
- minY = Math.min(minY, p.y);
615
- maxX = Math.max(maxX, p.x);
616
- maxY = Math.max(maxY, p.y);
617
- }
618
- return [new _point.default(minX, minY), new _point.default(maxX, minY), new _point.default(maxX, maxY), new _point.default(minX, maxY), new _point.default(minX, minY)];
619
- }
620
- }
621
-
622
- /**
623
- * Given a coordinate, return the screen point that corresponds to it
624
- * @param {Coordinate} coord
625
- * @returns {Point} screen point
626
- * @private
627
- */
628
- coordinatePoint(coord) {
629
- const p = _glMatrix.vec4.fromValues(coord.x * this.worldSize, coord.y * this.worldSize, 0, 1);
630
- _glMatrix.vec4.transformMat4(p, p, this.pixelMatrix);
631
- return new _point.default(p[0] / p[3], p[1] / p[3]);
632
- }
633
- /**
634
- * Given a location, return the screen point that corresponds to it
635
- * @param {LngLat} lnglat location
636
- * @returns {Point} screen point
637
- * @private
638
- */
639
- locationPoint(lnglat) {
640
- return this.coordinatePoint(this.locationCoordinate(lnglat));
641
- }
642
-
643
- /**
644
- * Given a point on screen, return its lnglat
645
- * @param {Point} p screen point
646
- * @returns {LngLat} lnglat location
647
- * @private
648
- */
649
- pointLocation(p) {
650
- // if(p.x !== 0 && p.x !== 1001) {
651
- // console.log(p.x)
652
- // }
653
-
654
- return this.coordinateLocation(this.pointCoordinate(p));
655
- }
656
-
657
- /**
658
- * Given a geographical lnglat, return an unrounded
659
- * coordinate that represents it at this transform's zoom level.
660
- * @param {LngLat} lnglat
661
- * @returns {Coordinate}
662
- * @private
663
- */
664
- locationCoordinate(lnglat) {
665
- return _mercator.default.fromLngLat(lnglat);
666
- }
667
-
668
- /**
669
- * Given a Coordinate, return its geographical position.
670
- * @param {Coordinate} coord
671
- * @returns {LngLat} lnglat
672
- * @private
673
- */
674
- coordinateLocation(coord) {
675
- return coord.toLngLat();
676
- }
677
- getProjectionMatrix() {
678
- return this.projMatrix;
679
- }
680
- /**
681
- * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map.
682
- * @param {UnwrappedTileID} unwrappedTileID;
683
- * @private
684
- */
685
- // private calculatePosMatrix(
686
- // unwrappedTileID: UnwrappedTileID,
687
- // aligned: boolean = false,
688
- // ): Float32Array {
689
- // const posMatrixKey = unwrappedTileID.key;
690
- // const cache = aligned ? this.alignedPosMatrixCache : this.posMatrixCache;
691
- // if (cache[posMatrixKey]) {
692
- // return cache[posMatrixKey];
693
- // }
694
-
695
- // const canonical = unwrappedTileID.canonical;
696
- // const scale = this.worldSize / this.zoomScale(canonical.z);
697
- // const unwrappedX =
698
- // canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;
699
-
700
- // const posMatrix = mat4.identity(new Float64Array(16));
701
- // mat4.translate(posMatrix, posMatrix, [
702
- // unwrappedX * scale,
703
- // canonical.y * scale,
704
- // 0,
705
- // ]);
706
- // mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);
707
- // mat4.multiply(
708
- // posMatrix,
709
- // aligned ? this.alignedProjMatrix : this.projMatrix,
710
- // posMatrix,
711
- // );
712
-
713
- // cache[posMatrixKey] = new Float32Array(posMatrix);
714
- // return cache[posMatrixKey];
715
- // }
716
-
717
- constrain() {
718
- if (!this.center || !this.width || !this.height || this.constraining) {
719
- return;
720
- }
721
- this.constraining = true;
722
- let minY = -90;
723
- let maxY = 90;
724
- let minX = -180;
725
- let maxX = 180;
726
- let sy;
727
- let sx;
728
- let x2;
729
- let y2;
730
- const size = this.size;
731
- const unmodified = this.unmodified;
732
- if (this.latRange) {
733
- const latRange = this.latRange;
734
- minY = (0, _mercator.mercatorYfromLat)(latRange[1]) * this.worldSize;
735
- maxY = (0, _mercator.mercatorYfromLat)(latRange[0]) * this.worldSize;
736
- sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;
737
- }
738
- if (this.lngRange) {
739
- const lngRange = this.lngRange;
740
- minX = (0, _mercator.mercatorXfromLng)(lngRange[0]) * this.worldSize;
741
- maxX = (0, _mercator.mercatorXfromLng)(lngRange[1]) * this.worldSize;
742
- sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;
743
- }
744
- const point = this.point;
745
-
746
- // how much the map should scale to fit the screen into given latitude/longitude ranges
747
- const s = Math.max(sx || 0, sy || 0);
748
- if (s) {
749
- this.center = this.unproject(new _point.default(sx ? (maxX + minX) / 2 : point.x, sy ? (maxY + minY) / 2 : point.y));
750
- this.zoom += this.scaleZoom(s);
751
- this.unmodified = unmodified;
752
- this.constraining = false;
753
- return;
754
- }
755
- if (this.latRange) {
756
- const y = point.y;
757
- const h2 = size.y / 2;
758
- if (y - h2 < minY) {
759
- y2 = minY + h2;
760
- }
761
- if (y + h2 > maxY) {
762
- y2 = maxY - h2;
763
- }
764
- }
765
- if (this.lngRange) {
766
- const x = point.x;
767
- const w2 = size.x / 2;
768
- if (x - w2 < minX) {
769
- x2 = minX + w2;
770
- }
771
- if (x + w2 > maxX) {
772
- x2 = maxX - w2;
773
- }
774
- }
775
-
776
- // pan the map if the screen goes off the range
777
- if (x2 !== undefined || y2 !== undefined) {
778
- this.center = this.unproject(new _point.default(x2 !== undefined ? x2 : point.x, y2 !== undefined ? y2 : point.y));
779
- }
780
- this.unmodified = unmodified;
781
- this.constraining = false;
782
- }
783
- calcMatrices() {
784
- if (!this.height) {
785
- return;
786
- }
787
- const halfFov = this._fov / 2;
788
- const offset = this.centerOffset;
789
- this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;
790
-
791
- // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the
792
- // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.
793
- // 1 Z unit is equivalent to 1 horizontal px at the center of the map
794
- // (the distance between[width/2, height/2] and [width/2 + 1, height/2])
795
- const groundAngle = Math.PI / 2 + this._pitch;
796
- const fovAboveCenter = this._fov * (0.5 + offset.y / this.height);
797
- const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * this.cameraToCenterDistance / Math.sin((0, _util.clamp)(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));
798
- const point = this.point;
799
- const x = point.x;
800
- const y = point.y;
801
-
802
- // Calculate z distance of the farthest fragment that should be rendered.
803
- const furthestDistance = Math.cos(Math.PI / 2 - this._pitch) * topHalfSurfaceDistance + this.cameraToCenterDistance;
804
- // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
805
- const farZ = furthestDistance * 1.01;
806
-
807
- // The larger the value of nearZ is
808
- // - the more depth precision is available for features (good)
809
- // - clipping starts appearing sooner when the camera is close to 3d features (bad)
810
- //
811
- // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues
812
- // when rendering it's layers using custom layers. This value was experimentally chosen and
813
- // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.
814
- const nearZ = this.height / 50;
815
-
816
- // matrix for conversion from location to GL coordinates (-1 .. 1)
817
- // 使用 Float64Array 的原因是为了避免计算精度问题、 mat4.create() 默认使用 Float32Array
818
- let m = new Float64Array(16);
819
- // @ts-ignore
820
- _glMatrix.mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);
821
-
822
- // Apply center of perspective offset
823
- m[8] = -offset.x * 2 / this.width;
824
- m[9] = offset.y * 2 / this.height;
825
-
826
- // @ts-ignore
827
- _glMatrix.mat4.scale(m, m, [1, -1, 1]);
828
- // @ts-ignore
829
- _glMatrix.mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);
830
- // @ts-ignore
831
- _glMatrix.mat4.rotateX(m, m, this._pitch);
832
- // @ts-ignore
833
- _glMatrix.mat4.rotateZ(m, m, this.angle);
834
- // @ts-ignore
835
- _glMatrix.mat4.translate(m, m, [-x, -y, 0]);
836
-
837
- // The mercatorMatrix can be used to transform points from mercator coordinates
838
- // ([0, 0] nw, [1, 1] se) to GL coordinates.
839
- // @ts-ignore
840
- this.mercatorMatrix = _glMatrix.mat4.scale([], m, [this.worldSize, this.worldSize, this.worldSize]);
841
- // scale vertically to meters per pixel (inverse of ground resolution):
842
-
843
- // @ts-ignore
844
- _glMatrix.mat4.scale(m, m, [1, 1, (0, _mercator.mercatorZfromAltitude)(1, this.center.lat) * this.worldSize, 1]);
845
- // @ts-ignore
846
- this.projMatrix = m;
847
- // @ts-ignore
848
- this.invProjMatrix = _glMatrix.mat4.invert([], this.projMatrix);
849
-
850
- // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.
851
- // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional
852
- // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension
853
- // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle
854
- // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that
855
- // it is always <= 0.5 pixels.
856
- const xShift = this.width % 2 / 2;
857
- const yShift = this.height % 2 / 2;
858
- const angleCos = Math.cos(this.angle);
859
- const angleSin = Math.sin(this.angle);
860
- const dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift;
861
- const dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;
862
- // const alignedM = mat4.clone(m);
863
- const alignedM = new Float64Array(m);
864
- // @ts-ignore
865
- _glMatrix.mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);
866
- // @ts-ignore
867
- this.alignedProjMatrix = alignedM;
868
-
869
- // @ts-ignore
870
- m = _glMatrix.mat4.create();
871
- // @ts-ignore
872
- _glMatrix.mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);
873
- // @ts-ignore
874
- _glMatrix.mat4.translate(m, m, [1, -1, 0]);
875
- // @ts-ignore
876
- this.labelPlaneMatrix = m;
877
-
878
- // @ts-ignore
879
- m = _glMatrix.mat4.create();
880
- // @ts-ignore
881
- _glMatrix.mat4.scale(m, m, [1, -1, 1]);
882
- // @ts-ignore
883
- _glMatrix.mat4.translate(m, m, [-1, -1, 0]);
884
- // @ts-ignore
885
- _glMatrix.mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);
886
- // @ts-ignore
887
- this.glCoordMatrix = m;
888
-
889
- // matrix for conversion from location to screen coordinates
890
- this.pixelMatrix = _glMatrix.mat4.multiply(
891
- // @ts-ignore
892
- new Float64Array(16), this.labelPlaneMatrix, this.projMatrix);
893
-
894
- // inverse matrix for conversion from screen coordinaes to location
895
- // @ts-ignore
896
- m = _glMatrix.mat4.invert(new Float64Array(16), this.pixelMatrix);
897
- if (!m) {
898
- throw new Error('failed to invert matrix');
899
- }
900
- // @ts-ignore
901
- this.pixelMatrixInverse = m;
902
- this.posMatrixCache = {};
903
- this.alignedPosMatrixCache = {};
904
- }
905
- }
906
- exports.default = Transform;