@antv/l7-map 2.18.2 → 2.18.3
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/es/camera.d.ts +85 -0
- package/es/camera.js +718 -0
- package/es/css/l7.css +98 -0
- package/es/earthmap.d.ts +66 -0
- package/es/earthmap.js +369 -0
- package/es/geo/edge_insets.d.ts +54 -0
- package/es/geo/edge_insets.js +108 -0
- package/es/geo/lng_lat.d.ts +18 -0
- package/es/geo/lng_lat.js +73 -0
- package/es/geo/lng_lat_bounds.d.ts +24 -0
- package/es/geo/lng_lat_bounds.js +154 -0
- package/es/geo/mercator.d.ts +29 -0
- package/es/geo/mercator.js +84 -0
- package/es/geo/point.d.ts +40 -0
- package/es/geo/point.js +224 -0
- package/es/geo/simple.d.ts +29 -0
- package/es/geo/simple.js +87 -0
- package/es/geo/transform.d.ts +198 -0
- package/es/geo/transform.js +961 -0
- package/es/handler/IHandler.d.ts +34 -0
- package/es/handler/IHandler.js +1 -0
- package/es/handler/blockable_map_event.d.ts +17 -0
- package/es/handler/blockable_map_event.js +78 -0
- package/es/handler/box_zoom.d.ts +59 -0
- package/es/handler/box_zoom.js +180 -0
- package/es/handler/click_zoom.d.ts +16 -0
- package/es/handler/click_zoom.js +54 -0
- package/es/handler/events/event.d.ts +4 -0
- package/es/handler/events/event.js +11 -0
- package/es/handler/events/index.d.ts +4 -0
- package/es/handler/events/index.js +4 -0
- package/es/handler/events/map_mouse_event.d.ts +34 -0
- package/es/handler/events/map_mouse_event.js +64 -0
- package/es/handler/events/map_touch_event.d.ts +57 -0
- package/es/handler/events/map_touch_event.js +95 -0
- package/es/handler/events/map_wheel_event.d.ts +33 -0
- package/es/handler/events/map_wheel_event.js +50 -0
- package/es/handler/events/render_event.d.ts +5 -0
- package/es/handler/events/render_event.js +26 -0
- package/es/handler/handler_inertia.d.ts +23 -0
- package/es/handler/handler_inertia.js +157 -0
- package/es/handler/handler_manager.d.ts +61 -0
- package/es/handler/handler_manager.js +577 -0
- package/es/handler/handler_util.d.ts +4 -0
- package/es/handler/handler_util.js +9 -0
- package/es/handler/keyboard.d.ts +36 -0
- package/es/handler/keyboard.js +143 -0
- package/es/handler/map_event.d.ts +29 -0
- package/es/handler/map_event.js +125 -0
- package/es/handler/mouse/index.d.ts +4 -0
- package/es/handler/mouse/index.js +4 -0
- package/es/handler/mouse/mouse_handler.d.ts +22 -0
- package/es/handler/mouse/mouse_handler.js +118 -0
- package/es/handler/mouse/mousepan_handler.d.ts +10 -0
- package/es/handler/mouse/mousepan_handler.js +44 -0
- package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/es/handler/mouse/mousepitch_hander.js +46 -0
- package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/es/handler/mouse/mouserotate_hander.js +46 -0
- package/es/handler/mouse/util.d.ts +6 -0
- package/es/handler/mouse/util.js +11 -0
- package/es/handler/scroll_zoom.d.ts +93 -0
- package/es/handler/scroll_zoom.js +325 -0
- package/es/handler/shim/dblclick_zoom.d.ts +40 -0
- package/es/handler/shim/dblclick_zoom.js +67 -0
- package/es/handler/shim/drag_pan.d.ts +61 -0
- package/es/handler/shim/drag_pan.js +84 -0
- package/es/handler/shim/drag_rotate.d.ts +46 -0
- package/es/handler/shim/drag_rotate.js +74 -0
- package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/es/handler/shim/touch_zoom_rotate.js +115 -0
- package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/es/handler/tap/single_tap_recognizer.js +97 -0
- package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/es/handler/tap/tap_drag_zoom.js +106 -0
- package/es/handler/tap/tap_recognizer.d.ts +17 -0
- package/es/handler/tap/tap_recognizer.js +54 -0
- package/es/handler/tap/tap_zoom.d.ts +22 -0
- package/es/handler/tap/tap_zoom.js +109 -0
- package/es/handler/touch/index.d.ts +5 -0
- package/es/handler/touch/index.js +5 -0
- package/es/handler/touch/touch_pan.d.ts +30 -0
- package/es/handler/touch/touch_pan.js +110 -0
- package/es/handler/touch/touch_pitch.d.ts +13 -0
- package/es/handler/touch/touch_pitch.js +93 -0
- package/es/handler/touch/touch_rotate.d.ts +12 -0
- package/es/handler/touch/touch_rotate.js +77 -0
- package/es/handler/touch/touch_zoom.d.ts +12 -0
- package/es/handler/touch/touch_zoom.js +54 -0
- package/es/handler/touch/two_touch.d.ts +23 -0
- package/es/handler/touch/two_touch.js +125 -0
- package/es/hash.d.ts +14 -0
- package/es/hash.js +134 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/interface.d.ts +34 -0
- package/es/interface.js +1 -0
- package/es/map.d.ts +70 -0
- package/es/map.js +387 -0
- package/es/util.d.ts +25 -0
- package/es/util.js +88 -0
- package/es/utils/Aabb.d.ts +12 -0
- package/es/utils/Aabb.js +112 -0
- package/es/utils/dom.d.ts +4 -0
- package/es/utils/dom.js +140 -0
- package/es/utils/performance.d.ts +17 -0
- package/es/utils/performance.js +62 -0
- package/es/utils/primitives.d.ts +6 -0
- package/es/utils/primitives.js +47 -0
- package/es/utils/task_queue.d.ts +13 -0
- package/es/utils/task_queue.js +89 -0
- package/lib/camera.js +724 -0
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +376 -0
- package/lib/geo/edge_insets.js +114 -0
- package/lib/geo/lng_lat.js +81 -0
- package/lib/geo/lng_lat_bounds.js +161 -0
- package/lib/geo/mercator.js +100 -0
- package/lib/geo/point.js +231 -0
- package/lib/geo/simple.js +104 -0
- package/lib/geo/transform.js +971 -0
- package/lib/handler/IHandler.js +5 -0
- package/lib/handler/blockable_map_event.js +84 -0
- package/lib/handler/box_zoom.js +186 -0
- package/lib/handler/click_zoom.js +61 -0
- package/lib/handler/events/event.js +20 -0
- package/lib/handler/events/index.js +27 -0
- package/lib/handler/events/map_mouse_event.js +70 -0
- package/lib/handler/events/map_touch_event.js +100 -0
- package/lib/handler/events/map_wheel_event.js +57 -0
- package/lib/handler/events/render_event.js +33 -0
- package/lib/handler/handler_inertia.js +162 -0
- package/lib/handler/handler_manager.js +584 -0
- package/lib/handler/handler_util.js +15 -0
- package/lib/handler/keyboard.js +151 -0
- package/lib/handler/map_event.js +131 -0
- package/lib/handler/mouse/index.js +27 -0
- package/lib/handler/mouse/mouse_handler.js +124 -0
- package/lib/handler/mouse/mousepan_handler.js +49 -0
- package/lib/handler/mouse/mousepitch_hander.js +51 -0
- package/lib/handler/mouse/mouserotate_hander.js +51 -0
- package/lib/handler/mouse/util.js +22 -0
- package/lib/handler/scroll_zoom.js +333 -0
- package/lib/handler/shim/dblclick_zoom.js +74 -0
- package/lib/handler/shim/drag_pan.js +91 -0
- package/lib/handler/shim/drag_rotate.js +81 -0
- package/lib/handler/shim/touch_zoom_rotate.js +122 -0
- package/lib/handler/tap/single_tap_recognizer.js +106 -0
- package/lib/handler/tap/tap_drag_zoom.js +112 -0
- package/lib/handler/tap/tap_recognizer.js +63 -0
- package/lib/handler/tap/tap_zoom.js +115 -0
- package/lib/handler/touch/index.js +34 -0
- package/lib/handler/touch/touch_pan.js +117 -0
- package/lib/handler/touch/touch_pitch.js +98 -0
- package/lib/handler/touch/touch_rotate.js +82 -0
- package/lib/handler/touch/touch_zoom.js +59 -0
- package/lib/handler/touch/two_touch.js +131 -0
- package/lib/hash.js +143 -0
- package/lib/index.js +49 -0
- package/lib/interface.js +5 -0
- package/lib/map.js +394 -0
- package/lib/util.js +108 -0
- package/lib/utils/Aabb.js +119 -0
- package/lib/utils/dom.js +147 -0
- package/lib/utils/performance.js +70 -0
- package/lib/utils/primitives.js +54 -0
- package/lib/utils/task_queue.js +97 -0
- package/package.json +3 -3
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _lng_lat = _interopRequireDefault(require("./lng_lat"));
|
|
11
|
+
var LngLatBounds = /*#__PURE__*/function () {
|
|
12
|
+
function LngLatBounds(sw, ne) {
|
|
13
|
+
(0, _classCallCheck2.default)(this, LngLatBounds);
|
|
14
|
+
if (!sw) {
|
|
15
|
+
// noop
|
|
16
|
+
} else if (ne) {
|
|
17
|
+
this.setSouthWest(sw).setNorthEast(ne);
|
|
18
|
+
} else if (sw.length === 4) {
|
|
19
|
+
this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
|
|
20
|
+
} else {
|
|
21
|
+
this.setSouthWest(sw[0]).setNorthEast(sw[1]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
(0, _createClass2.default)(LngLatBounds, [{
|
|
25
|
+
key: "setNorthEast",
|
|
26
|
+
value: function setNorthEast(ne) {
|
|
27
|
+
this.ne = ne instanceof _lng_lat.default ? new _lng_lat.default(ne.lng, ne.lat) : _lng_lat.default.convert(ne);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "setSouthWest",
|
|
32
|
+
value: function setSouthWest(sw) {
|
|
33
|
+
this.sw = sw instanceof _lng_lat.default ? new _lng_lat.default(sw.lng, sw.lat) : _lng_lat.default.convert(sw);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "extend",
|
|
38
|
+
value: function extend(obj) {
|
|
39
|
+
var sw = this.sw;
|
|
40
|
+
var ne = this.ne;
|
|
41
|
+
var sw2;
|
|
42
|
+
var ne2;
|
|
43
|
+
if (obj instanceof _lng_lat.default) {
|
|
44
|
+
sw2 = obj;
|
|
45
|
+
ne2 = obj;
|
|
46
|
+
} else if (obj instanceof LngLatBounds) {
|
|
47
|
+
sw2 = obj.sw;
|
|
48
|
+
ne2 = obj.ne;
|
|
49
|
+
if (!sw2 || !ne2) {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if (Array.isArray(obj)) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
if (obj.length === 4 || obj.every(Array.isArray)) {
|
|
56
|
+
var lngLatBoundsObj = obj;
|
|
57
|
+
return this.extend(LngLatBounds.convert(lngLatBoundsObj));
|
|
58
|
+
} else {
|
|
59
|
+
var lngLatObj = obj;
|
|
60
|
+
return this.extend(_lng_lat.default.convert(lngLatObj));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
if (!sw && !ne) {
|
|
66
|
+
this.sw = new _lng_lat.default(sw2.lng, sw2.lat);
|
|
67
|
+
this.ne = new _lng_lat.default(ne2.lng, ne2.lat);
|
|
68
|
+
} else {
|
|
69
|
+
sw.lng = Math.min(sw2.lng, sw.lng);
|
|
70
|
+
sw.lat = Math.min(sw2.lat, sw.lat);
|
|
71
|
+
ne.lng = Math.max(ne2.lng, ne.lng);
|
|
72
|
+
ne.lat = Math.max(ne2.lat, ne.lat);
|
|
73
|
+
}
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "getCenter",
|
|
78
|
+
value: function getCenter() {
|
|
79
|
+
return new _lng_lat.default((this.sw.lng + this.ne.lng) / 2, (this.sw.lat + this.ne.lat) / 2);
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "getSouthWest",
|
|
83
|
+
value: function getSouthWest() {
|
|
84
|
+
return this.sw;
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "getNorthEast",
|
|
88
|
+
value: function getNorthEast() {
|
|
89
|
+
return this.ne;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "getNorthWest",
|
|
93
|
+
value: function getNorthWest() {
|
|
94
|
+
return new _lng_lat.default(this.getWest(), this.getNorth());
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "getSouthEast",
|
|
98
|
+
value: function getSouthEast() {
|
|
99
|
+
return new _lng_lat.default(this.getEast(), this.getSouth());
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "getWest",
|
|
103
|
+
value: function getWest() {
|
|
104
|
+
return this.sw.lng;
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "getSouth",
|
|
108
|
+
value: function getSouth() {
|
|
109
|
+
return this.sw.lat;
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "getEast",
|
|
113
|
+
value: function getEast() {
|
|
114
|
+
return this.ne.lng;
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "getNorth",
|
|
118
|
+
value: function getNorth() {
|
|
119
|
+
return this.ne.lat;
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "toArray",
|
|
123
|
+
value: function toArray() {
|
|
124
|
+
return [this.sw.toArray(), this.ne.toArray()];
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "toString",
|
|
128
|
+
value: function toString() {
|
|
129
|
+
return "LngLatBounds(".concat(this.sw.toString(), ", ").concat(this.ne.toString(), ")");
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "isEmpty",
|
|
133
|
+
value: function isEmpty() {
|
|
134
|
+
return !(this.sw && this.ne);
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "contains",
|
|
138
|
+
value: function contains(lnglat) {
|
|
139
|
+
var _LngLat$convert = _lng_lat.default.convert(lnglat),
|
|
140
|
+
lng = _LngLat$convert.lng,
|
|
141
|
+
lat = _LngLat$convert.lat;
|
|
142
|
+
var containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
|
|
143
|
+
var containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
|
|
144
|
+
if (this.sw.lng > this.ne.lng) {
|
|
145
|
+
// wrapped coordinates
|
|
146
|
+
containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
|
|
147
|
+
}
|
|
148
|
+
return containsLatitude && containsLongitude;
|
|
149
|
+
}
|
|
150
|
+
}], [{
|
|
151
|
+
key: "convert",
|
|
152
|
+
value: function convert(input) {
|
|
153
|
+
if (input instanceof LngLatBounds) {
|
|
154
|
+
return input;
|
|
155
|
+
}
|
|
156
|
+
return new LngLatBounds(input);
|
|
157
|
+
}
|
|
158
|
+
}]);
|
|
159
|
+
return LngLatBounds;
|
|
160
|
+
}();
|
|
161
|
+
exports.default = LngLatBounds;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.MercatorCoordinate = void 0;
|
|
9
|
+
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
exports.latFromMercatorY = latFromMercatorY;
|
|
12
|
+
exports.lngFromMercatorX = lngFromMercatorX;
|
|
13
|
+
exports.mercatorScale = mercatorScale;
|
|
14
|
+
exports.mercatorXfromLng = mercatorXfromLng;
|
|
15
|
+
exports.mercatorYfromLat = mercatorYfromLat;
|
|
16
|
+
exports.mercatorZfromAltitude = mercatorZfromAltitude;
|
|
17
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
var _lng_lat = _interopRequireWildcard(require("../geo/lng_lat"));
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
/*
|
|
23
|
+
* The average circumference of the world in meters.
|
|
24
|
+
*/
|
|
25
|
+
var earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius; // meters
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* The circumference at a line of latitude in meters.
|
|
29
|
+
*/
|
|
30
|
+
function circumferenceAtLatitude(latitude) {
|
|
31
|
+
return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
|
|
32
|
+
}
|
|
33
|
+
function mercatorXfromLng(lng) {
|
|
34
|
+
return (180 + lng) / 360;
|
|
35
|
+
}
|
|
36
|
+
function mercatorYfromLat(lat) {
|
|
37
|
+
return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
|
|
38
|
+
}
|
|
39
|
+
function mercatorZfromAltitude(altitude, lat) {
|
|
40
|
+
return altitude / circumferenceAtLatitude(lat);
|
|
41
|
+
}
|
|
42
|
+
function lngFromMercatorX(x) {
|
|
43
|
+
return x * 360 - 180;
|
|
44
|
+
}
|
|
45
|
+
function latFromMercatorY(y) {
|
|
46
|
+
var y2 = 180 - y * 360;
|
|
47
|
+
return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
48
|
+
}
|
|
49
|
+
function altitudeFromMercatorZ(z, y) {
|
|
50
|
+
return z * circumferenceAtLatitude(latFromMercatorY(y));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Determine the Mercator scale factor for a given latitude, see
|
|
55
|
+
* https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
|
|
56
|
+
*
|
|
57
|
+
* At the equator the scale factor will be 1, which increases at higher latitudes.
|
|
58
|
+
*
|
|
59
|
+
* @param {number} lat Latitude
|
|
60
|
+
* @returns {number} scale factor
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
function mercatorScale(lat) {
|
|
64
|
+
return 1 / Math.cos(lat * Math.PI / 180);
|
|
65
|
+
}
|
|
66
|
+
var MercatorCoordinate = /*#__PURE__*/function () {
|
|
67
|
+
function MercatorCoordinate(x, y) {
|
|
68
|
+
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
69
|
+
(0, _classCallCheck2.default)(this, MercatorCoordinate);
|
|
70
|
+
this.x = +x;
|
|
71
|
+
this.y = +y;
|
|
72
|
+
this.z = +z;
|
|
73
|
+
}
|
|
74
|
+
(0, _createClass2.default)(MercatorCoordinate, [{
|
|
75
|
+
key: "toLngLat",
|
|
76
|
+
value: function toLngLat() {
|
|
77
|
+
return new _lng_lat.default(lngFromMercatorX(this.x), latFromMercatorY(this.y));
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "toAltitude",
|
|
81
|
+
value: function toAltitude() {
|
|
82
|
+
return altitudeFromMercatorZ(this.z, this.y);
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "meterInMercatorCoordinateUnits",
|
|
86
|
+
value: function meterInMercatorCoordinateUnits() {
|
|
87
|
+
// 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude
|
|
88
|
+
return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));
|
|
89
|
+
}
|
|
90
|
+
}], [{
|
|
91
|
+
key: "fromLngLat",
|
|
92
|
+
value: function fromLngLat(lngLatLike) {
|
|
93
|
+
var altitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
94
|
+
var lngLat = _lng_lat.default.convert(lngLatLike);
|
|
95
|
+
return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
|
|
96
|
+
}
|
|
97
|
+
}]);
|
|
98
|
+
return MercatorCoordinate;
|
|
99
|
+
}();
|
|
100
|
+
exports.MercatorCoordinate = exports.default = MercatorCoordinate;
|
package/lib/geo/point.js
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var Point = /*#__PURE__*/function () {
|
|
11
|
+
function Point(x, y) {
|
|
12
|
+
(0, _classCallCheck2.default)(this, Point);
|
|
13
|
+
this.x = x;
|
|
14
|
+
this.y = y;
|
|
15
|
+
}
|
|
16
|
+
(0, _createClass2.default)(Point, [{
|
|
17
|
+
key: "clone",
|
|
18
|
+
value: function clone() {
|
|
19
|
+
return new Point(this.x, this.y);
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
key: "_add",
|
|
23
|
+
value: function _add(p) {
|
|
24
|
+
this.x += p.x;
|
|
25
|
+
this.y += p.y;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
key: "add",
|
|
30
|
+
value: function add(p) {
|
|
31
|
+
return this.clone()._add(p);
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "_sub",
|
|
35
|
+
value: function _sub(p) {
|
|
36
|
+
this.x -= p.x;
|
|
37
|
+
this.y -= p.y;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "sub",
|
|
42
|
+
value: function sub(p) {
|
|
43
|
+
return this.clone()._sub(p);
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "_multByPoint",
|
|
47
|
+
value: function _multByPoint(p) {
|
|
48
|
+
this.x *= p.x;
|
|
49
|
+
this.y *= p.y;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "multByPoint",
|
|
54
|
+
value: function multByPoint(p) {
|
|
55
|
+
return this.clone()._multByPoint(p);
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "_divByPoint",
|
|
59
|
+
value: function _divByPoint(p) {
|
|
60
|
+
this.x /= p.x;
|
|
61
|
+
this.y /= p.y;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "divByPoint",
|
|
66
|
+
value: function divByPoint(p) {
|
|
67
|
+
return this.clone()._divByPoint(p);
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "_mult",
|
|
71
|
+
value: function _mult(k) {
|
|
72
|
+
this.x *= k;
|
|
73
|
+
this.y *= k;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "mult",
|
|
78
|
+
value: function mult(k) {
|
|
79
|
+
return this.clone()._mult(k);
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "_div",
|
|
83
|
+
value: function _div(k) {
|
|
84
|
+
this.x /= k;
|
|
85
|
+
this.y /= k;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "div",
|
|
90
|
+
value: function div(k) {
|
|
91
|
+
return this.clone()._div(k);
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "_rotate",
|
|
95
|
+
value: function _rotate(angle) {
|
|
96
|
+
var cos = Math.cos(angle);
|
|
97
|
+
var sin = Math.sin(angle);
|
|
98
|
+
var x = cos * this.x - sin * this.y;
|
|
99
|
+
var y = sin * this.x + cos * this.y;
|
|
100
|
+
this.x = x;
|
|
101
|
+
this.y = y;
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "rotate",
|
|
106
|
+
value: function rotate(angle) {
|
|
107
|
+
return this.clone()._rotate(angle);
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "_rotateAround",
|
|
111
|
+
value: function _rotateAround(angle, p) {
|
|
112
|
+
var cos = Math.cos(angle);
|
|
113
|
+
var sin = Math.sin(angle);
|
|
114
|
+
var x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
|
|
115
|
+
var y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
|
116
|
+
this.x = x;
|
|
117
|
+
this.y = y;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "roateAround",
|
|
122
|
+
value: function roateAround(angle, p) {
|
|
123
|
+
return this.clone()._rotateAround(angle, p);
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "_matMult",
|
|
127
|
+
value: function _matMult(m) {
|
|
128
|
+
var x = m[0] * this.x + m[1] * this.y;
|
|
129
|
+
var y = m[2] * this.x + m[3] * this.y;
|
|
130
|
+
this.x = x;
|
|
131
|
+
this.y = y;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "matMult",
|
|
136
|
+
value: function matMult(m) {
|
|
137
|
+
return this.clone()._matMult(m);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "_unit",
|
|
141
|
+
value: function _unit() {
|
|
142
|
+
this.div(this.mag());
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "unit",
|
|
147
|
+
value: function unit() {
|
|
148
|
+
return this.clone()._unit();
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "_perp",
|
|
152
|
+
value: function _perp() {
|
|
153
|
+
var y = this.y;
|
|
154
|
+
this.y = this.x;
|
|
155
|
+
this.x = -y;
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "perp",
|
|
160
|
+
value: function perp() {
|
|
161
|
+
return this.clone()._perp();
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "_round",
|
|
165
|
+
value: function _round() {
|
|
166
|
+
this.x = Math.round(this.x);
|
|
167
|
+
this.y = Math.round(this.y);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
key: "round",
|
|
172
|
+
value: function round() {
|
|
173
|
+
return this.clone()._round();
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "mag",
|
|
177
|
+
value: function mag() {
|
|
178
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
key: "equals",
|
|
182
|
+
value: function equals(other) {
|
|
183
|
+
return this.x === other.x && this.y === other.y;
|
|
184
|
+
}
|
|
185
|
+
}, {
|
|
186
|
+
key: "dist",
|
|
187
|
+
value: function dist(p) {
|
|
188
|
+
return Math.sqrt(this.distSqr(p));
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "distSqr",
|
|
192
|
+
value: function distSqr(p) {
|
|
193
|
+
var dx = p.x - this.x;
|
|
194
|
+
var dy = p.y - this.y;
|
|
195
|
+
return dx * dx + dy * dy;
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "angle",
|
|
199
|
+
value: function angle() {
|
|
200
|
+
return Math.atan2(this.y, this.x);
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "angleTo",
|
|
204
|
+
value: function angleTo(b) {
|
|
205
|
+
return Math.atan2(this.y - b.y, this.x - b.x);
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "angleWith",
|
|
209
|
+
value: function angleWith(b) {
|
|
210
|
+
return this.angleWithSep(b.x, b.y);
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "angleWithSep",
|
|
214
|
+
value: function angleWithSep(x, y) {
|
|
215
|
+
return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
|
|
216
|
+
}
|
|
217
|
+
}], [{
|
|
218
|
+
key: "convert",
|
|
219
|
+
value: function convert(a) {
|
|
220
|
+
if (a instanceof Point) {
|
|
221
|
+
return a;
|
|
222
|
+
}
|
|
223
|
+
if (Array.isArray(a)) {
|
|
224
|
+
return new Point(a[0], a[1]);
|
|
225
|
+
}
|
|
226
|
+
return a;
|
|
227
|
+
}
|
|
228
|
+
}]);
|
|
229
|
+
return Point;
|
|
230
|
+
}();
|
|
231
|
+
exports.default = Point;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
9
|
+
exports.circumferenceAtLatitude = circumferenceAtLatitude;
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
exports.latFromMercatorY = latFromMercatorY;
|
|
12
|
+
exports.lngFromMercatorX = lngFromMercatorX;
|
|
13
|
+
exports.mercatorScale = mercatorScale;
|
|
14
|
+
exports.mercatorXfromLng = mercatorXfromLng;
|
|
15
|
+
exports.mercatorYfromLat = mercatorYfromLat;
|
|
16
|
+
exports.mercatorZfromAltitude = mercatorZfromAltitude;
|
|
17
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
var _lng_lat = _interopRequireWildcard(require("../geo/lng_lat"));
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
/*
|
|
23
|
+
* The average circumference of the world in meters.
|
|
24
|
+
*/
|
|
25
|
+
var earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius; // meters
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* The circumference at a line of latitude in meters.
|
|
29
|
+
*/
|
|
30
|
+
function circumferenceAtLatitude(latitude) {
|
|
31
|
+
return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
|
|
32
|
+
}
|
|
33
|
+
function mercatorXfromLng(lng) {
|
|
34
|
+
return lng;
|
|
35
|
+
}
|
|
36
|
+
function mercatorYfromLat(lat) {
|
|
37
|
+
return lat;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
+
function mercatorZfromAltitude(altitude, lat) {
|
|
42
|
+
return altitude;
|
|
43
|
+
}
|
|
44
|
+
function lngFromMercatorX(x) {
|
|
45
|
+
return x;
|
|
46
|
+
}
|
|
47
|
+
function latFromMercatorY(y) {
|
|
48
|
+
return y;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
+
function altitudeFromMercatorZ(z, y) {
|
|
53
|
+
return z;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Determine the Mercator scale factor for a given latitude, see
|
|
58
|
+
* https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
|
|
59
|
+
*
|
|
60
|
+
* At the equator the scale factor will be 1, which increases at higher latitudes.
|
|
61
|
+
*
|
|
62
|
+
* @param {number} lat Latitude
|
|
63
|
+
* @returns {number} scale factor
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
67
|
+
function mercatorScale(lat) {
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
var SimpleCoordinate = /*#__PURE__*/function () {
|
|
71
|
+
function SimpleCoordinate(x, y) {
|
|
72
|
+
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
73
|
+
(0, _classCallCheck2.default)(this, SimpleCoordinate);
|
|
74
|
+
this.x = +x;
|
|
75
|
+
this.y = +y;
|
|
76
|
+
this.z = +z;
|
|
77
|
+
}
|
|
78
|
+
(0, _createClass2.default)(SimpleCoordinate, [{
|
|
79
|
+
key: "toLngLat",
|
|
80
|
+
value: function toLngLat() {
|
|
81
|
+
return new _lng_lat.default(this.x, this.y);
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "toAltitude",
|
|
85
|
+
value: function toAltitude() {
|
|
86
|
+
return this.z;
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "meterInMercatorCoordinateUnits",
|
|
90
|
+
value: function meterInMercatorCoordinateUnits() {
|
|
91
|
+
// 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude
|
|
92
|
+
return 1;
|
|
93
|
+
}
|
|
94
|
+
}], [{
|
|
95
|
+
key: "fromLngLat",
|
|
96
|
+
value: function fromLngLat(lngLatLike) {
|
|
97
|
+
var altitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
98
|
+
var lngLat = _lng_lat.default.convert(lngLatLike);
|
|
99
|
+
return new SimpleCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
|
|
100
|
+
}
|
|
101
|
+
}]);
|
|
102
|
+
return SimpleCoordinate;
|
|
103
|
+
}();
|
|
104
|
+
exports.default = SimpleCoordinate;
|