@developmentseed/geotiff 0.3.0-beta.3

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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -0
  3. package/dist/api.d.ts +34 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +84 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/array.d.ts +75 -0
  8. package/dist/array.d.ts.map +1 -0
  9. package/dist/array.js +141 -0
  10. package/dist/array.js.map +1 -0
  11. package/dist/codecs/canvas.d.ts +3 -0
  12. package/dist/codecs/canvas.d.ts.map +1 -0
  13. package/dist/codecs/canvas.js +32 -0
  14. package/dist/codecs/canvas.js.map +1 -0
  15. package/dist/codecs/decompression-stream.d.ts +6 -0
  16. package/dist/codecs/decompression-stream.d.ts.map +1 -0
  17. package/dist/codecs/decompression-stream.js +19 -0
  18. package/dist/codecs/decompression-stream.js.map +1 -0
  19. package/dist/codecs/deflate.d.ts +2 -0
  20. package/dist/codecs/deflate.d.ts.map +1 -0
  21. package/dist/codecs/deflate.js +5 -0
  22. package/dist/codecs/deflate.js.map +1 -0
  23. package/dist/codecs/lerc.d.ts +3 -0
  24. package/dist/codecs/lerc.d.ts.map +1 -0
  25. package/dist/codecs/lerc.js +16 -0
  26. package/dist/codecs/lerc.js.map +1 -0
  27. package/dist/codecs/lzw.d.ts +3 -0
  28. package/dist/codecs/lzw.d.ts.map +1 -0
  29. package/dist/codecs/lzw.js +8 -0
  30. package/dist/codecs/lzw.js.map +1 -0
  31. package/dist/codecs/predictor.d.ts +15 -0
  32. package/dist/codecs/predictor.d.ts.map +1 -0
  33. package/dist/codecs/predictor.js +88 -0
  34. package/dist/codecs/predictor.js.map +1 -0
  35. package/dist/colormap.d.ts +10 -0
  36. package/dist/colormap.d.ts.map +1 -0
  37. package/dist/colormap.js +31 -0
  38. package/dist/colormap.js.map +1 -0
  39. package/dist/crs.d.ts +86 -0
  40. package/dist/crs.d.ts.map +1 -0
  41. package/dist/crs.js +462 -0
  42. package/dist/crs.js.map +1 -0
  43. package/dist/decode/api.d.ts +28 -0
  44. package/dist/decode/api.d.ts.map +1 -0
  45. package/dist/decode/api.js +80 -0
  46. package/dist/decode/api.js.map +1 -0
  47. package/dist/decode.d.ts +34 -0
  48. package/dist/decode.d.ts.map +1 -0
  49. package/dist/decode.js +84 -0
  50. package/dist/decode.js.map +1 -0
  51. package/dist/fetch.d.ts +27 -0
  52. package/dist/fetch.d.ts.map +1 -0
  53. package/dist/fetch.js +116 -0
  54. package/dist/fetch.js.map +1 -0
  55. package/dist/geotiff.d.ts +116 -0
  56. package/dist/geotiff.d.ts.map +1 -0
  57. package/dist/geotiff.js +239 -0
  58. package/dist/geotiff.js.map +1 -0
  59. package/dist/ifd.d.ts +84 -0
  60. package/dist/ifd.d.ts.map +1 -0
  61. package/dist/ifd.js +113 -0
  62. package/dist/ifd.js.map +1 -0
  63. package/dist/index.d.ts +10 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +6 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/overview.d.ts +55 -0
  68. package/dist/overview.d.ts.map +1 -0
  69. package/dist/overview.js +78 -0
  70. package/dist/overview.js.map +1 -0
  71. package/dist/tile-matrix-set.d.ts +36 -0
  72. package/dist/tile-matrix-set.d.ts.map +1 -0
  73. package/dist/tile-matrix-set.js +87 -0
  74. package/dist/tile-matrix-set.js.map +1 -0
  75. package/dist/tile.d.ts +11 -0
  76. package/dist/tile.d.ts.map +1 -0
  77. package/dist/tile.js +2 -0
  78. package/dist/tile.js.map +1 -0
  79. package/dist/transform.d.ts +28 -0
  80. package/dist/transform.d.ts.map +1 -0
  81. package/dist/transform.js +51 -0
  82. package/dist/transform.js.map +1 -0
  83. package/dist/tsconfig.tsbuildinfo +1 -0
  84. package/package.json +59 -0
