maplibre-gl-raster 0.8.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);
|
|
@@ -19136,8 +19156,8 @@ var PixelInspector = class {
|
|
|
19136
19156
|
//#region src/lib/ui/AddDataSection.ts
|
|
19137
19157
|
/**
|
|
19138
19158
|
* "Add data" section: URL input + Load button, plus a drop zone that accepts
|
|
19139
|
-
* `.tif` / `.tiff` files via click-to-browse
|
|
19140
|
-
* cog-viewer's EmptyState.
|
|
19159
|
+
* one or more `.tif` / `.tiff` files via click-to-browse (multi-select) or
|
|
19160
|
+
* drag-and-drop. Ported from cog-viewer's EmptyState.
|
|
19141
19161
|
*/
|
|
19142
19162
|
var AddDataSection = class {
|
|
19143
19163
|
/** Root element to insert into the panel. */
|
|
@@ -19149,6 +19169,11 @@ var AddDataSection = class {
|
|
|
19149
19169
|
*/
|
|
19150
19170
|
constructor(options) {
|
|
19151
19171
|
const isTiff = (file) => /\.tiff?$/i.test(file.name);
|
|
19172
|
+
const addFiles = (files) => {
|
|
19173
|
+
if (!files) return;
|
|
19174
|
+
const beforeId = currentBeforeId();
|
|
19175
|
+
for (const file of Array.from(files)) if (isTiff(file)) options.onAddFile(file, beforeId);
|
|
19176
|
+
};
|
|
19152
19177
|
const input = el("input", {
|
|
19153
19178
|
className: "mlr-input",
|
|
19154
19179
|
type: "text",
|
|
@@ -19250,17 +19275,19 @@ var AddDataSection = class {
|
|
|
19250
19275
|
const fileInput = el("input", {
|
|
19251
19276
|
type: "file",
|
|
19252
19277
|
ariaLabel: "raster-file",
|
|
19253
|
-
attrs: {
|
|
19278
|
+
attrs: {
|
|
19279
|
+
accept: ".tif,.tiff",
|
|
19280
|
+
multiple: ""
|
|
19281
|
+
}
|
|
19254
19282
|
});
|
|
19255
19283
|
fileInput.style.display = "none";
|
|
19256
19284
|
fileInput.addEventListener("change", () => {
|
|
19257
|
-
|
|
19258
|
-
if (f && isTiff(f)) options.onAddFile(f, currentBeforeId());
|
|
19285
|
+
addFiles(fileInput.files);
|
|
19259
19286
|
fileInput.value = "";
|
|
19260
19287
|
});
|
|
19261
19288
|
const dropZone = el("div", {
|
|
19262
19289
|
className: "mlr-drop-zone",
|
|
19263
|
-
text: "Drop
|
|
19290
|
+
text: "Drop .tif files here, or click to browse",
|
|
19264
19291
|
attrs: {
|
|
19265
19292
|
role: "button",
|
|
19266
19293
|
tabindex: "0"
|
|
@@ -19283,8 +19310,7 @@ var AddDataSection = class {
|
|
|
19283
19310
|
dropZone.addEventListener("drop", (e) => {
|
|
19284
19311
|
e.preventDefault();
|
|
19285
19312
|
dropZone.classList.remove("dragover");
|
|
19286
|
-
|
|
19287
|
-
if (f && isTiff(f)) options.onAddFile(f, currentBeforeId());
|
|
19313
|
+
addFiles(e.dataTransfer?.files);
|
|
19288
19314
|
});
|
|
19289
19315
|
this.el = el("div", { className: "mlr-section mlr-add-data" }, el("div", {
|
|
19290
19316
|
className: "mlr-section-title",
|
|
@@ -21424,4 +21450,4 @@ var RasterControl = class {
|
|
|
21424
21450
|
//#endregion
|
|
21425
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 };
|
|
21426
21452
|
|
|
21427
|
-
//# sourceMappingURL=RasterControl-
|
|
21453
|
+
//# sourceMappingURL=RasterControl-B2cGQaYt.js.map
|