Skip to content

Commit

Permalink
Handle the zoomed out case where the source extent is infinite. This
Browse files Browse the repository at this point in the history
does raise the question of whether an Infinite extent intersects a
finite extent. It appears not to, but maybe it should.
  • Loading branch information
pjsg committed Dec 28, 2019
1 parent 4040d03 commit f457093
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions src/ol/reproj/Triangulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,19 @@ class Triangulation {
}

if (!needsSubdivision && this.maxSourceExtent_) {
if (!intersects(sourceQuadExtent, this.maxSourceExtent_)) {
// whole quad outside source projection extent -> ignore
return;
if (isFinite(sourceQuadExtent[0]) &&
isFinite(sourceQuadExtent[1]) &&
isFinite(sourceQuadExtent[2]) &&
isFinite(sourceQuadExtent[3])) {
if (!intersects(sourceQuadExtent, this.maxSourceExtent_)) {
// whole quad outside source projection extent -> ignore
return;
}
}
}

let isNotFinite = 0;

if (!needsSubdivision) {
if (!isFinite(aSrc[0]) || !isFinite(aSrc[1]) ||
!isFinite(bSrc[0]) || !isFinite(bSrc[1]) ||
Expand All @@ -261,7 +268,16 @@ class Triangulation {
if (maxSubdivision > 0) {
needsSubdivision = true;
} else {
return;
// It might be the case that only 1 of the points is infinite. In this case
// we can draw a single triangle with the other three points
isNotFinite =
(((!isFinite(aSrc[0]) || !isFinite(aSrc[1])) | 0) << 3) +
(((!isFinite(bSrc[0]) || !isFinite(bSrc[1])) | 0) << 2) +
(((!isFinite(cSrc[0]) || !isFinite(cSrc[1])) | 0) << 1) +
((!isFinite(dSrc[0]) || !isFinite(dSrc[1])) | 0);
if (isNotFinite != 1 && isNotFinite != 2 && isNotFinite != 4 && isNotFinite != 8) {
return;
}
}
}
}
Expand Down Expand Up @@ -320,8 +336,22 @@ class Triangulation {
this.wrapsXInSource_ = true;
}

this.addTriangle_(a, c, d, aSrc, cSrc, dSrc);
this.addTriangle_(a, c, b, aSrc, cSrc, bSrc);
// Exactly zero or one of *Src is not finite
if ((isNotFinite & 0xb) == 0) {
this.addTriangle_(a, c, d, aSrc, cSrc, dSrc);
}
if ((isNotFinite & 0xe) == 0) {
this.addTriangle_(a, c, b, aSrc, cSrc, bSrc);
}
if (isNotFinite) {
// Try the other two triangles
if ((isNotFinite & 0xd) == 0) {
this.addTriangle_(b, d, a, bSrc, dSrc, aSrc);
}
if ((isNotFinite & 0x7) == 0) {
this.addTriangle_(b, d, c, bSrc, dSrc, cSrc);
}
}
}

/**
Expand Down

0 comments on commit f457093

Please sign in to comment.