maplibre-gl-raster 0.3.0 → 0.4.0

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.
package/README.md CHANGED
@@ -114,6 +114,7 @@ The main control class implementing MapLibre's `IControl` interface.
114
114
  | `interleaved` | `boolean` | `true` | Render the deck.gl overlay interleaved with the basemap layers |
115
115
  | `defaultUrl` | `string` | `''` | Prefills the Add data URL input (not loaded until the user clicks Load) |
116
116
  | `autoLoad` | `boolean` | `false` | Load `defaultUrl` automatically when the control is added to the map |
117
+ | `engine` | `RenderEngine` | `'maplibre-gl-raster'` | Initial rendering backend; switchable at runtime from the panel |
117
118
 
118
119
  #### Raster Methods
119
120
 
@@ -125,6 +126,7 @@ The main control class implementing MapLibre's `IControl` interface.
125
126
  - `selectRaster(id | null)` - Choose which layer the panel's settings edit
126
127
  - `zoomToRaster(id)` - Fit the map to a layer's bounds
127
128
  - `reorderRaster(id, toIndex)` - Move a layer in the draw order (0 = bottom)
129
+ - `getEngine()` / `setEngine(engine)` - Read / switch the rendering backend (see [Rendering engines](#rendering-engines))
128
130
 
129
131
  `addRaster` options (`AddRasterOptions`): `id`, `name`, `state` (initial `Partial<RasterLayerState>` overrides), `zoomTo` (default `true`), and `beforeId` (insert the raster beneath an existing style layer, e.g. a label layer; also available as an input in the panel's Add data section).
130
132
 
@@ -141,6 +143,44 @@ The main control class implementing MapLibre's `IControl` interface.
141
143
  - `rasteradd` / `rasterremove` / `rasterchange` / `rasterselect` - Layer lifecycle events (payload includes `layerId`)
142
144
  - `error` - Loading or rendering errors (payload includes `error`)
143
145
 
146
+ ### Rendering engines
147
+
148
+ The panel has a **Rendering engine** selector (and a matching `engine` option /
149
+ `getEngine()` / `setEngine()` API) that switches the backend used for every
150
+ layer:
151
+
152
+ - **`maplibre-gl-raster`** (default) - the GPU pipeline described above: a
153
+ deck.gl `COGLayer` on a shared `MapboxOverlay`. Parameter changes re-render
154
+ without re-fetching tiles.
155
+ - **`cog-tiler-wasm`** - a serverless CPU/WASM XYZ tiler
156
+ ([cog-tiler-wasm](https://github.com/opengeos/cog-tiler-wasm)) wired to a
157
+ MapLibre custom protocol. Tiles are rendered on the CPU and served as native
158
+ MapLibre raster layers. The panel's settings (bands, rescale, colormap,
159
+ curve, gamma, nodata, opacity) map directly onto its render parameters.
160
+
161
+ `cog-tiler-wasm` is an **optional peer dependency**, loaded lazily the first
162
+ time the engine is selected, so it never enters the default bundle. To use it,
163
+ install it alongside its own peers:
164
+
165
+ ```bash
166
+ npm install cog-tiler-wasm whitebox-wasm proj4 "geotiff@^2.1" geotiff-geokeys-to-proj4
167
+ ```
168
+
169
+ > Pin `geotiff` to the `2.x` line. `cog-tiler-wasm` reads a GeoTIFF's embedded
170
+ > color table from `fileDirectory.ColorMap`, which `geotiff@3` resolves lazily
171
+ > (so paletted rasters like NLCD would otherwise render through a continuous
172
+ > colormap instead of their categorical colors).
173
+
174
+ ```typescript
175
+ // Start on the WASM engine, or switch at runtime:
176
+ const control = new RasterControl({ engine: "cog-tiler-wasm" });
177
+ // ...
178
+ control.setEngine("maplibre-gl-raster");
179
+ ```
180
+
181
+ If the package is not installed, selecting the engine surfaces a load error via
182
+ the `error` event; the default engine keeps working.
183
+
144
184
  ### RasterLayerState
145
185
 
146
186
  Per-layer visualization state, editable via the panel or `setRasterState`: