@cogeotiff/core 7.2.0 → 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 -500
  2. package/README.md +28 -10
  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 -10
  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,170 +1,171 @@
1
1
  // Stolen from geotiff.js
2
- export enum TiffTag {
3
- // TIFF Baseline
4
- Artist = 0x013b,
5
- BitsPerSample = 0x0102,
6
- CellLength = 0x0109,
7
- CellWidth = 0x0108,
8
- ColorMap = 0x0140,
9
- Compression = 0x0103,
10
- Copyright = 0x8298,
11
- DateTime = 0x0132,
12
- ExtraSamples = 0x0152,
13
- FillOrder = 0x010a,
14
- FreeByteCounts = 0x0121,
15
- FreeOffsets = 0x0120,
16
- GrayResponseCurve = 0x0123,
17
- GrayResponseUnit = 0x0122,
18
- HostComputer = 0x013c,
19
- ImageDescription = 0x010e,
20
- ImageHeight = 0x0101,
21
- ImageWidth = 0x0100,
22
- Make = 0x010f,
23
- MaxSampleValue = 0x0119,
24
- MinSampleValue = 0x0118,
25
- Model = 0x0110,
26
- NewSubFileType = 0x00fe,
27
- Orientation = 0x0112,
28
- PhotometricInterpretation = 0x0106,
29
- PlanarConfiguration = 0x011c,
30
- ResolutionUnit = 0x0128,
31
- RowsPerStrip = 0x0116,
32
- SamplesPerPixel = 0x0115,
33
- Software = 0x0131,
34
- StripByteCounts = 0x0117,
35
- StripOffsets = 0x0111,
36
- SubFileType = 0x00ff,
37
- Threshholding = 0x0107,
38
- XResolution = 0x011a,
39
- YResolution = 0x011b,
2
+ export enum TagId {
3
+ // TIFF Baseline
4
+ Artist = 0x013b,
5
+ BitsPerSample = 0x0102,
6
+ CellLength = 0x0109,
7
+ CellWidth = 0x0108,
8
+ ColorMap = 0x0140,
9
+ Compression = 0x0103,
10
+ Copyright = 0x8298,
11
+ DateTime = 0x0132,
12
+ ExtraSamples = 0x0152,
13
+ FillOrder = 0x010a,
14
+ FreeByteCounts = 0x0121,
15
+ FreeOffsets = 0x0120,
16
+ GrayResponseCurve = 0x0123,
17
+ GrayResponseUnit = 0x0122,
18
+ HostComputer = 0x013c,
19
+ ImageDescription = 0x010e,
20
+ ImageHeight = 0x0101,
21
+ ImageWidth = 0x0100,
22
+ Make = 0x010f,
23
+ MaxSampleValue = 0x0119,
24
+ MinSampleValue = 0x0118,
25
+ Model = 0x0110,
26
+ NewSubFileType = 0x00fe,
27
+ Orientation = 0x0112,
28
+ PhotometricInterpretation = 0x0106,
29
+ PlanarConfiguration = 0x011c,
30
+ ResolutionUnit = 0x0128,
31
+ RowsPerStrip = 0x0116,
32
+ SamplesPerPixel = 0x0115,
33
+ Software = 0x0131,
34
+ StripByteCounts = 0x0117,
35
+ StripOffsets = 0x0111,
36
+ SubFileType = 0x00ff,
37
+ Threshholding = 0x0107,
38
+ XResolution = 0x011a,
39
+ YResolution = 0x011b,
40
40
 
41
- // TIFF Extended
42
- BadFaxLines = 0x0146,
43
- CleanFaxData = 0x0147,
44
- ClipPath = 0x0157,
45
- ConsecutiveBadFaxLines = 0x0148,
46
- Decode = 0x01b1,
47
- DefaultImageColor = 0x01b2,
48
- DocumentName = 0x010d,
49
- DotRange = 0x0150,
50
- HalftoneHints = 0x0141,
51
- Indexed = 0x015a,
52
- JPEGTables = 0x015b,
53
- PageName = 0x011d,
54
- PageNumber = 0x0129,
55
- Predictor = 0x013d,
56
- PrimaryChromaticities = 0x013f,
57
- ReferenceBlackWhite = 0x0214,
58
- SampleFormat = 0x0153,
59
- SMinSampleValue = 0x0154,
60
- SMaxSampleValue = 0x0155,
61
- StripRowCounts = 0x022f,
62
- SubIFDs = 0x014a,
63
- T4Options = 0x0124,
64
- T6Options = 0x0125,
65
- TileByteCounts = 0x0145,
66
- TileHeight = 0x0143,
67
- TileOffsets = 0x0144,
68
- TileWidth = 0x0142,
69
- TransferFunction = 0x012d,
70
- WhitePoint = 0x013e,
71
- XClipPathUnits = 0x0158,
72
- XPosition = 0x011e,
73
- YCbCrCoefficients = 0x0211,
74
- YCbCrPositioning = 0x0213,
75
- YCbCrSubSampling = 0x0212,
76
- YClipPathUnits = 0x0159,
77
- YPosition = 0x011f,
41
+ // TIFF Extended
42
+ BadFaxLines = 0x0146,
43
+ CleanFaxData = 0x0147,
44
+ ClipPath = 0x0157,
45
+ ConsecutiveBadFaxLines = 0x0148,
46
+ Decode = 0x01b1,
47
+ DefaultImageColor = 0x01b2,
48
+ DocumentName = 0x010d,
49
+ DotRange = 0x0150,
50
+ HalftoneHints = 0x0141,
51
+ Indexed = 0x015a,
52
+ JPEGTables = 0x015b,
53
+ PageName = 0x011d,
54
+ PageNumber = 0x0129,
55
+ Predictor = 0x013d,
56
+ PrimaryChromaticities = 0x013f,
57
+ ReferenceBlackWhite = 0x0214,
58
+ SampleFormat = 0x0153,
59
+ SMinSampleValue = 0x0154,
60
+ SMaxSampleValue = 0x0155,
61
+ StripRowCounts = 0x022f,
62
+ SubIFDs = 0x014a,
63
+ T4Options = 0x0124,
64
+ T6Options = 0x0125,
65
+ TileByteCounts = 0x0145,
66
+ TileHeight = 0x0143,
67
+ TileOffsets = 0x0144,
68
+ TileWidth = 0x0142,
69
+ TransferFunction = 0x012d,
70
+ WhitePoint = 0x013e,
71
+ XClipPathUnits = 0x0158,
72
+ XPosition = 0x011e,
73
+ YCbCrCoefficients = 0x0211,
74
+ YCbCrPositioning = 0x0213,
75
+ YCbCrSubSampling = 0x0212,
76
+ YClipPathUnits = 0x0159,
77
+ YPosition = 0x011f,
78
78
 
79
- // EXIF
80
- ApertureValue = 0x9202,
81
- ColorSpace = 0xa001,
82
- DateTimeDigitized = 0x9004,
83
- DateTimeOriginal = 0x9003,
84
- ExifIFD = 0x8769,
85
- ExifVersion = 0x9000,
86
- ExposureTime = 0x829a,
87
- FileSource = 0xa300,
88
- Flash = 0x9209,
89
- FlashpixVersion = 0xa000,
90
- FNumber = 0x829d,
91
- ImageUniqueID = 0xa420,
92
- LightSource = 0x9208,
93
- MakerNote = 0x927c,
94
- ShutterSpeedValue = 0x9201,
95
- UserComment = 0x9286,
79
+ // EXIF
80
+ ApertureValue = 0x9202,
81
+ ColorSpace = 0xa001,
82
+ DateTimeDigitized = 0x9004,
83
+ DateTimeOriginal = 0x9003,
84
+ ExifIFD = 0x8769,
85
+ ExifVersion = 0x9000,
86
+ ExposureTime = 0x829a,
87
+ FileSource = 0xa300,
88
+ Flash = 0x9209,
89
+ FlashpixVersion = 0xa000,
90
+ FNumber = 0x829d,
91
+ ImageUniqueID = 0xa420,
92
+ LightSource = 0x9208,
93
+ MakerNote = 0x927c,
94
+ ShutterSpeedValue = 0x9201,
95
+ UserComment = 0x9286,
96
96
 
97
- // IPTC
98
- IPTC = 0x83bb,
97
+ // IPTC
98
+ IPTC = 0x83bb,
99
99
 
100
- // ICC
101
- ICCProfile = 0x8773,
100
+ // ICC
101
+ ICCProfile = 0x8773,
102
102
 
103
- // XMP
104
- XMP = 0x02bc,
103
+ // XMP
104
+ XMP = 0x02bc,
105
105
 
106
- // GDAL
107
- GDAL_METADATA = 0xa480,
108
- GDAL_NODATA = 0xa481,
106
+ // GDAL
107
+ GdalMetadata = 0xa480,
108
+ GdalNoData = 0xa481,
109
+ LercParams = 0xc5f2,
109
110
 
110
- // Photoshop
111
- Photoshop = 0x8649,
111
+ // Photoshop
112
+ Photoshop = 0x8649,
112
113
 
113
- // GeoTiff
114
- ModelPixelScale = 0x830e,
115
- ModelTiePoint = 0x8482,
116
- ModelTransformation = 0x85d8,
117
- GeoKeyDirectory = 0x87af,
118
- GeoDoubleParams = 0x87b0,
119
- GeoAsciiParams = 0x87b1,
114
+ // GeoTiff
115
+ ModelPixelScale = 0x830e,
116
+ ModelTiePoint = 0x8482,
117
+ ModelTransformation = 0x85d8,
118
+ GeoKeyDirectory = 0x87af,
119
+ GeoDoubleParams = 0x87b0,
120
+ GeoAsciiParams = 0x87b1,
120
121
  }
121
122
 
122
- export enum TiffTagGeo {
123
- GTModelTypeGeoKey = 1024,
124
- GTRasterTypeGeoKey = 1025,
125
- GTCitationGeoKey = 1026,
126
- GeographicTypeGeoKey = 2048,
127
- GeogCitationGeoKey = 2049,
128
- GeogGeodeticDatumGeoKey = 2050,
129
- GeogPrimeMeridianGeoKey = 2051,
130
- GeogLinearUnitsGeoKey = 2052,
131
- GeogLinearUnitSizeGeoKey = 2053,
132
- GeogAngularUnitsGeoKey = 2054,
133
- GeogAngularUnitSizeGeoKey = 2055,
134
- GeogEllipsoidGeoKey = 2056,
135
- GeogSemiMajorAxisGeoKey = 2057,
136
- GeogSemiMinorAxisGeoKey = 2058,
137
- GeogInvFlatteningGeoKey = 2059,
138
- GeogAzimuthUnitsGeoKey = 2060,
139
- GeogPrimeMeridianLongGeoKey = 2061,
140
- GeogTOWGS84GeoKey = 2062,
141
- ProjectedCSTypeGeoKey = 3072,
142
- PCSCitationGeoKey = 3073,
143
- ProjectionGeoKey = 3074,
144
- ProjCoordTransGeoKey = 3075,
145
- ProjLinearUnitsGeoKey = 3076,
146
- ProjLinearUnitSizeGeoKey = 3077,
147
- ProjStdParallel1GeoKey = 3078,
148
- ProjStdParallel2GeoKey = 3079,
149
- ProjNatOriginLongGeoKey = 3080,
150
- ProjNatOriginLatGeoKey = 3081,
151
- ProjFalseEastingGeoKey = 3082,
152
- ProjFalseNorthingGeoKey = 3083,
153
- ProjFalseOriginLongGeoKey = 3084,
154
- ProjFalseOriginLatGeoKey = 3085,
155
- ProjFalseOriginEastingGeoKey = 3086,
156
- ProjFalseOriginNorthingGeoKey = 3087,
157
- ProjCenterLongGeoKey = 3088,
158
- ProjCenterLatGeoKey = 3089,
159
- ProjCenterEastingGeoKey = 3090,
160
- ProjCenterNorthingGeoKey = 3091,
161
- ProjScaleAtNatOriginGeoKey = 3092,
162
- ProjScaleAtCenterGeoKey = 3093,
163
- ProjAzimuthAngleGeoKey = 3094,
164
- ProjStraightVertPoleLongGeoKey = 3095,
165
- ProjRectifiedGridAngleGeoKey = 3096,
166
- VerticalCSTypeGeoKey = 4096,
167
- VerticalCitationGeoKey = 4097,
168
- VerticalDatumGeoKey = 4098,
169
- VerticalUnitsGeoKey = 4099,
123
+ export enum TagGeoId {
124
+ GTModelTypeGeoKey = 1024,
125
+ GTRasterTypeGeoKey = 1025,
126
+ GTCitationGeoKey = 1026,
127
+ GeographicTypeGeoKey = 2048,
128
+ GeogCitationGeoKey = 2049,
129
+ GeogGeodeticDatumGeoKey = 2050,
130
+ GeogPrimeMeridianGeoKey = 2051,
131
+ GeogLinearUnitsGeoKey = 2052,
132
+ GeogLinearUnitSizeGeoKey = 2053,
133
+ GeogAngularUnitsGeoKey = 2054,
134
+ GeogAngularUnitSizeGeoKey = 2055,
135
+ GeogEllipsoidGeoKey = 2056,
136
+ GeogSemiMajorAxisGeoKey = 2057,
137
+ GeogSemiMinorAxisGeoKey = 2058,
138
+ GeogInvFlatteningGeoKey = 2059,
139
+ GeogAzimuthUnitsGeoKey = 2060,
140
+ GeogPrimeMeridianLongGeoKey = 2061,
141
+ GeogTOWGS84GeoKey = 2062,
142
+ ProjectedCSTypeGeoKey = 3072,
143
+ PCSCitationGeoKey = 3073,
144
+ ProjectionGeoKey = 3074,
145
+ ProjCoordTransGeoKey = 3075,
146
+ ProjLinearUnitsGeoKey = 3076,
147
+ ProjLinearUnitSizeGeoKey = 3077,
148
+ ProjStdParallel1GeoKey = 3078,
149
+ ProjStdParallel2GeoKey = 3079,
150
+ ProjNatOriginLongGeoKey = 3080,
151
+ ProjNatOriginLatGeoKey = 3081,
152
+ ProjFalseEastingGeoKey = 3082,
153
+ ProjFalseNorthingGeoKey = 3083,
154
+ ProjFalseOriginLongGeoKey = 3084,
155
+ ProjFalseOriginLatGeoKey = 3085,
156
+ ProjFalseOriginEastingGeoKey = 3086,
157
+ ProjFalseOriginNorthingGeoKey = 3087,
158
+ ProjCenterLongGeoKey = 3088,
159
+ ProjCenterLatGeoKey = 3089,
160
+ ProjCenterEastingGeoKey = 3090,
161
+ ProjCenterNorthingGeoKey = 3091,
162
+ ProjScaleAtNatOriginGeoKey = 3092,
163
+ ProjScaleAtCenterGeoKey = 3093,
164
+ ProjAzimuthAngleGeoKey = 3094,
165
+ ProjStraightVertPoleLongGeoKey = 3095,
166
+ ProjRectifiedGridAngleGeoKey = 3096,
167
+ VerticalCSTypeGeoKey = 4096,
168
+ VerticalCitationGeoKey = 4097,
169
+ VerticalDatumGeoKey = 4098,
170
+ VerticalUnitsGeoKey = 4099,
170
171
  }
@@ -1,18 +1,18 @@
1
1
  export enum TiffTagValueType {
2
- BYTE = 0x0001,
3
- ASCII = 0x0002,
4
- SHORT = 0x0003,
5
- LONG = 0x0004,
6
- RATIONAL = 0x0005,
7
- SBYTE = 0x0006,
8
- UNDEFINED = 0x0007,
9
- SSHORT = 0x0008,
10
- SLONG = 0x0009,
11
- SRATIONAL = 0x000a,
12
- FLOAT = 0x000b,
13
- DOUBLE = 0x000c,
14
- // introduced by BigTIFF
15
- LONG8 = 0x0010,
16
- SLONG8 = 0x0011,
17
- IFD8 = 0x0012,
2
+ Uint8 = 0x0001,
3
+ Ascii = 0x0002,
4
+ Uint16 = 0x0003,
5
+ Uint32 = 0x0004,
6
+ Rational = 0x0005,
7
+ Int8 = 0x0006,
8
+ Undefined = 0x0007,
9
+ Int16 = 0x0008,
10
+ Int32 = 0x0009,
11
+ SignedRational = 0x000a,
12
+ Float32 = 0x000b,
13
+ Float64 = 0x000c,
14
+ // introduced by BigTIFF
15
+ Uint64 = 0x0010,
16
+ Int64 = 0x0011,
17
+ Ifd8 = 0x0012,
18
18
  }
@@ -2,15 +2,15 @@
2
2
  * Tif version number that is stored at the start of a tif file
3
3
  */
4
4
  export enum TiffVersion {
5
- /**
6
- * Big tif's,
7
- * generally uses 64bit numbers for offsets
8
- * @see http://bigtiff.org/
9
- **/
10
- BigTiff = 43,
11
- /**
12
- * Original tif
13
- * Uses 32 bit or smaller numbers for offsets and counters
14
- */
15
- Tiff = 42,
5
+ /**
6
+ * Big tif's,
7
+ * generally uses 64bit numbers for offsets
8
+ * @see http://bigtiff.org/
9
+ **/
10
+ BigTiff = 43,
11
+ /**
12
+ * Original tif
13
+ * Uses 32 bit or smaller numbers for offsets and counters
14
+ */
15
+ Tiff = 42,
16
16
  }
package/src/index.ts CHANGED
@@ -1,5 +1,11 @@
1
- export * from './cog.tiff.js';
2
- export * from './cog.tiff.image.js';
3
- export * from './const/index.js';
4
- export * from './read/tiff.value.reader.js';
5
- export { Vector, BoundingBox, Size, Point } from './vector.js';
1
+ export { CogTiff } from './cog.tiff.js';
2
+ export { TiffEndian } from './const/tiff.endian.js';
3
+ export { TiffCompression, TiffMimeType } from './const/tiff.mime.js';
4
+ export { TagGeoId as TiffTagGeo, TagId as TiffTagId } from './const/tiff.tag.id.js';
5
+ export { TiffTagValueType } from './const/tiff.tag.value.js';
6
+ export { TiffVersion } from './const/tiff.version.js';
7
+ export { TagInline, TagLazy, TagOffset, Tag as TiffTag } from './read/tiff.tag.js';
8
+ export { getTiffTagSize } from './read/tiff.value.reader.js';
9
+ export { Source } from './source.js';
10
+ export { toHex } from './util/util.hex.js';
11
+ export { BoundingBox, Point, Size, Vector } from './vector.js';
@@ -0,0 +1,23 @@
1
+ /** Extension to DataView that includes the offset to where in a file the view is from */
2
+ export type DataViewOffset = DataView & {
3
+ /** Offset in the source to where this data was read from */
4
+ sourceOffset: number;
5
+ };
6
+
7
+ /** Convert the dataview to a dataview with a offset */
8
+ export function toDataViewOffset(d: DataView, offset: number): asserts d is DataViewOffset {
9
+ (d as DataViewOffset).sourceOffset = offset;
10
+ }
11
+
12
+ /**
13
+ * Does a DataviewOffset include the absolute bytes of the source file
14
+ *
15
+ * @param view DataViewOffset to check
16
+ * @param targetOffset the absolute offset in the file
17
+ * @param count number of bytes to include
18
+ */
19
+ export function hasBytes(view: DataViewOffset, targetOffset: number, count: number): boolean {
20
+ if (targetOffset < view.sourceOffset) return false;
21
+ if (view.sourceOffset + view.byteLength < targetOffset + count) return false;
22
+ return true;
23
+ }
@@ -1,22 +1,21 @@
1
- import { ByteSize } from '@chunkd/core';
2
- import { CogTiff } from '../cog.tiff.js';
1
+ import { ByteSize } from '../util/bytes.js';
3
2
 
4
3
  export enum GhostOption {
5
- GDAL_STRUCTURAL_METADATA_SIZE = 'GDAL_STRUCTURAL_METADATA_SIZE',
6
- LAYOUT = 'LAYOUT',
7
- BLOCK_ORDER = 'BLOCK_ORDER',
8
- BLOCK_LEADER = 'BLOCK_LEADER',
9
- BLOCK_TRAILER = 'BLOCK_TRAILER',
10
- KNOWN_INCOMPATIBLE_EDITION = 'KNOWN_INCOMPATIBLE_EDITION',
11
- MASK_INTERLEAVED_WITH_IMAGERY = 'MASK_INTERLEAVED_WITH_IMAGERY',
4
+ GdalStructuralMetadataSize = 'GDAL_STRUCTURAL_METADATA_SIZE',
5
+ Layout = 'LAYOUT',
6
+ BlockOrder = 'BLOCK_ORDER',
7
+ BlockLeader = 'BLOCK_LEADER',
8
+ BlockTrailer = 'BLOCK_TRAILER',
9
+ KnownIncompatibleEdition = 'KNOWN_INCOMPATIBLE_EDITION',
10
+ MaskInterleavedWithImagery = 'MASK_INTERLEAVED_WITH_IMAGERY',
12
11
  }
13
12
 
14
13
  export enum GhostOptionTileOrder {
15
- RowMajor = 'ROW_MAJOR',
14
+ RowMajor = 'ROW_MAJOR',
16
15
  }
17
16
 
18
17
  export enum GhostOptionTileLeader {
19
- uint32 = 'SIZE_AS_UINT4',
18
+ uint32 = 'SIZE_AS_UINT4',
20
19
  }
21
20
 
22
21
  /**
@@ -24,64 +23,63 @@ export enum GhostOptionTileLeader {
24
23
  * this class represents the optimizations that can be used
25
24
  */
26
25
  export class CogTifGhostOptions {
27
- options: Map<string, string> = new Map();
28
- source: CogTiff;
26
+ options: Map<string, string> = new Map();
29
27
 
30
- /**
31
- * Has GDAL optimized this tif
32
- */
33
- get isCogOptimized(): boolean {
34
- if (this.isBroken) return false;
35
- return this.options.get(GhostOption.LAYOUT) === 'IFDS_BEFORE_DATA';
36
- }
28
+ /**
29
+ * Has GDAL optimized this tif
30
+ */
31
+ get isCogOptimized(): boolean {
32
+ if (this.isBroken) return false;
33
+ return this.options.get(GhostOption.Layout) === 'IFDS_BEFORE_DATA';
34
+ }
37
35
 
38
- /**
39
- * Has GDAL determined this tif is now broken
40
- */
41
- get isBroken(): boolean {
42
- return this.options.get(GhostOption.KNOWN_INCOMPATIBLE_EDITION) === 'YES';
43
- }
36
+ /**
37
+ * Has GDAL determined this tif is now broken
38
+ */
39
+ get isBroken(): boolean {
40
+ return this.options.get(GhostOption.KnownIncompatibleEdition) === 'YES';
41
+ }
44
42
 
45
- /**
46
- * Load the ghost options from a source
47
- * @param bytes the ghost header bytes
48
- */
49
- process(bytes: Uint8Array): void {
50
- let key = '';
51
- let value = '';
52
- let setValue = false;
53
- for (let i = 0; i < bytes.length; i++) {
54
- const charCode = bytes[i];
55
- if (charCode === 0) break;
43
+ /**
44
+ * Load the ghost options from a source
45
+ * @param bytes the ghost header bytes
46
+ */
47
+ process(bytes: DataView, offset: number, ghostSize: number): void {
48
+ let key = '';
49
+ let value = '';
50
+ let setValue = false;
51
+ for (let i = 0; i < ghostSize; i++) {
52
+ const charCode = bytes.getUint8(offset + i);
53
+ if (charCode === 0) break;
56
54
 
57
- const char = String.fromCharCode(charCode);
58
- if (char === '\n') {
59
- this.options.set(key.trim(), value.trim());
60
- key = '';
61
- value = '';
62
- setValue = false;
63
- } else if (char === '=') {
64
- setValue = true;
65
- } else {
66
- if (setValue) value += char;
67
- else key += char;
68
- }
69
- }
55
+ const char = String.fromCharCode(charCode);
56
+ if (char === '\n') {
57
+ this.options.set(key.trim(), value.trim());
58
+ key = '';
59
+ value = '';
60
+ setValue = false;
61
+ } else if (char === '=') {
62
+ setValue = true;
63
+ } else {
64
+ if (setValue) value += char;
65
+ else key += char;
66
+ }
70
67
  }
68
+ }
71
69
 
72
- /**
73
- * If the tile leader is set, how many bytes are allocated to the tile size
74
- */
75
- get tileLeaderByteSize(): ByteSize | null {
76
- switch (this.options.get(GhostOption.BLOCK_LEADER)) {
77
- case GhostOptionTileLeader.uint32:
78
- return ByteSize.UInt32;
79
- default:
80
- return null;
81
- }
70
+ /**
71
+ * If the tile leader is set, how many bytes are allocated to the tile size
72
+ */
73
+ get tileLeaderByteSize(): ByteSize | null {
74
+ switch (this.options.get(GhostOption.BlockLeader)) {
75
+ case GhostOptionTileLeader.uint32:
76
+ return ByteSize.UInt32;
77
+ default:
78
+ return null;
82
79
  }
80
+ }
83
81
 
84
- get isMaskInterleaved(): boolean {
85
- return this.options.get(GhostOption.MASK_INTERLEAVED_WITH_IMAGERY) === 'YES';
86
- }
82
+ get isMaskInterleaved(): boolean {
83
+ return this.options.get(GhostOption.MaskInterleavedWithImagery) === 'YES';
84
+ }
87
85
  }
@@ -1,45 +1,49 @@
1
- import { ByteSize } from '@chunkd/core';
1
+ import { ByteSize } from '../util/bytes.js';
2
2
  import { TiffVersion } from '../const/tiff.version.js';
3
3
 
4
4
  export const TagTiffConfig: TiffIfdConfig = {
5
- version: TiffVersion.Tiff,
6
- pointer: ByteSize.UInt32,
7
- offset: ByteSize.UInt16,
8
- /**
9
- * Each tag entry is specified as
10
- * UInt16:TagCode
11
- * UInt16:TagType
12
- * UInt32:TagCount
13
- * UInt32:Pointer To Value or value
14
- */
15
- ifd: ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt32,
5
+ version: TiffVersion.Tiff,
6
+ pointer: ByteSize.UInt32,
7
+ offset: ByteSize.UInt16,
8
+ /**
9
+ * Each tag entry is specified as
10
+ * UInt16:TagCode
11
+ * UInt16:TagType
12
+ * UInt32:TagCount
13
+ * UInt32:Pointer To Value or value
14
+ */
15
+ ifd: ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt32,
16
16
  };
17
17
 
18
18
  export const TagTiffBigConfig: TiffIfdConfig = {
19
- version: TiffVersion.BigTiff,
20
- /** Size of most pointers */
21
- pointer: ByteSize.UInt64,
22
- /** Size of offsets */
23
- offset: ByteSize.UInt64,
19
+ version: TiffVersion.BigTiff,
20
+ /** Size of most pointers */
21
+ pointer: ByteSize.UInt64,
22
+ /** Size of offsets */
23
+ offset: ByteSize.UInt64,
24
24
 
25
- /**
26
- * Each tag entry is specified as
27
- * UInt16:TagCode
28
- * UInt16:TagType
29
- * UInt64:TagCount
30
- * UInt64:Pointer To Value or value
31
- */
32
- ifd: ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt64,
25
+ /**
26
+ * Each tag entry is specified as
27
+ * UInt16:TagCode
28
+ * UInt16:TagType
29
+ * UInt64:TagCount
30
+ * UInt64:Pointer To Value or value
31
+ */
32
+ ifd: ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt64,
33
33
  };
34
34
 
35
35
  export interface TiffIfdConfig {
36
- version: TiffVersion;
37
- pointer: ByteSize;
38
- offset: ByteSize;
39
- ifd: number;
36
+ /** Tiff type */
37
+ version: TiffVersion;
38
+ /** Number of bytes a pointer uses */
39
+ pointer: number;
40
+ /** Number of bytes a offset uses */
41
+ offset: number;
42
+ /** Number of bytes the IFD tag contains */
43
+ ifd: number;
40
44
  }
41
45
 
42
46
  export const TiffIfdEntry = {
43
- [TiffVersion.BigTiff]: TagTiffBigConfig,
44
- [TiffVersion.Tiff]: TagTiffConfig,
47
+ [TiffVersion.BigTiff]: TagTiffBigConfig,
48
+ [TiffVersion.Tiff]: TagTiffConfig,
45
49
  };