Commit defe5bc8 authored by Mike Bostock's avatar Mike Bostock
Browse files

Clamp latitude for conic conformal projection.

The Lambert conic conformal projection extends to infinity along the outer edge
of the projection, and thus the latitude must be clamped either at -π/2 or +π/2
depending on the parallels. Fixes #1802.
parent 2b148070
......@@ -4600,7 +4600,12 @@
}, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n;
if (!n) return d3_geo_mercator;
function forward(λ, φ) {
var ρ = abs(abs(φ) - halfπ) < ε ? 0 : F / Math.pow(t(φ), n);
if (F > 0) {
if (φ < -halfπ + ε) φ = -halfπ + ε;
} else {
if (φ > halfπ - ε) φ = halfπ - ε;
}
var ρ = F / Math.pow(t(φ), n);
return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ];
}
forward.invert = function(x, y) {
......
This diff is collapsed.
......@@ -13,7 +13,9 @@ function d3_geo_conicConformal(φ0, φ1) {
if (!n) return d3_geo_mercator;
function forward(λ, φ) {
var ρ = abs(abs(φ) - halfπ) < ε ? 0 : F / Math.pow(t(φ), n);
if (F > 0) { if (φ < -halfπ + ε) φ = -halfπ + ε; }
else { if (φ > halfπ - ε) φ = halfπ - ε; }
var ρ = F / Math.pow(t(φ), n);
return [
ρ * Math.sin(n * λ),
F - ρ * Math.cos(n * λ)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment