Special steps need to be taken when the source projection canWrapX().
Some of the calculated triangles can happen to be crossing the "dateline" (some vertices are x-negative and some are x-positive) (e.g. [175, 0], [-170, 0], [-160, 1] in EPSG:4326).
Without detecting and solving this, the reprojection process loads all the tiles from -170 to 175 and renders them into the triangle (they end up being mirrored).
To solve this, the triangulation process detects this and remembers that this triangle needs to be "shifted" during reprojection (by the width of the projection extent). The affine transformation is calculated in shifted space: x = goog.math.modulo(x, shiftDistance). For some of the input files, the drawImage call is then shifted back to properly combine tiles from both sides of the dateline. This is also taken into account when calculating the source extent of the triangulation.
Special steps need to be taken when the source projection
canWrapX()
. Some of the calculated triangles can happen to be crossing the "dateline" (some vertices are x-negative and some are x-positive) (e.g.[175, 0], [-170, 0], [-160, 1]
in EPSG:4326).Without detecting and solving this, the reprojection process loads all the tiles from -170 to 175 and renders them into the triangle (they end up being mirrored).
To solve this, the triangulation process detects this and remembers that this triangle needs to be "shifted" during reprojection (by the width of the projection extent). The affine transformation is calculated in shifted space:
x = goog.math.modulo(x, shiftDistance)
. For some of the input files, thedrawImage
call is then shifted back to properly combine tiles from both sides of the dateline. This is also taken into account when calculating the source extent of the triangulation.