Carga
This commit is contained in:
2025-04-17 00:35:33 -06:00
parent 4977462629
commit 67fc72aed5
1333 changed files with 1077639 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
/* *
*
* Equal Earth projection, an equal-area projection designed to minimize
* distortion and remain pleasing to the eye.
*
* Invented by Bojan Šavrič, Bernhard Jenny, and Tom Patterson in 2018. It is
* inspired by the widely used Robinson projection.
*
* */
'use strict';
var A1 = 1.340264, A2 = -0.081106, A3 = 0.000893, A4 = 0.003796, M = Math.sqrt(3) / 2.0, scale = 74.03120656864502;
var EqualEarth = /** @class */ (function () {
function EqualEarth() {
this.bounds = {
x1: -200.37508342789243,
x2: 200.37508342789243,
y1: -97.52595454902263,
y2: 97.52595454902263
};
}
EqualEarth.prototype.forward = function (lonLat) {
var d = Math.PI / 180, paramLat = Math.asin(M * Math.sin(lonLat[1] * d)), paramLatSq = paramLat * paramLat, paramLatPow6 = paramLatSq * paramLatSq * paramLatSq;
var x = lonLat[0] * d * Math.cos(paramLat) * scale / (M *
(A1 +
3 * A2 * paramLatSq +
paramLatPow6 * (7 * A3 + 9 * A4 * paramLatSq)));
var y = paramLat * scale * (A1 + A2 * paramLatSq + paramLatPow6 * (A3 + A4 * paramLatSq));
return [x, y];
};
EqualEarth.prototype.inverse = function (xy) {
var x = xy[0] / scale, y = xy[1] / scale, d = 180 / Math.PI, epsilon = 1e-9, iterations = 12;
var paramLat = y, paramLatSq, paramLatPow6, fy, fpy, dlat, i;
for (i = 0; i < iterations; ++i) {
paramLatSq = paramLat * paramLat;
paramLatPow6 = paramLatSq * paramLatSq * paramLatSq;
fy = paramLat * (A1 + A2 * paramLatSq + paramLatPow6 * (A3 + A4 * paramLatSq)) - y;
fpy = A1 + 3 * A2 * paramLatSq + paramLatPow6 * (7 * A3 + 9 * A4 * paramLatSq);
paramLat -= dlat = fy / fpy;
if (Math.abs(dlat) < epsilon) {
break;
}
}
paramLatSq = paramLat * paramLat;
paramLatPow6 = paramLatSq * paramLatSq * paramLatSq;
var lon = d * M * x * (A1 + 3 * A2 * paramLatSq + paramLatPow6 * (7 * A3 + 9 * A4 * paramLatSq)) / Math.cos(paramLat);
var lat = d * Math.asin(Math.sin(paramLat) / M);
return [lon, lat];
};
return EqualEarth;
}());
export default EqualEarth;

View File

@@ -0,0 +1,60 @@
/* *
* Lambert Conformal Conic projection
* */
'use strict';
var sign = Math.sign ||
(function (n) { return (n === 0 ? 0 : n > 0 ? 1 : -1); }), scale = 63.78137, deg2rad = Math.PI / 180, halfPI = Math.PI / 2, eps10 = 1e-6, tany = function (y) { return Math.tan((halfPI + y) / 2); };
var LambertConformalConic = /** @class */ (function () {
function LambertConformalConic(options) {
var _a;
var parallels = (options.parallels || [])
.map(function (n) { return n * deg2rad; }), lat1 = parallels[0] || 0, lat2 = (_a = parallels[1]) !== null && _a !== void 0 ? _a : lat1, cosLat1 = Math.cos(lat1);
if (typeof options.projectedBounds === 'object') {
this.projectedBounds = options.projectedBounds;
}
// Apply the global variables
var n = lat1 === lat2 ?
Math.sin(lat1) :
Math.log(cosLat1 / Math.cos(lat2)) / Math.log(tany(lat2) / tany(lat1));
if (Math.abs(n) < 1e-10) {
n = (sign(n) || 1) * 1e-10;
}
this.n = n;
this.c = cosLat1 * Math.pow(tany(lat1), n) / n;
}
LambertConformalConic.prototype.forward = function (lonLat) {
var lon = lonLat[0] * deg2rad, _a = this, c = _a.c, n = _a.n, projectedBounds = _a.projectedBounds;
var lat = lonLat[1] * deg2rad;
if (c > 0) {
if (lat < -halfPI + eps10) {
lat = -halfPI + eps10;
}
}
else {
if (lat > halfPI - eps10) {
lat = halfPI - eps10;
}
}
var r = c / Math.pow(tany(lat), n), x = r * Math.sin(n * lon) * scale, y = (c - r * Math.cos(n * lon)) * scale, xy = [x, y];
if (projectedBounds && (x < projectedBounds.x1 ||
x > projectedBounds.x2 ||
y < projectedBounds.y1 ||
y > projectedBounds.y2)) {
xy.outside = true;
}
return xy;
};
LambertConformalConic.prototype.inverse = function (xy) {
var x = xy[0] / scale, y = xy[1] / scale, _a = this, c = _a.c, n = _a.n, cy = c - y, rho = sign(n) * Math.sqrt(x * x + cy * cy);
var l = Math.atan2(x, Math.abs(cy)) * sign(cy);
if (cy * n < 0) {
l -= Math.PI * sign(x) * sign(cy);
}
return [
(l / n) / deg2rad,
(2 * Math.atan(Math.pow(c / rho, 1 / n)) - halfPI) / deg2rad
];
};
return LambertConformalConic;
}());
export default LambertConformalConic;

