diff --git a/packages/deck.gl-raster/src/raster-layer.ts b/packages/deck.gl-raster/src/raster-layer.ts index f1bd37b3..c635fae9 100644 --- a/packages/deck.gl-raster/src/raster-layer.ts +++ b/packages/deck.gl-raster/src/raster-layer.ts @@ -79,6 +79,22 @@ export interface RasterLayerProps extends CompositeLayerProps { */ maxError?: number; + /** + * Minimum V (top edge) of the mesh in UV space [0, 1]. + * Use to exclude rows at the top of the tile from meshing + * (e.g. when the tile touches lat +90° and the projection is undefined). + * @default 0 + */ + _vMin?: number; + + /** + * Maximum V (bottom edge) of the mesh in UV space [0, 1]. + * Use to exclude rows at the bottom of the tile from meshing + * (e.g. when the tile touches lat -90° and the projection is undefined). + * @default 1 + */ + _vMax?: number; + /** If set, enables debug mode for visualizing the mesh and reprojection process. */ debug?: boolean; @@ -141,6 +157,8 @@ export class RasterLayer extends CompositeLayer { height, reprojectionFns, maxError = DEFAULT_MAX_ERROR, + _vMin, + _vMax, } = this.props; // The mesh is lined up with the upper and left edges of the raster. So if @@ -154,6 +172,7 @@ export class RasterLayer extends CompositeLayer { reprojectionFns, width + 1, height + 1, + { _vMin, _vMax }, ); reprojector.run(maxError); const { indices, positions, texCoords } = reprojectorToMesh(reprojector); diff --git a/packages/raster-reproject/src/delatin.ts b/packages/raster-reproject/src/delatin.ts index cae56d90..8ca6d977 100644 --- a/packages/raster-reproject/src/delatin.ts +++ b/packages/raster-reproject/src/delatin.ts @@ -112,6 +112,7 @@ export class RasterReprojector { reprojectors: ReprojectionFns, width: number, height: number = width, + { _vMin = 0, _vMax = 1 }: { _vMin?: number; _vMax?: number } = {}, ) { this.reprojectors = reprojectors; this.width = width; @@ -131,12 +132,14 @@ export class RasterReprojector { this._pending = []; // triangles pending addition to queue this._pendingLen = 0; - // The two initial triangles cover the entire input texture in UV space, so - // they range from [0, 0] to [1, 1] in u and v. + // The two initial triangles cover the input texture UV space. + // _vMin/_vMax allow callers to exclude rows at the top/bottom edges + // (e.g. to avoid polar singularities when the tile touches lat ±90°). const u1 = 1; - const v1 = 1; - const p0 = this._addPoint(0, 0); - const p1 = this._addPoint(u1, 0); + const v0 = _vMin; + const v1 = _vMax; + const p0 = this._addPoint(0, v0); + const p1 = this._addPoint(u1, v0); const p2 = this._addPoint(0, v1); const p3 = this._addPoint(u1, v1);