maplibre-gl-raster 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18232,6 +18232,26 @@ function deriveLayerName(source) {
18232
18232
  /** Default engine when none is configured: the deck.gl GPU pipeline. */
18233
18233
  var DEFAULT_ENGINE = "maplibre-gl-raster";
18234
18234
  /**
18235
+ * Clamps a bounds' latitudes to the valid WGS84 range. GeoTIFF bounds are
18236
+ * derived as `origin + n * pixelSize`, so a global raster whose pixel size was
18237
+ * stored rounded (e.g. GEBCO's 1/240° stored as 0.004166666666667) can
18238
+ * overshoot the poles by a floating-point epsilon — and MapLibre's LngLat
18239
+ * rejects any latitude outside [-90, 90], crashing fitBounds. Longitudes are
18240
+ * left alone: MapLibre accepts any longitude, and clamping would corrupt
18241
+ * antimeridian-crossing rasters.
18242
+ */
18243
+ function clampBoundsLatitude(bounds) {
18244
+ const clamp = (lat) => Math.min(90, Math.max(-90, lat));
18245
+ const south = clamp(bounds.south);
18246
+ const north = clamp(bounds.north);
18247
+ if (south === bounds.south && north === bounds.north) return bounds;
18248
+ return {
18249
+ ...bounds,
18250
+ south,
18251
+ north
18252
+ };
18253
+ }
18254
+ /**
18235
18255
  * The band indexes a layer actually samples, deduped and sorted. Mirrors the
18236
18256
  * `requested` logic in render-pipeline's buildRenderTile: RGB samples the first
18237
18257
  * three entries (R, G, B); single-band / colormap / palette the first one. The
@@ -18700,10 +18720,10 @@ var LayerManager = class {
18700
18720
  const layer = this.getLayer(id);
18701
18721
  if (!layer) return;
18702
18722
  const boundsArrived = !layer.bounds;
18703
- layer.bounds = bounds;
18723
+ layer.bounds = clampBoundsLatitude(bounds);
18704
18724
  if (zoomTo && layer.zoomTo) {
18705
18725
  layer.zoomTo = false;
18706
- this._fitBounds(bounds);
18726
+ this._fitBounds(layer.bounds);
18707
18727
  }
18708
18728
  if (boundsArrived) this._emit({
18709
18729
  type: "rasterchange",
@@ -18823,7 +18843,7 @@ var LayerManager = class {
18823
18843
  }),
18824
18844
  onGeoTIFFLoad: (_tiff, options) => {
18825
18845
  const boundsArrived = !layer.bounds;
18826
- layer.bounds = options.geographicBounds;
18846
+ layer.bounds = clampBoundsLatitude(options.geographicBounds);
18827
18847
  if (layer.zoomTo) {
18828
18848
  layer.zoomTo = false;
18829
18849
  this._fitBounds(layer.bounds);
@@ -21430,4 +21450,4 @@ var RasterControl = class {
21430
21450
  //#endregion
21431
21451
  export { statsForBand as A, COLORMAP_NAMES as C, colormaps_default as D, colormapDisplayName as E, createResilientEpsgResolver as F, computeAutoStats as M, percentileFromHistogram as N, DEFAULT_INDEX_RANGE as O, readBandNames as P, COLORMAP_DISPLAY_NAMES as S, COLORMAP_ROW_COUNT as T, debounce as _, NORMALIZED_DIFFERENCE_INDICES as a, throttle as b, readPixelValues as c, PALETTE_COLORMAP as d, isKnownColormap as f, classNames as g, clamp as h, CUSTOM_NORMALIZED_DIFFERENCE as i, MAX_SAMPLE_TILES as j, autoRangeFor as k, DEFAULT_ENGINE as l, sampleColormapStops as m, Colorbar as n, guessBandForRole as o, loadColormapSprite as p, CUSTOM_INDEX_ID as r, indexById as s, RasterControl as t, LayerManager as u, formatNumericValue as v, COLORMAP_OPTIONS as w, loadGeoTIFF as x, generateId as y };
21432
21452
 
21433
- //# sourceMappingURL=RasterControl-BfTDWAnW.js.map
21453
+ //# sourceMappingURL=RasterControl-B2cGQaYt.js.map