@ac-kit/format-tiff 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE +28 -0
  3. package/README.md +114 -2
  4. package/dist/codec/_deflate.d.ts +12 -0
  5. package/dist/codec/_deflate.d.ts.map +1 -0
  6. package/dist/codec/_deflate.js +33 -0
  7. package/dist/codec/_deflate.js.map +1 -0
  8. package/dist/codec/_lzw.d.ts +18 -0
  9. package/dist/codec/_lzw.d.ts.map +1 -0
  10. package/dist/codec/_lzw.js +134 -0
  11. package/dist/codec/_lzw.js.map +1 -0
  12. package/dist/codec/_packbits.d.ts +10 -0
  13. package/dist/codec/_packbits.d.ts.map +1 -0
  14. package/dist/codec/_packbits.js +34 -0
  15. package/dist/codec/_packbits.js.map +1 -0
  16. package/dist/codec/_predictor.d.ts +15 -0
  17. package/dist/codec/_predictor.d.ts.map +1 -0
  18. package/dist/codec/_predictor.js +68 -0
  19. package/dist/codec/_predictor.js.map +1 -0
  20. package/dist/codec/tiff-decoder.d.ts +54 -0
  21. package/dist/codec/tiff-decoder.d.ts.map +1 -0
  22. package/dist/codec/tiff-decoder.js +2 -0
  23. package/dist/codec/tiff-decoder.js.map +1 -0
  24. package/dist/container/_ifd.d.ts +45 -0
  25. package/dist/container/_ifd.d.ts.map +1 -0
  26. package/dist/container/_ifd.js +160 -0
  27. package/dist/container/_ifd.js.map +1 -0
  28. package/dist/container/_image.d.ts +37 -0
  29. package/dist/container/_image.d.ts.map +1 -0
  30. package/dist/container/_image.js +201 -0
  31. package/dist/container/_image.js.map +1 -0
  32. package/dist/container/_reader.d.ts +18 -0
  33. package/dist/container/_reader.d.ts.map +1 -0
  34. package/dist/container/_reader.js +53 -0
  35. package/dist/container/_reader.js.map +1 -0
  36. package/dist/container/open-tiff.d.ts +40 -0
  37. package/dist/container/open-tiff.d.ts.map +1 -0
  38. package/dist/container/open-tiff.js +209 -0
  39. package/dist/container/open-tiff.js.map +1 -0
  40. package/dist/container/read-tiff-gdal-metadata.d.ts +33 -0
  41. package/dist/container/read-tiff-gdal-metadata.d.ts.map +1 -0
  42. package/dist/container/read-tiff-gdal-metadata.js +82 -0
  43. package/dist/container/read-tiff-gdal-metadata.js.map +1 -0
  44. package/dist/container/tiff.d.ts +119 -0
  45. package/dist/container/tiff.d.ts.map +1 -0
  46. package/dist/container/tiff.js +2 -0
  47. package/dist/container/tiff.js.map +1 -0
  48. package/dist/errors.d.ts +34 -0
  49. package/dist/errors.d.ts.map +1 -0
  50. package/dist/errors.js +43 -0
  51. package/dist/errors.js.map +1 -0
  52. package/dist/field/_field-values.d.ts +10 -0
  53. package/dist/field/_field-values.d.ts.map +1 -0
  54. package/dist/field/_field-values.js +51 -0
  55. package/dist/field/_field-values.js.map +1 -0
  56. package/dist/field/tiff-field-type.d.ts +42 -0
  57. package/dist/field/tiff-field-type.d.ts.map +1 -0
  58. package/dist/field/tiff-field-type.js +68 -0
  59. package/dist/field/tiff-field-type.js.map +1 -0
  60. package/dist/field/tiff-field.d.ts +62 -0
  61. package/dist/field/tiff-field.d.ts.map +1 -0
  62. package/dist/field/tiff-field.js +125 -0
  63. package/dist/field/tiff-field.js.map +1 -0
  64. package/dist/field/tiff-tag.d.ts +120 -0
  65. package/dist/field/tiff-tag.d.ts.map +1 -0
  66. package/dist/field/tiff-tag.js +124 -0
  67. package/dist/field/tiff-tag.js.map +1 -0
  68. package/dist/geotiff/geo-key.d.ts +67 -0
  69. package/dist/geotiff/geo-key.d.ts.map +1 -0
  70. package/dist/geotiff/geo-key.js +69 -0
  71. package/dist/geotiff/geo-key.js.map +1 -0
  72. package/dist/geotiff/geotiff-raster-to-model.d.ts +36 -0
  73. package/dist/geotiff/geotiff-raster-to-model.d.ts.map +1 -0
  74. package/dist/geotiff/geotiff-raster-to-model.js +70 -0
  75. package/dist/geotiff/geotiff-raster-to-model.js.map +1 -0
  76. package/dist/geotiff/index.d.ts +4 -0
  77. package/dist/geotiff/index.d.ts.map +1 -0
  78. package/dist/geotiff/index.js +4 -0
  79. package/dist/geotiff/index.js.map +1 -0
  80. package/dist/geotiff/read-geotiff.d.ts +63 -0
  81. package/dist/geotiff/read-geotiff.d.ts.map +1 -0
  82. package/dist/geotiff/read-geotiff.js +150 -0
  83. package/dist/geotiff/read-geotiff.js.map +1 -0
  84. package/dist/index.d.ts +11 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +11 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/raster/_decode-chunk.d.ts +29 -0
  89. package/dist/raster/_decode-chunk.d.ts.map +1 -0
  90. package/dist/raster/_decode-chunk.js +159 -0
  91. package/dist/raster/_decode-chunk.js.map +1 -0
  92. package/dist/raster/_layout.d.ts +27 -0
  93. package/dist/raster/_layout.d.ts.map +1 -0
  94. package/dist/raster/_layout.js +79 -0
  95. package/dist/raster/_layout.js.map +1 -0
  96. package/dist/raster/_samples.d.ts +52 -0
  97. package/dist/raster/_samples.d.ts.map +1 -0
  98. package/dist/raster/_samples.js +192 -0
  99. package/dist/raster/_samples.js.map +1 -0
  100. package/dist/raster/read-tiff-window.d.ts +109 -0
  101. package/dist/raster/read-tiff-window.d.ts.map +1 -0
  102. package/dist/raster/read-tiff-window.js +396 -0
  103. package/dist/raster/read-tiff-window.js.map +1 -0
  104. package/dist/raster/tiff-sample-array.d.ts +7 -0
  105. package/dist/raster/tiff-sample-array.d.ts.map +1 -0
  106. package/dist/raster/tiff-sample-array.js +2 -0
  107. package/dist/raster/tiff-sample-array.js.map +1 -0
  108. package/package.json +68 -3
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The GeoKeys of GeoTIFF 1.1 (OGC 19-008r4 §7.1), by their ID in the
3
+ * `GeoKeyDirectoryTag`, with the 1.1 names (`GeodeticCRSGeoKey` for 1.0's
4
+ * `GeographicTypeGeoKey`, `ProjectedCRSGeoKey` for `ProjectedCSTypeGeoKey`,
5
+ * `VerticalGeoKey` for `VerticalCSTypeGeoKey`). Every other key is kept by ID.
6
+ */
7
+ export var GeoKey;
8
+ (function (GeoKey) {
9
+ GeoKey[GeoKey["GT_MODEL_TYPE"] = 1024] = "GT_MODEL_TYPE";
10
+ GeoKey[GeoKey["GT_RASTER_TYPE"] = 1025] = "GT_RASTER_TYPE";
11
+ GeoKey[GeoKey["GT_CITATION"] = 1026] = "GT_CITATION";
12
+ GeoKey[GeoKey["GEODETIC_CRS"] = 2048] = "GEODETIC_CRS";
13
+ GeoKey[GeoKey["GEODETIC_CITATION"] = 2049] = "GEODETIC_CITATION";
14
+ GeoKey[GeoKey["GEODETIC_DATUM"] = 2050] = "GEODETIC_DATUM";
15
+ GeoKey[GeoKey["PRIME_MERIDIAN"] = 2051] = "PRIME_MERIDIAN";
16
+ GeoKey[GeoKey["GEOG_LINEAR_UNITS"] = 2052] = "GEOG_LINEAR_UNITS";
17
+ GeoKey[GeoKey["GEOG_LINEAR_UNIT_SIZE"] = 2053] = "GEOG_LINEAR_UNIT_SIZE";
18
+ GeoKey[GeoKey["GEOG_ANGULAR_UNITS"] = 2054] = "GEOG_ANGULAR_UNITS";
19
+ GeoKey[GeoKey["GEOG_ANGULAR_UNIT_SIZE"] = 2055] = "GEOG_ANGULAR_UNIT_SIZE";
20
+ GeoKey[GeoKey["ELLIPSOID"] = 2056] = "ELLIPSOID";
21
+ GeoKey[GeoKey["ELLIPSOID_SEMI_MAJOR_AXIS"] = 2057] = "ELLIPSOID_SEMI_MAJOR_AXIS";
22
+ GeoKey[GeoKey["ELLIPSOID_SEMI_MINOR_AXIS"] = 2058] = "ELLIPSOID_SEMI_MINOR_AXIS";
23
+ GeoKey[GeoKey["ELLIPSOID_INV_FLATTENING"] = 2059] = "ELLIPSOID_INV_FLATTENING";
24
+ GeoKey[GeoKey["GEOG_AZIMUTH_UNITS"] = 2060] = "GEOG_AZIMUTH_UNITS";
25
+ GeoKey[GeoKey["PRIME_MERIDIAN_LONGITUDE"] = 2061] = "PRIME_MERIDIAN_LONGITUDE";
26
+ /** GeoTIFF 1.1 Annex: the datum shift to WGS 84, as GDAL writes it. */
27
+ GeoKey[GeoKey["GEOG_TO_WGS84"] = 2062] = "GEOG_TO_WGS84";
28
+ GeoKey[GeoKey["PROJECTED_CRS"] = 3072] = "PROJECTED_CRS";
29
+ GeoKey[GeoKey["PROJECTED_CITATION"] = 3073] = "PROJECTED_CITATION";
30
+ GeoKey[GeoKey["PROJECTION"] = 3074] = "PROJECTION";
31
+ GeoKey[GeoKey["PROJ_METHOD"] = 3075] = "PROJ_METHOD";
32
+ GeoKey[GeoKey["PROJ_LINEAR_UNITS"] = 3076] = "PROJ_LINEAR_UNITS";
33
+ GeoKey[GeoKey["PROJ_LINEAR_UNIT_SIZE"] = 3077] = "PROJ_LINEAR_UNIT_SIZE";
34
+ GeoKey[GeoKey["PROJ_STD_PARALLEL_1"] = 3078] = "PROJ_STD_PARALLEL_1";
35
+ GeoKey[GeoKey["PROJ_STD_PARALLEL_2"] = 3079] = "PROJ_STD_PARALLEL_2";
36
+ GeoKey[GeoKey["PROJ_NAT_ORIGIN_LONG"] = 3080] = "PROJ_NAT_ORIGIN_LONG";
37
+ GeoKey[GeoKey["PROJ_NAT_ORIGIN_LAT"] = 3081] = "PROJ_NAT_ORIGIN_LAT";
38
+ GeoKey[GeoKey["PROJ_FALSE_EASTING"] = 3082] = "PROJ_FALSE_EASTING";
39
+ GeoKey[GeoKey["PROJ_FALSE_NORTHING"] = 3083] = "PROJ_FALSE_NORTHING";
40
+ GeoKey[GeoKey["PROJ_FALSE_ORIGIN_LONG"] = 3084] = "PROJ_FALSE_ORIGIN_LONG";
41
+ GeoKey[GeoKey["PROJ_FALSE_ORIGIN_LAT"] = 3085] = "PROJ_FALSE_ORIGIN_LAT";
42
+ GeoKey[GeoKey["PROJ_FALSE_ORIGIN_EASTING"] = 3086] = "PROJ_FALSE_ORIGIN_EASTING";
43
+ GeoKey[GeoKey["PROJ_FALSE_ORIGIN_NORTHING"] = 3087] = "PROJ_FALSE_ORIGIN_NORTHING";
44
+ GeoKey[GeoKey["PROJ_CENTER_LONG"] = 3088] = "PROJ_CENTER_LONG";
45
+ GeoKey[GeoKey["PROJ_CENTER_LAT"] = 3089] = "PROJ_CENTER_LAT";
46
+ GeoKey[GeoKey["PROJ_CENTER_EASTING"] = 3090] = "PROJ_CENTER_EASTING";
47
+ GeoKey[GeoKey["PROJ_CENTER_NORTHING"] = 3091] = "PROJ_CENTER_NORTHING";
48
+ GeoKey[GeoKey["PROJ_SCALE_AT_NAT_ORIGIN"] = 3092] = "PROJ_SCALE_AT_NAT_ORIGIN";
49
+ GeoKey[GeoKey["PROJ_SCALE_AT_CENTER"] = 3093] = "PROJ_SCALE_AT_CENTER";
50
+ GeoKey[GeoKey["PROJ_AZIMUTH_ANGLE"] = 3094] = "PROJ_AZIMUTH_ANGLE";
51
+ GeoKey[GeoKey["PROJ_STRAIGHT_VERT_POLE_LONG"] = 3095] = "PROJ_STRAIGHT_VERT_POLE_LONG";
52
+ GeoKey[GeoKey["PROJ_RECTIFIED_GRID_ANGLE"] = 3096] = "PROJ_RECTIFIED_GRID_ANGLE";
53
+ GeoKey[GeoKey["VERTICAL"] = 4096] = "VERTICAL";
54
+ GeoKey[GeoKey["VERTICAL_CITATION"] = 4097] = "VERTICAL_CITATION";
55
+ GeoKey[GeoKey["VERTICAL_DATUM"] = 4098] = "VERTICAL_DATUM";
56
+ GeoKey[GeoKey["VERTICAL_UNITS"] = 4099] = "VERTICAL_UNITS";
57
+ })(GeoKey || (GeoKey = {}));
58
+ /** `GTModelTypeGeoKey` values (GeoTIFF 1.1 §7.4.1). */
59
+ export var GeoTiffModelType;
60
+ (function (GeoTiffModelType) {
61
+ GeoTiffModelType[GeoTiffModelType["PROJECTED"] = 1] = "PROJECTED";
62
+ /** Geodetic (geographic 2D) coordinates. */
63
+ GeoTiffModelType[GeoTiffModelType["GEODETIC"] = 2] = "GEODETIC";
64
+ GeoTiffModelType[GeoTiffModelType["GEOCENTRIC"] = 3] = "GEOCENTRIC";
65
+ GeoTiffModelType[GeoTiffModelType["USER_DEFINED"] = 32767] = "USER_DEFINED";
66
+ })(GeoTiffModelType || (GeoTiffModelType = {}));
67
+ /** The value GeoTIFF reserves for a user-defined code (§7.2). */
68
+ export const GEOTIFF_USER_DEFINED = 32767;
69
+ //# sourceMappingURL=geo-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-key.js","sourceRoot":"","sources":["../../src/geotiff/geo-key.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,MAiDX;AAjDD,WAAY,MAAM;IACjB,wDAAoB,CAAA;IACpB,0DAAqB,CAAA;IACrB,oDAAkB,CAAA;IAClB,sDAAmB,CAAA;IACnB,gEAAwB,CAAA;IACxB,0DAAqB,CAAA;IACrB,0DAAqB,CAAA;IACrB,gEAAwB,CAAA;IACxB,wEAA4B,CAAA;IAC5B,kEAAyB,CAAA;IACzB,0EAA6B,CAAA;IAC7B,gDAAgB,CAAA;IAChB,gFAAgC,CAAA;IAChC,gFAAgC,CAAA;IAChC,8EAA+B,CAAA;IAC/B,kEAAyB,CAAA;IACzB,8EAA+B,CAAA;IAC/B,uEAAuE;IACvE,wDAAoB,CAAA;IACpB,wDAAoB,CAAA;IACpB,kEAAyB,CAAA;IACzB,kDAAiB,CAAA;IACjB,oDAAkB,CAAA;IAClB,gEAAwB,CAAA;IACxB,wEAA4B,CAAA;IAC5B,oEAA0B,CAAA;IAC1B,oEAA0B,CAAA;IAC1B,sEAA2B,CAAA;IAC3B,oEAA0B,CAAA;IAC1B,kEAAyB,CAAA;IACzB,oEAA0B,CAAA;IAC1B,0EAA6B,CAAA;IAC7B,wEAA4B,CAAA;IAC5B,gFAAgC,CAAA;IAChC,kFAAiC,CAAA;IACjC,8DAAuB,CAAA;IACvB,4DAAsB,CAAA;IACtB,oEAA0B,CAAA;IAC1B,sEAA2B,CAAA;IAC3B,8EAA+B,CAAA;IAC/B,sEAA2B,CAAA;IAC3B,kEAAyB,CAAA;IACzB,sFAAmC,CAAA;IACnC,gFAAgC,CAAA;IAChC,8CAAe,CAAA;IACf,gEAAwB,CAAA;IACxB,0DAAqB,CAAA;IACrB,0DAAqB,CAAA;AACtB,CAAC,EAjDW,MAAM,KAAN,MAAM,QAiDjB;AAED,uDAAuD;AACvD,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC3B,iEAAa,CAAA;IACb,4CAA4C;IAC5C,+DAAY,CAAA;IACZ,mEAAc,CAAA;IACd,2EAAoB,CAAA;AACrB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Affine2 } from "@ac-kit/math-linear";
2
+ import type { TiffImage } from "../container/tiff.js";
3
+ /** Options of {@link geotiffRasterToModel}. */
4
+ export type GeotiffRasterToModelOptions = {
5
+ /**
6
+ * Where raster point `(0, 0)` is in the transform written: `"corner"` (the
7
+ * default), the outer corner of the first pixel, as GDAL's geotransform has
8
+ * it, so pixel `(i, j)` covers `[i, i + 1) × [j, j + 1)`; `"center"`, the
9
+ * centre of the first pixel, so sample `(i, j)` is at integer coordinates,
10
+ * natural for a DEM's posts. The file's raster type (PixelIsArea or
11
+ * PixelIsPoint) is accounted for either way.
12
+ */
13
+ readonly origin?: "corner" | "center" | undefined;
14
+ };
15
+ /**
16
+ * Writes to `out` the affine transform from raster `(column, row)` to model
17
+ * `(x, y)` coordinates of `image`: from its `ModelTransformationTag` (the 2D
18
+ * part), or from one tiepoint and its `ModelPixelScaleTag`, rows growing down
19
+ * as `y` decreases. A PixelIsPoint file's raster space is shifted half a pixel
20
+ * to the `origin` asked, as GDAL does by default.
21
+ *
22
+ * Allocates the {@link readGeoTiff} result; keep it out of hot loops.
23
+ *
24
+ * @example
25
+ * const rasterToModel = affine2Create();
26
+ * if (geotiffRasterToModel(rasterToModel, image, { origin: "center" })) {
27
+ * vec2TransformAffine2(lonLat, vec2Of(column, row), rasterToModel);
28
+ * }
29
+ *
30
+ * @returns Whether the image has such a transform; `out` is left untouched when
31
+ * it has none, or only ground control points (several tiepoints and no
32
+ * scale).
33
+ * @throws What {@link readGeoTiff} throws.
34
+ */
35
+ export declare function geotiffRasterToModel(out: Affine2, image: TiffImage, options?: GeotiffRasterToModelOptions): boolean;
36
+ //# sourceMappingURL=geotiff-raster-to-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff-raster-to-model.d.ts","sourceRoot":"","sources":["../../src/geotiff/geotiff-raster-to-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,+CAA+C;AAC/C,MAAM,MAAM,2BAA2B,GAAG;IACzC;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;CAClD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,SAAS,EAChB,OAAO,GAAE,2BAAgC,GACvC,OAAO,CA6CT"}
@@ -0,0 +1,70 @@
1
+ import { readGeoTiff } from "./read-geotiff.js";
2
+ /**
3
+ * Writes to `out` the affine transform from raster `(column, row)` to model
4
+ * `(x, y)` coordinates of `image`: from its `ModelTransformationTag` (the 2D
5
+ * part), or from one tiepoint and its `ModelPixelScaleTag`, rows growing down
6
+ * as `y` decreases. A PixelIsPoint file's raster space is shifted half a pixel
7
+ * to the `origin` asked, as GDAL does by default.
8
+ *
9
+ * Allocates the {@link readGeoTiff} result; keep it out of hot loops.
10
+ *
11
+ * @example
12
+ * const rasterToModel = affine2Create();
13
+ * if (geotiffRasterToModel(rasterToModel, image, { origin: "center" })) {
14
+ * vec2TransformAffine2(lonLat, vec2Of(column, row), rasterToModel);
15
+ * }
16
+ *
17
+ * @returns Whether the image has such a transform; `out` is left untouched when
18
+ * it has none, or only ground control points (several tiepoints and no
19
+ * scale).
20
+ * @throws What {@link readGeoTiff} throws.
21
+ */
22
+ export function geotiffRasterToModel(out, image, options = {}) {
23
+ const geo = readGeoTiff(image);
24
+ if (geo === undefined) {
25
+ return false;
26
+ }
27
+ let a;
28
+ let b;
29
+ let c;
30
+ let d;
31
+ let e;
32
+ let f;
33
+ const { transformation, pixelScale } = geo;
34
+ const tiepoint = geo.tiepoints[0];
35
+ if (transformation !== undefined) {
36
+ a = transformation[0];
37
+ c = transformation[1];
38
+ e = transformation[3];
39
+ b = transformation[4];
40
+ d = transformation[5];
41
+ f = transformation[7];
42
+ }
43
+ else if (pixelScale !== undefined && tiepoint !== undefined) {
44
+ a = pixelScale[0];
45
+ b = 0;
46
+ c = 0;
47
+ d = -pixelScale[1];
48
+ e = tiepoint.x - tiepoint.i * a;
49
+ f = tiepoint.y - tiepoint.j * d;
50
+ }
51
+ else {
52
+ return false;
53
+ }
54
+ // The file's raster origin, against the one asked: half a pixel apart.
55
+ const fileOrigin = geo.rasterType === "point" ? "center" : "corner";
56
+ const origin = options.origin ?? "corner";
57
+ if (fileOrigin !== origin) {
58
+ const shift = origin === "corner" ? -0.5 : 0.5;
59
+ e += shift * (a + c);
60
+ f += shift * (b + d);
61
+ }
62
+ out[0] = a;
63
+ out[1] = b;
64
+ out[2] = c;
65
+ out[3] = d;
66
+ out[4] = e;
67
+ out[5] = f;
68
+ return true;
69
+ }
70
+ //# sourceMappingURL=geotiff-raster-to-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff-raster-to-model.js","sourceRoot":"","sources":["../../src/geotiff/geotiff-raster-to-model.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAehD;;;;;;;;;;;;;;;;;;;GAmBG;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ACP,OAAO,KAAK,CAAC;IACd,CAAC;IACD,uEAAuE;IACvE,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACpE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;IAC1C,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/C,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACrB,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./geo-key.js";
2
+ export * from "./geotiff-raster-to-model.js";
3
+ export * from "./read-geotiff.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geotiff/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./geo-key.js";
2
+ export * from "./geotiff-raster-to-model.js";
3
+ export * from "./read-geotiff.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/geotiff/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { TiffImage } from "../container/tiff.js";
2
+ /**
3
+ * A GeoKey's value: one `SHORT` as a number, several as an array, `DOUBLE`s
4
+ * from `GeoDoubleParams` as an array, text from `GeoAsciiParams` as a string
5
+ * (its `|` terminator dropped).
6
+ */
7
+ export type GeoKeyValue = number | readonly number[] | string;
8
+ /** A `ModelTiepointTag` entry: raster point `(i, j, k)` at model `(x, y, z)`. */
9
+ export type GeoTiffTiepoint = {
10
+ readonly i: number;
11
+ readonly j: number;
12
+ readonly k: number;
13
+ readonly x: number;
14
+ readonly y: number;
15
+ readonly z: number;
16
+ };
17
+ /** The GeoTIFF 1.1 georeferencing of one image. */
18
+ export type GeoTiff = {
19
+ /** `KeyDirectoryVersion`, `KeyRevision` and `MinorRevision`: 1.1.0 or 1.1.1. */
20
+ readonly version: readonly [number, number, number];
21
+ /** Every GeoKey, by ID ({@link GeoKey}). */
22
+ readonly keys: ReadonlyMap<number, GeoKeyValue>;
23
+ /** `GTModelTypeGeoKey` ({@link GeoTiffModelType}). */
24
+ readonly modelType: number | undefined;
25
+ /**
26
+ * `GTRasterTypeGeoKey`: `"area"` (PixelIsArea, the default) when raster point
27
+ * `(0, 0)` is the outer corner of the first pixel, `"point"` (PixelIsPoint)
28
+ * when it is its centre.
29
+ */
30
+ readonly rasterType: "area" | "point";
31
+ /**
32
+ * The EPSG code of the horizontal CRS: `ProjectedCRSGeoKey` when present,
33
+ * else `GeodeticCRSGeoKey`; `"user-defined"` for 32767, which the other keys
34
+ * then describe.
35
+ */
36
+ readonly horizontalCrs: number | "user-defined" | undefined;
37
+ /** The EPSG code of `VerticalGeoKey` (EGM2008 heights: 3855). */
38
+ readonly verticalCrs: number | "user-defined" | undefined;
39
+ /** `ModelPixelScaleTag`: `(sx, sy, sz)`. */
40
+ readonly pixelScale: readonly [number, number, number] | undefined;
41
+ readonly tiepoints: readonly GeoTiffTiepoint[];
42
+ /** `ModelTransformationTag`: a 4 × 4 matrix, row by row. */
43
+ readonly transformation: readonly number[] | undefined;
44
+ };
45
+ /**
46
+ * The GeoTIFF 1.1 (OGC 19-008r4) georeferencing of `image`: its GeoKeys, the
47
+ * CRS codes they name, and the tiepoints, pixel scale and transformation that
48
+ * map its raster space to the model. `undefined` when it has none of these
49
+ * tags. {@link geotiffRasterToModel} turns them into an affine transform.
50
+ *
51
+ * Time and memory linear in the tags.
52
+ *
53
+ * @example
54
+ * const geo = readGeoTiff(image);
55
+ * geo?.horizontalCrs; // 4326
56
+ * geo?.verticalCrs; // 3855, EGM2008 heights
57
+ *
58
+ * @throws {TiffFormatError} When the key directory is cut short, of a version
59
+ * other than 1, or refers past its parameter tags; when the tiepoint, scale
60
+ * or transformation tags have the wrong number of values.
61
+ */
62
+ export declare function readGeoTiff(image: TiffImage): GeoTiff | undefined;
63
+ //# sourceMappingURL=read-geotiff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-geotiff.d.ts","sourceRoot":"","sources":["../../src/geotiff/read-geotiff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAWtD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC;AAE9D,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,OAAO,GAAG;IACrB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChD,sDAAsD;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC5D,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC1D,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACnE,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,4DAA4D;IAC5D,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACvD,CAAC;AAuFF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CA4EjE"}
@@ -0,0 +1,150 @@
1
+ import { TiffFormatError } from "../errors.js";
2
+ import { fieldNumberAt_, fieldValueCount_ } from "../field/_field-values.js";
3
+ import { tiffFieldNumbers, tiffFieldText, } from "../field/tiff-field.js";
4
+ import { TiffTag } from "../field/tiff-tag.js";
5
+ import { GEOTIFF_USER_DEFINED, GeoKey } from "./geo-key.js";
6
+ function code_(keys, key) {
7
+ const value = keys.get(key);
8
+ if (typeof value !== "number") {
9
+ return undefined;
10
+ }
11
+ return value === GEOTIFF_USER_DEFINED ? "user-defined" : value;
12
+ }
13
+ function readKeys_(image, directory) {
14
+ const shorts = fieldValueCount_(directory);
15
+ const at = (index) => {
16
+ if (index >= shorts) {
17
+ throw new TiffFormatError(`GeoKeyDirectoryTag cut short at value ${index}`, image.offset);
18
+ }
19
+ return fieldNumberAt_(directory, index);
20
+ };
21
+ const version = [at(0), at(1), at(2)];
22
+ if (version[0] !== 1) {
23
+ throw new TiffFormatError(`GeoKeyDirectoryTag version ${version[0]}`, image.offset);
24
+ }
25
+ const count = at(3);
26
+ const doublesField = image.fields.get(TiffTag.GEO_DOUBLE_PARAMS);
27
+ const doubles = doublesField === undefined ? [] : tiffFieldNumbers(doublesField);
28
+ const asciiField = image.fields.get(TiffTag.GEO_ASCII_PARAMS);
29
+ const ascii = asciiField === undefined ? "" : tiffFieldText(asciiField).join("\0");
30
+ const keys = new Map();
31
+ for (let index = 0; index < count; index++) {
32
+ const base = 4 + index * 4;
33
+ const key = at(base);
34
+ const location = at(base + 1);
35
+ const valueCount = at(base + 2);
36
+ const valueOffset = at(base + 3);
37
+ let value;
38
+ if (location === 0) {
39
+ value = valueOffset;
40
+ }
41
+ else if (location === TiffTag.GEO_DOUBLE_PARAMS) {
42
+ if (valueOffset + valueCount > doubles.length) {
43
+ throw new TiffFormatError(`GeoKey ${key} past GeoDoubleParamsTag`, image.offset);
44
+ }
45
+ const values = doubles.slice(valueOffset, valueOffset + valueCount);
46
+ value = values.length === 1 ? values[0] : values;
47
+ }
48
+ else if (location === TiffTag.GEO_ASCII_PARAMS) {
49
+ if (valueOffset + valueCount > ascii.length) {
50
+ throw new TiffFormatError(`GeoKey ${key} past GeoAsciiParamsTag`, image.offset);
51
+ }
52
+ value = ascii
53
+ .slice(valueOffset, valueOffset + valueCount)
54
+ .replace(/[|\0]$/u, "");
55
+ }
56
+ else if (location === TiffTag.GEO_KEY_DIRECTORY) {
57
+ const values = [];
58
+ for (let offset = 0; offset < valueCount; offset++) {
59
+ values.push(at(valueOffset + offset));
60
+ }
61
+ value = values.length === 1 ? values[0] : values;
62
+ }
63
+ else {
64
+ throw new TiffFormatError(`GeoKey ${key} in tag ${location}`, image.offset);
65
+ }
66
+ keys.set(key, value);
67
+ }
68
+ return { version, keys };
69
+ }
70
+ /**
71
+ * The GeoTIFF 1.1 (OGC 19-008r4) georeferencing of `image`: its GeoKeys, the
72
+ * CRS codes they name, and the tiepoints, pixel scale and transformation that
73
+ * map its raster space to the model. `undefined` when it has none of these
74
+ * tags. {@link geotiffRasterToModel} turns them into an affine transform.
75
+ *
76
+ * Time and memory linear in the tags.
77
+ *
78
+ * @example
79
+ * const geo = readGeoTiff(image);
80
+ * geo?.horizontalCrs; // 4326
81
+ * geo?.verticalCrs; // 3855, EGM2008 heights
82
+ *
83
+ * @throws {TiffFormatError} When the key directory is cut short, of a version
84
+ * other than 1, or refers past its parameter tags; when the tiepoint, scale
85
+ * or transformation tags have the wrong number of values.
86
+ */
87
+ export function readGeoTiff(image) {
88
+ const { fields } = image;
89
+ const directory = fields.get(TiffTag.GEO_KEY_DIRECTORY);
90
+ const scaleField = fields.get(TiffTag.MODEL_PIXEL_SCALE);
91
+ const tiepointField = fields.get(TiffTag.MODEL_TIEPOINT);
92
+ const transformationField = fields.get(TiffTag.MODEL_TRANSFORMATION);
93
+ if (directory === undefined &&
94
+ scaleField === undefined &&
95
+ tiepointField === undefined &&
96
+ transformationField === undefined) {
97
+ return undefined;
98
+ }
99
+ const { version, keys } = directory === undefined
100
+ ? {
101
+ version: [1, 1, 0],
102
+ keys: new Map(),
103
+ }
104
+ : readKeys_(image, directory);
105
+ let pixelScale;
106
+ if (scaleField !== undefined) {
107
+ const values = tiffFieldNumbers(scaleField);
108
+ if (values.length < 2) {
109
+ throw new TiffFormatError(`ModelPixelScaleTag of ${values.length} values`, image.offset);
110
+ }
111
+ pixelScale = [values[0], values[1], values[2] ?? 0];
112
+ }
113
+ const tiepoints = [];
114
+ if (tiepointField !== undefined) {
115
+ const values = tiffFieldNumbers(tiepointField);
116
+ if (values.length % 6 !== 0) {
117
+ throw new TiffFormatError(`ModelTiepointTag of ${values.length} values`, image.offset);
118
+ }
119
+ for (let index = 0; index < values.length; index += 6) {
120
+ tiepoints.push({
121
+ i: values[index],
122
+ j: values[index + 1],
123
+ k: values[index + 2],
124
+ x: values[index + 3],
125
+ y: values[index + 4],
126
+ z: values[index + 5],
127
+ });
128
+ }
129
+ }
130
+ let transformation;
131
+ if (transformationField !== undefined) {
132
+ transformation = tiffFieldNumbers(transformationField);
133
+ if (transformation.length !== 16) {
134
+ throw new TiffFormatError(`ModelTransformationTag of ${transformation.length} values`, image.offset);
135
+ }
136
+ }
137
+ const modelType = keys.get(GeoKey.GT_MODEL_TYPE);
138
+ return {
139
+ version,
140
+ keys,
141
+ modelType: typeof modelType === "number" ? modelType : undefined,
142
+ rasterType: keys.get(GeoKey.GT_RASTER_TYPE) === 2 ? "point" : "area",
143
+ horizontalCrs: code_(keys, GeoKey.PROJECTED_CRS) ?? code_(keys, GeoKey.GEODETIC_CRS),
144
+ verticalCrs: code_(keys, GeoKey.VERTICAL),
145
+ pixelScale,
146
+ tiepoints,
147
+ transformation,
148
+ };
149
+ }
150
+ //# sourceMappingURL=read-geotiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-geotiff.js","sourceRoot":"","sources":["../../src/geotiff/read-geotiff.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAEN,gBAAgB,EAChB,aAAa,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAgD5D,SAAS,KAAK,CACb,IAAsC,EACtC,GAAW;IA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pE,aAAa,EACZ,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC;QACtE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC;QACzC,UAAU;QACV,SAAS;QACT,cAAc;KACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from "./codec/tiff-decoder.js";
2
+ export * from "./container/open-tiff.js";
3
+ export * from "./container/read-tiff-gdal-metadata.js";
4
+ export * from "./container/tiff.js";
5
+ export * from "./errors.js";
6
+ export * from "./field/tiff-field.js";
7
+ export * from "./field/tiff-field-type.js";
8
+ export * from "./field/tiff-tag.js";
9
+ export * from "./raster/read-tiff-window.js";
10
+ export * from "./raster/tiff-sample-array.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wCAAwC,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./codec/tiff-decoder.js";
2
+ export * from "./container/open-tiff.js";
3
+ export * from "./container/read-tiff-gdal-metadata.js";
4
+ export * from "./container/tiff.js";
5
+ export * from "./errors.js";
6
+ export * from "./field/tiff-field.js";
7
+ export * from "./field/tiff-field-type.js";
8
+ export * from "./field/tiff-tag.js";
9
+ export * from "./raster/read-tiff-window.js";
10
+ export * from "./raster/tiff-sample-array.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wCAAwC,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { TiffDecoders } from "../codec/tiff-decoder.js";
2
+ import type { ImageContext_ } from "../container/_image.js";
3
+ import type { TiffImage } from "../container/tiff.js";
4
+ /** One strip or tile of one plane, where it is and what it decodes to. */
5
+ export type Chunk_ = {
6
+ readonly index: number;
7
+ readonly plane: number;
8
+ readonly column: number;
9
+ readonly row: number;
10
+ readonly offset: number;
11
+ readonly byteCount: number;
12
+ readonly rows: number;
13
+ readonly rowBytes: number;
14
+ };
15
+ /**
16
+ * Checks that the image's codec, predictor and colour layout can be decoded,
17
+ * before any read.
18
+ *
19
+ * @throws {TiffUnsupportedError} For a compression with no decoder, a predictor
20
+ * other than 1–3 or one the samples' widths rule out, or subsampled YCbCr
21
+ * outside JPEG.
22
+ */
23
+ export declare function checkDecodable_(image: TiffImage, decoders: TiffDecoders | undefined): void;
24
+ /**
25
+ * Decodes one stored chunk to its rows, predictor undone, in an array the
26
+ * caller may change. `stored` holds exactly the chunk's bytes.
27
+ */
28
+ export declare function decodeChunk_(image: TiffImage, context: ImageContext_, chunk: Chunk_, stored: Uint8Array<ArrayBuffer>, decoders: TiffDecoders | undefined, signal: AbortSignal | undefined): Promise<Uint8Array<ArrayBuffer>>;
29
+ //# sourceMappingURL=_decode-chunk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_decode-chunk.d.ts","sourceRoot":"","sources":["../../src/raster/_decode-chunk.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAStD,0EAA0E;AAC1E,MAAM,MAAM,MAAM,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B,CAAC;AAWF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,YAAY,GAAG,SAAS,GAChC,IAAI,CA6DN;AAED;;;GAGG;AACH,wBAAsB,YAAY,CACjC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,EAC/B,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC7B,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAgFlC"}