maplibre-gl-raster 0.14.5 → 0.14.7
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/dist/{RasterControl-BgzJWA7T.js → RasterControl-GAiOG6eI.js} +1714 -2788
- package/dist/RasterControl-GAiOG6eI.js.map +1 -0
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.mjs +1 -1
- package/package.json +1 -1
- package/dist/LercDecode.es-CZm5toNk.js +0 -442
- package/dist/LercDecode.es-CZm5toNk.js.map +0 -1
- package/dist/RasterControl-BgzJWA7T.js.map +0 -1
- package/dist/__vite-browser-external-BgMKmFg9.js +0 -9
- package/dist/__vite-browser-external-BgMKmFg9.js.map +0 -1
- package/dist/assets/LercDecode.es-Bvg6-wb5.js +0 -442
- package/dist/assets/LercDecode.es-Bvg6-wb5.js.map +0 -1
- package/dist/assets/__vite-browser-external-BgMKmFg9.js +0 -9
- package/dist/assets/__vite-browser-external-BgMKmFg9.js.map +0 -1
- package/dist/assets/chunk-FDOR9p9I.js +0 -24
- package/dist/assets/decode-CdkGJX8C.js +0 -949
- package/dist/assets/decode-CdkGJX8C.js.map +0 -1
- package/dist/assets/lerc-CLJkU_zB.js +0 -34
- package/dist/assets/lerc-CLJkU_zB.js.map +0 -1
- package/dist/assets/lzw-CQJJDca2.js +0 -174
- package/dist/assets/lzw-CQJJDca2.js.map +0 -1
- package/dist/assets/worker-CcHZ_QZT.js +0 -51
- package/dist/assets/worker-CcHZ_QZT.js.map +0 -1
- package/dist/assets/zstd-DBZv9xja.js +0 -569
- package/dist/assets/zstd-DBZv9xja.js.map +0 -1
- package/dist/chunk-FDOR9p9I.js +0 -24
- package/dist/decode-BL-qbDOV.js +0 -1975
- package/dist/decode-BL-qbDOV.js.map +0 -1
- package/dist/lerc-DSUJtfvu.js +0 -34
- package/dist/lerc-DSUJtfvu.js.map +0 -1
- package/dist/lzw-YEsReV21.js +0 -174
- package/dist/lzw-YEsReV21.js.map +0 -1
- package/dist/zstd-DBZv9xja.js +0 -569
- package/dist/zstd-DBZv9xja.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as Photometric, c as RasterTypeKey, d as TiffTag, f as TiffTagGeo, i as Compression, l as SampleFormat, n as decode$1, o as PlanarConfiguration, r as Tiff, s as Predictor, u as SubFileType } from "./decode-BL-qbDOV.js";
|
|
2
1
|
import { MapboxOverlay } from "@deck.gl/mapbox";
|
|
3
2
|
import { PathLayer, PolygonLayer, TextLayer } from "@deck.gl/layers";
|
|
4
3
|
import { CompositeLayer, _GlobeViewport, assert } from "@deck.gl/core";
|
|
5
4
|
import { SimpleMeshLayer } from "@deck.gl/mesh-layers";
|
|
6
5
|
import { TileLayer, _Tileset2D } from "@deck.gl/geo-layers";
|
|
6
|
+
import { GeoTIFF, defaultDecoderPool, parseColormap } from "@developmentseed/geotiff";
|
|
7
7
|
import { Popup, addProtocol, removeProtocol } from "maplibre-gl";
|
|
8
8
|
//#region node_modules/@developmentseed/proj/dist/meters-per-unit.js
|
|
9
9
|
/**
|
|
@@ -1665,6 +1665,739 @@ var MaskTexture = {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
};
|
|
1667
1667
|
//#endregion
|
|
1668
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.endian.js
|
|
1669
|
+
/**
|
|
1670
|
+
* Tiff format
|
|
1671
|
+
*
|
|
1672
|
+
* The header of a Tiff file contains the endianness of the file
|
|
1673
|
+
*/
|
|
1674
|
+
var TiffEndian;
|
|
1675
|
+
(function(TiffEndian) {
|
|
1676
|
+
TiffEndian[TiffEndian["Big"] = 19789] = "Big";
|
|
1677
|
+
TiffEndian[TiffEndian["Little"] = 18761] = "Little";
|
|
1678
|
+
})(TiffEndian || (TiffEndian = {}));
|
|
1679
|
+
//#endregion
|
|
1680
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.tag.id.js
|
|
1681
|
+
/** Sub file type for tag 254 {@link TiffTag.SubFileType} */
|
|
1682
|
+
var SubFileType;
|
|
1683
|
+
(function(SubFileType) {
|
|
1684
|
+
/** Reduced resolution version */
|
|
1685
|
+
SubFileType[SubFileType["ReducedImage"] = 1] = "ReducedImage";
|
|
1686
|
+
/** One page of many */
|
|
1687
|
+
SubFileType[SubFileType["Page"] = 2] = "Page";
|
|
1688
|
+
/** Transparency mask */
|
|
1689
|
+
SubFileType[SubFileType["Mask"] = 4] = "Mask";
|
|
1690
|
+
})(SubFileType || (SubFileType = {}));
|
|
1691
|
+
var Orientation;
|
|
1692
|
+
(function(Orientation) {
|
|
1693
|
+
Orientation[Orientation["TopLeft"] = 1] = "TopLeft";
|
|
1694
|
+
Orientation[Orientation["TopRight"] = 2] = "TopRight";
|
|
1695
|
+
Orientation[Orientation["BottomRight"] = 3] = "BottomRight";
|
|
1696
|
+
Orientation[Orientation["BottomLeft"] = 4] = "BottomLeft";
|
|
1697
|
+
Orientation[Orientation["LeftTop"] = 5] = "LeftTop";
|
|
1698
|
+
Orientation[Orientation["RightTOP"] = 6] = "RightTOP";
|
|
1699
|
+
Orientation[Orientation["RightBottom"] = 7] = "RightBottom";
|
|
1700
|
+
Orientation[Orientation["LeftBottom"] = 8] = "LeftBottom";
|
|
1701
|
+
})(Orientation || (Orientation = {}));
|
|
1702
|
+
var RasterTypeKey;
|
|
1703
|
+
(function(RasterTypeKey) {
|
|
1704
|
+
/**
|
|
1705
|
+
* PixelIsArea (default) a pixel is treated as an area,
|
|
1706
|
+
* the raster coordinate (0,0) is the top left corner of the top left pixel.
|
|
1707
|
+
*/
|
|
1708
|
+
RasterTypeKey[RasterTypeKey["PixelIsArea"] = 1] = "PixelIsArea";
|
|
1709
|
+
/**
|
|
1710
|
+
* PixelIsPoint treats pixels as point samples with empty space between the "pixel" samples.
|
|
1711
|
+
* the raster coordinate (0,0) is the location of the top left raster pixel.
|
|
1712
|
+
*/
|
|
1713
|
+
RasterTypeKey[RasterTypeKey["PixelIsPoint"] = 2] = "PixelIsPoint";
|
|
1714
|
+
})(RasterTypeKey || (RasterTypeKey = {}));
|
|
1715
|
+
var ModelTypeCode;
|
|
1716
|
+
(function(ModelTypeCode) {
|
|
1717
|
+
ModelTypeCode[ModelTypeCode["Unknown"] = 0] = "Unknown";
|
|
1718
|
+
/** Projection Coordinate System */
|
|
1719
|
+
ModelTypeCode[ModelTypeCode["Projected"] = 1] = "Projected";
|
|
1720
|
+
/** Geographic latitude-longitude System */
|
|
1721
|
+
ModelTypeCode[ModelTypeCode["Geographic"] = 2] = "Geographic";
|
|
1722
|
+
/** Geocentric (X,Y,Z) Coordinate System */
|
|
1723
|
+
ModelTypeCode[ModelTypeCode["Geocentric"] = 3] = "Geocentric";
|
|
1724
|
+
ModelTypeCode[ModelTypeCode["UserDefined"] = 32767] = "UserDefined";
|
|
1725
|
+
})(ModelTypeCode || (ModelTypeCode = {}));
|
|
1726
|
+
/** Sub file type for tag 255 {@link TiffTag.OldSubFileType} */
|
|
1727
|
+
var OldSubFileType;
|
|
1728
|
+
(function(OldSubFileType) {
|
|
1729
|
+
/** Full resolution image data */
|
|
1730
|
+
OldSubFileType[OldSubFileType["Image"] = 1] = "Image";
|
|
1731
|
+
/** Reduced resolution version */
|
|
1732
|
+
OldSubFileType[OldSubFileType["ReducedImage"] = 2] = "ReducedImage";
|
|
1733
|
+
/** One page of many */
|
|
1734
|
+
OldSubFileType[OldSubFileType["Page"] = 3] = "Page";
|
|
1735
|
+
})(OldSubFileType || (OldSubFileType = {}));
|
|
1736
|
+
/** Tiff compression types */
|
|
1737
|
+
var Compression;
|
|
1738
|
+
(function(Compression) {
|
|
1739
|
+
Compression[Compression["None"] = 1] = "None";
|
|
1740
|
+
Compression[Compression["Ccittrle"] = 2] = "Ccittrle";
|
|
1741
|
+
Compression[Compression["CcittT4"] = 3] = "CcittT4";
|
|
1742
|
+
Compression[Compression["CcittT6"] = 4] = "CcittT6";
|
|
1743
|
+
Compression[Compression["Lzw"] = 5] = "Lzw";
|
|
1744
|
+
Compression[Compression["Jpeg6"] = 6] = "Jpeg6";
|
|
1745
|
+
Compression[Compression["Jpeg"] = 7] = "Jpeg";
|
|
1746
|
+
Compression[Compression["DeflateOther"] = 8] = "DeflateOther";
|
|
1747
|
+
Compression[Compression["T85"] = 9] = "T85";
|
|
1748
|
+
Compression[Compression["T43"] = 10] = "T43";
|
|
1749
|
+
Compression[Compression["Next"] = 32766] = "Next";
|
|
1750
|
+
Compression[Compression["Ccittrlew"] = 32771] = "Ccittrlew";
|
|
1751
|
+
Compression[Compression["PackBits"] = 32773] = "PackBits";
|
|
1752
|
+
Compression[Compression["ThunderScan"] = 32809] = "ThunderScan";
|
|
1753
|
+
Compression[Compression["It8ctpad"] = 32895] = "It8ctpad";
|
|
1754
|
+
Compression[Compression["It8lw"] = 32896] = "It8lw";
|
|
1755
|
+
Compression[Compression["It8mp"] = 32897] = "It8mp";
|
|
1756
|
+
Compression[Compression["It8bl"] = 32898] = "It8bl";
|
|
1757
|
+
Compression[Compression["PixarFilm"] = 32908] = "PixarFilm";
|
|
1758
|
+
Compression[Compression["PixarLog"] = 32909] = "PixarLog";
|
|
1759
|
+
Compression[Compression["Deflate"] = 32946] = "Deflate";
|
|
1760
|
+
Compression[Compression["Dcs"] = 32947] = "Dcs";
|
|
1761
|
+
Compression[Compression["Jbig"] = 34661] = "Jbig";
|
|
1762
|
+
Compression[Compression["SgiLog"] = 34676] = "SgiLog";
|
|
1763
|
+
Compression[Compression["SgiLog24"] = 34677] = "SgiLog24";
|
|
1764
|
+
Compression[Compression["Jp2000"] = 34712] = "Jp2000";
|
|
1765
|
+
Compression[Compression["Lerc"] = 34887] = "Lerc";
|
|
1766
|
+
Compression[Compression["Lzma"] = 34925] = "Lzma";
|
|
1767
|
+
Compression[Compression["Zstd"] = 5e4] = "Zstd";
|
|
1768
|
+
Compression[Compression["Webp"] = 50001] = "Webp";
|
|
1769
|
+
Compression[Compression["JpegXl"] = 50002] = "JpegXl";
|
|
1770
|
+
Compression[Compression["JpegXlDng17"] = 52546] = "JpegXlDng17";
|
|
1771
|
+
})(Compression || (Compression = {}));
|
|
1772
|
+
var PlanarConfiguration;
|
|
1773
|
+
(function(PlanarConfiguration) {
|
|
1774
|
+
/** single image plane */
|
|
1775
|
+
PlanarConfiguration[PlanarConfiguration["Contig"] = 1] = "Contig";
|
|
1776
|
+
/** separate planes of data */
|
|
1777
|
+
PlanarConfiguration[PlanarConfiguration["Separate"] = 2] = "Separate";
|
|
1778
|
+
})(PlanarConfiguration || (PlanarConfiguration = {}));
|
|
1779
|
+
var Predictor;
|
|
1780
|
+
(function(Predictor) {
|
|
1781
|
+
Predictor[Predictor["None"] = 1] = "None";
|
|
1782
|
+
/** Horizontal differencing */
|
|
1783
|
+
Predictor[Predictor["Horizontal"] = 2] = "Horizontal";
|
|
1784
|
+
/** Floating point */
|
|
1785
|
+
Predictor[Predictor["FloatingPoint"] = 3] = "FloatingPoint";
|
|
1786
|
+
})(Predictor || (Predictor = {}));
|
|
1787
|
+
var SampleFormat;
|
|
1788
|
+
(function(SampleFormat) {
|
|
1789
|
+
/** Unsigned integer data */
|
|
1790
|
+
SampleFormat[SampleFormat["Uint"] = 1] = "Uint";
|
|
1791
|
+
/** Signed integer data */
|
|
1792
|
+
SampleFormat[SampleFormat["Int"] = 2] = "Int";
|
|
1793
|
+
/** IEEE floating point data */
|
|
1794
|
+
SampleFormat[SampleFormat["Float"] = 3] = "Float";
|
|
1795
|
+
/** Untyped data */
|
|
1796
|
+
SampleFormat[SampleFormat["Void"] = 4] = "Void";
|
|
1797
|
+
/** Complex signed int */
|
|
1798
|
+
SampleFormat[SampleFormat["ComplexInt"] = 5] = "ComplexInt";
|
|
1799
|
+
/** Complex ieee floating */
|
|
1800
|
+
SampleFormat[SampleFormat["ComplexFloat"] = 6] = "ComplexFloat";
|
|
1801
|
+
})(SampleFormat || (SampleFormat = {}));
|
|
1802
|
+
var Photometric;
|
|
1803
|
+
(function(Photometric) {
|
|
1804
|
+
/** min value is white */
|
|
1805
|
+
Photometric[Photometric["MinIsWhite"] = 0] = "MinIsWhite";
|
|
1806
|
+
/** min value is black */
|
|
1807
|
+
Photometric[Photometric["MinIsBlack"] = 1] = "MinIsBlack";
|
|
1808
|
+
/** RGB color model */
|
|
1809
|
+
Photometric[Photometric["Rgb"] = 2] = "Rgb";
|
|
1810
|
+
/** color map indexed */
|
|
1811
|
+
Photometric[Photometric["Palette"] = 3] = "Palette";
|
|
1812
|
+
/** $holdout mask */
|
|
1813
|
+
Photometric[Photometric["Mask"] = 4] = "Mask";
|
|
1814
|
+
/** !color separations */
|
|
1815
|
+
Photometric[Photometric["Separated"] = 5] = "Separated";
|
|
1816
|
+
/** !CCIR 601 */
|
|
1817
|
+
Photometric[Photometric["Ycbcr"] = 6] = "Ycbcr";
|
|
1818
|
+
/** !1976 CIE L*a*b* */
|
|
1819
|
+
Photometric[Photometric["Cielab"] = 8] = "Cielab";
|
|
1820
|
+
/** ICC L*a*b* [Adobe TIFF Technote 4] */
|
|
1821
|
+
Photometric[Photometric["Icclab"] = 9] = "Icclab";
|
|
1822
|
+
/** ITU L*a*b* */
|
|
1823
|
+
Photometric[Photometric["Itulab"] = 10] = "Itulab";
|
|
1824
|
+
/** color filter array */
|
|
1825
|
+
Photometric[Photometric["Cfa"] = 32803] = "Cfa";
|
|
1826
|
+
/** CIE Log2(L) */
|
|
1827
|
+
Photometric[Photometric["Logl"] = 32844] = "Logl";
|
|
1828
|
+
Photometric[Photometric["Logluv"] = 32845] = "Logluv";
|
|
1829
|
+
})(Photometric || (Photometric = {}));
|
|
1830
|
+
/**
|
|
1831
|
+
* Tiff tags as defined by libtiff and libgeotiff
|
|
1832
|
+
*
|
|
1833
|
+
* - {@link https://gitlab.com/libtiff/libtiff}
|
|
1834
|
+
* - {@link https://github.com/OSGeo/libgeotiff/}
|
|
1835
|
+
*/
|
|
1836
|
+
var TiffTag;
|
|
1837
|
+
(function(TiffTag) {
|
|
1838
|
+
/**
|
|
1839
|
+
* Type of the sub file
|
|
1840
|
+
*
|
|
1841
|
+
* @see {@link SubFileType}
|
|
1842
|
+
*/
|
|
1843
|
+
TiffTag[TiffTag["SubFileType"] = 254] = "SubFileType";
|
|
1844
|
+
/**
|
|
1845
|
+
* Type of sub file
|
|
1846
|
+
*
|
|
1847
|
+
* @see {@link OldSubFileType}
|
|
1848
|
+
*/
|
|
1849
|
+
TiffTag[TiffTag["OldSubFileType"] = 255] = "OldSubFileType";
|
|
1850
|
+
/** Width of image in pixels */
|
|
1851
|
+
TiffTag[TiffTag["ImageWidth"] = 256] = "ImageWidth";
|
|
1852
|
+
/** Height of image in pixels */
|
|
1853
|
+
TiffTag[TiffTag["ImageHeight"] = 257] = "ImageHeight";
|
|
1854
|
+
/**
|
|
1855
|
+
* Number of bits per channel
|
|
1856
|
+
*
|
|
1857
|
+
* @example
|
|
1858
|
+
* ```typescript
|
|
1859
|
+
* [8,8,8] // 8 bit RGB
|
|
1860
|
+
* [16] // 16bit
|
|
1861
|
+
* ```
|
|
1862
|
+
*/
|
|
1863
|
+
TiffTag[TiffTag["BitsPerSample"] = 258] = "BitsPerSample";
|
|
1864
|
+
/**
|
|
1865
|
+
*
|
|
1866
|
+
* Data type of the image
|
|
1867
|
+
*
|
|
1868
|
+
* See {@link SampleFormat}
|
|
1869
|
+
*
|
|
1870
|
+
* @example
|
|
1871
|
+
* ```typescript
|
|
1872
|
+
* [1] // SampleFormat.Uint
|
|
1873
|
+
* [1,1,1,1] // 4 band Uint
|
|
1874
|
+
* ```
|
|
1875
|
+
*/
|
|
1876
|
+
TiffTag[TiffTag["SampleFormat"] = 339] = "SampleFormat";
|
|
1877
|
+
/**
|
|
1878
|
+
* Compression Type
|
|
1879
|
+
*
|
|
1880
|
+
* @see {@link Compression}
|
|
1881
|
+
*
|
|
1882
|
+
* @example
|
|
1883
|
+
* ```typescript
|
|
1884
|
+
* 5 // Compression.Lzw
|
|
1885
|
+
* ```
|
|
1886
|
+
*/
|
|
1887
|
+
TiffTag[TiffTag["Compression"] = 259] = "Compression";
|
|
1888
|
+
/**
|
|
1889
|
+
* Photometric interpretation
|
|
1890
|
+
*
|
|
1891
|
+
* @see {@link Photometric}
|
|
1892
|
+
*
|
|
1893
|
+
* @example
|
|
1894
|
+
* ```typescript
|
|
1895
|
+
* 2 // Photometric.Rgb
|
|
1896
|
+
* ```
|
|
1897
|
+
*/
|
|
1898
|
+
TiffTag[TiffTag["Photometric"] = 262] = "Photometric";
|
|
1899
|
+
/** Tile width in pixels */
|
|
1900
|
+
TiffTag[TiffTag["TileWidth"] = 322] = "TileWidth";
|
|
1901
|
+
/** Tile height in pixels */
|
|
1902
|
+
TiffTag[TiffTag["TileHeight"] = 323] = "TileHeight";
|
|
1903
|
+
/**
|
|
1904
|
+
* Offsets to data tiles
|
|
1905
|
+
* `0` means the tile has no data (sparse tiff)
|
|
1906
|
+
*
|
|
1907
|
+
* @example
|
|
1908
|
+
* ```typescript
|
|
1909
|
+
* [0, 3200, 1406] // three tiles, first tile does not exist
|
|
1910
|
+
* ```
|
|
1911
|
+
*/
|
|
1912
|
+
TiffTag[TiffTag["TileOffsets"] = 324] = "TileOffsets";
|
|
1913
|
+
/**
|
|
1914
|
+
* Byte counts for tiles
|
|
1915
|
+
* `0 means the tile does not exist (sparse tiff)
|
|
1916
|
+
*
|
|
1917
|
+
* @example
|
|
1918
|
+
* ```typescript
|
|
1919
|
+
* [0, 3200, 1406] // three tiles, first tile does not exist
|
|
1920
|
+
* ```
|
|
1921
|
+
**/
|
|
1922
|
+
TiffTag[TiffTag["TileByteCounts"] = 325] = "TileByteCounts";
|
|
1923
|
+
/** JPEG table stream */
|
|
1924
|
+
TiffTag[TiffTag["JpegTables"] = 347] = "JpegTables";
|
|
1925
|
+
TiffTag[TiffTag["StripOffsets"] = 273] = "StripOffsets";
|
|
1926
|
+
TiffTag[TiffTag["StripByteCounts"] = 279] = "StripByteCounts";
|
|
1927
|
+
/**
|
|
1928
|
+
* GDAL metadata
|
|
1929
|
+
* Generally a xml document with lots of information about the tiff and how it was created
|
|
1930
|
+
*/
|
|
1931
|
+
TiffTag[TiffTag["GdalMetadata"] = 42112] = "GdalMetadata";
|
|
1932
|
+
/**
|
|
1933
|
+
* No data value encoded as a string
|
|
1934
|
+
*
|
|
1935
|
+
* @example "-9999"
|
|
1936
|
+
*/
|
|
1937
|
+
TiffTag[TiffTag["GdalNoData"] = 42113] = "GdalNoData";
|
|
1938
|
+
/** GeoTiff Tags */
|
|
1939
|
+
/**
|
|
1940
|
+
* Pixel scale in meters
|
|
1941
|
+
* in the format [scaleX, scaleY, scaleZ]
|
|
1942
|
+
*
|
|
1943
|
+
* Requires {@link ModelTiePoint} to be set and {@link ModelTransformation} not to be set
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* [100.0, 100.0, 0.0]
|
|
1948
|
+
* ```
|
|
1949
|
+
*/
|
|
1950
|
+
TiffTag[TiffTag["ModelPixelScale"] = 33550] = "ModelPixelScale";
|
|
1951
|
+
/**
|
|
1952
|
+
* Position of the tiff
|
|
1953
|
+
*
|
|
1954
|
+
* contains a list of tie points that contain
|
|
1955
|
+
* [x,y,z] of position in the in the tiff, generally [0,0,0]
|
|
1956
|
+
* [x,y,z] of the position in the projected
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* Mapping tiff point `[0,0,0]` to projected coordinates `[350807.4, 5316081.3, 0.0]`
|
|
1960
|
+
* ```
|
|
1961
|
+
* [0, 0, 0, 350807.4, 5316081.3, 0.0]
|
|
1962
|
+
* ```
|
|
1963
|
+
*/
|
|
1964
|
+
TiffTag[TiffTag["ModelTiePoint"] = 33922] = "ModelTiePoint";
|
|
1965
|
+
/**
|
|
1966
|
+
* Exact affine transformation between the tiff and the projected location
|
|
1967
|
+
*
|
|
1968
|
+
* this tag should not be defined when {@link ModelTiePoint} or {@link ModelPixelScale} are used
|
|
1969
|
+
*
|
|
1970
|
+
* @example
|
|
1971
|
+
*```typescript
|
|
1972
|
+
* [ 0, 100.0, 0, 400000.0,
|
|
1973
|
+
* 100.0, 0, 0, 500000.0,
|
|
1974
|
+
* 0, 0, 0, 0,
|
|
1975
|
+
* 0, 0, 0, 1]
|
|
1976
|
+
* ```
|
|
1977
|
+
*/
|
|
1978
|
+
TiffTag[TiffTag["ModelTransformation"] = 34264] = "ModelTransformation";
|
|
1979
|
+
/**
|
|
1980
|
+
* List of GeoTiff tags
|
|
1981
|
+
* {@link TiffTagGeo}
|
|
1982
|
+
*
|
|
1983
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_geokeydirectorytag}
|
|
1984
|
+
*/
|
|
1985
|
+
TiffTag[TiffTag["GeoKeyDirectory"] = 34735] = "GeoKeyDirectory";
|
|
1986
|
+
/**
|
|
1987
|
+
* Double Parameters for GeoTiff Tags
|
|
1988
|
+
*
|
|
1989
|
+
* {@link TiffTagGeo}
|
|
1990
|
+
*/
|
|
1991
|
+
TiffTag[TiffTag["GeoDoubleParams"] = 34736] = "GeoDoubleParams";
|
|
1992
|
+
/**
|
|
1993
|
+
* Ascii Parameters for GeoTiff Tags
|
|
1994
|
+
*
|
|
1995
|
+
* {@link TiffTagGeo}
|
|
1996
|
+
*/
|
|
1997
|
+
TiffTag[TiffTag["GeoAsciiParams"] = 34737] = "GeoAsciiParams";
|
|
1998
|
+
/**
|
|
1999
|
+
* Stores the LERC version and additional compression
|
|
2000
|
+
*
|
|
2001
|
+
* @example
|
|
2002
|
+
* ```typescript
|
|
2003
|
+
* [4, 0] // version 4, no extra compression
|
|
2004
|
+
* ```
|
|
2005
|
+
*/
|
|
2006
|
+
TiffTag[TiffTag["LercParameters"] = 50674] = "LercParameters";
|
|
2007
|
+
TiffTag[TiffTag["PlanarConfiguration"] = 284] = "PlanarConfiguration";
|
|
2008
|
+
/** Untyped values */
|
|
2009
|
+
TiffTag[TiffTag["CellLength"] = 265] = "CellLength";
|
|
2010
|
+
TiffTag[TiffTag["CellWidth"] = 264] = "CellWidth";
|
|
2011
|
+
TiffTag[TiffTag["ColorMap"] = 320] = "ColorMap";
|
|
2012
|
+
TiffTag[TiffTag["Copyright"] = 33432] = "Copyright";
|
|
2013
|
+
TiffTag[TiffTag["DateTime"] = 306] = "DateTime";
|
|
2014
|
+
TiffTag[TiffTag["ExtraSamples"] = 338] = "ExtraSamples";
|
|
2015
|
+
TiffTag[TiffTag["FillOrder"] = 266] = "FillOrder";
|
|
2016
|
+
TiffTag[TiffTag["FreeByteCounts"] = 289] = "FreeByteCounts";
|
|
2017
|
+
TiffTag[TiffTag["FreeOffsets"] = 288] = "FreeOffsets";
|
|
2018
|
+
TiffTag[TiffTag["GrayResponseCurve"] = 291] = "GrayResponseCurve";
|
|
2019
|
+
TiffTag[TiffTag["GrayResponseUnit"] = 290] = "GrayResponseUnit";
|
|
2020
|
+
TiffTag[TiffTag["HostComputer"] = 316] = "HostComputer";
|
|
2021
|
+
TiffTag[TiffTag["ImageDescription"] = 270] = "ImageDescription";
|
|
2022
|
+
TiffTag[TiffTag["Make"] = 271] = "Make";
|
|
2023
|
+
TiffTag[TiffTag["MaxSampleValue"] = 281] = "MaxSampleValue";
|
|
2024
|
+
TiffTag[TiffTag["MinSampleValue"] = 280] = "MinSampleValue";
|
|
2025
|
+
TiffTag[TiffTag["Model"] = 272] = "Model";
|
|
2026
|
+
TiffTag[TiffTag["Orientation"] = 274] = "Orientation";
|
|
2027
|
+
TiffTag[TiffTag["ResolutionUnit"] = 296] = "ResolutionUnit";
|
|
2028
|
+
TiffTag[TiffTag["RowsPerStrip"] = 278] = "RowsPerStrip";
|
|
2029
|
+
TiffTag[TiffTag["SamplesPerPixel"] = 277] = "SamplesPerPixel";
|
|
2030
|
+
TiffTag[TiffTag["Software"] = 305] = "Software";
|
|
2031
|
+
TiffTag[TiffTag["Threshholding"] = 263] = "Threshholding";
|
|
2032
|
+
TiffTag[TiffTag["XResolution"] = 282] = "XResolution";
|
|
2033
|
+
TiffTag[TiffTag["YResolution"] = 283] = "YResolution";
|
|
2034
|
+
TiffTag[TiffTag["BadFaxLines"] = 326] = "BadFaxLines";
|
|
2035
|
+
TiffTag[TiffTag["CleanFaxData"] = 327] = "CleanFaxData";
|
|
2036
|
+
TiffTag[TiffTag["ClipPath"] = 343] = "ClipPath";
|
|
2037
|
+
TiffTag[TiffTag["ConsecutiveBadFaxLines"] = 328] = "ConsecutiveBadFaxLines";
|
|
2038
|
+
TiffTag[TiffTag["Decode"] = 433] = "Decode";
|
|
2039
|
+
TiffTag[TiffTag["DefaultImageColor"] = 434] = "DefaultImageColor";
|
|
2040
|
+
TiffTag[TiffTag["DocumentName"] = 269] = "DocumentName";
|
|
2041
|
+
TiffTag[TiffTag["DotRange"] = 336] = "DotRange";
|
|
2042
|
+
TiffTag[TiffTag["HalftoneHints"] = 321] = "HalftoneHints";
|
|
2043
|
+
TiffTag[TiffTag["Indexed"] = 346] = "Indexed";
|
|
2044
|
+
TiffTag[TiffTag["PageName"] = 285] = "PageName";
|
|
2045
|
+
TiffTag[TiffTag["PageNumber"] = 297] = "PageNumber";
|
|
2046
|
+
TiffTag[TiffTag["Predictor"] = 317] = "Predictor";
|
|
2047
|
+
TiffTag[TiffTag["PrimaryChromaticities"] = 319] = "PrimaryChromaticities";
|
|
2048
|
+
TiffTag[TiffTag["ReferenceBlackWhite"] = 532] = "ReferenceBlackWhite";
|
|
2049
|
+
TiffTag[TiffTag["SMinSampleValue"] = 340] = "SMinSampleValue";
|
|
2050
|
+
TiffTag[TiffTag["SMaxSampleValue"] = 341] = "SMaxSampleValue";
|
|
2051
|
+
TiffTag[TiffTag["StripRowCounts"] = 559] = "StripRowCounts";
|
|
2052
|
+
TiffTag[TiffTag["SubIFDs"] = 330] = "SubIFDs";
|
|
2053
|
+
TiffTag[TiffTag["T4Options"] = 292] = "T4Options";
|
|
2054
|
+
TiffTag[TiffTag["T6Options"] = 293] = "T6Options";
|
|
2055
|
+
TiffTag[TiffTag["TransferFunction"] = 301] = "TransferFunction";
|
|
2056
|
+
TiffTag[TiffTag["WhitePoint"] = 318] = "WhitePoint";
|
|
2057
|
+
TiffTag[TiffTag["XClipPathUnits"] = 344] = "XClipPathUnits";
|
|
2058
|
+
TiffTag[TiffTag["XPosition"] = 286] = "XPosition";
|
|
2059
|
+
TiffTag[TiffTag["YCbCrCoefficients"] = 529] = "YCbCrCoefficients";
|
|
2060
|
+
TiffTag[TiffTag["YCbCrPositioning"] = 531] = "YCbCrPositioning";
|
|
2061
|
+
TiffTag[TiffTag["YCbCrSubSampling"] = 530] = "YCbCrSubSampling";
|
|
2062
|
+
TiffTag[TiffTag["YClipPathUnits"] = 345] = "YClipPathUnits";
|
|
2063
|
+
TiffTag[TiffTag["YPosition"] = 287] = "YPosition";
|
|
2064
|
+
TiffTag[TiffTag["ApertureValue"] = 37378] = "ApertureValue";
|
|
2065
|
+
TiffTag[TiffTag["ColorSpace"] = 40961] = "ColorSpace";
|
|
2066
|
+
TiffTag[TiffTag["DateTimeDigitized"] = 36868] = "DateTimeDigitized";
|
|
2067
|
+
TiffTag[TiffTag["DateTimeOriginal"] = 36867] = "DateTimeOriginal";
|
|
2068
|
+
TiffTag[TiffTag["ExifIFD"] = 34665] = "ExifIFD";
|
|
2069
|
+
TiffTag[TiffTag["ExifVersion"] = 36864] = "ExifVersion";
|
|
2070
|
+
TiffTag[TiffTag["ExposureTime"] = 33434] = "ExposureTime";
|
|
2071
|
+
TiffTag[TiffTag["FileSource"] = 41728] = "FileSource";
|
|
2072
|
+
TiffTag[TiffTag["Flash"] = 37385] = "Flash";
|
|
2073
|
+
TiffTag[TiffTag["FlashpixVersion"] = 40960] = "FlashpixVersion";
|
|
2074
|
+
TiffTag[TiffTag["FNumber"] = 33437] = "FNumber";
|
|
2075
|
+
TiffTag[TiffTag["ImageUniqueID"] = 42016] = "ImageUniqueID";
|
|
2076
|
+
TiffTag[TiffTag["LightSource"] = 37384] = "LightSource";
|
|
2077
|
+
TiffTag[TiffTag["MakerNote"] = 37500] = "MakerNote";
|
|
2078
|
+
TiffTag[TiffTag["ShutterSpeedValue"] = 37377] = "ShutterSpeedValue";
|
|
2079
|
+
TiffTag[TiffTag["UserComment"] = 37510] = "UserComment";
|
|
2080
|
+
TiffTag[TiffTag["IPTC"] = 33723] = "IPTC";
|
|
2081
|
+
TiffTag[TiffTag["ICCProfile"] = 34675] = "ICCProfile";
|
|
2082
|
+
TiffTag[TiffTag["XMP"] = 700] = "XMP";
|
|
2083
|
+
})(TiffTag || (TiffTag = {}));
|
|
2084
|
+
/**
|
|
2085
|
+
* Geotiff tags as defined by OGC GeoTiff 1.1
|
|
2086
|
+
*
|
|
2087
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_summary_of_geokey_ids_and_names}
|
|
2088
|
+
*/
|
|
2089
|
+
var TiffTagGeo;
|
|
2090
|
+
(function(TiffTagGeo) {
|
|
2091
|
+
/**
|
|
2092
|
+
* This GeoKey defines the type of Model coordinate reference system used, to which the transformation from the raster space is made:
|
|
2093
|
+
*
|
|
2094
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_gtmodeltypegeokey}
|
|
2095
|
+
*
|
|
2096
|
+
* {@link ModelTypeCode}
|
|
2097
|
+
*/
|
|
2098
|
+
TiffTagGeo[TiffTagGeo["GTModelTypeGeoKey"] = 1024] = "GTModelTypeGeoKey";
|
|
2099
|
+
/**
|
|
2100
|
+
* There are currently only two options: `RasterPixelIsPoint` and `RasterPixelIsArea`
|
|
2101
|
+
*
|
|
2102
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_gtrastertypegeokey}
|
|
2103
|
+
*
|
|
2104
|
+
* {@link RasterTypeKey}
|
|
2105
|
+
*/
|
|
2106
|
+
TiffTagGeo[TiffTagGeo["GTRasterTypeGeoKey"] = 1025] = "GTRasterTypeGeoKey";
|
|
2107
|
+
/**
|
|
2108
|
+
* ASCII reference to published documentation on the overall configuration of the GeoTIFF file.
|
|
2109
|
+
*
|
|
2110
|
+
* @example "NZGD2000 / New Zealand Transverse Mercator 2000"
|
|
2111
|
+
*/
|
|
2112
|
+
TiffTagGeo[TiffTagGeo["GTCitationGeoKey"] = 1026] = "GTCitationGeoKey";
|
|
2113
|
+
/**
|
|
2114
|
+
* Renamed from GeographicTypeGeoKey in OGC GeoTiff
|
|
2115
|
+
*/
|
|
2116
|
+
TiffTagGeo[TiffTagGeo["GeodeticCRSGeoKey"] = 2048] = "GeodeticCRSGeoKey";
|
|
2117
|
+
/**
|
|
2118
|
+
* Renamed from GeogCitationGeoKey in OGC GeoTiff
|
|
2119
|
+
*
|
|
2120
|
+
* @example "NZTM"
|
|
2121
|
+
*/
|
|
2122
|
+
TiffTagGeo[TiffTagGeo["GeodeticCitationGeoKey"] = 2049] = "GeodeticCitationGeoKey";
|
|
2123
|
+
/**
|
|
2124
|
+
* Renamed from GeogGeodeticDatumGeoKey in OGC GeoTiff
|
|
2125
|
+
*/
|
|
2126
|
+
TiffTagGeo[TiffTagGeo["GeodeticDatumGeoKey"] = 2050] = "GeodeticDatumGeoKey";
|
|
2127
|
+
/**
|
|
2128
|
+
* Renamed from "GeogPrimeMeridianGeoKey" in OGC GeoTiff
|
|
2129
|
+
*/
|
|
2130
|
+
TiffTagGeo[TiffTagGeo["PrimeMeridianGeoKey"] = 2051] = "PrimeMeridianGeoKey";
|
|
2131
|
+
/**
|
|
2132
|
+
* Linear unit of measure
|
|
2133
|
+
* @example 9001 // Metre
|
|
2134
|
+
*/
|
|
2135
|
+
TiffTagGeo[TiffTagGeo["GeogLinearUnitsGeoKey"] = 2052] = "GeogLinearUnitsGeoKey";
|
|
2136
|
+
TiffTagGeo[TiffTagGeo["GeogLinearUnitSizeGeoKey"] = 2053] = "GeogLinearUnitSizeGeoKey";
|
|
2137
|
+
/**
|
|
2138
|
+
* Angular unit of measure
|
|
2139
|
+
*
|
|
2140
|
+
* @example 9102 // Degree
|
|
2141
|
+
*/
|
|
2142
|
+
TiffTagGeo[TiffTagGeo["GeogAngularUnitsGeoKey"] = 2054] = "GeogAngularUnitsGeoKey";
|
|
2143
|
+
TiffTagGeo[TiffTagGeo["GeogAngularUnitSizeGeoKey"] = 2055] = "GeogAngularUnitSizeGeoKey";
|
|
2144
|
+
/**
|
|
2145
|
+
* Renamed from "GeogEllipsoidGeoKey" in OGC GeoTiff
|
|
2146
|
+
*/
|
|
2147
|
+
TiffTagGeo[TiffTagGeo["EllipsoidGeoKey"] = 2056] = "EllipsoidGeoKey";
|
|
2148
|
+
/**
|
|
2149
|
+
* Renamed from "GeogSemiMajorAxisGeoKey" in OGC GeoTiff
|
|
2150
|
+
*/
|
|
2151
|
+
TiffTagGeo[TiffTagGeo["EllipsoidSemiMajorAxisGeoKey"] = 2057] = "EllipsoidSemiMajorAxisGeoKey";
|
|
2152
|
+
/**
|
|
2153
|
+
* Renamed from "GeogSemiMinorAxisGeoKey" in OGC GeoTiff
|
|
2154
|
+
*/
|
|
2155
|
+
TiffTagGeo[TiffTagGeo["EllipsoidSemiMinorAxisGeoKey"] = 2058] = "EllipsoidSemiMinorAxisGeoKey";
|
|
2156
|
+
/**
|
|
2157
|
+
* Renamed from "GeogInvFlatteningGeoKey" in OGC GeoTiff
|
|
2158
|
+
*/
|
|
2159
|
+
TiffTagGeo[TiffTagGeo["EllipsoidInvFlatteningGeoKey"] = 2059] = "EllipsoidInvFlatteningGeoKey";
|
|
2160
|
+
/**
|
|
2161
|
+
* Renamed from "GeogPrimeMeridianLongGeoKey" in OGC GeoTiff
|
|
2162
|
+
*/
|
|
2163
|
+
TiffTagGeo[TiffTagGeo["PrimeMeridianLongitudeGeoKey"] = 2061] = "PrimeMeridianLongitudeGeoKey";
|
|
2164
|
+
TiffTagGeo[TiffTagGeo["GeogTOWGS84GeoKey"] = 2062] = "GeogTOWGS84GeoKey";
|
|
2165
|
+
TiffTagGeo[TiffTagGeo["GeogAzimuthUnitsGeoKey"] = 2060] = "GeogAzimuthUnitsGeoKey";
|
|
2166
|
+
/**
|
|
2167
|
+
* EPSG code of the tiff
|
|
2168
|
+
*
|
|
2169
|
+
* Renamed from "ProjectedCSTypeGeoKey" in OGC GeoTiff
|
|
2170
|
+
*
|
|
2171
|
+
* @example
|
|
2172
|
+
* ```typescript
|
|
2173
|
+
* 2193 // NZTM
|
|
2174
|
+
* 3857 // WebMercatorQuad
|
|
2175
|
+
* ```
|
|
2176
|
+
*/
|
|
2177
|
+
TiffTagGeo[TiffTagGeo["ProjectedCRSGeoKey"] = 3072] = "ProjectedCRSGeoKey";
|
|
2178
|
+
/**
|
|
2179
|
+
* ASCII reference to published documentation on the Projected Coordinate System
|
|
2180
|
+
*
|
|
2181
|
+
* Renamed from "PCSCitationGeoKey" in OGC GeoTiff
|
|
2182
|
+
*
|
|
2183
|
+
* @example "UTM Zone 60 N with WGS 84"
|
|
2184
|
+
*/
|
|
2185
|
+
TiffTagGeo[TiffTagGeo["ProjectedCitationGeoKey"] = 3073] = "ProjectedCitationGeoKey";
|
|
2186
|
+
/**
|
|
2187
|
+
* Specifies a map projection from the GeoTIFF CRS register or to indicate that the map projection is user-defined.
|
|
2188
|
+
*
|
|
2189
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_map_projection_geokeys}
|
|
2190
|
+
*
|
|
2191
|
+
* @example 2193
|
|
2192
|
+
*/
|
|
2193
|
+
TiffTagGeo[TiffTagGeo["ProjectionGeoKey"] = 3074] = "ProjectionGeoKey";
|
|
2194
|
+
TiffTagGeo[TiffTagGeo["ProjMethodGeoKey"] = 3075] = "ProjMethodGeoKey";
|
|
2195
|
+
TiffTagGeo[TiffTagGeo["ProjLinearUnitsGeoKey"] = 3076] = "ProjLinearUnitsGeoKey";
|
|
2196
|
+
TiffTagGeo[TiffTagGeo["ProjLinearUnitSizeGeoKey"] = 3077] = "ProjLinearUnitSizeGeoKey";
|
|
2197
|
+
TiffTagGeo[TiffTagGeo["ProjStdParallel1GeoKey"] = 3078] = "ProjStdParallel1GeoKey";
|
|
2198
|
+
TiffTagGeo[TiffTagGeo["ProjStdParallel2GeoKey"] = 3079] = "ProjStdParallel2GeoKey";
|
|
2199
|
+
TiffTagGeo[TiffTagGeo["ProjNatOriginLongGeoKey"] = 3080] = "ProjNatOriginLongGeoKey";
|
|
2200
|
+
TiffTagGeo[TiffTagGeo["ProjNatOriginLatGeoKey"] = 3081] = "ProjNatOriginLatGeoKey";
|
|
2201
|
+
TiffTagGeo[TiffTagGeo["ProjFalseEastingGeoKey"] = 3082] = "ProjFalseEastingGeoKey";
|
|
2202
|
+
TiffTagGeo[TiffTagGeo["ProjFalseNorthingGeoKey"] = 3083] = "ProjFalseNorthingGeoKey";
|
|
2203
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginLongGeoKey"] = 3084] = "ProjFalseOriginLongGeoKey";
|
|
2204
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginLatGeoKey"] = 3085] = "ProjFalseOriginLatGeoKey";
|
|
2205
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginEastingGeoKey"] = 3086] = "ProjFalseOriginEastingGeoKey";
|
|
2206
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginNorthingGeoKey"] = 3087] = "ProjFalseOriginNorthingGeoKey";
|
|
2207
|
+
TiffTagGeo[TiffTagGeo["ProjCenterLongGeoKey"] = 3088] = "ProjCenterLongGeoKey";
|
|
2208
|
+
TiffTagGeo[TiffTagGeo["ProjCenterLatGeoKey"] = 3089] = "ProjCenterLatGeoKey";
|
|
2209
|
+
TiffTagGeo[TiffTagGeo["ProjCenterEastingGeoKey"] = 3090] = "ProjCenterEastingGeoKey";
|
|
2210
|
+
TiffTagGeo[TiffTagGeo["ProjCenterNorthingGeoKey"] = 3091] = "ProjCenterNorthingGeoKey";
|
|
2211
|
+
TiffTagGeo[TiffTagGeo["ProjScaleAtNatOriginGeoKey"] = 3092] = "ProjScaleAtNatOriginGeoKey";
|
|
2212
|
+
TiffTagGeo[TiffTagGeo["ProjScaleAtCenterGeoKey"] = 3093] = "ProjScaleAtCenterGeoKey";
|
|
2213
|
+
TiffTagGeo[TiffTagGeo["ProjAzimuthAngleGeoKey"] = 3094] = "ProjAzimuthAngleGeoKey";
|
|
2214
|
+
TiffTagGeo[TiffTagGeo["ProjStraightVertPoleLongGeoKey"] = 3095] = "ProjStraightVertPoleLongGeoKey";
|
|
2215
|
+
TiffTagGeo[TiffTagGeo["ProjRectifiedGridAngleGeoKey"] = 3096] = "ProjRectifiedGridAngleGeoKey";
|
|
2216
|
+
/**
|
|
2217
|
+
* This key is provided to specify the vertical coordinate reference system from the GeoTIFF CRS register or to indicate that the CRS is a user-defined vertical coordinate reference system. The value for VerticalGeoKey should follow the
|
|
2218
|
+
*
|
|
2219
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_verticalgeokey}
|
|
2220
|
+
*
|
|
2221
|
+
* @example 4979
|
|
2222
|
+
*/
|
|
2223
|
+
TiffTagGeo[TiffTagGeo["VerticalGeoKey"] = 4096] = "VerticalGeoKey";
|
|
2224
|
+
/**
|
|
2225
|
+
*
|
|
2226
|
+
* @example "Geographic 3D WGS 84, Ellipsoidal height"
|
|
2227
|
+
*/
|
|
2228
|
+
TiffTagGeo[TiffTagGeo["VerticalCitationGeoKey"] = 4097] = "VerticalCitationGeoKey";
|
|
2229
|
+
/**
|
|
2230
|
+
* vertical datum for a user-defined vertical coordinate reference system.
|
|
2231
|
+
*/
|
|
2232
|
+
TiffTagGeo[TiffTagGeo["VerticalDatumGeoKey"] = 4098] = "VerticalDatumGeoKey";
|
|
2233
|
+
/**
|
|
2234
|
+
* Linear Unit for vertical CRS
|
|
2235
|
+
*
|
|
2236
|
+
* @example 9001
|
|
2237
|
+
*/
|
|
2238
|
+
TiffTagGeo[TiffTagGeo["VerticalUnitsGeoKey"] = 4099] = "VerticalUnitsGeoKey";
|
|
2239
|
+
})(TiffTagGeo || (TiffTagGeo = {}));
|
|
2240
|
+
/**
|
|
2241
|
+
* EPSG Angular Units. exist between [9100, 9199]
|
|
2242
|
+
*
|
|
2243
|
+
* Taken from libgeotiff
|
|
2244
|
+
*/
|
|
2245
|
+
var AngularUnit;
|
|
2246
|
+
(function(AngularUnit) {
|
|
2247
|
+
AngularUnit[AngularUnit["Radian"] = 9101] = "Radian";
|
|
2248
|
+
AngularUnit[AngularUnit["Degree"] = 9102] = "Degree";
|
|
2249
|
+
AngularUnit[AngularUnit["ArcMinute"] = 9103] = "ArcMinute";
|
|
2250
|
+
AngularUnit[AngularUnit["ArcDegree"] = 9104] = "ArcDegree";
|
|
2251
|
+
AngularUnit[AngularUnit["Grad"] = 9105] = "Grad";
|
|
2252
|
+
AngularUnit[AngularUnit["Gon"] = 9106] = "Gon";
|
|
2253
|
+
AngularUnit[AngularUnit["Dms"] = 9107] = "Dms";
|
|
2254
|
+
})(AngularUnit || (AngularUnit = {}));
|
|
2255
|
+
/**
|
|
2256
|
+
* ESPG Liner units exist between [9000, 9099]
|
|
2257
|
+
*
|
|
2258
|
+
* Taken from libgeotiff
|
|
2259
|
+
*/
|
|
2260
|
+
var LinearUnit;
|
|
2261
|
+
(function(LinearUnit) {
|
|
2262
|
+
LinearUnit[LinearUnit["Metre"] = 9001] = "Metre";
|
|
2263
|
+
LinearUnit[LinearUnit["Foot"] = 9002] = "Foot";
|
|
2264
|
+
LinearUnit[LinearUnit["FootUsSurvey"] = 9003] = "FootUsSurvey";
|
|
2265
|
+
LinearUnit[LinearUnit["FootModifiedAmerican"] = 9004] = "FootModifiedAmerican";
|
|
2266
|
+
LinearUnit[LinearUnit["FootClarke"] = 9005] = "FootClarke";
|
|
2267
|
+
LinearUnit[LinearUnit["FootIndian"] = 9006] = "FootIndian";
|
|
2268
|
+
LinearUnit[LinearUnit["Link"] = 9007] = "Link";
|
|
2269
|
+
LinearUnit[LinearUnit["LinkBenoit"] = 9008] = "LinkBenoit";
|
|
2270
|
+
LinearUnit[LinearUnit["LinkSears"] = 9009] = "LinkSears";
|
|
2271
|
+
LinearUnit[LinearUnit["ChainBenoit"] = 9010] = "ChainBenoit";
|
|
2272
|
+
LinearUnit[LinearUnit["ChainSears"] = 9011] = "ChainSears";
|
|
2273
|
+
LinearUnit[LinearUnit["YardSears"] = 9012] = "YardSears";
|
|
2274
|
+
LinearUnit[LinearUnit["YardIndian"] = 9013] = "YardIndian";
|
|
2275
|
+
LinearUnit[LinearUnit["Fathom"] = 9014] = "Fathom";
|
|
2276
|
+
LinearUnit[LinearUnit["MileInternationalNautical"] = 9015] = "MileInternationalNautical";
|
|
2277
|
+
})(LinearUnit || (LinearUnit = {}));
|
|
2278
|
+
TiffTag.TileByteCounts, TiffTag.TileOffsets, TiffTag.StripOffsets, TiffTag.StripByteCounts, TiffTag.BitsPerSample, TiffTag.SampleFormat, TiffTag.GeoKeyDirectory, TiffTag.GeoDoubleParams;
|
|
2279
|
+
//#endregion
|
|
2280
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.mime.js
|
|
2281
|
+
/**
|
|
2282
|
+
* MimeType conversion for common tif image compresson types
|
|
2283
|
+
*/
|
|
2284
|
+
var TiffMimeType;
|
|
2285
|
+
(function(TiffMimeType) {
|
|
2286
|
+
TiffMimeType["None"] = "application/octet-stream";
|
|
2287
|
+
TiffMimeType["Jbig"] = "image/jbig";
|
|
2288
|
+
TiffMimeType["Dcs"] = "image/x-kodak-dcs";
|
|
2289
|
+
TiffMimeType["PackBits"] = "application/packbits";
|
|
2290
|
+
TiffMimeType["Jpeg"] = "image/jpeg";
|
|
2291
|
+
TiffMimeType["Jp2000"] = "image/jp2";
|
|
2292
|
+
TiffMimeType["JpegXl"] = "image/jpegxl";
|
|
2293
|
+
TiffMimeType["Webp"] = "image/webp";
|
|
2294
|
+
TiffMimeType["Zstd"] = "application/zstd";
|
|
2295
|
+
TiffMimeType["Lzw"] = "application/lzw";
|
|
2296
|
+
TiffMimeType["Deflate"] = "application/deflate";
|
|
2297
|
+
TiffMimeType["Lerc"] = "application/lerc";
|
|
2298
|
+
TiffMimeType["Lzma"] = "application/x-lzma";
|
|
2299
|
+
})(TiffMimeType || (TiffMimeType = {}));
|
|
2300
|
+
Compression.None, TiffMimeType.None, Compression.Lzw, TiffMimeType.Lzw, Compression.Jpeg6, TiffMimeType.Jpeg, Compression.Jpeg, TiffMimeType.Jpeg, Compression.DeflateOther, TiffMimeType.Deflate, Compression.Deflate, TiffMimeType.Deflate, Compression.Lerc, TiffMimeType.Lerc, Compression.Lzma, TiffMimeType.Lzma, Compression.Jp2000, TiffMimeType.Jp2000, Compression.Zstd, TiffMimeType.Zstd, Compression.Webp, TiffMimeType.Webp, Compression.JpegXl, TiffMimeType.JpegXl, Compression.Ccittrle, TiffMimeType.None, Compression.CcittT4, TiffMimeType.None, Compression.CcittT6, TiffMimeType.None, Compression.T85, TiffMimeType.Jbig, Compression.T43, TiffMimeType.Jbig, Compression.Next, TiffMimeType.None, Compression.Ccittrlew, TiffMimeType.None, Compression.PackBits, TiffMimeType.PackBits, Compression.ThunderScan, TiffMimeType.None, Compression.It8ctpad, TiffMimeType.None, Compression.It8lw, TiffMimeType.None, Compression.It8mp, TiffMimeType.None, Compression.It8bl, TiffMimeType.None, Compression.PixarFilm, TiffMimeType.None, Compression.PixarLog, TiffMimeType.None, Compression.Dcs, TiffMimeType.Dcs, Compression.Jbig, TiffMimeType.Jbig, Compression.SgiLog, TiffMimeType.None, Compression.SgiLog24, TiffMimeType.None, Compression.JpegXlDng17, TiffMimeType.JpegXl;
|
|
2301
|
+
//#endregion
|
|
2302
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.tag.value.js
|
|
2303
|
+
var TiffTagValueType;
|
|
2304
|
+
(function(TiffTagValueType) {
|
|
2305
|
+
TiffTagValueType[TiffTagValueType["Uint8"] = 1] = "Uint8";
|
|
2306
|
+
TiffTagValueType[TiffTagValueType["Ascii"] = 2] = "Ascii";
|
|
2307
|
+
TiffTagValueType[TiffTagValueType["Uint16"] = 3] = "Uint16";
|
|
2308
|
+
TiffTagValueType[TiffTagValueType["Uint32"] = 4] = "Uint32";
|
|
2309
|
+
TiffTagValueType[TiffTagValueType["Rational"] = 5] = "Rational";
|
|
2310
|
+
TiffTagValueType[TiffTagValueType["Int8"] = 6] = "Int8";
|
|
2311
|
+
TiffTagValueType[TiffTagValueType["Undefined"] = 7] = "Undefined";
|
|
2312
|
+
TiffTagValueType[TiffTagValueType["Int16"] = 8] = "Int16";
|
|
2313
|
+
TiffTagValueType[TiffTagValueType["Int32"] = 9] = "Int32";
|
|
2314
|
+
TiffTagValueType[TiffTagValueType["SignedRational"] = 10] = "SignedRational";
|
|
2315
|
+
TiffTagValueType[TiffTagValueType["Float32"] = 11] = "Float32";
|
|
2316
|
+
TiffTagValueType[TiffTagValueType["Float64"] = 12] = "Float64";
|
|
2317
|
+
TiffTagValueType[TiffTagValueType["Ifd"] = 13] = "Ifd";
|
|
2318
|
+
TiffTagValueType[TiffTagValueType["Uint64"] = 16] = "Uint64";
|
|
2319
|
+
TiffTagValueType[TiffTagValueType["Int64"] = 17] = "Int64";
|
|
2320
|
+
TiffTagValueType[TiffTagValueType["Ifd8"] = 18] = "Ifd8";
|
|
2321
|
+
})(TiffTagValueType || (TiffTagValueType = {}));
|
|
2322
|
+
//#endregion
|
|
2323
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.version.js
|
|
2324
|
+
/**
|
|
2325
|
+
* Tif version number that is stored at the start of a tif file
|
|
2326
|
+
*/
|
|
2327
|
+
var TiffVersion;
|
|
2328
|
+
(function(TiffVersion) {
|
|
2329
|
+
/**
|
|
2330
|
+
* Big tif's,
|
|
2331
|
+
* generally uses 64bit numbers for offsets
|
|
2332
|
+
* @see http://bigtiff.org/
|
|
2333
|
+
**/
|
|
2334
|
+
TiffVersion[TiffVersion["BigTiff"] = 43] = "BigTiff";
|
|
2335
|
+
/**
|
|
2336
|
+
* Original tif
|
|
2337
|
+
* Uses 32 bit or smaller numbers for offsets and counters
|
|
2338
|
+
*/
|
|
2339
|
+
TiffVersion[TiffVersion["Tiff"] = 42] = "Tiff";
|
|
2340
|
+
})(TiffVersion || (TiffVersion = {}));
|
|
2341
|
+
//#endregion
|
|
2342
|
+
//#region node_modules/@cogeotiff/core/build/util/bytes.js
|
|
2343
|
+
var ByteSizeFloat;
|
|
2344
|
+
(function(ByteSizeFloat) {
|
|
2345
|
+
ByteSizeFloat[ByteSizeFloat["Double"] = 8] = "Double";
|
|
2346
|
+
ByteSizeFloat[ByteSizeFloat["Float32"] = 4] = "Float32";
|
|
2347
|
+
})(ByteSizeFloat || (ByteSizeFloat = {}));
|
|
2348
|
+
var ByteSize;
|
|
2349
|
+
(function(ByteSize) {
|
|
2350
|
+
ByteSize[ByteSize["UInt64"] = 8] = "UInt64";
|
|
2351
|
+
ByteSize[ByteSize["UInt32"] = 4] = "UInt32";
|
|
2352
|
+
ByteSize[ByteSize["UInt16"] = 2] = "UInt16";
|
|
2353
|
+
ByteSize[ByteSize["UInt8"] = 1] = "UInt8";
|
|
2354
|
+
})(ByteSize || (ByteSize = {}));
|
|
2355
|
+
//#endregion
|
|
2356
|
+
//#region node_modules/@cogeotiff/core/build/read/endian.js
|
|
2357
|
+
var buffer = /* @__PURE__ */ new ArrayBuffer(4);
|
|
2358
|
+
var uint32 = new Uint32Array(buffer);
|
|
2359
|
+
var uint8 = new Uint8Array(buffer);
|
|
2360
|
+
uint32[0] = 1;
|
|
2361
|
+
uint8[0];
|
|
2362
|
+
new Set([
|
|
2363
|
+
TiffTag.Compression,
|
|
2364
|
+
TiffTag.ImageHeight,
|
|
2365
|
+
TiffTag.ImageWidth,
|
|
2366
|
+
TiffTag.ModelPixelScale,
|
|
2367
|
+
TiffTag.ModelTiePoint,
|
|
2368
|
+
TiffTag.ModelTransformation,
|
|
2369
|
+
TiffTag.TileHeight,
|
|
2370
|
+
TiffTag.TileWidth
|
|
2371
|
+
]);
|
|
2372
|
+
new Set([
|
|
2373
|
+
TiffTag.GeoKeyDirectory,
|
|
2374
|
+
TiffTag.GeoAsciiParams,
|
|
2375
|
+
TiffTag.GeoDoubleParams
|
|
2376
|
+
]);
|
|
2377
|
+
//#endregion
|
|
2378
|
+
//#region node_modules/@cogeotiff/core/build/read/tiff.gdal.js
|
|
2379
|
+
var GhostOption;
|
|
2380
|
+
(function(GhostOption) {
|
|
2381
|
+
GhostOption["GdalStructuralMetadataSize"] = "GDAL_STRUCTURAL_METADATA_SIZE";
|
|
2382
|
+
GhostOption["Layout"] = "LAYOUT";
|
|
2383
|
+
GhostOption["BlockOrder"] = "BLOCK_ORDER";
|
|
2384
|
+
GhostOption["BlockLeader"] = "BLOCK_LEADER";
|
|
2385
|
+
GhostOption["BlockTrailer"] = "BLOCK_TRAILER";
|
|
2386
|
+
GhostOption["KnownIncompatibleEdition"] = "KNOWN_INCOMPATIBLE_EDITION";
|
|
2387
|
+
GhostOption["MaskInterleavedWithImagery"] = "MASK_INTERLEAVED_WITH_IMAGERY";
|
|
2388
|
+
})(GhostOption || (GhostOption = {}));
|
|
2389
|
+
var GhostOptionTileOrder;
|
|
2390
|
+
(function(GhostOptionTileOrder) {
|
|
2391
|
+
GhostOptionTileOrder["RowMajor"] = "ROW_MAJOR";
|
|
2392
|
+
})(GhostOptionTileOrder || (GhostOptionTileOrder = {}));
|
|
2393
|
+
var GhostOptionTileLeader;
|
|
2394
|
+
(function(GhostOptionTileLeader) {
|
|
2395
|
+
GhostOptionTileLeader["uint32"] = "SIZE_AS_UINT4";
|
|
2396
|
+
})(GhostOptionTileLeader || (GhostOptionTileLeader = {}));
|
|
2397
|
+
TiffVersion.Tiff, ByteSize.UInt32, ByteSize.UInt16, ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt32;
|
|
2398
|
+
TiffVersion.BigTiff, ByteSize.UInt64, ByteSize.UInt64, ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt64;
|
|
2399
|
+
TiffVersion.BigTiff, TiffVersion.Tiff;
|
|
2400
|
+
//#endregion
|
|
1668
2401
|
//#region src/lib/raster/stats.ts
|
|
1669
2402
|
/**
|
|
1670
2403
|
* Parse band descriptions from the GDAL_METADATA XML tag. Looks for
|
|
@@ -3881,28 +4614,6 @@ function translation(xoff, yoff) {
|
|
|
3881
4614
|
];
|
|
3882
4615
|
}
|
|
3883
4616
|
/**
|
|
3884
|
-
* Create a scaling transform from a scalar or vector.
|
|
3885
|
-
*
|
|
3886
|
-
* You can pass either one or two scaling factors. Passing only a single scalar
|
|
3887
|
-
* value will scale in both dimensions equally. A vector scaling value scales
|
|
3888
|
-
* the dimensions independently.
|
|
3889
|
-
*
|
|
3890
|
-
* @param sx Scaling factor in x direction.
|
|
3891
|
-
* @param sy Scaling factor in y direction (defaults to sx if not provided).
|
|
3892
|
-
*
|
|
3893
|
-
* @return Transform that applies the given scaling.
|
|
3894
|
-
*/
|
|
3895
|
-
function scale$3(sx, sy = sx) {
|
|
3896
|
-
return [
|
|
3897
|
-
sx,
|
|
3898
|
-
0,
|
|
3899
|
-
0,
|
|
3900
|
-
0,
|
|
3901
|
-
sy,
|
|
3902
|
-
0
|
|
3903
|
-
];
|
|
3904
|
-
}
|
|
3905
|
-
/**
|
|
3906
4617
|
* Apply a geotransform to a coordinate.
|
|
3907
4618
|
*
|
|
3908
4619
|
* That is, we apply this series of equations:
|
|
@@ -8110,2175 +8821,99 @@ var RasterTileLayer = class extends CompositeLayer {
|
|
|
8110
8821
|
}
|
|
8111
8822
|
};
|
|
8112
8823
|
//#endregion
|
|
8113
|
-
//#region node_modules
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
*/
|
|
8122
|
-
function parseColormap(cmap, nodata) {
|
|
8123
|
-
const size = cmap.length / 3;
|
|
8124
|
-
const rgba = new Uint8ClampedArray(size * 4);
|
|
8125
|
-
const rOffset = 0;
|
|
8126
|
-
const gOffset = size;
|
|
8127
|
-
const bOffset = size * 2;
|
|
8128
|
-
for (let i = 0; i < size; i++) {
|
|
8129
|
-
rgba[4 * i + 0] = cmap[rOffset + i] >> 8;
|
|
8130
|
-
rgba[4 * i + 1] = cmap[gOffset + i] >> 8;
|
|
8131
|
-
rgba[4 * i + 2] = cmap[bOffset + i] >> 8;
|
|
8132
|
-
rgba[4 * i + 3] = 255;
|
|
8824
|
+
//#region node_modules/proj4/lib/global.js
|
|
8825
|
+
function global_default(defs) {
|
|
8826
|
+
defs("EPSG:4326", "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
|
|
8827
|
+
defs("EPSG:4269", "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees");
|
|
8828
|
+
defs("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
|
|
8829
|
+
for (var i = 1; i <= 60; ++i) {
|
|
8830
|
+
defs("EPSG:" + (32600 + i), "+proj=utm +zone=" + i + " +datum=WGS84 +units=m");
|
|
8831
|
+
defs("EPSG:" + (32700 + i), "+proj=utm +zone=" + i + " +south +datum=WGS84 +units=m");
|
|
8133
8832
|
}
|
|
8134
|
-
|
|
8135
|
-
|
|
8833
|
+
defs("EPSG:5041", "+title=WGS 84 / UPS North (E,N) +proj=stere +lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m");
|
|
8834
|
+
defs("EPSG:5042", "+title=WGS 84 / UPS South (E,N) +proj=stere +lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m");
|
|
8835
|
+
defs.WGS84 = defs["EPSG:4326"];
|
|
8836
|
+
defs["EPSG:3785"] = defs["EPSG:3857"];
|
|
8837
|
+
defs.GOOGLE = defs["EPSG:3857"];
|
|
8838
|
+
defs["EPSG:900913"] = defs["EPSG:3857"];
|
|
8839
|
+
defs["EPSG:102113"] = defs["EPSG:3857"];
|
|
8136
8840
|
}
|
|
8137
8841
|
//#endregion
|
|
8138
|
-
//#region node_modules
|
|
8139
|
-
var
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
this.protocols = new Set(opts.protocols ?? []);
|
|
8154
|
-
}
|
|
8155
|
-
fetch(req, next) {
|
|
8156
|
-
if (this.protocols.size > 0 && !this.protocols.has(req.source.url.protocol)) return next(req);
|
|
8157
|
-
if (req.length == null) return next(req);
|
|
8158
|
-
const cacheKey = `${req.source.url.toString()}@${req.offset}+${req.length}`;
|
|
8159
|
-
let existing = this.cacheA.get(cacheKey);
|
|
8160
|
-
if (existing) {
|
|
8161
|
-
existing.hits++;
|
|
8162
|
-
return existing.promise;
|
|
8163
|
-
}
|
|
8164
|
-
existing = this.cacheB.get(cacheKey);
|
|
8165
|
-
if (existing) {
|
|
8166
|
-
existing.hits++;
|
|
8167
|
-
existing.saves++;
|
|
8168
|
-
this.size += existing.size;
|
|
8169
|
-
this.cacheA.set(cacheKey, existing);
|
|
8170
|
-
return existing.promise;
|
|
8171
|
-
}
|
|
8172
|
-
existing = {
|
|
8173
|
-
promise: next(req),
|
|
8174
|
-
hits: 0,
|
|
8175
|
-
saves: 0,
|
|
8176
|
-
size: req.length
|
|
8177
|
-
};
|
|
8178
|
-
this.size += existing.size;
|
|
8179
|
-
if (this.size > this.maxSize) {
|
|
8180
|
-
this.size = existing.size;
|
|
8181
|
-
this.cacheB = this.cacheA;
|
|
8182
|
-
this.cacheA = /* @__PURE__ */ new Map();
|
|
8183
|
-
this.resets++;
|
|
8184
|
-
}
|
|
8185
|
-
this.cacheA.set(cacheKey, existing);
|
|
8186
|
-
return existing.promise;
|
|
8187
|
-
}
|
|
8188
|
-
};
|
|
8189
|
-
//#endregion
|
|
8190
|
-
//#region node_modules/@chunkd/source/build/src/error.js
|
|
8191
|
-
var SourceError = class SourceError extends Error {
|
|
8192
|
-
/** Status code for the error eg 403 - Forbidden vs 404 Not found */
|
|
8193
|
-
code;
|
|
8194
|
-
/** URL that the status code came from */
|
|
8195
|
-
url;
|
|
8196
|
-
/** File system that triggered the error */
|
|
8197
|
-
source;
|
|
8198
|
-
constructor(msg, code, source, cause) {
|
|
8199
|
-
super(msg, { cause });
|
|
8200
|
-
this.code = code;
|
|
8201
|
-
this.url = source.url;
|
|
8202
|
-
this.source = source;
|
|
8203
|
-
/** Helper to determine if this class is a SourceError, useful for when `instanceof` fails */
|
|
8204
|
-
Object.defineProperty(this, "_sourceError", {
|
|
8205
|
-
enumerable: false,
|
|
8206
|
-
value: "SourceError"
|
|
8207
|
-
});
|
|
8208
|
-
}
|
|
8209
|
-
/** Check that a unknown is a FsError */
|
|
8210
|
-
static is(e) {
|
|
8211
|
-
if (e instanceof SourceError) return true;
|
|
8212
|
-
if (typeof e !== "object") return false;
|
|
8213
|
-
if (e == null) return false;
|
|
8214
|
-
return "_sourceError" in e && e["_sourceError"] === "SourceError";
|
|
8215
|
-
}
|
|
8216
|
-
};
|
|
8842
|
+
//#region node_modules/proj4/lib/constants/values.js
|
|
8843
|
+
var SRS_WGS84_SEMIMAJOR = 6378137;
|
|
8844
|
+
var SRS_WGS84_SEMIMINOR = 6356752.314;
|
|
8845
|
+
var SRS_WGS84_ESQUARED = .0066943799901413165;
|
|
8846
|
+
var SEC_TO_RAD = 484813681109536e-20;
|
|
8847
|
+
var HALF_PI = Math.PI / 2;
|
|
8848
|
+
var SIXTH = .16666666666666666;
|
|
8849
|
+
var RA4 = .04722222222222222;
|
|
8850
|
+
var RA6 = .022156084656084655;
|
|
8851
|
+
var EPSLN = 1e-10;
|
|
8852
|
+
var D2R = .017453292519943295;
|
|
8853
|
+
var R2D = 57.29577951308232;
|
|
8854
|
+
var FORTPI = Math.PI / 4;
|
|
8855
|
+
var TWO_PI = Math.PI * 2;
|
|
8856
|
+
var SPI = 3.14159265359;
|
|
8217
8857
|
//#endregion
|
|
8218
|
-
//#region node_modules
|
|
8219
|
-
var
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
/**
|
|
8234
|
-
* Parse a Content-Range header to extract the size of the source
|
|
8235
|
-
*
|
|
8236
|
-
* @example
|
|
8237
|
-
* ```typescript
|
|
8238
|
-
* ContentRange.parseRange("bytes 200-1000/67589"); // 67589
|
|
8239
|
-
* ```
|
|
8240
|
-
* @throws if range is not a Content-Range with size
|
|
8241
|
-
*/
|
|
8242
|
-
parseSize(range) {
|
|
8243
|
-
const [unit, chunks] = range.split(" ");
|
|
8244
|
-
if (unit !== "bytes") throw new Error("Failed to parse content-range: " + range);
|
|
8245
|
-
if (chunks == null) throw new Error("Failed to parse content-range: " + range);
|
|
8246
|
-
const [, size] = chunks.split("/");
|
|
8247
|
-
const result = Number(size);
|
|
8248
|
-
if (isNaN(result)) throw new Error("Failed to parse content-range: " + range);
|
|
8249
|
-
return result;
|
|
8250
|
-
}
|
|
8251
|
-
};
|
|
8858
|
+
//#region node_modules/proj4/lib/constants/PrimeMeridian.js
|
|
8859
|
+
var primeMeridian = {};
|
|
8860
|
+
primeMeridian.greenwich = 0;
|
|
8861
|
+
primeMeridian.lisbon = -9.131906111111;
|
|
8862
|
+
primeMeridian.paris = 2.337229166667;
|
|
8863
|
+
primeMeridian.bogota = -74.080916666667;
|
|
8864
|
+
primeMeridian.madrid = -3.687938888889;
|
|
8865
|
+
primeMeridian.rome = 12.452333333333;
|
|
8866
|
+
primeMeridian.bern = 7.439583333333;
|
|
8867
|
+
primeMeridian.jakarta = 106.807719444444;
|
|
8868
|
+
primeMeridian.ferro = -17.666666666667;
|
|
8869
|
+
primeMeridian.brussels = 4.367975;
|
|
8870
|
+
primeMeridian.stockholm = 18.058277777778;
|
|
8871
|
+
primeMeridian.athens = 23.7163375;
|
|
8872
|
+
primeMeridian.oslo = 10.722916666667;
|
|
8252
8873
|
//#endregion
|
|
8253
|
-
//#region node_modules
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
}
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
}
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
}
|
|
8274
|
-
|
|
8275
|
-
return this.source.url;
|
|
8276
|
-
}
|
|
8277
|
-
get metadata() {
|
|
8278
|
-
return this.source.metadata;
|
|
8279
|
-
}
|
|
8280
|
-
head(options) {
|
|
8281
|
-
return this.source.head(options);
|
|
8282
|
-
}
|
|
8283
|
-
async fetch(offset, length, options) {
|
|
8284
|
-
const middleware = this.middleware;
|
|
8285
|
-
if (middleware == null || middleware.length === 0) return this.source.fetch(offset, length, options);
|
|
8286
|
-
const handler = (req) => this.source.fetch(req.offset, req.length, options);
|
|
8287
|
-
return this.run(handler, offset, length, options);
|
|
8288
|
-
}
|
|
8289
|
-
/** Run a request using all the middleware */
|
|
8290
|
-
async run(handler, offset, length, options) {
|
|
8291
|
-
const middleware = this.middleware;
|
|
8292
|
-
if (middleware == null) return handler({
|
|
8293
|
-
source: this,
|
|
8294
|
-
offset,
|
|
8295
|
-
length,
|
|
8296
|
-
signal: options?.signal
|
|
8297
|
-
});
|
|
8298
|
-
function runMiddleware(middleware, next) {
|
|
8299
|
-
return (req) => middleware.fetch(req, next);
|
|
8300
|
-
}
|
|
8301
|
-
for (let i = middleware.length - 1; i >= 0; i--) handler = runMiddleware(middleware[i], handler);
|
|
8302
|
-
return handler({
|
|
8303
|
-
source: this,
|
|
8304
|
-
offset,
|
|
8305
|
-
length,
|
|
8306
|
-
signal: options?.signal
|
|
8307
|
-
});
|
|
8308
|
-
}
|
|
8874
|
+
//#region node_modules/proj4/lib/constants/units.js
|
|
8875
|
+
var units_default = {
|
|
8876
|
+
mm: { to_meter: .001 },
|
|
8877
|
+
cm: { to_meter: .01 },
|
|
8878
|
+
ft: { to_meter: .3048 },
|
|
8879
|
+
"us-ft": { to_meter: 1200 / 3937 },
|
|
8880
|
+
fath: { to_meter: 1.8288 },
|
|
8881
|
+
kmi: { to_meter: 1852 },
|
|
8882
|
+
"us-ch": { to_meter: 20.1168402336805 },
|
|
8883
|
+
"us-mi": { to_meter: 1609.34721869444 },
|
|
8884
|
+
km: { to_meter: 1e3 },
|
|
8885
|
+
"ind-ft": { to_meter: .30479841 },
|
|
8886
|
+
"ind-yd": { to_meter: .91439523 },
|
|
8887
|
+
mi: { to_meter: 1609.344 },
|
|
8888
|
+
yd: { to_meter: .9144 },
|
|
8889
|
+
ch: { to_meter: 20.1168 },
|
|
8890
|
+
link: { to_meter: .201168 },
|
|
8891
|
+
dm: { to_meter: .1 },
|
|
8892
|
+
in: { to_meter: .0254 },
|
|
8893
|
+
"ind-ch": { to_meter: 20.11669506 },
|
|
8894
|
+
"us-in": { to_meter: .025400050800101 },
|
|
8895
|
+
"us-yd": { to_meter: .914401828803658 }
|
|
8309
8896
|
};
|
|
8310
8897
|
//#endregion
|
|
8311
|
-
//#region node_modules
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8898
|
+
//#region node_modules/proj4/lib/match.js
|
|
8899
|
+
var ignoredChar = /[\s_\-\/\(\)]/g;
|
|
8900
|
+
function match(obj, key) {
|
|
8901
|
+
if (obj[key]) return obj[key];
|
|
8902
|
+
var keys = Object.keys(obj);
|
|
8903
|
+
var lkey = key.toLowerCase().replace(ignoredChar, "");
|
|
8904
|
+
var i = -1;
|
|
8905
|
+
var testkey, processedKey;
|
|
8906
|
+
while (++i < keys.length) {
|
|
8907
|
+
testkey = keys[i];
|
|
8908
|
+
processedKey = testkey.toLowerCase().replace(ignoredChar, "");
|
|
8909
|
+
if (processedKey === lkey) return obj[testkey];
|
|
8317
8910
|
}
|
|
8318
8911
|
}
|
|
8319
8912
|
//#endregion
|
|
8320
|
-
//#region node_modules
|
|
8913
|
+
//#region node_modules/proj4/lib/projString.js
|
|
8321
8914
|
/**
|
|
8322
|
-
*
|
|
8323
|
-
*
|
|
8324
|
-
*
|
|
8325
|
-
* This can **GREATLY** increase cache hits when using a @see {SourceCache}
|
|
8326
|
-
*/
|
|
8327
|
-
var SourceChunk = class {
|
|
8328
|
-
name = "source:chunk";
|
|
8329
|
-
/** Number of bytes to chunk requests into */
|
|
8330
|
-
chunkSize;
|
|
8331
|
-
constructor(opts) {
|
|
8332
|
-
this.chunkSize = opts.size ?? 32 * 1024;
|
|
8333
|
-
}
|
|
8334
|
-
async fetch(req, next) {
|
|
8335
|
-
if (req.offset < 0) return next(req);
|
|
8336
|
-
if (req.length == null) return next(req);
|
|
8337
|
-
const startChunkId = Math.floor(req.offset / this.chunkSize);
|
|
8338
|
-
const endChunkId = Math.ceil((req.offset + req.length) / this.chunkSize);
|
|
8339
|
-
const maxSize = req.source.metadata?.size;
|
|
8340
|
-
if (maxSize != null && req.offset + req.length > maxSize) throw new SourceError(`Request outside of bounds ${ContentRange.toRange(req.offset, req.length)}`, 416, req.source);
|
|
8341
|
-
const startByte = startChunkId * this.chunkSize;
|
|
8342
|
-
const maxLength = (maxSize != null ? Math.min(endChunkId * this.chunkSize, maxSize) : endChunkId * this.chunkSize) - startByte;
|
|
8343
|
-
const chunkOffset = req.offset - startByte;
|
|
8344
|
-
if (endChunkId - startChunkId > 1) return (await this.fetchChunks(req, startChunkId, endChunkId)).slice(chunkOffset, chunkOffset + req.length);
|
|
8345
|
-
if (req.offset === startByte && req.length === maxLength) return next(req);
|
|
8346
|
-
return (await next({
|
|
8347
|
-
...req,
|
|
8348
|
-
offset: startByte,
|
|
8349
|
-
length: maxLength
|
|
8350
|
-
})).slice(chunkOffset, chunkOffset + req.length);
|
|
8351
|
-
}
|
|
8352
|
-
async fetchChunks(req, startId, endId) {
|
|
8353
|
-
const promises = [];
|
|
8354
|
-
const maxEndByte = req.source.metadata?.size ?? endId * this.chunkSize;
|
|
8355
|
-
for (let chunk = startId; chunk < endId; chunk++) {
|
|
8356
|
-
const startByte = chunk * this.chunkSize;
|
|
8357
|
-
const chunkLength = Math.min(startByte + this.chunkSize, maxEndByte) - startByte;
|
|
8358
|
-
promises.push(req.source.fetch(chunk * this.chunkSize, chunkLength, req.signal ? { signal: req.signal } : void 0));
|
|
8359
|
-
}
|
|
8360
|
-
const results = await Promise.all(promises);
|
|
8361
|
-
const outputBuffer = new Uint8Array(promises.length * this.chunkSize);
|
|
8362
|
-
for (let i = 0; i < results.length; i++) outputBuffer.set(new Uint8Array(results[i]), i * this.chunkSize);
|
|
8363
|
-
return outputBuffer.buffer;
|
|
8364
|
-
}
|
|
8365
|
-
};
|
|
8366
|
-
//#endregion
|
|
8367
|
-
//#region node_modules/@chunkd/source-http/build/src/index.js
|
|
8368
|
-
/** Load the ETag and content-range from the response */
|
|
8369
|
-
function getMetadataFromResponse(response) {
|
|
8370
|
-
const metadata = {};
|
|
8371
|
-
const contentLength = response.headers.get("content-length");
|
|
8372
|
-
if (contentLength) metadata.size = parseInt(contentLength);
|
|
8373
|
-
const contentRange = response.headers.get("content-range");
|
|
8374
|
-
if (contentRange != null) metadata.size = ContentRange.parseSize(contentRange);
|
|
8375
|
-
metadata.eTag = response.headers.get("etag") ?? void 0;
|
|
8376
|
-
metadata.contentType = response.headers.get("content-type") ?? void 0;
|
|
8377
|
-
metadata.contentDisposition = response.headers.get("content-disposition") ?? void 0;
|
|
8378
|
-
metadata.cacheControl = response.headers.get("cache-control") ?? void 0;
|
|
8379
|
-
metadata.contentEncoding = response.headers.get("content-encoding") ?? void 0;
|
|
8380
|
-
return metadata;
|
|
8381
|
-
}
|
|
8382
|
-
var SourceHttp = class SourceHttp {
|
|
8383
|
-
constructor(url, headers) {
|
|
8384
|
-
this.type = "http";
|
|
8385
|
-
this.url = typeof url === "string" ? SourceHttp.tryUrl(url) : url;
|
|
8386
|
-
this.headers = headers;
|
|
8387
|
-
}
|
|
8388
|
-
/** Attempt to parse a relative string into a URL */
|
|
8389
|
-
static tryUrl(s) {
|
|
8390
|
-
try {
|
|
8391
|
-
return new URL(s);
|
|
8392
|
-
} catch (_e) {
|
|
8393
|
-
if (typeof document !== "undefined") return new URL(s, document.baseURI);
|
|
8394
|
-
return new URL(s, import.meta.url);
|
|
8395
|
-
}
|
|
8396
|
-
}
|
|
8397
|
-
head() {
|
|
8398
|
-
if (this._head) return this._head;
|
|
8399
|
-
this._head = SourceHttp.fetch(this.url, {
|
|
8400
|
-
method: "HEAD",
|
|
8401
|
-
headers: this.headers
|
|
8402
|
-
}).then((res) => {
|
|
8403
|
-
if (!res.ok) {
|
|
8404
|
-
delete this._head;
|
|
8405
|
-
throw new Error(`Failed to HEAD ${this.url.href}`, { cause: {
|
|
8406
|
-
statusCode: res.status,
|
|
8407
|
-
msg: res.statusText
|
|
8408
|
-
} });
|
|
8409
|
-
}
|
|
8410
|
-
this.metadata = getMetadataFromResponse(res);
|
|
8411
|
-
return this.metadata;
|
|
8412
|
-
});
|
|
8413
|
-
return this._head;
|
|
8414
|
-
}
|
|
8415
|
-
async fetch(offset, length, options) {
|
|
8416
|
-
try {
|
|
8417
|
-
const headers = {
|
|
8418
|
-
range: ContentRange.toRange(offset, length),
|
|
8419
|
-
...this.headers
|
|
8420
|
-
};
|
|
8421
|
-
const response = await SourceHttp.fetch(this.url, {
|
|
8422
|
-
headers,
|
|
8423
|
-
signal: options?.signal
|
|
8424
|
-
});
|
|
8425
|
-
if (!response.ok) throw new SourceError(`Failed to fetch ${this.url.href} ${headers.range}`, response.status, this, new Error(response.statusText));
|
|
8426
|
-
const metadata = getMetadataFromResponse(response);
|
|
8427
|
-
if (this.metadata == null) this.metadata = metadata;
|
|
8428
|
-
else if (this.metadata.eTag && this.metadata.eTag !== metadata.eTag) throw new SourceError(`ETag conflict ${this.url.href} ${headers.range} expected: ${this.metadata.eTag} got: ${metadata.eTag}`, 409, this);
|
|
8429
|
-
return response.arrayBuffer();
|
|
8430
|
-
} catch (e) {
|
|
8431
|
-
if (SourceError.is(e) && e.source === this) throw e;
|
|
8432
|
-
throw new SourceError(`Failed to fetch: ${this.url.href}`, 500, this, e);
|
|
8433
|
-
}
|
|
8434
|
-
}
|
|
8435
|
-
};
|
|
8436
|
-
SourceHttp.fetch = (a, b) => fetch(a, b);
|
|
8437
|
-
//#endregion
|
|
8438
|
-
//#region node_modules/@chunkd/source-memory/build/src/index.js
|
|
8439
|
-
function parseMemoryUrl(s) {
|
|
8440
|
-
if (typeof s !== "string") return s;
|
|
8441
|
-
const url = tryParseUrl(s);
|
|
8442
|
-
if (url) return url;
|
|
8443
|
-
return new URL("memory://" + s);
|
|
8444
|
-
}
|
|
8445
|
-
var SourceMemory = class SourceMemory {
|
|
8446
|
-
url;
|
|
8447
|
-
type = "memory";
|
|
8448
|
-
data;
|
|
8449
|
-
metadata;
|
|
8450
|
-
static toArrayBuffer(buf) {
|
|
8451
|
-
if (buf instanceof ArrayBuffer) return buf;
|
|
8452
|
-
if (buf.byteLength === buf.buffer.byteLength) return buf.buffer;
|
|
8453
|
-
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
8454
|
-
}
|
|
8455
|
-
constructor(url, bytes) {
|
|
8456
|
-
const buf = SourceMemory.toArrayBuffer(bytes ?? new Uint8Array());
|
|
8457
|
-
this.url = parseMemoryUrl(url);
|
|
8458
|
-
this.data = buf;
|
|
8459
|
-
this.metadata = { size: buf.byteLength };
|
|
8460
|
-
}
|
|
8461
|
-
head() {
|
|
8462
|
-
return Promise.resolve({ size: this.data.byteLength });
|
|
8463
|
-
}
|
|
8464
|
-
fetch(offset, length) {
|
|
8465
|
-
if (offset < 0) offset = this.data.byteLength + offset;
|
|
8466
|
-
if (offset > this.data.byteLength) throw new SourceError(`Read offset outside of file bounds range:${ContentRange.toRange(offset, length)} fileSize:${this.data.byteLength}`, 416, this);
|
|
8467
|
-
return Promise.resolve(this.data.slice(offset, length == null ? void 0 : offset + length));
|
|
8468
|
-
}
|
|
8469
|
-
};
|
|
8470
|
-
//#endregion
|
|
8471
|
-
//#region node_modules/@developmentseed/geotiff/dist/crs.js
|
|
8472
|
-
var PROJJSON_SCHEMA = "https://proj.org/schemas/v0.7/projjson.schema.json";
|
|
8473
|
-
var MODEL_TYPE_PROJECTED$1 = 1;
|
|
8474
|
-
var MODEL_TYPE_GEOGRAPHIC$1 = 2;
|
|
8475
|
-
var USER_DEFINED$1 = 32767;
|
|
8476
|
-
var CT_TRANSVERSE_MERCATOR = 1;
|
|
8477
|
-
var CT_TRANSVERSE_MERCATOR_SOUTH = 2;
|
|
8478
|
-
var CT_OBLIQUE_MERCATOR = 3;
|
|
8479
|
-
var CT_OBLIQUE_MERCATOR_LABORDE = 4;
|
|
8480
|
-
var CT_OBLIQUE_MERCATOR_ROSENMUND = 5;
|
|
8481
|
-
var CT_OBLIQUE_MERCATOR_SPHERICAL = 6;
|
|
8482
|
-
var CT_MERCATOR = 7;
|
|
8483
|
-
var CT_LAMBERT_CONFORMAL_CONIC_2SP = 8;
|
|
8484
|
-
var CT_LAMBERT_CONFORMAL_CONIC_1SP = 9;
|
|
8485
|
-
var CT_LAMBERT_AZIMUTHAL_EQUAL_AREA = 10;
|
|
8486
|
-
var CT_ALBERS_EQUAL_AREA = 11;
|
|
8487
|
-
var CT_AZIMUTHAL_EQUIDISTANT = 12;
|
|
8488
|
-
var CT_STEREOGRAPHIC = 14;
|
|
8489
|
-
var CT_POLAR_STEREOGRAPHIC = 15;
|
|
8490
|
-
var CT_OBLIQUE_STEREOGRAPHIC = 16;
|
|
8491
|
-
var CT_EQUIRECTANGULAR = 17;
|
|
8492
|
-
var CT_CASSINI_SOLDNER = 18;
|
|
8493
|
-
var CT_ORTHOGRAPHIC = 21;
|
|
8494
|
-
var CT_POLYCONIC = 22;
|
|
8495
|
-
var CT_SINUSOIDAL = 24;
|
|
8496
|
-
var CT_NEW_ZEALAND_MAP_GRID = 26;
|
|
8497
|
-
var CT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED = 27;
|
|
8498
|
-
var ANGULAR_UNIT_DEGREE = 9102;
|
|
8499
|
-
var ANGULAR_UNIT_RADIAN = 9101;
|
|
8500
|
-
var ANGULAR_UNIT_GRAD = 9105;
|
|
8501
|
-
var ANGULAR_UNIT = {
|
|
8502
|
-
[ANGULAR_UNIT_DEGREE]: "degree",
|
|
8503
|
-
[ANGULAR_UNIT_RADIAN]: "radian",
|
|
8504
|
-
[ANGULAR_UNIT_GRAD]: "grad"
|
|
8505
|
-
};
|
|
8506
|
-
var LINEAR_UNIT_METRE = 9001;
|
|
8507
|
-
var LINEAR_UNIT_FOOT = 9002;
|
|
8508
|
-
var LINEAR_UNIT_US_SURVEY_FOOT = 9003;
|
|
8509
|
-
var US_SURVEY_FOOT = {
|
|
8510
|
-
type: "LinearUnit",
|
|
8511
|
-
name: "US survey foot",
|
|
8512
|
-
conversion_factor: .30480060960121924
|
|
8513
|
-
};
|
|
8514
|
-
var LINEAR_UNIT = {
|
|
8515
|
-
[LINEAR_UNIT_METRE]: "metre",
|
|
8516
|
-
[LINEAR_UNIT_FOOT]: "foot",
|
|
8517
|
-
[LINEAR_UNIT_US_SURVEY_FOOT]: US_SURVEY_FOOT
|
|
8518
|
-
};
|
|
8519
|
-
/**
|
|
8520
|
-
* Parse a CRS from a GeoKeyDirectory.
|
|
8521
|
-
*
|
|
8522
|
-
* Returns the EPSG code as a number for EPSG-coded CRSes (letting the caller
|
|
8523
|
-
* decide how to resolve it), or a PROJJSON object built from the geo keys for
|
|
8524
|
-
* user-defined CRSes.
|
|
8525
|
-
*/
|
|
8526
|
-
function crsFromGeoKeys(gkd) {
|
|
8527
|
-
const modelType = gkd.modelType;
|
|
8528
|
-
if (modelType === MODEL_TYPE_PROJECTED$1) return _projectedCrs(gkd);
|
|
8529
|
-
if (modelType === MODEL_TYPE_GEOGRAPHIC$1) return _geographicCrs(gkd);
|
|
8530
|
-
throw new Error(`Unsupported GeoTIFF model type: ${modelType}`);
|
|
8531
|
-
}
|
|
8532
|
-
function _geographicCrs(gkd) {
|
|
8533
|
-
const epsg = gkd.geodeticCRS;
|
|
8534
|
-
if (epsg !== null && epsg !== USER_DEFINED$1) return epsg;
|
|
8535
|
-
return _buildGeographicCrs(gkd, PROJJSON_SCHEMA);
|
|
8536
|
-
}
|
|
8537
|
-
function _projectedCrs(gkd) {
|
|
8538
|
-
const epsg = gkd.projectedCRS;
|
|
8539
|
-
if (epsg !== null && epsg !== USER_DEFINED$1) return epsg;
|
|
8540
|
-
return _buildProjectedCrs(gkd);
|
|
8541
|
-
}
|
|
8542
|
-
function _buildGeographicCrs(gkd, schema) {
|
|
8543
|
-
const ellipsoid = _buildEllipsoid(gkd);
|
|
8544
|
-
let pmName = "Greenwich";
|
|
8545
|
-
let pmLongitude = 0;
|
|
8546
|
-
if (gkd.primeMeridian !== null && gkd.primeMeridian !== USER_DEFINED$1) pmName = `EPSG:${gkd.primeMeridian}`;
|
|
8547
|
-
else if (gkd.primeMeridianLongitude !== null) {
|
|
8548
|
-
pmLongitude = gkd.primeMeridianLongitude;
|
|
8549
|
-
pmName = "User-defined";
|
|
8550
|
-
}
|
|
8551
|
-
let datum;
|
|
8552
|
-
if (gkd.geodeticDatum !== null && gkd.geodeticDatum !== USER_DEFINED$1) datum = {
|
|
8553
|
-
type: "GeodeticReferenceFrame",
|
|
8554
|
-
name: `Unknown datum based upon EPSG ${gkd.geodeticDatum} ellipsoid`
|
|
8555
|
-
};
|
|
8556
|
-
else datum = {
|
|
8557
|
-
type: "GeodeticReferenceFrame",
|
|
8558
|
-
name: gkd.geodeticCitation ?? "User-defined",
|
|
8559
|
-
ellipsoid,
|
|
8560
|
-
prime_meridian: {
|
|
8561
|
-
name: pmName,
|
|
8562
|
-
longitude: pmLongitude
|
|
8563
|
-
}
|
|
8564
|
-
};
|
|
8565
|
-
const crs = {
|
|
8566
|
-
type: "GeographicCRS",
|
|
8567
|
-
name: gkd.geodeticCitation ?? "User-defined",
|
|
8568
|
-
datum,
|
|
8569
|
-
coordinate_system: _geographicCs(gkd)
|
|
8570
|
-
};
|
|
8571
|
-
if (schema !== void 0) crs.$schema = schema;
|
|
8572
|
-
return crs;
|
|
8573
|
-
}
|
|
8574
|
-
function _buildProjectedCrs(gkd) {
|
|
8575
|
-
const baseCrs = _buildGeographicCrs(gkd);
|
|
8576
|
-
const conversion = _buildConversion(gkd);
|
|
8577
|
-
const cs = _projectedCs(gkd);
|
|
8578
|
-
return {
|
|
8579
|
-
type: "ProjectedCRS",
|
|
8580
|
-
$schema: PROJJSON_SCHEMA,
|
|
8581
|
-
name: gkd.projectedCitation ?? gkd.citation ?? "User-defined",
|
|
8582
|
-
base_crs: baseCrs,
|
|
8583
|
-
conversion,
|
|
8584
|
-
coordinate_system: cs
|
|
8585
|
-
};
|
|
8586
|
-
}
|
|
8587
|
-
function _buildEllipsoid(gkd) {
|
|
8588
|
-
if (gkd.ellipsoid !== null && gkd.ellipsoid !== USER_DEFINED$1) {
|
|
8589
|
-
const ellipsoid = { name: `EPSG ellipsoid ${gkd.ellipsoid}` };
|
|
8590
|
-
if (gkd.ellipsoidSemiMajorAxis !== null) ellipsoid.semi_major_axis = gkd.ellipsoidSemiMajorAxis;
|
|
8591
|
-
if (gkd.ellipsoidInvFlattening !== null) ellipsoid.inverse_flattening = gkd.ellipsoidInvFlattening;
|
|
8592
|
-
else if (gkd.ellipsoidSemiMinorAxis !== null) ellipsoid.semi_minor_axis = gkd.ellipsoidSemiMinorAxis;
|
|
8593
|
-
return ellipsoid;
|
|
8594
|
-
}
|
|
8595
|
-
if (gkd.ellipsoidSemiMajorAxis === null) throw new Error("User-defined ellipsoid requires ellipsoidSemiMajorAxis");
|
|
8596
|
-
const ellipsoid = {
|
|
8597
|
-
name: gkd.geodeticCitation ?? "User-defined",
|
|
8598
|
-
semi_major_axis: gkd.ellipsoidSemiMajorAxis
|
|
8599
|
-
};
|
|
8600
|
-
if (gkd.ellipsoidInvFlattening !== null) ellipsoid.inverse_flattening = gkd.ellipsoidInvFlattening;
|
|
8601
|
-
else if (gkd.ellipsoidSemiMinorAxis !== null) ellipsoid.semi_minor_axis = gkd.ellipsoidSemiMinorAxis;
|
|
8602
|
-
else throw new Error("User-defined ellipsoid requires ellipsoidInvFlattening or ellipsoidSemiMinorAxis");
|
|
8603
|
-
return ellipsoid;
|
|
8604
|
-
}
|
|
8605
|
-
function _buildConversion(gkd) {
|
|
8606
|
-
const ct = gkd.projMethod;
|
|
8607
|
-
if (ct === null) throw new Error("User-defined projected CRS requires projMethod");
|
|
8608
|
-
const angular = (name, value, default_ = 0) => ({
|
|
8609
|
-
name,
|
|
8610
|
-
value: value ?? default_,
|
|
8611
|
-
unit: "degree"
|
|
8612
|
-
});
|
|
8613
|
-
const linear = (name, value, default_ = 0) => ({
|
|
8614
|
-
name,
|
|
8615
|
-
value: value ?? default_,
|
|
8616
|
-
unit: "metre"
|
|
8617
|
-
});
|
|
8618
|
-
const scale = (name, value, default_ = 1) => ({
|
|
8619
|
-
name,
|
|
8620
|
-
value: value ?? default_,
|
|
8621
|
-
unit: "unity"
|
|
8622
|
-
});
|
|
8623
|
-
switch (ct) {
|
|
8624
|
-
case CT_TRANSVERSE_MERCATOR:
|
|
8625
|
-
case CT_TRANSVERSE_MERCATOR_SOUTH:
|
|
8626
|
-
case CT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED: {
|
|
8627
|
-
const name = ct === CT_TRANSVERSE_MERCATOR ? "Transverse Mercator" : "Transverse Mercator (South Orientated)";
|
|
8628
|
-
return {
|
|
8629
|
-
name,
|
|
8630
|
-
method: { name },
|
|
8631
|
-
parameters: [
|
|
8632
|
-
angular("Latitude of natural origin", gkd.projNatOriginLat),
|
|
8633
|
-
angular("Longitude of natural origin", gkd.projNatOriginLong),
|
|
8634
|
-
scale("Scale factor at natural origin", gkd.projScaleAtNatOrigin),
|
|
8635
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8636
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8637
|
-
]
|
|
8638
|
-
};
|
|
8639
|
-
}
|
|
8640
|
-
case CT_OBLIQUE_MERCATOR:
|
|
8641
|
-
case CT_OBLIQUE_MERCATOR_LABORDE:
|
|
8642
|
-
case CT_OBLIQUE_MERCATOR_ROSENMUND:
|
|
8643
|
-
case CT_OBLIQUE_MERCATOR_SPHERICAL: {
|
|
8644
|
-
const name = "Hotine Oblique Mercator (variant B)";
|
|
8645
|
-
return {
|
|
8646
|
-
name,
|
|
8647
|
-
method: { name },
|
|
8648
|
-
parameters: [
|
|
8649
|
-
angular("Latitude of projection centre", gkd.projCenterLat),
|
|
8650
|
-
angular("Longitude of projection centre", gkd.projCenterLong),
|
|
8651
|
-
angular("Azimuth of initial line", gkd.projAzimuthAngle),
|
|
8652
|
-
angular("Angle from Rectified to Skew Grid", gkd.projAzimuthAngle),
|
|
8653
|
-
scale("Scale factor on initial line", gkd.projScaleAtCenter),
|
|
8654
|
-
linear("Easting at projection centre", gkd.projCenterEasting),
|
|
8655
|
-
linear("Northing at projection centre", gkd.projCenterNorthing)
|
|
8656
|
-
]
|
|
8657
|
-
};
|
|
8658
|
-
}
|
|
8659
|
-
case CT_MERCATOR: {
|
|
8660
|
-
const name = "Mercator (variant A)";
|
|
8661
|
-
return {
|
|
8662
|
-
name,
|
|
8663
|
-
method: { name },
|
|
8664
|
-
parameters: [
|
|
8665
|
-
angular("Latitude of natural origin", gkd.projNatOriginLat),
|
|
8666
|
-
angular("Longitude of natural origin", gkd.projNatOriginLong),
|
|
8667
|
-
scale("Scale factor at natural origin", gkd.projScaleAtNatOrigin),
|
|
8668
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8669
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8670
|
-
]
|
|
8671
|
-
};
|
|
8672
|
-
}
|
|
8673
|
-
case CT_LAMBERT_CONFORMAL_CONIC_2SP: {
|
|
8674
|
-
const name = "Lambert Conic Conformal (2SP)";
|
|
8675
|
-
return {
|
|
8676
|
-
name,
|
|
8677
|
-
method: { name },
|
|
8678
|
-
parameters: [
|
|
8679
|
-
angular("Latitude of false origin", gkd.projFalseOriginLat ?? gkd.projNatOriginLat),
|
|
8680
|
-
angular("Longitude of false origin", gkd.projFalseOriginLong ?? gkd.projNatOriginLong),
|
|
8681
|
-
angular("Latitude of 1st standard parallel", gkd.projStdParallel1),
|
|
8682
|
-
angular("Latitude of 2nd standard parallel", gkd.projStdParallel2),
|
|
8683
|
-
linear("Easting at false origin", gkd.projFalseOriginEasting ?? gkd.projFalseEasting),
|
|
8684
|
-
linear("Northing at false origin", gkd.projFalseOriginNorthing ?? gkd.projFalseNorthing)
|
|
8685
|
-
]
|
|
8686
|
-
};
|
|
8687
|
-
}
|
|
8688
|
-
case CT_LAMBERT_CONFORMAL_CONIC_1SP: {
|
|
8689
|
-
const name = "Lambert Conic Conformal (1SP)";
|
|
8690
|
-
return {
|
|
8691
|
-
name,
|
|
8692
|
-
method: { name },
|
|
8693
|
-
parameters: [
|
|
8694
|
-
angular("Latitude of natural origin", gkd.projNatOriginLat),
|
|
8695
|
-
angular("Longitude of natural origin", gkd.projNatOriginLong),
|
|
8696
|
-
scale("Scale factor at natural origin", gkd.projScaleAtNatOrigin),
|
|
8697
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8698
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8699
|
-
]
|
|
8700
|
-
};
|
|
8701
|
-
}
|
|
8702
|
-
case CT_LAMBERT_AZIMUTHAL_EQUAL_AREA: {
|
|
8703
|
-
const name = "Lambert Azimuthal Equal Area";
|
|
8704
|
-
return {
|
|
8705
|
-
name,
|
|
8706
|
-
method: { name },
|
|
8707
|
-
parameters: [
|
|
8708
|
-
angular("Latitude of natural origin", gkd.projCenterLat),
|
|
8709
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8710
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8711
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8712
|
-
]
|
|
8713
|
-
};
|
|
8714
|
-
}
|
|
8715
|
-
case CT_ALBERS_EQUAL_AREA: {
|
|
8716
|
-
const name = "Albers Equal Area";
|
|
8717
|
-
return {
|
|
8718
|
-
name,
|
|
8719
|
-
method: { name },
|
|
8720
|
-
parameters: [
|
|
8721
|
-
angular("Latitude of false origin", gkd.projFalseOriginLat ?? gkd.projNatOriginLat),
|
|
8722
|
-
angular("Longitude of false origin", gkd.projFalseOriginLong ?? gkd.projNatOriginLong),
|
|
8723
|
-
angular("Latitude of 1st standard parallel", gkd.projStdParallel1),
|
|
8724
|
-
angular("Latitude of 2nd standard parallel", gkd.projStdParallel2),
|
|
8725
|
-
linear("Easting at false origin", gkd.projFalseOriginEasting ?? gkd.projFalseEasting),
|
|
8726
|
-
linear("Northing at false origin", gkd.projFalseOriginNorthing ?? gkd.projFalseNorthing)
|
|
8727
|
-
]
|
|
8728
|
-
};
|
|
8729
|
-
}
|
|
8730
|
-
case CT_AZIMUTHAL_EQUIDISTANT: {
|
|
8731
|
-
const name = "Modified Azimuthal Equidistant";
|
|
8732
|
-
return {
|
|
8733
|
-
name,
|
|
8734
|
-
method: { name },
|
|
8735
|
-
parameters: [
|
|
8736
|
-
angular("Latitude of natural origin", gkd.projCenterLat),
|
|
8737
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8738
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8739
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8740
|
-
]
|
|
8741
|
-
};
|
|
8742
|
-
}
|
|
8743
|
-
case CT_STEREOGRAPHIC: {
|
|
8744
|
-
const name = "Stereographic";
|
|
8745
|
-
return {
|
|
8746
|
-
name,
|
|
8747
|
-
method: { name },
|
|
8748
|
-
parameters: [
|
|
8749
|
-
angular("Latitude of natural origin", gkd.projCenterLat),
|
|
8750
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8751
|
-
scale("Scale factor at natural origin", gkd.projScaleAtCenter),
|
|
8752
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8753
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8754
|
-
]
|
|
8755
|
-
};
|
|
8756
|
-
}
|
|
8757
|
-
case CT_POLAR_STEREOGRAPHIC: {
|
|
8758
|
-
const name = "Polar Stereographic (variant B)";
|
|
8759
|
-
return {
|
|
8760
|
-
name,
|
|
8761
|
-
method: { name },
|
|
8762
|
-
parameters: [
|
|
8763
|
-
angular("Latitude of standard parallel", gkd.projNatOriginLat ?? gkd.projStdParallel1),
|
|
8764
|
-
angular("Longitude of origin", gkd.projStraightVertPoleLong ?? gkd.projNatOriginLong),
|
|
8765
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8766
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8767
|
-
]
|
|
8768
|
-
};
|
|
8769
|
-
}
|
|
8770
|
-
case CT_OBLIQUE_STEREOGRAPHIC: {
|
|
8771
|
-
const name = "Oblique Stereographic";
|
|
8772
|
-
return {
|
|
8773
|
-
name,
|
|
8774
|
-
method: { name },
|
|
8775
|
-
parameters: [
|
|
8776
|
-
angular("Latitude of natural origin", gkd.projCenterLat),
|
|
8777
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8778
|
-
scale("Scale factor at natural origin", gkd.projScaleAtCenter),
|
|
8779
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8780
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8781
|
-
]
|
|
8782
|
-
};
|
|
8783
|
-
}
|
|
8784
|
-
case CT_EQUIRECTANGULAR: {
|
|
8785
|
-
const name = "Equidistant Cylindrical";
|
|
8786
|
-
return {
|
|
8787
|
-
name,
|
|
8788
|
-
method: { name },
|
|
8789
|
-
parameters: [
|
|
8790
|
-
angular("Latitude of 1st standard parallel", gkd.projStdParallel1 ?? gkd.projCenterLat),
|
|
8791
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8792
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8793
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8794
|
-
]
|
|
8795
|
-
};
|
|
8796
|
-
}
|
|
8797
|
-
case CT_CASSINI_SOLDNER: {
|
|
8798
|
-
const name = "Cassini-Soldner";
|
|
8799
|
-
return {
|
|
8800
|
-
name,
|
|
8801
|
-
method: { name },
|
|
8802
|
-
parameters: [
|
|
8803
|
-
angular("Latitude of natural origin", gkd.projNatOriginLat),
|
|
8804
|
-
angular("Longitude of natural origin", gkd.projNatOriginLong),
|
|
8805
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8806
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8807
|
-
]
|
|
8808
|
-
};
|
|
8809
|
-
}
|
|
8810
|
-
case CT_POLYCONIC: {
|
|
8811
|
-
const name = "American Polyconic";
|
|
8812
|
-
return {
|
|
8813
|
-
name,
|
|
8814
|
-
method: { name },
|
|
8815
|
-
parameters: [
|
|
8816
|
-
angular("Latitude of natural origin", gkd.projNatOriginLat),
|
|
8817
|
-
angular("Longitude of natural origin", gkd.projNatOriginLong),
|
|
8818
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8819
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8820
|
-
]
|
|
8821
|
-
};
|
|
8822
|
-
}
|
|
8823
|
-
case CT_SINUSOIDAL: {
|
|
8824
|
-
const name = "Sinusoidal";
|
|
8825
|
-
return {
|
|
8826
|
-
name,
|
|
8827
|
-
method: { name },
|
|
8828
|
-
parameters: [
|
|
8829
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8830
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8831
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8832
|
-
]
|
|
8833
|
-
};
|
|
8834
|
-
}
|
|
8835
|
-
case CT_ORTHOGRAPHIC: {
|
|
8836
|
-
const name = "Orthographic";
|
|
8837
|
-
return {
|
|
8838
|
-
name,
|
|
8839
|
-
method: { name },
|
|
8840
|
-
parameters: [
|
|
8841
|
-
angular("Latitude of natural origin", gkd.projCenterLat),
|
|
8842
|
-
angular("Longitude of natural origin", gkd.projCenterLong),
|
|
8843
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8844
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8845
|
-
]
|
|
8846
|
-
};
|
|
8847
|
-
}
|
|
8848
|
-
case CT_NEW_ZEALAND_MAP_GRID: {
|
|
8849
|
-
const name = "New Zealand Map Grid";
|
|
8850
|
-
return {
|
|
8851
|
-
name,
|
|
8852
|
-
method: { name },
|
|
8853
|
-
parameters: [
|
|
8854
|
-
angular("Latitude of natural origin", gkd.projNatOriginLat),
|
|
8855
|
-
angular("Longitude of natural origin", gkd.projNatOriginLong),
|
|
8856
|
-
linear("False easting", gkd.projFalseEasting),
|
|
8857
|
-
linear("False northing", gkd.projFalseNorthing)
|
|
8858
|
-
]
|
|
8859
|
-
};
|
|
8860
|
-
}
|
|
8861
|
-
default: throw new Error(`Unsupported coordinate transformation type: ${ct}`);
|
|
8862
|
-
}
|
|
8863
|
-
}
|
|
8864
|
-
function _geographicCs(gkd) {
|
|
8865
|
-
const unit = ANGULAR_UNIT[gkd.angularUnits ?? ANGULAR_UNIT_DEGREE] ?? "degree";
|
|
8866
|
-
return {
|
|
8867
|
-
subtype: "ellipsoidal",
|
|
8868
|
-
axis: [{
|
|
8869
|
-
name: "Geodetic latitude",
|
|
8870
|
-
abbreviation: "Lat",
|
|
8871
|
-
direction: "north",
|
|
8872
|
-
unit
|
|
8873
|
-
}, {
|
|
8874
|
-
name: "Geodetic longitude",
|
|
8875
|
-
abbreviation: "Lon",
|
|
8876
|
-
direction: "east",
|
|
8877
|
-
unit
|
|
8878
|
-
}]
|
|
8879
|
-
};
|
|
8880
|
-
}
|
|
8881
|
-
function _projectedCs(gkd) {
|
|
8882
|
-
const unit = LINEAR_UNIT[gkd.projLinearUnits ?? LINEAR_UNIT_METRE] ?? "metre";
|
|
8883
|
-
return {
|
|
8884
|
-
subtype: "Cartesian",
|
|
8885
|
-
axis: [{
|
|
8886
|
-
name: "Easting",
|
|
8887
|
-
abbreviation: "E",
|
|
8888
|
-
direction: "east",
|
|
8889
|
-
unit
|
|
8890
|
-
}, {
|
|
8891
|
-
name: "Northing",
|
|
8892
|
-
abbreviation: "N",
|
|
8893
|
-
direction: "north",
|
|
8894
|
-
unit
|
|
8895
|
-
}]
|
|
8896
|
-
};
|
|
8897
|
-
}
|
|
8898
|
-
/**
|
|
8899
|
-
* Fetch the given byte ranges from a source, coalescing nearby ranges into a
|
|
8900
|
-
* smaller number of underlying `source.fetch` calls. Returns one `ArrayBuffer`
|
|
8901
|
-
* per input range, in input order.
|
|
8902
|
-
*
|
|
8903
|
-
* Vendored from cogeotiff PR #1463 (`packages/core/src/source.coalesce.ts`),
|
|
8904
|
-
* reformatted to this repo's conventions. Kept here (rather than relying on the
|
|
8905
|
-
* upstream `Source.fetchRanges` hook) because `@developmentseed/geotiff` routes
|
|
8906
|
-
* tile-data reads through an uncached `dataSource` typed as `Pick<Source, "fetch">`.
|
|
8907
|
-
*/
|
|
8908
|
-
async function coalesceRanges(source, ranges, options) {
|
|
8909
|
-
if (ranges.length === 0) return [];
|
|
8910
|
-
const coalesce = options?.coalesce ?? 1048576;
|
|
8911
|
-
const maxRangeSize = options?.maxRangeSize ?? 16777216;
|
|
8912
|
-
const signal = options?.signal;
|
|
8913
|
-
const merged = mergeRanges(ranges, coalesce, maxRangeSize);
|
|
8914
|
-
const fetched = await dispatchMerged(source, merged, signal);
|
|
8915
|
-
const result = new Array(ranges.length);
|
|
8916
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
8917
|
-
const range = ranges[i];
|
|
8918
|
-
const groupIndex = findGroupIndex(merged, range.offset);
|
|
8919
|
-
const group = merged[groupIndex];
|
|
8920
|
-
const groupBytes = fetched[groupIndex];
|
|
8921
|
-
const start = range.offset - group.offset;
|
|
8922
|
-
const end = start + range.length;
|
|
8923
|
-
if (end > groupBytes.byteLength) throw new Error(`Failed to fetch bytes from offset:${range.offset} wanted:${range.length} got:${groupBytes.byteLength - start}`);
|
|
8924
|
-
result[i] = groupBytes.slice(start, end);
|
|
8925
|
-
}
|
|
8926
|
-
return result;
|
|
8927
|
-
}
|
|
8928
|
-
/**
|
|
8929
|
-
* Sort ranges by offset and merge consecutive ones whose gap is `<= coalesce`
|
|
8930
|
-
* and whose merged size stays `<= maxRangeSize`.
|
|
8931
|
-
*/
|
|
8932
|
-
function mergeRanges(ranges, coalesce, maxRangeSize) {
|
|
8933
|
-
const sorted = [...ranges].sort((a, b) => a.offset - b.offset);
|
|
8934
|
-
const out = [];
|
|
8935
|
-
let current = null;
|
|
8936
|
-
for (const r of sorted) {
|
|
8937
|
-
if (current == null) {
|
|
8938
|
-
current = {
|
|
8939
|
-
offset: r.offset,
|
|
8940
|
-
length: r.length
|
|
8941
|
-
};
|
|
8942
|
-
continue;
|
|
8943
|
-
}
|
|
8944
|
-
const currentEnd = current.offset + current.length;
|
|
8945
|
-
const nextEnd = r.offset + r.length;
|
|
8946
|
-
const gap = r.offset - currentEnd;
|
|
8947
|
-
const mergedEnd = Math.max(currentEnd, nextEnd);
|
|
8948
|
-
const mergedSize = mergedEnd - current.offset;
|
|
8949
|
-
if (gap <= coalesce && mergedSize <= maxRangeSize) current.length = mergedEnd - current.offset;
|
|
8950
|
-
else {
|
|
8951
|
-
out.push(current);
|
|
8952
|
-
current = {
|
|
8953
|
-
offset: r.offset,
|
|
8954
|
-
length: r.length
|
|
8955
|
-
};
|
|
8956
|
-
}
|
|
8957
|
-
}
|
|
8958
|
-
if (current != null) out.push(current);
|
|
8959
|
-
return out;
|
|
8960
|
-
}
|
|
8961
|
-
/** Binary search for the merged group whose offset is the largest `<= target`. */
|
|
8962
|
-
function findGroupIndex(merged, target) {
|
|
8963
|
-
let lo = 0;
|
|
8964
|
-
let hi = merged.length - 1;
|
|
8965
|
-
while (lo < hi) {
|
|
8966
|
-
const mid = lo + hi + 1 >>> 1;
|
|
8967
|
-
if (merged[mid].offset <= target) lo = mid;
|
|
8968
|
-
else hi = mid - 1;
|
|
8969
|
-
}
|
|
8970
|
-
return lo;
|
|
8971
|
-
}
|
|
8972
|
-
/** Fetch every merged range, at most {@link COALESCE_PARALLEL} requests in flight. */
|
|
8973
|
-
async function dispatchMerged(source, merged, signal) {
|
|
8974
|
-
const out = new Array(merged.length);
|
|
8975
|
-
for (let i = 0; i < merged.length; i += 6) {
|
|
8976
|
-
const batch = merged.slice(i, i + 6);
|
|
8977
|
-
const results = await Promise.all(batch.map((g) => source.fetch(g.offset, g.length, { signal })));
|
|
8978
|
-
for (let j = 0; j < results.length; j++) out[i + j] = results[j];
|
|
8979
|
-
}
|
|
8980
|
-
return out;
|
|
8981
|
-
}
|
|
8982
|
-
//#endregion
|
|
8983
|
-
//#region node_modules/@developmentseed/geotiff/dist/fetch.js
|
|
8984
|
-
async function fetchTile(self, x, y, { boundless = true, pool, signal } = {}) {
|
|
8985
|
-
const tileFetch = fetchCogBytes(self, x, y, { signal });
|
|
8986
|
-
const maskFetch = self.maskImage != null ? getTile(self.maskImage, x, y, self.dataSource, {
|
|
8987
|
-
signal,
|
|
8988
|
-
debug: self._debug ? { label: "mask" } : void 0
|
|
8989
|
-
}) : Promise.resolve(null);
|
|
8990
|
-
const [tileBytes, maskBytes] = await Promise.all([tileFetch, maskFetch]);
|
|
8991
|
-
return assembleTile(self, x, y, tileBytes, maskBytes, {
|
|
8992
|
-
boundless,
|
|
8993
|
-
pool
|
|
8994
|
-
});
|
|
8995
|
-
}
|
|
8996
|
-
/**
|
|
8997
|
-
* Decode already-fetched compressed tile (and optional mask) bytes into a
|
|
8998
|
-
* {@link Tile}. Performs no I/O — the bytes are supplied by the caller. Shared
|
|
8999
|
-
* by {@link fetchTile} (single-tile fetch) and {@link fetchTiles} (batched
|
|
9000
|
-
* fetch with range coalescing).
|
|
9001
|
-
*/
|
|
9002
|
-
async function assembleTile(self, x, y, tileBytes, maskBytes, { boundless, pool }) {
|
|
9003
|
-
const { bitsPerSample: bitsPerSamples, predictor, planarConfiguration, sampleFormat: sampleFormats, lercParameters } = self.cachedTags;
|
|
9004
|
-
const { sampleFormat, bitsPerSample } = getUniqueSampleFormat(sampleFormats, bitsPerSamples);
|
|
9005
|
-
const tileTransform = compose(self.transform, translation(x * self.tileWidth, y * self.tileHeight));
|
|
9006
|
-
const samplesPerPixel = self.image.value(TiffTag.SamplesPerPixel) ?? 1;
|
|
9007
|
-
const decoderMetadata = {
|
|
9008
|
-
sampleFormat,
|
|
9009
|
-
bitsPerSample,
|
|
9010
|
-
samplesPerPixel,
|
|
9011
|
-
width: self.tileWidth,
|
|
9012
|
-
height: self.tileHeight,
|
|
9013
|
-
predictor,
|
|
9014
|
-
planarConfiguration,
|
|
9015
|
-
lercParameters
|
|
9016
|
-
};
|
|
9017
|
-
const [decodedPixels, mask] = await Promise.all([decodeTile(tileBytes, decoderMetadata, pool), maskBytes != null && self.maskImage != null ? decodeMask(maskBytes, self.maskImage, pool) : Promise.resolve(null)]);
|
|
9018
|
-
const array = {
|
|
9019
|
-
...decodedPixels,
|
|
9020
|
-
count: samplesPerPixel,
|
|
9021
|
-
height: self.tileHeight,
|
|
9022
|
-
width: self.tileWidth,
|
|
9023
|
-
mask,
|
|
9024
|
-
transform: tileTransform,
|
|
9025
|
-
crs: self.crs,
|
|
9026
|
-
nodata: self.nodata
|
|
9027
|
-
};
|
|
9028
|
-
return {
|
|
9029
|
-
x,
|
|
9030
|
-
y,
|
|
9031
|
-
array: boundless === true ? array : clipToImageBounds(self, x, y, array)
|
|
9032
|
-
};
|
|
9033
|
-
}
|
|
9034
|
-
/**
|
|
9035
|
-
* Fetch multiple tiles from a GeoTIFF or Overview, batching the underlying
|
|
9036
|
-
* reads.
|
|
9037
|
-
*
|
|
9038
|
-
* Unlike repeated {@link fetchTile} calls, this resolves every requested
|
|
9039
|
-
* tile's byte range up front and fetches the data through {@link getTiles} /
|
|
9040
|
-
* {@link getMultipleBytes}, which coalesce nearby ranges into far fewer HTTP
|
|
9041
|
-
* range requests — a big win when the coordinates form a contiguous block, as
|
|
9042
|
-
* they do when assembling a coarse tile from finer covering tiles. Decoding is
|
|
9043
|
-
* still done per tile (via the shared {@link assembleTile}); only the I/O is
|
|
9044
|
-
* batched.
|
|
9045
|
-
*
|
|
9046
|
-
* @param self - The GeoTIFF or Overview to fetch tiles from.
|
|
9047
|
-
* @param xy - Array of `[x, y]` tile coordinates.
|
|
9048
|
-
* @param options - Optional parameters (same as {@link fetchTile}).
|
|
9049
|
-
* @returns Array of {@link Tile} objects in the same order as `xy`.
|
|
9050
|
-
*
|
|
9051
|
-
* @see {@link fetchTile} for single-tile fetching.
|
|
9052
|
-
* @see {@link getTiles} for the batched, range-coalescing byte reader.
|
|
9053
|
-
*/
|
|
9054
|
-
async function fetchTiles(self, xy, { boundless = true, pool, signal } = {}) {
|
|
9055
|
-
if (xy.length === 0) return [];
|
|
9056
|
-
const dataFetch = fetchCogBytesMultiple(self, xy, { signal });
|
|
9057
|
-
const maskFetch = self.maskImage != null ? getTiles(self.maskImage, xy, self.dataSource, {
|
|
9058
|
-
signal,
|
|
9059
|
-
debug: self._debug ? { label: "mask" } : void 0
|
|
9060
|
-
}) : Promise.resolve(xy.map(() => null));
|
|
9061
|
-
const [allTileBytes, allMaskBytes] = await Promise.all([dataFetch, maskFetch]);
|
|
9062
|
-
return Promise.all(xy.map(([x, y], i) => assembleTile(self, x, y, allTileBytes[i], allMaskBytes[i] ?? null, {
|
|
9063
|
-
boundless,
|
|
9064
|
-
pool
|
|
9065
|
-
})));
|
|
9066
|
-
}
|
|
9067
|
-
async function decodeMask(mask, maskImage, pool) {
|
|
9068
|
-
const maskSampleFormats = maskImage.value(TiffTag.SampleFormat) ?? [1];
|
|
9069
|
-
const maskBitsPerSample = maskImage.value(TiffTag.BitsPerSample) ?? [8];
|
|
9070
|
-
const { sampleFormat, bitsPerSample } = getUniqueSampleFormat(maskSampleFormats, new Uint16Array(maskBitsPerSample));
|
|
9071
|
-
const { width, height } = maskImage.tileSize;
|
|
9072
|
-
const metadata = {
|
|
9073
|
-
sampleFormat,
|
|
9074
|
-
bitsPerSample,
|
|
9075
|
-
samplesPerPixel: maskImage.value(TiffTag.SamplesPerPixel) ?? 1,
|
|
9076
|
-
width,
|
|
9077
|
-
height,
|
|
9078
|
-
predictor: maskImage.value(TiffTag.Predictor) ?? 1,
|
|
9079
|
-
planarConfiguration: maskImage.value(TiffTag.PlanarConfiguration) ?? PlanarConfiguration.Contig
|
|
9080
|
-
};
|
|
9081
|
-
const decoderFn = (bytes, compression, meta) => pool ? pool.decode(bytes, compression, meta) : decode$1(bytes, compression, meta);
|
|
9082
|
-
const { bytes, compression } = mask;
|
|
9083
|
-
const decoded = await decoderFn(bytes, compression, metadata);
|
|
9084
|
-
const data = decoded.layout === "pixel-interleaved" ? decoded.data : decoded.bands[0];
|
|
9085
|
-
if (data instanceof Uint8Array) return data;
|
|
9086
|
-
throw new Error("Expected mask data to decode to Uint8Array");
|
|
9087
|
-
}
|
|
9088
|
-
async function decodeTile(tile, metadata, pool) {
|
|
9089
|
-
const decoderFn = (bytes, compression, meta) => pool ? pool.decode(bytes, compression, meta) : decode$1(bytes, compression, meta);
|
|
9090
|
-
if (Array.isArray(tile)) {
|
|
9091
|
-
const bandMetadata = {
|
|
9092
|
-
...metadata,
|
|
9093
|
-
samplesPerPixel: 1
|
|
9094
|
-
};
|
|
9095
|
-
return {
|
|
9096
|
-
layout: "band-separate",
|
|
9097
|
-
bands: (await Promise.all(tile.map(({ bytes, compression }) => decoderFn(bytes, compression, bandMetadata)))).map((result) => result.layout === "band-separate" ? result.bands[0] : result.data)
|
|
9098
|
-
};
|
|
9099
|
-
} else {
|
|
9100
|
-
const { bytes, compression } = tile;
|
|
9101
|
-
return decoderFn(bytes, compression, metadata);
|
|
9102
|
-
}
|
|
9103
|
-
}
|
|
9104
|
-
/** Fetch bytes from a COG, handling whether pixel/band interleaving. */
|
|
9105
|
-
async function fetchCogBytes(self, x, y, { signal } = {}) {
|
|
9106
|
-
const debug = self._debug ? { label: "data" } : void 0;
|
|
9107
|
-
switch (self.cachedTags.planarConfiguration) {
|
|
9108
|
-
case PlanarConfiguration.Contig: {
|
|
9109
|
-
const tile = await getTile(self.image, x, y, self.dataSource, {
|
|
9110
|
-
signal,
|
|
9111
|
-
debug
|
|
9112
|
-
});
|
|
9113
|
-
if (tile === null) throw new Error(`Tile at (${x}, ${y}) not found`);
|
|
9114
|
-
return tile;
|
|
9115
|
-
}
|
|
9116
|
-
case PlanarConfiguration.Separate: return await fetchBandSeparateTileBytes(self, x, y, { signal });
|
|
9117
|
-
default: throw new Error(`Unsupported PlanarConfiguration: ${self.cachedTags.planarConfiguration}`);
|
|
9118
|
-
}
|
|
9119
|
-
}
|
|
9120
|
-
async function findBandSeparateTileByteRanges(self, x, y) {
|
|
9121
|
-
const { x: tilesPerRow, y: tilesPerColumn } = self.image.tileCount;
|
|
9122
|
-
const tilesPerBand = tilesPerRow * tilesPerColumn;
|
|
9123
|
-
const numBands = self.cachedTags.samplesPerPixel;
|
|
9124
|
-
const tileSizes = [...Array(numBands).keys()].map((band) => {
|
|
9125
|
-
const bandIdx = band * tilesPerBand + y * tilesPerRow + x;
|
|
9126
|
-
return self.image.getTileSize(bandIdx);
|
|
9127
|
-
});
|
|
9128
|
-
return Promise.all(tileSizes);
|
|
9129
|
-
}
|
|
9130
|
-
async function fetchBandSeparateTileBytes(self, x, y, { signal } = {}) {
|
|
9131
|
-
const debug = self._debug ? { label: "data" } : void 0;
|
|
9132
|
-
const buffers = (await findBandSeparateTileByteRanges(self, x, y)).map(async ({ offset, imageSize }) => {
|
|
9133
|
-
const tile = await getBytes(self.image, offset, imageSize, self.dataSource, {
|
|
9134
|
-
signal,
|
|
9135
|
-
debug
|
|
9136
|
-
});
|
|
9137
|
-
if (tile === null) throw new Error(`Tile at (${x}, ${y}) not found`);
|
|
9138
|
-
return tile;
|
|
9139
|
-
});
|
|
9140
|
-
return Promise.all(buffers);
|
|
9141
|
-
}
|
|
9142
|
-
/**
|
|
9143
|
-
* Batched, range-coalescing counterpart to {@link fetchCogBytes}: fetch the
|
|
9144
|
-
* compressed bytes for many tiles in as few HTTP range requests as possible.
|
|
9145
|
-
* Returns one entry per input coordinate, in input order. Throws (matching
|
|
9146
|
-
* {@link fetchCogBytes}) if a requested tile is sparse / not present.
|
|
9147
|
-
*/
|
|
9148
|
-
async function fetchCogBytesMultiple(self, xy, { signal } = {}) {
|
|
9149
|
-
const debug = self._debug ? { label: "data" } : void 0;
|
|
9150
|
-
switch (self.cachedTags.planarConfiguration) {
|
|
9151
|
-
case PlanarConfiguration.Contig: return (await getTiles(self.image, xy, self.dataSource, {
|
|
9152
|
-
signal,
|
|
9153
|
-
debug
|
|
9154
|
-
})).map((tile, i) => {
|
|
9155
|
-
if (tile === null) {
|
|
9156
|
-
const [x, y] = xy[i];
|
|
9157
|
-
throw new Error(`Tile at (${x}, ${y}) not found`);
|
|
9158
|
-
}
|
|
9159
|
-
return tile;
|
|
9160
|
-
});
|
|
9161
|
-
case PlanarConfiguration.Separate: return fetchBandSeparateTileBytesMultiple(self, xy, { signal });
|
|
9162
|
-
default: throw new Error(`Unsupported PlanarConfiguration: ${self.cachedTags.planarConfiguration}`);
|
|
9163
|
-
}
|
|
9164
|
-
}
|
|
9165
|
-
/**
|
|
9166
|
-
* Batched, range-coalescing counterpart to {@link fetchBandSeparateTileBytes}.
|
|
9167
|
-
* Every band of every requested tile is flattened into a single
|
|
9168
|
-
* {@link getMultipleBytes} call, so coalescing can merge ranges across both
|
|
9169
|
-
* bands and neighbouring tiles; the results are regrouped per tile afterwards.
|
|
9170
|
-
*/
|
|
9171
|
-
async function fetchBandSeparateTileBytesMultiple(self, xy, { signal } = {}) {
|
|
9172
|
-
const debug = self._debug ? { label: "data" } : void 0;
|
|
9173
|
-
const numBands = self.cachedTags.samplesPerPixel;
|
|
9174
|
-
const flatRanges = (await Promise.all(xy.map(([x, y]) => findBandSeparateTileByteRanges(self, x, y)))).flatMap((ranges) => ranges.map(({ offset, imageSize }) => ({
|
|
9175
|
-
offset,
|
|
9176
|
-
byteCount: imageSize
|
|
9177
|
-
})));
|
|
9178
|
-
const flatResults = await getMultipleBytes(self.image, flatRanges, self.dataSource, {
|
|
9179
|
-
signal,
|
|
9180
|
-
debug
|
|
9181
|
-
});
|
|
9182
|
-
return xy.map(([x, y], t) => flatResults.slice(t * numBands, t * numBands + numBands).map((res) => {
|
|
9183
|
-
if (res === null) throw new Error(`Tile at (${x}, ${y}) not found`);
|
|
9184
|
-
return res;
|
|
9185
|
-
}));
|
|
9186
|
-
}
|
|
9187
|
-
/**
|
|
9188
|
-
* Load a tile into an ArrayBuffer.
|
|
9189
|
-
*
|
|
9190
|
-
* If the tile compression is JPEG, this will also apply the JPEG compression
|
|
9191
|
-
* tables to the resulting ArrayBuffer (see `image.getJpegHeader`).
|
|
9192
|
-
*
|
|
9193
|
-
* Though this function lives upstream in @cogeotiff/core, we vendor it here
|
|
9194
|
-
* so we can route the *tile data* read through a separate source. The tile's
|
|
9195
|
-
* byte range is looked up via `image.getTileSize(idx)`, which inside cogeotiff
|
|
9196
|
-
* uses the source that was passed to `Tiff.create` (our header source — cached
|
|
9197
|
-
* for small repeated reads). The actual tile bytes are then fetched from
|
|
9198
|
-
* `dataSource`, which is the raw HTTP source with no caching: tile data is
|
|
9199
|
-
* large and read once, so caching it would just evict header metadata.
|
|
9200
|
-
*/
|
|
9201
|
-
async function getTile(image, x, y, dataSource, options) {
|
|
9202
|
-
const { size, tileSize: tiles } = image;
|
|
9203
|
-
if (tiles == null) throw new Error("Tiff is not tiled");
|
|
9204
|
-
const nyTiles = Math.ceil(size.height / tiles.height);
|
|
9205
|
-
const nxTiles = Math.ceil(size.width / tiles.width);
|
|
9206
|
-
if (x >= nxTiles || y >= nyTiles) throw new Error(`Tile index is outside of range x:${x} >= ${nxTiles} or y:${y} >= ${nyTiles}`);
|
|
9207
|
-
const idx = y * nxTiles + x;
|
|
9208
|
-
const totalTiles = nxTiles * nyTiles;
|
|
9209
|
-
if (idx >= totalTiles) throw new Error(`Tile index is outside of tile range: ${idx} >= ${totalTiles}`);
|
|
9210
|
-
const { offset, imageSize } = await image.getTileSize(idx);
|
|
9211
|
-
return getBytes(image, offset, imageSize, dataSource, options);
|
|
9212
|
-
}
|
|
9213
|
-
/**
|
|
9214
|
-
* Read image bytes at the given offset from `dataSource`.
|
|
9215
|
-
*
|
|
9216
|
-
* Though this function lives upstream in @cogeotiff/core, we vendor it here
|
|
9217
|
-
* so we can route reads through the data source (uncached) rather than the
|
|
9218
|
-
* header source (cached) that cogeotiff would use by default. Tile data is
|
|
9219
|
-
* large and read once; caching it would evict header metadata and inflate
|
|
9220
|
-
* memory.
|
|
9221
|
-
*/
|
|
9222
|
-
async function getBytes(image, offset, byteCount, dataSource, options) {
|
|
9223
|
-
if (byteCount === 0) return null;
|
|
9224
|
-
if (options?.debug !== void 0) console.log(`[geotiff dataSource] ${options.debug.label}: offset=${offset} length=${byteCount}`);
|
|
9225
|
-
const bytes = await dataSource.fetch(offset, byteCount, options);
|
|
9226
|
-
if (bytes.byteLength < byteCount) throw new Error(`Failed to fetch bytes from offset:${offset} wanted:${byteCount} got:${bytes.byteLength}`);
|
|
9227
|
-
const compression = image.value(TiffTag.Compression) ?? Compression.None;
|
|
9228
|
-
if (compression === Compression.Jpeg) return {
|
|
9229
|
-
bytes: image.getJpegHeader(bytes),
|
|
9230
|
-
compression
|
|
9231
|
-
};
|
|
9232
|
-
return {
|
|
9233
|
-
bytes,
|
|
9234
|
-
compression
|
|
9235
|
-
};
|
|
9236
|
-
}
|
|
9237
|
-
/**
|
|
9238
|
-
* Read image bytes for multiple ranges in a single batched I/O round trip.
|
|
9239
|
-
*
|
|
9240
|
-
* Vectorized counterpart to {@link getBytes}. The non-sparse ranges are
|
|
9241
|
-
* dispatched through {@link coalesceRanges}, which merges nearby byte ranges
|
|
9242
|
-
* into fewer `dataSource.fetch` calls. Returns one entry per input range, in
|
|
9243
|
-
* input order; sparse ranges (`offset === 0` or `byteCount === 0`) yield `null`,
|
|
9244
|
-
* matching {@link getBytes}.
|
|
9245
|
-
*
|
|
9246
|
-
* Vendored from cogeotiff PR #1463 (`TiffImage.getMultipleBytes`) for the same
|
|
9247
|
-
* reason as {@link getBytes}: tile data must read through the uncached
|
|
9248
|
-
* `dataSource` rather than the cached header source. Upstream also lets a
|
|
9249
|
-
* `Source` provide its own `fetchRanges`; `@cogeotiff/core@9.5.0` has no such
|
|
9250
|
-
* interface method and `dataSource` is only `Pick<Source, "fetch">`, so the
|
|
9251
|
-
* coalescing here is always done locally.
|
|
9252
|
-
*/
|
|
9253
|
-
async function getMultipleBytes(image, ranges, dataSource, options) {
|
|
9254
|
-
if (ranges.length === 0) return [];
|
|
9255
|
-
const results = new Array(ranges.length);
|
|
9256
|
-
const realRanges = [];
|
|
9257
|
-
const realIndices = [];
|
|
9258
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
9259
|
-
const range = ranges[i];
|
|
9260
|
-
if (range.offset === 0 || range.byteCount === 0) results[i] = null;
|
|
9261
|
-
else {
|
|
9262
|
-
realIndices.push(i);
|
|
9263
|
-
realRanges.push({
|
|
9264
|
-
offset: range.offset,
|
|
9265
|
-
length: range.byteCount
|
|
9266
|
-
});
|
|
9267
|
-
}
|
|
9268
|
-
}
|
|
9269
|
-
if (realRanges.length === 0) return results;
|
|
9270
|
-
if (options?.debug !== void 0) for (const r of realRanges) console.log(`[geotiff dataSource] ${options.debug.label}: offset=${r.offset} length=${r.length}`);
|
|
9271
|
-
const fetched = await coalesceRanges(dataSource, realRanges, {
|
|
9272
|
-
coalesce: options?.coalesce,
|
|
9273
|
-
maxRangeSize: options?.maxRangeSize,
|
|
9274
|
-
signal: options?.signal
|
|
9275
|
-
});
|
|
9276
|
-
const compression = image.value(TiffTag.Compression) ?? Compression.None;
|
|
9277
|
-
for (let k = 0; k < fetched.length; k++) {
|
|
9278
|
-
const i = realIndices[k];
|
|
9279
|
-
const raw = fetched[k];
|
|
9280
|
-
results[i] = {
|
|
9281
|
-
bytes: compression === Compression.Jpeg ? image.getJpegHeader(raw) : raw,
|
|
9282
|
-
compression
|
|
9283
|
-
};
|
|
9284
|
-
}
|
|
9285
|
-
return results;
|
|
9286
|
-
}
|
|
9287
|
-
/**
|
|
9288
|
-
* Load multiple tiles in a single batched I/O round trip.
|
|
9289
|
-
*
|
|
9290
|
-
* Resolves the offset/size of every requested tile via `image.getTileSize`
|
|
9291
|
-
* (header-source reads — small entries, served by the chunk cache), then fetches
|
|
9292
|
-
* the tile data through {@link getMultipleBytes} (uncached `dataSource`, with
|
|
9293
|
-
* range coalescing). Returns one entry per input tile, in input order; sparse
|
|
9294
|
-
* tiles yield `null` matching {@link getBytes}.
|
|
9295
|
-
*
|
|
9296
|
-
* Vendored from cogeotiff PR #1463 (`TiffImage.getTiles`) for the same reason as
|
|
9297
|
-
* {@link getTile}: the tile-data read must route through `dataSource`.
|
|
9298
|
-
*/
|
|
9299
|
-
async function getTiles(image, xy, dataSource, options) {
|
|
9300
|
-
if (xy.length === 0) return [];
|
|
9301
|
-
const { size, tileSize } = image;
|
|
9302
|
-
if (tileSize == null) throw new Error("Tiff is not tiled");
|
|
9303
|
-
const nyTiles = Math.ceil(size.height / tileSize.height);
|
|
9304
|
-
const nxTiles = Math.ceil(size.width / tileSize.width);
|
|
9305
|
-
const totalTiles = nxTiles * nyTiles;
|
|
9306
|
-
const indices = xy.map(([x, y]) => {
|
|
9307
|
-
if (x >= nxTiles || y >= nyTiles) throw new Error(`Tile index is outside of range x:${x} >= ${nxTiles} or y:${y} >= ${nyTiles}`);
|
|
9308
|
-
const idx = y * nxTiles + x;
|
|
9309
|
-
if (idx >= totalTiles) throw new Error(`Tile index is outside of tile range: ${idx} >= ${totalTiles}`);
|
|
9310
|
-
return idx;
|
|
9311
|
-
});
|
|
9312
|
-
return getMultipleBytes(image, (await Promise.all(indices.map((i) => image.getTileSize(i)))).map((s) => ({
|
|
9313
|
-
offset: s.offset,
|
|
9314
|
-
byteCount: s.imageSize
|
|
9315
|
-
})), dataSource, options);
|
|
9316
|
-
}
|
|
9317
|
-
/**
|
|
9318
|
-
* Clip a decoded tile array to the valid image bounds.
|
|
9319
|
-
*
|
|
9320
|
-
* Edge tiles in a COG are always encoded at the full tile size, with the
|
|
9321
|
-
* out-of-bounds region zero-padded. When `boundless=false` is requested, this
|
|
9322
|
-
* function copies only the valid pixel sub-rectangle into a new typed array,
|
|
9323
|
-
* returning a `RasterArray` whose `width`/`height` match the actual image
|
|
9324
|
-
* content rather than the tile dimensions.
|
|
9325
|
-
*
|
|
9326
|
-
* Interior tiles (where the tile fits entirely within the image) are returned
|
|
9327
|
-
* unchanged.
|
|
9328
|
-
*/
|
|
9329
|
-
function clipToImageBounds(self, x, y, array) {
|
|
9330
|
-
const { width: clippedWidth, height: clippedHeight } = self.image.getTileBounds(x, y);
|
|
9331
|
-
if (clippedWidth === self.tileWidth && clippedHeight === self.tileHeight) return array;
|
|
9332
|
-
const clippedMask = array.mask ? clipRows(array.mask, self.tileWidth, clippedWidth, clippedHeight, 1) : array.mask;
|
|
9333
|
-
if (array.layout === "pixel-interleaved") {
|
|
9334
|
-
const { count, data } = array;
|
|
9335
|
-
const clipped = clipRows(data, self.tileWidth, clippedWidth, clippedHeight, count);
|
|
9336
|
-
return {
|
|
9337
|
-
...array,
|
|
9338
|
-
width: clippedWidth,
|
|
9339
|
-
height: clippedHeight,
|
|
9340
|
-
data: clipped,
|
|
9341
|
-
mask: clippedMask
|
|
9342
|
-
};
|
|
9343
|
-
}
|
|
9344
|
-
const { bands } = array;
|
|
9345
|
-
const clippedBands = bands.map((band) => clipRows(band, self.tileWidth, clippedWidth, clippedHeight, 1));
|
|
9346
|
-
return {
|
|
9347
|
-
...array,
|
|
9348
|
-
width: clippedWidth,
|
|
9349
|
-
height: clippedHeight,
|
|
9350
|
-
bands: clippedBands,
|
|
9351
|
-
mask: clippedMask
|
|
9352
|
-
};
|
|
9353
|
-
}
|
|
9354
|
-
/**
|
|
9355
|
-
* Copy rows from a strided typed array, keeping only `clippedWidth * samplesPerPixel`
|
|
9356
|
-
* values per row out of `tileWidth * samplesPerPixel`.
|
|
9357
|
-
*/
|
|
9358
|
-
function clipRows(src, tileWidth, clippedWidth, clippedHeight, samplesPerPixel) {
|
|
9359
|
-
const srcStride = tileWidth * samplesPerPixel;
|
|
9360
|
-
const dstStride = clippedWidth * samplesPerPixel;
|
|
9361
|
-
const dst = new src.constructor(dstStride * clippedHeight);
|
|
9362
|
-
for (let r = 0; r < clippedHeight; r++) dst.set(src.subarray(r * srcStride, r * srcStride + dstStride), r * dstStride);
|
|
9363
|
-
return dst;
|
|
9364
|
-
}
|
|
9365
|
-
function getUniqueSampleFormat(sampleFormats, bitsPerSamples) {
|
|
9366
|
-
const uniqueSampleFormats = new Set(sampleFormats);
|
|
9367
|
-
const uniqueBitsPerSample = new Set(bitsPerSamples);
|
|
9368
|
-
if (uniqueSampleFormats.size > 1) throw new Error("Multiple sample formats are not supported.");
|
|
9369
|
-
if (uniqueBitsPerSample.size > 1) throw new Error("Multiple bits per sample values are not supported.");
|
|
9370
|
-
const sampleFormat = sampleFormats[0];
|
|
9371
|
-
const bitsPerSample = bitsPerSamples[0];
|
|
9372
|
-
if (sampleFormat === void 0 || bitsPerSample === void 0) throw new Error("SampleFormat and BitsPerSample arrays cannot be empty.");
|
|
9373
|
-
return {
|
|
9374
|
-
sampleFormat,
|
|
9375
|
-
bitsPerSample
|
|
9376
|
-
};
|
|
9377
|
-
}
|
|
9378
|
-
//#endregion
|
|
9379
|
-
//#region node_modules/@developmentseed/geotiff/dist/gdal-metadata.js
|
|
9380
|
-
function parseGDALMetadata(gdalMetadata, { count }) {
|
|
9381
|
-
if (gdalMetadata == null) return null;
|
|
9382
|
-
const root = new DOMParser().parseFromString(gdalMetadata, "text/xml").documentElement;
|
|
9383
|
-
if (root.tagName !== "GDALMetadata") throw new Error("Not a GDALMetadata XML block");
|
|
9384
|
-
const bandStatistics = /* @__PURE__ */ new Map();
|
|
9385
|
-
const offsets = Array(count).fill(0);
|
|
9386
|
-
const scales = Array(count).fill(1);
|
|
9387
|
-
const getOrCreateBand = (sample) => {
|
|
9388
|
-
const idx = parseInt(sample, 10) + 1;
|
|
9389
|
-
if (!bandStatistics.has(idx)) bandStatistics.set(idx, {
|
|
9390
|
-
max: null,
|
|
9391
|
-
min: null,
|
|
9392
|
-
mean: null,
|
|
9393
|
-
std: null,
|
|
9394
|
-
validPercent: null
|
|
9395
|
-
});
|
|
9396
|
-
return bandStatistics.get(idx);
|
|
9397
|
-
};
|
|
9398
|
-
for (const elem of Array.from(root.querySelectorAll("Item"))) {
|
|
9399
|
-
const name = elem.getAttribute("name");
|
|
9400
|
-
const sample = elem.getAttribute("sample");
|
|
9401
|
-
const text = elem.textContent ?? "";
|
|
9402
|
-
if (sample === null) continue;
|
|
9403
|
-
switch (name) {
|
|
9404
|
-
case "STATISTICS_MAXIMUM":
|
|
9405
|
-
getOrCreateBand(sample).max = parseFloat(text);
|
|
9406
|
-
break;
|
|
9407
|
-
case "STATISTICS_MEAN":
|
|
9408
|
-
getOrCreateBand(sample).mean = parseFloat(text);
|
|
9409
|
-
break;
|
|
9410
|
-
case "STATISTICS_MINIMUM":
|
|
9411
|
-
getOrCreateBand(sample).min = parseFloat(text);
|
|
9412
|
-
break;
|
|
9413
|
-
case "STATISTICS_STDDEV":
|
|
9414
|
-
getOrCreateBand(sample).std = parseFloat(text);
|
|
9415
|
-
break;
|
|
9416
|
-
case "STATISTICS_VALID_PERCENT":
|
|
9417
|
-
getOrCreateBand(sample).validPercent = parseFloat(text);
|
|
9418
|
-
break;
|
|
9419
|
-
case "OFFSET":
|
|
9420
|
-
offsets[parseInt(sample, 10)] = parseFloat(text);
|
|
9421
|
-
break;
|
|
9422
|
-
case "SCALE":
|
|
9423
|
-
scales[parseInt(sample, 10)] = parseFloat(text);
|
|
9424
|
-
break;
|
|
9425
|
-
}
|
|
9426
|
-
}
|
|
9427
|
-
return {
|
|
9428
|
-
bandStatistics,
|
|
9429
|
-
offsets,
|
|
9430
|
-
scales
|
|
9431
|
-
};
|
|
9432
|
-
}
|
|
9433
|
-
//#endregion
|
|
9434
|
-
//#region node_modules/@developmentseed/geotiff/dist/ifd.js
|
|
9435
|
-
/** Pre-fetch TIFF tags for easier visualization. */
|
|
9436
|
-
async function prefetchTags(image, options = {}) {
|
|
9437
|
-
const { signal } = options;
|
|
9438
|
-
const compression = image.value(TiffTag.Compression);
|
|
9439
|
-
if (compression === null) throw new Error("Compression tag should always exist.");
|
|
9440
|
-
const [bitsPerSample, colorMap, gdalNoData, gdalMetadata, lercParameters, modelPixelScale, modelTiepoint, modelTransformation, photometric, planarConfiguration, predictor, sampleFormat, samplesPerPixel] = await Promise.all([
|
|
9441
|
-
image.fetch(TiffTag.BitsPerSample, { signal }),
|
|
9442
|
-
image.fetch(TiffTag.ColorMap, { signal }),
|
|
9443
|
-
image.fetch(TiffTag.GdalNoData, { signal }),
|
|
9444
|
-
image.fetch(TiffTag.GdalMetadata, { signal }),
|
|
9445
|
-
image.fetch(TiffTag.LercParameters, { signal }),
|
|
9446
|
-
image.fetch(TiffTag.ModelPixelScale, { signal }),
|
|
9447
|
-
image.fetch(TiffTag.ModelTiePoint, { signal }),
|
|
9448
|
-
image.fetch(TiffTag.ModelTransformation, { signal }),
|
|
9449
|
-
image.fetch(TiffTag.Photometric, { signal }),
|
|
9450
|
-
image.fetch(TiffTag.PlanarConfiguration, { signal }),
|
|
9451
|
-
image.fetch(TiffTag.Predictor, { signal }),
|
|
9452
|
-
image.fetch(TiffTag.SampleFormat, { signal }),
|
|
9453
|
-
image.fetch(TiffTag.SamplesPerPixel, { signal })
|
|
9454
|
-
]);
|
|
9455
|
-
const missingTag = (tagName) => {
|
|
9456
|
-
throw new Error(`${tagName} tag should always exist.`);
|
|
9457
|
-
};
|
|
9458
|
-
if (bitsPerSample === null) missingTag("BitsPerSample");
|
|
9459
|
-
if (samplesPerPixel === null) missingTag("SamplesPerPixel");
|
|
9460
|
-
if (photometric === null) missingTag("Photometric");
|
|
9461
|
-
return {
|
|
9462
|
-
bitsPerSample: new Uint16Array(bitsPerSample),
|
|
9463
|
-
colorMap: colorMap ? new Uint16Array(colorMap) : void 0,
|
|
9464
|
-
compression,
|
|
9465
|
-
gdalMetadata,
|
|
9466
|
-
lercParameters,
|
|
9467
|
-
modelTiepoint,
|
|
9468
|
-
modelPixelScale,
|
|
9469
|
-
modelTransformation,
|
|
9470
|
-
nodata: gdalNoData !== null ? Number(gdalNoData) : null,
|
|
9471
|
-
photometric,
|
|
9472
|
-
planarConfiguration: planarConfiguration ?? PlanarConfiguration.Contig,
|
|
9473
|
-
predictor: predictor ?? Predictor.None,
|
|
9474
|
-
sampleFormat: sampleFormat ?? [SampleFormat.Uint],
|
|
9475
|
-
samplesPerPixel
|
|
9476
|
-
};
|
|
9477
|
-
}
|
|
9478
|
-
function extractGeoKeyDirectory(image) {
|
|
9479
|
-
const geo = (key) => image.valueGeo(key) ?? null;
|
|
9480
|
-
return {
|
|
9481
|
-
modelType: geo(TiffTagGeo.GTModelTypeGeoKey),
|
|
9482
|
-
rasterType: geo(TiffTagGeo.GTRasterTypeGeoKey),
|
|
9483
|
-
citation: geo(TiffTagGeo.GTCitationGeoKey),
|
|
9484
|
-
geodeticCRS: geo(TiffTagGeo.GeodeticCRSGeoKey),
|
|
9485
|
-
geodeticCitation: geo(TiffTagGeo.GeodeticCitationGeoKey),
|
|
9486
|
-
geodeticDatum: geo(TiffTagGeo.GeodeticDatumGeoKey),
|
|
9487
|
-
primeMeridian: geo(TiffTagGeo.PrimeMeridianGeoKey),
|
|
9488
|
-
linearUnits: geo(TiffTagGeo.GeogLinearUnitsGeoKey),
|
|
9489
|
-
linearUnitSize: geo(TiffTagGeo.GeogLinearUnitSizeGeoKey),
|
|
9490
|
-
angularUnits: geo(TiffTagGeo.GeogAngularUnitsGeoKey),
|
|
9491
|
-
angularUnitSize: geo(TiffTagGeo.GeogAngularUnitSizeGeoKey),
|
|
9492
|
-
ellipsoid: geo(TiffTagGeo.EllipsoidGeoKey),
|
|
9493
|
-
ellipsoidSemiMajorAxis: geo(TiffTagGeo.EllipsoidSemiMajorAxisGeoKey),
|
|
9494
|
-
ellipsoidSemiMinorAxis: geo(TiffTagGeo.EllipsoidSemiMinorAxisGeoKey),
|
|
9495
|
-
ellipsoidInvFlattening: geo(TiffTagGeo.EllipsoidInvFlatteningGeoKey),
|
|
9496
|
-
azimuthUnits: geo(TiffTagGeo.GeogAzimuthUnitsGeoKey),
|
|
9497
|
-
primeMeridianLongitude: geo(TiffTagGeo.PrimeMeridianLongitudeGeoKey),
|
|
9498
|
-
toWGS84: geo(TiffTagGeo.GeogTOWGS84GeoKey),
|
|
9499
|
-
projectedCRS: geo(TiffTagGeo.ProjectedCRSGeoKey),
|
|
9500
|
-
projectedCitation: geo(TiffTagGeo.ProjectedCitationGeoKey),
|
|
9501
|
-
projection: geo(TiffTagGeo.ProjectionGeoKey),
|
|
9502
|
-
projMethod: geo(TiffTagGeo.ProjMethodGeoKey),
|
|
9503
|
-
projLinearUnits: geo(TiffTagGeo.ProjLinearUnitsGeoKey),
|
|
9504
|
-
projLinearUnitSize: geo(TiffTagGeo.ProjLinearUnitSizeGeoKey),
|
|
9505
|
-
projStdParallel1: geo(TiffTagGeo.ProjStdParallel1GeoKey),
|
|
9506
|
-
projStdParallel2: geo(TiffTagGeo.ProjStdParallel2GeoKey),
|
|
9507
|
-
projNatOriginLong: geo(TiffTagGeo.ProjNatOriginLongGeoKey),
|
|
9508
|
-
projNatOriginLat: geo(TiffTagGeo.ProjNatOriginLatGeoKey),
|
|
9509
|
-
projFalseEasting: geo(TiffTagGeo.ProjFalseEastingGeoKey),
|
|
9510
|
-
projFalseNorthing: geo(TiffTagGeo.ProjFalseNorthingGeoKey),
|
|
9511
|
-
projFalseOriginLong: geo(TiffTagGeo.ProjFalseOriginLongGeoKey),
|
|
9512
|
-
projFalseOriginLat: geo(TiffTagGeo.ProjFalseOriginLatGeoKey),
|
|
9513
|
-
projFalseOriginEasting: geo(TiffTagGeo.ProjFalseOriginEastingGeoKey),
|
|
9514
|
-
projFalseOriginNorthing: geo(TiffTagGeo.ProjFalseOriginNorthingGeoKey),
|
|
9515
|
-
projCenterLong: geo(TiffTagGeo.ProjCenterLongGeoKey),
|
|
9516
|
-
projCenterLat: geo(TiffTagGeo.ProjCenterLatGeoKey),
|
|
9517
|
-
projCenterEasting: geo(TiffTagGeo.ProjCenterEastingGeoKey),
|
|
9518
|
-
projCenterNorthing: geo(TiffTagGeo.ProjCenterNorthingGeoKey),
|
|
9519
|
-
projScaleAtNatOrigin: geo(TiffTagGeo.ProjScaleAtNatOriginGeoKey),
|
|
9520
|
-
projScaleAtCenter: geo(TiffTagGeo.ProjScaleAtCenterGeoKey),
|
|
9521
|
-
projAzimuthAngle: geo(TiffTagGeo.ProjAzimuthAngleGeoKey),
|
|
9522
|
-
projStraightVertPoleLong: geo(TiffTagGeo.ProjStraightVertPoleLongGeoKey),
|
|
9523
|
-
projRectifiedGridAngle: geo(TiffTagGeo.ProjRectifiedGridAngleGeoKey),
|
|
9524
|
-
verticalCRS: geo(TiffTagGeo.VerticalGeoKey),
|
|
9525
|
-
verticalCitation: geo(TiffTagGeo.VerticalCitationGeoKey),
|
|
9526
|
-
verticalDatum: geo(TiffTagGeo.VerticalDatumGeoKey),
|
|
9527
|
-
verticalUnits: geo(TiffTagGeo.VerticalUnitsGeoKey)
|
|
9528
|
-
};
|
|
9529
|
-
}
|
|
9530
|
-
//#endregion
|
|
9531
|
-
//#region node_modules/@developmentseed/geotiff/dist/transform.js
|
|
9532
|
-
function createTransform({ modelTiepoint, modelPixelScale, modelTransformation, rasterType }) {
|
|
9533
|
-
let transform;
|
|
9534
|
-
if (modelTiepoint && modelPixelScale) transform = createFromModelTiepointAndPixelScale(modelTiepoint, modelPixelScale);
|
|
9535
|
-
else if (modelTransformation) transform = createFromModelTransformation(modelTransformation);
|
|
9536
|
-
else throw new Error("The image does not have an affine transformation.");
|
|
9537
|
-
if (rasterType === RasterTypeKey.PixelIsPoint) transform = compose(transform, translation(-.5, -.5));
|
|
9538
|
-
return transform;
|
|
9539
|
-
}
|
|
9540
|
-
function createFromModelTiepointAndPixelScale(modelTiepoint, modelPixelScale) {
|
|
9541
|
-
const xOrigin = modelTiepoint[3];
|
|
9542
|
-
const yOrigin = modelTiepoint[4];
|
|
9543
|
-
return [
|
|
9544
|
-
modelPixelScale[0],
|
|
9545
|
-
0,
|
|
9546
|
-
xOrigin,
|
|
9547
|
-
0,
|
|
9548
|
-
-modelPixelScale[1],
|
|
9549
|
-
yOrigin
|
|
9550
|
-
];
|
|
9551
|
-
}
|
|
9552
|
-
function createFromModelTransformation(modelTransformation) {
|
|
9553
|
-
const xOrigin = modelTransformation[3];
|
|
9554
|
-
const yOrigin = modelTransformation[7];
|
|
9555
|
-
const rowRotation = modelTransformation[1];
|
|
9556
|
-
const colRotation = modelTransformation[4];
|
|
9557
|
-
return [
|
|
9558
|
-
modelTransformation[0],
|
|
9559
|
-
rowRotation,
|
|
9560
|
-
xOrigin,
|
|
9561
|
-
colRotation,
|
|
9562
|
-
modelTransformation[5],
|
|
9563
|
-
yOrigin
|
|
9564
|
-
];
|
|
9565
|
-
}
|
|
9566
|
-
/**
|
|
9567
|
-
* Get the (row, col) pixel index containing the geographic coordinate (x, y).
|
|
9568
|
-
*
|
|
9569
|
-
* @param x x coordinate in the CRS.
|
|
9570
|
-
* @param y y coordinate in the CRS.
|
|
9571
|
-
* @param op Rounding function applied to fractional pixel indices.
|
|
9572
|
-
* Defaults to Math.floor.
|
|
9573
|
-
* @returns [row, col] pixel indices.
|
|
9574
|
-
*/
|
|
9575
|
-
function index(self, x, y, op = Math.floor) {
|
|
9576
|
-
const [col, row] = apply(invert$2(self.transform), x, y);
|
|
9577
|
-
return [op(row), op(col)];
|
|
9578
|
-
}
|
|
9579
|
-
/**
|
|
9580
|
-
* Get the geographic (x, y) coordinate of the pixel at (row, col).
|
|
9581
|
-
*
|
|
9582
|
-
* @param row Pixel row.
|
|
9583
|
-
* @param col Pixel column.
|
|
9584
|
-
* @param offset Which part of the pixel to return. Defaults to "center".
|
|
9585
|
-
* @returns [x, y] in the CRS.
|
|
9586
|
-
*/
|
|
9587
|
-
function xy(self, row, col, offset = "center") {
|
|
9588
|
-
let c;
|
|
9589
|
-
let r;
|
|
9590
|
-
switch (offset) {
|
|
9591
|
-
case "center":
|
|
9592
|
-
c = col + .5;
|
|
9593
|
-
r = row + .5;
|
|
9594
|
-
break;
|
|
9595
|
-
case "ul":
|
|
9596
|
-
c = col;
|
|
9597
|
-
r = row;
|
|
9598
|
-
break;
|
|
9599
|
-
case "ur":
|
|
9600
|
-
c = col + 1;
|
|
9601
|
-
r = row;
|
|
9602
|
-
break;
|
|
9603
|
-
case "ll":
|
|
9604
|
-
c = col;
|
|
9605
|
-
r = row + 1;
|
|
9606
|
-
break;
|
|
9607
|
-
case "lr":
|
|
9608
|
-
c = col + 1;
|
|
9609
|
-
r = row + 1;
|
|
9610
|
-
break;
|
|
9611
|
-
}
|
|
9612
|
-
return apply(self.transform, c, r);
|
|
9613
|
-
}
|
|
9614
|
-
//#endregion
|
|
9615
|
-
//#region node_modules/@developmentseed/geotiff/dist/overview.js
|
|
9616
|
-
/**
|
|
9617
|
-
* A single resolution level of a GeoTIFF — either the full-resolution image
|
|
9618
|
-
* or a reduced-resolution overview. Pairs the data IFD with its
|
|
9619
|
-
* corresponding mask IFD (if any).
|
|
9620
|
-
*/
|
|
9621
|
-
var Overview = class {
|
|
9622
|
-
cachedTags;
|
|
9623
|
-
/** The data source used for fetching tile data. */
|
|
9624
|
-
dataSource;
|
|
9625
|
-
/** A reference to the parent GeoTIFF object. */
|
|
9626
|
-
geotiff;
|
|
9627
|
-
/** The GeoKeyDirectory of the primary IFD. */
|
|
9628
|
-
gkd;
|
|
9629
|
-
/** The data IFD for this resolution level. */
|
|
9630
|
-
image;
|
|
9631
|
-
/** The IFD for the mask associated with this overview level, if any. */
|
|
9632
|
-
maskImage = null;
|
|
9633
|
-
constructor(geotiff, gkd, image, maskImage, cachedTags, dataSource) {
|
|
9634
|
-
this.geotiff = geotiff;
|
|
9635
|
-
this.gkd = gkd;
|
|
9636
|
-
this.image = image;
|
|
9637
|
-
this.maskImage = maskImage;
|
|
9638
|
-
this.cachedTags = cachedTags;
|
|
9639
|
-
this.dataSource = dataSource;
|
|
9640
|
-
}
|
|
9641
|
-
/**
|
|
9642
|
-
* The CRS parsed from the GeoKeyDirectory.
|
|
9643
|
-
*
|
|
9644
|
-
* Returns an EPSG code (number) for EPSG-coded CRSes, or a PROJJSON object
|
|
9645
|
-
* for user-defined CRSes. The result is cached after the first access.
|
|
9646
|
-
*
|
|
9647
|
-
* See also {@link GeoTIFF.epsg} for the EPSG code directly from the TIFF tags.
|
|
9648
|
-
*/
|
|
9649
|
-
get crs() {
|
|
9650
|
-
return this.geotiff.crs;
|
|
9651
|
-
}
|
|
9652
|
-
/** Image height in pixels. */
|
|
9653
|
-
get height() {
|
|
9654
|
-
return this.image.size.height;
|
|
9655
|
-
}
|
|
9656
|
-
/** The no data value, or null if not set. */
|
|
9657
|
-
get nodata() {
|
|
9658
|
-
return this.geotiff.nodata;
|
|
9659
|
-
}
|
|
9660
|
-
/** Inherits the {@link GeoTIFF._debug} flag from the parent. */
|
|
9661
|
-
get _debug() {
|
|
9662
|
-
return this.geotiff._debug;
|
|
9663
|
-
}
|
|
9664
|
-
/** The number of tiles in the x and y directions */
|
|
9665
|
-
get tileCount() {
|
|
9666
|
-
return this.image.tileCount;
|
|
9667
|
-
}
|
|
9668
|
-
/** Tile height in pixels. */
|
|
9669
|
-
get tileHeight() {
|
|
9670
|
-
return this.image.tileSize.height;
|
|
9671
|
-
}
|
|
9672
|
-
/** Tile width in pixels. */
|
|
9673
|
-
get tileWidth() {
|
|
9674
|
-
return this.image.tileSize.width;
|
|
9675
|
-
}
|
|
9676
|
-
/**
|
|
9677
|
-
* Return the dataset's georeferencing transformation matrix.
|
|
9678
|
-
*/
|
|
9679
|
-
get transform() {
|
|
9680
|
-
const fullTransform = this.geotiff.transform;
|
|
9681
|
-
return compose(fullTransform, scale$3(this.geotiff.width / this.width, this.geotiff.height / this.height));
|
|
9682
|
-
}
|
|
9683
|
-
/** Image width in pixels. */
|
|
9684
|
-
get width() {
|
|
9685
|
-
return this.image.size.width;
|
|
9686
|
-
}
|
|
9687
|
-
/** Fetch a single tile from the full-resolution image.
|
|
9688
|
-
*
|
|
9689
|
-
* @param x The tile column index (0-based).
|
|
9690
|
-
* @param y The tile row index (0-based).
|
|
9691
|
-
* @param options Optional parameters for fetching the tile.
|
|
9692
|
-
* @param options.boundless Whether to clip tiles that are partially outside the image bounds. When `true`, no clipping is applied and edge tiles are returned at the full nominal tile size. Defaults to `true`.
|
|
9693
|
-
* @param options.pool An optional {@link DecoderPool} for decoding the tile data. If not provided, a new decoder will be created for each tile.
|
|
9694
|
-
* @param options.signal An optional {@link AbortSignal} to cancel the fetch request.
|
|
9695
|
-
*/
|
|
9696
|
-
async fetchTile(x, y, options = {}) {
|
|
9697
|
-
return await fetchTile(this, x, y, options);
|
|
9698
|
-
}
|
|
9699
|
-
/**
|
|
9700
|
-
* Fetch multiple tiles in parallel.
|
|
9701
|
-
*
|
|
9702
|
-
* A future implementation may coalesce contiguous byte ranges to reduce
|
|
9703
|
-
* the number of HTTP requests.
|
|
9704
|
-
*
|
|
9705
|
-
* @param xy - Array of `[x, y]` tile coordinates.
|
|
9706
|
-
* @param options - Optional parameters (same as {@link fetchTile}).
|
|
9707
|
-
* @returns Array of {@link Tile} objects in the same order as `xy`.
|
|
9708
|
-
*
|
|
9709
|
-
* @see {@link fetchTile} for single-tile fetching.
|
|
9710
|
-
*/
|
|
9711
|
-
async fetchTiles(xy, options = {}) {
|
|
9712
|
-
return await fetchTiles(this, xy, options);
|
|
9713
|
-
}
|
|
9714
|
-
/**
|
|
9715
|
-
* Get the (row, col) pixel index containing the geographic coordinate (x, y).
|
|
9716
|
-
*
|
|
9717
|
-
* @param x x coordinate in the CRS.
|
|
9718
|
-
* @param y y coordinate in the CRS.
|
|
9719
|
-
* @param op Rounding function applied to fractional pixel indices.
|
|
9720
|
-
* Defaults to Math.floor.
|
|
9721
|
-
* @returns [row, col] pixel indices.
|
|
9722
|
-
*/
|
|
9723
|
-
index(x, y, op = Math.floor) {
|
|
9724
|
-
return index(this, x, y, op);
|
|
9725
|
-
}
|
|
9726
|
-
/**
|
|
9727
|
-
* Get the geographic (x, y) coordinate of the pixel at (row, col).
|
|
9728
|
-
*
|
|
9729
|
-
* @param row Pixel row.
|
|
9730
|
-
* @param col Pixel column.
|
|
9731
|
-
* @param offset Which part of the pixel to return. Defaults to "center".
|
|
9732
|
-
* @returns [x, y] in the CRS.
|
|
9733
|
-
*/
|
|
9734
|
-
xy(row, col, offset = "center") {
|
|
9735
|
-
return xy(this, row, col, offset);
|
|
9736
|
-
}
|
|
9737
|
-
};
|
|
9738
|
-
//#endregion
|
|
9739
|
-
//#region node_modules/@developmentseed/geotiff/dist/geotiff.js
|
|
9740
|
-
/**
|
|
9741
|
-
* A high-level GeoTIFF abstraction built on
|
|
9742
|
-
* {@link https://github.com/blacha/cogeotiff | @cogeotiff/core}'s `Tiff` and
|
|
9743
|
-
* `TiffImage` classes.
|
|
9744
|
-
*
|
|
9745
|
-
* This class separates data IFDs from mask IFDs, pairs them by resolution
|
|
9746
|
-
* level, and exposes sorted overviews. Intentionally mirrors the Python
|
|
9747
|
-
* {@link https://github.com/developmentseed/async-geotiff | async-geotiff} API
|
|
9748
|
-
* as closely as possible.
|
|
9749
|
-
*
|
|
9750
|
-
* Construct via {@link GeoTIFF.fromUrl}, {@link GeoTIFF.fromArrayBuffer},
|
|
9751
|
-
* {@link GeoTIFF.open} or {@link GeoTIFF.fromTiff}.
|
|
9752
|
-
*
|
|
9753
|
-
* @see {@link Overview} for reduced-resolution overview images.
|
|
9754
|
-
*/
|
|
9755
|
-
var GeoTIFF = class GeoTIFF {
|
|
9756
|
-
/**
|
|
9757
|
-
* Reduced-resolution overview levels, sorted finest-to-coarsest.
|
|
9758
|
-
*
|
|
9759
|
-
* Does not include the full-resolution image — use {@link fetchTile} on the
|
|
9760
|
-
* GeoTIFF instance itself for that.
|
|
9761
|
-
*/
|
|
9762
|
-
overviews;
|
|
9763
|
-
/** A cached CRS value. */
|
|
9764
|
-
_crs;
|
|
9765
|
-
/** Cached TIFF tags that are pre-fetched when opening the GeoTIFF. */
|
|
9766
|
-
cachedTags;
|
|
9767
|
-
/** The data source used for fetching tile data.
|
|
9768
|
-
*
|
|
9769
|
-
* This is typically the raw source (e.g. HTTP or memory) rather than a
|
|
9770
|
-
* layered source with caching and chunking, to avoid unnecessary copying of
|
|
9771
|
-
* tile data through cache layers.
|
|
9772
|
-
*/
|
|
9773
|
-
dataSource;
|
|
9774
|
-
/** The underlying Tiff instance. */
|
|
9775
|
-
tiff;
|
|
9776
|
-
/** The primary (full-resolution) TiffImage. */
|
|
9777
|
-
image;
|
|
9778
|
-
/** The mask IFD of the full-resolution GeoTIFF, if any. */
|
|
9779
|
-
maskImage;
|
|
9780
|
-
/** The GeoKeyDirectory of the primary IFD. */
|
|
9781
|
-
gkd;
|
|
9782
|
-
/** Parsed GDALMetadata tag, if present. */
|
|
9783
|
-
gdalMetadata;
|
|
9784
|
-
/**
|
|
9785
|
-
* Internal: when true, log each `dataSource` fetch (image tile data and
|
|
9786
|
-
* mask tile data) to the console with offset/length and a `data`/`mask`
|
|
9787
|
-
* label. Enable via the `debug` option on {@link GeoTIFF.open} or
|
|
9788
|
-
* {@link GeoTIFF.fromUrl}. Read by the tile-fetch path; not part of the
|
|
9789
|
-
* public API surface.
|
|
9790
|
-
*
|
|
9791
|
-
* @internal
|
|
9792
|
-
*/
|
|
9793
|
-
_debug;
|
|
9794
|
-
constructor(tiff, image, maskImage, gkd, overviews, cachedTags, dataSource, gdalMetadata, debug) {
|
|
9795
|
-
this.tiff = tiff;
|
|
9796
|
-
this.image = image;
|
|
9797
|
-
this.maskImage = maskImage;
|
|
9798
|
-
this.gkd = gkd;
|
|
9799
|
-
this.overviews = overviews;
|
|
9800
|
-
this.cachedTags = cachedTags;
|
|
9801
|
-
this.dataSource = dataSource;
|
|
9802
|
-
this.gdalMetadata = gdalMetadata;
|
|
9803
|
-
this._debug = debug;
|
|
9804
|
-
}
|
|
9805
|
-
/**
|
|
9806
|
-
* Open a GeoTIFF from a @cogeotiff/core Source.
|
|
9807
|
-
*
|
|
9808
|
-
* This creates and initialises the underlying Tiff, then classifies IFDs.
|
|
9809
|
-
*
|
|
9810
|
-
* @param options.dataSource A source for fetching tile data. This is separate from the source used to construct the TIFF to allow for separate caching implementations.
|
|
9811
|
-
* @param options.headerSource The source used to construct the TIFF. This is typically a layered source with caching and chunking, to optimise access to TIFF tags and IFDs. Callers who want to control the initial read size should compose a `SourceChunk` of the desired block size; cogeotiff's default `defaultReadSize` (16 KiB) gets padded up by the chunking layer anyway.
|
|
9812
|
-
* @param options.signal An optional {@link AbortSignal} to cancel the header reads.
|
|
9813
|
-
* @param options.debug When true, the returned GeoTIFF logs each tile/mask data fetch to the console. Off by default.
|
|
9814
|
-
*/
|
|
9815
|
-
static async open(options) {
|
|
9816
|
-
const { dataSource, headerSource, signal, debug } = options;
|
|
9817
|
-
const tiff = await new Tiff(headerSource).init({ signal });
|
|
9818
|
-
tiff.options = void 0;
|
|
9819
|
-
return GeoTIFF.fromTiff(tiff, dataSource, {
|
|
9820
|
-
signal,
|
|
9821
|
-
debug
|
|
9822
|
-
});
|
|
9823
|
-
}
|
|
9824
|
-
/**
|
|
9825
|
-
* Create a GeoTIFF from an already-initialised Tiff instance.
|
|
9826
|
-
*
|
|
9827
|
-
* All IFDs are walked; mask IFDs are matched to data IFDs by matching
|
|
9828
|
-
* (width, height). Overviews are sorted from finest to coarsest resolution.
|
|
9829
|
-
*
|
|
9830
|
-
* @param dataSource A source for fetching tile data. This is separate from the source used to construct the TIFF to allow for separate caching implementations.
|
|
9831
|
-
* @param options.signal An optional {@link AbortSignal} to cancel header tag reads.
|
|
9832
|
-
* @param options.debug When true, the returned GeoTIFF logs each tile/mask data fetch to the console.
|
|
9833
|
-
*/
|
|
9834
|
-
static async fromTiff(tiff, dataSource, options = {}) {
|
|
9835
|
-
const { signal, debug = false } = options;
|
|
9836
|
-
const images = tiff.images;
|
|
9837
|
-
if (images.length === 0) throw new Error("TIFF does not contain any IFDs");
|
|
9838
|
-
await Promise.all(images.map((image) => image.init(true, { signal })));
|
|
9839
|
-
const primaryImage = images[0];
|
|
9840
|
-
const gkd = extractGeoKeyDirectory(primaryImage);
|
|
9841
|
-
const dataIFDs = /* @__PURE__ */ new Map();
|
|
9842
|
-
const maskIFDs = /* @__PURE__ */ new Map();
|
|
9843
|
-
for (let i = 1; i < images.length; i++) {
|
|
9844
|
-
const image = images[i];
|
|
9845
|
-
const size = image.size;
|
|
9846
|
-
const key = `${size.width},${size.height}`;
|
|
9847
|
-
if (isMaskIfd(image)) maskIFDs.set(key, image);
|
|
9848
|
-
else dataIFDs.set(key, image);
|
|
9849
|
-
}
|
|
9850
|
-
const primaryKey = `${primaryImage.size.width},${primaryImage.size.height}`;
|
|
9851
|
-
const primaryMask = maskIFDs.get(primaryKey) ?? null;
|
|
9852
|
-
const dataEntries = Array.from(dataIFDs.entries());
|
|
9853
|
-
dataEntries.sort((a, b) => {
|
|
9854
|
-
const sa = a[1].size;
|
|
9855
|
-
const sb = b[1].size;
|
|
9856
|
-
return sb.width * sb.height - sa.width * sa.height;
|
|
9857
|
-
});
|
|
9858
|
-
const cachedTags = await prefetchTags(primaryImage, { signal });
|
|
9859
|
-
const geotiff = new GeoTIFF(tiff, primaryImage, primaryMask, gkd, [], cachedTags, dataSource, parseGDALMetadata(cachedTags.gdalMetadata, { count: cachedTags.samplesPerPixel }), debug);
|
|
9860
|
-
geotiff.overviews = dataEntries.map(([key, dataImage]) => {
|
|
9861
|
-
return new Overview(geotiff, gkd, dataImage, maskIFDs.get(key) ?? null, cachedTags, dataSource);
|
|
9862
|
-
});
|
|
9863
|
-
return geotiff;
|
|
9864
|
-
}
|
|
9865
|
-
/**
|
|
9866
|
-
* Create a GeoTIFF from an ArrayBuffer containing the entire file.
|
|
9867
|
-
*
|
|
9868
|
-
* This is a convenience method that wraps the ArrayBuffer in a memory source
|
|
9869
|
-
* and calls {@link GeoTIFF.open}. For large files, consider using
|
|
9870
|
-
* {@link GeoTIFF.fromUrl} or {@link GeoTIFF.open} with a chunked HTTP source
|
|
9871
|
-
* to avoid loading the entire file into memory at once.
|
|
9872
|
-
*
|
|
9873
|
-
* @param input The ArrayBuffer containing the GeoTIFF file data.
|
|
9874
|
-
* @returns A Promise that resolves to a GeoTIFF instance.
|
|
9875
|
-
*/
|
|
9876
|
-
static async fromArrayBuffer(input) {
|
|
9877
|
-
const source = new SourceMemory("memory://input.tif", input);
|
|
9878
|
-
return await GeoTIFF.open({
|
|
9879
|
-
dataSource: source,
|
|
9880
|
-
headerSource: source
|
|
9881
|
-
});
|
|
9882
|
-
}
|
|
9883
|
-
/**
|
|
9884
|
-
* Create a new GeoTIFF from a URL.
|
|
9885
|
-
*
|
|
9886
|
-
* Wraps the HTTP source with a fixed-size block-aligned LRU cache tuned for
|
|
9887
|
-
* TIFF metadata. cogeotiff's lazy per-entry reads (for tile offsets, byte
|
|
9888
|
-
* counts, and other tag values) are served by the block cache; adjacent
|
|
9889
|
-
* entries within a single block hit one underlying request. Tile data reads
|
|
9890
|
-
* bypass the cache and go straight to the raw HTTP source.
|
|
9891
|
-
*
|
|
9892
|
-
* @param url The URL of the GeoTIFF to open.
|
|
9893
|
-
* @param options Optional parameters.
|
|
9894
|
-
* @param options.chunkSize Bytes per chunk for the header cache. Defaults to 64 KiB (matches geotiff.js's BlockedSource).
|
|
9895
|
-
* @param options.cacheSize Total cache size in bytes. Defaults to 8 MiB (~128 blocks at the default chunk size).
|
|
9896
|
-
* @param options.signal An optional {@link AbortSignal} to cancel the header reads.
|
|
9897
|
-
* @param options.debug When true, the returned GeoTIFF logs each tile/mask data fetch to the console with offset/length and a `data`/`mask` label. Off by default.
|
|
9898
|
-
* @returns A Promise that resolves to a GeoTIFF instance.
|
|
9899
|
-
*/
|
|
9900
|
-
static async fromUrl(url, { chunkSize = 64 * 1024, cacheSize = 8 * 1024 * 1024, signal, debug } = {}) {
|
|
9901
|
-
const source = new SourceHttp(url, {});
|
|
9902
|
-
source.metadata = { size: Number.POSITIVE_INFINITY };
|
|
9903
|
-
const view = new SourceView(source, [new SourceChunk({ size: chunkSize }), new SourceCache({ size: cacheSize })]);
|
|
9904
|
-
return await GeoTIFF.open({
|
|
9905
|
-
dataSource: source,
|
|
9906
|
-
headerSource: view,
|
|
9907
|
-
signal,
|
|
9908
|
-
debug
|
|
9909
|
-
});
|
|
9910
|
-
}
|
|
9911
|
-
/**
|
|
9912
|
-
* The CRS parsed from the GeoKeyDirectory.
|
|
9913
|
-
*
|
|
9914
|
-
* Returns an EPSG code (number) for EPSG-coded CRSes, or a PROJJSON object
|
|
9915
|
-
* for user-defined CRSes. The result is cached after the first access.
|
|
9916
|
-
*
|
|
9917
|
-
* See also {@link GeoTIFF.epsg} for the EPSG code directly from the TIFF tags.
|
|
9918
|
-
*/
|
|
9919
|
-
get crs() {
|
|
9920
|
-
if (this._crs === void 0) this._crs = crsFromGeoKeys(this.gkd);
|
|
9921
|
-
return this._crs;
|
|
9922
|
-
}
|
|
9923
|
-
/** Image width in pixels. */
|
|
9924
|
-
get width() {
|
|
9925
|
-
return this.image.size.width;
|
|
9926
|
-
}
|
|
9927
|
-
/** Image height in pixels. */
|
|
9928
|
-
get height() {
|
|
9929
|
-
return this.image.size.height;
|
|
9930
|
-
}
|
|
9931
|
-
/** The number of tiles in the x and y directions */
|
|
9932
|
-
get tileCount() {
|
|
9933
|
-
return this.image.tileCount;
|
|
9934
|
-
}
|
|
9935
|
-
/** Tile width in pixels. */
|
|
9936
|
-
get tileWidth() {
|
|
9937
|
-
return this.image.tileSize.width;
|
|
9938
|
-
}
|
|
9939
|
-
/** Tile height in pixels. */
|
|
9940
|
-
get tileHeight() {
|
|
9941
|
-
return this.image.tileSize.height;
|
|
9942
|
-
}
|
|
9943
|
-
/** The no data value, or null if not set. */
|
|
9944
|
-
get nodata() {
|
|
9945
|
-
return this.image.noData;
|
|
9946
|
-
}
|
|
9947
|
-
/** Whether the primary image is tiled. */
|
|
9948
|
-
get isTiled() {
|
|
9949
|
-
return this.image.isTiled();
|
|
9950
|
-
}
|
|
9951
|
-
/**
|
|
9952
|
-
* The pre-existing statistics for each band, if available.
|
|
9953
|
-
*
|
|
9954
|
-
* Extracted from the GDALMetadata TIFF tag; never computed on demand.
|
|
9955
|
-
* Keys are **1-based** band indices to match GDAL's convention.
|
|
9956
|
-
*
|
|
9957
|
-
* Returns `null` if no statistics are stored in the file.
|
|
9958
|
-
*/
|
|
9959
|
-
get storedStats() {
|
|
9960
|
-
const stats = this.gdalMetadata?.bandStatistics;
|
|
9961
|
-
return stats && stats.size > 0 ? stats : null;
|
|
9962
|
-
}
|
|
9963
|
-
/**
|
|
9964
|
-
* The offset for each band (0-indexed), defaulting to 0.
|
|
9965
|
-
*
|
|
9966
|
-
* Extracted from the GDALMetadata TIFF tag.
|
|
9967
|
-
*/
|
|
9968
|
-
get offsets() {
|
|
9969
|
-
return this.gdalMetadata?.offsets ?? Array(this.count).fill(0);
|
|
9970
|
-
}
|
|
9971
|
-
/**
|
|
9972
|
-
* The scale for each band (0-indexed), defaulting to 1.
|
|
9973
|
-
*
|
|
9974
|
-
* Extracted from the GDALMetadata TIFF tag.
|
|
9975
|
-
*/
|
|
9976
|
-
get scales() {
|
|
9977
|
-
return this.gdalMetadata?.scales ?? Array(this.count).fill(1);
|
|
9978
|
-
}
|
|
9979
|
-
/** Number of bands (samples per pixel). */
|
|
9980
|
-
get count() {
|
|
9981
|
-
return this.image.value(TiffTag.SamplesPerPixel) ?? 1;
|
|
9982
|
-
}
|
|
9983
|
-
/** Bounding box [minX, minY, maxX, maxY] in the CRS. */
|
|
9984
|
-
get bbox() {
|
|
9985
|
-
return this.image.bbox;
|
|
9986
|
-
}
|
|
9987
|
-
/**
|
|
9988
|
-
* Return the dataset's georeferencing transformation matrix.
|
|
9989
|
-
*/
|
|
9990
|
-
get transform() {
|
|
9991
|
-
const { modelPixelScale, modelTiepoint, modelTransformation } = this.cachedTags;
|
|
9992
|
-
return createTransform({
|
|
9993
|
-
modelTiepoint,
|
|
9994
|
-
modelPixelScale,
|
|
9995
|
-
modelTransformation,
|
|
9996
|
-
rasterType: this.gkd.rasterType
|
|
9997
|
-
});
|
|
9998
|
-
}
|
|
9999
|
-
/** Fetch a single tile from the full-resolution image.
|
|
10000
|
-
*
|
|
10001
|
-
* @param x The tile column index (0-based).
|
|
10002
|
-
* @param y The tile row index (0-based).
|
|
10003
|
-
* @param options Optional parameters for fetching the tile.
|
|
10004
|
-
* @param options.boundless Whether to clip tiles that are partially outside the image bounds. When `true`, no clipping is applied and edge tiles are returned at the full nominal tile size. Defaults to `true`.
|
|
10005
|
-
* @param options.pool An optional {@link DecoderPool} for decoding the tile data. If not provided, a new decoder will be created for each tile.
|
|
10006
|
-
* @param options.signal An optional {@link AbortSignal} to cancel the fetch request.
|
|
10007
|
-
*/
|
|
10008
|
-
async fetchTile(x, y, options = {}) {
|
|
10009
|
-
return await fetchTile(this, x, y, options);
|
|
10010
|
-
}
|
|
10011
|
-
/**
|
|
10012
|
-
* Fetch multiple tiles in parallel.
|
|
10013
|
-
*
|
|
10014
|
-
* A future implementation may coalesce contiguous byte ranges to reduce
|
|
10015
|
-
* the number of HTTP requests.
|
|
10016
|
-
*
|
|
10017
|
-
* @param xy - Array of `[x, y]` tile coordinates.
|
|
10018
|
-
* @param options - Optional parameters (same as {@link fetchTile}).
|
|
10019
|
-
* @returns Array of {@link Tile} objects in the same order as `xy`.
|
|
10020
|
-
*
|
|
10021
|
-
* @see {@link fetchTile} for single-tile fetching.
|
|
10022
|
-
*/
|
|
10023
|
-
async fetchTiles(xy, options = {}) {
|
|
10024
|
-
return await fetchTiles(this, xy, options);
|
|
10025
|
-
}
|
|
10026
|
-
/**
|
|
10027
|
-
* Get the (row, col) pixel index containing the geographic coordinate (x, y).
|
|
10028
|
-
*
|
|
10029
|
-
* @param x x coordinate in the CRS.
|
|
10030
|
-
* @param y y coordinate in the CRS.
|
|
10031
|
-
* @param op Rounding function applied to fractional pixel indices.
|
|
10032
|
-
* Defaults to Math.floor.
|
|
10033
|
-
* @returns [row, col] pixel indices.
|
|
10034
|
-
*/
|
|
10035
|
-
index(x, y, op = Math.floor) {
|
|
10036
|
-
return index(this, x, y, op);
|
|
10037
|
-
}
|
|
10038
|
-
/**
|
|
10039
|
-
* Get the geographic (x, y) coordinate of the pixel at (row, col).
|
|
10040
|
-
*
|
|
10041
|
-
* @param row Pixel row.
|
|
10042
|
-
* @param col Pixel column.
|
|
10043
|
-
* @param offset Which part of the pixel to return. Defaults to "center".
|
|
10044
|
-
* @returns [x, y] in the CRS.
|
|
10045
|
-
*/
|
|
10046
|
-
xy(row, col, offset = "center") {
|
|
10047
|
-
return xy(this, row, col, offset);
|
|
10048
|
-
}
|
|
10049
|
-
};
|
|
10050
|
-
/**
|
|
10051
|
-
* Determine whether a TiffImage is a mask IFD.
|
|
10052
|
-
*
|
|
10053
|
-
* A mask IFD has SubFileType with the Mask bit set (value 4) AND
|
|
10054
|
-
* PhotometricInterpretation === Mask (4).
|
|
10055
|
-
*/
|
|
10056
|
-
function isMaskIfd(image) {
|
|
10057
|
-
const subFileType = image.value(TiffTag.SubFileType);
|
|
10058
|
-
const photometric = image.value(TiffTag.Photometric);
|
|
10059
|
-
return subFileType !== null && (subFileType & SubFileType.Mask) !== 0 && photometric === Photometric.Mask;
|
|
10060
|
-
}
|
|
10061
|
-
//#endregion
|
|
10062
|
-
//#region node_modules/@developmentseed/geotiff/dist/pool/wrapper.js
|
|
10063
|
-
/**
|
|
10064
|
-
* Wraps a Worker, tracking in-flight jobs and routing responses via jobId.
|
|
10065
|
-
*/
|
|
10066
|
-
var WorkerWrapper = class {
|
|
10067
|
-
worker;
|
|
10068
|
-
jobIdCounter = 0;
|
|
10069
|
-
jobs = /* @__PURE__ */ new Map();
|
|
10070
|
-
constructor(worker) {
|
|
10071
|
-
this.worker = worker;
|
|
10072
|
-
this.worker.addEventListener("message", (e) => this.onMessage(e));
|
|
10073
|
-
}
|
|
10074
|
-
get jobCount() {
|
|
10075
|
-
return this.jobs.size;
|
|
10076
|
-
}
|
|
10077
|
-
onMessage(e) {
|
|
10078
|
-
const { jobId, error, pixels } = e.data;
|
|
10079
|
-
const job = this.jobs.get(jobId);
|
|
10080
|
-
this.jobs.delete(jobId);
|
|
10081
|
-
if (!job) return;
|
|
10082
|
-
if (error) job.reject(new Error(error));
|
|
10083
|
-
else job.resolve(pixels);
|
|
10084
|
-
}
|
|
10085
|
-
submitJob(request, transferables) {
|
|
10086
|
-
const jobId = this.jobIdCounter++;
|
|
10087
|
-
return new Promise((resolve, reject) => {
|
|
10088
|
-
this.jobs.set(jobId, {
|
|
10089
|
-
resolve,
|
|
10090
|
-
reject
|
|
10091
|
-
});
|
|
10092
|
-
this.worker.postMessage({
|
|
10093
|
-
...request,
|
|
10094
|
-
jobId
|
|
10095
|
-
}, { transfer: transferables });
|
|
10096
|
-
});
|
|
10097
|
-
}
|
|
10098
|
-
terminate() {
|
|
10099
|
-
this.worker.terminate();
|
|
10100
|
-
}
|
|
10101
|
-
};
|
|
10102
|
-
//#endregion
|
|
10103
|
-
//#region node_modules/@developmentseed/geotiff/dist/pool/pool.js
|
|
10104
|
-
var defaultSize = typeof navigator !== "undefined" ? navigator.hardwareConcurrency ?? 2 : 2;
|
|
10105
|
-
/**
|
|
10106
|
-
* Manages a pool of Web Workers for off-main-thread tile decoding.
|
|
10107
|
-
*
|
|
10108
|
-
* Use {@link defaultDecoderPool} to create a pool backed by the built-in,
|
|
10109
|
-
* default decompressors.
|
|
10110
|
-
*
|
|
10111
|
-
* When no `createWorker` factory is provided, decoding falls back to the main
|
|
10112
|
-
* thread. This lets the pool be constructed unconditionally and wired up with
|
|
10113
|
-
* a worker later (or never, for SSR / Node environments).
|
|
10114
|
-
*/
|
|
10115
|
-
var DecoderPool = class {
|
|
10116
|
-
workerWrappers;
|
|
10117
|
-
constructor(options = {}) {
|
|
10118
|
-
const { size = defaultSize, createWorker } = options;
|
|
10119
|
-
this.workerWrappers = [];
|
|
10120
|
-
if (createWorker && size > 0) for (let i = 0; i < size; i++) this.workerWrappers.push(new WorkerWrapper(createWorker()));
|
|
10121
|
-
}
|
|
10122
|
-
/** True when workers are available for off-main-thread decoding. */
|
|
10123
|
-
get hasWorkers() {
|
|
10124
|
-
return this.workerWrappers.length > 0;
|
|
10125
|
-
}
|
|
10126
|
-
/**
|
|
10127
|
-
* Decode a compressed tile buffer.
|
|
10128
|
-
*
|
|
10129
|
-
* When workers are available, the compressed `bytes` buffer is transferred
|
|
10130
|
-
* zero-copy to the least-loaded worker. The returned `DecodedPixels` typed
|
|
10131
|
-
* array buffers are transferred back to the main thread.
|
|
10132
|
-
*
|
|
10133
|
-
* When no workers are available, decoding runs on the main thread via the
|
|
10134
|
-
* normal `decode()` path.
|
|
10135
|
-
*/
|
|
10136
|
-
async decode(bytes, compression, metadata) {
|
|
10137
|
-
if (!this.hasWorkers) return decode$1(bytes, compression, metadata);
|
|
10138
|
-
const worker = this.leastLoaded();
|
|
10139
|
-
const request = {
|
|
10140
|
-
compression,
|
|
10141
|
-
metadata,
|
|
10142
|
-
buffer: bytes
|
|
10143
|
-
};
|
|
10144
|
-
return await worker.submitJob(request, [bytes]);
|
|
10145
|
-
}
|
|
10146
|
-
/** Terminate all workers and release resources. */
|
|
10147
|
-
destroy() {
|
|
10148
|
-
for (const w of this.workerWrappers) w.terminate();
|
|
10149
|
-
this.workerWrappers.length = 0;
|
|
10150
|
-
}
|
|
10151
|
-
leastLoaded() {
|
|
10152
|
-
let best = this.workerWrappers[0];
|
|
10153
|
-
for (let i = 1; i < this.workerWrappers.length; i++) if (this.workerWrappers[i].jobCount < best.jobCount) best = this.workerWrappers[i];
|
|
10154
|
-
return best;
|
|
10155
|
-
}
|
|
10156
|
-
};
|
|
10157
|
-
/**
|
|
10158
|
-
* A default DecoderPool instance.
|
|
10159
|
-
*
|
|
10160
|
-
* It will be created on first call of `defaultDecoderPool`.
|
|
10161
|
-
*/
|
|
10162
|
-
var DEFAULT_POOL = null;
|
|
10163
|
-
/**
|
|
10164
|
-
* Create a default `DecoderPool` backed by the built-in worker.
|
|
10165
|
-
*
|
|
10166
|
-
* A cached decoder pool instance is returned on subsequent calls.
|
|
10167
|
-
*
|
|
10168
|
-
* You may want to create it lazily (rather than as a module-level singleton)
|
|
10169
|
-
* to keep the `new URL(…, import.meta.url)` out of the module's static
|
|
10170
|
-
* initialisation, so bundlers that build IIFE/UMD outputs don't try to inline
|
|
10171
|
-
* the worker at build time.
|
|
10172
|
-
*
|
|
10173
|
-
* @example
|
|
10174
|
-
* Create a default decoder pool:
|
|
10175
|
-
* ```
|
|
10176
|
-
* const pool = defaultDecoderPool();
|
|
10177
|
-
* ```
|
|
10178
|
-
*/
|
|
10179
|
-
function defaultDecoderPool() {
|
|
10180
|
-
if (DEFAULT_POOL !== null) return DEFAULT_POOL;
|
|
10181
|
-
DEFAULT_POOL = new DecoderPool({ createWorker: () => new Worker(new URL(
|
|
10182
|
-
/* @vite-ignore */
|
|
10183
|
-
"/assets/worker-CcHZ_QZT.js",
|
|
10184
|
-
"" + import.meta.url
|
|
10185
|
-
), { type: "module" }) });
|
|
10186
|
-
return DEFAULT_POOL;
|
|
10187
|
-
}
|
|
10188
|
-
//#endregion
|
|
10189
|
-
//#region node_modules/proj4/lib/global.js
|
|
10190
|
-
function global_default(defs) {
|
|
10191
|
-
defs("EPSG:4326", "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
|
|
10192
|
-
defs("EPSG:4269", "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees");
|
|
10193
|
-
defs("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
|
|
10194
|
-
for (var i = 1; i <= 60; ++i) {
|
|
10195
|
-
defs("EPSG:" + (32600 + i), "+proj=utm +zone=" + i + " +datum=WGS84 +units=m");
|
|
10196
|
-
defs("EPSG:" + (32700 + i), "+proj=utm +zone=" + i + " +south +datum=WGS84 +units=m");
|
|
10197
|
-
}
|
|
10198
|
-
defs("EPSG:5041", "+title=WGS 84 / UPS North (E,N) +proj=stere +lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m");
|
|
10199
|
-
defs("EPSG:5042", "+title=WGS 84 / UPS South (E,N) +proj=stere +lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m");
|
|
10200
|
-
defs.WGS84 = defs["EPSG:4326"];
|
|
10201
|
-
defs["EPSG:3785"] = defs["EPSG:3857"];
|
|
10202
|
-
defs.GOOGLE = defs["EPSG:3857"];
|
|
10203
|
-
defs["EPSG:900913"] = defs["EPSG:3857"];
|
|
10204
|
-
defs["EPSG:102113"] = defs["EPSG:3857"];
|
|
10205
|
-
}
|
|
10206
|
-
//#endregion
|
|
10207
|
-
//#region node_modules/proj4/lib/constants/values.js
|
|
10208
|
-
var SRS_WGS84_SEMIMAJOR = 6378137;
|
|
10209
|
-
var SRS_WGS84_SEMIMINOR = 6356752.314;
|
|
10210
|
-
var SRS_WGS84_ESQUARED = .0066943799901413165;
|
|
10211
|
-
var SEC_TO_RAD = 484813681109536e-20;
|
|
10212
|
-
var HALF_PI = Math.PI / 2;
|
|
10213
|
-
var SIXTH = .16666666666666666;
|
|
10214
|
-
var RA4 = .04722222222222222;
|
|
10215
|
-
var RA6 = .022156084656084655;
|
|
10216
|
-
var EPSLN = 1e-10;
|
|
10217
|
-
var D2R = .017453292519943295;
|
|
10218
|
-
var R2D = 57.29577951308232;
|
|
10219
|
-
var FORTPI = Math.PI / 4;
|
|
10220
|
-
var TWO_PI = Math.PI * 2;
|
|
10221
|
-
var SPI = 3.14159265359;
|
|
10222
|
-
//#endregion
|
|
10223
|
-
//#region node_modules/proj4/lib/constants/PrimeMeridian.js
|
|
10224
|
-
var primeMeridian = {};
|
|
10225
|
-
primeMeridian.greenwich = 0;
|
|
10226
|
-
primeMeridian.lisbon = -9.131906111111;
|
|
10227
|
-
primeMeridian.paris = 2.337229166667;
|
|
10228
|
-
primeMeridian.bogota = -74.080916666667;
|
|
10229
|
-
primeMeridian.madrid = -3.687938888889;
|
|
10230
|
-
primeMeridian.rome = 12.452333333333;
|
|
10231
|
-
primeMeridian.bern = 7.439583333333;
|
|
10232
|
-
primeMeridian.jakarta = 106.807719444444;
|
|
10233
|
-
primeMeridian.ferro = -17.666666666667;
|
|
10234
|
-
primeMeridian.brussels = 4.367975;
|
|
10235
|
-
primeMeridian.stockholm = 18.058277777778;
|
|
10236
|
-
primeMeridian.athens = 23.7163375;
|
|
10237
|
-
primeMeridian.oslo = 10.722916666667;
|
|
10238
|
-
//#endregion
|
|
10239
|
-
//#region node_modules/proj4/lib/constants/units.js
|
|
10240
|
-
var units_default = {
|
|
10241
|
-
mm: { to_meter: .001 },
|
|
10242
|
-
cm: { to_meter: .01 },
|
|
10243
|
-
ft: { to_meter: .3048 },
|
|
10244
|
-
"us-ft": { to_meter: 1200 / 3937 },
|
|
10245
|
-
fath: { to_meter: 1.8288 },
|
|
10246
|
-
kmi: { to_meter: 1852 },
|
|
10247
|
-
"us-ch": { to_meter: 20.1168402336805 },
|
|
10248
|
-
"us-mi": { to_meter: 1609.34721869444 },
|
|
10249
|
-
km: { to_meter: 1e3 },
|
|
10250
|
-
"ind-ft": { to_meter: .30479841 },
|
|
10251
|
-
"ind-yd": { to_meter: .91439523 },
|
|
10252
|
-
mi: { to_meter: 1609.344 },
|
|
10253
|
-
yd: { to_meter: .9144 },
|
|
10254
|
-
ch: { to_meter: 20.1168 },
|
|
10255
|
-
link: { to_meter: .201168 },
|
|
10256
|
-
dm: { to_meter: .1 },
|
|
10257
|
-
in: { to_meter: .0254 },
|
|
10258
|
-
"ind-ch": { to_meter: 20.11669506 },
|
|
10259
|
-
"us-in": { to_meter: .025400050800101 },
|
|
10260
|
-
"us-yd": { to_meter: .914401828803658 }
|
|
10261
|
-
};
|
|
10262
|
-
//#endregion
|
|
10263
|
-
//#region node_modules/proj4/lib/match.js
|
|
10264
|
-
var ignoredChar = /[\s_\-\/\(\)]/g;
|
|
10265
|
-
function match(obj, key) {
|
|
10266
|
-
if (obj[key]) return obj[key];
|
|
10267
|
-
var keys = Object.keys(obj);
|
|
10268
|
-
var lkey = key.toLowerCase().replace(ignoredChar, "");
|
|
10269
|
-
var i = -1;
|
|
10270
|
-
var testkey, processedKey;
|
|
10271
|
-
while (++i < keys.length) {
|
|
10272
|
-
testkey = keys[i];
|
|
10273
|
-
processedKey = testkey.toLowerCase().replace(ignoredChar, "");
|
|
10274
|
-
if (processedKey === lkey) return obj[testkey];
|
|
10275
|
-
}
|
|
10276
|
-
}
|
|
10277
|
-
//#endregion
|
|
10278
|
-
//#region node_modules/proj4/lib/projString.js
|
|
10279
|
-
/**
|
|
10280
|
-
* @param {string} defData
|
|
10281
|
-
* @returns {import('./defs').ProjectionDefinition}
|
|
8915
|
+
* @param {string} defData
|
|
8916
|
+
* @returns {import('./defs').ProjectionDefinition}
|
|
10282
8917
|
*/
|
|
10283
8918
|
function projString_default(defData) {
|
|
10284
8919
|
/** @type {import('./defs').ProjectionDefinition} */
|
|
@@ -17649,667 +16284,958 @@ var COGLayer = class extends RasterTileLayer {
|
|
|
17649
16284
|
};
|
|
17650
16285
|
return wrapped;
|
|
17651
16286
|
}
|
|
17652
|
-
_renderTileCallback() {
|
|
17653
|
-
const userFn = this.props.renderTile ?? this.state.defaultRenderTile;
|
|
17654
|
-
if (!userFn) return;
|
|
17655
|
-
return userFn;
|
|
16287
|
+
_renderTileCallback() {
|
|
16288
|
+
const userFn = this.props.renderTile ?? this.state.defaultRenderTile;
|
|
16289
|
+
if (!userFn) return;
|
|
16290
|
+
return userFn;
|
|
16291
|
+
}
|
|
16292
|
+
};
|
|
16293
|
+
//#endregion
|
|
16294
|
+
//#region node_modules/flatqueue/index.js
|
|
16295
|
+
/**
|
|
16296
|
+
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
16297
|
+
* Uint32ArrayConstructor | Int32ArrayConstructor | Uint16ArrayConstructor |
|
|
16298
|
+
* Int16ArrayConstructor | Uint8ArrayConstructor | Int8ArrayConstructor} TypedArrayConstructor
|
|
16299
|
+
*/
|
|
16300
|
+
/** @template [T=number] */
|
|
16301
|
+
var FlatQueue = class {
|
|
16302
|
+
/**
|
|
16303
|
+
* Creates an empty queue. If `capacity` is provided, the queue is backed by fixed-size typed
|
|
16304
|
+
* arrays for better performance and memory use, but can't grow beyond `capacity`. `values` uses
|
|
16305
|
+
* `ValuesArray` (default `Float64Array`) and `ids` uses `IdsArray` (default `Uint32Array`); pass
|
|
16306
|
+
* narrower constructors like `Uint16Array` if your values or ids are known to fit them.
|
|
16307
|
+
*
|
|
16308
|
+
* @param {number} [capacity]
|
|
16309
|
+
* @param {TypedArrayConstructor} [ValuesArray]
|
|
16310
|
+
* @param {TypedArrayConstructor} [IdsArray]
|
|
16311
|
+
*/
|
|
16312
|
+
constructor(capacity = Infinity, ValuesArray = Float64Array, IdsArray = Uint32Array) {
|
|
16313
|
+
const fixed = capacity !== Infinity;
|
|
16314
|
+
/** @type {T[]} */
|
|
16315
|
+
this.ids = fixed ? new IdsArray(capacity) : [];
|
|
16316
|
+
/** @type {number[]} */
|
|
16317
|
+
this.values = fixed ? new ValuesArray(capacity) : [];
|
|
16318
|
+
/** Maximum number of items the queue can hold; `Infinity` for regular-array queues, which grow on demand. */
|
|
16319
|
+
this.capacity = capacity;
|
|
16320
|
+
/** Number of items in the queue. */
|
|
16321
|
+
this.length = 0;
|
|
16322
|
+
}
|
|
16323
|
+
/** Removes all items from the queue. */
|
|
16324
|
+
clear() {
|
|
16325
|
+
this.length = 0;
|
|
16326
|
+
}
|
|
16327
|
+
/**
|
|
16328
|
+
* Adds `item` to the queue with the specified `priority`.
|
|
16329
|
+
*
|
|
16330
|
+
* `priority` must be a number. Items are sorted and returned from low to high priority. Multiple items
|
|
16331
|
+
* with the same priority value can be added to the queue, but there is no guaranteed order between these items.
|
|
16332
|
+
*
|
|
16333
|
+
* For fixed-capacity queues, throws a `RangeError` if the queue is already full.
|
|
16334
|
+
*
|
|
16335
|
+
* @param {T} item
|
|
16336
|
+
* @param {number} priority
|
|
16337
|
+
*/
|
|
16338
|
+
push(item, priority) {
|
|
16339
|
+
if (this.length === this.capacity) throw new RangeError("Queue is at capacity.");
|
|
16340
|
+
let pos = this.length++;
|
|
16341
|
+
while (pos > 0) {
|
|
16342
|
+
const parent = pos - 1 >> 1;
|
|
16343
|
+
const parentValue = this.values[parent];
|
|
16344
|
+
if (priority >= parentValue) break;
|
|
16345
|
+
this.ids[pos] = this.ids[parent];
|
|
16346
|
+
this.values[pos] = parentValue;
|
|
16347
|
+
pos = parent;
|
|
16348
|
+
}
|
|
16349
|
+
this.ids[pos] = item;
|
|
16350
|
+
this.values[pos] = priority;
|
|
16351
|
+
}
|
|
16352
|
+
/**
|
|
16353
|
+
* Removes and returns the item from the head of this queue, which is one of
|
|
16354
|
+
* the items with the lowest priority. If this queue is empty, returns `undefined`.
|
|
16355
|
+
*/
|
|
16356
|
+
pop() {
|
|
16357
|
+
if (this.length === 0) return void 0;
|
|
16358
|
+
const ids = this.ids, values = this.values, top = ids[0], last = --this.length;
|
|
16359
|
+
if (last > 0) {
|
|
16360
|
+
const id = ids[last];
|
|
16361
|
+
const value = values[last];
|
|
16362
|
+
let pos = 0;
|
|
16363
|
+
const halfLen = last >> 1;
|
|
16364
|
+
while (pos < halfLen) {
|
|
16365
|
+
const left = (pos << 1) + 1;
|
|
16366
|
+
const right = left + 1;
|
|
16367
|
+
const child = left + (+(right < last) & +(values[right] < values[left]));
|
|
16368
|
+
if (values[child] >= value) break;
|
|
16369
|
+
ids[pos] = ids[child];
|
|
16370
|
+
values[pos] = values[child];
|
|
16371
|
+
pos = child;
|
|
16372
|
+
}
|
|
16373
|
+
ids[pos] = id;
|
|
16374
|
+
values[pos] = value;
|
|
16375
|
+
}
|
|
16376
|
+
return top;
|
|
16377
|
+
}
|
|
16378
|
+
/** Returns the item from the head of this queue without removing it. If this queue is empty, returns `undefined`. */
|
|
16379
|
+
peek() {
|
|
16380
|
+
return this.length > 0 ? this.ids[0] : void 0;
|
|
16381
|
+
}
|
|
16382
|
+
/**
|
|
16383
|
+
* Returns the priority value of the item at the head of this queue without
|
|
16384
|
+
* removing it. If this queue is empty, returns `undefined`.
|
|
16385
|
+
*/
|
|
16386
|
+
peekValue() {
|
|
16387
|
+
return this.length > 0 ? this.values[0] : void 0;
|
|
16388
|
+
}
|
|
16389
|
+
/**
|
|
16390
|
+
* Shrinks the internal arrays to `this.length`. No-op for queues with fixed capacity.
|
|
16391
|
+
*
|
|
16392
|
+
* `pop()` and `clear()` calls don't free memory automatically to avoid unnecessary resize operations.
|
|
16393
|
+
* This also means that items that have been added to the queue can't be garbage collected until
|
|
16394
|
+
* a new item is pushed in their place, or this method is called.
|
|
16395
|
+
*/
|
|
16396
|
+
shrink() {
|
|
16397
|
+
if (Array.isArray(this.ids)) this.ids.length = this.length;
|
|
16398
|
+
if (Array.isArray(this.values)) this.values.length = this.length;
|
|
16399
|
+
}
|
|
16400
|
+
};
|
|
16401
|
+
//#endregion
|
|
16402
|
+
//#region node_modules/flatbush/index.js
|
|
16403
|
+
var ARRAY_TYPES = [
|
|
16404
|
+
Int8Array,
|
|
16405
|
+
Uint8Array,
|
|
16406
|
+
Uint8ClampedArray,
|
|
16407
|
+
Int16Array,
|
|
16408
|
+
Uint16Array,
|
|
16409
|
+
Int32Array,
|
|
16410
|
+
Uint32Array,
|
|
16411
|
+
Float32Array,
|
|
16412
|
+
Float64Array
|
|
16413
|
+
];
|
|
16414
|
+
var VERSION = 3;
|
|
16415
|
+
/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */
|
|
16416
|
+
/** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray */
|
|
16417
|
+
var Flatbush = class Flatbush {
|
|
16418
|
+
/**
|
|
16419
|
+
* Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
|
|
16420
|
+
* @param {ArrayBufferLike} data
|
|
16421
|
+
* @param {number} [byteOffset=0] byte offset to the start of the Flatbush buffer in the referenced ArrayBuffer.
|
|
16422
|
+
* @returns {Flatbush} index
|
|
16423
|
+
*/
|
|
16424
|
+
static from(data, byteOffset = 0) {
|
|
16425
|
+
if (byteOffset % 8 !== 0) throw new Error("byteOffset must be 8-byte aligned.");
|
|
16426
|
+
if (!data || data.byteLength === void 0 || "buffer" in data) throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");
|
|
16427
|
+
const [magic, versionAndType] = new Uint8Array(data, byteOffset + 0, 2);
|
|
16428
|
+
if (magic !== 251) throw new Error("Data does not appear to be in a Flatbush format.");
|
|
16429
|
+
const version = versionAndType >> 4;
|
|
16430
|
+
if (version !== VERSION) throw new Error(`Got v${version} data when expected v${VERSION}.`);
|
|
16431
|
+
const ArrayType = ARRAY_TYPES[versionAndType & 15];
|
|
16432
|
+
if (!ArrayType) throw new Error("Unrecognized array type.");
|
|
16433
|
+
const [nodeSize] = new Uint16Array(data, byteOffset + 2, 1);
|
|
16434
|
+
const [numItems] = new Uint32Array(data, byteOffset + 4, 1);
|
|
16435
|
+
return new Flatbush(numItems, nodeSize, ArrayType, void 0, data, byteOffset);
|
|
16436
|
+
}
|
|
16437
|
+
/**
|
|
16438
|
+
* Create a Flatbush index that will hold a given number of items.
|
|
16439
|
+
* @param {number} numItems
|
|
16440
|
+
* @param {number} [nodeSize=16] Size of the tree node (16 by default).
|
|
16441
|
+
* @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
|
|
16442
|
+
* @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used to store data (`ArrayBuffer` by default).
|
|
16443
|
+
* @param {ArrayBufferLike} [data] (Only used internally)
|
|
16444
|
+
* @param {number} [byteOffset=0] (Only used internally)
|
|
16445
|
+
*/
|
|
16446
|
+
constructor(numItems, nodeSize = 16, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data, byteOffset = 0) {
|
|
16447
|
+
if (numItems === void 0) throw new Error("Missing required argument: numItems.");
|
|
16448
|
+
if (isNaN(numItems) || numItems <= 0) throw new Error(`Unexpected numItems value: ${numItems}.`);
|
|
16449
|
+
this.numItems = +numItems;
|
|
16450
|
+
this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);
|
|
16451
|
+
this.byteOffset = byteOffset;
|
|
16452
|
+
let n = numItems;
|
|
16453
|
+
let numNodes = n;
|
|
16454
|
+
this._levelBounds = [n * 4];
|
|
16455
|
+
do {
|
|
16456
|
+
n = Math.ceil(n / this.nodeSize);
|
|
16457
|
+
numNodes += n;
|
|
16458
|
+
this._levelBounds.push(numNodes * 4);
|
|
16459
|
+
} while (n !== 1);
|
|
16460
|
+
this.ArrayType = ArrayType;
|
|
16461
|
+
this.IndexArrayType = numNodes < 16384 ? Uint16Array : Uint32Array;
|
|
16462
|
+
const arrayTypeIndex = ARRAY_TYPES.indexOf(ArrayType);
|
|
16463
|
+
const nodesByteSize = numNodes * 4 * ArrayType.BYTES_PER_ELEMENT;
|
|
16464
|
+
if (arrayTypeIndex < 0) throw new Error(`Unexpected typed array class: ${ArrayType}.`);
|
|
16465
|
+
/** @type {new(b: ArrayBufferLike, o: number, l: number) => TypedArray} */
|
|
16466
|
+
const BoxCtor = ArrayType;
|
|
16467
|
+
/** @type {new(b: ArrayBufferLike, o: number, l: number) => Uint16Array | Uint32Array} */
|
|
16468
|
+
const IdxCtor = this.IndexArrayType;
|
|
16469
|
+
if (data) {
|
|
16470
|
+
this.data = data;
|
|
16471
|
+
this._boxes = new BoxCtor(data, byteOffset + 8, numNodes * 4);
|
|
16472
|
+
this._indices = new IdxCtor(data, byteOffset + 8 + nodesByteSize, numNodes);
|
|
16473
|
+
this._pos = numNodes * 4;
|
|
16474
|
+
this.minX = this._boxes[this._pos - 4];
|
|
16475
|
+
this.minY = this._boxes[this._pos - 3];
|
|
16476
|
+
this.maxX = this._boxes[this._pos - 2];
|
|
16477
|
+
this.maxY = this._boxes[this._pos - 1];
|
|
16478
|
+
} else {
|
|
16479
|
+
const data = this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
|
|
16480
|
+
this._boxes = new BoxCtor(data, 8, numNodes * 4);
|
|
16481
|
+
this._indices = new IdxCtor(data, 8 + nodesByteSize, numNodes);
|
|
16482
|
+
this._pos = 0;
|
|
16483
|
+
this.minX = Infinity;
|
|
16484
|
+
this.minY = Infinity;
|
|
16485
|
+
this.maxX = -Infinity;
|
|
16486
|
+
this.maxY = -Infinity;
|
|
16487
|
+
new Uint8Array(data, 0, 2).set([251, (VERSION << 4) + arrayTypeIndex]);
|
|
16488
|
+
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
16489
|
+
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
16490
|
+
}
|
|
16491
|
+
/** @type FlatQueue<number> */
|
|
16492
|
+
this._queue = new FlatQueue();
|
|
16493
|
+
}
|
|
16494
|
+
/**
|
|
16495
|
+
* Add a given rectangle to the index.
|
|
16496
|
+
* @param {number} minX
|
|
16497
|
+
* @param {number} minY
|
|
16498
|
+
* @param {number} maxX
|
|
16499
|
+
* @param {number} maxY
|
|
16500
|
+
* @returns {number} A zero-based, incremental number that represents the newly added rectangle.
|
|
16501
|
+
*/
|
|
16502
|
+
add(minX, minY, maxX = minX, maxY = minY) {
|
|
16503
|
+
const index = this._pos >> 2;
|
|
16504
|
+
const boxes = this._boxes;
|
|
16505
|
+
this._indices[index] = index;
|
|
16506
|
+
boxes[this._pos++] = minX;
|
|
16507
|
+
boxes[this._pos++] = minY;
|
|
16508
|
+
boxes[this._pos++] = maxX;
|
|
16509
|
+
boxes[this._pos++] = maxY;
|
|
16510
|
+
if (minX < this.minX) this.minX = minX;
|
|
16511
|
+
if (minY < this.minY) this.minY = minY;
|
|
16512
|
+
if (maxX > this.maxX) this.maxX = maxX;
|
|
16513
|
+
if (maxY > this.maxY) this.maxY = maxY;
|
|
16514
|
+
return index;
|
|
16515
|
+
}
|
|
16516
|
+
/** Perform indexing of the added rectangles. */
|
|
16517
|
+
finish() {
|
|
16518
|
+
if (this._pos >> 2 !== this.numItems) throw new Error(`Added ${this._pos >> 2} items when expected ${this.numItems}.`);
|
|
16519
|
+
const boxes = this._boxes;
|
|
16520
|
+
if (this.numItems <= this.nodeSize) {
|
|
16521
|
+
boxes[this._pos++] = this.minX;
|
|
16522
|
+
boxes[this._pos++] = this.minY;
|
|
16523
|
+
boxes[this._pos++] = this.maxX;
|
|
16524
|
+
boxes[this._pos++] = this.maxY;
|
|
16525
|
+
return;
|
|
16526
|
+
}
|
|
16527
|
+
const width = this.maxX - this.minX || 1;
|
|
16528
|
+
const height = this.maxY - this.minY || 1;
|
|
16529
|
+
const hilbertValues = new Int32Array(this.numItems);
|
|
16530
|
+
const hilbertMax = 65535;
|
|
16531
|
+
for (let i = 0, pos = 0; i < this.numItems; i++) {
|
|
16532
|
+
const minX = boxes[pos++];
|
|
16533
|
+
const minY = boxes[pos++];
|
|
16534
|
+
const maxX = boxes[pos++];
|
|
16535
|
+
const maxY = boxes[pos++];
|
|
16536
|
+
hilbertValues[i] = hilbert(Math.floor(hilbertMax * ((minX + maxX) / 2 - this.minX) / width), Math.floor(hilbertMax * ((minY + maxY) / 2 - this.minY) / height));
|
|
16537
|
+
}
|
|
16538
|
+
sort(hilbertValues, boxes, this._indices, 0, this.numItems - 1, this.nodeSize);
|
|
16539
|
+
for (let i = 0, pos = 0; i < this._levelBounds.length - 1; i++) {
|
|
16540
|
+
const end = this._levelBounds[i];
|
|
16541
|
+
while (pos < end) {
|
|
16542
|
+
const nodeIndex = pos;
|
|
16543
|
+
let nodeMinX = boxes[pos++];
|
|
16544
|
+
let nodeMinY = boxes[pos++];
|
|
16545
|
+
let nodeMaxX = boxes[pos++];
|
|
16546
|
+
let nodeMaxY = boxes[pos++];
|
|
16547
|
+
for (let j = 1; j < this.nodeSize && pos < end; j++) {
|
|
16548
|
+
nodeMinX = Math.min(nodeMinX, boxes[pos++]);
|
|
16549
|
+
nodeMinY = Math.min(nodeMinY, boxes[pos++]);
|
|
16550
|
+
nodeMaxX = Math.max(nodeMaxX, boxes[pos++]);
|
|
16551
|
+
nodeMaxY = Math.max(nodeMaxY, boxes[pos++]);
|
|
16552
|
+
}
|
|
16553
|
+
this._indices[this._pos >> 2] = nodeIndex;
|
|
16554
|
+
boxes[this._pos++] = nodeMinX;
|
|
16555
|
+
boxes[this._pos++] = nodeMinY;
|
|
16556
|
+
boxes[this._pos++] = nodeMaxX;
|
|
16557
|
+
boxes[this._pos++] = nodeMaxY;
|
|
16558
|
+
}
|
|
16559
|
+
}
|
|
17656
16560
|
}
|
|
17657
|
-
};
|
|
17658
|
-
//#endregion
|
|
17659
|
-
//#region node_modules/flatqueue/index.js
|
|
17660
|
-
/**
|
|
17661
|
-
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
17662
|
-
* Uint32ArrayConstructor | Int32ArrayConstructor | Uint16ArrayConstructor |
|
|
17663
|
-
* Int16ArrayConstructor | Uint8ArrayConstructor | Int8ArrayConstructor} TypedArrayConstructor
|
|
17664
|
-
*/
|
|
17665
|
-
/** @template [T=number] */
|
|
17666
|
-
var FlatQueue = class {
|
|
17667
16561
|
/**
|
|
17668
|
-
*
|
|
17669
|
-
*
|
|
17670
|
-
*
|
|
17671
|
-
*
|
|
17672
|
-
*
|
|
17673
|
-
* @param {number} [
|
|
17674
|
-
* @
|
|
17675
|
-
* @param {TypedArrayConstructor} [IdsArray]
|
|
16562
|
+
* Search the index by a bounding box.
|
|
16563
|
+
* @param {number} minX
|
|
16564
|
+
* @param {number} minY
|
|
16565
|
+
* @param {number} maxX
|
|
16566
|
+
* @param {number} maxY
|
|
16567
|
+
* @param {(index: number, x0: number, y0: number, x1: number, y1: number) => boolean} [filterFn] An optional function that is called on every found item; if supplied, only items for which this function returns true will be included in the results array.
|
|
16568
|
+
* @returns {number[]} An array of indices of items intersecting or touching the given bounding box.
|
|
17676
16569
|
*/
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
/** @type
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
16570
|
+
search(minX, minY, maxX, maxY, filterFn) {
|
|
16571
|
+
if (this._pos !== this._boxes.length) throw new Error("Data not yet indexed - call index.finish().");
|
|
16572
|
+
const { _boxes: boxes, _levelBounds: levelBounds, _indices: indices, nodeSize } = this;
|
|
16573
|
+
const numItems4 = this.numItems * 4;
|
|
16574
|
+
/** @type number | undefined */
|
|
16575
|
+
let nodeIndex = boxes.length - 4;
|
|
16576
|
+
let level = levelBounds.length - 1;
|
|
16577
|
+
const q = [];
|
|
16578
|
+
const results = [];
|
|
16579
|
+
let contained = false;
|
|
16580
|
+
while (nodeIndex !== void 0) {
|
|
16581
|
+
const end = Math.min(nodeIndex + nodeSize * 4, levelBounds[level]);
|
|
16582
|
+
const isNode = nodeIndex >= numItems4;
|
|
16583
|
+
if (contained) this._collectContained(nodeIndex, end, level, isNode, q, results, filterFn);
|
|
16584
|
+
else for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
16585
|
+
const x0 = boxes[pos];
|
|
16586
|
+
if (maxX < x0) continue;
|
|
16587
|
+
const y0 = boxes[pos + 1];
|
|
16588
|
+
if (maxY < y0) continue;
|
|
16589
|
+
const x1 = boxes[pos + 2];
|
|
16590
|
+
if (minX > x1) continue;
|
|
16591
|
+
const y1 = boxes[pos + 3];
|
|
16592
|
+
if (minY > y1) continue;
|
|
16593
|
+
const index = indices[pos >> 2] | 0;
|
|
16594
|
+
if (isNode) {
|
|
16595
|
+
const c = +(minX <= x0 && minY <= y0 && maxX >= x1 && maxY >= y1);
|
|
16596
|
+
q.push(index | c, level - 1);
|
|
16597
|
+
} else if (filterFn === void 0 || filterFn(index, x0, y0, x1, y1)) results.push(index);
|
|
16598
|
+
}
|
|
16599
|
+
level = q.pop();
|
|
16600
|
+
nodeIndex = q.pop();
|
|
16601
|
+
if (nodeIndex !== void 0) {
|
|
16602
|
+
contained = (nodeIndex & 1) === 1;
|
|
16603
|
+
nodeIndex &= -2;
|
|
16604
|
+
}
|
|
16605
|
+
}
|
|
16606
|
+
return results;
|
|
17691
16607
|
}
|
|
17692
16608
|
/**
|
|
17693
|
-
*
|
|
17694
|
-
*
|
|
17695
|
-
*
|
|
17696
|
-
*
|
|
17697
|
-
*
|
|
17698
|
-
*
|
|
17699
|
-
*
|
|
17700
|
-
* @param {
|
|
17701
|
-
* @param {number} priority
|
|
16609
|
+
* Collect children of a node whose bbox is fully inside the query, skipping intersection tests.
|
|
16610
|
+
* @param {number} nodeIndex
|
|
16611
|
+
* @param {number} end
|
|
16612
|
+
* @param {number} level
|
|
16613
|
+
* @param {boolean} isNode whether the children are tree nodes (vs leaf items)
|
|
16614
|
+
* @param {number[]} q the traversal queue
|
|
16615
|
+
* @param {number[]} results
|
|
16616
|
+
* @param {((index: number, x0: number, y0: number, x1: number, y1: number) => boolean) | undefined} filterFn
|
|
17702
16617
|
*/
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
const
|
|
17709
|
-
if (
|
|
17710
|
-
this.ids[pos] = this.ids[parent];
|
|
17711
|
-
this.values[pos] = parentValue;
|
|
17712
|
-
pos = parent;
|
|
16618
|
+
_collectContained(nodeIndex, end, level, isNode, q, results, filterFn) {
|
|
16619
|
+
const boxes = this._boxes;
|
|
16620
|
+
const indices = this._indices;
|
|
16621
|
+
if (isNode) for (let pos = nodeIndex; pos < end; pos += 4) q.push(indices[pos >> 2] | 1, level - 1);
|
|
16622
|
+
else for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
16623
|
+
const index = indices[pos >> 2] | 0;
|
|
16624
|
+
if (filterFn === void 0 || filterFn(index, boxes[pos], boxes[pos + 1], boxes[pos + 2], boxes[pos + 3])) results.push(index);
|
|
17713
16625
|
}
|
|
17714
|
-
this.ids[pos] = item;
|
|
17715
|
-
this.values[pos] = priority;
|
|
17716
16626
|
}
|
|
17717
16627
|
/**
|
|
17718
|
-
*
|
|
17719
|
-
*
|
|
16628
|
+
* Search items in order of distance from the given point.
|
|
16629
|
+
* @param {number} x
|
|
16630
|
+
* @param {number} y
|
|
16631
|
+
* @param {number} [maxResults=Infinity]
|
|
16632
|
+
* @param {number} [maxDistance=Infinity]
|
|
16633
|
+
* @param {(index: number) => boolean} [filterFn] An optional function for filtering the results.
|
|
16634
|
+
* @returns {number[]} An array of indices of items found.
|
|
17720
16635
|
*/
|
|
17721
|
-
|
|
17722
|
-
if (this.
|
|
17723
|
-
const
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
16636
|
+
neighbors(x, y, maxResults = Infinity, maxDistance = Infinity, filterFn) {
|
|
16637
|
+
if (this._pos !== this._boxes.length) throw new Error("Data not yet indexed - call index.finish().");
|
|
16638
|
+
const { _boxes: boxes, _levelBounds: levelBounds, _indices: indices, _queue: q, nodeSize } = this;
|
|
16639
|
+
const numItems4 = this.numItems * 4;
|
|
16640
|
+
const nodeSize4 = nodeSize * 4;
|
|
16641
|
+
const results = [];
|
|
16642
|
+
const maxDistSquared = maxDistance * maxDistance;
|
|
16643
|
+
q.push(boxes.length - 4 << 1, 0);
|
|
16644
|
+
while (q.length) {
|
|
16645
|
+
const top = q.ids[0];
|
|
16646
|
+
if (top & 1) {
|
|
16647
|
+
if (q.values[0] > maxDistSquared) break;
|
|
16648
|
+
q.pop();
|
|
16649
|
+
results.push(top >> 1);
|
|
16650
|
+
if (results.length === maxResults) break;
|
|
16651
|
+
continue;
|
|
17737
16652
|
}
|
|
17738
|
-
|
|
17739
|
-
|
|
16653
|
+
q.pop();
|
|
16654
|
+
const nodeIndex = top >> 1;
|
|
16655
|
+
const isLeafLevel = nodeIndex < numItems4;
|
|
16656
|
+
const end = Math.min(nodeIndex + nodeSize4, upperBound(nodeIndex, levelBounds));
|
|
16657
|
+
for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
16658
|
+
const childIndex = indices[pos >> 2] | 0;
|
|
16659
|
+
const minX = boxes[pos];
|
|
16660
|
+
const minY = boxes[pos + 1];
|
|
16661
|
+
const maxX = boxes[pos + 2];
|
|
16662
|
+
const maxY = boxes[pos + 3];
|
|
16663
|
+
const dx = x < minX ? minX - x : x > maxX ? x - maxX : 0;
|
|
16664
|
+
const dy = y < minY ? minY - y : y > maxY ? y - maxY : 0;
|
|
16665
|
+
const dist = dx * dx + dy * dy;
|
|
16666
|
+
if (dist > maxDistSquared) continue;
|
|
16667
|
+
if (isLeafLevel) {
|
|
16668
|
+
if (filterFn === void 0 || filterFn(childIndex)) q.push(childIndex << 1 | 1, dist);
|
|
16669
|
+
} else q.push(childIndex << 1, dist);
|
|
16670
|
+
}
|
|
16671
|
+
}
|
|
16672
|
+
q.clear();
|
|
16673
|
+
return results;
|
|
16674
|
+
}
|
|
16675
|
+
};
|
|
16676
|
+
/**
|
|
16677
|
+
* Binary search for the first value in the array bigger than the given.
|
|
16678
|
+
* @param {number} value
|
|
16679
|
+
* @param {number[]} arr
|
|
16680
|
+
*/
|
|
16681
|
+
function upperBound(value, arr) {
|
|
16682
|
+
let i = 0;
|
|
16683
|
+
let j = arr.length - 1;
|
|
16684
|
+
while (i < j) {
|
|
16685
|
+
const m = i + j >> 1;
|
|
16686
|
+
if (arr[m] > value) j = m;
|
|
16687
|
+
else i = m + 1;
|
|
16688
|
+
}
|
|
16689
|
+
return arr[i];
|
|
16690
|
+
}
|
|
16691
|
+
/**
|
|
16692
|
+
* Custom quicksort that partially sorts bbox data alongside the hilbert values.
|
|
16693
|
+
* @param {Int32Array} values
|
|
16694
|
+
* @param {TypedArray} boxes
|
|
16695
|
+
* @param {Uint16Array | Uint32Array} indices
|
|
16696
|
+
* @param {number} left
|
|
16697
|
+
* @param {number} right
|
|
16698
|
+
* @param {number} nodeSize
|
|
16699
|
+
*/
|
|
16700
|
+
function sort(values, boxes, indices, left, right, nodeSize) {
|
|
16701
|
+
const stack = [left, right];
|
|
16702
|
+
while (stack.length) {
|
|
16703
|
+
const r = stack.pop() || 0;
|
|
16704
|
+
const l = stack.pop() || 0;
|
|
16705
|
+
if (r - l <= nodeSize && Math.floor(l / nodeSize) >= Math.floor(r / nodeSize)) continue;
|
|
16706
|
+
const a = values[l];
|
|
16707
|
+
const b = values[l + r >> 1];
|
|
16708
|
+
const c = values[r];
|
|
16709
|
+
const pivot = a > b !== a > c ? a : b < a !== b < c ? b : c;
|
|
16710
|
+
let i = l - 1;
|
|
16711
|
+
let j = r + 1;
|
|
16712
|
+
while (true) {
|
|
16713
|
+
do
|
|
16714
|
+
i++;
|
|
16715
|
+
while (values[i] < pivot);
|
|
16716
|
+
do
|
|
16717
|
+
j--;
|
|
16718
|
+
while (values[j] > pivot);
|
|
16719
|
+
if (i >= j) break;
|
|
16720
|
+
swap(values, boxes, indices, i, j);
|
|
17740
16721
|
}
|
|
17741
|
-
|
|
16722
|
+
stack.push(l, j, j + 1, r);
|
|
17742
16723
|
}
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
16724
|
+
}
|
|
16725
|
+
/**
|
|
16726
|
+
* Swap two values and two corresponding boxes.
|
|
16727
|
+
* @param {Int32Array} values
|
|
16728
|
+
* @param {TypedArray} boxes
|
|
16729
|
+
* @param {Uint16Array | Uint32Array} indices
|
|
16730
|
+
* @param {number} i
|
|
16731
|
+
* @param {number} j
|
|
16732
|
+
*/
|
|
16733
|
+
function swap(values, boxes, indices, i, j) {
|
|
16734
|
+
const temp = values[i];
|
|
16735
|
+
values[i] = values[j];
|
|
16736
|
+
values[j] = temp;
|
|
16737
|
+
const k = 4 * i;
|
|
16738
|
+
const m = 4 * j;
|
|
16739
|
+
const a = boxes[k];
|
|
16740
|
+
const b = boxes[k + 1];
|
|
16741
|
+
const c = boxes[k + 2];
|
|
16742
|
+
const d = boxes[k + 3];
|
|
16743
|
+
boxes[k] = boxes[m];
|
|
16744
|
+
boxes[k + 1] = boxes[m + 1];
|
|
16745
|
+
boxes[k + 2] = boxes[m + 2];
|
|
16746
|
+
boxes[k + 3] = boxes[m + 3];
|
|
16747
|
+
boxes[m] = a;
|
|
16748
|
+
boxes[m + 1] = b;
|
|
16749
|
+
boxes[m + 2] = c;
|
|
16750
|
+
boxes[m + 3] = d;
|
|
16751
|
+
const e = indices[i];
|
|
16752
|
+
indices[i] = indices[j];
|
|
16753
|
+
indices[j] = e;
|
|
16754
|
+
}
|
|
16755
|
+
/**
|
|
16756
|
+
* Fast Hilbert curve algorithm by http://threadlocalmutex.com/
|
|
16757
|
+
* Ported from C++ https://github.com/rawrunprotected/hilbert_curves (public domain)
|
|
16758
|
+
* @param {number} x
|
|
16759
|
+
* @param {number} y
|
|
16760
|
+
*/
|
|
16761
|
+
function hilbert(x, y) {
|
|
16762
|
+
let a = x ^ y;
|
|
16763
|
+
let b = 65535 ^ a;
|
|
16764
|
+
let c = 65535 ^ (x | y);
|
|
16765
|
+
let d = x & (y ^ 65535);
|
|
16766
|
+
let A = a | b >> 1;
|
|
16767
|
+
let B = a >> 1 ^ a;
|
|
16768
|
+
let C = c ^ (c >> 1 ^ b & d >> 1);
|
|
16769
|
+
let D = d ^ (a & c >> 1 ^ d >> 1);
|
|
16770
|
+
a = A & A >> 2 ^ B & B >> 2;
|
|
16771
|
+
b = A & B >> 2 ^ B & (A ^ B) >> 2;
|
|
16772
|
+
c = C ^ (A & C >> 2 ^ B & D >> 2);
|
|
16773
|
+
d = D ^ (B & C >> 2 ^ (A ^ B) & D >> 2);
|
|
16774
|
+
A = a & a >> 4 ^ b & b >> 4;
|
|
16775
|
+
B = a & b >> 4 ^ b & (a ^ b) >> 4;
|
|
16776
|
+
C = c ^ (a & c >> 4 ^ b & d >> 4);
|
|
16777
|
+
D = d ^ (b & c >> 4 ^ (a ^ b) & d >> 4);
|
|
16778
|
+
c = C ^ (A & C >> 8 ^ B & D >> 8);
|
|
16779
|
+
d = D ^ (B & C >> 8 ^ (A ^ B) & D >> 8);
|
|
16780
|
+
c ^= c >> 1;
|
|
16781
|
+
d ^= d >> 1;
|
|
16782
|
+
a = x ^ y;
|
|
16783
|
+
b = d | 65535 ^ (a | c);
|
|
16784
|
+
a = (a | a << 8) & 16711935;
|
|
16785
|
+
a = (a | a << 4) & 252645135;
|
|
16786
|
+
a = (a | a << 2) & 858993459;
|
|
16787
|
+
a = (a | a << 1) & 1431655765;
|
|
16788
|
+
b = (b | b << 8) & 16711935;
|
|
16789
|
+
b = (b | b << 4) & 252645135;
|
|
16790
|
+
b = (b | b << 2) & 858993459;
|
|
16791
|
+
b = (b | b << 1) & 1431655765;
|
|
16792
|
+
return ((b << 1 | a) >>> 0) - 2147483648;
|
|
16793
|
+
}
|
|
16794
|
+
//#endregion
|
|
16795
|
+
//#region node_modules/@developmentseed/deck.gl-geotiff/dist/mosaic-layer/mosaic-tileset-2d.js
|
|
16796
|
+
var MosaicTileset2D = class extends _Tileset2D {
|
|
16797
|
+
/** Closure returning the parent layer's current sources array. Re-evaluated
|
|
16798
|
+
* on each `getTileIndices` call so updates to the layer's `sources` prop
|
|
16799
|
+
* propagate without recreating the tileset. */
|
|
16800
|
+
getSources;
|
|
16801
|
+
/** Access the spatial index on the MosaicLayer instance. */
|
|
16802
|
+
getIndex;
|
|
16803
|
+
constructor(getSources, getIndex, opts) {
|
|
16804
|
+
super(opts);
|
|
16805
|
+
this.getIndex = getIndex;
|
|
16806
|
+
this.getSources = getSources;
|
|
17746
16807
|
}
|
|
17747
|
-
/**
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
*/
|
|
17751
|
-
peekValue() {
|
|
17752
|
-
return this.length > 0 ? this.values[0] : void 0;
|
|
16808
|
+
/** The Tileset2D cache key for a source. */
|
|
16809
|
+
getTileId(tileIndex) {
|
|
16810
|
+
return tileIndex.id;
|
|
17753
16811
|
}
|
|
17754
|
-
/**
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
* `pop()` and `clear()` calls don't free memory automatically to avoid unnecessary resize operations.
|
|
17758
|
-
* This also means that items that have been added to the queue can't be garbage collected until
|
|
17759
|
-
* a new item is pushed in their place, or this method is called.
|
|
17760
|
-
*/
|
|
17761
|
-
shrink() {
|
|
17762
|
-
if (Array.isArray(this.ids)) this.ids.length = this.length;
|
|
17763
|
-
if (Array.isArray(this.values)) this.values.length = this.length;
|
|
16812
|
+
/** Must override to provide a zoom level for the tile. */
|
|
16813
|
+
getTileZoom(_tileIndex) {
|
|
16814
|
+
return 0;
|
|
17764
16815
|
}
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
Int16Array,
|
|
17773
|
-
Uint16Array,
|
|
17774
|
-
Int32Array,
|
|
17775
|
-
Uint32Array,
|
|
17776
|
-
Float32Array,
|
|
17777
|
-
Float64Array
|
|
17778
|
-
];
|
|
17779
|
-
var VERSION = 3;
|
|
17780
|
-
/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */
|
|
17781
|
-
/** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray */
|
|
17782
|
-
var Flatbush = class Flatbush {
|
|
17783
|
-
/**
|
|
17784
|
-
* Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
|
|
17785
|
-
* @param {ArrayBufferLike} data
|
|
17786
|
-
* @param {number} [byteOffset=0] byte offset to the start of the Flatbush buffer in the referenced ArrayBuffer.
|
|
17787
|
-
* @returns {Flatbush} index
|
|
17788
|
-
*/
|
|
17789
|
-
static from(data, byteOffset = 0) {
|
|
17790
|
-
if (byteOffset % 8 !== 0) throw new Error("byteOffset must be 8-byte aligned.");
|
|
17791
|
-
if (!data || data.byteLength === void 0 || "buffer" in data) throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");
|
|
17792
|
-
const [magic, versionAndType] = new Uint8Array(data, byteOffset + 0, 2);
|
|
17793
|
-
if (magic !== 251) throw new Error("Data does not appear to be in a Flatbush format.");
|
|
17794
|
-
const version = versionAndType >> 4;
|
|
17795
|
-
if (version !== VERSION) throw new Error(`Got v${version} data when expected v${VERSION}.`);
|
|
17796
|
-
const ArrayType = ARRAY_TYPES[versionAndType & 15];
|
|
17797
|
-
if (!ArrayType) throw new Error("Unrecognized array type.");
|
|
17798
|
-
const [nodeSize] = new Uint16Array(data, byteOffset + 2, 1);
|
|
17799
|
-
const [numItems] = new Uint32Array(data, byteOffset + 4, 1);
|
|
17800
|
-
return new Flatbush(numItems, nodeSize, ArrayType, void 0, data, byteOffset);
|
|
16816
|
+
/** Must override because our tileIndex does not have x, y, z */
|
|
16817
|
+
getTileMetadata(tileIndex) {
|
|
16818
|
+
const { id, bbox } = tileIndex;
|
|
16819
|
+
return {
|
|
16820
|
+
id,
|
|
16821
|
+
bbox
|
|
16822
|
+
};
|
|
17801
16823
|
}
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
if (arrayTypeIndex < 0) throw new Error(`Unexpected typed array class: ${ArrayType}.`);
|
|
17830
|
-
/** @type {new(b: ArrayBufferLike, o: number, l: number) => TypedArray} */
|
|
17831
|
-
const BoxCtor = ArrayType;
|
|
17832
|
-
/** @type {new(b: ArrayBufferLike, o: number, l: number) => Uint16Array | Uint32Array} */
|
|
17833
|
-
const IdxCtor = this.IndexArrayType;
|
|
17834
|
-
if (data) {
|
|
17835
|
-
this.data = data;
|
|
17836
|
-
this._boxes = new BoxCtor(data, byteOffset + 8, numNodes * 4);
|
|
17837
|
-
this._indices = new IdxCtor(data, byteOffset + 8 + nodesByteSize, numNodes);
|
|
17838
|
-
this._pos = numNodes * 4;
|
|
17839
|
-
this.minX = this._boxes[this._pos - 4];
|
|
17840
|
-
this.minY = this._boxes[this._pos - 3];
|
|
17841
|
-
this.maxX = this._boxes[this._pos - 2];
|
|
17842
|
-
this.maxY = this._boxes[this._pos - 1];
|
|
17843
|
-
} else {
|
|
17844
|
-
const data = this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
|
|
17845
|
-
this._boxes = new BoxCtor(data, 8, numNodes * 4);
|
|
17846
|
-
this._indices = new IdxCtor(data, 8 + nodesByteSize, numNodes);
|
|
17847
|
-
this._pos = 0;
|
|
17848
|
-
this.minX = Infinity;
|
|
17849
|
-
this.minY = Infinity;
|
|
17850
|
-
this.maxX = -Infinity;
|
|
17851
|
-
this.maxY = -Infinity;
|
|
17852
|
-
new Uint8Array(data, 0, 2).set([251, (VERSION << 4) + arrayTypeIndex]);
|
|
17853
|
-
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
17854
|
-
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
17855
|
-
}
|
|
17856
|
-
/** @type FlatQueue<number> */
|
|
17857
|
-
this._queue = new FlatQueue();
|
|
16824
|
+
getParentIndex(tileIndex) {
|
|
16825
|
+
return tileIndex;
|
|
16826
|
+
}
|
|
16827
|
+
getTileIndices({ viewport, maxZoom, minZoom }) {
|
|
16828
|
+
if (viewport.zoom < (minZoom ?? -Infinity)) return [];
|
|
16829
|
+
if (viewport.zoom > (maxZoom ?? Infinity)) return [];
|
|
16830
|
+
const index = this.getIndex();
|
|
16831
|
+
if (!index) return [];
|
|
16832
|
+
const viewportBounds = viewport.getBounds();
|
|
16833
|
+
const indices = index.search(...viewportBounds);
|
|
16834
|
+
const sources = this.getSources();
|
|
16835
|
+
const selectedSources = indices.map((sourceIndex) => {
|
|
16836
|
+
const source = sources[sourceIndex];
|
|
16837
|
+
return {
|
|
16838
|
+
x: 0,
|
|
16839
|
+
y: 0,
|
|
16840
|
+
z: 0,
|
|
16841
|
+
...source,
|
|
16842
|
+
id: source.id ?? String(sourceIndex)
|
|
16843
|
+
};
|
|
16844
|
+
});
|
|
16845
|
+
const { maxRequests } = this.opts;
|
|
16846
|
+
if (selectedSources.length <= maxRequests) return selectedSources;
|
|
16847
|
+
return sortItemsByDistanceFromViewportCenter(selectedSources, viewport, (source) => {
|
|
16848
|
+
const [minX, minY, maxX, maxY] = source.bbox;
|
|
16849
|
+
return [(minX + maxX) * .5, (minY + maxY) * .5];
|
|
16850
|
+
});
|
|
17858
16851
|
}
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
|
|
17872
|
-
|
|
17873
|
-
|
|
17874
|
-
|
|
17875
|
-
if (minX < this.minX) this.minX = minX;
|
|
17876
|
-
if (minY < this.minY) this.minY = minY;
|
|
17877
|
-
if (maxX > this.maxX) this.maxX = maxX;
|
|
17878
|
-
if (maxY > this.maxY) this.maxY = maxY;
|
|
17879
|
-
return index;
|
|
16852
|
+
};
|
|
16853
|
+
//#endregion
|
|
16854
|
+
//#region node_modules/@developmentseed/deck.gl-geotiff/dist/mosaic-layer/mosaic-layer.js
|
|
16855
|
+
var defaultProps = { sources: [] };
|
|
16856
|
+
/**
|
|
16857
|
+
* A deck.gl layer for rendering a mosaic of raster sources.
|
|
16858
|
+
*
|
|
16859
|
+
* The `renderSource` prop is called whenever a source is present in the current
|
|
16860
|
+
* viewport.
|
|
16861
|
+
*/
|
|
16862
|
+
var MosaicLayer = class extends CompositeLayer {
|
|
16863
|
+
static layerName = "MosaicLayer";
|
|
16864
|
+
static defaultProps = defaultProps;
|
|
16865
|
+
initializeState(context) {
|
|
16866
|
+
super.initializeState(context);
|
|
16867
|
+
this._buildSpatialIndex();
|
|
17880
16868
|
}
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
16869
|
+
updateState(params) {
|
|
16870
|
+
super.updateState(params);
|
|
16871
|
+
const { props, oldProps } = params;
|
|
16872
|
+
if (props.sources !== oldProps.sources) this._buildSpatialIndex();
|
|
16873
|
+
}
|
|
16874
|
+
_buildSpatialIndex() {
|
|
16875
|
+
const { sources } = this.props;
|
|
16876
|
+
if (sources.length === 0) {
|
|
16877
|
+
this.setState({ index: null });
|
|
17890
16878
|
return;
|
|
17891
16879
|
}
|
|
17892
|
-
const
|
|
17893
|
-
const
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
for (let i = 0, pos = 0; i < this.numItems; i++) {
|
|
17897
|
-
const minX = boxes[pos++];
|
|
17898
|
-
const minY = boxes[pos++];
|
|
17899
|
-
const maxX = boxes[pos++];
|
|
17900
|
-
const maxY = boxes[pos++];
|
|
17901
|
-
hilbertValues[i] = hilbert(Math.floor(hilbertMax * ((minX + maxX) / 2 - this.minX) / width), Math.floor(hilbertMax * ((minY + maxY) / 2 - this.minY) / height));
|
|
17902
|
-
}
|
|
17903
|
-
sort(hilbertValues, boxes, this._indices, 0, this.numItems - 1, this.nodeSize);
|
|
17904
|
-
for (let i = 0, pos = 0; i < this._levelBounds.length - 1; i++) {
|
|
17905
|
-
const end = this._levelBounds[i];
|
|
17906
|
-
while (pos < end) {
|
|
17907
|
-
const nodeIndex = pos;
|
|
17908
|
-
let nodeMinX = boxes[pos++];
|
|
17909
|
-
let nodeMinY = boxes[pos++];
|
|
17910
|
-
let nodeMaxX = boxes[pos++];
|
|
17911
|
-
let nodeMaxY = boxes[pos++];
|
|
17912
|
-
for (let j = 1; j < this.nodeSize && pos < end; j++) {
|
|
17913
|
-
nodeMinX = Math.min(nodeMinX, boxes[pos++]);
|
|
17914
|
-
nodeMinY = Math.min(nodeMinY, boxes[pos++]);
|
|
17915
|
-
nodeMaxX = Math.max(nodeMaxX, boxes[pos++]);
|
|
17916
|
-
nodeMaxY = Math.max(nodeMaxY, boxes[pos++]);
|
|
17917
|
-
}
|
|
17918
|
-
this._indices[this._pos >> 2] = nodeIndex;
|
|
17919
|
-
boxes[this._pos++] = nodeMinX;
|
|
17920
|
-
boxes[this._pos++] = nodeMinY;
|
|
17921
|
-
boxes[this._pos++] = nodeMaxX;
|
|
17922
|
-
boxes[this._pos++] = nodeMaxY;
|
|
17923
|
-
}
|
|
17924
|
-
}
|
|
16880
|
+
const index = new Flatbush(sources.length);
|
|
16881
|
+
for (const source of sources) index.add(...source.bbox);
|
|
16882
|
+
index.finish();
|
|
16883
|
+
this.setState({ index });
|
|
17925
16884
|
}
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
* @returns {number[]} An array of indices of items intersecting or touching the given bounding box.
|
|
17934
|
-
*/
|
|
17935
|
-
search(minX, minY, maxX, maxY, filterFn) {
|
|
17936
|
-
if (this._pos !== this._boxes.length) throw new Error("Data not yet indexed - call index.finish().");
|
|
17937
|
-
const { _boxes: boxes, _levelBounds: levelBounds, _indices: indices, nodeSize } = this;
|
|
17938
|
-
const numItems4 = this.numItems * 4;
|
|
17939
|
-
/** @type number | undefined */
|
|
17940
|
-
let nodeIndex = boxes.length - 4;
|
|
17941
|
-
let level = levelBounds.length - 1;
|
|
17942
|
-
const q = [];
|
|
17943
|
-
const results = [];
|
|
17944
|
-
let contained = false;
|
|
17945
|
-
while (nodeIndex !== void 0) {
|
|
17946
|
-
const end = Math.min(nodeIndex + nodeSize * 4, levelBounds[level]);
|
|
17947
|
-
const isNode = nodeIndex >= numItems4;
|
|
17948
|
-
if (contained) this._collectContained(nodeIndex, end, level, isNode, q, results, filterFn);
|
|
17949
|
-
else for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
17950
|
-
const x0 = boxes[pos];
|
|
17951
|
-
if (maxX < x0) continue;
|
|
17952
|
-
const y0 = boxes[pos + 1];
|
|
17953
|
-
if (maxY < y0) continue;
|
|
17954
|
-
const x1 = boxes[pos + 2];
|
|
17955
|
-
if (minX > x1) continue;
|
|
17956
|
-
const y1 = boxes[pos + 3];
|
|
17957
|
-
if (minY > y1) continue;
|
|
17958
|
-
const index = indices[pos >> 2] | 0;
|
|
17959
|
-
if (isNode) {
|
|
17960
|
-
const c = +(minX <= x0 && minY <= y0 && maxX >= x1 && maxY >= y1);
|
|
17961
|
-
q.push(index | c, level - 1);
|
|
17962
|
-
} else if (filterFn === void 0 || filterFn(index, x0, y0, x1, y1)) results.push(index);
|
|
17963
|
-
}
|
|
17964
|
-
level = q.pop();
|
|
17965
|
-
nodeIndex = q.pop();
|
|
17966
|
-
if (nodeIndex !== void 0) {
|
|
17967
|
-
contained = (nodeIndex & 1) === 1;
|
|
17968
|
-
nodeIndex &= -2;
|
|
16885
|
+
renderTileLayer(renderSource) {
|
|
16886
|
+
const { id, minZoom, maxZoom, debounceTime, extent, maxCacheByteSize, maxCacheSize, maxRequests, onSourceLoad, onSourceError, onSourceUnload, onViewportLoad } = this.props;
|
|
16887
|
+
const getSources = () => this.props.sources;
|
|
16888
|
+
const getIndex = () => this.state.index;
|
|
16889
|
+
class MosaicTileset2DFactory extends MosaicTileset2D {
|
|
16890
|
+
constructor(opts) {
|
|
16891
|
+
super(getSources, getIndex, opts);
|
|
17969
16892
|
}
|
|
17970
16893
|
}
|
|
17971
|
-
return
|
|
16894
|
+
return new TileLayer({
|
|
16895
|
+
id: `mosaic-layer-${id}`,
|
|
16896
|
+
TilesetClass: MosaicTileset2DFactory,
|
|
16897
|
+
minZoom,
|
|
16898
|
+
maxZoom,
|
|
16899
|
+
debounceTime,
|
|
16900
|
+
extent,
|
|
16901
|
+
...maxCacheByteSize !== void 0 && { maxCacheByteSize },
|
|
16902
|
+
maxCacheSize,
|
|
16903
|
+
maxRequests,
|
|
16904
|
+
getTileData: async (data) => {
|
|
16905
|
+
const index = data.index;
|
|
16906
|
+
const { signal } = data;
|
|
16907
|
+
return {
|
|
16908
|
+
source: index,
|
|
16909
|
+
data: this.props.getSource && await this.props.getSource(index, { signal }),
|
|
16910
|
+
signal
|
|
16911
|
+
};
|
|
16912
|
+
},
|
|
16913
|
+
renderSubLayers: (props) => {
|
|
16914
|
+
const { data } = props;
|
|
16915
|
+
const { source, signal, data: userData } = data;
|
|
16916
|
+
return renderSource(source, {
|
|
16917
|
+
data: userData,
|
|
16918
|
+
signal
|
|
16919
|
+
});
|
|
16920
|
+
},
|
|
16921
|
+
...onSourceLoad && { onTileLoad: (tile) => {
|
|
16922
|
+
const source = tile.index;
|
|
16923
|
+
onSourceLoad(source, { data: tile.content?.data });
|
|
16924
|
+
} },
|
|
16925
|
+
...onSourceError && { onTileError: (error, tile) => {
|
|
16926
|
+
if (!tile) return;
|
|
16927
|
+
const source = tile.index;
|
|
16928
|
+
onSourceError(source, { error });
|
|
16929
|
+
} },
|
|
16930
|
+
...onSourceUnload && { onTileUnload: (tile) => {
|
|
16931
|
+
const source = tile.index;
|
|
16932
|
+
onSourceUnload(source, { data: tile.content?.data });
|
|
16933
|
+
} },
|
|
16934
|
+
...onViewportLoad && { onViewportLoad: (tiles) => {
|
|
16935
|
+
onViewportLoad(tiles.map((tile) => ({
|
|
16936
|
+
source: tile.index,
|
|
16937
|
+
data: tile.content?.data
|
|
16938
|
+
})));
|
|
16939
|
+
} }
|
|
16940
|
+
});
|
|
17972
16941
|
}
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
17978
|
-
|
|
17979
|
-
|
|
17980
|
-
|
|
17981
|
-
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
|
|
17986
|
-
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
16942
|
+
renderLayers() {
|
|
16943
|
+
const { sources, renderSource } = this.props;
|
|
16944
|
+
if (!sources) return null;
|
|
16945
|
+
return this.renderTileLayer(renderSource);
|
|
16946
|
+
}
|
|
16947
|
+
};
|
|
16948
|
+
//#endregion
|
|
16949
|
+
//#region node_modules/@chunkd/middleware/build/src/middleware/cache.js
|
|
16950
|
+
var SourceCache = class {
|
|
16951
|
+
name = "source:cache";
|
|
16952
|
+
maxSize;
|
|
16953
|
+
/** Number of bytes cached in cacheA, when this overflows maxSize cacheA is moved to cacheB and cacheB is dropped */
|
|
16954
|
+
size = 0;
|
|
16955
|
+
/** Number of times `this.cacheB` has been cleared */
|
|
16956
|
+
resets = 0;
|
|
16957
|
+
/** Primary cache of objects */
|
|
16958
|
+
cacheA = /* @__PURE__ */ new Map();
|
|
16959
|
+
cacheB = /* @__PURE__ */ new Map();
|
|
16960
|
+
/** List of protocols to cache */
|
|
16961
|
+
protocols;
|
|
16962
|
+
constructor(opts) {
|
|
16963
|
+
this.maxSize = opts.size;
|
|
16964
|
+
this.protocols = new Set(opts.protocols ?? []);
|
|
16965
|
+
}
|
|
16966
|
+
fetch(req, next) {
|
|
16967
|
+
if (this.protocols.size > 0 && !this.protocols.has(req.source.url.protocol)) return next(req);
|
|
16968
|
+
if (req.length == null) return next(req);
|
|
16969
|
+
const cacheKey = `${req.source.url.toString()}@${req.offset}+${req.length}`;
|
|
16970
|
+
let existing = this.cacheA.get(cacheKey);
|
|
16971
|
+
if (existing) {
|
|
16972
|
+
existing.hits++;
|
|
16973
|
+
return existing.promise;
|
|
16974
|
+
}
|
|
16975
|
+
existing = this.cacheB.get(cacheKey);
|
|
16976
|
+
if (existing) {
|
|
16977
|
+
existing.hits++;
|
|
16978
|
+
existing.saves++;
|
|
16979
|
+
this.size += existing.size;
|
|
16980
|
+
this.cacheA.set(cacheKey, existing);
|
|
16981
|
+
return existing.promise;
|
|
16982
|
+
}
|
|
16983
|
+
existing = {
|
|
16984
|
+
promise: next(req),
|
|
16985
|
+
hits: 0,
|
|
16986
|
+
saves: 0,
|
|
16987
|
+
size: req.length
|
|
16988
|
+
};
|
|
16989
|
+
this.size += existing.size;
|
|
16990
|
+
if (this.size > this.maxSize) {
|
|
16991
|
+
this.size = existing.size;
|
|
16992
|
+
this.cacheB = this.cacheA;
|
|
16993
|
+
this.cacheA = /* @__PURE__ */ new Map();
|
|
16994
|
+
this.resets++;
|
|
17990
16995
|
}
|
|
16996
|
+
this.cacheA.set(cacheKey, existing);
|
|
16997
|
+
return existing.promise;
|
|
16998
|
+
}
|
|
16999
|
+
};
|
|
17000
|
+
//#endregion
|
|
17001
|
+
//#region node_modules/@chunkd/source/build/src/error.js
|
|
17002
|
+
var SourceError = class SourceError extends Error {
|
|
17003
|
+
/** Status code for the error eg 403 - Forbidden vs 404 Not found */
|
|
17004
|
+
code;
|
|
17005
|
+
/** URL that the status code came from */
|
|
17006
|
+
url;
|
|
17007
|
+
/** File system that triggered the error */
|
|
17008
|
+
source;
|
|
17009
|
+
constructor(msg, code, source, cause) {
|
|
17010
|
+
super(msg, { cause });
|
|
17011
|
+
this.code = code;
|
|
17012
|
+
this.url = source.url;
|
|
17013
|
+
this.source = source;
|
|
17014
|
+
/** Helper to determine if this class is a SourceError, useful for when `instanceof` fails */
|
|
17015
|
+
Object.defineProperty(this, "_sourceError", {
|
|
17016
|
+
enumerable: false,
|
|
17017
|
+
value: "SourceError"
|
|
17018
|
+
});
|
|
17019
|
+
}
|
|
17020
|
+
/** Check that a unknown is a FsError */
|
|
17021
|
+
static is(e) {
|
|
17022
|
+
if (e instanceof SourceError) return true;
|
|
17023
|
+
if (typeof e !== "object") return false;
|
|
17024
|
+
if (e == null) return false;
|
|
17025
|
+
return "_sourceError" in e && e["_sourceError"] === "SourceError";
|
|
17991
17026
|
}
|
|
17027
|
+
};
|
|
17028
|
+
//#endregion
|
|
17029
|
+
//#region node_modules/@chunkd/source/build/src/range.js
|
|
17030
|
+
var ContentRange = {
|
|
17031
|
+
/** Convert a offset/length to a range request
|
|
17032
|
+
*
|
|
17033
|
+
* @example
|
|
17034
|
+
* ```typescript
|
|
17035
|
+
* ContentRange.toRange(10) // "bytes=10"
|
|
17036
|
+
* ContentRange.toRange(0, 1024) // "bytes=0-1023"
|
|
17037
|
+
* ```
|
|
17038
|
+
*/
|
|
17039
|
+
toRange(offset, length) {
|
|
17040
|
+
if (length == null) return `bytes=${offset}`;
|
|
17041
|
+
if (offset < 0) throw new Error("Cannot read from remote source with negative offset and length");
|
|
17042
|
+
return `bytes=${offset}-${offset + length - 1}`;
|
|
17043
|
+
},
|
|
17992
17044
|
/**
|
|
17993
|
-
*
|
|
17994
|
-
*
|
|
17995
|
-
* @
|
|
17996
|
-
*
|
|
17997
|
-
*
|
|
17998
|
-
*
|
|
17999
|
-
* @
|
|
17045
|
+
* Parse a Content-Range header to extract the size of the source
|
|
17046
|
+
*
|
|
17047
|
+
* @example
|
|
17048
|
+
* ```typescript
|
|
17049
|
+
* ContentRange.parseRange("bytes 200-1000/67589"); // 67589
|
|
17050
|
+
* ```
|
|
17051
|
+
* @throws if range is not a Content-Range with size
|
|
18000
17052
|
*/
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
const
|
|
18006
|
-
const
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
while (q.length) {
|
|
18010
|
-
const top = q.ids[0];
|
|
18011
|
-
if (top & 1) {
|
|
18012
|
-
if (q.values[0] > maxDistSquared) break;
|
|
18013
|
-
q.pop();
|
|
18014
|
-
results.push(top >> 1);
|
|
18015
|
-
if (results.length === maxResults) break;
|
|
18016
|
-
continue;
|
|
18017
|
-
}
|
|
18018
|
-
q.pop();
|
|
18019
|
-
const nodeIndex = top >> 1;
|
|
18020
|
-
const isLeafLevel = nodeIndex < numItems4;
|
|
18021
|
-
const end = Math.min(nodeIndex + nodeSize4, upperBound(nodeIndex, levelBounds));
|
|
18022
|
-
for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
18023
|
-
const childIndex = indices[pos >> 2] | 0;
|
|
18024
|
-
const minX = boxes[pos];
|
|
18025
|
-
const minY = boxes[pos + 1];
|
|
18026
|
-
const maxX = boxes[pos + 2];
|
|
18027
|
-
const maxY = boxes[pos + 3];
|
|
18028
|
-
const dx = x < minX ? minX - x : x > maxX ? x - maxX : 0;
|
|
18029
|
-
const dy = y < minY ? minY - y : y > maxY ? y - maxY : 0;
|
|
18030
|
-
const dist = dx * dx + dy * dy;
|
|
18031
|
-
if (dist > maxDistSquared) continue;
|
|
18032
|
-
if (isLeafLevel) {
|
|
18033
|
-
if (filterFn === void 0 || filterFn(childIndex)) q.push(childIndex << 1 | 1, dist);
|
|
18034
|
-
} else q.push(childIndex << 1, dist);
|
|
18035
|
-
}
|
|
18036
|
-
}
|
|
18037
|
-
q.clear();
|
|
18038
|
-
return results;
|
|
17053
|
+
parseSize(range) {
|
|
17054
|
+
const [unit, chunks] = range.split(" ");
|
|
17055
|
+
if (unit !== "bytes") throw new Error("Failed to parse content-range: " + range);
|
|
17056
|
+
if (chunks == null) throw new Error("Failed to parse content-range: " + range);
|
|
17057
|
+
const [, size] = chunks.split("/");
|
|
17058
|
+
const result = Number(size);
|
|
17059
|
+
if (isNaN(result)) throw new Error("Failed to parse content-range: " + range);
|
|
17060
|
+
return result;
|
|
18039
17061
|
}
|
|
18040
17062
|
};
|
|
17063
|
+
//#endregion
|
|
17064
|
+
//#region node_modules/@chunkd/source/build/src/view.js
|
|
18041
17065
|
/**
|
|
18042
|
-
*
|
|
18043
|
-
*
|
|
18044
|
-
* @
|
|
18045
|
-
|
|
18046
|
-
function upperBound(value, arr) {
|
|
18047
|
-
let i = 0;
|
|
18048
|
-
let j = arr.length - 1;
|
|
18049
|
-
while (i < j) {
|
|
18050
|
-
const m = i + j >> 1;
|
|
18051
|
-
if (arr[m] > value) j = m;
|
|
18052
|
-
else i = m + 1;
|
|
18053
|
-
}
|
|
18054
|
-
return arr[i];
|
|
18055
|
-
}
|
|
18056
|
-
/**
|
|
18057
|
-
* Custom quicksort that partially sorts bbox data alongside the hilbert values.
|
|
18058
|
-
* @param {Int32Array} values
|
|
18059
|
-
* @param {TypedArray} boxes
|
|
18060
|
-
* @param {Uint16Array | Uint32Array} indices
|
|
18061
|
-
* @param {number} left
|
|
18062
|
-
* @param {number} right
|
|
18063
|
-
* @param {number} nodeSize
|
|
17066
|
+
* Wrap a source with middleware to modify requests to the sources
|
|
17067
|
+
*
|
|
17068
|
+
* @see {@link SourceMiddleware}
|
|
17069
|
+
* @see @chunkd/middle for example middleware
|
|
18064
17070
|
*/
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
const a = values[l];
|
|
18072
|
-
const b = values[l + r >> 1];
|
|
18073
|
-
const c = values[r];
|
|
18074
|
-
const pivot = a > b !== a > c ? a : b < a !== b < c ? b : c;
|
|
18075
|
-
let i = l - 1;
|
|
18076
|
-
let j = r + 1;
|
|
18077
|
-
while (true) {
|
|
18078
|
-
do
|
|
18079
|
-
i++;
|
|
18080
|
-
while (values[i] < pivot);
|
|
18081
|
-
do
|
|
18082
|
-
j--;
|
|
18083
|
-
while (values[j] > pivot);
|
|
18084
|
-
if (i >= j) break;
|
|
18085
|
-
swap(values, boxes, indices, i, j);
|
|
18086
|
-
}
|
|
18087
|
-
stack.push(l, j, j + 1, r);
|
|
17071
|
+
var SourceView = class {
|
|
17072
|
+
source;
|
|
17073
|
+
middleware;
|
|
17074
|
+
static is(s) {
|
|
17075
|
+
if ("middleware" in s) return true;
|
|
17076
|
+
return false;
|
|
18088
17077
|
}
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
* @param {Int32Array} values
|
|
18093
|
-
* @param {TypedArray} boxes
|
|
18094
|
-
* @param {Uint16Array | Uint32Array} indices
|
|
18095
|
-
* @param {number} i
|
|
18096
|
-
* @param {number} j
|
|
18097
|
-
*/
|
|
18098
|
-
function swap(values, boxes, indices, i, j) {
|
|
18099
|
-
const temp = values[i];
|
|
18100
|
-
values[i] = values[j];
|
|
18101
|
-
values[j] = temp;
|
|
18102
|
-
const k = 4 * i;
|
|
18103
|
-
const m = 4 * j;
|
|
18104
|
-
const a = boxes[k];
|
|
18105
|
-
const b = boxes[k + 1];
|
|
18106
|
-
const c = boxes[k + 2];
|
|
18107
|
-
const d = boxes[k + 3];
|
|
18108
|
-
boxes[k] = boxes[m];
|
|
18109
|
-
boxes[k + 1] = boxes[m + 1];
|
|
18110
|
-
boxes[k + 2] = boxes[m + 2];
|
|
18111
|
-
boxes[k + 3] = boxes[m + 3];
|
|
18112
|
-
boxes[m] = a;
|
|
18113
|
-
boxes[m + 1] = b;
|
|
18114
|
-
boxes[m + 2] = c;
|
|
18115
|
-
boxes[m + 3] = d;
|
|
18116
|
-
const e = indices[i];
|
|
18117
|
-
indices[i] = indices[j];
|
|
18118
|
-
indices[j] = e;
|
|
18119
|
-
}
|
|
18120
|
-
/**
|
|
18121
|
-
* Fast Hilbert curve algorithm by http://threadlocalmutex.com/
|
|
18122
|
-
* Ported from C++ https://github.com/rawrunprotected/hilbert_curves (public domain)
|
|
18123
|
-
* @param {number} x
|
|
18124
|
-
* @param {number} y
|
|
18125
|
-
*/
|
|
18126
|
-
function hilbert(x, y) {
|
|
18127
|
-
let a = x ^ y;
|
|
18128
|
-
let b = 65535 ^ a;
|
|
18129
|
-
let c = 65535 ^ (x | y);
|
|
18130
|
-
let d = x & (y ^ 65535);
|
|
18131
|
-
let A = a | b >> 1;
|
|
18132
|
-
let B = a >> 1 ^ a;
|
|
18133
|
-
let C = c ^ (c >> 1 ^ b & d >> 1);
|
|
18134
|
-
let D = d ^ (a & c >> 1 ^ d >> 1);
|
|
18135
|
-
a = A & A >> 2 ^ B & B >> 2;
|
|
18136
|
-
b = A & B >> 2 ^ B & (A ^ B) >> 2;
|
|
18137
|
-
c = C ^ (A & C >> 2 ^ B & D >> 2);
|
|
18138
|
-
d = D ^ (B & C >> 2 ^ (A ^ B) & D >> 2);
|
|
18139
|
-
A = a & a >> 4 ^ b & b >> 4;
|
|
18140
|
-
B = a & b >> 4 ^ b & (a ^ b) >> 4;
|
|
18141
|
-
C = c ^ (a & c >> 4 ^ b & d >> 4);
|
|
18142
|
-
D = d ^ (b & c >> 4 ^ (a ^ b) & d >> 4);
|
|
18143
|
-
c = C ^ (A & C >> 8 ^ B & D >> 8);
|
|
18144
|
-
d = D ^ (B & C >> 8 ^ (A ^ B) & D >> 8);
|
|
18145
|
-
c ^= c >> 1;
|
|
18146
|
-
d ^= d >> 1;
|
|
18147
|
-
a = x ^ y;
|
|
18148
|
-
b = d | 65535 ^ (a | c);
|
|
18149
|
-
a = (a | a << 8) & 16711935;
|
|
18150
|
-
a = (a | a << 4) & 252645135;
|
|
18151
|
-
a = (a | a << 2) & 858993459;
|
|
18152
|
-
a = (a | a << 1) & 1431655765;
|
|
18153
|
-
b = (b | b << 8) & 16711935;
|
|
18154
|
-
b = (b | b << 4) & 252645135;
|
|
18155
|
-
b = (b | b << 2) & 858993459;
|
|
18156
|
-
b = (b | b << 1) & 1431655765;
|
|
18157
|
-
return ((b << 1 | a) >>> 0) - 2147483648;
|
|
18158
|
-
}
|
|
18159
|
-
//#endregion
|
|
18160
|
-
//#region node_modules/@developmentseed/deck.gl-geotiff/dist/mosaic-layer/mosaic-tileset-2d.js
|
|
18161
|
-
var MosaicTileset2D = class extends _Tileset2D {
|
|
18162
|
-
/** Closure returning the parent layer's current sources array. Re-evaluated
|
|
18163
|
-
* on each `getTileIndices` call so updates to the layer's `sources` prop
|
|
18164
|
-
* propagate without recreating the tileset. */
|
|
18165
|
-
getSources;
|
|
18166
|
-
/** Access the spatial index on the MosaicLayer instance. */
|
|
18167
|
-
getIndex;
|
|
18168
|
-
constructor(getSources, getIndex, opts) {
|
|
18169
|
-
super(opts);
|
|
18170
|
-
this.getIndex = getIndex;
|
|
18171
|
-
this.getSources = getSources;
|
|
17078
|
+
constructor(source, middleware = []) {
|
|
17079
|
+
this.source = source;
|
|
17080
|
+
this.middleware = middleware;
|
|
18172
17081
|
}
|
|
18173
|
-
|
|
18174
|
-
|
|
18175
|
-
return tileIndex.id;
|
|
17082
|
+
get type() {
|
|
17083
|
+
return this.source.type;
|
|
18176
17084
|
}
|
|
18177
|
-
|
|
18178
|
-
|
|
18179
|
-
return 0;
|
|
17085
|
+
get url() {
|
|
17086
|
+
return this.source.url;
|
|
18180
17087
|
}
|
|
18181
|
-
|
|
18182
|
-
|
|
18183
|
-
const { id, bbox } = tileIndex;
|
|
18184
|
-
return {
|
|
18185
|
-
id,
|
|
18186
|
-
bbox
|
|
18187
|
-
};
|
|
17088
|
+
get metadata() {
|
|
17089
|
+
return this.source.metadata;
|
|
18188
17090
|
}
|
|
18189
|
-
|
|
18190
|
-
return
|
|
17091
|
+
head(options) {
|
|
17092
|
+
return this.source.head(options);
|
|
18191
17093
|
}
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
if (
|
|
18195
|
-
const
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
|
|
18200
|
-
const
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
...source,
|
|
18207
|
-
id: source.id ?? String(sourceIndex)
|
|
18208
|
-
};
|
|
17094
|
+
async fetch(offset, length, options) {
|
|
17095
|
+
const middleware = this.middleware;
|
|
17096
|
+
if (middleware == null || middleware.length === 0) return this.source.fetch(offset, length, options);
|
|
17097
|
+
const handler = (req) => this.source.fetch(req.offset, req.length, options);
|
|
17098
|
+
return this.run(handler, offset, length, options);
|
|
17099
|
+
}
|
|
17100
|
+
/** Run a request using all the middleware */
|
|
17101
|
+
async run(handler, offset, length, options) {
|
|
17102
|
+
const middleware = this.middleware;
|
|
17103
|
+
if (middleware == null) return handler({
|
|
17104
|
+
source: this,
|
|
17105
|
+
offset,
|
|
17106
|
+
length,
|
|
17107
|
+
signal: options?.signal
|
|
18209
17108
|
});
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
17109
|
+
function runMiddleware(middleware, next) {
|
|
17110
|
+
return (req) => middleware.fetch(req, next);
|
|
17111
|
+
}
|
|
17112
|
+
for (let i = middleware.length - 1; i >= 0; i--) handler = runMiddleware(middleware[i], handler);
|
|
17113
|
+
return handler({
|
|
17114
|
+
source: this,
|
|
17115
|
+
offset,
|
|
17116
|
+
length,
|
|
17117
|
+
signal: options?.signal
|
|
18215
17118
|
});
|
|
18216
17119
|
}
|
|
18217
17120
|
};
|
|
18218
17121
|
//#endregion
|
|
18219
|
-
//#region node_modules/@
|
|
18220
|
-
var defaultProps = { sources: [] };
|
|
17122
|
+
//#region node_modules/@chunkd/middleware/build/src/middleware/chunk.js
|
|
18221
17123
|
/**
|
|
18222
|
-
*
|
|
17124
|
+
* Chunk requests into requests of specific byte sizes
|
|
17125
|
+
* If a request is split into smaller chunks should that be re-run as smaller requests and combined later
|
|
18223
17126
|
*
|
|
18224
|
-
*
|
|
18225
|
-
* viewport.
|
|
17127
|
+
* This can **GREATLY** increase cache hits when using a @see {SourceCache}
|
|
18226
17128
|
*/
|
|
18227
|
-
var
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
this.
|
|
17129
|
+
var SourceChunk = class {
|
|
17130
|
+
name = "source:chunk";
|
|
17131
|
+
/** Number of bytes to chunk requests into */
|
|
17132
|
+
chunkSize;
|
|
17133
|
+
constructor(opts) {
|
|
17134
|
+
this.chunkSize = opts.size ?? 32 * 1024;
|
|
18233
17135
|
}
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
|
|
17136
|
+
async fetch(req, next) {
|
|
17137
|
+
if (req.offset < 0) return next(req);
|
|
17138
|
+
if (req.length == null) return next(req);
|
|
17139
|
+
const startChunkId = Math.floor(req.offset / this.chunkSize);
|
|
17140
|
+
const endChunkId = Math.ceil((req.offset + req.length) / this.chunkSize);
|
|
17141
|
+
const maxSize = req.source.metadata?.size;
|
|
17142
|
+
if (maxSize != null && req.offset + req.length > maxSize) throw new SourceError(`Request outside of bounds ${ContentRange.toRange(req.offset, req.length)}`, 416, req.source);
|
|
17143
|
+
const startByte = startChunkId * this.chunkSize;
|
|
17144
|
+
const maxLength = (maxSize != null ? Math.min(endChunkId * this.chunkSize, maxSize) : endChunkId * this.chunkSize) - startByte;
|
|
17145
|
+
const chunkOffset = req.offset - startByte;
|
|
17146
|
+
if (endChunkId - startChunkId > 1) return (await this.fetchChunks(req, startChunkId, endChunkId)).slice(chunkOffset, chunkOffset + req.length);
|
|
17147
|
+
if (req.offset === startByte && req.length === maxLength) return next(req);
|
|
17148
|
+
return (await next({
|
|
17149
|
+
...req,
|
|
17150
|
+
offset: startByte,
|
|
17151
|
+
length: maxLength
|
|
17152
|
+
})).slice(chunkOffset, chunkOffset + req.length);
|
|
18238
17153
|
}
|
|
18239
|
-
|
|
18240
|
-
const
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
17154
|
+
async fetchChunks(req, startId, endId) {
|
|
17155
|
+
const promises = [];
|
|
17156
|
+
const maxEndByte = req.source.metadata?.size ?? endId * this.chunkSize;
|
|
17157
|
+
for (let chunk = startId; chunk < endId; chunk++) {
|
|
17158
|
+
const startByte = chunk * this.chunkSize;
|
|
17159
|
+
const chunkLength = Math.min(startByte + this.chunkSize, maxEndByte) - startByte;
|
|
17160
|
+
promises.push(req.source.fetch(chunk * this.chunkSize, chunkLength, req.signal ? { signal: req.signal } : void 0));
|
|
18244
17161
|
}
|
|
18245
|
-
const
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
|
|
17162
|
+
const results = await Promise.all(promises);
|
|
17163
|
+
const outputBuffer = new Uint8Array(promises.length * this.chunkSize);
|
|
17164
|
+
for (let i = 0; i < results.length; i++) outputBuffer.set(new Uint8Array(results[i]), i * this.chunkSize);
|
|
17165
|
+
return outputBuffer.buffer;
|
|
18249
17166
|
}
|
|
18250
|
-
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
17167
|
+
};
|
|
17168
|
+
//#endregion
|
|
17169
|
+
//#region node_modules/@chunkd/source-http/build/src/index.js
|
|
17170
|
+
/** Load the ETag and content-range from the response */
|
|
17171
|
+
function getMetadataFromResponse(response) {
|
|
17172
|
+
const metadata = {};
|
|
17173
|
+
const contentLength = response.headers.get("content-length");
|
|
17174
|
+
if (contentLength) metadata.size = parseInt(contentLength);
|
|
17175
|
+
const contentRange = response.headers.get("content-range");
|
|
17176
|
+
if (contentRange != null) metadata.size = ContentRange.parseSize(contentRange);
|
|
17177
|
+
metadata.eTag = response.headers.get("etag") ?? void 0;
|
|
17178
|
+
metadata.contentType = response.headers.get("content-type") ?? void 0;
|
|
17179
|
+
metadata.contentDisposition = response.headers.get("content-disposition") ?? void 0;
|
|
17180
|
+
metadata.cacheControl = response.headers.get("cache-control") ?? void 0;
|
|
17181
|
+
metadata.contentEncoding = response.headers.get("content-encoding") ?? void 0;
|
|
17182
|
+
return metadata;
|
|
17183
|
+
}
|
|
17184
|
+
var SourceHttp = class SourceHttp {
|
|
17185
|
+
constructor(url, headers) {
|
|
17186
|
+
this.type = "http";
|
|
17187
|
+
this.url = typeof url === "string" ? SourceHttp.tryUrl(url) : url;
|
|
17188
|
+
this.headers = headers;
|
|
17189
|
+
}
|
|
17190
|
+
/** Attempt to parse a relative string into a URL */
|
|
17191
|
+
static tryUrl(s) {
|
|
17192
|
+
try {
|
|
17193
|
+
return new URL(s);
|
|
17194
|
+
} catch (_e) {
|
|
17195
|
+
if (typeof document !== "undefined") return new URL(s, document.baseURI);
|
|
17196
|
+
return new URL(s, import.meta.url);
|
|
18258
17197
|
}
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
signal
|
|
18276
|
-
};
|
|
18277
|
-
},
|
|
18278
|
-
renderSubLayers: (props) => {
|
|
18279
|
-
const { data } = props;
|
|
18280
|
-
const { source, signal, data: userData } = data;
|
|
18281
|
-
return renderSource(source, {
|
|
18282
|
-
data: userData,
|
|
18283
|
-
signal
|
|
18284
|
-
});
|
|
18285
|
-
},
|
|
18286
|
-
...onSourceLoad && { onTileLoad: (tile) => {
|
|
18287
|
-
const source = tile.index;
|
|
18288
|
-
onSourceLoad(source, { data: tile.content?.data });
|
|
18289
|
-
} },
|
|
18290
|
-
...onSourceError && { onTileError: (error, tile) => {
|
|
18291
|
-
if (!tile) return;
|
|
18292
|
-
const source = tile.index;
|
|
18293
|
-
onSourceError(source, { error });
|
|
18294
|
-
} },
|
|
18295
|
-
...onSourceUnload && { onTileUnload: (tile) => {
|
|
18296
|
-
const source = tile.index;
|
|
18297
|
-
onSourceUnload(source, { data: tile.content?.data });
|
|
18298
|
-
} },
|
|
18299
|
-
...onViewportLoad && { onViewportLoad: (tiles) => {
|
|
18300
|
-
onViewportLoad(tiles.map((tile) => ({
|
|
18301
|
-
source: tile.index,
|
|
18302
|
-
data: tile.content?.data
|
|
18303
|
-
})));
|
|
18304
|
-
} }
|
|
17198
|
+
}
|
|
17199
|
+
head() {
|
|
17200
|
+
if (this._head) return this._head;
|
|
17201
|
+
this._head = SourceHttp.fetch(this.url, {
|
|
17202
|
+
method: "HEAD",
|
|
17203
|
+
headers: this.headers
|
|
17204
|
+
}).then((res) => {
|
|
17205
|
+
if (!res.ok) {
|
|
17206
|
+
delete this._head;
|
|
17207
|
+
throw new Error(`Failed to HEAD ${this.url.href}`, { cause: {
|
|
17208
|
+
statusCode: res.status,
|
|
17209
|
+
msg: res.statusText
|
|
17210
|
+
} });
|
|
17211
|
+
}
|
|
17212
|
+
this.metadata = getMetadataFromResponse(res);
|
|
17213
|
+
return this.metadata;
|
|
18305
17214
|
});
|
|
17215
|
+
return this._head;
|
|
18306
17216
|
}
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
17217
|
+
async fetch(offset, length, options) {
|
|
17218
|
+
try {
|
|
17219
|
+
const headers = {
|
|
17220
|
+
range: ContentRange.toRange(offset, length),
|
|
17221
|
+
...this.headers
|
|
17222
|
+
};
|
|
17223
|
+
const response = await SourceHttp.fetch(this.url, {
|
|
17224
|
+
headers,
|
|
17225
|
+
signal: options?.signal
|
|
17226
|
+
});
|
|
17227
|
+
if (!response.ok) throw new SourceError(`Failed to fetch ${this.url.href} ${headers.range}`, response.status, this, new Error(response.statusText));
|
|
17228
|
+
const metadata = getMetadataFromResponse(response);
|
|
17229
|
+
if (this.metadata == null) this.metadata = metadata;
|
|
17230
|
+
else if (this.metadata.eTag && this.metadata.eTag !== metadata.eTag) throw new SourceError(`ETag conflict ${this.url.href} ${headers.range} expected: ${this.metadata.eTag} got: ${metadata.eTag}`, 409, this);
|
|
17231
|
+
return response.arrayBuffer();
|
|
17232
|
+
} catch (e) {
|
|
17233
|
+
if (SourceError.is(e) && e.source === this) throw e;
|
|
17234
|
+
throw new SourceError(`Failed to fetch: ${this.url.href}`, 500, this, e);
|
|
17235
|
+
}
|
|
18311
17236
|
}
|
|
18312
17237
|
};
|
|
17238
|
+
SourceHttp.fetch = (a, b) => fetch(a, b);
|
|
18313
17239
|
//#endregion
|
|
18314
17240
|
//#region src/lib/raster/repair-geokeys.ts
|
|
18315
17241
|
var MODEL_TYPE_PROJECTED = 1;
|
|
@@ -24218,6 +23144,6 @@ var RasterControl = class {
|
|
|
24218
23144
|
}
|
|
24219
23145
|
};
|
|
24220
23146
|
//#endregion
|
|
24221
|
-
export { DEFAULT_TITILER_ENDPOINT as A, COLORMAP_ROW_COUNT as B, throttle as C, loadVrt as D, isVrtUrl as E, loadColormapSprite as F, statsForBand as G, colormaps_default as H, sampleColormapStops as I, mergeAutoStats as J, MAX_SAMPLE_TILES as K, COLORMAP_DISPLAY_NAMES as L, isMosaicJsonUrl as M, PALETTE_COLORMAP as N, parseVrt as O, isKnownColormap as P,
|
|
23147
|
+
export { Photometric as $, DEFAULT_TITILER_ENDPOINT as A, COLORMAP_ROW_COUNT as B, throttle as C, loadVrt as D, isVrtUrl as E, loadColormapSprite as F, statsForBand as G, colormaps_default as H, sampleColormapStops as I, mergeAutoStats as J, MAX_SAMPLE_TILES as K, COLORMAP_DISPLAY_NAMES as L, isMosaicJsonUrl as M, PALETTE_COLORMAP as N, parseVrt as O, isKnownColormap as P, Compression as Q, COLORMAP_NAMES as R, generateId as S, isVrtFile as T, DEFAULT_INDEX_RANGE as U, colormapDisplayName as V, autoRangeFor as W, percentileFromHistogram as X, mergeBandStats as Y, readBandNames as Z, parseMosaic as _, NORMALIZED_DIFFERENCE_INDICES as a, debounce as b, readPixelValues as c, MAX_MOSAIC_ASSETS as d, PlanarConfiguration as et, MosaicUnsupportedError as f, mosaicMinZoom as g, mosaicInitialView as h, CUSTOM_NORMALIZED_DIFFERENCE as i, createResilientEpsgResolver as it, TITILER_TMS as j, loadGeoTIFF as k, DEFAULT_ENGINE as l, loadMosaic as m, Colorbar as n, SampleFormat as nt, guessBandForRole as o, assetUrlToHttps as p, computeAutoStats as q, CUSTOM_INDEX_ID as r, TiffTag as rt, indexById as s, RasterControl as t, Predictor as tt, LayerManager as u, clamp as v, VrtUnsupportedError as w, formatNumericValue as x, classNames as y, COLORMAP_OPTIONS as z };
|
|
24222
23148
|
|
|
24223
|
-
//# sourceMappingURL=RasterControl-
|
|
23149
|
+
//# sourceMappingURL=RasterControl-GAiOG6eI.js.map
|