@cogeotiff/core 7.2.1 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +3 -507
  2. package/README.md +23 -11
  3. package/build/__benchmark__/cog.read.benchmark.d.ts +0 -1
  4. package/build/__benchmark__/cog.read.benchmark.js +6 -4
  5. package/build/__benchmark__/cog.read.benchmark.js.map +1 -0
  6. package/build/__benchmark__/source.file.d.ts +9 -0
  7. package/build/__benchmark__/source.file.js +29 -0
  8. package/build/__benchmark__/source.file.js.map +1 -0
  9. package/build/__benchmark__/source.memory.d.ts +9 -0
  10. package/build/__benchmark__/source.memory.js +32 -0
  11. package/build/__benchmark__/source.memory.js.map +1 -0
  12. package/build/__test__/cog.image.test.d.ts +1 -2
  13. package/build/__test__/cog.image.test.js +82 -90
  14. package/build/__test__/cog.image.test.js.map +1 -0
  15. package/build/__test__/cog.read.test.d.ts +1 -2
  16. package/build/__test__/cog.read.test.js +37 -55
  17. package/build/__test__/cog.read.test.js.map +1 -0
  18. package/build/__test__/example.d.ts +1 -0
  19. package/build/__test__/example.js +27 -0
  20. package/build/__test__/example.js.map +1 -0
  21. package/build/cog.tiff.d.ts +22 -28
  22. package/build/cog.tiff.image.d.ts +16 -28
  23. package/build/cog.tiff.image.js +147 -101
  24. package/build/cog.tiff.image.js.map +1 -0
  25. package/build/cog.tiff.js +141 -97
  26. package/build/cog.tiff.js.map +1 -0
  27. package/build/const/index.d.ts +1 -2
  28. package/build/const/index.js +2 -2
  29. package/build/const/index.js.map +1 -0
  30. package/build/const/tiff.endian.d.ts +0 -1
  31. package/build/const/tiff.endian.js +1 -1
  32. package/build/const/tiff.endian.js.map +1 -0
  33. package/build/const/tiff.mime.d.ts +10 -11
  34. package/build/const/tiff.mime.js +22 -22
  35. package/build/const/tiff.mime.js.map +1 -0
  36. package/build/const/tiff.tag.id.d.ts +5 -5
  37. package/build/const/tiff.tag.id.js +155 -154
  38. package/build/const/tiff.tag.id.js.map +1 -0
  39. package/build/const/tiff.tag.value.d.ts +15 -16
  40. package/build/const/tiff.tag.value.js +16 -16
  41. package/build/const/tiff.tag.value.js.map +1 -0
  42. package/build/const/tiff.version.d.ts +0 -1
  43. package/build/const/tiff.version.js +1 -1
  44. package/build/const/tiff.version.js.map +1 -0
  45. package/build/index.d.ts +11 -6
  46. package/build/index.js +9 -5
  47. package/build/index.js.map +1 -0
  48. package/build/read/data.view.offset.d.ts +15 -0
  49. package/build/read/data.view.offset.js +19 -0
  50. package/build/read/data.view.offset.js.map +1 -0
  51. package/build/read/tiff.gdal.d.ts +9 -12
  52. package/build/read/tiff.gdal.js +22 -17
  53. package/build/read/tiff.gdal.js.map +1 -0
  54. package/build/read/tiff.ifd.config.d.ts +6 -4
  55. package/build/read/tiff.ifd.config.js +2 -2
  56. package/build/read/tiff.ifd.config.js.map +1 -0
  57. package/build/read/tiff.tag.d.ts +37 -20
  58. package/build/read/tiff.tag.factory.d.ts +16 -0
  59. package/build/read/tiff.tag.factory.js +130 -0
  60. package/build/read/tiff.tag.factory.js.map +1 -0
  61. package/build/read/tiff.tag.js +2 -37
  62. package/build/read/tiff.tag.js.map +1 -0
  63. package/build/read/tiff.value.reader.d.ts +2 -6
  64. package/build/read/tiff.value.reader.js +16 -54
  65. package/build/read/tiff.value.reader.js.map +1 -0
  66. package/build/source.d.ts +5 -0
  67. package/build/source.js +2 -0
  68. package/build/source.js.map +1 -0
  69. package/build/util/bytes.d.ts +17 -0
  70. package/build/util/bytes.js +42 -0
  71. package/build/util/bytes.js.map +1 -0
  72. package/build/util/util.hex.d.ts +2 -3
  73. package/build/util/util.hex.js +4 -5
  74. package/build/util/util.hex.js.map +1 -0
  75. package/build/vector.d.ts +0 -1
  76. package/build/vector.js +1 -1
  77. package/build/vector.js.map +1 -0
  78. package/package.json +25 -30
  79. package/src/__benchmark__/cog.read.benchmark.ts +12 -10
  80. package/src/__benchmark__/source.file.ts +23 -0
  81. package/src/__benchmark__/source.memory.ts +23 -0
  82. package/src/__test__/cog.image.test.ts +188 -197
  83. package/src/__test__/cog.read.test.ts +50 -72
  84. package/src/__test__/example.ts +31 -0
  85. package/src/cog.tiff.image.ts +456 -448
  86. package/src/cog.tiff.ts +143 -146
  87. package/src/const/index.ts +1 -1
  88. package/src/const/tiff.endian.ts +2 -2
  89. package/src/const/tiff.mime.ts +21 -21
  90. package/src/const/tiff.tag.id.ts +159 -158
  91. package/src/const/tiff.tag.value.ts +16 -16
  92. package/src/const/tiff.version.ts +11 -11
  93. package/src/index.ts +11 -5
  94. package/src/read/data.view.offset.ts +23 -0
  95. package/src/read/tiff.gdal.ts +61 -63
  96. package/src/read/tiff.ifd.config.ts +35 -31
  97. package/src/read/tiff.tag.factory.ts +163 -0
  98. package/src/read/tiff.tag.ts +38 -39
  99. package/src/read/tiff.value.reader.ts +25 -73
  100. package/src/source.ts +5 -0
  101. package/src/util/bytes.ts +44 -0
  102. package/src/util/util.hex.ts +5 -7
  103. package/src/vector.ts +5 -5
  104. package/tsconfig.json +8 -8
  105. package/build/__benchmark__/cog.read.benchmark.d.ts.map +0 -1
  106. package/build/__test__/cog.image.test.d.ts.map +0 -1
  107. package/build/__test__/cog.read.test.d.ts.map +0 -1
  108. package/build/cog.tiff.d.ts.map +0 -1
  109. package/build/cog.tiff.image.d.ts.map +0 -1
  110. package/build/const/index.d.ts.map +0 -1
  111. package/build/const/tiff.endian.d.ts.map +0 -1
  112. package/build/const/tiff.mime.d.ts.map +0 -1
  113. package/build/const/tiff.tag.id.d.ts.map +0 -1
  114. package/build/const/tiff.tag.value.d.ts.map +0 -1
  115. package/build/const/tiff.version.d.ts.map +0 -1
  116. package/build/index.d.ts.map +0 -1
  117. package/build/read/tag/__test__/tag.test.d.ts +0 -2
  118. package/build/read/tag/__test__/tag.test.d.ts.map +0 -1
  119. package/build/read/tag/__test__/tag.test.js +0 -23
  120. package/build/read/tag/tiff.tag.base.d.ts +0 -55
  121. package/build/read/tag/tiff.tag.base.d.ts.map +0 -1
  122. package/build/read/tag/tiff.tag.base.js +0 -79
  123. package/build/read/tag/tiff.tag.lazy.d.ts +0 -7
  124. package/build/read/tag/tiff.tag.lazy.d.ts.map +0 -1
  125. package/build/read/tag/tiff.tag.lazy.js +0 -18
  126. package/build/read/tag/tiff.tag.offset.d.ts +0 -21
  127. package/build/read/tag/tiff.tag.offset.d.ts.map +0 -1
  128. package/build/read/tag/tiff.tag.offset.js +0 -54
  129. package/build/read/tag/tiff.tag.static.d.ts +0 -8
  130. package/build/read/tag/tiff.tag.static.d.ts.map +0 -1
  131. package/build/read/tag/tiff.tag.static.js +0 -17
  132. package/build/read/tiff.gdal.d.ts.map +0 -1
  133. package/build/read/tiff.ifd.config.d.ts.map +0 -1
  134. package/build/read/tiff.tag.d.ts.map +0 -1
  135. package/build/read/tiff.value.reader.d.ts.map +0 -1
  136. package/build/source/cog.source.view.d.ts +0 -33
  137. package/build/source/cog.source.view.d.ts.map +0 -1
  138. package/build/source/cog.source.view.js +0 -65
  139. package/build/util/util.hex.d.ts.map +0 -1
  140. package/build/vector.d.ts.map +0 -1
  141. package/src/@types/ieee754.d.ts +0 -18
  142. package/src/read/tag/__test__/tag.test.ts +0 -27
  143. package/src/read/tag/tiff.tag.base.ts +0 -126
  144. package/src/read/tag/tiff.tag.lazy.ts +0 -17
  145. package/src/read/tag/tiff.tag.offset.ts +0 -61
  146. package/src/read/tag/tiff.tag.static.ts +0 -15
  147. package/src/source/cog.source.view.ts +0 -77
