devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
72 lines (70 loc) • 2.51 kB
JavaScript
/**
* DevExtreme (cjs/viz/vector_map/projection.js)
* Version: 25.1.3
* Build date: Wed Jun 25 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "projection", {
enumerable: true,
get: function() {
return _projection.projection
}
});
var _projection = require("./projection.main");
const _min = Math.min;
const _max = Math.max;
const _sin = Math.sin;
const _asin = Math.asin;
const _tan = Math.tan;
const _atan = Math.atan;
const _exp = Math.exp;
const _log = Math.log;
const PI = Math.PI;
const PI_DIV_4 = PI / 4;
const GEO_LON_BOUND = 180;
const GEO_LAT_BOUND = 90;
const RADIANS = PI / 180;
const MERCATOR_LAT_BOUND = (2 * _atan(_exp(PI)) - PI / 2) / RADIANS;
const MILLER_LAT_BOUND = (2.5 * _atan(_exp(.8 * PI)) - .625 * PI) / RADIANS;
function clamp(value, threshold) {
return _max(_min(value, +threshold), -threshold)
}
_projection.projection.add("mercator", (0, _projection.projection)({
aspectRatio: 1,
to: function(coordinates) {
return [coordinates[0] / 180, _log(_tan(PI_DIV_4 + clamp(coordinates[1], MERCATOR_LAT_BOUND) * RADIANS / 2)) / PI]
},
from: function(coordinates) {
return [180 * coordinates[0], (2 * _atan(_exp(coordinates[1] * PI)) - PI / 2) / RADIANS]
}
}));
_projection.projection.add("equirectangular", (0, _projection.projection)({
aspectRatio: 2,
to: function(coordinates) {
return [coordinates[0] / 180, coordinates[1] / 90]
},
from: function(coordinates) {
return [180 * coordinates[0], 90 * coordinates[1]]
}
}));
_projection.projection.add("lambert", (0, _projection.projection)({
aspectRatio: 2,
to: function(coordinates) {
return [coordinates[0] / 180, _sin(clamp(coordinates[1], 90) * RADIANS)]
},
from: function(coordinates) {
return [180 * coordinates[0], _asin(clamp(coordinates[1], 1)) / RADIANS]
}
}));
_projection.projection.add("miller", (0, _projection.projection)({
aspectRatio: 1,
to: function(coordinates) {
return [coordinates[0] / 180, 1.25 * _log(_tan(PI_DIV_4 + clamp(coordinates[1], MILLER_LAT_BOUND) * RADIANS * .4)) / PI]
},
from: function(coordinates) {
return [180 * coordinates[0], (2.5 * _atan(_exp(.8 * coordinates[1] * PI)) - .625 * PI) / RADIANS]
}
}));