package/dist/ifd.d.ts ADDED
@@ -0,0 +1,84 @@
1
+ import type { TiffImage, TiffTagGeoType, TiffTagType } from "@cogeotiff/core";
2
+ import { TiffTag, TiffTagGeo } from "@cogeotiff/core";
3
+ export declare enum Predictor {
4
+ None = 1,
5
+ /** Horizontal differencing */
6
+ Horizontal = 2,
7
+ /** Floating point */
8
+ FloatingPoint = 3
9
+ }
10
+ /** Subset of TIFF tags that we pre-fetch for easier visualization. */
11
+ export interface CachedTags {
12
+ bitsPerSample: Uint16Array;
13
+ colorMap?: Uint16Array;
14
+ compression: TiffTagType[TiffTag.Compression];
15
+ nodata: number | null;
16
+ photometric: TiffTagType[TiffTag.Photometric];
17
+ /** https://web.archive.org/web/20240329145322/https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html */
18
+ planarConfiguration: TiffTagType[TiffTag.PlanarConfiguration];
19
+ predictor: Predictor;
20
+ sampleFormat: TiffTagType[TiffTag.SampleFormat];
21
+ samplesPerPixel: TiffTagType[TiffTag.SamplesPerPixel];
22
+ }
23
+ /** Pre-fetch TIFF tags for easier visualization. */
24
+ export declare function prefetchTags(image: TiffImage): Promise<CachedTags>;
25
+ /**
26
+ * Parsed GeoKey directory.
27
+ *
28
+ * All fields are optional because any given GeoTIFF may only contain a subset
29
+ * of keys. Types reference `TiffTagGeoType` so `@cogeotiff/core` remains the
30
+ * source of truth.
31
+ *
32
+ * @see https://docs.ogc.org/is/19-008r4/19-008r4.html#_summary_of_geokey_ids_and_names
33
+ */
34
+ export type GeoKeyDirectory = {
35
+ modelType: TiffTagGeoType[TiffTagGeo.GTModelTypeGeoKey] | null;
36
+ rasterType: TiffTagGeoType[TiffTagGeo.GTRasterTypeGeoKey] | null;
37
+ citation: TiffTagGeoType[TiffTagGeo.GTCitationGeoKey] | null;
38
+ geodeticCRS: TiffTagGeoType[TiffTagGeo.GeodeticCRSGeoKey] | null;
39
+ geodeticCitation: TiffTagGeoType[TiffTagGeo.GeodeticCitationGeoKey] | null;
40
+ geodeticDatum: TiffTagGeoType[TiffTagGeo.GeodeticDatumGeoKey] | null;
41
+ primeMeridian: TiffTagGeoType[TiffTagGeo.PrimeMeridianGeoKey] | null;
42
+ linearUnits: TiffTagGeoType[TiffTagGeo.GeogLinearUnitsGeoKey] | null;
43
+ linearUnitSize: TiffTagGeoType[TiffTagGeo.GeogLinearUnitSizeGeoKey] | null;
44
+ angularUnits: TiffTagGeoType[TiffTagGeo.GeogAngularUnitsGeoKey] | null;
45
+ angularUnitSize: TiffTagGeoType[TiffTagGeo.GeogAngularUnitSizeGeoKey] | null;
46
+ ellipsoid: TiffTagGeoType[TiffTagGeo.EllipsoidGeoKey] | null;
47
+ ellipsoidSemiMajorAxis: TiffTagGeoType[TiffTagGeo.EllipsoidSemiMajorAxisGeoKey] | null;
48
+ ellipsoidSemiMinorAxis: TiffTagGeoType[TiffTagGeo.EllipsoidSemiMinorAxisGeoKey] | null;
49
+ ellipsoidInvFlattening: TiffTagGeoType[TiffTagGeo.EllipsoidInvFlatteningGeoKey] | null;
50
+ azimuthUnits: TiffTagGeoType[TiffTagGeo.GeogAzimuthUnitsGeoKey] | null;
51
+ primeMeridianLongitude: TiffTagGeoType[TiffTagGeo.PrimeMeridianLongitudeGeoKey] | null;
52
+ toWGS84: TiffTagGeoType[TiffTagGeo.GeogTOWGS84GeoKey] | null;
53
+ projectedCRS: TiffTagGeoType[TiffTagGeo.ProjectedCRSGeoKey] | null;
54
+ projectedCitation: TiffTagGeoType[TiffTagGeo.ProjectedCitationGeoKey] | null;
55
+ projection: TiffTagGeoType[TiffTagGeo.ProjectionGeoKey] | null;
56
+ projMethod: TiffTagGeoType[TiffTagGeo.ProjMethodGeoKey] | null;
57
+ projLinearUnits: TiffTagGeoType[TiffTagGeo.ProjLinearUnitsGeoKey] | null;
58
+ projLinearUnitSize: TiffTagGeoType[TiffTagGeo.ProjLinearUnitSizeGeoKey] | null;
59
+ projStdParallel1: TiffTagGeoType[TiffTagGeo.ProjStdParallel1GeoKey] | null;
60
+ projStdParallel2: TiffTagGeoType[TiffTagGeo.ProjStdParallel2GeoKey] | null;
61
+ projNatOriginLong: TiffTagGeoType[TiffTagGeo.ProjNatOriginLongGeoKey] | null;
62
+ projNatOriginLat: TiffTagGeoType[TiffTagGeo.ProjNatOriginLatGeoKey] | null;
63
+ projFalseEasting: TiffTagGeoType[TiffTagGeo.ProjFalseEastingGeoKey] | null;
64
+ projFalseNorthing: TiffTagGeoType[TiffTagGeo.ProjFalseNorthingGeoKey] | null;
65
+ projFalseOriginLong: TiffTagGeoType[TiffTagGeo.ProjFalseOriginLongGeoKey] | null;
66
+ projFalseOriginLat: TiffTagGeoType[TiffTagGeo.ProjFalseOriginLatGeoKey] | null;
67
+ projFalseOriginEasting: TiffTagGeoType[TiffTagGeo.ProjFalseOriginEastingGeoKey] | null;
68
+ projFalseOriginNorthing: TiffTagGeoType[TiffTagGeo.ProjFalseOriginNorthingGeoKey] | null;
69
+ projCenterLong: TiffTagGeoType[TiffTagGeo.ProjCenterLongGeoKey] | null;
70
+ projCenterLat: TiffTagGeoType[TiffTagGeo.ProjCenterLatGeoKey] | null;
71
+ projCenterEasting: TiffTagGeoType[TiffTagGeo.ProjCenterEastingGeoKey] | null;
72
+ projCenterNorthing: TiffTagGeoType[TiffTagGeo.ProjCenterNorthingGeoKey] | null;
73
+ projScaleAtNatOrigin: TiffTagGeoType[TiffTagGeo.ProjScaleAtNatOriginGeoKey] | null;
74
+ projScaleAtCenter: TiffTagGeoType[TiffTagGeo.ProjScaleAtCenterGeoKey] | null;
75
+ projAzimuthAngle: TiffTagGeoType[TiffTagGeo.ProjAzimuthAngleGeoKey] | null;
76
+ projStraightVertPoleLong: TiffTagGeoType[TiffTagGeo.ProjStraightVertPoleLongGeoKey] | null;
77
+ projRectifiedGridAngle: TiffTagGeoType[TiffTagGeo.ProjRectifiedGridAngleGeoKey] | null;
78
+ verticalCRS: TiffTagGeoType[TiffTagGeo.VerticalGeoKey] | null;
79
+ verticalCitation: TiffTagGeoType[TiffTagGeo.VerticalCitationGeoKey] | null;
80
+ verticalDatum: TiffTagGeoType[TiffTagGeo.VerticalDatumGeoKey] | null;
81
+ verticalUnits: TiffTagGeoType[TiffTagGeo.VerticalUnitsGeoKey] | null;
82
+ };
83
+ export declare function extractGeoKeyDirectory(image: TiffImage): GeoKeyDirectory;
84
+ //# sourceMappingURL=ifd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifd.d.ts","sourceRoot":"","sources":["../src/ifd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAgB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGpE,oBAAY,SAAS;IACnB,IAAI,IAAI;IACR,8BAA8B;IAC9B,UAAU,IAAI;IACd,qBAAqB;IACrB,aAAa,IAAI;CAClB;AAED,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,kIAAkI;IAClI,mBAAmB,EAAE,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9D,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAChD,eAAe,EAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;CACvD;AAED,oDAAoD;AACpD,wBAAsB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CA4DxE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAE5B,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAC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pull/1412
3
+ export var Predictor;
4
+ (function (Predictor) {
5
+ Predictor[Predictor["None"] = 1] = "None";
6
+ /** Horizontal differencing */
7
+ Predictor[Predictor["Horizontal"] = 2] = "Horizontal";
8
+ /** Floating point */
9
+ Predictor[Predictor["FloatingPoint"] = 3] = "FloatingPoint";
10
+ })(Predictor || (Predictor = {}));
11
+ /** Pre-fetch TIFF tags for easier visualization. */
12
+ export async function prefetchTags(image) {
13
+ // Compression is pre-fetched in init
14
+ const compression = image.value(TiffTag.Compression);
15
+ if (compression === null) {
16
+ throw new Error("Compression tag should always exist.");
17
+ }
18
+ const nodata = image.noData;
19
+ const [bitsPerSample, colorMap, photometric, planarConfiguration, predictor, sampleFormat, samplesPerPixel,] = await Promise.all([
20
+ image.fetch(TiffTag.BitsPerSample),
21
+ image.fetch(TiffTag.ColorMap),
22
+ image.fetch(TiffTag.Photometric),
23
+ image.fetch(TiffTag.PlanarConfiguration),
24
+ image.fetch(TiffTag.Predictor),
25
+ image.fetch(TiffTag.SampleFormat),
26
+ image.fetch(TiffTag.SamplesPerPixel),
27
+ ]);
28
+ const missingTag = (tagName) => {
29
+ throw new Error(`${tagName} tag should always exist.`);
30
+ };
31
+ if (bitsPerSample === null) {
32
+ missingTag("BitsPerSample");
33
+ }
34
+ if (samplesPerPixel === null) {
35
+ missingTag("SamplesPerPixel");
36
+ }
37
+ if (planarConfiguration === null) {
38
+ missingTag("PlanarConfiguration");
39
+ }
40
+ if (photometric === null) {
41
+ missingTag("Photometric");
42
+ }
43
+ return {
44
+ bitsPerSample: new Uint16Array(bitsPerSample),
45
+ colorMap: colorMap ? new Uint16Array(colorMap) : undefined,
46
+ compression,
47
+ nodata,
48
+ photometric,
49
+ planarConfiguration,
50
+ predictor: predictor ?? Predictor.None,
51
+ // Uint is the default sample format according to the spec
52
+ // https://web.archive.org/web/20240329145340/https://www.awaresystems.be/imaging/tiff/tifftags/sampleformat.html
53
+ sampleFormat: sampleFormat ?? [SampleFormat.Uint],
54
+ samplesPerPixel,
55
+ };
56
+ }
57
+ export function extractGeoKeyDirectory(image) {
58
+ const geo = (key) => image.valueGeo(key) ?? null;
59
+ return {
60
+ // Configuration keys
61
+ modelType: geo(TiffTagGeo.GTModelTypeGeoKey),
62
+ rasterType: geo(TiffTagGeo.GTRasterTypeGeoKey),
63
+ citation: geo(TiffTagGeo.GTCitationGeoKey),
64
+ // Geographic CRS keys
65
+ geodeticCRS: geo(TiffTagGeo.GeodeticCRSGeoKey),
66
+ geodeticCitation: geo(TiffTagGeo.GeodeticCitationGeoKey),
67
+ geodeticDatum: geo(TiffTagGeo.GeodeticDatumGeoKey),
68
+ primeMeridian: geo(TiffTagGeo.PrimeMeridianGeoKey),
69
+ linearUnits: geo(TiffTagGeo.GeogLinearUnitsGeoKey),
70
+ linearUnitSize: geo(TiffTagGeo.GeogLinearUnitSizeGeoKey),
71
+ angularUnits: geo(TiffTagGeo.GeogAngularUnitsGeoKey),
72
+ angularUnitSize: geo(TiffTagGeo.GeogAngularUnitSizeGeoKey),
73
+ ellipsoid: geo(TiffTagGeo.EllipsoidGeoKey),
74
+ ellipsoidSemiMajorAxis: geo(TiffTagGeo.EllipsoidSemiMajorAxisGeoKey),
75
+ ellipsoidSemiMinorAxis: geo(TiffTagGeo.EllipsoidSemiMinorAxisGeoKey),
76
+ ellipsoidInvFlattening: geo(TiffTagGeo.EllipsoidInvFlatteningGeoKey),
77
+ azimuthUnits: geo(TiffTagGeo.GeogAzimuthUnitsGeoKey),
78
+ primeMeridianLongitude: geo(TiffTagGeo.PrimeMeridianLongitudeGeoKey),
79
+ toWGS84: geo(TiffTagGeo.GeogTOWGS84GeoKey),
80
+ // Projected CRS keys
81
+ projectedCRS: geo(TiffTagGeo.ProjectedCRSGeoKey),
82
+ projectedCitation: geo(TiffTagGeo.ProjectedCitationGeoKey),
83
+ projection: geo(TiffTagGeo.ProjectionGeoKey),
84
+ projMethod: geo(TiffTagGeo.ProjMethodGeoKey),
85
+ projLinearUnits: geo(TiffTagGeo.ProjLinearUnitsGeoKey),
86
+ projLinearUnitSize: geo(TiffTagGeo.ProjLinearUnitSizeGeoKey),
87
+ projStdParallel1: geo(TiffTagGeo.ProjStdParallel1GeoKey),
88
+ projStdParallel2: geo(TiffTagGeo.ProjStdParallel2GeoKey),
89
+ projNatOriginLong: geo(TiffTagGeo.ProjNatOriginLongGeoKey),
90
+ projNatOriginLat: geo(TiffTagGeo.ProjNatOriginLatGeoKey),
91
+ projFalseEasting: geo(TiffTagGeo.ProjFalseEastingGeoKey),
92
+ projFalseNorthing: geo(TiffTagGeo.ProjFalseNorthingGeoKey),
93
+ projFalseOriginLong: geo(TiffTagGeo.ProjFalseOriginLongGeoKey),
94
+ projFalseOriginLat: geo(TiffTagGeo.ProjFalseOriginLatGeoKey),
95
+ projFalseOriginEasting: geo(TiffTagGeo.ProjFalseOriginEastingGeoKey),
96
+ projFalseOriginNorthing: geo(TiffTagGeo.ProjFalseOriginNorthingGeoKey),
97
+ projCenterLong: geo(TiffTagGeo.ProjCenterLongGeoKey),
98
+ projCenterLat: geo(TiffTagGeo.ProjCenterLatGeoKey),
99
+ projCenterEasting: geo(TiffTagGeo.ProjCenterEastingGeoKey),
100
+ projCenterNorthing: geo(TiffTagGeo.ProjCenterNorthingGeoKey),
101
+ projScaleAtNatOrigin: geo(TiffTagGeo.ProjScaleAtNatOriginGeoKey),
102
+ projScaleAtCenter: geo(TiffTagGeo.ProjScaleAtCenterGeoKey),
103
+ projAzimuthAngle: geo(TiffTagGeo.ProjAzimuthAngleGeoKey),
104
+ projStraightVertPoleLong: geo(TiffTagGeo.ProjStraightVertPoleLongGeoKey),
105
+ projRectifiedGridAngle: geo(TiffTagGeo.ProjRectifiedGridAngleGeoKey),
106
+ // Vertical CRS keys
107
+ verticalCRS: geo(TiffTagGeo.VerticalGeoKey),
108
+ verticalCitation: geo(TiffTagGeo.VerticalCitationGeoKey),
109
+ verticalDatum: geo(TiffTagGeo.VerticalDatumGeoKey),
110
+ verticalUnits: geo(TiffTagGe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AC;QAC3C,gBAAgB,EAAE,GAAG,CAAC,UAAU,CAAC,sBAAsB,CAAC;QACxD,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC;QAClD,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type { RasterArray } from "./array.js";
2
+ export { parseColormap } from "./colormap.js";
3
+ export type { ProjJson } from "./crs.js";
4
+ export type { DecodedPixels, Decoder, DecoderMetadata } from "./decode.js";
5
+ export { decode, registry } from "./decode.js";
6
+ export { GeoTIFF } from "./geotiff.js";
7
+ export { Overview } from "./overview.js";
8
+ export type { Tile } from "./tile.js";
9
+ export { generateTileMatrixSet } from "./tile-matrix-set.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { parseColormap } from "./colormap.js";
2
+ export { decode, registry } from "./decode.js";
3
+ export { GeoTIFF } from "./geotiff.js";
4
+ export { Overview } from "./overview.js";
5
+ export { generateTileMatrixSet } from "./tile-matrix-set.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { TiffImage } from "@cogeotiff/core";
2
+ import type { Affine } from "@developmentseed/affine";
3
+ import type { ProjJson } from "./crs.js";
4
+ import type { GeoTIFF } from "./geotiff.js";
5
+ import type { CachedTags, GeoKeyDirectory } from "./ifd.js";
6
+ import type { Tile } from "./tile.js";
7
+ /**
8
+ * A single resolution level of a GeoTIFF — either the full-resolution image
9
+ * or a reduced-resolution overview. Pairs the data IFD with its
10
+ * corresponding mask IFD (if any).
11
+ */
12
+ export declare class Overview {
13
+ readonly cachedTags: CachedTags;
14
+ /** A reference to the parent GeoTIFF object. */
15
+ readonly geotiff: GeoTIFF;
16
+ /** The GeoKeyDirectory of the primary IFD. */
17
+ readonly gkd: GeoKeyDirectory;
18
+ /** The data IFD for this resolution level. */
19
+ readonly image: TiffImage;
20
+ /** The IFD for the mask associated with this overview level, if any. */
21
+ readonly maskImage: TiffImage | null;
22
+ constructor(geotiff: GeoTIFF, gkd: GeoKeyDirectory, image: TiffImage, maskImage: TiffImage | null, cachedTags: CachedTags);
23
+ get crs(): number | ProjJson;
24
+ get height(): number;
25
+ get nodata(): number | null;
26
+ get tileHeight(): number;
27
+ get tileWidth(): number;
28
+ get transform(): Affine;
29
+ get width(): number;
30
+ /** Fetch a single tile from the full-resolution image. */
31
+ fetchTile(x: number, y: number, options?: {
32
+ boundless?: boolean;
33
+ signal?: AbortSignal;
34
+ }): Promise<Tile>;
35
+ /**
36
+ * Get the (row, col) pixel index containing the geographic coordinate (x, y).
37
+ *
38
+ * @param x x coordinate in the CRS.
39
+ * @param y y coordinate in the CRS.
40
+ * @param op Rounding function applied to fractional pixel indices.
41
+ * Defaults to Math.floor.
42
+ * @returns [row, col] pixel indices.
43
+ */
44
+ index(x: number, y: number, op?: (n: number) => number): [number, number];
45
+ /**
46
+ * Get the geographic (x, y) coordinate of the pixel at (row, col).
47
+ *
48
+ * @param row Pixel row.
49
+ * @param col Pixel column.
50
+ * @param offset Which part of the pixel to return. Defaults to "center".
51
+ * @returns [x, y] in the CRS.
52
+ */
53
+ xy(row: number, col: number, offset?: "center" | "ul" | "ur" | "ll" | "lr"): [number, number];
54
+ }
55
+ //# sourceMappingURL=overview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../src/overview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC;;;;GAIG;AACH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,8CAA8C;IAC9C,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAE9B,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAE1B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAQ;gBAG1C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,GAAG,IAAI,EAC3B,UAAU,EAAE,UAAU;IASxB,IAAI,GAAG,IAAI,MAAM,GAAG,QAAQ,CAE3B;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,IAAI,CAE1B;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,SAAS,IAAI,MAAM,CAKtB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,0DAA0D;IACpD,SAAS,CACb,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAC1D,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;;;;;OAQG;IACH,KAAK,CACH,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAmB,GACrC,CAAC,MAAM,EAAE,MAAM,CAAC;IAInB;;;;;;;OAOG;IACH,EAAE,CACA,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAe,GACtD,CAAC,MAAM,EAAE,MAAM,CAAC;CAGpB"}
@@ -0,0 +1,78 @@
1
+ import { compose, scale } from "@developmentseed/affine";
2
+ import { fetchTile } from "./fetch.js";
3
+ import { index, xy } from "./transform.js";
4
+ /**
5
+ * A single resolution level of a GeoTIFF — either the full-resolution image
6
+ * or a reduced-resolution overview. Pairs the data IFD with its
7
+ * corresponding mask IFD (if any).
8
+ */
9
+ export class Overview {
10
+ cachedTags;
11
+ /** A reference to the parent GeoTIFF object. */
12
+ geotiff;
13
+ /** The GeoKeyDirectory of the primary IFD. */
14
+ gkd;
15
+ /** The data IFD for this resolution level. */
16
+ image;
17
+ /** The IFD for the mask associated with this overview level, if any. */
18
+ maskImage = null;
19
+ constructor(geotiff, gkd, image, maskImage, cachedTags) {
20
+ this.geotiff = geotiff;
21
+ this.gkd = gkd;
22
+ this.image = image;
23
+ this.maskImage = maskImage;
24
+ this.cachedTags = cachedTags;
25
+ }
26
+ get crs() {
27
+ return this.geotiff.crs;
28
+ }
29
+ get height() {
30
+ return this.image.size.height;
31
+ }
32
+ get nodata() {
33
+ return this.geotiff.nodata;
34
+ }
35
+ get tileHeight() {
36
+ return this.image.tileSize.height;
37
+ }
38
+ get tileWidth() {
39
+ return this.image.tileSize.width;
40
+ }
41
+ get transform() {
42
+ const fullTransform = this.geotiff.transform;
43
+ const scaleX = this.geotiff.width / this.width;
44
+ const scaleY = this.geotiff.height / this.height;
45
+ return compose(fullTransform, scale(scaleX, scaleY));
46
+ }
47
+ get width() {
48
+ return this.image.size.width;
49
+ }
50
+ /** Fetch a single tile from the full-resolution image. */
51
+ async fetchTile(x, y, options = {}) {
52
+ return await fetchTile(this, x, y, options);
53
+ }
54
+ /**
55
+ * Get the (row, col) pixel index containing the geographic coordinate (x, y).
56
+ *
57
+ * @param x x coordinate in the CRS.
58
+ * @param y y coordinate in the CRS.
59
+ * @param op Rounding function applied to fractional pixel indices.
60
+ * Defaults to Math.floor.
61
+ * @returns [row, col] pixel indices.
62
+ */
63
+ index(x, y, op = Math.floor) {
64
+ return index(this, x, y, op);
65
+ }
66
+ /**
67
+ * Get the geographic (x, y) coordinate of the pixel at (row, col).
68
+ *
69
+ * @param row Pixel row.
70
+ * @param col Pixel column.
71
+ * @param offset Which part of the pixel to return. Defaults to "center".
72
+ * @returns [x, y] in the CRS.
73
+ */
74
+ xy(row, col, offset = "center") {
75
+ return xy(this, row, col, offset);
76
+ }
77
+ }
78
+ //# sourceMappingURL=overview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview.js","sourceRoot":"","sources":["../src/overview.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACV,UAAU,CAAa;IAEhC,gDAAgD;IACvC,OAAO,CAAU;IAE1B,8CAA8C;IACrC,GAAG,CAAkB;IAE9B,8CAA8C;IACrC,KAAK,CAAY;IAE1B,wEAAwE;IAC/D,SAAS,GAAqB,IAAI,CAAC;IAE5C,YACE,OAAgB,EAChB,GAAoB,EACpB,KAAgB,EAChB,SAA2B,EAC3B,UAAsB;QAEtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IACpC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;IACnC,CAAC;IAED,IAAI,SAAS;QACX,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACjD,OAAO,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/B,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,SAAS,CACb,CAAS,EACT,CAAS,EACT,UAAyD,EAAE;QAE3D,OAAO,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CACH,CAAS,EACT,CAAS,EACT,KAA4B,IAAI,CAAC,KAAK;QAEtC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,EAAE,CACA,GAAW,EACX,GAAW,EACX,SAA+C,QAAQ;QAEvD,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import type { TileMatrixSet } from "@developmentseed/morecantile";
2
+ import type { GeoTIFF } from "./geotiff.js";
3
+ /**
4
+ * A minimal projection definition compatible with what wkt-parser returns.
5
+ *
6
+ * This type extracts only the partial properties we need from the full
7
+ * wkt-parser output.
8
+ */
9
+ interface ProjectionDefinition {
10
+ datum?: {
11
+ /** Semi-major axis of the ellipsoid. */
12
+ a: number;
13
+ };
14
+ a?: number;
15
+ to_meter?: number;
16
+ units?: string;
17
+ }
18
+ /**
19
+ * Generate a Tile Matrix Set from a GeoTIFF file.
20
+ *
21
+ * Produces one TileMatrix per overview (coarsest first) plus a final entry
22
+ * for the full-resolution level. The GeoTIFF must be tiled.
23
+ *
24
+ * This requires a crs definition that includes a `units` property, so that we
25
+ * can convert pixel sizes to physical screen units. Use [`wkt-parser`] to parse
26
+ * a WKT string or PROJJSON object, then pass the result as the `crs` argument.
27
+ *
28
+ * [`wkt-parser`]: https://github.com/proj4js/wkt-parser
29
+ *
30
+ * @see https://docs.ogc.org/is/17-083r4/17-083r4.html
31
+ */
32
+ export declare function generateTileMatrixSet(geotiff: GeoTIFF, crs: ProjectionDefinition, { id }?: {
33
+ id?: string;
34
+ }): TileMatrixSet;
35
+ export {};
36
+ //# sourceMappingURL=tile-matrix-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-matrix-set.d.ts","sourceRoot":"","sources":["../src/tile-matrix-set.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,aAAa,EACd,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;GAKG;AACH,UAAU,oBAAoB;IAC5B,KAAK,CAAC,EAAE;QACN,wCAAwC;QACxC,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA2CD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,oBAAoB,EACzB,EAAE,EAAa,EAAE,GAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAO,GACtC,aAAa,CAoFf"}
@@ -0,0 +1,87 @@
1
+ import * as affine from "@developmentseed/affine";
2
+ import { metersPerUnit } from "@developmentseed/morecantile";
3
+ import { v4 as uuidv4 } from "uuid";
4
+ const SCREEN_PIXEL_SIZE = 0.28e-3;
5
+ function buildCrs(crs) {
6
+ if (typeof crs === "number") {
7
+ return {
8
+ uri: `http://www.opengis.net/def/crs/EPSG/0/${crs}`,
9
+ };
10
+ }
11
+ // @ts-expect-error - typing issues between different projjson definitions.
12
+ return {
13
+ wkt: crs,
14
+ };
15
+ }
16
+ /**
17
+ * Build a TileMatrix entry for a single resolution level.
18
+ */
19
+ function buildTileMatrix(id, transform, mpu, cornerOfOrigin, tileWidth, tileHeight, width, height) {
20
+ return {
21
+ id,
22
+ scaleDenominator: (affine.a(transform) * mpu) / SCREEN_PIXEL_SIZE,
23
+ cellSize: affine.a(transform),
24
+ cornerOfOrigin,
25
+ pointOfOrigin: [affine.c(transform), affine.f(transform)],
26
+ tileWidth,
27
+ tileHeight,
28
+ matrixWidth: Math.ceil(width / tileWidth),
29
+ matrixHeight: Math.ceil(height / tileHeight),
30
+ };
31
+ }
32
+ /**
33
+ * Generate a Tile Matrix Set from a GeoTIFF file.
34
+ *
35
+ * Produces one TileMatrix per overview (coarsest first) plus a final entry
36
+ * for the full-resolution level. The GeoTIFF must be tiled.
37
+ *
38
+ * This requires a crs definition that includes a `units` property, so that we
39
+ * can convert pixel sizes to physical screen units. Use [`wkt-parser`] to parse
40
+ * a WKT string or PROJJSON object, then pass the result as the `crs` argument.
41
+ *
42
+ * [`wkt-parser`]: https://github.com/proj4js/wkt-parser
43
+ *
44
+ * @see https://docs.ogc.org/is/17-083r4/17-083r4.html
45
+ */
46
+ export function generateTileMatrixSet(geotiff, crs, { id = uuidv4() } = {}) {
47
+ const bbox = geotiff.bbox;
48
+ const tr = geotiff.transform;
49
+ // Full-resolution level is appended last.
50
+ if (!geotiff.isTiled) {
51
+ throw new Error("GeoTIFF must be tiled to generate a TMS.");
52
+ }
53
+ if (tr[1] !== 0 || tr[3] !== 0) {
54
+ // TileMatrixSet assumes orthogonal axes
55
+ throw new Error("COG TileMatrixSet with rotation/skewed geotransform is not supported");
56
+ }
57
+ // Perhaps we should allow metersPerUnit to take any string
58
+ const crsUnit = crs.units;
59
+ if (!crsUnit) {
60
+ throw new Error(`CRS definition must include "units" property`);
61
+ }
62
+ const semiMajorAxis = crs.a || crs.datum?.a;
63
+ const mpu = metersPerUnit(crsUnit, { semiMajorAxis });
64
+ const cornerOfOrigin = affine.e(tr) > 0 ? "bottomLeft" : "topLeft";
65
+ const tileMatrices = [];
66
+ // Overviews are sorted finest-to-coarsest; reverse to emit coarsest first.
67
+ const overviewsCoarseFirst = [...geotiff.overviews].reverse();
68
+ for (let idx = 0; idx < overviewsCoarseFirst.length; idx++) {
69
+ const overview = overviewsCoarseFirst[idx];
70
+ tileMatrices.push(buildTileMatrix(String(idx), overview.transform, mpu, cornerOfOrigin, overview.tileWidth, overview.tileHeight, overview.width, overview.height));
71
+ }
72
+ tileMatrices.push(buildTileMatrix(String(geotiff.overviews.length), tr, mpu, cornerOfOrigin, geotiff.tileWidth, geotiff.tileHeight, geotiff.width, geotiff.height));
73
+ const tmsCrs = buildCrs(geotiff.crs);
74
+ const boundingBox = {
75
+ lowerLeft: [bbox[0], bbox[1]],
76
+ upperRight: [bbox[2], bbox[3]],
77
+ crs: tmsCrs,
78
+ };
79
+ return {
80
+ title: "Generated TMS",
81
+ id,
82
+ crs: tmsCrs,
83
+ boundingBox,
84
+ tileMatrices,
85
+ };
86
+ }
87
+ //# sourceMappingURL=tile-matrix-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-matrix-set.js","sourceRoot":"","sources":["../src/tile-matrix-set.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAOlD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAoBpC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAElC,SAAS,QAAQ,CAAC,GAAs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S,EACjB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,MAAM,CACf,CACF,CAAC;IAEF,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,WAAW,GAAgB;QAC/B,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,GAAG,EAAE,MAAM;KACZ,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,eAAe;QACtB,EAAE;QACF,GAAG,EAAE,MAAM;QACX,WAAW;QACX,YAAY;KACb,CAAC;AACJ,CAAC"}
package/dist/tile.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { RasterArray } from "./array.js";
2
+ /** A single tile fetched from a GeoTIFF or Overview. */
3
+ export type Tile = {
4
+ /** Tile column index in the image's tile grid. */
5
+ x: number;
6
+ /** Tile row index in the image's tile grid. */
7
+ y: number;
8
+ /** Decoded raster data for this tile. */
9
+ array: RasterArray;
10
+ };
11
+ //# sourceMappingURL=tile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../src/tile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wDAAwD;AACxD,MAAM,MAAM,IAAI,GAAG;IACjB,kDAAkD;IAClD,CAAC,EAAE,MAAM,CAAC;IACV,+CAA+C;IAC/C,CAAC,EAAE,MAAM,CAAC;IACV,yCAAyC;IACzC,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC"}
package/dist/tile.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile.js","sourceRoot":"","sources":["../src/tile.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import type { Affine } from "@developmentseed/affine";
2
+ /**
3
+ * Interface for objects that have an affine transform.
4
+ */
5
+ export interface HasTransform {
6
+ /** The affine transform. */
7
+ readonly transform: Affine;
8
+ }
9
+ /**
10
+ * Get the (row, col) pixel index containing the geographic coordinate (x, y).
11
+ *
12
+ * @param x x coordinate in the CRS.
13
+ * @param y y coordinate in the CRS.
14
+ * @param op Rounding function applied to fractional pixel indices.
15
+ * Defaults to Math.floor.
16
+ * @returns [row, col] pixel indices.
17
+ */
18
+ export declare function index(self: HasTransform, x: number, y: number, op?: (n: number) => number): [number, number];
19
+ /**
20
+ * Get the geographic (x, y) coordinate of the pixel at (row, col).
21
+ *
22
+ * @param row Pixel row.
23
+ * @param col Pixel column.
24
+ * @param offset Which part of the pixel to return. Defaults to "center".
25
+ * @returns [x, y] in the CRS.
26
+ */
27
+ export declare function xy(self: HasTransform, row: number, col: number, offset?: "center" | "ul" | "ur" | "ll" | "lr"): [number, number];
28
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,YAAY,EAClB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAmB,GACrC,CAAC,MAAM,EAAE,MAAM,CAAC,CAIlB;AAED;;;;;;;GAOG;AACH,wBAAgB,EAAE,CAChB,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAe,GACtD,CAAC,MAAM,EAAE,MAAM,CAAC,CA4BlB"}
@@ -0,0 +1,51 @@
1
+ import { apply, invert } from "@developmentseed/affine";
2
+ /**
3
+ * Get the (row, col) pixel index containing the geographic coordinate (x, y).
4
+ *
5
+ * @param x x coordinate in the CRS.
6
+ * @param y y coordinate in the CRS.
7
+ * @param op Rounding function applied to fractional pixel indices.
8
+ * Defaults to Math.floor.
9
+ * @returns [row, col] pixel indices.
10
+ */
11
+ export function index(self, x, y, op = Math.floor) {
12
+ const inv = invert(self.transform);
13
+ const [col, row] = apply(inv, x, y);
14
+ return [op(row), op(col)];
15
+ }
16
+ /**
17
+ * Get the geographic (x, y) coordinate of the pixel at (row, col).
18
+ *
19
+ * @param row Pixel row.
20
+ * @param col Pixel column.
21
+ * @param offset Which part of the pixel to return. Defaults to "center".
22
+ * @returns [x, y] in the CRS.
23
+ */
24
+ export function xy(self, row, col, offset = "center") {
25
+ let c;
26
+ let r;
27
+ switch (offset) {
28
+ case "center":
29
+ c = col + 0.5;
30
+ r = row + 0.5;
31
+ break;
32
+ case "ul":
33
+ c = col;
34
+ r = row;
35
+ break;
36
+ case "ur":
37
+ c = col + 1;
38
+ r = row;
39
+ break;
40
+ case "ll":
41
+ c = col;
42
+ r = row + 1;
43
+ break;
44
+ case "lr":
45
+ c = col + 1;
46
+ r = row + 1;
47
+ break;
48
+ }
49
+ return apply(self.transform, c, r);
50
+ }
51
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAUxD;;;;;;;;GAQG;AACH,MAAM,UAAU,KAAK,CACnB,IAAkB,EAClB,CAAS,EACT,CAAS,EACT,KAA4B,IAAI,CAAC,KAAK;IAEtC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