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