@@ -1,52 +1,46 @@
1
- import { ChunkSource } from '@chunkd/core';
2
1
  import { CogTiffImage } from './cog.tiff.image.js';
3
2
  import { TiffVersion } from './const/tiff.version.js';
4
3
  import { CogTifGhostOptions } from './read/tiff.gdal.js';
5
4
  import { TiffIfdConfig } from './read/tiff.ifd.config.js';
5
+ import { Source } from './source.js';
6
6
  export declare class CogTiff {
7
- source: ChunkSource;
7
+ /** Read 16KB blocks at a time */
8
+ defaultReadSize: number;
9
+ /** Where this cog is fetching its data from */
10
+ source: Source;
11
+ /** Big or small Tiff */
8
12
  version: TiffVersion;
13
+ /** List of images, o is the base image */
9
14
  images: CogTiffImage[];
10
- options: CogTifGhostOptions;
11
- private cursor;
15
+ /** Ghost header options */
16
+ options?: CogTifGhostOptions;
17
+ /** Configuration for the size of the IFD */
12
18
  ifdConfig: TiffIfdConfig;
13
- constructor(source: ChunkSource);
14
- /** Create and initialize a CogTiff */
15
- static create(source: ChunkSource): Promise<CogTiff>;
19
+ /** Is the tiff being read is little Endian */
20
+ isLittleEndian: boolean;
16
21
  /** Has init() been called */
17
22
  isInitialized: boolean;
18
- _initPromise?: Promise<CogTiff>;
23
+ private _initPromise?;
24
+ constructor(source: Source);
25
+ /** Create a COG and initialize it by reading the COG headers */
26
+ static create(source: Source): Promise<CogTiff>;
19
27
  /**
20
28
  * Initialize the COG loading in the header and all image headers
21
- *
22
- * @param loadGeoKeys Whether to also initialize the GeoKeyDirectory
23
29
  */
24
- init(loadGeoKeys?: boolean): Promise<CogTiff>;
25
- private doInit;
26
- private fetchIfd;
27
- getImage(z: number): CogTiffImage;
30
+ init(): Promise<CogTiff>;
28
31
  /**
29
32
  * Find a image which has a resolution similar to the provided resolution
30
33
  *
31
34
  * @param resolution resolution to find
32
35
  */
33
36
  getImageByResolution(resolution: number): CogTiffImage;
37
+ /** Read the Starting header and all Image headers from the source */
38
+ private readHeader;
34
39
  /**
35
- * Get the raw bytes for a tile at a given x,y, index.
36
- *
37
- * This may return null if the tile does not exist eg Sparse cogs,
40
+ * Read a IFD at a the provided offset
38
41
  *
39
- * @param x tile x index
40
- * @param y tile y index
41
- * @param index image index
42
+ * @param offset file offset to read the header from
43
+ * @param view offset that contains the bytes for the header
42
44
  */
43
- getTile(x: number, y: number, index: number): Promise<{
44
- mimeType: string;
45
- bytes: Uint8Array;
46
- } | null>;
47
- private processIfd;
48
45
  private readIfd;
49
- /** Close the file source if it needs closing */
50
- close(): Promise<void>;
51
46
  }
