@antv/l7-map 2.5.36 → 2.5.37-mini4
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.
- package/lib/camera.js.map +1 -1
- package/lib/earthmap.js +7 -26
- package/lib/earthmap.js.map +1 -1
- package/lib/handler/handler_manager.js +55 -33
- package/lib/handler/handler_manager.js.map +1 -1
- package/lib/handler/shim/drag_pan.js +10 -2
- package/lib/handler/shim/drag_pan.js.map +1 -1
- package/lib/handler/shim/touch_zoom_rotate.js +10 -2
- package/lib/handler/shim/touch_zoom_rotate.js.map +1 -1
- package/lib/hash.js +9 -4
- package/lib/hash.js.map +1 -1
- package/lib/map.js +39 -19
- package/lib/map.js.map +1 -1
- package/lib/util.js +7 -5
- package/lib/util.js.map +1 -1
- package/lib/utils/dom.js +66 -26
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/performance.js +4 -1
- package/lib/utils/performance.js.map +1 -1
- package/package.json +3 -3
- package/LICENSE.md +0 -21
- package/es/camera.d.ts +0 -82
- package/es/camera.js +0 -729
- package/es/camera.js.map +0 -1
- package/es/earthmap.d.ts +0 -67
- package/es/earthmap.js +0 -454
- package/es/earthmap.js.map +0 -1
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/edge_insets.js +0 -88
- package/es/geo/edge_insets.js.map +0 -1
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -77
- package/es/geo/lng_lat.js.map +0 -1
- package/es/geo/lng_lat_bounds.d.ts +0 -24
- package/es/geo/lng_lat_bounds.js +0 -170
- package/es/geo/lng_lat_bounds.js.map +0 -1
- package/es/geo/mercator.d.ts +0 -28
- package/es/geo/mercator.js +0 -79
- package/es/geo/mercator.js.map +0 -1
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -237
- package/es/geo/point.js.map +0 -1
- package/es/geo/simple.d.ts +0 -28
- package/es/geo/simple.js +0 -78
- package/es/geo/simple.js.map +0 -1
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -663
- package/es/geo/transform.js.map +0 -1
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -2
- package/es/handler/IHandler.js.map +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -84
- package/es/handler/blockable_map_event.js.map +0 -1
- package/es/handler/box_zoom.d.ts +0 -59
- package/es/handler/box_zoom.js +0 -184
- package/es/handler/box_zoom.js.map +0 -1
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -64
- package/es/handler/click_zoom.js.map +0 -1
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -14
- package/es/handler/events/event.js.map +0 -1
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -5
- package/es/handler/events/index.js.map +0 -1
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -65
- package/es/handler/events/map_mouse_event.js.map +0 -1
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -75
- package/es/handler/events/map_touch_event.js.map +0 -1
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -52
- package/es/handler/events/map_wheel_event.js.map +0 -1
- package/es/handler/events/render_event.d.ts +0 -5
- package/es/handler/events/render_event.js +0 -41
- package/es/handler/events/render_event.js.map +0 -1
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_inertia.js +0 -186
- package/es/handler/handler_inertia.js.map +0 -1
- package/es/handler/handler_manager.d.ts +0 -57
- package/es/handler/handler_manager.js +0 -655
- package/es/handler/handler_manager.js.map +0 -1
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/handler_util.js +0 -10
- package/es/handler/handler_util.js.map +0 -1
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -157
- package/es/handler/keyboard.js.map +0 -1
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -120
- package/es/handler/map_event.js.map +0 -1
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -5
- package/es/handler/mouse/index.js.map +0 -1
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -131
- package/es/handler/mouse/mouse_handler.js.map +0 -1
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -54
- package/es/handler/mouse/mousepan_handler.js.map +0 -1
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -54
- package/es/handler/mouse/mousepitch_hander.js.map +0 -1
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -54
- package/es/handler/mouse/mouserotate_hander.js.map +0 -1
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -12
- package/es/handler/mouse/util.js.map +0 -1
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -317
- package/es/handler/scroll_zoom.js.map +0 -1
- package/es/handler/shim/dblclick_zoom.d.ts +0 -40
- package/es/handler/shim/dblclick_zoom.js +0 -45
- package/es/handler/shim/dblclick_zoom.js.map +0 -1
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -53
- package/es/handler/shim/drag_pan.js.map +0 -1
- package/es/handler/shim/drag_rotate.d.ts +0 -46
- package/es/handler/shim/drag_rotate.js +0 -51
- package/es/handler/shim/drag_rotate.js.map +0 -1
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -80
- package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -127
- package/es/handler/tap/single_tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -124
- package/es/handler/tap/tap_drag_zoom.js.map +0 -1
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -72
- package/es/handler/tap/tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -124
- package/es/handler/tap/tap_zoom.js.map +0 -1
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -6
- package/es/handler/touch/index.js.map +0 -1
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -139
- package/es/handler/touch/touch_pan.js.map +0 -1
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -120
- package/es/handler/touch/touch_pitch.js.map +0 -1
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -88
- package/es/handler/touch/touch_rotate.js.map +0 -1
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -79
- package/es/handler/touch/touch_zoom.js.map +0 -1
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -140
- package/es/handler/touch/two_touch.js.map +0 -1
- package/es/hash.d.ts +0 -15
- package/es/hash.js +0 -143
- package/es/hash.js.map +0 -1
- package/es/index.d.ts +0 -2
- package/es/index.js +0 -3
- package/es/index.js.map +0 -1
- package/es/interface.d.ts +0 -31
- package/es/interface.js +0 -2
- package/es/interface.js.map +0 -1
- package/es/map.d.ts +0 -67
- package/es/map.js +0 -454
- package/es/map.js.map +0 -1
- package/es/util.d.ts +0 -18
- package/es/util.js +0 -74
- package/es/util.js.map +0 -1
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -134
- package/es/utils/Aabb.js.map +0 -1
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -165
- package/es/utils/dom.js.map +0 -1
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -57
- package/es/utils/performance.js.map +0 -1
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -44
- package/es/utils/primitives.js.map +0 -1
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -113
- package/es/utils/task_queue.js.map +0 -1
package/es/geo/transform.js
DELETED
|
@@ -1,663 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
|
-
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
-
|
|
11
|
-
import { mat2, mat4, vec3, vec4 } from 'gl-matrix';
|
|
12
|
-
import Point from '../geo/point';
|
|
13
|
-
import { clamp, interpolate, wrap } from '../util';
|
|
14
|
-
import EdgeInsets from './edge_insets';
|
|
15
|
-
import LngLat from './lng_lat';
|
|
16
|
-
import LngLatBounds from './lng_lat_bounds';
|
|
17
|
-
import MercatorCoordinate, { mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude } from './mercator';
|
|
18
|
-
export var EXTENT = 8192;
|
|
19
|
-
|
|
20
|
-
var Transform = function () {
|
|
21
|
-
function Transform(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies) {
|
|
22
|
-
_classCallCheck(this, Transform);
|
|
23
|
-
|
|
24
|
-
_defineProperty(this, "tileSize", void 0);
|
|
25
|
-
|
|
26
|
-
_defineProperty(this, "tileZoom", void 0);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "lngRange", void 0);
|
|
29
|
-
|
|
30
|
-
_defineProperty(this, "latRange", void 0);
|
|
31
|
-
|
|
32
|
-
_defineProperty(this, "maxValidLatitude", void 0);
|
|
33
|
-
|
|
34
|
-
_defineProperty(this, "scale", void 0);
|
|
35
|
-
|
|
36
|
-
_defineProperty(this, "width", void 0);
|
|
37
|
-
|
|
38
|
-
_defineProperty(this, "height", void 0);
|
|
39
|
-
|
|
40
|
-
_defineProperty(this, "angle", void 0);
|
|
41
|
-
|
|
42
|
-
_defineProperty(this, "rotationMatrix", void 0);
|
|
43
|
-
|
|
44
|
-
_defineProperty(this, "pixelsToGLUnits", void 0);
|
|
45
|
-
|
|
46
|
-
_defineProperty(this, "cameraToCenterDistance", void 0);
|
|
47
|
-
|
|
48
|
-
_defineProperty(this, "mercatorMatrix", void 0);
|
|
49
|
-
|
|
50
|
-
_defineProperty(this, "projMatrix", void 0);
|
|
51
|
-
|
|
52
|
-
_defineProperty(this, "invProjMatrix", void 0);
|
|
53
|
-
|
|
54
|
-
_defineProperty(this, "alignedProjMatrix", void 0);
|
|
55
|
-
|
|
56
|
-
_defineProperty(this, "pixelMatrix", void 0);
|
|
57
|
-
|
|
58
|
-
_defineProperty(this, "pixelMatrixInverse", void 0);
|
|
59
|
-
|
|
60
|
-
_defineProperty(this, "glCoordMatrix", void 0);
|
|
61
|
-
|
|
62
|
-
_defineProperty(this, "labelPlaneMatrix", void 0);
|
|
63
|
-
|
|
64
|
-
_defineProperty(this, "_fov", void 0);
|
|
65
|
-
|
|
66
|
-
_defineProperty(this, "_pitch", void 0);
|
|
67
|
-
|
|
68
|
-
_defineProperty(this, "_zoom", void 0);
|
|
69
|
-
|
|
70
|
-
_defineProperty(this, "_renderWorldCopies", void 0);
|
|
71
|
-
|
|
72
|
-
_defineProperty(this, "_minZoom", void 0);
|
|
73
|
-
|
|
74
|
-
_defineProperty(this, "_maxZoom", void 0);
|
|
75
|
-
|
|
76
|
-
_defineProperty(this, "_minPitch", void 0);
|
|
77
|
-
|
|
78
|
-
_defineProperty(this, "_maxPitch", void 0);
|
|
79
|
-
|
|
80
|
-
_defineProperty(this, "_center", void 0);
|
|
81
|
-
|
|
82
|
-
_defineProperty(this, "zoomFraction", void 0);
|
|
83
|
-
|
|
84
|
-
_defineProperty(this, "unmodified", void 0);
|
|
85
|
-
|
|
86
|
-
_defineProperty(this, "edgeInsets", void 0);
|
|
87
|
-
|
|
88
|
-
_defineProperty(this, "constraining", void 0);
|
|
89
|
-
|
|
90
|
-
_defineProperty(this, "posMatrixCache", void 0);
|
|
91
|
-
|
|
92
|
-
_defineProperty(this, "alignedPosMatrixCache", void 0);
|
|
93
|
-
|
|
94
|
-
this.tileSize = 512;
|
|
95
|
-
this.maxValidLatitude = 85.051129;
|
|
96
|
-
this._renderWorldCopies = renderWorldCopies === undefined ? true : renderWorldCopies;
|
|
97
|
-
this._minZoom = minZoom || 0;
|
|
98
|
-
this._maxZoom = maxZoom || 22;
|
|
99
|
-
this._minPitch = minPitch === undefined || minPitch === null ? 0 : minPitch;
|
|
100
|
-
this._maxPitch = maxPitch === undefined || maxPitch === null ? 60 : maxPitch;
|
|
101
|
-
this.setMaxBounds();
|
|
102
|
-
this.width = 0;
|
|
103
|
-
this.height = 0;
|
|
104
|
-
this._center = new LngLat(0, 0);
|
|
105
|
-
this.zoom = 0;
|
|
106
|
-
this.angle = 0;
|
|
107
|
-
this._fov = 0.6435011087932844;
|
|
108
|
-
this._pitch = 0;
|
|
109
|
-
this.unmodified = true;
|
|
110
|
-
this.edgeInsets = new EdgeInsets();
|
|
111
|
-
this.posMatrixCache = {};
|
|
112
|
-
this.alignedPosMatrixCache = {};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_createClass(Transform, [{
|
|
116
|
-
key: "minZoom",
|
|
117
|
-
get: function get() {
|
|
118
|
-
return this._minZoom;
|
|
119
|
-
},
|
|
120
|
-
set: function set(zoom) {
|
|
121
|
-
if (this._minZoom === zoom) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
this._minZoom = zoom;
|
|
126
|
-
this.zoom = Math.max(this.zoom, zoom);
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "maxZoom",
|
|
130
|
-
get: function get() {
|
|
131
|
-
return this._maxZoom;
|
|
132
|
-
},
|
|
133
|
-
set: function set(zoom) {
|
|
134
|
-
if (this._maxZoom === zoom) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this._maxZoom = zoom;
|
|
139
|
-
this.zoom = Math.min(this.zoom, zoom);
|
|
140
|
-
}
|
|
141
|
-
}, {
|
|
142
|
-
key: "minPitch",
|
|
143
|
-
get: function get() {
|
|
144
|
-
return this._minPitch;
|
|
145
|
-
},
|
|
146
|
-
set: function set(pitch) {
|
|
147
|
-
if (this._minPitch === pitch) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
this._minPitch = pitch;
|
|
152
|
-
this._pitch = Math.max(this._pitch, pitch);
|
|
153
|
-
}
|
|
154
|
-
}, {
|
|
155
|
-
key: "maxPitch",
|
|
156
|
-
get: function get() {
|
|
157
|
-
return this._maxPitch;
|
|
158
|
-
},
|
|
159
|
-
set: function set(pitch) {
|
|
160
|
-
if (this._maxPitch === pitch) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
this._maxPitch = pitch;
|
|
165
|
-
this._pitch = Math.min(this._pitch, pitch);
|
|
166
|
-
}
|
|
167
|
-
}, {
|
|
168
|
-
key: "renderWorldCopies",
|
|
169
|
-
get: function get() {
|
|
170
|
-
return this._renderWorldCopies;
|
|
171
|
-
},
|
|
172
|
-
set: function set(renderWorldCopies) {
|
|
173
|
-
if (renderWorldCopies === undefined) {
|
|
174
|
-
renderWorldCopies = true;
|
|
175
|
-
} else if (renderWorldCopies === null) {
|
|
176
|
-
renderWorldCopies = false;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
this._renderWorldCopies = renderWorldCopies;
|
|
180
|
-
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "worldSize",
|
|
183
|
-
get: function get() {
|
|
184
|
-
return this.tileSize * this.scale;
|
|
185
|
-
}
|
|
186
|
-
}, {
|
|
187
|
-
key: "centerOffset",
|
|
188
|
-
get: function get() {
|
|
189
|
-
return this.centerPoint._sub(this.size._div(2));
|
|
190
|
-
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "size",
|
|
193
|
-
get: function get() {
|
|
194
|
-
return new Point(this.width, this.height);
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "bearing",
|
|
198
|
-
get: function get() {
|
|
199
|
-
return -this.angle / Math.PI * 180;
|
|
200
|
-
},
|
|
201
|
-
set: function set(bearing) {
|
|
202
|
-
var b = -wrap(bearing, -180, 180) * Math.PI / 180;
|
|
203
|
-
|
|
204
|
-
if (this.angle === b) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
this.unmodified = false;
|
|
209
|
-
this.angle = b;
|
|
210
|
-
this.calcMatrices();
|
|
211
|
-
this.rotationMatrix = mat2.create();
|
|
212
|
-
mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "pitch",
|
|
216
|
-
get: function get() {
|
|
217
|
-
return this._pitch / Math.PI * 180;
|
|
218
|
-
},
|
|
219
|
-
set: function set(pitch) {
|
|
220
|
-
var p = clamp(pitch, this._minPitch, this._maxPitch) / 180 * Math.PI;
|
|
221
|
-
|
|
222
|
-
if (this._pitch === p) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this.unmodified = false;
|
|
227
|
-
this._pitch = p;
|
|
228
|
-
this.calcMatrices();
|
|
229
|
-
}
|
|
230
|
-
}, {
|
|
231
|
-
key: "fov",
|
|
232
|
-
get: function get() {
|
|
233
|
-
return this._fov / Math.PI * 180;
|
|
234
|
-
},
|
|
235
|
-
set: function set(fov) {
|
|
236
|
-
fov = Math.max(0.01, Math.min(60, fov));
|
|
237
|
-
|
|
238
|
-
if (this._fov === fov) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
this.unmodified = false;
|
|
243
|
-
this._fov = fov / 180 * Math.PI;
|
|
244
|
-
this.calcMatrices();
|
|
245
|
-
}
|
|
246
|
-
}, {
|
|
247
|
-
key: "zoom",
|
|
248
|
-
get: function get() {
|
|
249
|
-
return this._zoom;
|
|
250
|
-
},
|
|
251
|
-
set: function set(zoom) {
|
|
252
|
-
var z = Math.min(Math.max(zoom, this._minZoom), this._maxZoom);
|
|
253
|
-
|
|
254
|
-
if (this._zoom === z) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
this.unmodified = false;
|
|
259
|
-
this._zoom = z;
|
|
260
|
-
this.scale = this.zoomScale(z);
|
|
261
|
-
this.tileZoom = Math.floor(z);
|
|
262
|
-
this.zoomFraction = z - this.tileZoom;
|
|
263
|
-
this.constrain();
|
|
264
|
-
this.calcMatrices();
|
|
265
|
-
}
|
|
266
|
-
}, {
|
|
267
|
-
key: "center",
|
|
268
|
-
get: function get() {
|
|
269
|
-
return this._center;
|
|
270
|
-
},
|
|
271
|
-
set: function set(center) {
|
|
272
|
-
if (center.lat === this._center.lat && center.lng === this._center.lng) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
this.unmodified = false;
|
|
277
|
-
this._center = center;
|
|
278
|
-
this.constrain();
|
|
279
|
-
this.calcMatrices();
|
|
280
|
-
}
|
|
281
|
-
}, {
|
|
282
|
-
key: "padding",
|
|
283
|
-
get: function get() {
|
|
284
|
-
return this.edgeInsets.toJSON();
|
|
285
|
-
},
|
|
286
|
-
set: function set(padding) {
|
|
287
|
-
if (this.edgeInsets.equals(padding)) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
this.unmodified = false;
|
|
292
|
-
this.edgeInsets.interpolate(this.edgeInsets, padding, 1);
|
|
293
|
-
this.calcMatrices();
|
|
294
|
-
}
|
|
295
|
-
}, {
|
|
296
|
-
key: "centerPoint",
|
|
297
|
-
get: function get() {
|
|
298
|
-
return this.edgeInsets.getCenter(this.width, this.height);
|
|
299
|
-
}
|
|
300
|
-
}, {
|
|
301
|
-
key: "point",
|
|
302
|
-
get: function get() {
|
|
303
|
-
return this.project(this.center);
|
|
304
|
-
}
|
|
305
|
-
}, {
|
|
306
|
-
key: "clone",
|
|
307
|
-
value: function clone() {
|
|
308
|
-
var clone = new Transform(this._minZoom, this._maxZoom, this._minPitch, this._maxPitch, this._renderWorldCopies);
|
|
309
|
-
clone.tileSize = this.tileSize;
|
|
310
|
-
clone.latRange = this.latRange;
|
|
311
|
-
clone.width = this.width;
|
|
312
|
-
clone.height = this.height;
|
|
313
|
-
clone.center = this._center;
|
|
314
|
-
clone.zoom = this.zoom;
|
|
315
|
-
clone.angle = this.angle;
|
|
316
|
-
clone.fov = this._fov;
|
|
317
|
-
clone.pitch = this._pitch;
|
|
318
|
-
clone.unmodified = this.unmodified;
|
|
319
|
-
clone.edgeInsets = this.edgeInsets.clone();
|
|
320
|
-
clone.calcMatrices();
|
|
321
|
-
return clone;
|
|
322
|
-
}
|
|
323
|
-
}, {
|
|
324
|
-
key: "isPaddingEqual",
|
|
325
|
-
value: function isPaddingEqual(padding) {
|
|
326
|
-
return this.edgeInsets.equals(padding);
|
|
327
|
-
}
|
|
328
|
-
}, {
|
|
329
|
-
key: "interpolatePadding",
|
|
330
|
-
value: function interpolatePadding(start, target, t) {
|
|
331
|
-
this.unmodified = false;
|
|
332
|
-
this.edgeInsets.interpolate(start, target, t);
|
|
333
|
-
this.constrain();
|
|
334
|
-
this.calcMatrices();
|
|
335
|
-
}
|
|
336
|
-
}, {
|
|
337
|
-
key: "coveringZoomLevel",
|
|
338
|
-
value: function coveringZoomLevel(options) {
|
|
339
|
-
var z = (options.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / options.tileSize));
|
|
340
|
-
return Math.max(0, z);
|
|
341
|
-
}
|
|
342
|
-
}, {
|
|
343
|
-
key: "resize",
|
|
344
|
-
value: function resize(width, height) {
|
|
345
|
-
this.width = width;
|
|
346
|
-
this.height = height;
|
|
347
|
-
this.pixelsToGLUnits = [2 / width, -2 / height];
|
|
348
|
-
this.constrain();
|
|
349
|
-
this.calcMatrices();
|
|
350
|
-
}
|
|
351
|
-
}, {
|
|
352
|
-
key: "zoomScale",
|
|
353
|
-
value: function zoomScale(zoom) {
|
|
354
|
-
return Math.pow(2, zoom);
|
|
355
|
-
}
|
|
356
|
-
}, {
|
|
357
|
-
key: "scaleZoom",
|
|
358
|
-
value: function scaleZoom(scale) {
|
|
359
|
-
return Math.log(scale) / Math.LN2;
|
|
360
|
-
}
|
|
361
|
-
}, {
|
|
362
|
-
key: "project",
|
|
363
|
-
value: function project(lnglat) {
|
|
364
|
-
var lat = clamp(lnglat.lat, -this.maxValidLatitude, this.maxValidLatitude);
|
|
365
|
-
return new Point(mercatorXfromLng(lnglat.lng) * this.worldSize, mercatorYfromLat(lat) * this.worldSize);
|
|
366
|
-
}
|
|
367
|
-
}, {
|
|
368
|
-
key: "unproject",
|
|
369
|
-
value: function unproject(point) {
|
|
370
|
-
return new MercatorCoordinate(point.x / this.worldSize, point.y / this.worldSize).toLngLat();
|
|
371
|
-
}
|
|
372
|
-
}, {
|
|
373
|
-
key: "setLocationAtPoint",
|
|
374
|
-
value: function setLocationAtPoint(lnglat, point) {
|
|
375
|
-
var a = this.pointCoordinate(point);
|
|
376
|
-
var b = this.pointCoordinate(this.centerPoint);
|
|
377
|
-
var loc = this.locationCoordinate(lnglat);
|
|
378
|
-
var newCenter = new MercatorCoordinate(loc.x - (a.x - b.x), loc.y - (a.y - b.y));
|
|
379
|
-
this.center = this.coordinateLocation(newCenter);
|
|
380
|
-
|
|
381
|
-
if (this._renderWorldCopies) {
|
|
382
|
-
this.center = this.center.wrap();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}, {
|
|
386
|
-
key: "pointCoordinate",
|
|
387
|
-
value: function pointCoordinate(p) {
|
|
388
|
-
var targetZ = 0;
|
|
389
|
-
var coord0 = new Float32Array([p.x, p.y, 0, 1]);
|
|
390
|
-
var coord1 = new Float32Array([p.x, p.y, 1, 1]);
|
|
391
|
-
vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);
|
|
392
|
-
vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);
|
|
393
|
-
var w0 = coord0[3];
|
|
394
|
-
var w1 = coord1[3];
|
|
395
|
-
var x0 = coord0[0] / w0;
|
|
396
|
-
var x1 = coord1[0] / w1;
|
|
397
|
-
var y0 = coord0[1] / w0;
|
|
398
|
-
var y1 = coord1[1] / w1;
|
|
399
|
-
var z0 = coord0[2] / w0;
|
|
400
|
-
var z1 = coord1[2] / w1;
|
|
401
|
-
var t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);
|
|
402
|
-
return new MercatorCoordinate(interpolate(x0, x1, t) / this.worldSize, interpolate(y0, y1, t) / this.worldSize);
|
|
403
|
-
}
|
|
404
|
-
}, {
|
|
405
|
-
key: "getBounds",
|
|
406
|
-
value: function getBounds() {
|
|
407
|
-
return new LngLatBounds().extend(this.pointLocation(new Point(0, 0))).extend(this.pointLocation(new Point(this.width, 0))).extend(this.pointLocation(new Point(this.width, this.height))).extend(this.pointLocation(new Point(0, this.height)));
|
|
408
|
-
}
|
|
409
|
-
}, {
|
|
410
|
-
key: "getMaxBounds",
|
|
411
|
-
value: function getMaxBounds() {
|
|
412
|
-
if (!this.latRange || this.latRange.length !== 2 || !this.lngRange || this.lngRange.length !== 2) {
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return new LngLatBounds([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]);
|
|
417
|
-
}
|
|
418
|
-
}, {
|
|
419
|
-
key: "setMaxBounds",
|
|
420
|
-
value: function setMaxBounds(bounds) {
|
|
421
|
-
if (bounds) {
|
|
422
|
-
this.lngRange = [bounds.getWest(), bounds.getEast()];
|
|
423
|
-
this.latRange = [bounds.getSouth(), bounds.getNorth()];
|
|
424
|
-
this.constrain();
|
|
425
|
-
} else {
|
|
426
|
-
this.lngRange = undefined;
|
|
427
|
-
this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}, {
|
|
431
|
-
key: "customLayerMatrix",
|
|
432
|
-
value: function customLayerMatrix() {
|
|
433
|
-
return this.mercatorMatrix.slice();
|
|
434
|
-
}
|
|
435
|
-
}, {
|
|
436
|
-
key: "maxPitchScaleFactor",
|
|
437
|
-
value: function maxPitchScaleFactor() {
|
|
438
|
-
if (!this.pixelMatrixInverse) {
|
|
439
|
-
return 1;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
var coord = this.pointCoordinate(new Point(0, 0));
|
|
443
|
-
var p = new Float32Array([coord.x * this.worldSize, coord.y * this.worldSize, 0, 1]);
|
|
444
|
-
var topPoint = vec4.transformMat4(p, p, this.pixelMatrix);
|
|
445
|
-
return topPoint[3] / this.cameraToCenterDistance;
|
|
446
|
-
}
|
|
447
|
-
}, {
|
|
448
|
-
key: "getCameraPoint",
|
|
449
|
-
value: function getCameraPoint() {
|
|
450
|
-
var pitch = this._pitch;
|
|
451
|
-
var yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);
|
|
452
|
-
return this.centerPoint.add(new Point(0, yOffset));
|
|
453
|
-
}
|
|
454
|
-
}, {
|
|
455
|
-
key: "getCameraQueryGeometry",
|
|
456
|
-
value: function getCameraQueryGeometry(queryGeometry) {
|
|
457
|
-
var c = this.getCameraPoint();
|
|
458
|
-
|
|
459
|
-
if (queryGeometry.length === 1) {
|
|
460
|
-
return [queryGeometry[0], c];
|
|
461
|
-
} else {
|
|
462
|
-
var minX = c.x;
|
|
463
|
-
var minY = c.y;
|
|
464
|
-
var maxX = c.x;
|
|
465
|
-
var maxY = c.y;
|
|
466
|
-
|
|
467
|
-
var _iterator = _createForOfIteratorHelper(queryGeometry),
|
|
468
|
-
_step;
|
|
469
|
-
|
|
470
|
-
try {
|
|
471
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
472
|
-
var p = _step.value;
|
|
473
|
-
minX = Math.min(minX, p.x);
|
|
474
|
-
minY = Math.min(minY, p.y);
|
|
475
|
-
maxX = Math.max(maxX, p.x);
|
|
476
|
-
maxY = Math.max(maxY, p.y);
|
|
477
|
-
}
|
|
478
|
-
} catch (err) {
|
|
479
|
-
_iterator.e(err);
|
|
480
|
-
} finally {
|
|
481
|
-
_iterator.f();
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return [new Point(minX, minY), new Point(maxX, minY), new Point(maxX, maxY), new Point(minX, maxY), new Point(minX, minY)];
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}, {
|
|
488
|
-
key: "coordinatePoint",
|
|
489
|
-
value: function coordinatePoint(coord) {
|
|
490
|
-
var p = vec4.fromValues(coord.x * this.worldSize, coord.y * this.worldSize, 0, 1);
|
|
491
|
-
vec4.transformMat4(p, p, this.pixelMatrix);
|
|
492
|
-
return new Point(p[0] / p[3], p[1] / p[3]);
|
|
493
|
-
}
|
|
494
|
-
}, {
|
|
495
|
-
key: "locationPoint",
|
|
496
|
-
value: function locationPoint(lnglat) {
|
|
497
|
-
return this.coordinatePoint(this.locationCoordinate(lnglat));
|
|
498
|
-
}
|
|
499
|
-
}, {
|
|
500
|
-
key: "pointLocation",
|
|
501
|
-
value: function pointLocation(p) {
|
|
502
|
-
return this.coordinateLocation(this.pointCoordinate(p));
|
|
503
|
-
}
|
|
504
|
-
}, {
|
|
505
|
-
key: "locationCoordinate",
|
|
506
|
-
value: function locationCoordinate(lnglat) {
|
|
507
|
-
return MercatorCoordinate.fromLngLat(lnglat);
|
|
508
|
-
}
|
|
509
|
-
}, {
|
|
510
|
-
key: "coordinateLocation",
|
|
511
|
-
value: function coordinateLocation(coord) {
|
|
512
|
-
return coord.toLngLat();
|
|
513
|
-
}
|
|
514
|
-
}, {
|
|
515
|
-
key: "getProjectionMatrix",
|
|
516
|
-
value: function getProjectionMatrix() {
|
|
517
|
-
return this.projMatrix;
|
|
518
|
-
}
|
|
519
|
-
}, {
|
|
520
|
-
key: "constrain",
|
|
521
|
-
value: function constrain() {
|
|
522
|
-
if (!this.center || !this.width || !this.height || this.constraining) {
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
this.constraining = true;
|
|
527
|
-
var minY = -90;
|
|
528
|
-
var maxY = 90;
|
|
529
|
-
var minX = -180;
|
|
530
|
-
var maxX = 180;
|
|
531
|
-
var sy;
|
|
532
|
-
var sx;
|
|
533
|
-
var x2;
|
|
534
|
-
var y2;
|
|
535
|
-
var size = this.size;
|
|
536
|
-
var unmodified = this.unmodified;
|
|
537
|
-
|
|
538
|
-
if (this.latRange) {
|
|
539
|
-
var latRange = this.latRange;
|
|
540
|
-
minY = mercatorYfromLat(latRange[1]) * this.worldSize;
|
|
541
|
-
maxY = mercatorYfromLat(latRange[0]) * this.worldSize;
|
|
542
|
-
sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (this.lngRange) {
|
|
546
|
-
var lngRange = this.lngRange;
|
|
547
|
-
minX = mercatorXfromLng(lngRange[0]) * this.worldSize;
|
|
548
|
-
maxX = mercatorXfromLng(lngRange[1]) * this.worldSize;
|
|
549
|
-
sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
var point = this.point;
|
|
553
|
-
var s = Math.max(sx || 0, sy || 0);
|
|
554
|
-
|
|
555
|
-
if (s) {
|
|
556
|
-
this.center = this.unproject(new Point(sx ? (maxX + minX) / 2 : point.x, sy ? (maxY + minY) / 2 : point.y));
|
|
557
|
-
this.zoom += this.scaleZoom(s);
|
|
558
|
-
this.unmodified = unmodified;
|
|
559
|
-
this.constraining = false;
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
if (this.latRange) {
|
|
564
|
-
var y = point.y;
|
|
565
|
-
var h2 = size.y / 2;
|
|
566
|
-
|
|
567
|
-
if (y - h2 < minY) {
|
|
568
|
-
y2 = minY + h2;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
if (y + h2 > maxY) {
|
|
572
|
-
y2 = maxY - h2;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
if (this.lngRange) {
|
|
577
|
-
var x = point.x;
|
|
578
|
-
var w2 = size.x / 2;
|
|
579
|
-
|
|
580
|
-
if (x - w2 < minX) {
|
|
581
|
-
x2 = minX + w2;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
if (x + w2 > maxX) {
|
|
585
|
-
x2 = maxX - w2;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
if (x2 !== undefined || y2 !== undefined) {
|
|
590
|
-
this.center = this.unproject(new Point(x2 !== undefined ? x2 : point.x, y2 !== undefined ? y2 : point.y));
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
this.unmodified = unmodified;
|
|
594
|
-
this.constraining = false;
|
|
595
|
-
}
|
|
596
|
-
}, {
|
|
597
|
-
key: "calcMatrices",
|
|
598
|
-
value: function calcMatrices() {
|
|
599
|
-
if (!this.height) {
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
var halfFov = this._fov / 2;
|
|
604
|
-
var offset = this.centerOffset;
|
|
605
|
-
this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;
|
|
606
|
-
var groundAngle = Math.PI / 2 + this._pitch;
|
|
607
|
-
var fovAboveCenter = this._fov * (0.5 + offset.y / this.height);
|
|
608
|
-
var topHalfSurfaceDistance = Math.sin(fovAboveCenter) * this.cameraToCenterDistance / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));
|
|
609
|
-
var point = this.point;
|
|
610
|
-
var x = point.x;
|
|
611
|
-
var y = point.y;
|
|
612
|
-
var furthestDistance = Math.cos(Math.PI / 2 - this._pitch) * topHalfSurfaceDistance + this.cameraToCenterDistance;
|
|
613
|
-
var farZ = furthestDistance * 1.01;
|
|
614
|
-
var nearZ = this.height / 50;
|
|
615
|
-
var m = mat4.create();
|
|
616
|
-
mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);
|
|
617
|
-
m[8] = -offset.x * 2 / this.width;
|
|
618
|
-
m[9] = offset.y * 2 / this.height;
|
|
619
|
-
mat4.scale(m, m, [1, -1, 1]);
|
|
620
|
-
mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);
|
|
621
|
-
mat4.rotateX(m, m, this._pitch);
|
|
622
|
-
mat4.rotateZ(m, m, this.angle);
|
|
623
|
-
mat4.translate(m, m, [-x, -y, 0]);
|
|
624
|
-
this.mercatorMatrix = mat4.scale(mat4.create(), m, [this.worldSize, this.worldSize, this.worldSize]);
|
|
625
|
-
mat4.scale(m, m, vec3.fromValues(1, 1, mercatorZfromAltitude(1, this.center.lat) * this.worldSize));
|
|
626
|
-
this.projMatrix = m;
|
|
627
|
-
this.invProjMatrix = mat4.invert(mat4.create(), this.projMatrix);
|
|
628
|
-
var xShift = this.width % 2 / 2;
|
|
629
|
-
var yShift = this.height % 2 / 2;
|
|
630
|
-
var angleCos = Math.cos(this.angle);
|
|
631
|
-
var angleSin = Math.sin(this.angle);
|
|
632
|
-
var dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift;
|
|
633
|
-
var dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;
|
|
634
|
-
var alignedM = mat4.clone(m);
|
|
635
|
-
mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);
|
|
636
|
-
this.alignedProjMatrix = alignedM;
|
|
637
|
-
m = mat4.create();
|
|
638
|
-
mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);
|
|
639
|
-
mat4.translate(m, m, [1, -1, 0]);
|
|
640
|
-
this.labelPlaneMatrix = m;
|
|
641
|
-
m = mat4.create();
|
|
642
|
-
mat4.scale(m, m, [1, -1, 1]);
|
|
643
|
-
mat4.translate(m, m, [-1, -1, 0]);
|
|
644
|
-
mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);
|
|
645
|
-
this.glCoordMatrix = m;
|
|
646
|
-
this.pixelMatrix = mat4.multiply(mat4.create(), this.labelPlaneMatrix, this.projMatrix);
|
|
647
|
-
m = mat4.invert(mat4.create(), this.pixelMatrix);
|
|
648
|
-
|
|
649
|
-
if (!m) {
|
|
650
|
-
throw new Error('failed to invert matrix');
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
this.pixelMatrixInverse = m;
|
|
654
|
-
this.posMatrixCache = {};
|
|
655
|
-
this.alignedPosMatrixCache = {};
|
|
656
|
-
}
|
|
657
|
-
}]);
|
|
658
|
-
|
|
659
|
-
return Transform;
|
|
660
|
-
}();
|
|
661
|
-
|
|
662
|
-
export { Transform as default };
|
|
663
|
-
//# sourceMappingURL=transform.js.map
|