@math.gl/web-mercator 5.0.0-beta.4 → 5.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"author": "Uber Technologies, Inc.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "5.0.0-beta.
|
|
7
|
+
"version": "5.0.0-beta.6",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"webgl",
|
|
10
10
|
"javascript",
|
|
@@ -32,14 +32,16 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"dist",
|
|
34
34
|
"src",
|
|
35
|
+
"!src/**/README.md",
|
|
36
|
+
"./README.md",
|
|
35
37
|
"LICENSE",
|
|
36
38
|
"THIRD-PARTY-NOTICES.md"
|
|
37
39
|
],
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@math.gl/core": "5.0.0-beta.
|
|
41
|
+
"@math.gl/core": "5.0.0-beta.6"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"mock-browser": "^0.92.14"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "c0b536175257abee1b30f687a3ca8cf5c8ca7bb9"
|
|
45
47
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare function getGlobeToMercatorTransition(zoom: number, { startZoom, endZoom }: {
|
|
2
|
-
startZoom: number;
|
|
3
|
-
endZoom: number;
|
|
4
|
-
}): number;
|
|
5
|
-
export type GlobeMercatorProjectionOptions = {
|
|
6
|
-
longitude: number;
|
|
7
|
-
latitude: number;
|
|
8
|
-
progress: number;
|
|
9
|
-
};
|
|
10
|
-
/** Positions are in meters in a center-relative east, north, up frame. */
|
|
11
|
-
export declare class GlobeMercatorProjection {
|
|
12
|
-
readonly longitude: number;
|
|
13
|
-
readonly latitude: number;
|
|
14
|
-
readonly progress: number;
|
|
15
|
-
constructor({ longitude, latitude, progress }: GlobeMercatorProjectionOptions);
|
|
16
|
-
project(position: readonly number[], out?: number[]): number[];
|
|
17
|
-
getShaderParameters(): GlobeMercatorProjectionOptions;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=globe-mercator-projection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globe-mercator-projection.d.ts","sourceRoot":"","sources":["../src/globe-mercator-projection.ts"],"names":[],"mappings":"AASA,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,EAAC,SAAS,EAAE,OAAO,EAAC,EAAE;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GACzD,MAAM,CAMR;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,0EAA0E;AAC1E,qBAAa,uBAAuB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,EAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAC,EAAE,8BAA8B;IAgB3E,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE;IAkClE,mBAAmB,IAAI,8BAA8B;CAOtD"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
-
/** Experimental, view-centered spherical globe to Web Mercator projection. */
|
|
5
|
-
const RADIUS = 6378137;
|
|
6
|
-
const RAD = Math.PI / 180;
|
|
7
|
-
const MAX_LATITUDE = 85.0511287798066;
|
|
8
|
-
export function getGlobeToMercatorTransition(zoom, { startZoom, endZoom }) {
|
|
9
|
-
if (![zoom, startZoom, endZoom].every(Number.isFinite) || startZoom >= endZoom) {
|
|
10
|
-
throw new RangeError('Expected finite zooms with startZoom < endZoom');
|
|
11
|
-
}
|
|
12
|
-
const t = Math.max(0, Math.min(1, (zoom - startZoom) / (endZoom - startZoom)));
|
|
13
|
-
return t * t * (3 - 2 * t);
|
|
14
|
-
}
|
|
15
|
-
/** Positions are in meters in a center-relative east, north, up frame. */
|
|
16
|
-
export class GlobeMercatorProjection {
|
|
17
|
-
constructor({ longitude, latitude, progress }) {
|
|
18
|
-
if (![longitude, latitude, progress].every(Number.isFinite) ||
|
|
19
|
-
Math.abs(latitude) > 90 ||
|
|
20
|
-
progress < 0 ||
|
|
21
|
-
progress > 1 ||
|
|
22
|
-
(progress > 0 && Math.abs(latitude) > MAX_LATITUDE)) {
|
|
23
|
-
throw new RangeError('Invalid globe Mercator projection parameters');
|
|
24
|
-
}
|
|
25
|
-
this.longitude = longitude;
|
|
26
|
-
this.latitude = latitude;
|
|
27
|
-
this.progress = progress;
|
|
28
|
-
Object.freeze(this);
|
|
29
|
-
}
|
|
30
|
-
project(position, out = []) {
|
|
31
|
-
const [longitude, latitude, height = 0] = position;
|
|
32
|
-
if (![longitude, latitude, height].every(Number.isFinite) ||
|
|
33
|
-
Math.abs(latitude) > 90 ||
|
|
34
|
-
(this.progress > 0 && Math.abs(latitude) > MAX_LATITUDE)) {
|
|
35
|
-
throw new RangeError('Position outside projection domain');
|
|
36
|
-
}
|
|
37
|
-
const delta = (((((longitude - this.longitude) % 360) + 540) % 360) - 180) * RAD;
|
|
38
|
-
const phi = latitude * RAD;
|
|
39
|
-
const center = this.latitude * RAD;
|
|
40
|
-
const cos = Math.cos(phi), sin = Math.sin(phi);
|
|
41
|
-
const radius = RADIUS + height;
|
|
42
|
-
const east = radius * cos * Math.sin(delta);
|
|
43
|
-
const north = radius * (sin * Math.cos(center) - cos * Math.cos(delta) * Math.sin(center));
|
|
44
|
-
const up = radius * (sin * Math.sin(center) + cos * Math.cos(delta) * Math.cos(center)) - RADIUS;
|
|
45
|
-
if (this.progress === 0) {
|
|
46
|
-
out[0] = east;
|
|
47
|
-
out[1] = north;
|
|
48
|
-
out[2] = up;
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
|
-
const scale = Math.cos(center);
|
|
52
|
-
const mercator = (p) => Math.log(Math.tan(Math.PI / 4 + p / 2));
|
|
53
|
-
const t = this.progress;
|
|
54
|
-
out[0] = east * (1 - t) + RADIUS * scale * delta * t;
|
|
55
|
-
out[1] = north * (1 - t) + RADIUS * scale * (mercator(phi) - mercator(center)) * t;
|
|
56
|
-
out[2] = up * (1 - t) + height * t;
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
getShaderParameters() {
|
|
60
|
-
return {
|
|
61
|
-
longitude: this.longitude,
|
|
62
|
-
latitude: this.latitude,
|
|
63
|
-
progress: this.progress
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=globe-mercator-projection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globe-mercator-projection.js","sourceRoot":"","sources":["../src/globe-mercator-projection.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,8EAA8E;AAC9E,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAC1B,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAEtC,MAAM,UAAU,4BAA4B,CAC1C,IAAY,EACZ,EAAC,SAAS,EAAE,OAAO,EAAuC;IAE1D,IAAI,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,IA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: MIT
|
|
3
|
-
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
/** Experimental, view-centered spherical globe to Web Mercator projection. */
|
|
6
|
-
const RADIUS = 6378137;
|
|
7
|
-
const RAD = Math.PI / 180;
|
|
8
|
-
const MAX_LATITUDE = 85.0511287798066;
|
|
9
|
-
|
|
10
|
-
export function getGlobeToMercatorTransition(
|
|
11
|
-
zoom: number,
|
|
12
|
-
{startZoom, endZoom}: {startZoom: number; endZoom: number}
|
|
13
|
-
): number {
|
|
14
|
-
if (![zoom, startZoom, endZoom].every(Number.isFinite) || startZoom >= endZoom) {
|
|
15
|
-
throw new RangeError('Expected finite zooms with startZoom < endZoom');
|
|
16
|
-
}
|
|
17
|
-
const t = Math.max(0, Math.min(1, (zoom - startZoom) / (endZoom - startZoom)));
|
|
18
|
-
return t * t * (3 - 2 * t);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type GlobeMercatorProjectionOptions = {
|
|
22
|
-
longitude: number;
|
|
23
|
-
latitude: number;
|
|
24
|
-
progress: number;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/** Positions are in meters in a center-relative east, north, up frame. */
|
|
28
|
-
export class GlobeMercatorProjection {
|
|
29
|
-
readonly longitude: number;
|
|
30
|
-
readonly latitude: number;
|
|
31
|
-
readonly progress: number;
|
|
32
|
-
|
|
33
|
-
constructor({longitude, latitude, progress}: GlobeMercatorProjectionOptions) {
|
|
34
|
-
if (
|
|
35
|
-
![longitude, latitude, progress].every(Number.isFinite) ||
|
|
36
|
-
Math.abs(latitude) > 90 ||
|
|
37
|
-
progress < 0 ||
|
|
38
|
-
progress > 1 ||
|
|
39
|
-
(progress > 0 && Math.abs(latitude) > MAX_LATITUDE)
|
|
40
|
-
) {
|
|
41
|
-
throw new RangeError('Invalid globe Mercator projection parameters');
|
|
42
|
-
}
|
|
43
|
-
this.longitude = longitude;
|
|
44
|
-
this.latitude = latitude;
|
|
45
|
-
this.progress = progress;
|
|
46
|
-
Object.freeze(this);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
project(position: readonly number[], out: number[] = []): number[] {
|
|
50
|
-
const [longitude, latitude, height = 0] = position;
|
|
51
|
-
if (
|
|
52
|
-
![longitude, latitude, height].every(Number.isFinite) ||
|
|
53
|
-
Math.abs(latitude) > 90 ||
|
|
54
|
-
(this.progress > 0 && Math.abs(latitude) > MAX_LATITUDE)
|
|
55
|
-
) {
|
|
56
|
-
throw new RangeError('Position outside projection domain');
|
|
57
|
-
}
|
|
58
|
-
const delta = (((((longitude - this.longitude) % 360) + 540) % 360) - 180) * RAD;
|
|
59
|
-
const phi = latitude * RAD;
|
|
60
|
-
const center = this.latitude * RAD;
|
|
61
|
-
const cos = Math.cos(phi),
|
|
62
|
-
sin = Math.sin(phi);
|
|
63
|
-
const radius = RADIUS + height;
|
|
64
|
-
const east = radius * cos * Math.sin(delta);
|
|
65
|
-
const north = radius * (sin * Math.cos(center) - cos * Math.cos(delta) * Math.sin(center));
|
|
66
|
-
const up =
|
|
67
|
-
radius * (sin * Math.sin(center) + cos * Math.cos(delta) * Math.cos(center)) - RADIUS;
|
|
68
|
-
if (this.progress === 0) {
|
|
69
|
-
out[0] = east;
|
|
70
|
-
out[1] = north;
|
|
71
|
-
out[2] = up;
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
const scale = Math.cos(center);
|
|
75
|
-
const mercator = (p: number) => Math.log(Math.tan(Math.PI / 4 + p / 2));
|
|
76
|
-
const t = this.progress;
|
|
77
|
-
out[0] = east * (1 - t) + RADIUS * scale * delta * t;
|
|
78
|
-
out[1] = north * (1 - t) + RADIUS * scale * (mercator(phi) - mercator(center)) * t;
|
|
79
|
-
out[2] = up * (1 - t) + height * t;
|
|
80
|
-
return out;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
getShaderParameters(): GlobeMercatorProjectionOptions {
|
|
84
|
-
return {
|
|
85
|
-
longitude: this.longitude,
|
|
86
|
-
latitude: this.latitude,
|
|
87
|
-
progress: this.progress
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|