52
- //# sourceMappingURL=cog.tiff.d.ts.map
@@ -1,10 +1,8 @@
1
1
  import { CogTiff } from './cog.tiff.js';
2
2
  import { TiffMimeType } from './const/tiff.mime.js';
3
- import { TiffTag, TiffTagGeo } from './const/tiff.tag.id.js';
4
- import { CogTiffTagBase } from './read/tag/tiff.tag.base.js';
5
- import { CogTiffTagOffset } from './read/tag/tiff.tag.offset.js';
3
+ import { TagId, TagGeoId } from './const/tiff.tag.id.js';
4
+ import { Tag, TagOffset } from './read/tiff.tag.js';
6
5
  import { BoundingBox, Size } from './vector.js';
7
- /** Invalid EPSG code */
8
6
  export declare const InvalidProjectionCode = 32767;
9
7
  /**
10
8
  * Number of tiles used inside this image
@@ -15,6 +13,8 @@ export interface CogTiffImageTiledCount {
15
13
  /** Number of tiles on the y axis */
16
14
  y: number;
17
15
  }
16
+ /** Tags that are commonly accessed for geotiffs */
17
+ export declare const ImportantTags: Set<TagId>;
18
18
  /**
19
19
  * Size of a individual tile
20
20
  */
@@ -26,15 +26,15 @@ export interface CogTiffImageTileSize {
26
26
  }
