maplibre-gl-raster 0.2.1 → 0.2.2
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.
|
@@ -16336,6 +16336,44 @@ var COLORMAP_OPTIONS = COLORMAP_NAMES.map((name) => ({
|
|
|
16336
16336
|
rowIndex: COLORMAP_INDEX[name]
|
|
16337
16337
|
}));
|
|
16338
16338
|
//#endregion
|
|
16339
|
+
//#region src/lib/raster/repair-geokeys.ts
|
|
16340
|
+
/**
|
|
16341
|
+
* Repair GeoTIFFs whose projected CRS is tagged with a "user-defined" model
|
|
16342
|
+
* type so {@link import('@developmentseed/geotiff').Overview.crs} can build it.
|
|
16343
|
+
*
|
|
16344
|
+
* `crsFromGeoKeys` only accepts `GTModelTypeGeoKey` of 1 (projected) or 2
|
|
16345
|
+
* (geographic) and throws `Unsupported GeoTIFF model type: 32767` for anything
|
|
16346
|
+
* else. Some exporters (notably ArcGIS, which writes an ESRI PE string for the
|
|
16347
|
+
* `WGS_1984_Web_Mercator` / "Popular Visualisation CRS" auxiliary-sphere
|
|
16348
|
+
* Mercator) emit a fully specified projected CRS via the projection geo keys
|
|
16349
|
+
* but leave `GTModelTypeGeoKey` and `ProjectedCSTypeGeoKey` as user-defined
|
|
16350
|
+
* (32767). COGLayer then fails to resolve the CRS and the raster never draws,
|
|
16351
|
+
* even though the projection is completely described by the keys already
|
|
16352
|
+
* present. See GeoLibre issue #393.
|
|
16353
|
+
*
|
|
16354
|
+
* When a projection coordinate-transformation method is present
|
|
16355
|
+
* (`ProjMethodGeoKey`, exposed as `gkd.projMethod`), the CRS is unambiguously
|
|
16356
|
+
* projected, so we set `modelType` to projected. `crsFromGeoKeys` then takes
|
|
16357
|
+
* the projected path and builds a PROJJSON CRS from the projection keys (or
|
|
16358
|
+
* returns the EPSG code when `ProjectedCSTypeGeoKey` carries one). Files with a
|
|
16359
|
+
* valid model type, or user-defined geographic CRSes with no projection method,
|
|
16360
|
+
* are left untouched.
|
|
16361
|
+
*
|
|
16362
|
+
* Must run before any `Overview.crs` access, which caches its result; callers
|
|
16363
|
+
* invoke it immediately after opening the GeoTIFF and before handing it to
|
|
16364
|
+
* COGLayer.
|
|
16365
|
+
*
|
|
16366
|
+
* @param tiff - The opened GeoTIFF to repair in place.
|
|
16367
|
+
*/
|
|
16368
|
+
function repairUserDefinedProjectedCrs(tiff) {
|
|
16369
|
+
const MODEL_TYPE_PROJECTED = 1;
|
|
16370
|
+
const MODEL_TYPE_USER_DEFINED = 32767;
|
|
16371
|
+
for (const overview of tiff.overviews) {
|
|
16372
|
+
const gkd = overview.gkd;
|
|
16373
|
+
if ((gkd.modelType === null || gkd.modelType === MODEL_TYPE_USER_DEFINED) && gkd.projMethod !== null) gkd.modelType = MODEL_TYPE_PROJECTED;
|
|
16374
|
+
}
|
|
16375
|
+
}
|
|
16376
|
+
//#endregion
|
|
16339
16377
|
//#region src/lib/raster/load-geotiff.ts
|
|
16340
16378
|
/**
|
|
16341
16379
|
* COG access pattern is hundreds of distinct Range requests against the
|
|
@@ -16414,10 +16452,12 @@ function loadGeoTIFF(url) {
|
|
|
16414
16452
|
const promise = (async () => {
|
|
16415
16453
|
const source = new CorsSafeSourceHttp(url, {});
|
|
16416
16454
|
const view = new SourceView(source, [new SourceChunk({ size: CHUNK_SIZE }), new SourceCache({ size: CACHE_SIZE })]);
|
|
16417
|
-
|
|
16455
|
+
const tiff = await GeoTIFF.open({
|
|
16418
16456
|
dataSource: source,
|
|
16419
16457
|
headerSource: view
|
|
16420
16458
|
});
|
|
16459
|
+
repairUserDefinedProjectedCrs(tiff);
|
|
16460
|
+
return tiff;
|
|
16421
16461
|
})();
|
|
16422
16462
|
inflight.set(url, promise);
|
|
16423
16463
|
promise.finally(() => inflight.delete(url)).catch(() => {});
|
|
@@ -19685,4 +19725,4 @@ var RasterControl = class {
|
|
|
19685
19725
|
//#endregion
|
|
19686
19726
|
export { colormaps_default as _, debounce as a, throttle as c, percentileFromHistogram as d, readBandNames as f, COLORMAP_ROW_COUNT as g, COLORMAP_OPTIONS as h, classNames as i, MAX_SAMPLE_TILES as l, COLORMAP_NAMES as m, PALETTE_COLORMAP as n, formatNumericValue as o, loadGeoTIFF as p, clamp as r, generateId as s, RasterControl as t, computeAutoStats as u, createResilientEpsgResolver as v };
|
|
19687
19727
|
|
|
19688
|
-
//# sourceMappingURL=RasterControl-
|
|
19728
|
+
//# sourceMappingURL=RasterControl-BxGg08KC.js.map
|