View File

@@ -0,0 +1,29 @@
/* *
* Miller projection
* */
'use strict';
var quarterPI = Math.PI / 4, deg2rad = Math.PI / 180, scale = 63.78137;
var Miller = /** @class */ (function () {
function Miller() {
this.bounds = {
x1: -200.37508342789243,
x2: 200.37508342789243,
y1: -146.91480769173063,
y2: 146.91480769173063
};
}
Miller.prototype.forward = function (lonLat) {
return [
lonLat[0] * deg2rad * scale,
1.25 * scale * Math.log(Math.tan(quarterPI + 0.4 * lonLat[1] * deg2rad))
];
};
Miller.prototype.inverse = function (xy) {
return [
(xy[0] / scale) / deg2rad,
2.5 * (Math.atan(Math.exp(0.8 * (xy[1] / scale))) - quarterPI) / deg2rad
];
};
return Miller;
}());
export default Miller;

View File

@@ -0,0 +1,37 @@
/* *
* Orthographic projection
* */
'use strict';
var deg2rad = Math.PI / 180, scale = 63.78460826781007;
var Orthographic = /** @class */ (function () {
function Orthographic() {
this.antimeridianCutting = false;
this.bounds = {
x1: -scale,
x2: scale,
y1: -scale,
y2: scale
};
}
Orthographic.prototype.forward = function (lonLat) {
var lonDeg = lonLat[0], latDeg = lonLat[1];
var lat = latDeg * deg2rad;
var xy = [
Math.cos(lat) * Math.sin(lonDeg * deg2rad) * scale,
Math.sin(lat) * scale
];
if (lonDeg < -90 || lonDeg > 90) {
xy.outside = true;
}
return xy;
};
Orthographic.prototype.inverse = function (xy) {
var x = xy[0] / scale, y = xy[1] / scale, z = Math.sqrt(x * x + y * y), c = Math.asin(z), cSin = Math.sin(c), cCos = Math.cos(c);
return [
Math.atan2(x * cSin, z * cCos) / deg2rad,
Math.asin(z && y * cSin / z) / deg2rad
];
};
return Orthographic;
}());
export default Orthographic;

View File

@@ -0,0 +1,19 @@
/* *
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
'use strict';
import LambertConformalConic from './LambertConformalConic.js';
import EqualEarth from './EqualEarth.js';
import Miller from './Miller.js';
import Orthographic from './Orthographic.js';
import WebMercator from './WebMercator.js';
var registry = {
EqualEarth: EqualEarth,
LambertConformalConic: LambertConformalConic,
Miller: Miller,
Orthographic: Orthographic,
WebMercator: WebMercator
};
export default registry;

View File

@@ -0,0 +1,36 @@
/* *
* Web Mercator projection, used for most online map tile services
* */
'use strict';
var maxLatitude = 85.0511287798, // The latitude that defines a square
r = 63.78137, deg2rad = Math.PI / 180;
var WebMercator = /** @class */ (function () {
function WebMercator() {
this.bounds = {
x1: -200.37508342789243,
x2: 200.37508342789243,
y1: -200.3750834278071,
y2: 200.3750834278071
};
this.maxLatitude = maxLatitude;
}
WebMercator.prototype.forward = function (lonLat) {
var sinLat = Math.sin(lonLat[1] * deg2rad);
var xy = [
r * lonLat[0] * deg2rad,
r * Math.log((1 + sinLat) / (1 - sinLat)) / 2
];
if (Math.abs(lonLat[1]) > maxLatitude) {
xy.outside = true;
}
return xy;
};
WebMercator.prototype.inverse = function (xy) {
return [
xy[0] / (r * deg2rad),
(2 * Math.atan(Math.exp(xy[1] / r)) - (Math.PI / 2)) / deg2rad
];
};
return WebMercator;
}());
export default WebMercator;