agdar/static/plugins/d3/src/geo/conic-equidistant.js
2025-11-02 14:35:35 +03:00

37 lines
817 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import "../math/abs";
import "../math/trigonometry";
import "conic";
import "equirectangular";
import "geo";
import "projection";
function d3_geo_conicEquidistant(φ0, φ1) {
var cosφ0 = Math.cos(φ0),
n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0),
G = cosφ0 / n + φ0;
if (abs(n) < ε) return d3_geo_equirectangular;
function forward(λ, φ) {
var ρ = G - φ;
return [
ρ * Math.sin(n * λ),
G - ρ * Math.cos(n * λ)
];
}
forward.invert = function(x, y) {
var ρ0_y = G - y;
return [
Math.atan2(x, ρ0_y) / n,
G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y)
];
};
return forward;
}
(d3.geo.conicEquidistant = function() {
return d3_geo_conic(d3_geo_conicEquidistant);
}).raw = d3_geo_conicEquidistant;