maplibre-gl-raster 0.5.0 → 0.6.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.
@@ -2646,7 +2646,7 @@ var SourceMemory = class SourceMemory {
2646
2646
  //#region node_modules/@developmentseed/geotiff/dist/crs.js
2647
2647
  var PROJJSON_SCHEMA = "https://proj.org/schemas/v0.7/projjson.schema.json";
2648
2648
  var MODEL_TYPE_PROJECTED$1 = 1;
2649
- var MODEL_TYPE_GEOGRAPHIC = 2;
2649
+ var MODEL_TYPE_GEOGRAPHIC$1 = 2;
2650
2650
  var USER_DEFINED$1 = 32767;
2651
2651
  var CT_TRANSVERSE_MERCATOR = 1;
2652
2652
  var CT_TRANSVERSE_MERCATOR_SOUTH = 2;
@@ -2701,7 +2701,7 @@ var LINEAR_UNIT = {
2701
2701
  function crsFromGeoKeys(gkd) {
2702
2702
  const modelType = gkd.modelType;
2703
2703
  if (modelType === MODEL_TYPE_PROJECTED$1) return _projectedCrs(gkd);
2704
- if (modelType === MODEL_TYPE_GEOGRAPHIC) return _geographicCrs(gkd);
2704
+ if (modelType === MODEL_TYPE_GEOGRAPHIC$1) return _geographicCrs(gkd);
2705
2705
  throw new Error(`Unsupported GeoTIFF model type: ${modelType}`);
2706
2706
  }
2707
2707
  function _geographicCrs(gkd) {
@@ -4555,8 +4555,10 @@ var COLORMAP_OPTIONS = COLORMAP_NAMES.map((name) => ({
4555
4555
  //#endregion
4556
4556
  //#region src/lib/raster/repair-geokeys.ts
4557
4557
  var MODEL_TYPE_PROJECTED = 1;
4558
+ var MODEL_TYPE_GEOGRAPHIC = 2;
4558
4559
  var USER_DEFINED = 32767;
4559
4560
  var EPSG_WEB_MERCATOR = 3857;
4561
+ var WKT_ROOT = /\b(?:PROJCS|PROJCRS|GEOGCS|GEOGCRS|GEOCCS|GEODCRS|BOUNDCRS|COMPD_CS|COMPOUNDCRS|VERT_CS|VERTCRS|LOCAL_CS|FITTED_CS)\s*\[/i;
4560
4562
  var WEB_MERCATOR_ALIASES = new Set([
4561
4563
  3785,
4562
4564
  900913,
@@ -4572,6 +4574,26 @@ function citationText(gkd) {
4572
4574
  ].filter((value) => typeof value === "string").join(" ");
4573
4575
  }
4574
4576
  /**
4577
+ * Pull an embedded WKT (or ESRI PE string) definition out of a citation geo
4578
+ * key, if one is present. The projected citation is preferred because that is
4579
+ * where ArcGIS writes the full `PROJCS[...]` for an exotic projection; the
4580
+ * generic and geodetic citations are checked as fallbacks. Returns the WKT from
4581
+ * the first matching root keyword onward (dropping any `ESRI PE String = `
4582
+ * prefix), or `null` when no citation carries one.
4583
+ */
4584
+ function wktFromCitation(gkd) {
4585
+ for (const citation of [
4586
+ gkd.projectedCitation,
4587
+ gkd.citation,
4588
+ gkd.geodeticCitation
4589
+ ]) {
4590
+ if (typeof citation !== "string") continue;
4591
+ const match = WKT_ROOT.exec(citation);
4592
+ if (match) return citation.slice(match.index);
4593
+ }
4594
+ return null;
4595
+ }
4596
+ /**
4575
4597
  * Repair GeoTIFF CRS geo keys so {@link import('@developmentseed/geotiff').Overview.crs}
4576
4598
  * resolves them to the right projection, in place. Two problems are fixed:
4577
4599
  *
@@ -4598,6 +4620,15 @@ function citationText(gkd) {
4598
4620
  * untouched. Must run before any `Overview.crs` access (which caches its
4599
4621
  * result), so callers invoke it immediately after opening the GeoTIFF.
4600
4622
  *
4623
+ * 3. **A projection the geo keys cannot express.** Some projections have no
4624
+ * `ProjCoordTransGeoKey` (e.g. equal-area world CRSes such as ESRI:54009
4625
+ * World Mollweide), so ArcGIS/GDAL leave the model type user-defined and the
4626
+ * full definition only in the citation as an `ESRI PE String = PROJCS[...]`
4627
+ * WKT. `crsFromGeoKeys` then throws `Unsupported GeoTIFF model type: 32767`.
4628
+ * {@link recoverCrsFromWktCitation} seeds the cached CRS from that WKT so the
4629
+ * consuming layer (which calls `parseWkt`/proj4) builds the projection from
4630
+ * it. This is projection-agnostic: proj4 understands the ESRI/OGC names.
4631
+ *
4601
4632
  * @param tiff - The opened GeoTIFF to repair in place.
4602
4633
  */
4603
4634
  function repairUserDefinedProjectedCrs(tiff) {
@@ -4608,6 +4639,30 @@ function repairUserDefinedProjectedCrs(tiff) {
4608
4639
  else if (projectedIsUserDefined && gkd.projMethod !== null && WEB_MERCATOR_CITATION.test(citationText(gkd))) gkd.projectedCRS = EPSG_WEB_MERCATOR;
4609
4640
  if ((gkd.modelType === null || gkd.modelType === USER_DEFINED) && gkd.projMethod !== null) gkd.modelType = MODEL_TYPE_PROJECTED;
4610
4641
  }
4642
+ recoverCrsFromWktCitation(tiff);
4643
+ }
4644
+ /**
4645
+ * Seed the GeoTIFF's cached CRS from an embedded WKT citation when the geo keys
4646
+ * still cannot describe the projection after {@link repairUserDefinedProjectedCrs}
4647
+ * has run. `crsFromGeoKeys` only accepts model type 1 (projected) or 2
4648
+ * (geographic) and throws otherwise; when the model type is still user-defined
4649
+ * (no `ProjMethodGeoKey` to promote it) the only definition is the WKT in the
4650
+ * citation. Setting the (lazily computed, single-shot) `_crs` cache to that WKT
4651
+ * string makes the getter return it instead of throwing, and the consuming layer
4652
+ * resolves it through `parseWkt` (wkt-parser + proj4).
4653
+ *
4654
+ * No-ops when the model type is resolvable, when the CRS is already cached, or
4655
+ * when no citation carries a WKT (so the original, descriptive error still
4656
+ * surfaces).
4657
+ */
4658
+ function recoverCrsFromWktCitation(tiff) {
4659
+ const gkd = tiff.overviews[0]?.gkd;
4660
+ if (!gkd) return;
4661
+ if (gkd.modelType === MODEL_TYPE_PROJECTED || gkd.modelType === MODEL_TYPE_GEOGRAPHIC) return;
4662
+ const wkt = wktFromCitation(gkd);
4663
+ if (!wkt) return;
4664
+ const cache = tiff;
4665
+ if (cache._crs === void 0) cache._crs = wkt;
4611
4666
  }
4612
4667
  //#endregion
4613
4668
  //#region src/lib/raster/load-geotiff.ts
@@ -19568,6 +19623,11 @@ var SettingsSection = class {
19568
19623
  this._inspectBtn.classList.toggle("active", active);
19569
19624
  this._inspectBtn.setAttribute("aria-pressed", String(active));
19570
19625
  }
19626
+ /** Public hook to re-sync the inspect button after the host toggles inspect
19627
+ * mode programmatically (e.g. via RasterControl.setInspect). */
19628
+ syncInspect() {
19629
+ this._syncInspectButton();
19630
+ }
19571
19631
  /** Reacts to a LayerManager change event: rebuilds unless the change came
19572
19632
  * from this UI or a histogram drag is active (deferred until drag end). */
19573
19633
  notifyChange() {
@@ -20080,6 +20140,10 @@ var PanelUI = class {
20080
20140
  this._renderList();
20081
20141
  this._settings.render();
20082
20142
  }
20143
+ /** Reflects an externally-toggled inspect mode on the Settings inspect button. */
20144
+ syncInspect() {
20145
+ this._settings.syncInspect();
20146
+ }
20083
20147
  /** Detaches event handlers and removes the UI from the DOM. */
20084
20148
  destroy() {
20085
20149
  for (const off of this._unsubscribe) off();
@@ -20586,6 +20650,28 @@ var RasterControl = class {
20586
20650
  this._layerManager?.select(id);
20587
20651
  }
20588
20652
  /**
20653
+ * Toggles pixel-inspect mode on or off — the same mode the panel's Inspect
20654
+ * button drives. While active, a map click reads the source band values of
20655
+ * the selected raster (see {@link selectRaster}) at that point and shows them
20656
+ * in a popup. Lets a host application offer inspection from its own UI.
20657
+ *
20658
+ * @param enabled - `true` to start inspecting, `false` to stop
20659
+ */
20660
+ setInspect(enabled) {
20661
+ if (!this._inspector) return;
20662
+ if (enabled) this._inspector.enable();
20663
+ else this._inspector.disable();
20664
+ this._panelUI?.syncInspect();
20665
+ }
20666
+ /**
20667
+ * Whether pixel-inspect mode is currently active.
20668
+ *
20669
+ * @returns `true` while inspecting
20670
+ */
20671
+ isInspecting() {
20672
+ return this._inspector?.enabled ?? false;
20673
+ }
20674
+ /**
20589
20675
  * Gets the active rendering engine.
20590
20676
  *
20591
20677
  * @returns The current engine, or the configured default before the control
@@ -20958,6 +21044,6 @@ var RasterControl = class {
20958
21044
  }
20959
21045
  };
20960
21046
  //#endregion
20961
- export { computeAutoStats as C, createResilientEpsgResolver as E, MAX_SAMPLE_TILES as S, readBandNames as T, COLORMAP_ROW_COUNT as _, loadColormapSprite as a, autoRangeFor as b, classNames as c, generateId as d, throttle as f, COLORMAP_OPTIONS as g, COLORMAP_NAMES as h, isKnownColormap as i, debounce as l, COLORMAP_DISPLAY_NAMES as m, Colorbar as n, sampleColormapStops as o, loadGeoTIFF as p, PALETTE_COLORMAP as r, clamp as s, RasterControl as t, formatNumericValue as u, colormapDisplayName as v, percentileFromHistogram as w, statsForBand as x, colormaps_default as y };
21047
+ export { MAX_SAMPLE_TILES as C, createResilientEpsgResolver as D, readBandNames as E, statsForBand as S, percentileFromHistogram as T, COLORMAP_OPTIONS as _, isKnownColormap as a, colormaps_default as b, clamp as c, formatNumericValue as d, generateId as f, COLORMAP_NAMES as g, COLORMAP_DISPLAY_NAMES as h, PALETTE_COLORMAP as i, classNames as l, loadGeoTIFF as m, Colorbar as n, loadColormapSprite as o, throttle as p, readPixelValues as r, sampleColormapStops as s, RasterControl as t, debounce as u, COLORMAP_ROW_COUNT as v, computeAutoStats as w, autoRangeFor as x, colormapDisplayName as y };
20962
21048
 
20963
- //# sourceMappingURL=RasterControl-vzjXiCsa.js.map
21049
+ //# sourceMappingURL=RasterControl-CGsK4CN7.js.map