Handle the zoomed out case where the source extent is infinite. This

does raise the question of whether an Infinite extent intersects a
finite extent. It appears not to, but maybe it should.
This commit is contained in:
philip
2019-12-28 22:31:30 +00:00
parent 4040d03ae6
commit f457093baf
+30
View File
@@ -247,11 +247,18 @@ class Triangulation {
} }
if (!needsSubdivision && this.maxSourceExtent_) { if (!needsSubdivision && this.maxSourceExtent_) {
if (isFinite(sourceQuadExtent[0]) &&
isFinite(sourceQuadExtent[1]) &&
isFinite(sourceQuadExtent[2]) &&
isFinite(sourceQuadExtent[3])) {
if (!intersects(sourceQuadExtent, this.maxSourceExtent_)) { if (!intersects(sourceQuadExtent, this.maxSourceExtent_)) {
// whole quad outside source projection extent -> ignore // whole quad outside source projection extent -> ignore
return; return;
} }
} }
}
let isNotFinite = 0;
if (!needsSubdivision) { if (!needsSubdivision) {
if (!isFinite(aSrc[0]) || !isFinite(aSrc[1]) || if (!isFinite(aSrc[0]) || !isFinite(aSrc[1]) ||
@@ -261,10 +268,19 @@ class Triangulation {
if (maxSubdivision > 0) { if (maxSubdivision > 0) {
needsSubdivision = true; needsSubdivision = true;
} else { } else {
// 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; return;
} }
} }
} }
}
if (maxSubdivision > 0) { if (maxSubdivision > 0) {
if (!needsSubdivision) { if (!needsSubdivision) {
@@ -320,9 +336,23 @@ class Triangulation {
this.wrapsXInSource_ = true; this.wrapsXInSource_ = true;
} }
// Exactly zero or one of *Src is not finite
if ((isNotFinite & 0xb) == 0) {
this.addTriangle_(a, c, d, aSrc, cSrc, dSrc); this.addTriangle_(a, c, d, aSrc, cSrc, dSrc);
}
if ((isNotFinite & 0xe) == 0) {
this.addTriangle_(a, c, b, aSrc, cSrc, bSrc); 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);
}
}
}
/** /**
* Calculates extent of the 'source' coordinates from all the triangles. * Calculates extent of the 'source' coordinates from all the triangles.