maplibre-gl-raster 0.6.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
|
|
@@ -20991,4 +21046,4 @@ var RasterControl = class {
|
|
|
20991
21046
|
//#endregion
|
|
20992
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 };
|
|
20993
21048
|
|
|
20994
|
-
//# sourceMappingURL=RasterControl-
|
|
21049
|
+
//# sourceMappingURL=RasterControl-CGsK4CN7.js.map
|