@nika-js/onlymap 0.6.25 → 0.7.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/CHANGELOG.md +22 -0
- package/README.md +5 -3
- package/dist/{LercDecode.es-DNwkPiJw.js → LercDecode.es-CYOgDeVu.js} +1 -1
- package/dist/{basemap-Da9yotkI.js → basemap-0rGUZkQT.js} +9 -1
- package/dist/basemap.d.ts +4 -0
- package/dist/elements/om-map.d.ts +9 -1
- package/dist/{geoparquet-D8-txekS.js → geoparquet-Cau8fzH7.js} +1 -1
- package/dist/hover-pick.d.ts +53 -0
- package/dist/html-data.d.ts +1 -1
- package/dist/{index-D6SeYdqX.js → index-BF3xZe9d.js} +1 -1
- package/dist/{index-CUnb2y9k.js → index-Bt3U7sbb.js} +1 -1
- package/dist/{index-Z6ZPKbXa.js → index-CpSUZ-J3.js} +1 -1
- package/dist/{index-31e3kTgK.js → index-CriPOt1s.js} +2 -2
- package/dist/{index-CPf0evzb.js → index-CxOS31XG.js} +11725 -11392
- package/dist/index.d.ts +1 -1
- package/dist/layer-registry.d.ts +10 -0
- package/dist/{lerc-CkqppWZk.js → lerc-aeqKo4fK.js} +2 -2
- package/dist/onlymap.standalone.js +29545 -28735
- package/dist/onlymapjs.js +91 -89
- package/dist/programmatic.d.ts +5 -0
- package/dist/{raster-CXPV5d4b.js → raster-D70FrkLt.js} +1049 -790
- package/dist/raster-identify.d.ts +19 -0
- package/dist/{raster-pipeline-CKW1mTzH.js → raster-pipeline-A-zvBnKU.js} +660 -450
- package/dist/raster-pipeline.d.ts +109 -14
- package/dist/raster.d.ts +91 -1
- package/dist/react.js +253 -234
- package/dist/runtime-core.d.ts +44 -0
- package/dist/version.d.ts +1 -1
- package/dist/widget-layout.d.ts +18 -0
- package/dist/{zarr-9YGMeWT7.js → zarr-DmrbmSNx.js} +10 -3
- package/docs/design/cog-v2.md +223 -0
- package/llms.txt +3 -2
- package/onlymapjs.attributes.json +9 -0
- package/onlymapjs.html-data.json +57 -0
- package/package.json +4 -2
- package/skills/onlymapjs/SKILL.md +1 -1
- package/skills/onlymapjs/references/syntax.md +17 -7
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { c as ae, t as ze, i as yt, a as Be, s as wt, C as St, b as Pt, F as bt, A as Ct, d as Lt, R as ge, e as It, p as Gt, m as vt, f as Et, g as Ft, r as At, h as jt, j as Rt, k as Ut, l as Mt } from "./raster-pipeline-A-zvBnKU.js";
|
|
2
|
+
import { ax as Ot, ay as Kt } from "./index-CxOS31XG.js";
|
|
3
|
+
import fe from "./index-CW1n5LdO.js";
|
|
4
|
+
function xt(e, t) {
|
|
4
5
|
const n = e.length / 3, r = new Uint8ClampedArray(n * 4), o = 0, i = n, a = n * 2;
|
|
5
6
|
for (let s = 0; s < n; s++)
|
|
6
7
|
r[4 * s + 0] = e[o + s] >> 8, r[4 * s + 1] = e[i + s] >> 8, r[4 * s + 2] = e[a + s] >> 8, r[4 * s + 3] = 255;
|
|
7
8
|
return new ImageData(r, n, 1);
|
|
8
9
|
}
|
|
9
|
-
var
|
|
10
|
+
var ee;
|
|
10
11
|
(function(e) {
|
|
11
12
|
e[e.Big = 19789] = "Big", e[e.Little = 18761] = "Little";
|
|
12
|
-
})(
|
|
13
|
+
})(ee || (ee = {}));
|
|
13
14
|
var J;
|
|
14
15
|
(function(e) {
|
|
15
16
|
e[e.ReducedImage = 1] = "ReducedImage", e[e.Page = 2] = "Page", e[e.Mask = 4] = "Mask";
|
|
16
17
|
})(J || (J = {}));
|
|
17
|
-
var
|
|
18
|
+
var ye;
|
|
18
19
|
(function(e) {
|
|
19
20
|
e[e.TopLeft = 1] = "TopLeft", e[e.TopRight = 2] = "TopRight", e[e.BottomRight = 3] = "BottomRight", e[e.BottomLeft = 4] = "BottomLeft", e[e.LeftTop = 5] = "LeftTop", e[e.RightTOP = 6] = "RightTOP", e[e.RightBottom = 7] = "RightBottom", e[e.LeftBottom = 8] = "LeftBottom";
|
|
20
|
-
})(
|
|
21
|
-
var
|
|
21
|
+
})(ye || (ye = {}));
|
|
22
|
+
var te;
|
|
22
23
|
(function(e) {
|
|
23
24
|
e[e.PixelIsArea = 1] = "PixelIsArea", e[e.PixelIsPoint = 2] = "PixelIsPoint";
|
|
24
|
-
})(
|
|
25
|
-
var
|
|
25
|
+
})(te || (te = {}));
|
|
26
|
+
var O;
|
|
26
27
|
(function(e) {
|
|
27
28
|
e[e.Unknown = 0] = "Unknown", e[e.Projected = 1] = "Projected", e[e.Geographic = 2] = "Geographic", e[e.Geocentric = 3] = "Geocentric", e[e.UserDefined = 32767] = "UserDefined";
|
|
28
|
-
})(
|
|
29
|
-
var
|
|
29
|
+
})(O || (O = {}));
|
|
30
|
+
var we;
|
|
30
31
|
(function(e) {
|
|
31
32
|
e[e.Image = 1] = "Image", e[e.ReducedImage = 2] = "ReducedImage", e[e.Page = 3] = "Page";
|
|
32
|
-
})(
|
|
33
|
-
var
|
|
33
|
+
})(we || (we = {}));
|
|
34
|
+
var f;
|
|
34
35
|
(function(e) {
|
|
35
36
|
e[e.None = 1] = "None", e[e.Ccittrle = 2] = "Ccittrle", e[e.CcittT4 = 3] = "CcittT4", e[e.CcittT6 = 4] = "CcittT6", e[e.Lzw = 5] = "Lzw", e[e.Jpeg6 = 6] = "Jpeg6", e[e.Jpeg = 7] = "Jpeg", e[e.DeflateOther = 8] = "DeflateOther", e[e.T85 = 9] = "T85", e[e.T43 = 10] = "T43", e[e.Next = 32766] = "Next", e[e.Ccittrlew = 32771] = "Ccittrlew", e[e.PackBits = 32773] = "PackBits", e[e.ThunderScan = 32809] = "ThunderScan", e[e.It8ctpad = 32895] = "It8ctpad", e[e.It8lw = 32896] = "It8lw", e[e.It8mp = 32897] = "It8mp", e[e.It8bl = 32898] = "It8bl", e[e.PixarFilm = 32908] = "PixarFilm", e[e.PixarLog = 32909] = "PixarLog", e[e.Deflate = 32946] = "Deflate", e[e.Dcs = 32947] = "Dcs", e[e.Jbig = 34661] = "Jbig", e[e.SgiLog = 34676] = "SgiLog", e[e.SgiLog24 = 34677] = "SgiLog24", e[e.Jp2000 = 34712] = "Jp2000", e[e.Lerc = 34887] = "Lerc", e[e.Lzma = 34925] = "Lzma", e[e.Zstd = 5e4] = "Zstd", e[e.Webp = 50001] = "Webp", e[e.JpegXl = 50002] = "JpegXl", e[e.JpegXlDng17 = 52546] = "JpegXlDng17";
|
|
36
|
-
})(
|
|
37
|
+
})(f || (f = {}));
|
|
37
38
|
var U;
|
|
38
39
|
(function(e) {
|
|
39
40
|
e[e.Contig = 1] = "Contig", e[e.Separate = 2] = "Separate";
|
|
@@ -42,227 +43,227 @@ var _;
|
|
|
42
43
|
(function(e) {
|
|
43
44
|
e[e.None = 1] = "None", e[e.Horizontal = 2] = "Horizontal", e[e.FloatingPoint = 3] = "FloatingPoint";
|
|
44
45
|
})(_ || (_ = {}));
|
|
45
|
-
var
|
|
46
|
+
var A;
|
|
46
47
|
(function(e) {
|
|
47
48
|
e[e.Uint = 1] = "Uint", e[e.Int = 2] = "Int", e[e.Float = 3] = "Float", e[e.Void = 4] = "Void", e[e.ComplexInt = 5] = "ComplexInt", e[e.ComplexFloat = 6] = "ComplexFloat";
|
|
48
|
-
})(
|
|
49
|
-
var
|
|
49
|
+
})(A || (A = {}));
|
|
50
|
+
var F;
|
|
50
51
|
(function(e) {
|
|
51
52
|
e[e.MinIsWhite = 0] = "MinIsWhite", e[e.MinIsBlack = 1] = "MinIsBlack", e[e.Rgb = 2] = "Rgb", e[e.Palette = 3] = "Palette", e[e.Mask = 4] = "Mask", e[e.Separated = 5] = "Separated", e[e.Ycbcr = 6] = "Ycbcr", e[e.Cielab = 8] = "Cielab", e[e.Icclab = 9] = "Icclab", e[e.Itulab = 10] = "Itulab", e[e.Cfa = 32803] = "Cfa", e[e.Logl = 32844] = "Logl", e[e.Logluv = 32845] = "Logluv";
|
|
52
|
-
})(
|
|
53
|
-
var
|
|
53
|
+
})(F || (F = {}));
|
|
54
|
+
var d;
|
|
54
55
|
(function(e) {
|
|
55
56
|
e[e.SubFileType = 254] = "SubFileType", e[e.OldSubFileType = 255] = "OldSubFileType", e[e.ImageWidth = 256] = "ImageWidth", e[e.ImageHeight = 257] = "ImageHeight", e[e.BitsPerSample = 258] = "BitsPerSample", e[e.SampleFormat = 339] = "SampleFormat", e[e.Compression = 259] = "Compression", e[e.Photometric = 262] = "Photometric", e[e.TileWidth = 322] = "TileWidth", e[e.TileHeight = 323] = "TileHeight", e[e.TileOffsets = 324] = "TileOffsets", e[e.TileByteCounts = 325] = "TileByteCounts", e[e.JpegTables = 347] = "JpegTables", e[e.StripOffsets = 273] = "StripOffsets", e[e.StripByteCounts = 279] = "StripByteCounts", e[e.GdalMetadata = 42112] = "GdalMetadata", e[e.GdalNoData = 42113] = "GdalNoData", e[e.ModelPixelScale = 33550] = "ModelPixelScale", e[e.ModelTiePoint = 33922] = "ModelTiePoint", e[e.ModelTransformation = 34264] = "ModelTransformation", e[e.GeoKeyDirectory = 34735] = "GeoKeyDirectory", e[e.GeoDoubleParams = 34736] = "GeoDoubleParams", e[e.GeoAsciiParams = 34737] = "GeoAsciiParams", e[e.LercParameters = 50674] = "LercParameters", e[e.PlanarConfiguration = 284] = "PlanarConfiguration", e[e.CellLength = 265] = "CellLength", e[e.CellWidth = 264] = "CellWidth", e[e.ColorMap = 320] = "ColorMap", e[e.Copyright = 33432] = "Copyright", e[e.DateTime = 306] = "DateTime", e[e.ExtraSamples = 338] = "ExtraSamples", e[e.FillOrder = 266] = "FillOrder", e[e.FreeByteCounts = 289] = "FreeByteCounts", e[e.FreeOffsets = 288] = "FreeOffsets", e[e.GrayResponseCurve = 291] = "GrayResponseCurve", e[e.GrayResponseUnit = 290] = "GrayResponseUnit", e[e.HostComputer = 316] = "HostComputer", e[e.ImageDescription = 270] = "ImageDescription", e[e.Make = 271] = "Make", e[e.MaxSampleValue = 281] = "MaxSampleValue", e[e.MinSampleValue = 280] = "MinSampleValue", e[e.Model = 272] = "Model", e[e.Orientation = 274] = "Orientation", e[e.ResolutionUnit = 296] = "ResolutionUnit", e[e.RowsPerStrip = 278] = "RowsPerStrip", e[e.SamplesPerPixel = 277] = "SamplesPerPixel", e[e.Software = 305] = "Software", e[e.Threshholding = 263] = "Threshholding", e[e.XResolution = 282] = "XResolution", e[e.YResolution = 283] = "YResolution", e[e.BadFaxLines = 326] = "BadFaxLines", e[e.CleanFaxData = 327] = "CleanFaxData", e[e.ClipPath = 343] = "ClipPath", e[e.ConsecutiveBadFaxLines = 328] = "ConsecutiveBadFaxLines", e[e.Decode = 433] = "Decode", e[e.DefaultImageColor = 434] = "DefaultImageColor", e[e.DocumentName = 269] = "DocumentName", e[e.DotRange = 336] = "DotRange", e[e.HalftoneHints = 321] = "HalftoneHints", e[e.Indexed = 346] = "Indexed", e[e.PageName = 285] = "PageName", e[e.PageNumber = 297] = "PageNumber", e[e.Predictor = 317] = "Predictor", e[e.PrimaryChromaticities = 319] = "PrimaryChromaticities", e[e.ReferenceBlackWhite = 532] = "ReferenceBlackWhite", e[e.SMinSampleValue = 340] = "SMinSampleValue", e[e.SMaxSampleValue = 341] = "SMaxSampleValue", e[e.StripRowCounts = 559] = "StripRowCounts", e[e.SubIFDs = 330] = "SubIFDs", e[e.T4Options = 292] = "T4Options", e[e.T6Options = 293] = "T6Options", e[e.TransferFunction = 301] = "TransferFunction", e[e.WhitePoint = 318] = "WhitePoint", e[e.XClipPathUnits = 344] = "XClipPathUnits", e[e.XPosition = 286] = "XPosition", e[e.YCbCrCoefficients = 529] = "YCbCrCoefficients", e[e.YCbCrPositioning = 531] = "YCbCrPositioning", e[e.YCbCrSubSampling = 530] = "YCbCrSubSampling", e[e.YClipPathUnits = 345] = "YClipPathUnits", e[e.YPosition = 287] = "YPosition", e[e.ApertureValue = 37378] = "ApertureValue", e[e.ColorSpace = 40961] = "ColorSpace", e[e.DateTimeDigitized = 36868] = "DateTimeDigitized", e[e.DateTimeOriginal = 36867] = "DateTimeOriginal", e[e.ExifIFD = 34665] = "ExifIFD", e[e.ExifVersion = 36864] = "ExifVersion", e[e.ExposureTime = 33434] = "ExposureTime", e[e.FileSource = 41728] = "FileSource", e[e.Flash = 37385] = "Flash", e[e.FlashpixVersion = 40960] = "FlashpixVersion", e[e.FNumber = 33437] = "FNumber", e[e.ImageUniqueID = 42016] = "ImageUniqueID", e[e.LightSource = 37384] = "LightSource", e[e.MakerNote = 37500] = "MakerNote", e[e.ShutterSpeedValue = 37377] = "ShutterSpeedValue", e[e.UserComment = 37510] = "UserComment", e[e.IPTC = 33723] = "IPTC", e[e.ICCProfile = 34675] = "ICCProfile", e[e.XMP = 700] = "XMP";
|
|
56
|
-
})(
|
|
57
|
-
var
|
|
57
|
+
})(d || (d = {}));
|
|
58
|
+
var m;
|
|
58
59
|
(function(e) {
|
|
59
60
|
e[e.GTModelTypeGeoKey = 1024] = "GTModelTypeGeoKey", e[e.GTRasterTypeGeoKey = 1025] = "GTRasterTypeGeoKey", e[e.GTCitationGeoKey = 1026] = "GTCitationGeoKey", e[e.GeodeticCRSGeoKey = 2048] = "GeodeticCRSGeoKey", e[e.GeodeticCitationGeoKey = 2049] = "GeodeticCitationGeoKey", e[e.GeodeticDatumGeoKey = 2050] = "GeodeticDatumGeoKey", e[e.PrimeMeridianGeoKey = 2051] = "PrimeMeridianGeoKey", e[e.GeogLinearUnitsGeoKey = 2052] = "GeogLinearUnitsGeoKey", e[e.GeogLinearUnitSizeGeoKey = 2053] = "GeogLinearUnitSizeGeoKey", e[e.GeogAngularUnitsGeoKey = 2054] = "GeogAngularUnitsGeoKey", e[e.GeogAngularUnitSizeGeoKey = 2055] = "GeogAngularUnitSizeGeoKey", e[e.EllipsoidGeoKey = 2056] = "EllipsoidGeoKey", e[e.EllipsoidSemiMajorAxisGeoKey = 2057] = "EllipsoidSemiMajorAxisGeoKey", e[e.EllipsoidSemiMinorAxisGeoKey = 2058] = "EllipsoidSemiMinorAxisGeoKey", e[e.EllipsoidInvFlatteningGeoKey = 2059] = "EllipsoidInvFlatteningGeoKey", e[e.PrimeMeridianLongitudeGeoKey = 2061] = "PrimeMeridianLongitudeGeoKey", e[e.GeogTOWGS84GeoKey = 2062] = "GeogTOWGS84GeoKey", e[e.GeogAzimuthUnitsGeoKey = 2060] = "GeogAzimuthUnitsGeoKey", e[e.ProjectedCRSGeoKey = 3072] = "ProjectedCRSGeoKey", e[e.ProjectedCitationGeoKey = 3073] = "ProjectedCitationGeoKey", e[e.ProjectionGeoKey = 3074] = "ProjectionGeoKey", e[e.ProjMethodGeoKey = 3075] = "ProjMethodGeoKey", e[e.ProjLinearUnitsGeoKey = 3076] = "ProjLinearUnitsGeoKey", e[e.ProjLinearUnitSizeGeoKey = 3077] = "ProjLinearUnitSizeGeoKey", e[e.ProjStdParallel1GeoKey = 3078] = "ProjStdParallel1GeoKey", e[e.ProjStdParallel2GeoKey = 3079] = "ProjStdParallel2GeoKey", e[e.ProjNatOriginLongGeoKey = 3080] = "ProjNatOriginLongGeoKey", e[e.ProjNatOriginLatGeoKey = 3081] = "ProjNatOriginLatGeoKey", e[e.ProjFalseEastingGeoKey = 3082] = "ProjFalseEastingGeoKey", e[e.ProjFalseNorthingGeoKey = 3083] = "ProjFalseNorthingGeoKey", e[e.ProjFalseOriginLongGeoKey = 3084] = "ProjFalseOriginLongGeoKey", e[e.ProjFalseOriginLatGeoKey = 3085] = "ProjFalseOriginLatGeoKey", e[e.ProjFalseOriginEastingGeoKey = 3086] = "ProjFalseOriginEastingGeoKey", e[e.ProjFalseOriginNorthingGeoKey = 3087] = "ProjFalseOriginNorthingGeoKey", e[e.ProjCenterLongGeoKey = 3088] = "ProjCenterLongGeoKey", e[e.ProjCenterLatGeoKey = 3089] = "ProjCenterLatGeoKey", e[e.ProjCenterEastingGeoKey = 3090] = "ProjCenterEastingGeoKey", e[e.ProjCenterNorthingGeoKey = 3091] = "ProjCenterNorthingGeoKey", e[e.ProjScaleAtNatOriginGeoKey = 3092] = "ProjScaleAtNatOriginGeoKey", e[e.ProjScaleAtCenterGeoKey = 3093] = "ProjScaleAtCenterGeoKey", e[e.ProjAzimuthAngleGeoKey = 3094] = "ProjAzimuthAngleGeoKey", e[e.ProjStraightVertPoleLongGeoKey = 3095] = "ProjStraightVertPoleLongGeoKey", e[e.ProjRectifiedGridAngleGeoKey = 3096] = "ProjRectifiedGridAngleGeoKey", e[e.VerticalGeoKey = 4096] = "VerticalGeoKey", e[e.VerticalCitationGeoKey = 4097] = "VerticalCitationGeoKey", e[e.VerticalDatumGeoKey = 4098] = "VerticalDatumGeoKey", e[e.VerticalUnitsGeoKey = 4099] = "VerticalUnitsGeoKey";
|
|
60
|
-
})(
|
|
61
|
-
var
|
|
61
|
+
})(m || (m = {}));
|
|
62
|
+
var Se;
|
|
62
63
|
(function(e) {
|
|
63
64
|
e[e.Radian = 9101] = "Radian", e[e.Degree = 9102] = "Degree", e[e.ArcMinute = 9103] = "ArcMinute", e[e.ArcDegree = 9104] = "ArcDegree", e[e.Grad = 9105] = "Grad", e[e.Gon = 9106] = "Gon", e[e.Dms = 9107] = "Dms";
|
|
64
|
-
})(
|
|
65
|
-
var
|
|
65
|
+
})(Se || (Se = {}));
|
|
66
|
+
var Pe;
|
|
66
67
|
(function(e) {
|
|
67
68
|
e[e.Metre = 9001] = "Metre", e[e.Foot = 9002] = "Foot", e[e.FootUsSurvey = 9003] = "FootUsSurvey", e[e.FootModifiedAmerican = 9004] = "FootModifiedAmerican", e[e.FootClarke = 9005] = "FootClarke", e[e.FootIndian = 9006] = "FootIndian", e[e.Link = 9007] = "Link", e[e.LinkBenoit = 9008] = "LinkBenoit", e[e.LinkSears = 9009] = "LinkSears", e[e.ChainBenoit = 9010] = "ChainBenoit", e[e.ChainSears = 9011] = "ChainSears", e[e.YardSears = 9012] = "YardSears", e[e.YardIndian = 9013] = "YardIndian", e[e.Fathom = 9014] = "Fathom", e[e.MileInternationalNautical = 9015] = "MileInternationalNautical";
|
|
68
|
-
})(
|
|
69
|
-
const
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
69
|
+
})(Pe || (Pe = {}));
|
|
70
|
+
const Dt = {
|
|
71
|
+
[d.TileByteCounts]: !0,
|
|
72
|
+
[d.TileOffsets]: !0,
|
|
73
|
+
[d.StripOffsets]: !0,
|
|
74
|
+
[d.StripByteCounts]: !0,
|
|
75
|
+
[d.BitsPerSample]: !0,
|
|
76
|
+
[d.SampleFormat]: !0,
|
|
77
|
+
[d.GeoKeyDirectory]: !0,
|
|
78
|
+
[d.GeoDoubleParams]: !0
|
|
78
79
|
};
|
|
79
|
-
var
|
|
80
|
+
var S;
|
|
80
81
|
(function(e) {
|
|
81
82
|
e.None = "application/octet-stream", e.Jbig = "image/jbig", e.Dcs = "image/x-kodak-dcs", e.PackBits = "application/packbits", e.Jpeg = "image/jpeg", e.Jp2000 = "image/jp2", e.JpegXl = "image/jpegxl", e.Webp = "image/webp", e.Zstd = "application/zstd", e.Lzw = "application/lzw", e.Deflate = "application/deflate", e.Lerc = "application/lerc", e.Lzma = "application/x-lzma";
|
|
82
|
-
})(
|
|
83
|
-
const
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
98
|
-
[
|
|
99
|
-
[
|
|
100
|
-
[
|
|
101
|
-
[
|
|
102
|
-
[
|
|
103
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
111
|
-
[
|
|
112
|
-
[
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
83
|
+
})(S || (S = {}));
|
|
84
|
+
const _e = {
|
|
85
|
+
[f.None]: S.None,
|
|
86
|
+
[f.Lzw]: S.Lzw,
|
|
87
|
+
[f.Jpeg6]: S.Jpeg,
|
|
88
|
+
[f.Jpeg]: S.Jpeg,
|
|
89
|
+
[f.DeflateOther]: S.Deflate,
|
|
90
|
+
[f.Deflate]: S.Deflate,
|
|
91
|
+
[f.Lerc]: S.Lerc,
|
|
92
|
+
[f.Lzma]: S.Lzma,
|
|
93
|
+
[f.Jp2000]: S.Jp2000,
|
|
94
|
+
[f.Zstd]: S.Zstd,
|
|
95
|
+
[f.Webp]: S.Webp,
|
|
96
|
+
[f.JpegXl]: S.JpegXl,
|
|
97
|
+
[f.Ccittrle]: S.None,
|
|
98
|
+
[f.CcittT4]: S.None,
|
|
99
|
+
[f.CcittT6]: S.None,
|
|
100
|
+
[f.T85]: S.Jbig,
|
|
101
|
+
[f.T43]: S.Jbig,
|
|
102
|
+
[f.Next]: S.None,
|
|
103
|
+
[f.Ccittrlew]: S.None,
|
|
104
|
+
[f.PackBits]: S.PackBits,
|
|
105
|
+
[f.ThunderScan]: S.None,
|
|
106
|
+
[f.It8ctpad]: S.None,
|
|
107
|
+
[f.It8lw]: S.None,
|
|
108
|
+
[f.It8mp]: S.None,
|
|
109
|
+
[f.It8bl]: S.None,
|
|
110
|
+
[f.PixarFilm]: S.None,
|
|
111
|
+
[f.PixarLog]: S.None,
|
|
112
|
+
[f.Dcs]: S.Dcs,
|
|
113
|
+
[f.Jbig]: S.Jbig,
|
|
114
|
+
[f.SgiLog]: S.None,
|
|
115
|
+
[f.SgiLog24]: S.None,
|
|
116
|
+
[f.JpegXlDng17]: S.JpegXl
|
|
116
117
|
};
|
|
117
|
-
function
|
|
118
|
-
return e == null ? null :
|
|
118
|
+
function Nt(e) {
|
|
119
|
+
return e == null ? null : _e[e];
|
|
119
120
|
}
|
|
120
|
-
var
|
|
121
|
+
var w;
|
|
121
122
|
(function(e) {
|
|
122
123
|
e[e.Uint8 = 1] = "Uint8", e[e.Ascii = 2] = "Ascii", e[e.Uint16 = 3] = "Uint16", e[e.Uint32 = 4] = "Uint32", e[e.Rational = 5] = "Rational", e[e.Int8 = 6] = "Int8", e[e.Undefined = 7] = "Undefined", e[e.Int16 = 8] = "Int16", e[e.Int32 = 9] = "Int32", e[e.SignedRational = 10] = "SignedRational", e[e.Float32 = 11] = "Float32", e[e.Float64 = 12] = "Float64", e[e.Ifd = 13] = "Ifd", e[e.Uint64 = 16] = "Uint64", e[e.Int64 = 17] = "Int64", e[e.Ifd8 = 18] = "Ifd8";
|
|
123
|
-
})(
|
|
124
|
-
var
|
|
124
|
+
})(w || (w = {}));
|
|
125
|
+
var R;
|
|
125
126
|
(function(e) {
|
|
126
127
|
e[e.BigTiff = 43] = "BigTiff", e[e.Tiff = 42] = "Tiff";
|
|
127
|
-
})(
|
|
128
|
+
})(R || (R = {}));
|
|
128
129
|
function N(e) {
|
|
129
130
|
switch (e) {
|
|
130
|
-
case
|
|
131
|
-
case
|
|
132
|
-
case
|
|
133
|
-
case
|
|
131
|
+
case w.Uint8:
|
|
132
|
+
case w.Ascii:
|
|
133
|
+
case w.Int8:
|
|
134
|
+
case w.Undefined:
|
|
134
135
|
return 1;
|
|
135
|
-
case
|
|
136
|
-
case
|
|
136
|
+
case w.Uint16:
|
|
137
|
+
case w.Int16:
|
|
137
138
|
return 2;
|
|
138
|
-
case
|
|
139
|
-
case
|
|
140
|
-
case
|
|
141
|
-
case
|
|
139
|
+
case w.Uint32:
|
|
140
|
+
case w.Int32:
|
|
141
|
+
case w.Float32:
|
|
142
|
+
case w.Ifd:
|
|
142
143
|
return 4;
|
|
143
|
-
case
|
|
144
|
-
case
|
|
145
|
-
case
|
|
146
|
-
case
|
|
147
|
-
case
|
|
148
|
-
case
|
|
144
|
+
case w.Rational:
|
|
145
|
+
case w.SignedRational:
|
|
146
|
+
case w.Float64:
|
|
147
|
+
case w.Uint64:
|
|
148
|
+
case w.Int64:
|
|
149
|
+
case w.Ifd8:
|
|
149
150
|
return 8;
|
|
150
151
|
default:
|
|
151
152
|
throw new Error(`Invalid fieldType ${String(e)}`);
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
var
|
|
155
|
+
var be;
|
|
155
156
|
(function(e) {
|
|
156
157
|
e[e.Double = 8] = "Double", e[e.Float32 = 4] = "Float32";
|
|
157
|
-
})(
|
|
158
|
-
var
|
|
158
|
+
})(be || (be = {}));
|
|
159
|
+
var I;
|
|
159
160
|
(function(e) {
|
|
160
161
|
e[e.UInt64 = 8] = "UInt64", e[e.UInt32 = 4] = "UInt32", e[e.UInt16 = 2] = "UInt16", e[e.UInt8 = 1] = "UInt8";
|
|
161
|
-
})(
|
|
162
|
-
const
|
|
163
|
-
function
|
|
164
|
-
const r = e.getUint32(t, n), o = e.getUint32(t + 4, n), i = n ? r +
|
|
162
|
+
})(I || (I = {}));
|
|
163
|
+
const Ce = 2 ** 32;
|
|
164
|
+
function $e(e, t, n) {
|
|
165
|
+
const r = e.getUint32(t, n), o = e.getUint32(t + 4, n), i = n ? r + Ce * o : Ce * r + o;
|
|
165
166
|
if (!Number.isSafeInteger(i))
|
|
166
167
|
throw new Error(i + " exceeds MAX_SAFE_INTEGER. Precision may is lost");
|
|
167
168
|
return i;
|
|
168
169
|
}
|
|
169
170
|
function K(e, t, n, r) {
|
|
170
171
|
switch (n) {
|
|
171
|
-
case
|
|
172
|
+
case I.UInt8:
|
|
172
173
|
return e.getUint8(t);
|
|
173
|
-
case
|
|
174
|
+
case I.UInt16:
|
|
174
175
|
return e.getUint16(t, r);
|
|
175
|
-
case
|
|
176
|
+
case I.UInt32:
|
|
176
177
|
return e.getUint32(t, r);
|
|
177
|
-
case
|
|
178
|
-
return
|
|
178
|
+
case I.UInt64:
|
|
179
|
+
return $e(e, t, r);
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
|
-
function
|
|
182
|
+
function X(e, t, n) {
|
|
182
183
|
return !(t < e.sourceOffset || e.sourceOffset + e.byteLength < t + n);
|
|
183
184
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
function
|
|
185
|
+
const ke = new ArrayBuffer(4), zt = new Uint32Array(ke), Bt = new Uint8Array(ke);
|
|
186
|
+
zt[0] = 1;
|
|
187
|
+
const Le = Bt[0] === 1;
|
|
188
|
+
function Ie(e, t, n, r) {
|
|
188
189
|
switch (e) {
|
|
189
|
-
case
|
|
190
|
+
case w.Ascii:
|
|
190
191
|
return String.fromCharCode(t.getUint8(n));
|
|
191
|
-
case
|
|
192
|
-
case
|
|
192
|
+
case w.Undefined:
|
|
193
|
+
case w.Uint8:
|
|
193
194
|
return t.getUint8(n);
|
|
194
|
-
case
|
|
195
|
+
case w.Int8:
|
|
195
196
|
return t.getInt8(n);
|
|
196
|
-
case
|
|
197
|
+
case w.Uint16:
|
|
197
198
|
return t.getUint16(n, r);
|
|
198
|
-
case
|
|
199
|
+
case w.Int16:
|
|
199
200
|
return t.getInt16(n, r);
|
|
200
|
-
case
|
|
201
|
-
case
|
|
201
|
+
case w.Uint32:
|
|
202
|
+
case w.Ifd:
|
|
202
203
|
return t.getUint32(n, r);
|
|
203
|
-
case
|
|
204
|
+
case w.Int32:
|
|
204
205
|
return t.getInt32(n, r);
|
|
205
|
-
case
|
|
206
|
+
case w.Rational:
|
|
206
207
|
return [t.getUint32(n, r), t.getUint32(n + 4, r)];
|
|
207
|
-
case
|
|
208
|
+
case w.SignedRational:
|
|
208
209
|
return [t.getInt32(n, r), t.getInt32(n + 4, r)];
|
|
209
|
-
case
|
|
210
|
+
case w.Float64:
|
|
210
211
|
return t.getFloat64(n, r);
|
|
211
|
-
case
|
|
212
|
+
case w.Float32:
|
|
212
213
|
return t.getFloat32(n, r);
|
|
213
|
-
case
|
|
214
|
-
return
|
|
214
|
+
case w.Uint64:
|
|
215
|
+
return $e(t, n, r);
|
|
215
216
|
default:
|
|
216
|
-
throw new Error(`Unknown read type "${e}" "${
|
|
217
|
+
throw new Error(`Unknown read type "${e}" "${w[e]}"`);
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
+
function We(e, t, n, r, o) {
|
|
220
221
|
switch (o) {
|
|
221
|
-
case
|
|
222
|
+
case w.Uint8:
|
|
222
223
|
return new Uint8Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
|
|
223
|
-
case
|
|
224
|
-
return e.isLittleEndian !==
|
|
225
|
-
case
|
|
226
|
-
return e.isLittleEndian !==
|
|
224
|
+
case w.Uint16:
|
|
225
|
+
return e.isLittleEndian !== Le ? null : new Uint16Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
|
|
226
|
+
case w.Uint32:
|
|
227
|
+
return e.isLittleEndian !== Le ? null : new Uint32Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
|
|
227
228
|
}
|
|
228
229
|
return null;
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function D(e, t, n, r, o, i) {
|
|
231
232
|
const a = N(o), s = i * a;
|
|
232
233
|
if (i === 1) {
|
|
233
|
-
const c =
|
|
234
|
-
return t &&
|
|
234
|
+
const c = Ie(o, n, r, e.isLittleEndian);
|
|
235
|
+
return t && Dt[t] ? [c] : c;
|
|
235
236
|
}
|
|
236
237
|
switch (o) {
|
|
237
|
-
case
|
|
238
|
+
case w.Ascii:
|
|
238
239
|
return String.fromCharCode.apply(null, new Uint8Array(n.buffer, r, s - 1));
|
|
239
240
|
}
|
|
240
|
-
if (t ===
|
|
241
|
-
const c =
|
|
241
|
+
if (t === d.TileOffsets || t === d.TileByteCounts || t === d.StripOffsets || t === d.StripByteCounts) {
|
|
242
|
+
const c = We(e, n, r, s, o);
|
|
242
243
|
if (c)
|
|
243
244
|
return c;
|
|
244
245
|
}
|
|
245
246
|
const l = [];
|
|
246
247
|
for (let c = 0; c < s; c += a)
|
|
247
|
-
l.push(
|
|
248
|
+
l.push(Ie(o, n, r + c, e.isLittleEndian));
|
|
248
249
|
return l;
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
+
function _t(e, t, n) {
|
|
251
252
|
const r = t.getUint16(n + 0, e.isLittleEndian), o = t.getUint16(n + 2, e.isLittleEndian), i = K(t, n + 4, e.ifdConfig.pointer, e.isLittleEndian), s = N(o) * i;
|
|
252
253
|
if (s <= e.ifdConfig.pointer) {
|
|
253
|
-
const c =
|
|
254
|
-
return { type: "inline", id: r, name:
|
|
254
|
+
const c = D(e, r, t, n + 4 + e.ifdConfig.pointer, o, i);
|
|
255
|
+
return { type: "inline", id: r, name: d[r], count: i, value: c, dataType: o, tagOffset: n };
|
|
255
256
|
}
|
|
256
257
|
const l = K(t, n + 4 + e.ifdConfig.pointer, e.ifdConfig.pointer, e.isLittleEndian);
|
|
257
258
|
switch (r) {
|
|
258
|
-
case
|
|
259
|
-
case
|
|
260
|
-
case
|
|
261
|
-
case
|
|
259
|
+
case d.TileOffsets:
|
|
260
|
+
case d.TileByteCounts:
|
|
261
|
+
case d.StripByteCounts:
|
|
262
|
+
case d.StripOffsets:
|
|
262
263
|
const c = {
|
|
263
264
|
type: "offset",
|
|
264
265
|
id: r,
|
|
265
|
-
name:
|
|
266
|
+
name: d[r],
|
|
266
267
|
count: i,
|
|
267
268
|
dataType: o,
|
|
268
269
|
dataOffset: l,
|
|
@@ -270,76 +271,76 @@ function Pt(e, t, n) {
|
|
|
270
271
|
value: [],
|
|
271
272
|
tagOffset: n
|
|
272
273
|
};
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
|
|
274
|
+
if (X(t, l, s)) {
|
|
275
|
+
const u = We(e, t, l - t.sourceOffset, s, o);
|
|
276
|
+
u ? (c.value = u, c.isLoaded = !0) : Wt(c, t);
|
|
276
277
|
}
|
|
277
278
|
return c;
|
|
278
279
|
}
|
|
279
|
-
if (
|
|
280
|
-
const c =
|
|
281
|
-
return { type: "inline", id: r, name:
|
|
280
|
+
if (X(t, l, s)) {
|
|
281
|
+
const c = D(e, r, t, l - t.sourceOffset, o, i);
|
|
282
|
+
return { type: "inline", id: r, name: d[r], count: i, value: c, dataType: o, tagOffset: n };
|
|
282
283
|
}
|
|
283
|
-
return { type: "lazy", id: r, name:
|
|
284
|
+
return { type: "lazy", id: r, name: d[r], count: i, dataOffset: l, dataType: o, tagOffset: n };
|
|
284
285
|
}
|
|
285
|
-
async function
|
|
286
|
+
async function $t(e, t, n) {
|
|
286
287
|
if (e.value != null)
|
|
287
288
|
return e.value;
|
|
288
289
|
const o = N(e.dataType) * e.count, i = await t.source.fetch(e.dataOffset, o, n), a = new DataView(i);
|
|
289
|
-
return e.value =
|
|
290
|
+
return e.value = D(t, e.id, a, 0, e.dataType, e.count), e.value;
|
|
290
291
|
}
|
|
291
|
-
async function
|
|
292
|
+
async function kt(e, t, n) {
|
|
292
293
|
const r = N(t.dataType);
|
|
293
294
|
if (t.view == null) {
|
|
294
295
|
const o = await e.source.fetch(t.dataOffset, r * t.count, n);
|
|
295
296
|
t.view = new DataView(o), t.view.sourceOffset = t.dataOffset;
|
|
296
297
|
}
|
|
297
|
-
return t.value =
|
|
298
|
+
return t.value = D(e, t.id, t.view, 0, t.dataType, t.count), t.view = void 0, t.isLoaded = !0, t.value;
|
|
298
299
|
}
|
|
299
|
-
function
|
|
300
|
+
function Wt(e, t) {
|
|
300
301
|
const n = N(e.dataType), r = t.byteOffset + e.dataOffset - t.sourceOffset;
|
|
301
302
|
e.view = new DataView(t.buffer.slice(r, r + n * e.count)), e.view.sourceOffset = e.dataOffset;
|
|
302
303
|
}
|
|
303
|
-
async function
|
|
304
|
+
async function Jt(e, t, n, r) {
|
|
304
305
|
if (n > t.count || n < 0)
|
|
305
306
|
throw new Error("TagOffset: out of bounds :" + n);
|
|
306
307
|
if (t.value[n] != null)
|
|
307
308
|
return t.value[n];
|
|
308
309
|
const o = N(t.dataType);
|
|
309
310
|
if (t.view == null) {
|
|
310
|
-
const a = await e.source.fetch(t.dataOffset + n * o, o, r), s = new DataView(a), l =
|
|
311
|
+
const a = await e.source.fetch(t.dataOffset + n * o, o, r), s = new DataView(a), l = D(e, void 0, s, 0, t.dataType, 1);
|
|
311
312
|
if (typeof l != "number")
|
|
312
313
|
throw new Error("Value is not a number");
|
|
313
314
|
return t.value[n] = l, l;
|
|
314
315
|
}
|
|
315
|
-
const i =
|
|
316
|
+
const i = D(e, void 0, t.view, n * o, t.dataType, 1);
|
|
316
317
|
if (typeof i != "number")
|
|
317
318
|
throw new Error("Value is not a number");
|
|
318
319
|
return t.value[n] = i, i;
|
|
319
320
|
}
|
|
320
|
-
function
|
|
321
|
+
function Vt(e, t, n) {
|
|
321
322
|
if (n > t.count || n < 0)
|
|
322
323
|
throw new Error("TagOffset: out of bounds :" + n);
|
|
323
324
|
if (t.value[n] != null)
|
|
324
325
|
return t.value[n];
|
|
325
326
|
if (t.view == null)
|
|
326
327
|
return null;
|
|
327
|
-
const r = N(t.dataType), o =
|
|
328
|
+
const r = N(t.dataType), o = D(e, void 0, t.view, n * r, t.dataType, 1);
|
|
328
329
|
if (typeof o != "number")
|
|
329
330
|
throw new Error("Value is not a number");
|
|
330
331
|
return t.value[n] = o, o;
|
|
331
332
|
}
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
]),
|
|
342
|
-
class
|
|
333
|
+
const Ge = 32767, Ht = /* @__PURE__ */ new Set([
|
|
334
|
+
d.Compression,
|
|
335
|
+
d.ImageHeight,
|
|
336
|
+
d.ImageWidth,
|
|
337
|
+
d.ModelPixelScale,
|
|
338
|
+
d.ModelTiePoint,
|
|
339
|
+
d.ModelTransformation,
|
|
340
|
+
d.TileHeight,
|
|
341
|
+
d.TileWidth
|
|
342
|
+
]), Yt = /* @__PURE__ */ new Set([d.GeoKeyDirectory, d.GeoAsciiParams, d.GeoDoubleParams]);
|
|
343
|
+
class Xt {
|
|
343
344
|
/**
|
|
344
345
|
* Id of the tif image, generally the image index inside the tif
|
|
345
346
|
* where 0 is the root image, and every sub image is +1
|
|
@@ -365,9 +366,9 @@ class Ft {
|
|
|
365
366
|
*/
|
|
366
367
|
async init(t = !0, n) {
|
|
367
368
|
const r = [];
|
|
368
|
-
|
|
369
|
+
Ht.forEach((o) => {
|
|
369
370
|
r.push(this.fetch(o, n));
|
|
370
|
-
}), t &&
|
|
371
|
+
}), t && Yt.forEach((o) => {
|
|
371
372
|
r.push(this.fetch(o, n));
|
|
372
373
|
}), await Promise.all(r), t && await this.loadGeoTiffTags();
|
|
373
374
|
}
|
|
@@ -417,11 +418,11 @@ class Ft {
|
|
|
417
418
|
if (r.type === "inline")
|
|
418
419
|
return r.value;
|
|
419
420
|
if (r.type === "lazy")
|
|
420
|
-
return
|
|
421
|
+
return $t(r, this.tiff, n);
|
|
421
422
|
if (r.isLoaded)
|
|
422
423
|
return r.value;
|
|
423
424
|
if (r.type === "offset")
|
|
424
|
-
return
|
|
425
|
+
return kt(this.tiff, r, n);
|
|
425
426
|
throw new Error("Cannot fetch:" + t);
|
|
426
427
|
}
|
|
427
428
|
/**
|
|
@@ -445,7 +446,7 @@ class Ft {
|
|
|
445
446
|
* @returns null if the tag does not exist
|
|
446
447
|
*/
|
|
447
448
|
get noData() {
|
|
448
|
-
const t = this.tags.get(
|
|
449
|
+
const t = this.tags.get(d.GdalNoData);
|
|
449
450
|
if (t == null)
|
|
450
451
|
return null;
|
|
451
452
|
if (t.value != null)
|
|
@@ -460,15 +461,15 @@ class Ft {
|
|
|
460
461
|
async loadGeoTiffTags() {
|
|
461
462
|
if (this.isGeoTagsLoaded)
|
|
462
463
|
return;
|
|
463
|
-
const t = this.tags.get(
|
|
464
|
+
const t = this.tags.get(d.GeoKeyDirectory);
|
|
464
465
|
if (t == null) {
|
|
465
466
|
this.isGeoTagsLoaded = !0;
|
|
466
467
|
return;
|
|
467
468
|
}
|
|
468
469
|
if (t.type === "lazy" && t.value == null && await Promise.all([
|
|
469
|
-
this.fetch(
|
|
470
|
-
this.fetch(
|
|
471
|
-
this.fetch(
|
|
470
|
+
this.fetch(d.GeoKeyDirectory),
|
|
471
|
+
this.fetch(d.GeoAsciiParams),
|
|
472
|
+
this.fetch(d.GeoDoubleParams)
|
|
472
473
|
]), this.isGeoTagsLoaded = !0, t.value == null)
|
|
473
474
|
return;
|
|
474
475
|
const n = t.value;
|
|
@@ -498,19 +499,19 @@ class Ft {
|
|
|
498
499
|
* @returns origin point of the image
|
|
499
500
|
*/
|
|
500
501
|
get origin() {
|
|
501
|
-
const t = this.value(
|
|
502
|
+
const t = this.value(d.ModelTiePoint);
|
|
502
503
|
if (t != null && t.length === 6)
|
|
503
504
|
return [t[3], t[4], t[5]];
|
|
504
|
-
const n = this.value(
|
|
505
|
+
const n = this.value(d.ModelTransformation);
|
|
505
506
|
if (n != null)
|
|
506
507
|
return [n[3], n[7], n[11]];
|
|
507
|
-
if (this.value(
|
|
508
|
+
if (this.value(d.SubFileType) === J.ReducedImage && this.id !== 0)
|
|
508
509
|
return this.tiff.images[0].origin;
|
|
509
510
|
throw new Error("Image does not have a geo transformation.");
|
|
510
511
|
}
|
|
511
512
|
/** Is there enough geo information on this image to figure out where its actually located */
|
|
512
513
|
get isGeoLocated() {
|
|
513
|
-
return this.value(
|
|
514
|
+
return this.value(d.ModelPixelScale) != null || this.value(d.ModelTransformation) != null ? !0 : this.isSubImage && this.id !== 0 ? this.tiff.images[0].isGeoLocated : !1;
|
|
514
515
|
}
|
|
515
516
|
/**
|
|
516
517
|
* Get the resolution of the image
|
|
@@ -518,10 +519,10 @@ class Ft {
|
|
|
518
519
|
* @returns [x,y,z] pixel scale
|
|
519
520
|
*/
|
|
520
521
|
get resolution() {
|
|
521
|
-
const t = this.value(
|
|
522
|
+
const t = this.value(d.ModelPixelScale);
|
|
522
523
|
if (t != null)
|
|
523
524
|
return [t[0], -t[1], t[2]];
|
|
524
|
-
const n = this.value(
|
|
525
|
+
const n = this.value(d.ModelTransformation);
|
|
525
526
|
if (n != null)
|
|
526
527
|
return [n[0], n[5], n[10]];
|
|
527
528
|
if (this.isSubImage && this.id !== 0) {
|
|
@@ -536,7 +537,7 @@ class Ft {
|
|
|
536
537
|
* @returns true if SubFileType is Reduces image, false otherwise
|
|
537
538
|
*/
|
|
538
539
|
get isSubImage() {
|
|
539
|
-
return this.value(
|
|
540
|
+
return this.value(d.SubFileType) === J.ReducedImage;
|
|
540
541
|
}
|
|
541
542
|
/**
|
|
542
543
|
* Bounding box of the image
|
|
@@ -558,8 +559,8 @@ class Ft {
|
|
|
558
559
|
* @returns Compression type eg webp
|
|
559
560
|
*/
|
|
560
561
|
get compression() {
|
|
561
|
-
const t = this.value(
|
|
562
|
-
return t == null ? null :
|
|
562
|
+
const t = this.value(d.Compression);
|
|
563
|
+
return t == null ? null : _e[t];
|
|
563
564
|
}
|
|
564
565
|
/**
|
|
565
566
|
* Attempt to read the EPSG Code from TiffGeoTags
|
|
@@ -569,26 +570,26 @@ class Ft {
|
|
|
569
570
|
* @returns EPSG Code if it exists and is not user defined.
|
|
570
571
|
*/
|
|
571
572
|
get epsg() {
|
|
572
|
-
const t = this.valueGeo(
|
|
573
|
-
if (t != null && t !==
|
|
573
|
+
const t = this.valueGeo(m.ProjectionGeoKey);
|
|
574
|
+
if (t != null && t !== Ge)
|
|
574
575
|
return t;
|
|
575
576
|
let n = null;
|
|
576
|
-
switch (this.valueGeo(
|
|
577
|
-
case
|
|
577
|
+
switch (this.valueGeo(m.GTModelTypeGeoKey)) {
|
|
578
|
+
case O.Unknown:
|
|
578
579
|
return null;
|
|
579
|
-
case
|
|
580
|
-
n = this.valueGeo(
|
|
580
|
+
case O.Projected:
|
|
581
|
+
n = this.valueGeo(m.ProjectedCRSGeoKey);
|
|
581
582
|
break;
|
|
582
|
-
case
|
|
583
|
-
n = this.valueGeo(
|
|
583
|
+
case O.Geographic:
|
|
584
|
+
n = this.valueGeo(m.GeodeticCRSGeoKey);
|
|
584
585
|
break;
|
|
585
|
-
case
|
|
586
|
-
n = this.valueGeo(
|
|
586
|
+
case O.Geocentric:
|
|
587
|
+
n = this.valueGeo(m.GeodeticCRSGeoKey);
|
|
587
588
|
break;
|
|
588
|
-
case
|
|
589
|
+
case O.UserDefined:
|
|
589
590
|
return null;
|
|
590
591
|
}
|
|
591
|
-
return n ===
|
|
592
|
+
return n === Ge ? null : n;
|
|
592
593
|
}
|
|
593
594
|
/**
|
|
594
595
|
* Get the size of the image
|
|
@@ -596,7 +597,7 @@ class Ft {
|
|
|
596
597
|
* @returns Size in pixels
|
|
597
598
|
*/
|
|
598
599
|
get size() {
|
|
599
|
-
const t = this.value(
|
|
600
|
+
const t = this.value(d.ImageWidth), n = this.value(d.ImageHeight);
|
|
600
601
|
if (t == null || n == null)
|
|
601
602
|
throw new Error("Tiff has no height or width");
|
|
602
603
|
return { width: t, height: n };
|
|
@@ -605,13 +606,13 @@ class Ft {
|
|
|
605
606
|
* Determine if this image is tiled
|
|
606
607
|
*/
|
|
607
608
|
isTiled() {
|
|
608
|
-
return this.value(
|
|
609
|
+
return this.value(d.TileWidth) !== null;
|
|
609
610
|
}
|
|
610
611
|
/**
|
|
611
612
|
* Get size of individual tiles
|
|
612
613
|
*/
|
|
613
614
|
get tileSize() {
|
|
614
|
-
const t = this.value(
|
|
615
|
+
const t = this.value(d.TileWidth), n = this.value(d.TileHeight);
|
|
615
616
|
if (t == null || n == null)
|
|
616
617
|
throw new Error("Tiff is not tiled");
|
|
617
618
|
return { width: t, height: n };
|
|
@@ -631,7 +632,7 @@ class Ft {
|
|
|
631
632
|
* @returns file offset to where the tiffs are stored
|
|
632
633
|
*/
|
|
633
634
|
get tileOffset() {
|
|
634
|
-
const t = this.tags.get(
|
|
635
|
+
const t = this.tags.get(d.TileOffsets);
|
|
635
636
|
if (t == null)
|
|
636
637
|
throw new Error("No tile offsets found");
|
|
637
638
|
return t;
|
|
@@ -644,7 +645,7 @@ class Ft {
|
|
|
644
645
|
* @returns number of strips present
|
|
645
646
|
*/
|
|
646
647
|
get stripCount() {
|
|
647
|
-
return this.tags.get(
|
|
648
|
+
return this.tags.get(d.StripByteCounts)?.count ?? 0;
|
|
648
649
|
}
|
|
649
650
|
// Clamp the bounds of the output image to the size of the image, as sometimes the edge tiles are not full tiles
|
|
650
651
|
getTileBounds(t, n) {
|
|
@@ -661,18 +662,18 @@ class Ft {
|
|
|
661
662
|
async getStrip(t, n) {
|
|
662
663
|
if (this.isTiled())
|
|
663
664
|
throw new Error("Cannot read stripes, tiff is tiled: " + t);
|
|
664
|
-
const r = this.tags.get(
|
|
665
|
+
const r = this.tags.get(d.StripByteCounts), o = this.tags.get(d.StripOffsets);
|
|
665
666
|
if (t >= r.count)
|
|
666
667
|
throw new Error("Cannot read strip, index out of bounds");
|
|
667
668
|
const [i, a] = await Promise.all([
|
|
668
|
-
|
|
669
|
-
|
|
669
|
+
k(this.tiff, o, t, n),
|
|
670
|
+
k(this.tiff, r, t, n)
|
|
670
671
|
]);
|
|
671
672
|
return this.getBytes(i, a, n);
|
|
672
673
|
}
|
|
673
674
|
/** The jpeg header is stored in the IFD, read the JPEG header and adjust the byte array to include it */
|
|
674
675
|
getJpegHeader(t) {
|
|
675
|
-
const n = this.value(
|
|
676
|
+
const n = this.value(d.JpegTables);
|
|
676
677
|
if (n == null)
|
|
677
678
|
throw new Error("Unable to find Jpeg header");
|
|
678
679
|
const r = n.slice(0, n.length - 2), o = new Uint8Array(t.byteLength + r.length - 2);
|
|
@@ -685,10 +686,10 @@ class Ft {
|
|
|
685
686
|
const o = await this.tiff.source.fetch(t, n, r);
|
|
686
687
|
if (o.byteLength < n)
|
|
687
688
|
throw new Error(`Failed to fetch bytes from offset:${t} wanted:${n} got:${o.byteLength}`);
|
|
688
|
-
let i = this.value(
|
|
689
|
-
i == null && (i =
|
|
690
|
-
const a =
|
|
691
|
-
return i ===
|
|
689
|
+
let i = this.value(d.Compression);
|
|
690
|
+
i == null && (i = f.None);
|
|
691
|
+
const a = Nt(i) ?? S.None;
|
|
692
|
+
return i === f.Jpeg ? { mimeType: a, bytes: this.getJpegHeader(o), compression: i } : { mimeType: a, bytes: o, compression: i };
|
|
692
693
|
}
|
|
693
694
|
/**
|
|
694
695
|
* Load a tile into a ArrayBuffer
|
|
@@ -708,8 +709,8 @@ class Ft {
|
|
|
708
709
|
const l = n * s + t, c = s * a;
|
|
709
710
|
if (l >= c)
|
|
710
711
|
throw new Error(`Tile index is outside of tile range: ${l} >= ${c}`);
|
|
711
|
-
const { offset:
|
|
712
|
-
return this.getBytes(
|
|
712
|
+
const { offset: u, imageSize: h } = await this.getTileSize(l, r);
|
|
713
|
+
return this.getBytes(u, h, r);
|
|
713
714
|
}
|
|
714
715
|
/**
|
|
715
716
|
* Does this tile exist in the tiff and does it actually have a value
|
|
@@ -741,48 +742,48 @@ class Ft {
|
|
|
741
742
|
* @returns Offset and byteCount for the tile
|
|
742
743
|
*/
|
|
743
744
|
async getTileSize(t, n) {
|
|
744
|
-
const r = this.tags.get(
|
|
745
|
+
const r = this.tags.get(d.TileByteCounts), o = ne(this.tiff, this.tileOffset, t), i = ne(this.tiff, r, t);
|
|
745
746
|
if (o != null && i != null)
|
|
746
747
|
return { offset: o, imageSize: i };
|
|
747
748
|
const a = this.tiff.options?.tileLeaderByteSize;
|
|
748
749
|
if (a) {
|
|
749
|
-
const c = o ?? await
|
|
750
|
+
const c = o ?? await k(this.tiff, this.tileOffset, t, n);
|
|
750
751
|
if (c === 0)
|
|
751
752
|
return { offset: 0, imageSize: 0 };
|
|
752
|
-
const
|
|
753
|
-
return { offset: c, imageSize: K(new DataView(
|
|
753
|
+
const u = await this.tiff.source.fetch(c - a, a, n);
|
|
754
|
+
return { offset: c, imageSize: K(new DataView(u), 0, a, this.tiff.isLittleEndian) };
|
|
754
755
|
}
|
|
755
756
|
if (r == null)
|
|
756
757
|
throw new Error("No tile byte counts found");
|
|
757
758
|
const [s, l] = await Promise.all([
|
|
758
|
-
o ??
|
|
759
|
-
i ??
|
|
759
|
+
o ?? k(this.tiff, this.tileOffset, t, n),
|
|
760
|
+
i ?? k(this.tiff, r, t, n)
|
|
760
761
|
]);
|
|
761
762
|
return { offset: s, imageSize: l };
|
|
762
763
|
}
|
|
763
764
|
}
|
|
764
|
-
function
|
|
765
|
-
const o =
|
|
766
|
-
return o != null ? Promise.resolve(o) :
|
|
765
|
+
function k(e, t, n, r) {
|
|
766
|
+
const o = ne(e, t, n);
|
|
767
|
+
return o != null ? Promise.resolve(o) : Jt(e, t, n, r);
|
|
767
768
|
}
|
|
768
|
-
function
|
|
769
|
+
function ne(e, t, n) {
|
|
769
770
|
if (n < 0)
|
|
770
|
-
throw new Error(`Tiff: ${e.source.url.href} out of bounds ${
|
|
771
|
-
return n >= t.count ? 0 : t.type === "inline" || t.isLoaded ? t.value[n] :
|
|
771
|
+
throw new Error(`Tiff: ${e.source.url.href} out of bounds ${d[t.id]} index:${n} total:${t.count}`);
|
|
772
|
+
return n >= t.count ? 0 : t.type === "inline" || t.isLoaded ? t.value[n] : Vt(e, t, n);
|
|
772
773
|
}
|
|
773
774
|
var z;
|
|
774
775
|
(function(e) {
|
|
775
776
|
e.GdalStructuralMetadataSize = "GDAL_STRUCTURAL_METADATA_SIZE", e.Layout = "LAYOUT", e.BlockOrder = "BLOCK_ORDER", e.BlockLeader = "BLOCK_LEADER", e.BlockTrailer = "BLOCK_TRAILER", e.KnownIncompatibleEdition = "KNOWN_INCOMPATIBLE_EDITION", e.MaskInterleavedWithImagery = "MASK_INTERLEAVED_WITH_IMAGERY";
|
|
776
777
|
})(z || (z = {}));
|
|
777
|
-
var
|
|
778
|
+
var ve;
|
|
778
779
|
(function(e) {
|
|
779
780
|
e.RowMajor = "ROW_MAJOR";
|
|
780
|
-
})(
|
|
781
|
-
var
|
|
781
|
+
})(ve || (ve = {}));
|
|
782
|
+
var re;
|
|
782
783
|
(function(e) {
|
|
783
784
|
e.uint32 = "SIZE_AS_UINT4";
|
|
784
|
-
})(
|
|
785
|
-
class
|
|
785
|
+
})(re || (re = {}));
|
|
786
|
+
class Zt {
|
|
786
787
|
options = /* @__PURE__ */ new Map();
|
|
787
788
|
/**
|
|
788
789
|
* Has GDAL optimized this tiff
|
|
@@ -816,8 +817,8 @@ class At {
|
|
|
816
817
|
*/
|
|
817
818
|
get tileLeaderByteSize() {
|
|
818
819
|
switch (this.options.get(z.BlockLeader)) {
|
|
819
|
-
case
|
|
820
|
-
return
|
|
820
|
+
case re.uint32:
|
|
821
|
+
return I.UInt32;
|
|
821
822
|
default:
|
|
822
823
|
return null;
|
|
823
824
|
}
|
|
@@ -826,10 +827,10 @@ class At {
|
|
|
826
827
|
return this.options.get(z.MaskInterleavedWithImagery) === "YES";
|
|
827
828
|
}
|
|
828
829
|
}
|
|
829
|
-
const
|
|
830
|
-
version:
|
|
831
|
-
pointer:
|
|
832
|
-
offset:
|
|
830
|
+
const Je = {
|
|
831
|
+
version: R.Tiff,
|
|
832
|
+
pointer: I.UInt32,
|
|
833
|
+
offset: I.UInt16,
|
|
833
834
|
/**
|
|
834
835
|
* Each tag entry is specified as
|
|
835
836
|
* UInt16:TagCode
|
|
@@ -837,13 +838,13 @@ const Ke = {
|
|
|
837
838
|
* UInt32:TagCount
|
|
838
839
|
* UInt32:Pointer To Value or value
|
|
839
840
|
*/
|
|
840
|
-
ifd:
|
|
841
|
-
},
|
|
842
|
-
version:
|
|
841
|
+
ifd: I.UInt16 + I.UInt16 + 2 * I.UInt32
|
|
842
|
+
}, Ve = {
|
|
843
|
+
version: R.BigTiff,
|
|
843
844
|
/** Size of most pointers */
|
|
844
|
-
pointer:
|
|
845
|
+
pointer: I.UInt64,
|
|
845
846
|
/** Size of offsets */
|
|
846
|
-
offset:
|
|
847
|
+
offset: I.UInt64,
|
|
847
848
|
/**
|
|
848
849
|
* Each tag entry is specified as
|
|
849
850
|
* UInt16:TagCode
|
|
@@ -851,10 +852,10 @@ const Ke = {
|
|
|
851
852
|
* UInt64:TagCount
|
|
852
853
|
* UInt64:Pointer To Value or value
|
|
853
854
|
*/
|
|
854
|
-
ifd:
|
|
855
|
+
ifd: I.UInt16 + I.UInt16 + 2 * I.UInt64
|
|
855
856
|
};
|
|
856
|
-
|
|
857
|
-
function
|
|
857
|
+
R.BigTiff + "", R.Tiff + "";
|
|
858
|
+
function Qt(e, t = 4, n = !0) {
|
|
858
859
|
const r = e.toString(16).padStart(t, "0");
|
|
859
860
|
return n ? "0x" + r : r;
|
|
860
861
|
}
|
|
@@ -866,13 +867,13 @@ class B {
|
|
|
866
867
|
/** Where this cog is fetching its data from */
|
|
867
868
|
source;
|
|
868
869
|
/** Big or small Tiff */
|
|
869
|
-
version =
|
|
870
|
+
version = R.Tiff;
|
|
870
871
|
/** List of images, o is the base image */
|
|
871
872
|
images = [];
|
|
872
873
|
/** Ghost header options */
|
|
873
874
|
options;
|
|
874
875
|
/** Configuration for the size of the IFD */
|
|
875
|
-
ifdConfig =
|
|
876
|
+
ifdConfig = Je;
|
|
876
877
|
/** Is the tiff being read is little Endian */
|
|
877
878
|
isLittleEndian = !1;
|
|
878
879
|
/** Has init() been called */
|
|
@@ -913,16 +914,16 @@ class B {
|
|
|
913
914
|
async readHeader(t) {
|
|
914
915
|
if (this.isInitialized)
|
|
915
916
|
return this;
|
|
916
|
-
const n = new DataView(await this.source.fetch(0,
|
|
917
|
+
const n = new DataView(await this.source.fetch(0, Ee(this.source, 0, this.defaultReadSize), t));
|
|
917
918
|
if (n.byteLength === 0)
|
|
918
919
|
throw new Error("Unable to read empty tiff");
|
|
919
920
|
n.sourceOffset = 0;
|
|
920
921
|
let r = 0;
|
|
921
922
|
const o = n.getUint16(r, this.isLittleEndian);
|
|
922
|
-
r += 2, this.isLittleEndian = o ===
|
|
923
|
+
r += 2, this.isLittleEndian = o === ee.Little, this.version = n.getUint16(r, this.isLittleEndian), r += 2;
|
|
923
924
|
let i;
|
|
924
|
-
if (this.version ===
|
|
925
|
-
this.ifdConfig =
|
|
925
|
+
if (this.version === R.BigTiff) {
|
|
926
|
+
this.ifdConfig = Ve;
|
|
926
927
|
const s = n.getUint16(r, this.isLittleEndian);
|
|
927
928
|
if (r += 2, s !== 8)
|
|
928
929
|
throw new Error("Only 8byte pointers are supported");
|
|
@@ -930,15 +931,15 @@ class B {
|
|
|
930
931
|
if (r += 2, l !== 0)
|
|
931
932
|
throw new Error("Invalid big tiff header");
|
|
932
933
|
i = K(n, r, this.ifdConfig.pointer, this.isLittleEndian), r += this.ifdConfig.pointer;
|
|
933
|
-
} else if (this.version ===
|
|
934
|
+
} else if (this.version === R.Tiff)
|
|
934
935
|
i = K(n, r, this.ifdConfig.pointer, this.isLittleEndian), r += this.ifdConfig.pointer;
|
|
935
936
|
else
|
|
936
937
|
throw new Error(`Only tiff supported version:${String(this.version)}`);
|
|
937
938
|
const a = i - r;
|
|
938
|
-
for (a > 0 && a < 16 * 1024 && (this.options = new
|
|
939
|
+
for (a > 0 && a < 16 * 1024 && (this.options = new Zt(), this.options.process(n, r, a)); i !== 0; ) {
|
|
939
940
|
let s = n;
|
|
940
|
-
if (!
|
|
941
|
-
const l = await this.source.fetch(i,
|
|
941
|
+
if (!X(s, i, 1024)) {
|
|
942
|
+
const l = await this.source.fetch(i, Ee(this.source, i, this.defaultReadSize), t);
|
|
942
943
|
s = new DataView(l), s.sourceOffset = i;
|
|
943
944
|
}
|
|
944
945
|
i = this.readIfd(i, s);
|
|
@@ -953,57 +954,57 @@ class B {
|
|
|
953
954
|
*/
|
|
954
955
|
readIfd(t, n) {
|
|
955
956
|
const r = t - n.sourceOffset, o = K(n, r, this.ifdConfig.offset, this.isLittleEndian), i = /* @__PURE__ */ new Map(), a = o * this.ifdConfig.ifd;
|
|
956
|
-
if (!
|
|
957
|
-
throw new Error("IFD out of range @ " +
|
|
957
|
+
if (!X(n, t, a))
|
|
958
|
+
throw new Error("IFD out of range @ " + Qt(t) + " IFD" + this.images.length);
|
|
958
959
|
const s = this.ifdConfig.ifd, l = r + this.ifdConfig.offset;
|
|
959
960
|
for (let c = 0; c < o; c++) {
|
|
960
|
-
const
|
|
961
|
-
i.set(
|
|
961
|
+
const u = _t(this, n, l + c * s);
|
|
962
|
+
i.set(u.id, u);
|
|
962
963
|
}
|
|
963
|
-
return this.images.push(new
|
|
964
|
+
return this.images.push(new Xt(this, this.images.length, i)), K(n, l + o * s, this.ifdConfig.pointer, this.isLittleEndian);
|
|
964
965
|
}
|
|
965
966
|
}
|
|
966
|
-
function
|
|
967
|
+
function Ee(e, t, n) {
|
|
967
968
|
const r = e.metadata?.size;
|
|
968
969
|
return r == null || r < 0 ? n : t + n > r ? r - t : n;
|
|
969
970
|
}
|
|
970
|
-
async function
|
|
971
|
+
async function se(e, t) {
|
|
971
972
|
const n = new Blob([e]), r = await createImageBitmap(n), o = new OffscreenCanvas(r.width, r.height), i = o.getContext("2d");
|
|
972
973
|
i.drawImage(r, 0, 0), r.close();
|
|
973
|
-
const { width: a, height: s } = o, c = i.getImageData(0, 0, a, s).data,
|
|
974
|
-
if (
|
|
974
|
+
const { width: a, height: s } = o, c = i.getImageData(0, 0, a, s).data, u = t.samplesPerPixel;
|
|
975
|
+
if (u === 4)
|
|
975
976
|
return { layout: "pixel-interleaved", data: c };
|
|
976
|
-
if (
|
|
977
|
-
const h = a * s,
|
|
978
|
-
for (let
|
|
979
|
-
g
|
|
980
|
-
return { layout: "pixel-interleaved", data:
|
|
977
|
+
if (u === 3) {
|
|
978
|
+
const h = a * s, p = new Uint8ClampedArray(h * 3);
|
|
979
|
+
for (let g = 0, y = 0; g < p.length; g += 3, y += 4)
|
|
980
|
+
p[g] = c[y], p[g + 1] = c[y + 1], p[g + 2] = c[y + 2];
|
|
981
|
+
return { layout: "pixel-interleaved", data: p };
|
|
981
982
|
}
|
|
982
|
-
if (
|
|
983
|
-
const h = a * s,
|
|
984
|
-
for (let
|
|
985
|
-
g
|
|
986
|
-
return { layout: "pixel-interleaved", data:
|
|
983
|
+
if (u === 1) {
|
|
984
|
+
const h = a * s, p = new Uint8ClampedArray(h);
|
|
985
|
+
for (let g = 0, y = 0; g < h; g++, y += 4)
|
|
986
|
+
p[g] = c[y];
|
|
987
|
+
return { layout: "pixel-interleaved", data: p };
|
|
987
988
|
}
|
|
988
|
-
throw new Error(`Unsupported SamplesPerPixel for JPEG: ${
|
|
989
|
+
throw new Error(`Unsupported SamplesPerPixel for JPEG: ${u}`);
|
|
989
990
|
}
|
|
990
|
-
function
|
|
991
|
+
function qt(e, t = "") {
|
|
991
992
|
if (!e)
|
|
992
993
|
throw new Error(t);
|
|
993
994
|
}
|
|
994
|
-
async function
|
|
995
|
+
async function Tt(e, { format: t, signal: n }) {
|
|
995
996
|
const r = e instanceof Response ? e : new Response(e);
|
|
996
|
-
|
|
997
|
+
qt(r.body, "Response does not contain body.");
|
|
997
998
|
try {
|
|
998
999
|
return await new Response(r.body.pipeThrough(new DecompressionStream(t), { signal: n })).arrayBuffer();
|
|
999
1000
|
} catch {
|
|
1000
1001
|
throw n?.throwIfAborted(), new Error(`Failed to decode ${t}`);
|
|
1001
1002
|
}
|
|
1002
1003
|
}
|
|
1003
|
-
async function
|
|
1004
|
-
return
|
|
1004
|
+
async function He(e) {
|
|
1005
|
+
return Tt(e, { format: "deflate" });
|
|
1005
1006
|
}
|
|
1006
|
-
function
|
|
1007
|
+
function en(e, t) {
|
|
1007
1008
|
const n = e;
|
|
1008
1009
|
let r = 0, o = e.length - t;
|
|
1009
1010
|
do {
|
|
@@ -1012,7 +1013,7 @@ function Ot(e, t) {
|
|
|
1012
1013
|
o -= t;
|
|
1013
1014
|
} while (o > 0);
|
|
1014
1015
|
}
|
|
1015
|
-
function
|
|
1016
|
+
function tn(e, t, n) {
|
|
1016
1017
|
let r = 0, o = e.length;
|
|
1017
1018
|
const i = o / n;
|
|
1018
1019
|
for (; o > t; ) {
|
|
@@ -1025,78 +1026,78 @@ function Mt(e, t, n) {
|
|
|
1025
1026
|
for (let l = 0; l < n; l++)
|
|
1026
1027
|
e[n * s + l] = a[(n - l - 1) * i + s];
|
|
1027
1028
|
}
|
|
1028
|
-
function
|
|
1029
|
+
function nn(e, t, n, r, o, i, a) {
|
|
1029
1030
|
if (t === _.None)
|
|
1030
1031
|
return e;
|
|
1031
1032
|
const s = o / 8, l = a === U.Separate ? 1 : i;
|
|
1032
1033
|
for (let c = 0; c < r; c++) {
|
|
1033
|
-
const
|
|
1034
|
-
if (
|
|
1034
|
+
const u = c * l * n * s;
|
|
1035
|
+
if (u >= e.byteLength)
|
|
1035
1036
|
break;
|
|
1036
1037
|
if (t === _.Horizontal) {
|
|
1037
1038
|
let h;
|
|
1038
|
-
const
|
|
1039
|
+
const p = l * n;
|
|
1039
1040
|
switch (o) {
|
|
1040
1041
|
case 8:
|
|
1041
|
-
h = new Uint8Array(e,
|
|
1042
|
+
h = new Uint8Array(e, u, p);
|
|
1042
1043
|
break;
|
|
1043
1044
|
case 16:
|
|
1044
|
-
h = new Uint16Array(e,
|
|
1045
|
+
h = new Uint16Array(e, u, p);
|
|
1045
1046
|
break;
|
|
1046
1047
|
case 32:
|
|
1047
|
-
h = new Uint32Array(e,
|
|
1048
|
+
h = new Uint32Array(e, u, p);
|
|
1048
1049
|
break;
|
|
1049
1050
|
default:
|
|
1050
1051
|
throw new Error(`Predictor 2 not supported for ${o} bits per sample.`);
|
|
1051
1052
|
}
|
|
1052
|
-
|
|
1053
|
+
en(h, l);
|
|
1053
1054
|
} else if (t === _.FloatingPoint) {
|
|
1054
|
-
const h = new Uint8Array(e,
|
|
1055
|
-
|
|
1055
|
+
const h = new Uint8Array(e, u, l * n * s);
|
|
1056
|
+
tn(h, l, s);
|
|
1056
1057
|
}
|
|
1057
1058
|
}
|
|
1058
1059
|
return e;
|
|
1059
1060
|
}
|
|
1060
|
-
async function
|
|
1061
|
+
async function rn(e) {
|
|
1061
1062
|
return e;
|
|
1062
1063
|
}
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
async function
|
|
1074
|
-
const r =
|
|
1064
|
+
const j = /* @__PURE__ */ new Map();
|
|
1065
|
+
j.set(f.None, () => Promise.resolve(rn));
|
|
1066
|
+
j.set(f.Deflate, () => Promise.resolve(He));
|
|
1067
|
+
j.set(f.DeflateOther, () => Promise.resolve(He));
|
|
1068
|
+
j.set(f.Lzw, () => import("./lzw-BY5a_5nb.js").then((e) => e.decode));
|
|
1069
|
+
j.set(f.Zstd, () => import("./zstd-jXobGRcq.js").then((e) => e.decode));
|
|
1070
|
+
j.set(f.Jpeg, () => Promise.resolve(se));
|
|
1071
|
+
j.set(f.Jpeg6, () => Promise.resolve(se));
|
|
1072
|
+
j.set(f.Webp, () => Promise.resolve(se));
|
|
1073
|
+
j.set(f.Lerc, () => import("./lerc-aeqKo4fK.js").then((e) => e.l).then((e) => e.decode));
|
|
1074
|
+
async function le(e, t, n) {
|
|
1075
|
+
const r = j.get(t);
|
|
1075
1076
|
if (!r)
|
|
1076
1077
|
throw new Error(`Unsupported compression: ${t}`);
|
|
1077
1078
|
const i = await (await r())(e, n);
|
|
1078
1079
|
if (i instanceof ArrayBuffer) {
|
|
1079
|
-
const { predictor: a, width: s, height: l, bitsPerSample: c, samplesPerPixel:
|
|
1080
|
+
const { predictor: a, width: s, height: l, bitsPerSample: c, samplesPerPixel: u, planarConfiguration: h } = n, p = nn(i, a, s, l, c, u, h);
|
|
1080
1081
|
return {
|
|
1081
1082
|
layout: "pixel-interleaved",
|
|
1082
|
-
data:
|
|
1083
|
+
data: an(p, n)
|
|
1083
1084
|
};
|
|
1084
1085
|
}
|
|
1085
1086
|
return i;
|
|
1086
1087
|
}
|
|
1087
|
-
function
|
|
1088
|
+
function on(e, t) {
|
|
1088
1089
|
const n = new Uint8Array(e), r = new Uint8Array(t);
|
|
1089
1090
|
for (let o = 0; o < t; o++)
|
|
1090
1091
|
r[o] = n[o >> 3] >> 7 - (o & 7) & 1 ? 255 : 0;
|
|
1091
1092
|
return r;
|
|
1092
1093
|
}
|
|
1093
|
-
function
|
|
1094
|
+
function an(e, t) {
|
|
1094
1095
|
const { sampleFormat: n, bitsPerSample: r } = t;
|
|
1095
1096
|
switch (n) {
|
|
1096
|
-
case
|
|
1097
|
+
case A.Uint:
|
|
1097
1098
|
switch (r) {
|
|
1098
1099
|
case 1:
|
|
1099
|
-
return
|
|
1100
|
+
return on(e, t.width * t.height * t.samplesPerPixel);
|
|
1100
1101
|
case 8:
|
|
1101
1102
|
return new Uint8Array(e);
|
|
1102
1103
|
case 16:
|
|
@@ -1105,7 +1106,7 @@ function Nt(e, t) {
|
|
|
1105
1106
|
return new Uint32Array(e);
|
|
1106
1107
|
}
|
|
1107
1108
|
break;
|
|
1108
|
-
case
|
|
1109
|
+
case A.Int:
|
|
1109
1110
|
switch (r) {
|
|
1110
1111
|
case 8:
|
|
1111
1112
|
return new Int8Array(e);
|
|
@@ -1115,7 +1116,7 @@ function Nt(e, t) {
|
|
|
1115
1116
|
return new Int32Array(e);
|
|
1116
1117
|
}
|
|
1117
1118
|
break;
|
|
1118
|
-
case
|
|
1119
|
+
case A.Float:
|
|
1119
1120
|
switch (r) {
|
|
1120
1121
|
case 32:
|
|
1121
1122
|
return new Float32Array(e);
|
|
@@ -1126,7 +1127,7 @@ function Nt(e, t) {
|
|
|
1126
1127
|
}
|
|
1127
1128
|
throw new Error(`Unsupported sample format/depth: SampleFormat=${n}, BitsPerSample=${r}`);
|
|
1128
1129
|
}
|
|
1129
|
-
class
|
|
1130
|
+
class sn {
|
|
1130
1131
|
name = "source:cache";
|
|
1131
1132
|
maxSize;
|
|
1132
1133
|
/** Number of bytes cached in cacheA, when this overflows maxSize cacheA is moved to cacheB and cacheB is dropped */
|
|
@@ -1149,7 +1150,7 @@ class zt {
|
|
|
1149
1150
|
return o ? (o.hits++, o.promise) : (o = this.cacheB.get(r), o ? (o.hits++, o.saves++, this.size += o.size, this.cacheA.set(r, o), o.promise) : (o = { promise: n(t), hits: 0, saves: 0, size: t.length }, this.size += o.size, this.size > this.maxSize && (this.size = o.size, this.cacheB = this.cacheA, this.cacheA = /* @__PURE__ */ new Map(), this.resets++), this.cacheA.set(r, o), o.promise));
|
|
1150
1151
|
}
|
|
1151
1152
|
}
|
|
1152
|
-
class
|
|
1153
|
+
class M extends Error {
|
|
1153
1154
|
/** Status code for the error eg 403 - Forbidden vs 404 Not found */
|
|
1154
1155
|
code;
|
|
1155
1156
|
/** URL that the status code came from */
|
|
@@ -1165,10 +1166,10 @@ class O extends Error {
|
|
|
1165
1166
|
}
|
|
1166
1167
|
/** Check that a unknown is a FsError */
|
|
1167
1168
|
static is(t) {
|
|
1168
|
-
return t instanceof
|
|
1169
|
+
return t instanceof M ? !0 : typeof t != "object" || t == null ? !1 : "_sourceError" in t && t._sourceError === "SourceError";
|
|
1169
1170
|
}
|
|
1170
1171
|
}
|
|
1171
|
-
const
|
|
1172
|
+
const Q = {
|
|
1172
1173
|
/** Convert a offset/length to a range request
|
|
1173
1174
|
*
|
|
1174
1175
|
* @example
|
|
@@ -1205,7 +1206,7 @@ const X = {
|
|
|
1205
1206
|
return o;
|
|
1206
1207
|
}
|
|
1207
1208
|
};
|
|
1208
|
-
class
|
|
1209
|
+
class ln {
|
|
1209
1210
|
source;
|
|
1210
1211
|
middleware;
|
|
1211
1212
|
static is(t) {
|
|
@@ -1246,14 +1247,14 @@ class Bt {
|
|
|
1246
1247
|
return t({ source: this, offset: n, length: r, signal: o?.signal });
|
|
1247
1248
|
}
|
|
1248
1249
|
}
|
|
1249
|
-
function
|
|
1250
|
+
function cn(e) {
|
|
1250
1251
|
try {
|
|
1251
1252
|
return new URL(e);
|
|
1252
1253
|
} catch {
|
|
1253
1254
|
return null;
|
|
1254
1255
|
}
|
|
1255
1256
|
}
|
|
1256
|
-
class
|
|
1257
|
+
class un {
|
|
1257
1258
|
name = "source:chunk";
|
|
1258
1259
|
/** Number of bytes to chunk requests into */
|
|
1259
1260
|
chunkSize;
|
|
@@ -1265,7 +1266,7 @@ class kt {
|
|
|
1265
1266
|
return n(t);
|
|
1266
1267
|
const r = Math.floor(t.offset / this.chunkSize), o = Math.ceil((t.offset + t.length) / this.chunkSize), i = t.source.metadata?.size;
|
|
1267
1268
|
if (i != null && t.offset + t.length > i)
|
|
1268
|
-
throw new
|
|
1269
|
+
throw new M(`Request outside of bounds ${Q.toRange(t.offset, t.length)}`, 416, t.source);
|
|
1269
1270
|
const a = r * this.chunkSize, l = (i != null ? Math.min(o * this.chunkSize, i) : o * this.chunkSize) - a, c = t.offset - a;
|
|
1270
1271
|
return o - r > 1 ? (await this.fetchChunks(t, r, o)).slice(c, c + t.length) : t.offset === a && t.length === l ? n(t) : (await n({ ...t, offset: a, length: l })).slice(c, c + t.length);
|
|
1271
1272
|
}
|
|
@@ -1281,15 +1282,15 @@ class kt {
|
|
|
1281
1282
|
return s.buffer;
|
|
1282
1283
|
}
|
|
1283
1284
|
}
|
|
1284
|
-
function
|
|
1285
|
+
function Fe(e) {
|
|
1285
1286
|
const t = {}, n = e.headers.get("content-length");
|
|
1286
1287
|
n && (t.size = parseInt(n));
|
|
1287
1288
|
const r = e.headers.get("content-range");
|
|
1288
|
-
return r != null && (t.size =
|
|
1289
|
+
return r != null && (t.size = Q.parseSize(r)), t.eTag = e.headers.get("etag") ?? void 0, t.contentType = e.headers.get("content-type") ?? void 0, t.contentDisposition = e.headers.get("content-disposition") ?? void 0, t.cacheControl = e.headers.get("cache-control") ?? void 0, t.contentEncoding = e.headers.get("content-encoding") ?? void 0, t;
|
|
1289
1290
|
}
|
|
1290
|
-
class
|
|
1291
|
+
class $ {
|
|
1291
1292
|
constructor(t, n) {
|
|
1292
|
-
this.type = "http", this.url = typeof t == "string" ?
|
|
1293
|
+
this.type = "http", this.url = typeof t == "string" ? $.tryUrl(t) : t, this.headers = n;
|
|
1293
1294
|
}
|
|
1294
1295
|
/** Attempt to parse a relative string into a URL */
|
|
1295
1296
|
static tryUrl(t) {
|
|
@@ -1300,36 +1301,36 @@ class k {
|
|
|
1300
1301
|
}
|
|
1301
1302
|
}
|
|
1302
1303
|
head() {
|
|
1303
|
-
return this._head ? this._head : (this._head =
|
|
1304
|
+
return this._head ? this._head : (this._head = $.fetch(this.url, { method: "HEAD", headers: this.headers }).then((t) => {
|
|
1304
1305
|
if (!t.ok)
|
|
1305
1306
|
throw delete this._head, new Error(`Failed to HEAD ${this.url.href}`, { cause: { statusCode: t.status, msg: t.statusText } });
|
|
1306
|
-
return this.metadata =
|
|
1307
|
+
return this.metadata = Fe(t), this.metadata;
|
|
1307
1308
|
}), this._head);
|
|
1308
1309
|
}
|
|
1309
1310
|
async fetch(t, n, r) {
|
|
1310
1311
|
try {
|
|
1311
|
-
const o = { range:
|
|
1312
|
+
const o = { range: Q.toRange(t, n), ...this.headers }, i = await $.fetch(this.url, { headers: o, signal: r?.signal });
|
|
1312
1313
|
if (!i.ok)
|
|
1313
|
-
throw new
|
|
1314
|
-
const a =
|
|
1314
|
+
throw new M(`Failed to fetch ${this.url.href} ${o.range}`, i.status, this, new Error(i.statusText));
|
|
1315
|
+
const a = Fe(i);
|
|
1315
1316
|
if (this.metadata == null)
|
|
1316
1317
|
this.metadata = a;
|
|
1317
1318
|
else if (this.metadata.eTag && this.metadata.eTag !== a.eTag)
|
|
1318
|
-
throw new
|
|
1319
|
+
throw new M(`ETag conflict ${this.url.href} ${o.range} expected: ${this.metadata.eTag} got: ${a.eTag}`, 409, this);
|
|
1319
1320
|
return i.arrayBuffer();
|
|
1320
1321
|
} catch (o) {
|
|
1321
|
-
throw
|
|
1322
|
+
throw M.is(o) && o.source === this ? o : new M(`Failed to fetch: ${this.url.href}`, 500, this, o);
|
|
1322
1323
|
}
|
|
1323
1324
|
}
|
|
1324
1325
|
}
|
|
1325
|
-
|
|
1326
|
-
function
|
|
1326
|
+
$.fetch = (e, t) => fetch(e, t);
|
|
1327
|
+
function dn(e) {
|
|
1327
1328
|
if (typeof e != "string")
|
|
1328
1329
|
return e;
|
|
1329
|
-
const t =
|
|
1330
|
+
const t = cn(e);
|
|
1330
1331
|
return t || new URL("memory://" + e);
|
|
1331
1332
|
}
|
|
1332
|
-
class
|
|
1333
|
+
class ce {
|
|
1333
1334
|
url;
|
|
1334
1335
|
type = "memory";
|
|
1335
1336
|
data;
|
|
@@ -1338,49 +1339,49 @@ class ae {
|
|
|
1338
1339
|
return t instanceof ArrayBuffer ? t : t.byteLength === t.buffer.byteLength ? t.buffer : t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
1339
1340
|
}
|
|
1340
1341
|
constructor(t, n) {
|
|
1341
|
-
const r =
|
|
1342
|
-
this.url =
|
|
1342
|
+
const r = ce.toArrayBuffer(n ?? new Uint8Array());
|
|
1343
|
+
this.url = dn(t), this.data = r, this.metadata = { size: r.byteLength };
|
|
1343
1344
|
}
|
|
1344
1345
|
head() {
|
|
1345
1346
|
return Promise.resolve({ size: this.data.byteLength });
|
|
1346
1347
|
}
|
|
1347
1348
|
fetch(t, n) {
|
|
1348
1349
|
if (t < 0 && (t = this.data.byteLength + t), t > this.data.byteLength)
|
|
1349
|
-
throw new
|
|
1350
|
+
throw new M(`Read offset outside of file bounds range:${Q.toRange(t, n)} fileSize:${this.data.byteLength}`, 416, this);
|
|
1350
1351
|
return Promise.resolve(this.data.slice(t, n == null ? void 0 : t + n));
|
|
1351
1352
|
}
|
|
1352
1353
|
}
|
|
1353
|
-
const
|
|
1354
|
-
[
|
|
1355
|
-
[
|
|
1356
|
-
[
|
|
1357
|
-
},
|
|
1354
|
+
const Ye = "https://proj.org/schemas/v0.7/projjson.schema.json", hn = 1, pn = 2, V = 32767, Ae = 1, mn = 2, gn = 3, fn = 4, yn = 5, wn = 6, Sn = 7, Pn = 8, bn = 9, Cn = 10, Ln = 11, In = 12, Gn = 14, vn = 15, En = 16, Fn = 17, An = 18, jn = 21, Rn = 22, Un = 24, Mn = 26, On = 27, Xe = 9102, Kn = 9101, xn = 9105, Dn = {
|
|
1355
|
+
[Xe]: "degree",
|
|
1356
|
+
[Kn]: "radian",
|
|
1357
|
+
[xn]: "grad"
|
|
1358
|
+
}, Ze = 9001, Nn = 9002, zn = 9003, Bn = {
|
|
1358
1359
|
type: "LinearUnit",
|
|
1359
1360
|
name: "US survey foot",
|
|
1360
1361
|
conversion_factor: 0.30480060960121924
|
|
1361
|
-
},
|
|
1362
|
-
[
|
|
1363
|
-
[
|
|
1364
|
-
[
|
|
1362
|
+
}, _n = {
|
|
1363
|
+
[Ze]: "metre",
|
|
1364
|
+
[Nn]: "foot",
|
|
1365
|
+
[zn]: Bn
|
|
1365
1366
|
};
|
|
1366
|
-
function
|
|
1367
|
+
function $n(e) {
|
|
1367
1368
|
const t = e.modelType;
|
|
1368
|
-
if (t ===
|
|
1369
|
-
return
|
|
1370
|
-
if (t ===
|
|
1371
|
-
return
|
|
1369
|
+
if (t === hn)
|
|
1370
|
+
return Wn(e);
|
|
1371
|
+
if (t === pn)
|
|
1372
|
+
return kn(e);
|
|
1372
1373
|
throw new Error(`Unsupported GeoTIFF model type: ${t}`);
|
|
1373
1374
|
}
|
|
1374
|
-
function
|
|
1375
|
+
function kn(e) {
|
|
1375
1376
|
const t = e.geodeticCRS;
|
|
1376
|
-
return t !== null && t !== V ? t :
|
|
1377
|
+
return t !== null && t !== V ? t : Qe(e, Ye);
|
|
1377
1378
|
}
|
|
1378
|
-
function
|
|
1379
|
+
function Wn(e) {
|
|
1379
1380
|
const t = e.projectedCRS;
|
|
1380
|
-
return t !== null && t !== V ? t :
|
|
1381
|
+
return t !== null && t !== V ? t : Jn(e);
|
|
1381
1382
|
}
|
|
1382
|
-
function
|
|
1383
|
-
const n =
|
|
1383
|
+
function Qe(e, t) {
|
|
1384
|
+
const n = Vn(e);
|
|
1384
1385
|
let r = "Greenwich", o = 0;
|
|
1385
1386
|
e.primeMeridian !== null && e.primeMeridian !== V ? r = `EPSG:${e.primeMeridian}` : e.primeMeridianLongitude !== null && (o = e.primeMeridianLongitude, r = "User-defined");
|
|
1386
1387
|
let i;
|
|
@@ -1397,22 +1398,22 @@ function _e(e, t) {
|
|
|
1397
1398
|
type: "GeographicCRS",
|
|
1398
1399
|
name: e.geodeticCitation ?? "User-defined",
|
|
1399
1400
|
datum: i,
|
|
1400
|
-
coordinate_system:
|
|
1401
|
+
coordinate_system: Yn(e)
|
|
1401
1402
|
};
|
|
1402
1403
|
return t !== void 0 && (a.$schema = t), a;
|
|
1403
1404
|
}
|
|
1404
|
-
function
|
|
1405
|
-
const t =
|
|
1405
|
+
function Jn(e) {
|
|
1406
|
+
const t = Qe(e), n = Hn(e), r = Xn(e);
|
|
1406
1407
|
return {
|
|
1407
1408
|
type: "ProjectedCRS",
|
|
1408
|
-
$schema:
|
|
1409
|
+
$schema: Ye,
|
|
1409
1410
|
name: e.projectedCitation ?? e.citation ?? "User-defined",
|
|
1410
1411
|
base_crs: t,
|
|
1411
1412
|
conversion: n,
|
|
1412
1413
|
coordinate_system: r
|
|
1413
1414
|
};
|
|
1414
1415
|
}
|
|
1415
|
-
function
|
|
1416
|
+
function Vn(e) {
|
|
1416
1417
|
if (e.ellipsoid !== null && e.ellipsoid !== V) {
|
|
1417
1418
|
const n = {
|
|
1418
1419
|
name: `EPSG ellipsoid ${e.ellipsoid}`
|
|
@@ -1433,7 +1434,7 @@ function Gn(e) {
|
|
|
1433
1434
|
throw new Error("User-defined ellipsoid requires ellipsoidInvFlattening or ellipsoidSemiMinorAxis");
|
|
1434
1435
|
return t;
|
|
1435
1436
|
}
|
|
1436
|
-
function
|
|
1437
|
+
function Hn(e) {
|
|
1437
1438
|
const t = e.projMethod;
|
|
1438
1439
|
if (t === null)
|
|
1439
1440
|
throw new Error("User-defined projected CRS requires projMethod");
|
|
@@ -1451,10 +1452,10 @@ function jn(e) {
|
|
|
1451
1452
|
unit: "unity"
|
|
1452
1453
|
});
|
|
1453
1454
|
switch (t) {
|
|
1454
|
-
case
|
|
1455
|
-
case
|
|
1456
|
-
case
|
|
1457
|
-
const i = t ===
|
|
1455
|
+
case Ae:
|
|
1456
|
+
case mn:
|
|
1457
|
+
case On: {
|
|
1458
|
+
const i = t === Ae ? "Transverse Mercator" : "Transverse Mercator (South Orientated)";
|
|
1458
1459
|
return {
|
|
1459
1460
|
name: i,
|
|
1460
1461
|
method: { name: i },
|
|
@@ -1467,10 +1468,10 @@ function jn(e) {
|
|
|
1467
1468
|
]
|
|
1468
1469
|
};
|
|
1469
1470
|
}
|
|
1470
|
-
case
|
|
1471
|
-
case
|
|
1472
|
-
case
|
|
1473
|
-
case
|
|
1471
|
+
case gn:
|
|
1472
|
+
case fn:
|
|
1473
|
+
case yn:
|
|
1474
|
+
case wn: {
|
|
1474
1475
|
const i = "Hotine Oblique Mercator (variant B)";
|
|
1475
1476
|
return {
|
|
1476
1477
|
name: i,
|
|
@@ -1486,7 +1487,7 @@ function jn(e) {
|
|
|
1486
1487
|
]
|
|
1487
1488
|
};
|
|
1488
1489
|
}
|
|
1489
|
-
case
|
|
1490
|
+
case Sn: {
|
|
1490
1491
|
const i = "Mercator (variant A)";
|
|
1491
1492
|
return {
|
|
1492
1493
|
name: i,
|
|
@@ -1500,7 +1501,7 @@ function jn(e) {
|
|
|
1500
1501
|
]
|
|
1501
1502
|
};
|
|
1502
1503
|
}
|
|
1503
|
-
case
|
|
1504
|
+
case Pn: {
|
|
1504
1505
|
const i = "Lambert Conic Conformal (2SP)";
|
|
1505
1506
|
return {
|
|
1506
1507
|
name: i,
|
|
@@ -1515,7 +1516,7 @@ function jn(e) {
|
|
|
1515
1516
|
]
|
|
1516
1517
|
};
|
|
1517
1518
|
}
|
|
1518
|
-
case
|
|
1519
|
+
case bn: {
|
|
1519
1520
|
const i = "Lambert Conic Conformal (1SP)";
|
|
1520
1521
|
return {
|
|
1521
1522
|
name: i,
|
|
@@ -1529,7 +1530,7 @@ function jn(e) {
|
|
|
1529
1530
|
]
|
|
1530
1531
|
};
|
|
1531
1532
|
}
|
|
1532
|
-
case
|
|
1533
|
+
case Cn: {
|
|
1533
1534
|
const i = "Lambert Azimuthal Equal Area";
|
|
1534
1535
|
return {
|
|
1535
1536
|
name: i,
|
|
@@ -1542,7 +1543,7 @@ function jn(e) {
|
|
|
1542
1543
|
]
|
|
1543
1544
|
};
|
|
1544
1545
|
}
|
|
1545
|
-
case
|
|
1546
|
+
case Ln: {
|
|
1546
1547
|
const i = "Albers Equal Area";
|
|
1547
1548
|
return {
|
|
1548
1549
|
name: i,
|
|
@@ -1557,7 +1558,7 @@ function jn(e) {
|
|
|
1557
1558
|
]
|
|
1558
1559
|
};
|
|
1559
1560
|
}
|
|
1560
|
-
case
|
|
1561
|
+
case In: {
|
|
1561
1562
|
const i = "Modified Azimuthal Equidistant";
|
|
1562
1563
|
return {
|
|
1563
1564
|
name: i,
|
|
@@ -1570,7 +1571,7 @@ function jn(e) {
|
|
|
1570
1571
|
]
|
|
1571
1572
|
};
|
|
1572
1573
|
}
|
|
1573
|
-
case
|
|
1574
|
+
case Gn: {
|
|
1574
1575
|
const i = "Stereographic";
|
|
1575
1576
|
return {
|
|
1576
1577
|
name: i,
|
|
@@ -1584,7 +1585,7 @@ function jn(e) {
|
|
|
1584
1585
|
]
|
|
1585
1586
|
};
|
|
1586
1587
|
}
|
|
1587
|
-
case
|
|
1588
|
+
case vn: {
|
|
1588
1589
|
const i = "Polar Stereographic (variant B)";
|
|
1589
1590
|
return {
|
|
1590
1591
|
name: i,
|
|
@@ -1597,7 +1598,7 @@ function jn(e) {
|
|
|
1597
1598
|
]
|
|
1598
1599
|
};
|
|
1599
1600
|
}
|
|
1600
|
-
case
|
|
1601
|
+
case En: {
|
|
1601
1602
|
const i = "Oblique Stereographic";
|
|
1602
1603
|
return {
|
|
1603
1604
|
name: i,
|
|
@@ -1611,7 +1612,7 @@ function jn(e) {
|
|
|
1611
1612
|
]
|
|
1612
1613
|
};
|
|
1613
1614
|
}
|
|
1614
|
-
case
|
|
1615
|
+
case Fn: {
|
|
1615
1616
|
const i = "Equidistant Cylindrical";
|
|
1616
1617
|
return {
|
|
1617
1618
|
name: i,
|
|
@@ -1624,7 +1625,7 @@ function jn(e) {
|
|
|
1624
1625
|
]
|
|
1625
1626
|
};
|
|
1626
1627
|
}
|
|
1627
|
-
case
|
|
1628
|
+
case An: {
|
|
1628
1629
|
const i = "Cassini-Soldner";
|
|
1629
1630
|
return {
|
|
1630
1631
|
name: i,
|
|
@@ -1637,7 +1638,7 @@ function jn(e) {
|
|
|
1637
1638
|
]
|
|
1638
1639
|
};
|
|
1639
1640
|
}
|
|
1640
|
-
case
|
|
1641
|
+
case Rn: {
|
|
1641
1642
|
const i = "American Polyconic";
|
|
1642
1643
|
return {
|
|
1643
1644
|
name: i,
|
|
@@ -1650,7 +1651,7 @@ function jn(e) {
|
|
|
1650
1651
|
]
|
|
1651
1652
|
};
|
|
1652
1653
|
}
|
|
1653
|
-
case
|
|
1654
|
+
case Un: {
|
|
1654
1655
|
const i = "Sinusoidal";
|
|
1655
1656
|
return {
|
|
1656
1657
|
name: i,
|
|
@@ -1662,7 +1663,7 @@ function jn(e) {
|
|
|
1662
1663
|
]
|
|
1663
1664
|
};
|
|
1664
1665
|
}
|
|
1665
|
-
case
|
|
1666
|
+
case jn: {
|
|
1666
1667
|
const i = "Orthographic";
|
|
1667
1668
|
return {
|
|
1668
1669
|
name: i,
|
|
@@ -1675,7 +1676,7 @@ function jn(e) {
|
|
|
1675
1676
|
]
|
|
1676
1677
|
};
|
|
1677
1678
|
}
|
|
1678
|
-
case
|
|
1679
|
+
case Mn: {
|
|
1679
1680
|
const i = "New Zealand Map Grid";
|
|
1680
1681
|
return {
|
|
1681
1682
|
name: i,
|
|
@@ -1692,8 +1693,8 @@ function jn(e) {
|
|
|
1692
1693
|
throw new Error(`Unsupported coordinate transformation type: ${t}`);
|
|
1693
1694
|
}
|
|
1694
1695
|
}
|
|
1695
|
-
function
|
|
1696
|
-
const t =
|
|
1696
|
+
function Yn(e) {
|
|
1697
|
+
const t = Dn[e.angularUnits ?? Xe] ?? "degree";
|
|
1697
1698
|
return {
|
|
1698
1699
|
subtype: "ellipsoidal",
|
|
1699
1700
|
axis: [
|
|
@@ -1712,8 +1713,8 @@ function En(e) {
|
|
|
1712
1713
|
]
|
|
1713
1714
|
};
|
|
1714
1715
|
}
|
|
1715
|
-
function
|
|
1716
|
-
const t =
|
|
1716
|
+
function Xn(e) {
|
|
1717
|
+
const t = _n[e.projLinearUnits ?? Ze] ?? "metre";
|
|
1717
1718
|
return {
|
|
1718
1719
|
subtype: "Cartesian",
|
|
1719
1720
|
axis: [
|
|
@@ -1722,20 +1723,20 @@ function Fn(e) {
|
|
|
1722
1723
|
]
|
|
1723
1724
|
};
|
|
1724
1725
|
}
|
|
1725
|
-
const
|
|
1726
|
-
async function
|
|
1726
|
+
const Zn = 1024 * 1024, Qn = 16 * 1024 * 1024, je = 6;
|
|
1727
|
+
async function qn(e, t, n) {
|
|
1727
1728
|
if (t.length === 0)
|
|
1728
1729
|
return [];
|
|
1729
|
-
const r = n?.coalesce ??
|
|
1730
|
+
const r = n?.coalesce ?? Zn, o = n?.maxRangeSize ?? Qn, i = n?.signal, a = Tn(t, r, o), s = await tr(e, a, i), l = new Array(t.length);
|
|
1730
1731
|
for (let c = 0; c < t.length; c++) {
|
|
1731
|
-
const
|
|
1732
|
-
if (P >
|
|
1733
|
-
throw new Error(`Failed to fetch bytes from offset:${
|
|
1734
|
-
l[c] =
|
|
1732
|
+
const u = t[c], h = er(a, u.offset), p = a[h], g = s[h], y = u.offset - p.offset, P = y + u.length;
|
|
1733
|
+
if (P > g.byteLength)
|
|
1734
|
+
throw new Error(`Failed to fetch bytes from offset:${u.offset} wanted:${u.length} got:${g.byteLength - y}`);
|
|
1735
|
+
l[c] = g.slice(y, P);
|
|
1735
1736
|
}
|
|
1736
1737
|
return l;
|
|
1737
1738
|
}
|
|
1738
|
-
function
|
|
1739
|
+
function Tn(e, t, n) {
|
|
1739
1740
|
const r = [...e].sort((a, s) => a.offset - s.offset), o = [];
|
|
1740
1741
|
let i = null;
|
|
1741
1742
|
for (const a of r) {
|
|
@@ -1743,12 +1744,12 @@ function Un(e, t, n) {
|
|
|
1743
1744
|
i = { offset: a.offset, length: a.length };
|
|
1744
1745
|
continue;
|
|
1745
1746
|
}
|
|
1746
|
-
const s = i.offset + i.length, l = a.offset + a.length, c = a.offset - s,
|
|
1747
|
-
c <= t && h <= n ? i.length =
|
|
1747
|
+
const s = i.offset + i.length, l = a.offset + a.length, c = a.offset - s, u = Math.max(s, l), h = u - i.offset;
|
|
1748
|
+
c <= t && h <= n ? i.length = u - i.offset : (o.push(i), i = { offset: a.offset, length: a.length });
|
|
1748
1749
|
}
|
|
1749
1750
|
return i != null && o.push(i), o;
|
|
1750
1751
|
}
|
|
1751
|
-
function
|
|
1752
|
+
function er(e, t) {
|
|
1752
1753
|
let n = 0, r = e.length - 1;
|
|
1753
1754
|
for (; n < r; ) {
|
|
1754
1755
|
const o = n + r + 1 >>> 1;
|
|
@@ -1756,82 +1757,82 @@ function On(e, t) {
|
|
|
1756
1757
|
}
|
|
1757
1758
|
return n;
|
|
1758
1759
|
}
|
|
1759
|
-
async function
|
|
1760
|
+
async function tr(e, t, n) {
|
|
1760
1761
|
const r = new Array(t.length);
|
|
1761
|
-
for (let o = 0; o < t.length; o +=
|
|
1762
|
-
const i = t.slice(o, o +
|
|
1762
|
+
for (let o = 0; o < t.length; o += je) {
|
|
1763
|
+
const i = t.slice(o, o + je), a = await Promise.all(i.map((s) => e.fetch(s.offset, s.length, { signal: n })));
|
|
1763
1764
|
for (let s = 0; s < a.length; s++)
|
|
1764
1765
|
r[o + s] = a[s];
|
|
1765
1766
|
}
|
|
1766
1767
|
return r;
|
|
1767
1768
|
}
|
|
1768
|
-
async function
|
|
1769
|
-
const a =
|
|
1769
|
+
async function qe(e, t, n, { boundless: r = !0, pool: o, signal: i } = {}) {
|
|
1770
|
+
const a = or(e, t, n, { signal: i }), s = e.maskImage != null ? nt(e.maskImage, t, n, e.dataSource, {
|
|
1770
1771
|
signal: i,
|
|
1771
1772
|
debug: e._debug ? { label: "mask" } : void 0
|
|
1772
1773
|
}) : Promise.resolve(null), [l, c] = await Promise.all([a, s]);
|
|
1773
|
-
return
|
|
1774
|
+
return Te(e, t, n, l, c, { boundless: r, pool: o });
|
|
1774
1775
|
}
|
|
1775
|
-
async function
|
|
1776
|
-
const { bitsPerSample: s, predictor: l, planarConfiguration: c, sampleFormat:
|
|
1777
|
-
sampleFormat:
|
|
1778
|
-
bitsPerSample:
|
|
1776
|
+
async function Te(e, t, n, r, o, { boundless: i, pool: a }) {
|
|
1777
|
+
const { bitsPerSample: s, predictor: l, planarConfiguration: c, sampleFormat: u, lercParameters: h } = e.cachedTags, { sampleFormat: p, bitsPerSample: g } = at(u, s), y = ae(e.transform, ze(t * e.tileWidth, n * e.tileHeight)), P = e.image.value(d.SamplesPerPixel) ?? 1, b = {
|
|
1778
|
+
sampleFormat: p,
|
|
1779
|
+
bitsPerSample: g,
|
|
1779
1780
|
samplesPerPixel: P,
|
|
1780
1781
|
width: e.tileWidth,
|
|
1781
1782
|
height: e.tileHeight,
|
|
1782
1783
|
predictor: l,
|
|
1783
1784
|
planarConfiguration: c,
|
|
1784
1785
|
lercParameters: h
|
|
1785
|
-
}, [
|
|
1786
|
-
|
|
1787
|
-
o != null && e.maskImage != null ?
|
|
1788
|
-
]),
|
|
1789
|
-
...
|
|
1786
|
+
}, [v, C] = await Promise.all([
|
|
1787
|
+
rr(r, b, a),
|
|
1788
|
+
o != null && e.maskImage != null ? nr(o, e.maskImage, a) : Promise.resolve(null)
|
|
1789
|
+
]), L = {
|
|
1790
|
+
...v,
|
|
1790
1791
|
count: P,
|
|
1791
1792
|
height: e.tileHeight,
|
|
1792
1793
|
width: e.tileWidth,
|
|
1793
|
-
mask:
|
|
1794
|
-
transform:
|
|
1794
|
+
mask: C,
|
|
1795
|
+
transform: y,
|
|
1795
1796
|
crs: e.crs,
|
|
1796
1797
|
nodata: e.nodata
|
|
1797
1798
|
};
|
|
1798
1799
|
return {
|
|
1799
1800
|
x: t,
|
|
1800
1801
|
y: n,
|
|
1801
|
-
array: i === !0 ?
|
|
1802
|
+
array: i === !0 ? L : lr(e, t, n, L)
|
|
1802
1803
|
};
|
|
1803
1804
|
}
|
|
1804
|
-
async function
|
|
1805
|
+
async function et(e, t, { boundless: n = !0, pool: r, signal: o } = {}) {
|
|
1805
1806
|
if (t.length === 0)
|
|
1806
1807
|
return [];
|
|
1807
|
-
const i =
|
|
1808
|
+
const i = ar(e, t, { signal: o }), a = e.maskImage != null ? it(e.maskImage, t, e.dataSource, {
|
|
1808
1809
|
signal: o,
|
|
1809
1810
|
debug: e._debug ? { label: "mask" } : void 0
|
|
1810
1811
|
}) : Promise.resolve(t.map(() => null)), [s, l] = await Promise.all([
|
|
1811
1812
|
i,
|
|
1812
1813
|
a
|
|
1813
1814
|
]);
|
|
1814
|
-
return Promise.all(t.map(([c,
|
|
1815
|
+
return Promise.all(t.map(([c, u], h) => Te(e, c, u, s[h], l[h] ?? null, {
|
|
1815
1816
|
boundless: n,
|
|
1816
1817
|
pool: r
|
|
1817
1818
|
})));
|
|
1818
1819
|
}
|
|
1819
|
-
async function
|
|
1820
|
-
const r = t.value(
|
|
1820
|
+
async function nr(e, t, n) {
|
|
1821
|
+
const r = t.value(d.SampleFormat) ?? [1], o = t.value(d.BitsPerSample) ?? [8], { sampleFormat: i, bitsPerSample: a } = at(r, new Uint16Array(o)), { width: s, height: l } = t.tileSize, c = {
|
|
1821
1822
|
sampleFormat: i,
|
|
1822
1823
|
bitsPerSample: a,
|
|
1823
|
-
samplesPerPixel: t.value(
|
|
1824
|
+
samplesPerPixel: t.value(d.SamplesPerPixel) ?? 1,
|
|
1824
1825
|
width: s,
|
|
1825
1826
|
height: l,
|
|
1826
|
-
predictor: t.value(
|
|
1827
|
-
planarConfiguration: t.value(
|
|
1828
|
-
},
|
|
1829
|
-
if (
|
|
1830
|
-
return
|
|
1827
|
+
predictor: t.value(d.Predictor) ?? 1,
|
|
1828
|
+
planarConfiguration: t.value(d.PlanarConfiguration) ?? U.Contig
|
|
1829
|
+
}, u = (P, b, v) => n ? n.decode(P, b, v) : le(P, b, v), { bytes: h, compression: p } = e, g = await u(h, p, c), y = g.layout === "pixel-interleaved" ? g.data : g.bands[0];
|
|
1830
|
+
if (y instanceof Uint8Array)
|
|
1831
|
+
return y;
|
|
1831
1832
|
throw new Error("Expected mask data to decode to Uint8Array");
|
|
1832
1833
|
}
|
|
1833
|
-
async function
|
|
1834
|
-
const r = (o, i, a) => n ? n.decode(o, i, a) :
|
|
1834
|
+
async function rr(e, t, n) {
|
|
1835
|
+
const r = (o, i, a) => n ? n.decode(o, i, a) : le(o, i, a);
|
|
1835
1836
|
if (Array.isArray(e)) {
|
|
1836
1837
|
const o = { ...t, samplesPerPixel: 1 };
|
|
1837
1838
|
return { layout: "band-separate", bands: (await Promise.all(e.map(({ bytes: s, compression: l }) => r(s, l, o)))).map((s) => s.layout === "band-separate" ? s.bands[0] : s.data) };
|
|
@@ -1840,11 +1841,11 @@ async function Dn(e, t, n) {
|
|
|
1840
1841
|
return r(o, i, t);
|
|
1841
1842
|
}
|
|
1842
1843
|
}
|
|
1843
|
-
async function
|
|
1844
|
+
async function or(e, t, n, { signal: r } = {}) {
|
|
1844
1845
|
const o = e._debug ? { label: "data" } : void 0;
|
|
1845
1846
|
switch (e.cachedTags.planarConfiguration) {
|
|
1846
1847
|
case U.Contig: {
|
|
1847
|
-
const i = await
|
|
1848
|
+
const i = await nt(e.image, t, n, e.dataSource, {
|
|
1848
1849
|
signal: r,
|
|
1849
1850
|
debug: o
|
|
1850
1851
|
});
|
|
@@ -1853,32 +1854,32 @@ async function xn(e, t, n, { signal: r } = {}) {
|
|
|
1853
1854
|
return i;
|
|
1854
1855
|
}
|
|
1855
1856
|
case U.Separate:
|
|
1856
|
-
return await
|
|
1857
|
+
return await ir(e, t, n, { signal: r });
|
|
1857
1858
|
default:
|
|
1858
1859
|
throw new Error(`Unsupported PlanarConfiguration: ${e.cachedTags.planarConfiguration}`);
|
|
1859
1860
|
}
|
|
1860
1861
|
}
|
|
1861
|
-
async function
|
|
1862
|
+
async function tt(e, t, n) {
|
|
1862
1863
|
const { x: r, y: o } = e.image.tileCount, i = r * o, a = e.cachedTags.samplesPerPixel, s = [...Array(a).keys()].map((l) => {
|
|
1863
1864
|
const c = l * i + n * r + t;
|
|
1864
1865
|
return e.image.getTileSize(c);
|
|
1865
1866
|
});
|
|
1866
1867
|
return Promise.all(s);
|
|
1867
1868
|
}
|
|
1868
|
-
async function
|
|
1869
|
-
const o = e._debug ? { label: "data" } : void 0, a = (await
|
|
1870
|
-
const c = await
|
|
1869
|
+
async function ir(e, t, n, { signal: r } = {}) {
|
|
1870
|
+
const o = e._debug ? { label: "data" } : void 0, a = (await tt(e, t, n)).map(async ({ offset: s, imageSize: l }) => {
|
|
1871
|
+
const c = await rt(e.image, s, l, e.dataSource, { signal: r, debug: o });
|
|
1871
1872
|
if (c === null)
|
|
1872
1873
|
throw new Error(`Tile at (${t}, ${n}) not found`);
|
|
1873
1874
|
return c;
|
|
1874
1875
|
});
|
|
1875
1876
|
return Promise.all(a);
|
|
1876
1877
|
}
|
|
1877
|
-
async function
|
|
1878
|
+
async function ar(e, t, { signal: n } = {}) {
|
|
1878
1879
|
const r = e._debug ? { label: "data" } : void 0;
|
|
1879
1880
|
switch (e.cachedTags.planarConfiguration) {
|
|
1880
1881
|
case U.Contig:
|
|
1881
|
-
return (await
|
|
1882
|
+
return (await it(e.image, t, e.dataSource, {
|
|
1882
1883
|
signal: n,
|
|
1883
1884
|
debug: r
|
|
1884
1885
|
})).map((i, a) => {
|
|
@@ -1889,95 +1890,95 @@ async function zn(e, t, { signal: n } = {}) {
|
|
|
1889
1890
|
return i;
|
|
1890
1891
|
});
|
|
1891
1892
|
case U.Separate:
|
|
1892
|
-
return
|
|
1893
|
+
return sr(e, t, { signal: n });
|
|
1893
1894
|
default:
|
|
1894
1895
|
throw new Error(`Unsupported PlanarConfiguration: ${e.cachedTags.planarConfiguration}`);
|
|
1895
1896
|
}
|
|
1896
1897
|
}
|
|
1897
|
-
async function
|
|
1898
|
-
const r = e._debug ? { label: "data" } : void 0, o = e.cachedTags.samplesPerPixel, a = (await Promise.all(t.map(([l, c]) =>
|
|
1898
|
+
async function sr(e, t, { signal: n } = {}) {
|
|
1899
|
+
const r = e._debug ? { label: "data" } : void 0, o = e.cachedTags.samplesPerPixel, a = (await Promise.all(t.map(([l, c]) => tt(e, l, c)))).flatMap((l) => l.map(({ offset: c, imageSize: u }) => ({
|
|
1899
1900
|
offset: c,
|
|
1900
|
-
byteCount:
|
|
1901
|
-
}))), s = await
|
|
1902
|
-
return t.map(([l, c],
|
|
1901
|
+
byteCount: u
|
|
1902
|
+
}))), s = await ot(e.image, a, e.dataSource, { signal: n, debug: r });
|
|
1903
|
+
return t.map(([l, c], u) => s.slice(u * o, u * o + o).map((h) => {
|
|
1903
1904
|
if (h === null)
|
|
1904
1905
|
throw new Error(`Tile at (${l}, ${c}) not found`);
|
|
1905
1906
|
return h;
|
|
1906
1907
|
}));
|
|
1907
1908
|
}
|
|
1908
|
-
async function
|
|
1909
|
+
async function nt(e, t, n, r, o) {
|
|
1909
1910
|
const { size: i, tileSize: a } = e;
|
|
1910
1911
|
if (a == null)
|
|
1911
1912
|
throw new Error("Tiff is not tiled");
|
|
1912
1913
|
const s = Math.ceil(i.height / a.height), l = Math.ceil(i.width / a.width);
|
|
1913
1914
|
if (t >= l || n >= s)
|
|
1914
1915
|
throw new Error(`Tile index is outside of range x:${t} >= ${l} or y:${n} >= ${s}`);
|
|
1915
|
-
const c = n * l + t,
|
|
1916
|
-
if (c >=
|
|
1917
|
-
throw new Error(`Tile index is outside of tile range: ${c} >= ${
|
|
1918
|
-
const { offset: h, imageSize:
|
|
1919
|
-
return
|
|
1916
|
+
const c = n * l + t, u = l * s;
|
|
1917
|
+
if (c >= u)
|
|
1918
|
+
throw new Error(`Tile index is outside of tile range: ${c} >= ${u}`);
|
|
1919
|
+
const { offset: h, imageSize: p } = await e.getTileSize(c);
|
|
1920
|
+
return rt(e, h, p, r, o);
|
|
1920
1921
|
}
|
|
1921
|
-
async function
|
|
1922
|
+
async function rt(e, t, n, r, o) {
|
|
1922
1923
|
if (n === 0)
|
|
1923
1924
|
return null;
|
|
1924
1925
|
o?.debug !== void 0 && console.log(`[geotiff dataSource] ${o.debug.label}: offset=${t} length=${n}`);
|
|
1925
1926
|
const i = await r.fetch(t, n, o);
|
|
1926
1927
|
if (i.byteLength < n)
|
|
1927
1928
|
throw new Error(`Failed to fetch bytes from offset:${t} wanted:${n} got:${i.byteLength}`);
|
|
1928
|
-
const a = e.value(
|
|
1929
|
-
return a ===
|
|
1929
|
+
const a = e.value(d.Compression) ?? f.None;
|
|
1930
|
+
return a === f.Jpeg ? {
|
|
1930
1931
|
bytes: e.getJpegHeader(i),
|
|
1931
1932
|
compression: a
|
|
1932
1933
|
} : { bytes: i, compression: a };
|
|
1933
1934
|
}
|
|
1934
|
-
async function
|
|
1935
|
+
async function ot(e, t, n, r) {
|
|
1935
1936
|
if (t.length === 0)
|
|
1936
1937
|
return [];
|
|
1937
1938
|
const o = new Array(t.length), i = [], a = [];
|
|
1938
1939
|
for (let c = 0; c < t.length; c++) {
|
|
1939
|
-
const
|
|
1940
|
-
|
|
1940
|
+
const u = t[c];
|
|
1941
|
+
u.offset === 0 || u.byteCount === 0 ? o[c] = null : (a.push(c), i.push({ offset: u.offset, length: u.byteCount }));
|
|
1941
1942
|
}
|
|
1942
1943
|
if (i.length === 0)
|
|
1943
1944
|
return o;
|
|
1944
1945
|
if (r?.debug !== void 0)
|
|
1945
1946
|
for (const c of i)
|
|
1946
1947
|
console.log(`[geotiff dataSource] ${r.debug.label}: offset=${c.offset} length=${c.length}`);
|
|
1947
|
-
const s = await
|
|
1948
|
+
const s = await qn(n, i, {
|
|
1948
1949
|
coalesce: r?.coalesce,
|
|
1949
1950
|
maxRangeSize: r?.maxRangeSize,
|
|
1950
1951
|
signal: r?.signal
|
|
1951
|
-
}), l = e.value(
|
|
1952
|
+
}), l = e.value(d.Compression) ?? f.None;
|
|
1952
1953
|
for (let c = 0; c < s.length; c++) {
|
|
1953
|
-
const
|
|
1954
|
-
o[
|
|
1954
|
+
const u = a[c], h = s[c], p = l === f.Jpeg ? e.getJpegHeader(h) : h;
|
|
1955
|
+
o[u] = { bytes: p, compression: l };
|
|
1955
1956
|
}
|
|
1956
1957
|
return o;
|
|
1957
1958
|
}
|
|
1958
|
-
async function
|
|
1959
|
+
async function it(e, t, n, r) {
|
|
1959
1960
|
if (t.length === 0)
|
|
1960
1961
|
return [];
|
|
1961
1962
|
const { size: o, tileSize: i } = e;
|
|
1962
1963
|
if (i == null)
|
|
1963
1964
|
throw new Error("Tiff is not tiled");
|
|
1964
|
-
const a = Math.ceil(o.height / i.height), s = Math.ceil(o.width / i.width), l = s * a, c = t.map(([h,
|
|
1965
|
-
if (h >= s ||
|
|
1966
|
-
throw new Error(`Tile index is outside of range x:${h} >= ${s} or y:${
|
|
1967
|
-
const
|
|
1968
|
-
if (
|
|
1969
|
-
throw new Error(`Tile index is outside of tile range: ${
|
|
1970
|
-
return
|
|
1971
|
-
}),
|
|
1972
|
-
return
|
|
1973
|
-
}
|
|
1974
|
-
function
|
|
1965
|
+
const a = Math.ceil(o.height / i.height), s = Math.ceil(o.width / i.width), l = s * a, c = t.map(([h, p]) => {
|
|
1966
|
+
if (h >= s || p >= a)
|
|
1967
|
+
throw new Error(`Tile index is outside of range x:${h} >= ${s} or y:${p} >= ${a}`);
|
|
1968
|
+
const g = p * s + h;
|
|
1969
|
+
if (g >= l)
|
|
1970
|
+
throw new Error(`Tile index is outside of tile range: ${g} >= ${l}`);
|
|
1971
|
+
return g;
|
|
1972
|
+
}), u = await Promise.all(c.map((h) => e.getTileSize(h)));
|
|
1973
|
+
return ot(e, u.map((h) => ({ offset: h.offset, byteCount: h.imageSize })), n, r);
|
|
1974
|
+
}
|
|
1975
|
+
function lr(e, t, n, r) {
|
|
1975
1976
|
const { width: o, height: i } = e.image.getTileBounds(t, n);
|
|
1976
1977
|
if (o === e.tileWidth && i === e.tileHeight)
|
|
1977
1978
|
return r;
|
|
1978
|
-
const a = r.mask ?
|
|
1979
|
+
const a = r.mask ? T(r.mask, e.tileWidth, o, i, 1) : r.mask;
|
|
1979
1980
|
if (r.layout === "pixel-interleaved") {
|
|
1980
|
-
const { count: c, data:
|
|
1981
|
+
const { count: c, data: u } = r, h = T(u, e.tileWidth, o, i, c);
|
|
1981
1982
|
return {
|
|
1982
1983
|
...r,
|
|
1983
1984
|
width: o,
|
|
@@ -1986,7 +1987,7 @@ function _n(e, t, n, r) {
|
|
|
1986
1987
|
mask: a
|
|
1987
1988
|
};
|
|
1988
1989
|
}
|
|
1989
|
-
const { bands: s } = r, l = s.map((c) =>
|
|
1990
|
+
const { bands: s } = r, l = s.map((c) => T(c, e.tileWidth, o, i, 1));
|
|
1990
1991
|
return {
|
|
1991
1992
|
...r,
|
|
1992
1993
|
width: o,
|
|
@@ -1995,13 +1996,13 @@ function _n(e, t, n, r) {
|
|
|
1995
1996
|
mask: a
|
|
1996
1997
|
};
|
|
1997
1998
|
}
|
|
1998
|
-
function
|
|
1999
|
+
function T(e, t, n, r, o) {
|
|
1999
2000
|
const i = t * o, a = n * o, s = new e.constructor(a * r);
|
|
2000
2001
|
for (let l = 0; l < r; l++)
|
|
2001
2002
|
s.set(e.subarray(l * i, l * i + a), l * a);
|
|
2002
2003
|
return s;
|
|
2003
2004
|
}
|
|
2004
|
-
function
|
|
2005
|
+
function at(e, t) {
|
|
2005
2006
|
const n = new Set(e), r = new Set(t);
|
|
2006
2007
|
if (n.size > 1)
|
|
2007
2008
|
throw new Error("Multiple sample formats are not supported.");
|
|
@@ -2015,172 +2016,172 @@ function Ze(e, t) {
|
|
|
2015
2016
|
bitsPerSample: i
|
|
2016
2017
|
};
|
|
2017
2018
|
}
|
|
2018
|
-
function
|
|
2019
|
+
function cr(e, { count: t }) {
|
|
2019
2020
|
if (e == null)
|
|
2020
2021
|
return null;
|
|
2021
2022
|
const o = new DOMParser().parseFromString(e, "text/xml").documentElement;
|
|
2022
2023
|
if (o.tagName !== "GDALMetadata")
|
|
2023
2024
|
throw new Error("Not a GDALMetadata XML block");
|
|
2024
2025
|
const i = /* @__PURE__ */ new Map(), a = Array(t).fill(0), s = Array(t).fill(1), l = (c) => {
|
|
2025
|
-
const
|
|
2026
|
-
return i.has(
|
|
2026
|
+
const u = parseInt(c, 10) + 1;
|
|
2027
|
+
return i.has(u) || i.set(u, {
|
|
2027
2028
|
max: null,
|
|
2028
2029
|
min: null,
|
|
2029
2030
|
mean: null,
|
|
2030
2031
|
std: null,
|
|
2031
2032
|
validPercent: null
|
|
2032
|
-
}), i.get(
|
|
2033
|
+
}), i.get(u);
|
|
2033
2034
|
};
|
|
2034
2035
|
for (const c of Array.from(o.querySelectorAll("Item"))) {
|
|
2035
|
-
const
|
|
2036
|
+
const u = c.getAttribute("name"), h = c.getAttribute("sample"), p = c.textContent ?? "";
|
|
2036
2037
|
if (h !== null)
|
|
2037
|
-
switch (
|
|
2038
|
+
switch (u) {
|
|
2038
2039
|
case "STATISTICS_MAXIMUM":
|
|
2039
|
-
l(h).max = parseFloat(
|
|
2040
|
+
l(h).max = parseFloat(p);
|
|
2040
2041
|
break;
|
|
2041
2042
|
case "STATISTICS_MEAN":
|
|
2042
|
-
l(h).mean = parseFloat(
|
|
2043
|
+
l(h).mean = parseFloat(p);
|
|
2043
2044
|
break;
|
|
2044
2045
|
case "STATISTICS_MINIMUM":
|
|
2045
|
-
l(h).min = parseFloat(
|
|
2046
|
+
l(h).min = parseFloat(p);
|
|
2046
2047
|
break;
|
|
2047
2048
|
case "STATISTICS_STDDEV":
|
|
2048
|
-
l(h).std = parseFloat(
|
|
2049
|
+
l(h).std = parseFloat(p);
|
|
2049
2050
|
break;
|
|
2050
2051
|
case "STATISTICS_VALID_PERCENT":
|
|
2051
|
-
l(h).validPercent = parseFloat(
|
|
2052
|
+
l(h).validPercent = parseFloat(p);
|
|
2052
2053
|
break;
|
|
2053
2054
|
case "OFFSET":
|
|
2054
|
-
a[parseInt(h, 10)] = parseFloat(
|
|
2055
|
+
a[parseInt(h, 10)] = parseFloat(p);
|
|
2055
2056
|
break;
|
|
2056
2057
|
case "SCALE":
|
|
2057
|
-
s[parseInt(h, 10)] = parseFloat(
|
|
2058
|
+
s[parseInt(h, 10)] = parseFloat(p);
|
|
2058
2059
|
break;
|
|
2059
2060
|
}
|
|
2060
2061
|
}
|
|
2061
2062
|
return { bandStatistics: i, offsets: a, scales: s };
|
|
2062
2063
|
}
|
|
2063
|
-
async function
|
|
2064
|
-
const { signal: n } = t, r = e.value(
|
|
2064
|
+
async function ur(e, t = {}) {
|
|
2065
|
+
const { signal: n } = t, r = e.value(d.Compression);
|
|
2065
2066
|
if (r === null)
|
|
2066
2067
|
throw new Error("Compression tag should always exist.");
|
|
2067
|
-
const [o, i, a, s, l, c,
|
|
2068
|
-
e.fetch(
|
|
2069
|
-
e.fetch(
|
|
2070
|
-
e.fetch(
|
|
2071
|
-
e.fetch(
|
|
2072
|
-
e.fetch(
|
|
2073
|
-
e.fetch(
|
|
2074
|
-
e.fetch(
|
|
2075
|
-
e.fetch(
|
|
2076
|
-
e.fetch(
|
|
2077
|
-
e.fetch(
|
|
2078
|
-
e.fetch(
|
|
2079
|
-
e.fetch(
|
|
2080
|
-
e.fetch(
|
|
2081
|
-
]),
|
|
2082
|
-
throw new Error(`${
|
|
2068
|
+
const [o, i, a, s, l, c, u, h, p, g, y, P, b] = await Promise.all([
|
|
2069
|
+
e.fetch(d.BitsPerSample, { signal: n }),
|
|
2070
|
+
e.fetch(d.ColorMap, { signal: n }),
|
|
2071
|
+
e.fetch(d.GdalNoData, { signal: n }),
|
|
2072
|
+
e.fetch(d.GdalMetadata, { signal: n }),
|
|
2073
|
+
e.fetch(d.LercParameters, { signal: n }),
|
|
2074
|
+
e.fetch(d.ModelPixelScale, { signal: n }),
|
|
2075
|
+
e.fetch(d.ModelTiePoint, { signal: n }),
|
|
2076
|
+
e.fetch(d.ModelTransformation, { signal: n }),
|
|
2077
|
+
e.fetch(d.Photometric, { signal: n }),
|
|
2078
|
+
e.fetch(d.PlanarConfiguration, { signal: n }),
|
|
2079
|
+
e.fetch(d.Predictor, { signal: n }),
|
|
2080
|
+
e.fetch(d.SampleFormat, { signal: n }),
|
|
2081
|
+
e.fetch(d.SamplesPerPixel, { signal: n })
|
|
2082
|
+
]), v = (C) => {
|
|
2083
|
+
throw new Error(`${C} tag should always exist.`);
|
|
2083
2084
|
};
|
|
2084
|
-
return o === null &&
|
|
2085
|
+
return o === null && v("BitsPerSample"), b === null && v("SamplesPerPixel"), p === null && v("Photometric"), {
|
|
2085
2086
|
bitsPerSample: new Uint16Array(o),
|
|
2086
2087
|
colorMap: i ? new Uint16Array(i) : void 0,
|
|
2087
2088
|
compression: r,
|
|
2088
2089
|
gdalMetadata: s,
|
|
2089
2090
|
lercParameters: l,
|
|
2090
|
-
modelTiepoint:
|
|
2091
|
+
modelTiepoint: u,
|
|
2091
2092
|
modelPixelScale: c,
|
|
2092
2093
|
modelTransformation: h,
|
|
2093
2094
|
nodata: a !== null ? Number(a) : null,
|
|
2094
|
-
photometric:
|
|
2095
|
+
photometric: p,
|
|
2095
2096
|
// PlanarConfiguration defaults to interleaved/chunky/contig
|
|
2096
2097
|
// https://web.archive.org/web/20240329145253/https://www.awaresystems.be/imaging/tiff/tifftags/planarconfiguration.html
|
|
2097
|
-
planarConfiguration:
|
|
2098
|
-
predictor:
|
|
2098
|
+
planarConfiguration: g ?? U.Contig,
|
|
2099
|
+
predictor: y ?? _.None,
|
|
2099
2100
|
// Uint is the default sample format according to the spec
|
|
2100
2101
|
// https://web.archive.org/web/20240329145340/https://www.awaresystems.be/imaging/tiff/tifftags/sampleformat.html
|
|
2101
|
-
sampleFormat: P ?? [
|
|
2102
|
-
samplesPerPixel:
|
|
2102
|
+
sampleFormat: P ?? [A.Uint],
|
|
2103
|
+
samplesPerPixel: b
|
|
2103
2104
|
};
|
|
2104
2105
|
}
|
|
2105
|
-
function
|
|
2106
|
+
function dr(e) {
|
|
2106
2107
|
const t = (n) => e.valueGeo(n) ?? null;
|
|
2107
2108
|
return {
|
|
2108
2109
|
// Configuration keys
|
|
2109
|
-
modelType: t(
|
|
2110
|
-
rasterType: t(
|
|
2111
|
-
citation: t(
|
|
2110
|
+
modelType: t(m.GTModelTypeGeoKey),
|
|
2111
|
+
rasterType: t(m.GTRasterTypeGeoKey),
|
|
2112
|
+
citation: t(m.GTCitationGeoKey),
|
|
2112
2113
|
// Geographic CRS keys
|
|
2113
|
-
geodeticCRS: t(
|
|
2114
|
-
geodeticCitation: t(
|
|
2115
|
-
geodeticDatum: t(
|
|
2116
|
-
primeMeridian: t(
|
|
2117
|
-
linearUnits: t(
|
|
2118
|
-
linearUnitSize: t(
|
|
2119
|
-
angularUnits: t(
|
|
2120
|
-
angularUnitSize: t(
|
|
2121
|
-
ellipsoid: t(
|
|
2122
|
-
ellipsoidSemiMajorAxis: t(
|
|
2123
|
-
ellipsoidSemiMinorAxis: t(
|
|
2124
|
-
ellipsoidInvFlattening: t(
|
|
2125
|
-
azimuthUnits: t(
|
|
2126
|
-
primeMeridianLongitude: t(
|
|
2127
|
-
toWGS84: t(
|
|
2114
|
+
geodeticCRS: t(m.GeodeticCRSGeoKey),
|
|
2115
|
+
geodeticCitation: t(m.GeodeticCitationGeoKey),
|
|
2116
|
+
geodeticDatum: t(m.GeodeticDatumGeoKey),
|
|
2117
|
+
primeMeridian: t(m.PrimeMeridianGeoKey),
|
|
2118
|
+
linearUnits: t(m.GeogLinearUnitsGeoKey),
|
|
2119
|
+
linearUnitSize: t(m.GeogLinearUnitSizeGeoKey),
|
|
2120
|
+
angularUnits: t(m.GeogAngularUnitsGeoKey),
|
|
2121
|
+
angularUnitSize: t(m.GeogAngularUnitSizeGeoKey),
|
|
2122
|
+
ellipsoid: t(m.EllipsoidGeoKey),
|
|
2123
|
+
ellipsoidSemiMajorAxis: t(m.EllipsoidSemiMajorAxisGeoKey),
|
|
2124
|
+
ellipsoidSemiMinorAxis: t(m.EllipsoidSemiMinorAxisGeoKey),
|
|
2125
|
+
ellipsoidInvFlattening: t(m.EllipsoidInvFlatteningGeoKey),
|
|
2126
|
+
azimuthUnits: t(m.GeogAzimuthUnitsGeoKey),
|
|
2127
|
+
primeMeridianLongitude: t(m.PrimeMeridianLongitudeGeoKey),
|
|
2128
|
+
toWGS84: t(m.GeogTOWGS84GeoKey),
|
|
2128
2129
|
// Projected CRS keys
|
|
2129
|
-
projectedCRS: t(
|
|
2130
|
-
projectedCitation: t(
|
|
2131
|
-
projection: t(
|
|
2132
|
-
projMethod: t(
|
|
2133
|
-
projLinearUnits: t(
|
|
2134
|
-
projLinearUnitSize: t(
|
|
2135
|
-
projStdParallel1: t(
|
|
2136
|
-
projStdParallel2: t(
|
|
2137
|
-
projNatOriginLong: t(
|
|
2138
|
-
projNatOriginLat: t(
|
|
2139
|
-
projFalseEasting: t(
|
|
2140
|
-
projFalseNorthing: t(
|
|
2141
|
-
projFalseOriginLong: t(
|
|
2142
|
-
projFalseOriginLat: t(
|
|
2143
|
-
projFalseOriginEasting: t(
|
|
2144
|
-
projFalseOriginNorthing: t(
|
|
2145
|
-
projCenterLong: t(
|
|
2146
|
-
projCenterLat: t(
|
|
2147
|
-
projCenterEasting: t(
|
|
2148
|
-
projCenterNorthing: t(
|
|
2149
|
-
projScaleAtNatOrigin: t(
|
|
2150
|
-
projScaleAtCenter: t(
|
|
2151
|
-
projAzimuthAngle: t(
|
|
2152
|
-
projStraightVertPoleLong: t(
|
|
2153
|
-
projRectifiedGridAngle: t(
|
|
2130
|
+
projectedCRS: t(m.ProjectedCRSGeoKey),
|
|
2131
|
+
projectedCitation: t(m.ProjectedCitationGeoKey),
|
|
2132
|
+
projection: t(m.ProjectionGeoKey),
|
|
2133
|
+
projMethod: t(m.ProjMethodGeoKey),
|
|
2134
|
+
projLinearUnits: t(m.ProjLinearUnitsGeoKey),
|
|
2135
|
+
projLinearUnitSize: t(m.ProjLinearUnitSizeGeoKey),
|
|
2136
|
+
projStdParallel1: t(m.ProjStdParallel1GeoKey),
|
|
2137
|
+
projStdParallel2: t(m.ProjStdParallel2GeoKey),
|
|
2138
|
+
projNatOriginLong: t(m.ProjNatOriginLongGeoKey),
|
|
2139
|
+
projNatOriginLat: t(m.ProjNatOriginLatGeoKey),
|
|
2140
|
+
projFalseEasting: t(m.ProjFalseEastingGeoKey),
|
|
2141
|
+
projFalseNorthing: t(m.ProjFalseNorthingGeoKey),
|
|
2142
|
+
projFalseOriginLong: t(m.ProjFalseOriginLongGeoKey),
|
|
2143
|
+
projFalseOriginLat: t(m.ProjFalseOriginLatGeoKey),
|
|
2144
|
+
projFalseOriginEasting: t(m.ProjFalseOriginEastingGeoKey),
|
|
2145
|
+
projFalseOriginNorthing: t(m.ProjFalseOriginNorthingGeoKey),
|
|
2146
|
+
projCenterLong: t(m.ProjCenterLongGeoKey),
|
|
2147
|
+
projCenterLat: t(m.ProjCenterLatGeoKey),
|
|
2148
|
+
projCenterEasting: t(m.ProjCenterEastingGeoKey),
|
|
2149
|
+
projCenterNorthing: t(m.ProjCenterNorthingGeoKey),
|
|
2150
|
+
projScaleAtNatOrigin: t(m.ProjScaleAtNatOriginGeoKey),
|
|
2151
|
+
projScaleAtCenter: t(m.ProjScaleAtCenterGeoKey),
|
|
2152
|
+
projAzimuthAngle: t(m.ProjAzimuthAngleGeoKey),
|
|
2153
|
+
projStraightVertPoleLong: t(m.ProjStraightVertPoleLongGeoKey),
|
|
2154
|
+
projRectifiedGridAngle: t(m.ProjRectifiedGridAngleGeoKey),
|
|
2154
2155
|
// Vertical CRS keys
|
|
2155
|
-
verticalCRS: t(
|
|
2156
|
-
verticalCitation: t(
|
|
2157
|
-
verticalDatum: t(
|
|
2158
|
-
verticalUnits: t(
|
|
2156
|
+
verticalCRS: t(m.VerticalGeoKey),
|
|
2157
|
+
verticalCitation: t(m.VerticalCitationGeoKey),
|
|
2158
|
+
verticalDatum: t(m.VerticalDatumGeoKey),
|
|
2159
|
+
verticalUnits: t(m.VerticalUnitsGeoKey)
|
|
2159
2160
|
};
|
|
2160
2161
|
}
|
|
2161
|
-
function
|
|
2162
|
+
function hr({ modelTiepoint: e, modelPixelScale: t, modelTransformation: n, rasterType: r }) {
|
|
2162
2163
|
let o;
|
|
2163
2164
|
if (e && t)
|
|
2164
|
-
o =
|
|
2165
|
+
o = pr(e, t);
|
|
2165
2166
|
else if (n)
|
|
2166
|
-
o =
|
|
2167
|
+
o = mr(n);
|
|
2167
2168
|
else
|
|
2168
2169
|
throw new Error("The image does not have an affine transformation.");
|
|
2169
|
-
return r ===
|
|
2170
|
+
return r === te.PixelIsPoint && (o = ae(o, ze(-0.5, -0.5))), o;
|
|
2170
2171
|
}
|
|
2171
|
-
function
|
|
2172
|
+
function pr(e, t) {
|
|
2172
2173
|
const n = e[3], r = e[4], o = t[0], i = -t[1];
|
|
2173
2174
|
return [o, 0, n, 0, i, r];
|
|
2174
2175
|
}
|
|
2175
|
-
function
|
|
2176
|
+
function mr(e) {
|
|
2176
2177
|
const t = e[3], n = e[7], r = e[1], o = e[4], i = e[0], a = e[5];
|
|
2177
2178
|
return [i, r, t, o, a, n];
|
|
2178
2179
|
}
|
|
2179
|
-
function
|
|
2180
|
-
const o =
|
|
2180
|
+
function st(e, t, n, r = Math.floor) {
|
|
2181
|
+
const o = yt(e.transform), [i, a] = Be(o, t, n);
|
|
2181
2182
|
return [r(a), r(i)];
|
|
2182
2183
|
}
|
|
2183
|
-
function
|
|
2184
|
+
function lt(e, t, n, r = "center") {
|
|
2184
2185
|
let o, i;
|
|
2185
2186
|
switch (r) {
|
|
2186
2187
|
case "center":
|
|
@@ -2199,9 +2200,9 @@ function qe(e, t, n, r = "center") {
|
|
|
2199
2200
|
o = n + 1, i = t + 1;
|
|
2200
2201
|
break;
|
|
2201
2202
|
}
|
|
2202
|
-
return
|
|
2203
|
+
return Be(e.transform, o, i);
|
|
2203
2204
|
}
|
|
2204
|
-
class
|
|
2205
|
+
class gr {
|
|
2205
2206
|
cachedTags;
|
|
2206
2207
|
/** The data source used for fetching tile data. */
|
|
2207
2208
|
dataSource;
|
|
@@ -2256,7 +2257,7 @@ class Yn {
|
|
|
2256
2257
|
*/
|
|
2257
2258
|
get transform() {
|
|
2258
2259
|
const t = this.geotiff.transform, n = this.geotiff.width / this.width, r = this.geotiff.height / this.height;
|
|
2259
|
-
return
|
|
2260
|
+
return ae(t, wt(n, r));
|
|
2260
2261
|
}
|
|
2261
2262
|
/** Image width in pixels. */
|
|
2262
2263
|
get width() {
|
|
@@ -2272,7 +2273,7 @@ class Yn {
|
|
|
2272
2273
|
* @param options.signal An optional {@link AbortSignal} to cancel the fetch request.
|
|
2273
2274
|
*/
|
|
2274
2275
|
async fetchTile(t, n, r = {}) {
|
|
2275
|
-
return await
|
|
2276
|
+
return await qe(this, t, n, r);
|
|
2276
2277
|
}
|
|
2277
2278
|
/**
|
|
2278
2279
|
* Fetch multiple tiles in parallel.
|
|
@@ -2287,7 +2288,7 @@ class Yn {
|
|
|
2287
2288
|
* @see {@link fetchTile} for single-tile fetching.
|
|
2288
2289
|
*/
|
|
2289
2290
|
async fetchTiles(t, n = {}) {
|
|
2290
|
-
return await
|
|
2291
|
+
return await et(this, t, n);
|
|
2291
2292
|
}
|
|
2292
2293
|
// TiledMixin
|
|
2293
2294
|
// Transform mixin
|
|
@@ -2301,7 +2302,7 @@ class Yn {
|
|
|
2301
2302
|
* @returns [row, col] pixel indices.
|
|
2302
2303
|
*/
|
|
2303
2304
|
index(t, n, r = Math.floor) {
|
|
2304
|
-
return
|
|
2305
|
+
return st(this, t, n, r);
|
|
2305
2306
|
}
|
|
2306
2307
|
/**
|
|
2307
2308
|
* Get the geographic (x, y) coordinate of the pixel at (row, col).
|
|
@@ -2312,10 +2313,10 @@ class Yn {
|
|
|
2312
2313
|
* @returns [x, y] in the CRS.
|
|
2313
2314
|
*/
|
|
2314
2315
|
xy(t, n, r = "center") {
|
|
2315
|
-
return
|
|
2316
|
+
return lt(this, t, n, r);
|
|
2316
2317
|
}
|
|
2317
2318
|
}
|
|
2318
|
-
class
|
|
2319
|
+
class x {
|
|
2319
2320
|
/**
|
|
2320
2321
|
* Reduced-resolution overview levels, sorted finest-to-coarsest.
|
|
2321
2322
|
*
|
|
@@ -2369,7 +2370,7 @@ class D {
|
|
|
2369
2370
|
*/
|
|
2370
2371
|
static async open(t) {
|
|
2371
2372
|
const { dataSource: n, headerSource: r, signal: o, debug: i } = t, a = await new B(r).init({ signal: o });
|
|
2372
|
-
return a.options = void 0,
|
|
2373
|
+
return a.options = void 0, x.fromTiff(a, n, { signal: o, debug: i });
|
|
2373
2374
|
}
|
|
2374
2375
|
/**
|
|
2375
2376
|
* Create a GeoTIFF from an already-initialised Tiff instance.
|
|
@@ -2385,24 +2386,24 @@ class D {
|
|
|
2385
2386
|
const { signal: o, debug: i = !1 } = r, a = t.images;
|
|
2386
2387
|
if (a.length === 0)
|
|
2387
2388
|
throw new Error("TIFF does not contain any IFDs");
|
|
2388
|
-
await Promise.all(a.map((
|
|
2389
|
-
const s = a[0], l =
|
|
2390
|
-
for (let
|
|
2391
|
-
const
|
|
2392
|
-
|
|
2389
|
+
await Promise.all(a.map((C) => C.init(!0, { signal: o })));
|
|
2390
|
+
const s = a[0], l = dr(s), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
2391
|
+
for (let C = 1; C < a.length; C++) {
|
|
2392
|
+
const L = a[C], E = L.size, G = `${E.width},${E.height}`;
|
|
2393
|
+
fr(L) ? u.set(G, L) : c.set(G, L);
|
|
2393
2394
|
}
|
|
2394
|
-
const h = `${s.size.width},${s.size.height}`,
|
|
2395
|
-
|
|
2396
|
-
const
|
|
2397
|
-
return
|
|
2395
|
+
const h = `${s.size.width},${s.size.height}`, p = u.get(h) ?? null, g = Array.from(c.entries());
|
|
2396
|
+
g.sort((C, L) => {
|
|
2397
|
+
const E = C[1].size, G = L[1].size;
|
|
2398
|
+
return G.width * G.height - E.width * E.height;
|
|
2398
2399
|
});
|
|
2399
|
-
const
|
|
2400
|
-
count:
|
|
2401
|
-
}),
|
|
2402
|
-
const
|
|
2403
|
-
return new
|
|
2400
|
+
const y = await ur(s, { signal: o }), P = cr(y.gdalMetadata, {
|
|
2401
|
+
count: y.samplesPerPixel
|
|
2402
|
+
}), b = new x(t, s, p, l, [], y, n, P, i), v = g.map(([C, L]) => {
|
|
2403
|
+
const E = u.get(C) ?? null;
|
|
2404
|
+
return new gr(b, l, L, E, y, n);
|
|
2404
2405
|
});
|
|
2405
|
-
return
|
|
2406
|
+
return b.overviews = v, b;
|
|
2406
2407
|
}
|
|
2407
2408
|
/**
|
|
2408
2409
|
* Create a GeoTIFF from an ArrayBuffer containing the entire file.
|
|
@@ -2416,8 +2417,8 @@ class D {
|
|
|
2416
2417
|
* @returns A Promise that resolves to a GeoTIFF instance.
|
|
2417
2418
|
*/
|
|
2418
2419
|
static async fromArrayBuffer(t) {
|
|
2419
|
-
const n = new
|
|
2420
|
-
return await
|
|
2420
|
+
const n = new ce("memory://input.tif", t);
|
|
2421
|
+
return await x.open({
|
|
2421
2422
|
dataSource: n,
|
|
2422
2423
|
headerSource: n
|
|
2423
2424
|
});
|
|
@@ -2440,13 +2441,13 @@ class D {
|
|
|
2440
2441
|
* @returns A Promise that resolves to a GeoTIFF instance.
|
|
2441
2442
|
*/
|
|
2442
2443
|
static async fromUrl(t, { chunkSize: n = 64 * 1024, cacheSize: r = 8 * 1024 * 1024, signal: o, debug: i } = {}) {
|
|
2443
|
-
const a = new
|
|
2444
|
+
const a = new $(t, {});
|
|
2444
2445
|
a.metadata = { size: Number.POSITIVE_INFINITY };
|
|
2445
|
-
const s = new
|
|
2446
|
-
new
|
|
2447
|
-
new
|
|
2446
|
+
const s = new ln(a, [
|
|
2447
|
+
new un({ size: n }),
|
|
2448
|
+
new sn({ size: r })
|
|
2448
2449
|
]);
|
|
2449
|
-
return await
|
|
2450
|
+
return await x.open({
|
|
2450
2451
|
// Tile data reads bypass the header cache (raw source).
|
|
2451
2452
|
dataSource: a,
|
|
2452
2453
|
headerSource: s,
|
|
@@ -2464,7 +2465,7 @@ class D {
|
|
|
2464
2465
|
* See also {@link GeoTIFF.epsg} for the EPSG code directly from the TIFF tags.
|
|
2465
2466
|
*/
|
|
2466
2467
|
get crs() {
|
|
2467
|
-
return this._crs === void 0 && (this._crs =
|
|
2468
|
+
return this._crs === void 0 && (this._crs = $n(this.gkd)), this._crs;
|
|
2468
2469
|
}
|
|
2469
2470
|
/** Image width in pixels. */
|
|
2470
2471
|
get width() {
|
|
@@ -2524,7 +2525,7 @@ class D {
|
|
|
2524
2525
|
}
|
|
2525
2526
|
/** Number of bands (samples per pixel). */
|
|
2526
2527
|
get count() {
|
|
2527
|
-
return this.image.value(
|
|
2528
|
+
return this.image.value(d.SamplesPerPixel) ?? 1;
|
|
2528
2529
|
}
|
|
2529
2530
|
/** Bounding box [minX, minY, maxX, maxY] in the CRS. */
|
|
2530
2531
|
get bbox() {
|
|
@@ -2535,7 +2536,7 @@ class D {
|
|
|
2535
2536
|
*/
|
|
2536
2537
|
get transform() {
|
|
2537
2538
|
const { modelPixelScale: t, modelTiepoint: n, modelTransformation: r } = this.cachedTags;
|
|
2538
|
-
return
|
|
2539
|
+
return hr({
|
|
2539
2540
|
modelTiepoint: n,
|
|
2540
2541
|
modelPixelScale: t,
|
|
2541
2542
|
modelTransformation: r,
|
|
@@ -2553,7 +2554,7 @@ class D {
|
|
|
2553
2554
|
* @param options.signal An optional {@link AbortSignal} to cancel the fetch request.
|
|
2554
2555
|
*/
|
|
2555
2556
|
async fetchTile(t, n, r = {}) {
|
|
2556
|
-
return await
|
|
2557
|
+
return await qe(this, t, n, r);
|
|
2557
2558
|
}
|
|
2558
2559
|
/**
|
|
2559
2560
|
* Fetch multiple tiles in parallel.
|
|
@@ -2568,7 +2569,7 @@ class D {
|
|
|
2568
2569
|
* @see {@link fetchTile} for single-tile fetching.
|
|
2569
2570
|
*/
|
|
2570
2571
|
async fetchTiles(t, n = {}) {
|
|
2571
|
-
return await
|
|
2572
|
+
return await et(this, t, n);
|
|
2572
2573
|
}
|
|
2573
2574
|
// Transform mixin
|
|
2574
2575
|
/**
|
|
@@ -2581,7 +2582,7 @@ class D {
|
|
|
2581
2582
|
* @returns [row, col] pixel indices.
|
|
2582
2583
|
*/
|
|
2583
2584
|
index(t, n, r = Math.floor) {
|
|
2584
|
-
return
|
|
2585
|
+
return st(this, t, n, r);
|
|
2585
2586
|
}
|
|
2586
2587
|
/**
|
|
2587
2588
|
* Get the geographic (x, y) coordinate of the pixel at (row, col).
|
|
@@ -2592,14 +2593,14 @@ class D {
|
|
|
2592
2593
|
* @returns [x, y] in the CRS.
|
|
2593
2594
|
*/
|
|
2594
2595
|
xy(t, n, r = "center") {
|
|
2595
|
-
return
|
|
2596
|
+
return lt(this, t, n, r);
|
|
2596
2597
|
}
|
|
2597
2598
|
}
|
|
2598
|
-
function
|
|
2599
|
-
const t = e.value(
|
|
2600
|
-
return t !== null && (t & J.Mask) !== 0 && n ===
|
|
2599
|
+
function fr(e) {
|
|
2600
|
+
const t = e.value(d.SubFileType), n = e.value(d.Photometric);
|
|
2601
|
+
return t !== null && (t & J.Mask) !== 0 && n === F.Mask;
|
|
2601
2602
|
}
|
|
2602
|
-
let
|
|
2603
|
+
let yr = class {
|
|
2603
2604
|
worker;
|
|
2604
2605
|
jobIdCounter = 0;
|
|
2605
2606
|
jobs = /* @__PURE__ */ new Map();
|
|
@@ -2623,14 +2624,14 @@ let Zn = class {
|
|
|
2623
2624
|
this.worker.terminate();
|
|
2624
2625
|
}
|
|
2625
2626
|
};
|
|
2626
|
-
const
|
|
2627
|
-
class
|
|
2627
|
+
const wr = typeof navigator < "u" ? navigator.hardwareConcurrency ?? 2 : 2;
|
|
2628
|
+
class oe {
|
|
2628
2629
|
workerWrappers;
|
|
2629
2630
|
constructor(t = {}) {
|
|
2630
|
-
const { size: n =
|
|
2631
|
+
const { size: n = wr, createWorker: r } = t;
|
|
2631
2632
|
if (this.workerWrappers = [], r && n > 0)
|
|
2632
2633
|
for (let o = 0; o < n; o++)
|
|
2633
|
-
this.workerWrappers.push(new
|
|
2634
|
+
this.workerWrappers.push(new yr(r()));
|
|
2634
2635
|
}
|
|
2635
2636
|
/** True when workers are available for off-main-thread decoding. */
|
|
2636
2637
|
get hasWorkers() {
|
|
@@ -2648,7 +2649,7 @@ class ne {
|
|
|
2648
2649
|
*/
|
|
2649
2650
|
async decode(t, n, r) {
|
|
2650
2651
|
if (!this.hasWorkers)
|
|
2651
|
-
return
|
|
2652
|
+
return le(t, n, r);
|
|
2652
2653
|
const o = this.leastLoaded(), i = {
|
|
2653
2654
|
compression: n,
|
|
2654
2655
|
metadata: r,
|
|
@@ -2670,8 +2671,8 @@ class ne {
|
|
|
2670
2671
|
}
|
|
2671
2672
|
}
|
|
2672
2673
|
let H = null;
|
|
2673
|
-
function
|
|
2674
|
-
return H !== null || (H = new
|
|
2674
|
+
function Sr() {
|
|
2675
|
+
return H !== null || (H = new oe({
|
|
2675
2676
|
createWorker: () => new Worker(new URL(
|
|
2676
2677
|
/* @vite-ignore */
|
|
2677
2678
|
"" + new URL("assets/worker-DtIrTJB7.js", import.meta.url).href,
|
|
@@ -2679,7 +2680,7 @@ function qn() {
|
|
|
2679
2680
|
), { type: "module" })
|
|
2680
2681
|
})), H;
|
|
2681
2682
|
}
|
|
2682
|
-
function
|
|
2683
|
+
function Pr(e) {
|
|
2683
2684
|
const { height: t, width: n } = e;
|
|
2684
2685
|
if (e.layout === "band-separate")
|
|
2685
2686
|
throw new Error("Band-separate images not yet implemented.");
|
|
@@ -2697,10 +2698,10 @@ function Tn(e) {
|
|
|
2697
2698
|
} else
|
|
2698
2699
|
throw new Error(`Unexpected number of channels in raster data: ${e.data.length / (t * n)}`);
|
|
2699
2700
|
}
|
|
2700
|
-
async function
|
|
2701
|
-
return typeof e == "string" || e instanceof URL ? await
|
|
2701
|
+
async function br(e) {
|
|
2702
|
+
return typeof e == "string" || e instanceof URL ? await x.fromUrl(e) : e instanceof ArrayBuffer ? await x.fromArrayBuffer(e) : e;
|
|
2702
2703
|
}
|
|
2703
|
-
function
|
|
2704
|
+
function Cr(e, t) {
|
|
2704
2705
|
const [n, r, o, i] = e.bbox, a = [
|
|
2705
2706
|
t.forward([n, r]),
|
|
2706
2707
|
// bottom-left
|
|
@@ -2710,20 +2711,20 @@ function tr(e, t) {
|
|
|
2710
2711
|
// top-right
|
|
2711
2712
|
t.forward([n, i])
|
|
2712
2713
|
// top-left
|
|
2713
|
-
], s = a.map((
|
|
2714
|
-
return { west: c, south:
|
|
2714
|
+
], s = a.map((g) => g[0]), l = a.map((g) => g[1]), c = Math.min(...s), u = Math.min(...l), h = Math.max(...s), p = Math.max(...l);
|
|
2715
|
+
return { west: c, south: u, east: h, north: p };
|
|
2715
2716
|
}
|
|
2716
|
-
const
|
|
2717
|
+
const Lr = (
|
|
2717
2718
|
/* glsl */
|
|
2718
2719
|
`
|
|
2719
2720
|
vec3 black_zero_to_rgb(float value) {
|
|
2720
2721
|
return vec3(value, value, value);
|
|
2721
2722
|
}
|
|
2722
2723
|
`
|
|
2723
|
-
),
|
|
2724
|
+
), Ir = {
|
|
2724
2725
|
name: "black-is-zero",
|
|
2725
2726
|
inject: {
|
|
2726
|
-
"fs:#decl":
|
|
2727
|
+
"fs:#decl": Lr,
|
|
2727
2728
|
"fs:DECKGL_FILTER_COLOR": (
|
|
2728
2729
|
/* glsl */
|
|
2729
2730
|
`
|
|
@@ -2731,7 +2732,7 @@ const nr = (
|
|
|
2731
2732
|
`
|
|
2732
2733
|
)
|
|
2733
2734
|
}
|
|
2734
|
-
},
|
|
2735
|
+
}, Gr = (
|
|
2735
2736
|
/* glsl */
|
|
2736
2737
|
`
|
|
2737
2738
|
const vec3 D65 = vec3(
|
|
@@ -2776,10 +2777,10 @@ const nr = (
|
|
|
2776
2777
|
return clamp(rgb, 0.0, 1.0);
|
|
2777
2778
|
}
|
|
2778
2779
|
`
|
|
2779
|
-
),
|
|
2780
|
+
), vr = {
|
|
2780
2781
|
name: "cielab-to-rgb",
|
|
2781
2782
|
inject: {
|
|
2782
|
-
"fs:#decl":
|
|
2783
|
+
"fs:#decl": Gr,
|
|
2783
2784
|
"fs:DECKGL_FILTER_COLOR": (
|
|
2784
2785
|
/* glsl */
|
|
2785
2786
|
`
|
|
@@ -2787,7 +2788,7 @@ const nr = (
|
|
|
2787
2788
|
`
|
|
2788
2789
|
)
|
|
2789
2790
|
}
|
|
2790
|
-
},
|
|
2791
|
+
}, Er = (
|
|
2791
2792
|
/* glsl */
|
|
2792
2793
|
`
|
|
2793
2794
|
vec3 cmykToRgb(vec4 cmyk) {
|
|
@@ -2801,10 +2802,10 @@ const nr = (
|
|
|
2801
2802
|
);
|
|
2802
2803
|
}
|
|
2803
2804
|
`
|
|
2804
|
-
),
|
|
2805
|
+
), Fr = {
|
|
2805
2806
|
name: "cmyk-to-rgb",
|
|
2806
2807
|
inject: {
|
|
2807
|
-
"fs:#decl":
|
|
2808
|
+
"fs:#decl": Er,
|
|
2808
2809
|
"fs:DECKGL_FILTER_COLOR": (
|
|
2809
2810
|
/* glsl */
|
|
2810
2811
|
`
|
|
@@ -2812,17 +2813,17 @@ const nr = (
|
|
|
2812
2813
|
`
|
|
2813
2814
|
)
|
|
2814
2815
|
}
|
|
2815
|
-
},
|
|
2816
|
+
}, Ar = (
|
|
2816
2817
|
/* glsl */
|
|
2817
2818
|
`
|
|
2818
2819
|
vec3 white_zero_to_rgb(float value) {
|
|
2819
2820
|
return vec3(1.0 - value, 1.0 - value, 1.0 - value);
|
|
2820
2821
|
}
|
|
2821
2822
|
`
|
|
2822
|
-
),
|
|
2823
|
+
), jr = {
|
|
2823
2824
|
name: "white-is-zero",
|
|
2824
2825
|
inject: {
|
|
2825
|
-
"fs:#decl":
|
|
2826
|
+
"fs:#decl": Ar,
|
|
2826
2827
|
"fs:DECKGL_FILTER_COLOR": (
|
|
2827
2828
|
/* glsl */
|
|
2828
2829
|
`
|
|
@@ -2830,7 +2831,7 @@ const nr = (
|
|
|
2830
2831
|
`
|
|
2831
2832
|
)
|
|
2832
2833
|
}
|
|
2833
|
-
},
|
|
2834
|
+
}, Rr = {
|
|
2834
2835
|
name: "mask-texture",
|
|
2835
2836
|
inject: {
|
|
2836
2837
|
"fs:#decl": "uniform sampler2D maskTexture;",
|
|
@@ -2848,18 +2849,18 @@ const nr = (
|
|
|
2848
2849
|
maskTexture: e.maskTexture
|
|
2849
2850
|
})
|
|
2850
2851
|
};
|
|
2851
|
-
function
|
|
2852
|
-
const r =
|
|
2852
|
+
function Ur(e, t, n) {
|
|
2853
|
+
const r = Mr(e), o = Or(t), i = Kr(n), a = `${r}:${i}:${o}`, s = xr[a];
|
|
2853
2854
|
if (!s)
|
|
2854
2855
|
throw new Error(`Unsupported texture format for SamplesPerPixel=${e}, BitsPerSample=${t}, SampleFormat=${n}`);
|
|
2855
2856
|
return s;
|
|
2856
2857
|
}
|
|
2857
|
-
function
|
|
2858
|
+
function Mr(e) {
|
|
2858
2859
|
if (e === 1 || e === 2 || e === 3 || e === 4)
|
|
2859
2860
|
return e;
|
|
2860
2861
|
throw new Error(`Unsupported SamplesPerPixel ${e}. Only 1, 2, 3, or 4 are supported.`);
|
|
2861
2862
|
}
|
|
2862
|
-
function
|
|
2863
|
+
function Or(e) {
|
|
2863
2864
|
const t = e[0];
|
|
2864
2865
|
for (let n = 1; n < e.length; n++)
|
|
2865
2866
|
if (e[n] !== t)
|
|
@@ -2868,23 +2869,23 @@ function pr(e) {
|
|
|
2868
2869
|
throw new Error(`Unsupported BitsPerSample ${t}. Only 8, 16, or 32 are supported.`);
|
|
2869
2870
|
return t;
|
|
2870
2871
|
}
|
|
2871
|
-
function
|
|
2872
|
+
function Kr(e) {
|
|
2872
2873
|
const t = e[0];
|
|
2873
2874
|
for (let n = 1; n < e.length; n++)
|
|
2874
2875
|
if (e[n] !== t)
|
|
2875
2876
|
throw new Error(`Unsupported varying SampleFormat ${e}. All samples must have the same format.`);
|
|
2876
2877
|
switch (t) {
|
|
2877
|
-
case
|
|
2878
|
+
case A.Uint:
|
|
2878
2879
|
return "unorm";
|
|
2879
|
-
case
|
|
2880
|
+
case A.Int:
|
|
2880
2881
|
return "sint";
|
|
2881
|
-
case
|
|
2882
|
+
case A.Float:
|
|
2882
2883
|
return "float";
|
|
2883
2884
|
default:
|
|
2884
2885
|
throw new Error(`Unsupported SampleFormat ${e}`);
|
|
2885
2886
|
}
|
|
2886
2887
|
}
|
|
2887
|
-
const
|
|
2888
|
+
const xr = {
|
|
2888
2889
|
// 1 byte per pixel
|
|
2889
2890
|
"1:sint:8": "r8sint",
|
|
2890
2891
|
"1:uint:8": "r8uint",
|
|
@@ -2931,120 +2932,120 @@ const mr = {
|
|
|
2931
2932
|
"4:sint:32": "rgba32sint",
|
|
2932
2933
|
"4:uint:32": "rgba32uint"
|
|
2933
2934
|
};
|
|
2934
|
-
function
|
|
2935
|
+
function Dr(e, t) {
|
|
2935
2936
|
const { sampleFormat: n } = e.cachedTags;
|
|
2936
2937
|
if (n === null)
|
|
2937
2938
|
throw new Error("SampleFormat tag is required to infer render pipeline");
|
|
2938
2939
|
switch (n[0]) {
|
|
2939
2940
|
// Unsigned integers
|
|
2940
|
-
case
|
|
2941
|
-
return
|
|
2941
|
+
case A.Uint:
|
|
2942
|
+
return Nr(e, t);
|
|
2942
2943
|
}
|
|
2943
2944
|
throw new Error(`Inferring render pipeline for non-unsigned integers not yet supported. Found SampleFormat: ${n}`);
|
|
2944
2945
|
}
|
|
2945
|
-
function
|
|
2946
|
+
function Nr(e, t) {
|
|
2946
2947
|
const { bitsPerSample: n, colorMap: r, photometric: o, sampleFormat: i, samplesPerPixel: a, nodata: s } = e.cachedTags, l = [
|
|
2947
2948
|
{
|
|
2948
|
-
module:
|
|
2949
|
+
module: Pt,
|
|
2949
2950
|
props: {
|
|
2950
|
-
textureName: (
|
|
2951
|
+
textureName: (g) => g.texture
|
|
2951
2952
|
}
|
|
2952
2953
|
}
|
|
2953
2954
|
];
|
|
2954
2955
|
if (s !== null) {
|
|
2955
|
-
const
|
|
2956
|
+
const g = 2 ** n[0] - 1, y = s / g;
|
|
2956
2957
|
l.push({
|
|
2957
|
-
module:
|
|
2958
|
-
props: { value:
|
|
2958
|
+
module: bt,
|
|
2959
|
+
props: { value: y }
|
|
2959
2960
|
});
|
|
2960
2961
|
}
|
|
2961
2962
|
e.maskImage !== null && l.push({
|
|
2962
|
-
module:
|
|
2963
|
+
module: Rr,
|
|
2963
2964
|
props: {
|
|
2964
2965
|
// TODO: how to handle if mask failed to load and is undefined here
|
|
2965
|
-
maskTexture: (
|
|
2966
|
+
maskTexture: (g) => g.mask
|
|
2966
2967
|
}
|
|
2967
2968
|
});
|
|
2968
|
-
const c =
|
|
2969
|
+
const c = zr({
|
|
2969
2970
|
count: a,
|
|
2970
2971
|
photometric: o,
|
|
2971
2972
|
device: t,
|
|
2972
2973
|
colorMap: r
|
|
2973
2974
|
});
|
|
2974
2975
|
c && l.push(c);
|
|
2975
|
-
const
|
|
2976
|
+
const u = o === F.Palette ? {
|
|
2976
2977
|
magFilter: "nearest",
|
|
2977
2978
|
minFilter: "nearest"
|
|
2978
2979
|
} : {
|
|
2979
2980
|
magFilter: "linear",
|
|
2980
2981
|
minFilter: "linear"
|
|
2981
2982
|
};
|
|
2982
|
-
return { getTileData: async (
|
|
2983
|
-
const { device: P, x:
|
|
2983
|
+
return { getTileData: async (g, y) => {
|
|
2984
|
+
const { device: P, x: b, y: v, signal: C, pool: L } = y, E = await g.fetchTile(b, v, {
|
|
2984
2985
|
boundless: !1,
|
|
2985
|
-
pool:
|
|
2986
|
-
signal:
|
|
2986
|
+
pool: L,
|
|
2987
|
+
signal: C
|
|
2987
2988
|
});
|
|
2988
|
-
let { array:
|
|
2989
|
-
const { width:
|
|
2990
|
-
let
|
|
2991
|
-
if (a === 3 && (
|
|
2989
|
+
let { array: G } = E;
|
|
2990
|
+
const { width: ue, height: de, mask: q } = G;
|
|
2991
|
+
let he = a;
|
|
2992
|
+
if (a === 3 && (G = Pr(G), he = 4), G.layout === "band-separate")
|
|
2992
2993
|
throw new Error("Band-separate images not yet implemented.");
|
|
2993
|
-
const
|
|
2994
|
+
const gt = Ur(
|
|
2994
2995
|
// Add one sample for added alpha channel
|
|
2995
|
-
|
|
2996
|
+
he,
|
|
2996
2997
|
n,
|
|
2997
2998
|
i
|
|
2998
2999
|
);
|
|
2999
|
-
let
|
|
3000
|
-
const
|
|
3001
|
-
data:
|
|
3002
|
-
format:
|
|
3003
|
-
width:
|
|
3004
|
-
height:
|
|
3005
|
-
sampler:
|
|
3000
|
+
let pe = G.data.byteLength;
|
|
3001
|
+
const ft = P.createTexture({
|
|
3002
|
+
data: G.data,
|
|
3003
|
+
format: gt,
|
|
3004
|
+
width: ue,
|
|
3005
|
+
height: de,
|
|
3006
|
+
sampler: u
|
|
3006
3007
|
});
|
|
3007
|
-
let
|
|
3008
|
-
return
|
|
3009
|
-
data:
|
|
3008
|
+
let me;
|
|
3009
|
+
return q !== null && (me = P.createTexture({
|
|
3010
|
+
data: q,
|
|
3010
3011
|
// Single-channel 8-bit texture for the mask
|
|
3011
3012
|
format: "r8unorm",
|
|
3012
|
-
width:
|
|
3013
|
-
height:
|
|
3013
|
+
width: ue,
|
|
3014
|
+
height: de,
|
|
3014
3015
|
// Use nearest filtering for the mask to avoid interpolated edges/halos
|
|
3015
3016
|
sampler: {
|
|
3016
3017
|
minFilter: "nearest",
|
|
3017
3018
|
magFilter: "nearest"
|
|
3018
3019
|
}
|
|
3019
|
-
}),
|
|
3020
|
-
texture:
|
|
3021
|
-
mask:
|
|
3022
|
-
byteLength:
|
|
3023
|
-
height:
|
|
3024
|
-
width:
|
|
3020
|
+
}), pe += q.byteLength), {
|
|
3021
|
+
texture: ft,
|
|
3022
|
+
mask: me,
|
|
3023
|
+
byteLength: pe,
|
|
3024
|
+
height: G.height,
|
|
3025
|
+
width: G.width
|
|
3025
3026
|
};
|
|
3026
|
-
}, renderTile: (
|
|
3027
|
-
renderPipeline: l.map((
|
|
3027
|
+
}, renderTile: (g) => ({
|
|
3028
|
+
renderPipeline: l.map((y, P) => Br(y, g))
|
|
3028
3029
|
}) };
|
|
3029
3030
|
}
|
|
3030
|
-
function
|
|
3031
|
+
function zr({ count: e, colorMap: t, device: n, photometric: r }) {
|
|
3031
3032
|
if (e === 3 || e === 4)
|
|
3032
3033
|
return null;
|
|
3033
3034
|
switch (r) {
|
|
3034
|
-
case
|
|
3035
|
+
case F.MinIsWhite:
|
|
3035
3036
|
return {
|
|
3036
|
-
module:
|
|
3037
|
+
module: jr
|
|
3037
3038
|
};
|
|
3038
|
-
case
|
|
3039
|
+
case F.MinIsBlack:
|
|
3039
3040
|
return {
|
|
3040
|
-
module:
|
|
3041
|
+
module: Ir
|
|
3041
3042
|
};
|
|
3042
|
-
case
|
|
3043
|
+
case F.Rgb:
|
|
3043
3044
|
return null;
|
|
3044
|
-
case
|
|
3045
|
+
case F.Palette: {
|
|
3045
3046
|
if (!t)
|
|
3046
3047
|
throw new Error("ColorMap is required for PhotometricInterpretation Palette");
|
|
3047
|
-
const { data: o, width: i, height: a } =
|
|
3048
|
+
const { data: o, width: i, height: a } = xt(t), s = n.createTexture({
|
|
3048
3049
|
dimension: "2d-array",
|
|
3049
3050
|
data: o,
|
|
3050
3051
|
format: "rgba8unorm",
|
|
@@ -3061,28 +3062,28 @@ function wr({ count: e, colorMap: t, device: n, photometric: r }) {
|
|
|
3061
3062
|
}
|
|
3062
3063
|
});
|
|
3063
3064
|
return {
|
|
3064
|
-
module:
|
|
3065
|
+
module: St,
|
|
3065
3066
|
props: {
|
|
3066
3067
|
colormapTexture: s
|
|
3067
3068
|
}
|
|
3068
3069
|
};
|
|
3069
3070
|
}
|
|
3070
3071
|
// Not sure why cogeotiff calls this "Separated", but it means CMYK
|
|
3071
|
-
case
|
|
3072
|
+
case F.Separated:
|
|
3072
3073
|
return {
|
|
3073
|
-
module:
|
|
3074
|
+
module: Fr
|
|
3074
3075
|
};
|
|
3075
|
-
case
|
|
3076
|
+
case F.Ycbcr:
|
|
3076
3077
|
return null;
|
|
3077
|
-
case
|
|
3078
|
+
case F.Cielab:
|
|
3078
3079
|
return {
|
|
3079
|
-
module:
|
|
3080
|
+
module: vr
|
|
3080
3081
|
};
|
|
3081
3082
|
default:
|
|
3082
3083
|
throw new Error(`Unsupported PhotometricInterpretation ${r}`);
|
|
3083
3084
|
}
|
|
3084
3085
|
}
|
|
3085
|
-
function
|
|
3086
|
+
function Br(e, t) {
|
|
3086
3087
|
const { module: n, props: r } = e;
|
|
3087
3088
|
if (!r)
|
|
3088
3089
|
return { module: n };
|
|
@@ -3093,11 +3094,11 @@ function Sr(e, t) {
|
|
|
3093
3094
|
}
|
|
3094
3095
|
return { module: n, props: o };
|
|
3095
3096
|
}
|
|
3096
|
-
function
|
|
3097
|
+
function _r(e, t) {
|
|
3097
3098
|
const r = [
|
|
3098
3099
|
...[...e.overviews].reverse(),
|
|
3099
3100
|
e
|
|
3100
|
-
].map((o) => new
|
|
3101
|
+
].map((o) => new Ct({
|
|
3101
3102
|
affine: o.transform,
|
|
3102
3103
|
arrayWidth: o.width,
|
|
3103
3104
|
arrayHeight: o.height,
|
|
@@ -3105,7 +3106,7 @@ function Pr(e, t) {
|
|
|
3105
3106
|
tileHeight: o.tileHeight,
|
|
3106
3107
|
mpu: t.mpu
|
|
3107
3108
|
}));
|
|
3108
|
-
return new
|
|
3109
|
+
return new Lt({
|
|
3109
3110
|
levels: r,
|
|
3110
3111
|
projectTo3857: t.projectTo3857,
|
|
3111
3112
|
projectFrom3857: t.projectFrom3857,
|
|
@@ -3113,7 +3114,7 @@ function Pr(e, t) {
|
|
|
3113
3114
|
projectFrom4326: t.projectFrom4326
|
|
3114
3115
|
});
|
|
3115
3116
|
}
|
|
3116
|
-
class
|
|
3117
|
+
class $r extends ge {
|
|
3117
3118
|
static layerName = "COGLayer";
|
|
3118
3119
|
// COGLayer's getTileData signature differs from the base class's, so
|
|
3119
3120
|
// `DefaultProps<COGLayerProps>` is not assignable to
|
|
@@ -3121,8 +3122,8 @@ class Cr extends he {
|
|
|
3121
3122
|
// to keep inheritance happy. The only COG-specific default is
|
|
3122
3123
|
// `epsgResolver`; all behavior still flows from the base class.
|
|
3123
3124
|
static defaultProps = {
|
|
3124
|
-
...
|
|
3125
|
-
epsgResolver:
|
|
3125
|
+
...ge.defaultProps,
|
|
3126
|
+
epsgResolver: It
|
|
3126
3127
|
};
|
|
3127
3128
|
initializeState() {
|
|
3128
3129
|
this.setState({});
|
|
@@ -3141,12 +3142,12 @@ class Cr extends he {
|
|
|
3141
3142
|
});
|
|
3142
3143
|
}
|
|
3143
3144
|
async _parseGeoTIFF() {
|
|
3144
|
-
const t = await
|
|
3145
|
-
if (!
|
|
3145
|
+
const t = await br(this.props.geotiff), n = t.crs, r = typeof n == "number" ? await this.props.epsgResolver(n) : Gt(n), o = fe(r, "EPSG:4326"), i = (P, b) => o.forward([P, b], !1), a = (P, b) => o.inverse([P, b], !1), s = fe(r, "EPSG:3857"), l = Et((P, b) => s.forward([P, b], !1), i), c = (P, b) => s.inverse([P, b], !1), u = r.units;
|
|
3146
|
+
if (!u)
|
|
3146
3147
|
throw new Error("Source projection is missing 'units' property, cannot compute meters per unit");
|
|
3147
|
-
const h =
|
|
3148
|
+
const h = vt(u, {
|
|
3148
3149
|
semiMajorAxis: r.datum?.a ?? r.a
|
|
3149
|
-
}),
|
|
3150
|
+
}), p = _r(t, {
|
|
3150
3151
|
projectTo4326: i,
|
|
3151
3152
|
projectFrom4326: a,
|
|
3152
3153
|
projectTo3857: l,
|
|
@@ -3154,18 +3155,18 @@ class Cr extends he {
|
|
|
3154
3155
|
mpu: h
|
|
3155
3156
|
});
|
|
3156
3157
|
if (this.props.onGeoTIFFLoad) {
|
|
3157
|
-
const P =
|
|
3158
|
+
const P = Cr(t, o);
|
|
3158
3159
|
this.props.onGeoTIFFLoad(t, {
|
|
3159
3160
|
projection: r,
|
|
3160
3161
|
geographicBounds: P
|
|
3161
3162
|
});
|
|
3162
3163
|
}
|
|
3163
|
-
let
|
|
3164
|
-
(!this.props.getTileData || !this.props.renderTile) && ({ getTileData:
|
|
3164
|
+
let g, y;
|
|
3165
|
+
(!this.props.getTileData || !this.props.renderTile) && ({ getTileData: g, renderTile: y } = Dr(t, this.context.device)), this.setState({
|
|
3165
3166
|
geotiff: t,
|
|
3166
|
-
tilesetDescriptor:
|
|
3167
|
-
defaultGetTileData:
|
|
3168
|
-
defaultRenderTile:
|
|
3167
|
+
tilesetDescriptor: p,
|
|
3168
|
+
defaultGetTileData: g,
|
|
3169
|
+
defaultRenderTile: y
|
|
3169
3170
|
});
|
|
3170
3171
|
}
|
|
3171
3172
|
_tilesetDescriptor() {
|
|
@@ -3187,7 +3188,7 @@ class Cr extends he {
|
|
|
3187
3188
|
x: a,
|
|
3188
3189
|
y: s,
|
|
3189
3190
|
signal: i.signal,
|
|
3190
|
-
pool: this.props.pool ??
|
|
3191
|
+
pool: this.props.pool ?? Sr()
|
|
3191
3192
|
});
|
|
3192
3193
|
} : void 0;
|
|
3193
3194
|
}
|
|
@@ -3197,7 +3198,7 @@ class Cr extends he {
|
|
|
3197
3198
|
return t;
|
|
3198
3199
|
}
|
|
3199
3200
|
}
|
|
3200
|
-
const
|
|
3201
|
+
const ct = `var j;
|
|
3201
3202
|
(function(e) {
|
|
3202
3203
|
e[e.Big = 19789] = "Big", e[e.Little = 18761] = "Little";
|
|
3203
3204
|
})(j || (j = {}));
|
|
@@ -3502,11 +3503,11 @@ export {
|
|
|
3502
3503
|
t as C,
|
|
3503
3504
|
S as D
|
|
3504
3505
|
};
|
|
3505
|
-
`,
|
|
3506
|
-
function
|
|
3506
|
+
`, Re = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", ct], { type: "text/javascript;charset=utf-8" });
|
|
3507
|
+
function kr(e) {
|
|
3507
3508
|
let t;
|
|
3508
3509
|
try {
|
|
3509
|
-
if (t =
|
|
3510
|
+
if (t = Re && (self.URL || self.webkitURL).createObjectURL(Re), !t) throw "";
|
|
3510
3511
|
const n = new Worker(t, {
|
|
3511
3512
|
type: "module",
|
|
3512
3513
|
name: e?.name
|
|
@@ -3516,7 +3517,7 @@ function Lr(e) {
|
|
|
3516
3517
|
}), n;
|
|
3517
3518
|
} catch {
|
|
3518
3519
|
return new Worker(
|
|
3519
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
3520
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(ct),
|
|
3520
3521
|
{
|
|
3521
3522
|
type: "module",
|
|
3522
3523
|
name: e?.name
|
|
@@ -3524,58 +3525,95 @@ function Lr(e) {
|
|
|
3524
3525
|
);
|
|
3525
3526
|
}
|
|
3526
3527
|
}
|
|
3527
|
-
|
|
3528
|
-
const t = e.layout === "band-separate" ? e.bands[0] : e.data;
|
|
3529
|
-
return t instanceof Float32Array ? t : new Float32Array(t);
|
|
3530
|
-
}
|
|
3531
|
-
function Ir(e) {
|
|
3532
|
-
const t = e.width * e.height, n = new Float32Array(t * 4);
|
|
3533
|
-
if (e.layout === "band-separate") {
|
|
3534
|
-
const [r, o, i] = [e.bands[0], e.bands[1], e.bands[2]];
|
|
3535
|
-
for (let a = 0; a < t; a++)
|
|
3536
|
-
n[a * 4] = r[a], n[a * 4 + 1] = o[a], n[a * 4 + 2] = i[a], n[a * 4 + 3] = 1;
|
|
3537
|
-
} else {
|
|
3538
|
-
const { data: r, count: o } = e;
|
|
3539
|
-
for (let i = 0; i < t; i++)
|
|
3540
|
-
n[i * 4] = r[i * o], n[i * 4 + 1] = r[i * o + 1], n[i * 4 + 2] = r[i * o + 2], n[i * 4 + 3] = 1;
|
|
3541
|
-
}
|
|
3542
|
-
return n;
|
|
3543
|
-
}
|
|
3544
|
-
const Gr = async (e, { device: t, x: n, y: r, signal: o, pool: i }) => {
|
|
3528
|
+
const Z = /* @__PURE__ */ new WeakMap(), Ue = async (e, { device: t, x: n, y: r, signal: o, pool: i }) => {
|
|
3545
3529
|
const a = () => {
|
|
3546
3530
|
throw o?.reason ?? new DOMException("aborted", "AbortError");
|
|
3547
3531
|
};
|
|
3548
3532
|
o?.aborted && a();
|
|
3549
3533
|
const s = await e.fetchTile(n, r, { boundless: !1, pool: i, signal: o });
|
|
3550
3534
|
o?.aborted && a();
|
|
3551
|
-
const l = s.array, c = e.cachedTags.samplesPerPixel,
|
|
3552
|
-
data: g,
|
|
3553
|
-
format: h ? "r32float" : "rgba32float",
|
|
3554
|
-
width: l.width,
|
|
3555
|
-
height: l.height,
|
|
3556
|
-
sampler: d
|
|
3557
|
-
});
|
|
3558
|
-
return {
|
|
3535
|
+
const l = s.array, c = e.cachedTags.samplesPerPixel, u = l.layout === "band-separate" ? l.bands.reduce((y, P) => y + P.byteLength || 0, 0) : l.data.byteLength, h = {
|
|
3559
3536
|
width: l.width,
|
|
3560
3537
|
height: l.height,
|
|
3561
|
-
byteLength:
|
|
3562
|
-
|
|
3563
|
-
|
|
3538
|
+
byteLength: u,
|
|
3539
|
+
device: t,
|
|
3540
|
+
array: l,
|
|
3541
|
+
bandTextures: /* @__PURE__ */ new Map(),
|
|
3542
|
+
colormapTexture: await Mt(t),
|
|
3564
3543
|
bandCount: c,
|
|
3565
3544
|
nodata: l.nodata
|
|
3566
3545
|
};
|
|
3546
|
+
let p = Z.get(e);
|
|
3547
|
+
p || Z.set(e, p = /* @__PURE__ */ new Map());
|
|
3548
|
+
const g = `${n},${r}`;
|
|
3549
|
+
return p.set(g, h), h.identifyKey = { image: e, key: g }, h;
|
|
3567
3550
|
};
|
|
3551
|
+
function ie(e) {
|
|
3552
|
+
const t = e.bitsPerSample?.[0] ?? 8, n = e.sampleFormat?.[0] ?? 1;
|
|
3553
|
+
return n === 3 ? `float${t}` : n === 2 ? `int${t}` : `uint${t}`;
|
|
3554
|
+
}
|
|
3555
|
+
function ut(e) {
|
|
3556
|
+
return (e.bitsPerSample?.[0] ?? 8) === 8 && (e.sampleFormat?.[0] ?? 1) === 1;
|
|
3557
|
+
}
|
|
3558
|
+
const Me = /* @__PURE__ */ new WeakMap();
|
|
3559
|
+
function Wr(e, t) {
|
|
3560
|
+
let n = Me.get(e);
|
|
3561
|
+
return n || Me.set(e, n = /* @__PURE__ */ new Map()), { get: () => n.get(t), set: (r) => n.set(t, r) };
|
|
3562
|
+
}
|
|
3563
|
+
function dt(e, t) {
|
|
3564
|
+
const n = e?.bandStatistics;
|
|
3565
|
+
if (!n) return null;
|
|
3566
|
+
const r = [];
|
|
3567
|
+
for (const o of t) {
|
|
3568
|
+
const i = n.get(o + 1);
|
|
3569
|
+
if (!i || i.min === null || i.max === null || !Number.isFinite(i.min) || !Number.isFinite(i.max) || i.min >= i.max) return null;
|
|
3570
|
+
r.push([i.min, i.max]);
|
|
3571
|
+
}
|
|
3572
|
+
return t.length === 1 ? { min: r[0][0], max: r[0][1], source: "stats" } : { min: [r[0][0], r[1][0], r[2][0]], max: [r[0][1], r[1][1], r[2][1]], source: "stats" };
|
|
3573
|
+
}
|
|
3574
|
+
async function ht(e, t, n) {
|
|
3575
|
+
const o = (await e.fetchTile(0, 0, { boundless: !1, pool: n })).array, i = o.nodata ?? null, a = [];
|
|
3576
|
+
for (const s of t) {
|
|
3577
|
+
const l = Ut(o, s);
|
|
3578
|
+
let c = 1 / 0, u = -1 / 0;
|
|
3579
|
+
for (let h = 0; h < l.length; h++) {
|
|
3580
|
+
const p = l[h];
|
|
3581
|
+
!Number.isFinite(p) || p === i || (p < c && (c = p), p > u && (u = p));
|
|
3582
|
+
}
|
|
3583
|
+
if (!(c < u)) return null;
|
|
3584
|
+
a.push([c, u]);
|
|
3585
|
+
}
|
|
3586
|
+
return t.length === 1 ? { min: a[0][0], max: a[0][1], source: "overview" } : { min: [a[0][0], a[1][0], a[2][0]], max: [a[0][1], a[1][1], a[2][1]], source: "overview" };
|
|
3587
|
+
}
|
|
3588
|
+
const pt = 12;
|
|
3589
|
+
function mt(e, t) {
|
|
3590
|
+
const n = Math.floor(e.length / 3), r = t.layout === "band-separate" ? t.bands[0] : t.data, o = /* @__PURE__ */ new Set(), i = t.width * t.height, a = t.layout === "band-separate" ? 1 : t.count ?? 1;
|
|
3591
|
+
for (let l = 0; l < i; l++)
|
|
3592
|
+
if (o.add(Number(r[l * a])), o.size > pt) return null;
|
|
3593
|
+
const s = (l) => (l >> 8).toString(16).padStart(2, "0");
|
|
3594
|
+
return [...o].filter((l) => Number.isInteger(l) && l >= 0 && l < n).sort((l, c) => l - c).map((l) => ({
|
|
3595
|
+
color: `#${s(e[l])}${s(e[n + l])}${s(e[n * 2 + l])}`,
|
|
3596
|
+
label: String(l)
|
|
3597
|
+
}));
|
|
3598
|
+
}
|
|
3599
|
+
const Oe = /* @__PURE__ */ new WeakSet(), Ke = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Set(), De = /* @__PURE__ */ new Set();
|
|
3600
|
+
function Ne(e, t, n) {
|
|
3601
|
+
if (Ke.has(e)) return;
|
|
3602
|
+
Ke.add(e);
|
|
3603
|
+
const r = (i) => Array.isArray(i) ? `[${i.map((a) => +a.toFixed(4)).join(", ")}]` : String(+i.toFixed(4)), o = n.source === "stats" ? "from file statistics" : "SAMPLED FROM THE COARSEST OVERVIEW (no GDAL statistics tags) — the window is data-derived and can move if the file is regenerated";
|
|
3604
|
+
console.warn(`[onlymapjs] "${e}" is ${t} — auto-stretched to [${r(n.min)}, ${r(n.max)}] ${o}. Set min/max (or rescale) explicitly for stable styling.`);
|
|
3605
|
+
}
|
|
3568
3606
|
let W;
|
|
3569
|
-
function
|
|
3607
|
+
function Y() {
|
|
3570
3608
|
if (W) return W;
|
|
3571
3609
|
try {
|
|
3572
|
-
W = new
|
|
3610
|
+
W = new oe({ createWorker: () => new kr() });
|
|
3573
3611
|
} catch (e) {
|
|
3574
|
-
console.warn("[onlymapjs] COGLayer: worker decode unavailable — falling back to main-thread decode.", e), W = new
|
|
3612
|
+
console.warn("[onlymapjs] COGLayer: worker decode unavailable — falling back to main-thread decode.", e), W = new oe({});
|
|
3575
3613
|
}
|
|
3576
3614
|
return W;
|
|
3577
3615
|
}
|
|
3578
|
-
class
|
|
3616
|
+
class Jr extends $r {
|
|
3579
3617
|
static layerName = "OmCOGLayer";
|
|
3580
3618
|
// Plain nulls (not `{type:"number", value:null}` specs): deck's typed
|
|
3581
3619
|
// number props reject null defaults with a console warning per instance.
|
|
@@ -3583,32 +3621,253 @@ class Er extends Cr {
|
|
|
3583
3621
|
rescaleMin: null,
|
|
3584
3622
|
rescaleMax: null,
|
|
3585
3623
|
colormap: null,
|
|
3586
|
-
nodataOverride: null
|
|
3624
|
+
nodataOverride: null,
|
|
3625
|
+
bands: null,
|
|
3626
|
+
stretch: null,
|
|
3627
|
+
gamma: null,
|
|
3628
|
+
reverse: null
|
|
3587
3629
|
};
|
|
3588
3630
|
constructor(t) {
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3631
|
+
super({ ...t, pool: t.pool ?? Y() }, {
|
|
3632
|
+
// Free the per-tile band textures + retained decode on cache eviction
|
|
3633
|
+
// (the guard makes this a no-op for the unstyled path's upstream tile
|
|
3634
|
+
// shape); the sprite texture is device-scoped and must NOT die here.
|
|
3635
|
+
onTileUnload: (n) => {
|
|
3636
|
+
const r = n.data;
|
|
3637
|
+
!r || typeof r != "object" || !("bandTextures" in r) || (Ft(r), r.identifyKey && Z.get(r.identifyKey.image)?.delete(r.identifyKey.key));
|
|
3638
|
+
}
|
|
3639
|
+
});
|
|
3640
|
+
}
|
|
3641
|
+
// The styled/unstyled fork lives in the CALLBACK RESOLVERS, not the
|
|
3642
|
+
// constructor (COG v2 phase 3): the fork now depends on the file header
|
|
3643
|
+
// (bit depth, palette, stats), which only exists once the async open
|
|
3644
|
+
// lands in state. Upstream reads these resolvers per render and recreates
|
|
3645
|
+
// its own wrappers each call, so fresh closures here are its native
|
|
3646
|
+
// convention — tile refetch is keyed on the tileset descriptor, never on
|
|
3647
|
+
// callback identity.
|
|
3648
|
+
/**
|
|
3649
|
+
* Upstream's `_parseGeoTIFF` EAGERLY infers a render pipeline at its tail
|
|
3650
|
+
* and HARD-THROWS for int/float sources ("Inferring render pipeline for
|
|
3651
|
+
* non-unsigned integers not yet supported") — before `state.geotiff` ever
|
|
3652
|
+
* lands, which would kill the exact auto-route that exists to serve those
|
|
3653
|
+
* sources. Conditional retry: the normal run stays untouched (uint8 infers
|
|
3654
|
+
* fine, one header fetch); on the inference throw only, re-run with a
|
|
3655
|
+
* props OVERLAY (prototype chain — the real props object is never mutated)
|
|
3656
|
+
* whose callback pair suppresses the infer, so state.geotiff lands and the
|
|
3657
|
+
* resolvers below route the source through the styled pipeline. The retry
|
|
3658
|
+
* costs one extra header fetch, paid only by sources that were a dead
|
|
3659
|
+
* layer before this existed.
|
|
3660
|
+
*/
|
|
3661
|
+
/** Structured runtime errors (phase 6) through the injected onRasterError → core.onRuntimeError channel — the layer stays mounted, the map stays alive. */
|
|
3662
|
+
omReportError(t, n, r, o) {
|
|
3663
|
+
const i = this.props.onRasterError;
|
|
3664
|
+
i?.({ severity: t, element: `om-layer#${this.props.id}`, attribute: n, message: r, fix: o });
|
|
3665
|
+
}
|
|
3666
|
+
async _parseGeoTIFF() {
|
|
3667
|
+
const t = String(this.props.geotiff ?? "");
|
|
3668
|
+
try {
|
|
3669
|
+
try {
|
|
3670
|
+
await super._parseGeoTIFF();
|
|
3671
|
+
} catch (i) {
|
|
3672
|
+
if (!/Inferring render pipeline|SampleFormat tag is required/.test(String(i))) throw i;
|
|
3673
|
+
await this.omRetryWithoutInference();
|
|
3674
|
+
}
|
|
3675
|
+
} catch (i) {
|
|
3676
|
+
if (i instanceof TypeError || /Failed to fetch|NetworkError|CORS/i.test(String(i))) {
|
|
3677
|
+
this.omReportError(
|
|
3678
|
+
"error",
|
|
3679
|
+
"src",
|
|
3680
|
+
`Could not read "${t}" — the server refused a cross-origin Range request.`,
|
|
3681
|
+
"Serve the COG with Access-Control-Allow-Origin (and expose Range/Content-Range headers), or host it same-origin."
|
|
3682
|
+
);
|
|
3683
|
+
return;
|
|
3684
|
+
}
|
|
3685
|
+
this.omReportError("error", "src", `Could not open "${t}" as a GeoTIFF: ${String(i).slice(0, 200)}`, "Check the URL serves a valid (Cloud-Optimized) GeoTIFF over HTTP range requests.");
|
|
3592
3686
|
return;
|
|
3593
3687
|
}
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3688
|
+
const n = this.omGeotiff();
|
|
3689
|
+
if (!n) return;
|
|
3690
|
+
const r = n.cachedTags;
|
|
3691
|
+
n.overviews.length === 0 && !xe.has(t) && (xe.add(t), this.omReportError(
|
|
3692
|
+
"warning",
|
|
3693
|
+
"src",
|
|
3694
|
+
`"${t}" is a plain (non-cloud-optimized) GeoTIFF — every view re-reads the full image.`,
|
|
3695
|
+
"Convert once: rio cogeo create in.tif out.tif (or gdal_translate -of COG)."
|
|
3696
|
+
));
|
|
3697
|
+
const o = this.omExtra();
|
|
3698
|
+
if (o.bands != null && !De.has(t)) {
|
|
3699
|
+
const i = r.samplesPerPixel ?? 1, a = typeof o.bands == "number" ? [o.bands] : o.bands;
|
|
3700
|
+
Array.isArray(a) && a.some((s) => !Number.isInteger(s) || s < 1 || s > i) && (De.add(t), this.omReportError(
|
|
3701
|
+
"error",
|
|
3702
|
+
"bands",
|
|
3703
|
+
`bands="${JSON.stringify(o.bands)}" but "${t}" has ${i} band${i === 1 ? "" : "s"}.`,
|
|
3704
|
+
`Select 1-based bands within 1..${i} (rendering falls back to the default selection meanwhile).`
|
|
3705
|
+
));
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
async omRetryWithoutInference() {
|
|
3709
|
+
{
|
|
3710
|
+
const t = this, n = t.props;
|
|
3711
|
+
t.props = Object.create(n, {
|
|
3712
|
+
getTileData: { value: Ue, configurable: !0 },
|
|
3713
|
+
renderTile: { value: () => null, configurable: !0 }
|
|
3714
|
+
});
|
|
3715
|
+
try {
|
|
3716
|
+
await super._parseGeoTIFF();
|
|
3717
|
+
} finally {
|
|
3718
|
+
t.props = n;
|
|
3602
3719
|
}
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
omExtra() {
|
|
3723
|
+
return this.props;
|
|
3724
|
+
}
|
|
3725
|
+
omAuthoredStyled() {
|
|
3726
|
+
const t = this.omExtra();
|
|
3727
|
+
return t.rescaleMin != null || t.rescaleMax != null || t.colormap != null && t.colormap !== "" || t.nodataOverride != null || t.bands != null || t.stretch != null || t.gamma != null || t.reverse != null || t.rescale === "auto";
|
|
3728
|
+
}
|
|
3729
|
+
omGeotiff() {
|
|
3730
|
+
return this.state?.geotiff;
|
|
3731
|
+
}
|
|
3732
|
+
/**
|
|
3733
|
+
* The bit-depth auto-route (the "my COG is blank" fix): a non-8-bit
|
|
3734
|
+
* source with NO styling attrs enters the styled pipeline anyway, with a
|
|
3735
|
+
* window from the header. Paletted sources (ColorMap tag) never route —
|
|
3736
|
+
* upstream renders the palette.
|
|
3737
|
+
*/
|
|
3738
|
+
omAutoWanted() {
|
|
3739
|
+
const t = this.omExtra();
|
|
3740
|
+
if (t.rescale === "auto") return !0;
|
|
3741
|
+
if (t.rescaleMin != null && t.rescaleMax != null) return !1;
|
|
3742
|
+
const n = this.omGeotiff();
|
|
3743
|
+
if (!n) return !1;
|
|
3744
|
+
const r = n.cachedTags;
|
|
3745
|
+
return r.colorMap ? !1 : this.omAuthoredStyled() ? !0 : !ut(r);
|
|
3746
|
+
}
|
|
3747
|
+
/** Resolved auto window, kicking off the one-shot overview sample when stats are absent. Undefined while pending/unavailable. */
|
|
3748
|
+
omAutoWindow() {
|
|
3749
|
+
if (!this.omAutoWanted()) return;
|
|
3750
|
+
const t = this.omGeotiff();
|
|
3751
|
+
if (!t) return;
|
|
3752
|
+
const n = this.omExtra(), r = t.cachedTags, o = At(n.bands, r.samplesPerPixel ?? 1), i = Wr(t, o.join(",")), a = i.get();
|
|
3753
|
+
if (a === "pending" || a === null) return;
|
|
3754
|
+
if (a) return a;
|
|
3755
|
+
const s = dt(t.gdalMetadata, o);
|
|
3756
|
+
if (s)
|
|
3757
|
+
return i.set(s), Ne(n.geotiff ?? "", ie(r), s), this.omPublishWindow(s, o), s;
|
|
3758
|
+
i.set("pending");
|
|
3759
|
+
const l = t.overviews[t.overviews.length - 1] ?? t;
|
|
3760
|
+
ht(l, o, this.props.pool ?? Y()).then((c) => {
|
|
3761
|
+
i.set(c), c && (Ne(n.geotiff ?? "", ie(r), c), this.omPublishWindow(c, o));
|
|
3762
|
+
try {
|
|
3763
|
+
this.setState({ omAutoWindowTick: this.state?.omAutoWindowTick === 1 ? 2 : 1 });
|
|
3764
|
+
} catch {
|
|
3765
|
+
}
|
|
3766
|
+
}).catch(() => i.set(null));
|
|
3767
|
+
}
|
|
3768
|
+
/** Feeds the resolved window to the consumer (legend derivation) via the injected onAutoWindow deck prop — the onTilesetLoad compose precedent. */
|
|
3769
|
+
omPublishWindow(t, n) {
|
|
3770
|
+
const r = this.props.onAutoWindow;
|
|
3771
|
+
r?.({ min: t.min, max: t.max, bands: n.map((o) => o + 1), source: t.source });
|
|
3772
|
+
}
|
|
3773
|
+
omStyledActive() {
|
|
3774
|
+
return this.omAuthoredStyled() ? !0 : this.omAutoWindow() !== void 0;
|
|
3775
|
+
}
|
|
3776
|
+
/** Authored style + auto window filling any unauthored window end. */
|
|
3777
|
+
omEffectiveStyle() {
|
|
3778
|
+
const t = this.omExtra(), n = this.omAutoWindow();
|
|
3779
|
+
return {
|
|
3780
|
+
...t,
|
|
3781
|
+
rescaleMin: t.rescaleMin ?? n?.min ?? null,
|
|
3782
|
+
rescaleMax: t.rescaleMax ?? n?.max ?? null
|
|
3783
|
+
};
|
|
3784
|
+
}
|
|
3785
|
+
/**
|
|
3786
|
+
* Pixel identify (COG v2 phase 4): lngLat → source CRS (the descriptor's
|
|
3787
|
+
* own projector) → full-res pixel (geotiff.index) → the FINEST currently-
|
|
3788
|
+
* loaded tile containing it → all bands sampled from the retained decode.
|
|
3789
|
+
* No fetch, no GPU readback; null when the point is outside the image or
|
|
3790
|
+
* no covering tile is resident.
|
|
3791
|
+
*/
|
|
3792
|
+
identify(t) {
|
|
3793
|
+
if (this.props.identify === "off") return null;
|
|
3794
|
+
const n = this.omGeotiff(), r = this.state?.tilesetDescriptor;
|
|
3795
|
+
if (!n || !r?.projectFrom4326) return null;
|
|
3796
|
+
let o;
|
|
3797
|
+
try {
|
|
3798
|
+
o = r.projectFrom4326(t[0], t[1]);
|
|
3799
|
+
} catch {
|
|
3800
|
+
return null;
|
|
3801
|
+
}
|
|
3802
|
+
const [i, a] = n.index(o[0], o[1], Math.floor);
|
|
3803
|
+
if (i < 0 || a < 0 || i >= n.height || a >= n.width) return null;
|
|
3804
|
+
const s = n.cachedTags.samplesPerPixel ?? 1, l = [n, ...n.overviews];
|
|
3805
|
+
for (const c of l) {
|
|
3806
|
+
const u = Z.get(c);
|
|
3807
|
+
if (!u || u.size === 0) continue;
|
|
3808
|
+
const h = Math.min(c.height - 1, Math.floor(i * c.height / n.height)), p = Math.min(c.width - 1, Math.floor(a * c.width / n.width)), g = Math.floor(p / c.tileWidth), y = Math.floor(h / c.tileHeight), P = u.get(`${g},${y}`);
|
|
3809
|
+
if (!P?.array) continue;
|
|
3810
|
+
const b = Math.min(P.width - 1, p - g * c.tileWidth), v = Math.min(P.height - 1, h - y * c.tileHeight), C = jt(P.array, b, v, s), L = P.nodata;
|
|
3811
|
+
return {
|
|
3812
|
+
values: C,
|
|
3813
|
+
bands: C.map((E, G) => G + 1),
|
|
3814
|
+
nodata: L != null && C.every((E) => E === L)
|
|
3815
|
+
};
|
|
3816
|
+
}
|
|
3817
|
+
return null;
|
|
3818
|
+
}
|
|
3819
|
+
updateState(t) {
|
|
3820
|
+
super.updateState(t), Ot(this.props.id, (n) => this.identify(n)), this.omMaybePaletteLegend();
|
|
3821
|
+
}
|
|
3822
|
+
/** One-shot palette legend derivation per opened file (phase 5). */
|
|
3823
|
+
omMaybePaletteLegend() {
|
|
3824
|
+
const t = this.omGeotiff();
|
|
3825
|
+
if (!t || Oe.has(t)) return;
|
|
3826
|
+
const n = t.cachedTags;
|
|
3827
|
+
if (!n.colorMap) return;
|
|
3828
|
+
Oe.add(t);
|
|
3829
|
+
const r = n.colorMap;
|
|
3830
|
+
(t.overviews[t.overviews.length - 1] ?? t).fetchTile(0, 0, { boundless: !1, pool: this.props.pool ?? Y() }).then((i) => {
|
|
3831
|
+
const a = mt(r, i.array);
|
|
3832
|
+
if (!a || a.length === 0) return;
|
|
3833
|
+
const s = this.props.onPaletteLegend;
|
|
3834
|
+
s?.(a);
|
|
3835
|
+
}).catch(() => {
|
|
3603
3836
|
});
|
|
3604
3837
|
}
|
|
3838
|
+
finalizeState(t) {
|
|
3839
|
+
Kt(this.props.id), super.finalizeState(t);
|
|
3840
|
+
}
|
|
3841
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3842
|
+
_getTileDataCallback() {
|
|
3843
|
+
if (!this.omStyledActive()) return super._getTileDataCallback();
|
|
3844
|
+
const t = this.omGeotiff();
|
|
3845
|
+
if (!t) return;
|
|
3846
|
+
const n = this.props.pool ?? Y();
|
|
3847
|
+
return async (r, o) => {
|
|
3848
|
+
const { x: i, y: a, z: s } = r.index, l = s === t.overviews.length ? t : t.overviews[t.overviews.length - 1 - s];
|
|
3849
|
+
return Ue(l, { device: o.device, x: i, y: a, signal: o.signal, pool: n });
|
|
3850
|
+
};
|
|
3851
|
+
}
|
|
3852
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3853
|
+
_renderTileCallback() {
|
|
3854
|
+
if (!this.omStyledActive()) return super._renderTileCallback();
|
|
3855
|
+
const t = this.omEffectiveStyle();
|
|
3856
|
+
return (n) => n ? Rt(n, t) : null;
|
|
3857
|
+
}
|
|
3605
3858
|
}
|
|
3606
|
-
const
|
|
3859
|
+
const Zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3607
3860
|
__proto__: null,
|
|
3608
|
-
OmCOGLayer:
|
|
3861
|
+
OmCOGLayer: Jr,
|
|
3862
|
+
PALETTE_LEGEND_MAX_CLASSES: pt,
|
|
3863
|
+
dtypeName: ie,
|
|
3864
|
+
isUint8: ut,
|
|
3865
|
+
overviewWindow: ht,
|
|
3866
|
+
paletteLegendEntries: mt,
|
|
3867
|
+
statsWindow: dt
|
|
3609
3868
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3610
3869
|
export {
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3870
|
+
f as C,
|
|
3871
|
+
j as D,
|
|
3872
|
+
Zr as r
|
|
3614
3873
|
};
|