Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Avoid generating coincident points.

This was breaking antemeridian clipping in some rare cases where a point
was coincident with the antemeridian.
  • Loading branch information...
commit d2d4d6292ec211807bd84fd52cf3ca8c7015c6b5 1 parent 110f7db
@jasondavies jasondavies authored
Showing with 16 additions and 13 deletions.
  1. +6 −5 d3.v2.js
  2. +3 −3 d3.v2.min.js
  3. +7 −5 src/geo/projection.js
View
11 d3.v2.js
@@ -2314,10 +2314,11 @@
1 = λ1 > 0 ? π : -π;
if (sλ0 !==1 && Math.abs1 - λ0) >= π) {
φ0 = d3_geo_projectionIntersectAntemeridian(λ0, φ0, λ1, φ1);
- context.lineTo(sλ0, φ0);
- context.moveTo(sλ1, φ0);
+ if (Math.abs0 -0) > ε) context.lineTo(sλ0, φ0);
+ if (Math.abs1 -1) > ε) context.moveTo(sλ1, φ0), context.lineTo(λ0 = λ1, φ0 = φ1); else context.moveTo0 = λ1, φ0 = φ1);
+ } else {
+ context.lineTo(λ0 = λ1, φ0 = φ1);
}
- context.lineTo(λ0 = λ1, φ0 = φ1);
0 =1;
}
},
@@ -2328,13 +2329,13 @@
return clip;
}
function d3_geo_antemeridianAngle(point) {
- return point[0] > 0 ? point[1] + π / 2 : -π / 2 - point[1];
+ return -(point[0] < 0 ? point[1] - π / 2 : π / 2 - point[1]);
}
function d3_geo_antemeridianInterpolate(from, to, context) {
from = from.point;
to = to.point;
if (from[0] !== to[0]) {
- var s = from[0] > to[0] ? -π : π, φ = s / 2;
+ var s = from[0] < to[0] ? π : -π, φ = s / 2;
context.lineTo(-s, φ);
context.lineTo(0, φ);
context.lineTo(s, φ);
View
6 d3.v2.min.js
3 additions, 3 deletions not shown
View
12 src/geo/projection.js
@@ -206,10 +206,12 @@ function d3_geo_projectionCutAntemeridian(rotatePoint) {
1 = λ1 > 0 ? π : -π;
if (sλ0 !==1 && Math.abs1 - λ0) >= π) {
φ0 = d3_geo_projectionIntersectAntemeridian(λ0, φ0, λ1, φ1);
- context.lineTo(sλ0, φ0);
- context.moveTo(sλ1, φ0);
+ if (Math.abs0 -0) > ε) context.lineTo(sλ0, φ0);
+ if (Math.abs1 -1) > ε) context.moveTo(sλ1, φ0), context.lineTo(λ0 = λ1, φ0 = φ1);
+ else context.moveTo0 = λ1, φ0 = φ1);
+ } else {
+ context.lineTo(λ0 = λ1, φ0 = φ1);
}
- context.lineTo(λ0 = λ1, φ0 = φ1);
0 =1;
}
},
@@ -221,14 +223,14 @@ function d3_geo_projectionCutAntemeridian(rotatePoint) {
}
function d3_geo_antemeridianAngle(point) {
- return point[0] > 0 ? point[1] + π / 2 : -π / 2 - point[1];
+ return -(point[0] < 0 ? point[1] - π / 2 : π / 2 - point[1]);
}
function d3_geo_antemeridianInterpolate(from, to, context) {
from = from.point;
to = to.point;
if (from[0] !== to[0]) {
- var s = from[0] > to[0] ? -π : π,
+ var s = from[0] < to[0] ? π : -π,
φ = s / 2;
context.lineTo(-s, φ);
context.lineTo( 0, φ);
Please sign in to comment.
Something went wrong with that request. Please try again.