27
27
  export declare class CogTiffImage {
28
28
  /** All IFD tags that have been read for the image */
29
- tags: Map<TiffTag, CogTiffTagBase>;
29
+ tags: Map<TagId, Tag>;
30
30
  /** Id of the tif image, generally the image index inside the tif */
31
31
  id: number;
32
- tif: CogTiff;
32
+ tiff: CogTiff;
33
33
  /** Has loadGeoTiffTags been called */
34
- private tagsGeoLoaded;
34
+ isGeoTagsLoaded: boolean;
35
35
  /** Sub tags stored in TiffTag.GeoKeyDirectory */
36
- tagsGeo: Map<TiffTagGeo, string | number>;
37
- constructor(tif: CogTiff, id: number, tags: Map<TiffTag, CogTiffTagBase>);
36
+ tagsGeo: Map<TagGeoId, string | number>;
37
+ constructor(tiff: CogTiff, id: number, tags: Map<TagId, Tag>);
38
38
  /**
39
39
  * Force loading of important tags if they have not already been loaded
40
40
  *
@@ -44,7 +44,7 @@ export declare class CogTiffImage {
44
44
  /**
45
45
  * Get the value of a TiffTag if it exists null otherwise
46
46
  */
47
- value<T>(tag: TiffTag): T | null;
47
+ value<T>(tag: TagId): T | null;
48
48
  /**
49
49
  * Load and unpack the GeoKeyDirectory
50
50
  */
@@ -52,12 +52,12 @@ export declare class CogTiffImage {
52
52
  /**
53
53
  * Get the associated GeoTiffTags
54
54
  */
55
- valueGeo(tag: TiffTagGeo): string | number | undefined;
55
+ valueGeo(tag: TagGeoId): string | number | undefined;
56
56
  /**
57
57
  * Load a tag, if it is not currently loaded, fetch the required data for the tag.
58
58
  * @param tag tag to fetch
59
59
  */
60
- fetch<T>(tag: TiffTag): Promise<T | null>;
60
+ fetch<T>(tag: TagId): Promise<T | null>;
61
61
  /**
62
62
  * Get the origin point for the image
63
63
  *
@@ -98,10 +98,6 @@ export declare class CogTiffImage {
98
98
  * @returns Size in pixels
99
99
  */
100
100
  get size(): Size;
101
- /**
102
- * Get the list of IFD tags that were read
103
- */
104
- get tagList(): string[];
105
101
  /**
106
102
  * Determine if this image is tiled
107
103
  */
@@ -121,7 +117,7 @@ export declare class CogTiffImage {
121
117
  *
122
118
  * @returns file offset to where the tiffs are stored
123
119
  */
124
- get tileOffset(): CogTiffTagOffset;
120
+ get tileOffset(): TagOffset;
125
121
  /**
126
122
  * Get the number of strip's inside this tiff
127
123
  *
@@ -130,13 +126,6 @@ export declare class CogTiffImage {
130
126
  * @returns number of strips present
131
127
  */
132
128
  get stripCount(): number;
133
- /**
134
- * Get a pointer to a specific tile inside the tiff file
135
- *
136
- * @param index tile index
137
- * @returns file offset of the specified tile
138
- */
139
- protected getTileOffset(index: number): Promise<number>;
140
129
  getTileBounds(x: number, y: number): BoundingBox;
141
130
  /**
142
131
  * Read a strip into a uint8 array
@@ -145,7 +134,7 @@ export declare class CogTiffImage {
145
134
  */
146
135
  getStrip(index: number): Promise<{
147
136
  mimeType: TiffMimeType;
148
- bytes: Uint8Array;
137
+ bytes: ArrayBuffer;
149
138
  } | null>;
150
139
  /** The jpeg header is stored in the IFD, read the JPEG header and adjust the byte array to include it */
151
140
  private getJpegHeader;
@@ -161,7 +150,7 @@ export declare class CogTiffImage {
161
150
  */
162
151
  getTile(x: number, y: number): Promise<{
163
152
  mimeType: TiffMimeType;
164
- bytes: Uint8Array;
153
+ bytes: ArrayBuffer;
165
154
  } | null>;
166
155
  /**
167
156
  * Does this tile exist in the tiff and does it actually have a value
@@ -173,9 +162,8 @@ export declare class CogTiffImage {
173
162
  * @returns if the tile exists and has data
174
163
  */
175
164
  hasTile(x: number, y: number): Promise<boolean>;
176
- protected getTileSize(index: number): Promise<{
165
+ getTileSize(index: number): Promise<{
177
166
  offset: number;
178
167
  imageSize: number;
179
168
  }>;
180
169
  }
181
- //# sourceMappingURL=cog.tiff.image.d.ts.map