@antv/l7-map 2.9.32-alpha.2 → 2.9.33

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 (168) hide show
  1. package/es/camera.d.ts +84 -0
  2. package/es/camera.js +765 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +421 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +118 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +81 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +167 -0
  12. package/es/geo/mercator.d.ts +28 -0
  13. package/es/geo/mercator.js +91 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +231 -0
  16. package/es/geo/simple.d.ts +28 -0
  17. package/es/geo/simple.js +90 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +971 -0
  20. package/es/handler/IHandler.d.ts +34 -0
  21. package/es/handler/IHandler.js +1 -0
  22. package/es/handler/blockable_map_event.d.ts +17 -0
  23. package/es/handler/blockable_map_event.js +83 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +200 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +59 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +12 -0
  30. package/es/handler/events/index.d.ts +4 -0
  31. package/es/handler/events/index.js +4 -0
  32. package/es/handler/events/map_mouse_event.d.ts +34 -0
  33. package/es/handler/events/map_mouse_event.js +75 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +105 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +61 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +39 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +184 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +684 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +10 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +162 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +131 -0
  50. package/es/handler/mouse/index.d.ts +4 -0
  51. package/es/handler/mouse/index.js +4 -0
  52. package/es/handler/mouse/mouse_handler.d.ts +22 -0
  53. package/es/handler/mouse/mouse_handler.js +129 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +54 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +56 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +56 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +12 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +353 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +72 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +96 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +80 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +130 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +120 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +114 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +62 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +115 -0
  80. package/es/handler/touch/index.d.ts +5 -0
  81. package/es/handler/touch/index.js +5 -0
  82. package/es/handler/touch/touch_pan.d.ts +30 -0
  83. package/es/handler/touch/touch_pan.js +128 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +110 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +88 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +67 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +134 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +156 -0
  94. package/es/index.d.ts +3 -0
  95. package/es/index.js +3 -0
  96. package/es/interface.d.ts +34 -0
  97. package/es/interface.js +1 -0
  98. package/es/map.d.ts +70 -0
  99. package/es/map.js +463 -0
  100. package/es/util.d.ts +18 -0
  101. package/es/util.js +84 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +133 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +218 -0
  106. package/es/utils/performance.d.ts +17 -0
  107. package/es/utils/performance.js +62 -0
  108. package/es/utils/primitives.d.ts +6 -0
  109. package/es/utils/primitives.js +45 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +106 -0
  112. package/lib/camera.js +533 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +278 -0
  115. package/lib/geo/edge_insets.js +76 -0
  116. package/lib/geo/lng_lat.js +73 -0
  117. package/lib/geo/lng_lat_bounds.js +138 -0
  118. package/lib/geo/mercator.js +91 -0
  119. package/lib/geo/point.js +176 -0
  120. package/lib/geo/simple.js +87 -0
  121. package/lib/geo/transform.js +503 -0
  122. package/lib/handler/IHandler.js +17 -0
  123. package/lib/handler/blockable_map_event.js +71 -0
  124. package/lib/handler/box_zoom.js +139 -0
  125. package/lib/handler/click_zoom.js +59 -0
  126. package/lib/handler/events/event.js +38 -0
  127. package/lib/handler/events/index.js +38 -0
  128. package/lib/handler/events/map_mouse_event.js +44 -0
  129. package/lib/handler/events/map_touch_event.js +48 -0
  130. package/lib/handler/events/map_wheel_event.js +36 -0
  131. package/lib/handler/events/render_event.js +33 -0
  132. package/lib/handler/handler_inertia.js +149 -0
  133. package/lib/handler/handler_manager.js +455 -0
  134. package/lib/handler/handler_util.js +35 -0
  135. package/lib/handler/keyboard.js +131 -0
  136. package/lib/handler/map_event.js +91 -0
  137. package/lib/handler/mouse/index.js +38 -0
  138. package/lib/handler/mouse/mouse_handler.js +103 -0
  139. package/lib/handler/mouse/mousepan_handler.js +48 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +47 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +47 -0
  142. package/lib/handler/mouse/util.js +44 -0
  143. package/lib/handler/scroll_zoom.js +225 -0
  144. package/lib/handler/shim/dblclick_zoom.js +46 -0
  145. package/lib/handler/shim/drag_pan.js +55 -0
  146. package/lib/handler/shim/drag_rotate.js +49 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +71 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +102 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +106 -0
  150. package/lib/handler/tap/tap_recognizer.js +66 -0
  151. package/lib/handler/tap/tap_zoom.js +99 -0
  152. package/lib/handler/touch/index.js +41 -0
  153. package/lib/handler/touch/touch_pan.js +110 -0
  154. package/lib/handler/touch/touch_pitch.js +86 -0
  155. package/lib/handler/touch/touch_rotate.js +65 -0
  156. package/lib/handler/touch/touch_zoom.js +56 -0
  157. package/lib/handler/touch/two_touch.js +105 -0
  158. package/lib/hash.js +120 -0
  159. package/lib/index.js +21 -0
  160. package/lib/interface.js +17 -0
  161. package/lib/map.js +308 -0
  162. package/lib/util.js +97 -0
  163. package/lib/utils/Aabb.js +90 -0
  164. package/lib/utils/dom.js +159 -0
  165. package/lib/utils/performance.js +80 -0
  166. package/lib/utils/primitives.js +63 -0
  167. package/lib/utils/task_queue.js +72 -0
  168. package/package.json +3 -3
