Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/Main/src/Source/CogSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ type CogSourceConfig = {
* An optional decoder pool to use when extracting data from a COG image.
*/
pool?: GeoTIFF.Pool;
/**
* Zoom level bounds for this source. Limits which tile zoom levels will
* request data from this COG. Required when used as an ElevationLayer
* source, since the tile system reads `source.zoom.max` to determine
* maximum subdivision depth.
*/
zoom?: { min: number, max: number };
[key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
}

Expand Down Expand Up @@ -61,6 +68,7 @@ class CogSource extends Source {
defaultAlpha: number;
resampleMethod: string;
pool: GeoTIFF.Pool;
zoom: { min: number, max: number };

/**
* @param config - Source configuration.
Expand All @@ -70,6 +78,7 @@ class CogSource extends Source {
pool = new GeoTIFF.Pool(),
defaultAlpha = 255,
resampleMethod = 'nearest',
zoom = { min: 0, max: Infinity },
...sourceConfig
} = config;

Expand All @@ -83,6 +92,7 @@ class CogSource extends Source {
this.defaultAlpha = defaultAlpha;
this.pool = pool;
this.resampleMethod = resampleMethod;
this.zoom = zoom;

this.overviews = [];

Expand Down Expand Up @@ -126,8 +136,9 @@ class CogSource extends Source {
});
}

extentInsideLimit(extent: Extent) {
return this.extent.intersectsExtent(extent);
extentInsideLimit(extent: Extent, zoom: number) {
return zoom >= this.zoom.min && zoom <= this.zoom.max
&& this.extent.intersectsExtent(extent);
}

urlFromExtent() {
Expand Down
Loading