@@ -0,0 +1,278 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/earthmap.ts
23
+ var earthmap_exports = {};
24
+ __export(earthmap_exports, {
25
+ EarthMap: () => EarthMap
26
+ });
27
+ module.exports = __toCommonJS(earthmap_exports);
28
+ var import_l7_utils = require("@antv/l7-utils");
29
+ var import_lodash = require("lodash");
30
+ var import_camera = __toESM(require("./camera"));
31
+ var import_l7 = require("./css/l7.css");
32
+ var import_lng_lat = __toESM(require("./geo/lng_lat"));
33
+ var import_lng_lat_bounds = __toESM(require("./geo/lng_lat_bounds"));
34
+ var import_point = __toESM(require("./geo/point"));
35
+ var import_handler_manager = __toESM(require("./handler/handler_manager"));
36
+ var import_util = require("./util");
37
+ var import_performance = require("./utils/performance");
38
+ var import_task_queue = __toESM(require("./utils/task_queue"));
39
+ var defaultMinZoom = -2;
40
+ var defaultMaxZoom = 22;
41
+ var defaultMinPitch = 0;
42
+ var defaultMaxPitch = 60;
43
+ var DefaultOptions = {
44
+ hash: false,
45
+ zoom: -1,
46
+ center: [112, 32],
47
+ pitch: 0,
48
+ bearing: 0,
49
+ interactive: true,
50
+ minZoom: defaultMinZoom,
51
+ maxZoom: defaultMaxZoom,
52
+ minPitch: defaultMinPitch,
53
+ maxPitch: defaultMaxPitch,
54
+ scrollZoom: true,
55
+ boxZoom: true,
56
+ dragRotate: true,
57
+ dragPan: true,
58
+ keyboard: true,
59
+ doubleClickZoom: true,
60
+ touchZoomRotate: true,
61
+ touchPitch: true,
62
+ bearingSnap: 7,
63
+ clickTolerance: 3,
64
+ pitchWithRotate: true,
65
+ trackResize: true,
66
+ renderWorldCopies: true,
67
+ pitchEnabled: true,
68
+ rotateEnabled: true
69
+ };
70
+ var EarthMap = class extends import_camera.default {
71
+ constructor(options) {
72
+ super((0, import_lodash.merge)({}, DefaultOptions, options));
73
+ this.renderTaskQueue = new import_task_queue.default();
74
+ this.trackResize = true;
75
+ this.onWindowOnline = () => {
76
+ this.update();
77
+ };
78
+ this.onWindowResize = (event) => {
79
+ if (this.trackResize) {
80
+ this.resize({ originalEvent: event }).update();
81
+ }
82
+ };
83
+ this.initContainer();
84
+ this.resize();
85
+ this.handlers = new import_handler_manager.default(this, this.options);
86
+ if (typeof window !== "undefined") {
87
+ window.addEventListener("online", this.onWindowOnline, false);
88
+ window.addEventListener("resize", this.onWindowResize, false);
89
+ window.addEventListener("orientationchange", this.onWindowResize, false);
90
+ }
91
+ }
92
+ resize(eventData) {
93
+ const dimensions = this.containerDimensions();
94
+ const width = dimensions[0];
95
+ const height = dimensions[1];
96
+ this.transform.resize(width, height);
97
+ const fireMoving = !this.moving;
98
+ if (fireMoving) {
99
+ this.stop();
100
+ this.emit("movestart", new Event("movestart", eventData));
101
+ this.emit("move", new Event("move", eventData));
102
+ }
103
+ this.emit("resize", new Event("resize", eventData));
104
+ if (fireMoving) {
105
+ this.emit("moveend", new Event("moveend", eventData));
106
+ }
107
+ return this;
108
+ }
109
+ getContainer() {
110
+ return this.container;
111
+ }
112
+ getCanvas() {
113
+ return this.canvas;
114
+ }
115
+ getCanvasContainer() {
116
+ return this.canvasContainer;
117
+ }
118
+ project(lngLat) {
119
+ return this.transform.locationPoint(import_lng_lat.default.convert(lngLat));
120
+ }
121
+ unproject(point) {
122
+ return this.transform.pointLocation(import_point.default.convert(point));
123
+ }
124
+ getBounds() {
125
+ return this.transform.getBounds();
126
+ }
127
+ getMaxBounds() {
128
+ return this.transform.getMaxBounds();
129
+ }
130
+ setMaxBounds(bounds) {
131
+ this.transform.setMaxBounds(import_lng_lat_bounds.default.convert(bounds));
132
+ }
133
+ setStyle(style) {
134
+ return;
135
+ }
136
+ setMinZoom(minZoom) {
137
+ minZoom = minZoom === null || minZoom === void 0 ? defaultMinZoom : minZoom;
138
+ if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
139
+ this.transform.minZoom = minZoom;
140
+ if (this.getZoom() < minZoom) {
141
+ this.setZoom(minZoom);
142
+ }
143
+ return this;
144
+ } else {
145
+ throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
146
+ }
147
+ }
148
+ getMinZoom() {
149
+ return this.transform.minZoom;
150
+ }
151
+ setMaxZoom(maxZoom) {
152
+ maxZoom = maxZoom === null || maxZoom === void 0 ? defaultMaxZoom : maxZoom;
153
+ if (maxZoom >= this.transform.minZoom) {
154
+ this.transform.maxZoom = maxZoom;
155
+ if (this.getZoom() > maxZoom) {
156
+ this.setZoom(maxZoom);
157
+ }
158
+ return this;
159
+ } else {
160
+ throw new Error("maxZoom must be greater than the current minZoom");
161
+ }
162
+ }
163
+ getMaxZoom() {
164
+ return this.transform.maxZoom;
165
+ }
166
+ setMinPitch(minPitch) {
167
+ minPitch = minPitch === null || minPitch === void 0 ? defaultMinPitch : minPitch;
168
+ if (minPitch < defaultMinPitch) {
169
+ throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
170
+ }
171
+ if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
172
+ this.transform.minPitch = minPitch;
173
+ if (this.getPitch() < minPitch) {
174
+ this.setPitch(minPitch);
175
+ }
176
+ return this;
177
+ } else {
178
+ throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
179
+ }
180
+ }
181
+ getMinPitch() {
182
+ return this.transform.minPitch;
183
+ }
184
+ setMaxPitch(maxPitch) {
185
+ maxPitch = maxPitch === null || maxPitch === void 0 ? defaultMaxPitch : maxPitch;
186
+ if (maxPitch > defaultMaxPitch) {
187
+ throw new Error(`maxPitch must be less than or equal to ${defaultMaxPitch}`);
188
+ }
189
+ if (maxPitch >= this.transform.minPitch) {
190
+ this.transform.maxPitch = maxPitch;
191
+ if (this.getPitch() > maxPitch) {
192
+ this.setPitch(maxPitch);
193
+ }
194
+ return this;
195
+ } else {
196
+ throw new Error("maxPitch must be greater than the current minPitch");
197
+ }
198
+ }
199
+ getMaxPitch() {
200
+ return this.transform.maxPitch;
201
+ }
202
+ getRenderWorldCopies() {
203
+ return this.transform.renderWorldCopies;
204
+ }
205
+ setRenderWorldCopies(renderWorldCopies) {
206
+ this.transform.renderWorldCopies = !!renderWorldCopies;
207
+ }
208
+ remove() {
209
+ if (this.frame) {
210
+ this.frame.cancel();
211
+ this.frame = null;
212
+ }
213
+ this.renderTaskQueue.clear();
214
+ }
215
+ requestRenderFrame(cb) {
216
+ this.update();
217
+ return this.renderTaskQueue.add(cb);
218
+ }
219
+ cancelRenderFrame(id) {
220
+ return this.renderTaskQueue.remove(id);
221
+ }
222
+ triggerRepaint() {
223
+ if (!this.frame) {
224
+ this.frame = (0, import_util.renderframe)((paintStartTimeStamp) => {
225
+ import_performance.PerformanceUtils.frame(paintStartTimeStamp);
226
+ this.frame = null;
227
+ this.update(paintStartTimeStamp);
228
+ });
229
+ }
230
+ }
231
+ update(time) {
232
+ if (!this.frame) {
233
+ this.frame = (0, import_util.renderframe)((paintStartTimeStamp) => {
234
+ import_performance.PerformanceUtils.frame(paintStartTimeStamp);
235
+ this.frame = null;
236
+ this.renderTaskQueue.run(time);
237
+ });
238
+ }
239
+ }
240
+ initContainer() {
241
+ if (typeof this.options.container === "string") {
242
+ this.container = window.document.getElementById(this.options.container);
243
+ if (!this.container) {
244
+ throw new Error(`Container '${this.options.container}' not found.`);
245
+ }
246
+ } else if (this.options.container instanceof HTMLElement) {
247
+ this.container = this.options.container;
248
+ } else {
249
+ throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
250
+ }
251
+ const container = this.container;
252
+ container.classList.add("l7-map");
253
+ const canvasContainer = this.canvasContainer = import_l7_utils.DOM.create("div", "l7-canvas-container", container);
254
+ if (this.options.interactive) {
255
+ canvasContainer.classList.add("l7-interactive");
256
+ }
257
+ }
258
+ containerDimensions() {
259
+ let width = 0;
260
+ let height = 0;
261
+ if (this.container) {
262
+ width = this.container.clientWidth || 400;
263
+ height = this.container.clientHeight || 300;
264
+ }
265
+ return [width, height];
266
+ }
267
+ resizeCanvas(width, height) {
268
+ const pixelRatio = import_l7_utils.DOM.DPR || 1;
269
+ this.canvas.width = pixelRatio * width;
270
+ this.canvas.height = pixelRatio * height;
271
+ this.canvas.style.width = `${width}px`;
272
+ this.canvas.style.height = `${height}px`;
273
+ }
274
+ };
275
+ // Annotate the CommonJS export names for ESM import in node:
276
+ 0 && (module.exports = {
277
+ EarthMap
278
+ });
@@ -0,0 +1,76 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/geo/edge_insets.ts
23
+ var edge_insets_exports = {};
24
+ __export(edge_insets_exports, {
25
+ default: () => EdgeInsets
26
+ });
27
+ module.exports = __toCommonJS(edge_insets_exports);
28
+ var import_util = require("../util");
29
+ var import_point = __toESM(require("./point"));
30
+ var EdgeInsets = class {
31
+ constructor(top = 0, bottom = 0, left = 0, right = 0) {
32
+ if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
33
+ throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");
34
+ }
35
+ this.top = top;
36
+ this.bottom = bottom;
37
+ this.left = left;
38
+ this.right = right;
39
+ }
40
+ interpolate(start, target, t) {
41
+ if (target.top != null && start.top != null) {
42
+ this.top = (0, import_util.interpolate)(start.top, target.top, t);
43
+ }
44
+ if (target.bottom != null && start.bottom != null) {
45
+ this.bottom = (0, import_util.interpolate)(start.bottom, target.bottom, t);
46
+ }
47
+ if (target.left != null && start.left != null) {
48
+ this.left = (0, import_util.interpolate)(start.left, target.left, t);
49
+ }
50
+ if (target.right != null && start.right != null) {
51
+ this.right = (0, import_util.interpolate)(start.right, target.right, t);
52
+ }
53
+ return this;
54
+ }
55
+ getCenter(width, height) {
56
+ const x = (0, import_util.clamp)((this.left + width - this.right) / 2, 0, width);
57
+ const y = (0, import_util.clamp)((this.top + height - this.bottom) / 2, 0, height);
58
+ return new import_point.default(x, y);
59
+ }
60
+ equals(other) {
61
+ return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
62
+ }
63
+ clone() {
64
+ return new EdgeInsets(this.top, this.bottom, this.left, this.right);
65
+ }
66
+ toJSON() {
67
+ return {
68
+ top: this.top,
69
+ bottom: this.bottom,
70
+ left: this.left,
71
+ right: this.right
72
+ };
73
+ }
74
+ };
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {});
@@ -0,0 +1,73 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/geo/lng_lat.ts
20
+ var lng_lat_exports = {};
21
+ __export(lng_lat_exports, {
22
+ default: () => LngLat,
23
+ earthRadius: () => earthRadius
24
+ });
25
+ module.exports = __toCommonJS(lng_lat_exports);
26
+ var import_util = require("../util");
27
+ var earthRadius = 63710088e-1;
28
+ var LngLat = class {
29
+ static convert(input) {
30
+ if (input instanceof LngLat) {
31
+ return input;
32
+ }
33
+ if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
34
+ return new LngLat(Number(input[0]), Number(input[1]));
35
+ }
36
+ if (!Array.isArray(input) && typeof input === "object" && input !== null) {
37
+ const lng = "lng" in input ? input.lng : input.lon;
38
+ return new LngLat(Number(lng), Number(input.lat));
39
+ }
40
+ throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]");
41
+ }
42
+ constructor(lng, lat) {
43
+ if (isNaN(lng) || isNaN(lat)) {
44
+ throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
45
+ }
46
+ this.lng = +lng;
47
+ this.lat = +lat;
48
+ if (this.lat > 90 || this.lat < -90) {
49
+ throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
50
+ }
51
+ }
52
+ wrap() {
53
+ return new LngLat((0, import_util.wrap)(this.lng, -180, 180), this.lat);
54
+ }
55
+ toArray() {
56
+ return [this.lng, this.lat];
57
+ }
58
+ toString() {
59
+ return `LngLat(${this.lng}, ${this.lat})`;
60
+ }
61
+ distanceTo(lngLat) {
62
+ const rad = Math.PI / 180;
63
+ const lat1 = this.lat * rad;
64
+ const lat2 = lngLat.lat * rad;
65
+ const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
66
+ const maxMeters = earthRadius * Math.acos(Math.min(a, 1));
67
+ return maxMeters;
68
+ }
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ earthRadius
73
+ });
@@ -0,0 +1,138 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/geo/lng_lat_bounds.ts
23
+ var lng_lat_bounds_exports = {};
24
+ __export(lng_lat_bounds_exports, {
25
+ default: () => LngLatBounds
26
+ });
27
+ module.exports = __toCommonJS(lng_lat_bounds_exports);
28
+ var import_lng_lat = __toESM(require("./lng_lat"));
29
+ var LngLatBounds = class {
30
+ static convert(input) {
31
+ if (input instanceof LngLatBounds) {
32
+ return input;
33
+ }
34
+ return new LngLatBounds(input);
35
+ }
36
+ constructor(sw, ne) {
37
+ if (!sw) {
38
+ } else if (ne) {
39
+ this.setSouthWest(sw).setNorthEast(ne);
40
+ } else if (sw.length === 4) {
41
+ this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
42
+ } else {
43
+ this.setSouthWest(sw[0]).setNorthEast(sw[1]);
44
+ }
45
+ }
46
+ setNorthEast(ne) {
47
+ this.ne = ne instanceof import_lng_lat.default ? new import_lng_lat.default(ne.lng, ne.lat) : import_lng_lat.default.convert(ne);
48
+ return this;
49
+ }
50
+ setSouthWest(sw) {
51
+ this.sw = sw instanceof import_lng_lat.default ? new import_lng_lat.default(sw.lng, sw.lat) : import_lng_lat.default.convert(sw);
52
+ return this;
53
+ }
54
+ extend(obj) {
55
+ const sw = this.sw;
56
+ const ne = this.ne;
57
+ let sw2;
58
+ let ne2;
59
+ if (obj instanceof import_lng_lat.default) {
60
+ sw2 = obj;
61
+ ne2 = obj;
62
+ } else if (obj instanceof LngLatBounds) {
63
+ sw2 = obj.sw;
64
+ ne2 = obj.ne;
65
+ if (!sw2 || !ne2) {
66
+ return this;
67
+ }
68
+ } else {
69
+ if (Array.isArray(obj)) {
70
+ if (obj.length === 4 || obj.every(Array.isArray)) {
71
+ const lngLatBoundsObj = obj;
72
+ return this.extend(LngLatBounds.convert(lngLatBoundsObj));
73
+ } else {
74
+ const lngLatObj = obj;
75
+ return this.extend(import_lng_lat.default.convert(lngLatObj));
76
+ }
77
+ }
78
+ return this;
79
+ }
80
+ if (!sw && !ne) {
81
+ this.sw = new import_lng_lat.default(sw2.lng, sw2.lat);
82
+ this.ne = new import_lng_lat.default(ne2.lng, ne2.lat);
83
+ } else {
84
+ sw.lng = Math.min(sw2.lng, sw.lng);
85
+ sw.lat = Math.min(sw2.lat, sw.lat);
86
+ ne.lng = Math.max(ne2.lng, ne.lng);
87
+ ne.lat = Math.max(ne2.lat, ne.lat);
88
+ }
89
+ return this;
90
+ }
91
+ getCenter() {
92
+ return new import_lng_lat.default((this.sw.lng + this.ne.lng) / 2, (this.sw.lat + this.ne.lat) / 2);
93
+ }
94
+ getSouthWest() {
95
+ return this.sw;
96
+ }
97
+ getNorthEast() {
98
+ return this.ne;
99
+ }
100
+ getNorthWest() {
101
+ return new import_lng_lat.default(this.getWest(), this.getNorth());
102
+ }
103
+ getSouthEast() {
104
+ return new import_lng_lat.default(this.getEast(), this.getSouth());
105
+ }
106
+ getWest() {
107
+ return this.sw.lng;
108
+ }
109
+ getSouth() {
110
+ return this.sw.lat;
111
+ }
112
+ getEast() {
113
+ return this.ne.lng;
114
+ }
115
+ getNorth() {
116
+ return this.ne.lat;
117
+ }
118
+ toArray() {
119
+ return [this.sw.toArray(), this.ne.toArray()];
120
+ }
121
+ toString() {
122
+ return `LngLatBounds(${this.sw.toString()}, ${this.ne.toString()})`;
123
+ }
124
+ isEmpty() {
125
+ return !(this.sw && this.ne);
126
+ }
127
+ contains(lnglat) {
128
+ const { lng, lat } = import_lng_lat.default.convert(lnglat);
129
+ const containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
130
+ let containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
131
+ if (this.sw.lng > this.ne.lng) {
132
+ containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
133
+ }
134
+ return containsLatitude && containsLongitude;
135
+ }
136
+ };
137
+ // Annotate the CommonJS export names for ESM import in node:
138
+ 0 && (module.exports = {});
@@ -0,0 +1,91 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/geo/mercator.ts
23
+ var mercator_exports = {};
24
+ __export(mercator_exports, {
25
+ altitudeFromMercatorZ: () => altitudeFromMercatorZ,
26
+ default: () => MercatorCoordinate,
27
+ latFromMercatorY: () => latFromMercatorY,
28
+ lngFromMercatorX: () => lngFromMercatorX,
29
+ mercatorScale: () => mercatorScale,
30
+ mercatorXfromLng: () => mercatorXfromLng,
31
+ mercatorYfromLat: () => mercatorYfromLat,
32
+ mercatorZfromAltitude: () => mercatorZfromAltitude
33
+ });
34
+ module.exports = __toCommonJS(mercator_exports);
35
+ var import_lng_lat = __toESM(require("../geo/lng_lat"));
36
+ var earthCircumfrence = 2 * Math.PI * import_lng_lat.earthRadius;
37
+ function circumferenceAtLatitude(latitude) {
38
+ return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
39
+ }
40
+ function mercatorXfromLng(lng) {
41
+ return (180 + lng) / 360;
42
+ }
43
+ function mercatorYfromLat(lat) {
44
+ return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
45
+ }
46
+ function mercatorZfromAltitude(altitude, lat) {
47
+ return altitude / circumferenceAtLatitude(lat);
48
+ }
49
+ function lngFromMercatorX(x) {
50
+ return x * 360 - 180;
51
+ }
52
+ function latFromMercatorY(y) {
53
+ const y2 = 180 - y * 360;
54
+ return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
55
+ }
56
+ function altitudeFromMercatorZ(z, y) {
57
+ return z * circumferenceAtLatitude(latFromMercatorY(y));
58
+ }
59
+ function mercatorScale(lat) {
60
+ return 1 / Math.cos(lat * Math.PI / 180);
61
+ }
62
+ var MercatorCoordinate = class {
63
+ static fromLngLat(lngLatLike, altitude = 0) {
64
+ const lngLat = import_lng_lat.default.convert(lngLatLike);
65
+ return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
66
+ }
67
+ constructor(x, y, z = 0) {
68
+ this.x = +x;
69
+ this.y = +y;
70
+ this.z = +z;
71
+ }
72
+ toLngLat() {
73
+ return new import_lng_lat.default(lngFromMercatorX(this.x), latFromMercatorY(this.y));
74
+ }
75
+ toAltitude() {
76
+ return altitudeFromMercatorZ(this.z, this.y);
77
+ }
78
+ meterInMercatorCoordinateUnits() {
79
+ return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));
80
+ }
81
+ };
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ altitudeFromMercatorZ,
85
+ latFromMercatorY,
86
+ lngFromMercatorX,
87
+ mercatorScale,
88
+ mercatorXfromLng,
89
+ mercatorYfromLat,
90
+ mercatorZfromAltitude
91
+ });