@cogeotiff/core 7.2.1 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -502
- package/README.md +23 -11
- package/build/__benchmark__/cog.read.benchmark.d.ts +0 -1
- package/build/__benchmark__/cog.read.benchmark.js +6 -4
- package/build/__benchmark__/cog.read.benchmark.js.map +1 -0
- package/build/__benchmark__/source.file.d.ts +9 -0
- package/build/__benchmark__/source.file.js +29 -0
- package/build/__benchmark__/source.file.js.map +1 -0
- package/build/__benchmark__/source.memory.d.ts +9 -0
- package/build/__benchmark__/source.memory.js +32 -0
- package/build/__benchmark__/source.memory.js.map +1 -0
- package/build/__test__/cog.image.test.d.ts +1 -2
- package/build/__test__/cog.image.test.js +82 -90
- package/build/__test__/cog.image.test.js.map +1 -0
- package/build/__test__/cog.read.test.d.ts +1 -2
- package/build/__test__/cog.read.test.js +37 -55
- package/build/__test__/cog.read.test.js.map +1 -0
- package/build/__test__/example.d.ts +1 -0
- package/build/__test__/example.js +27 -0
- package/build/__test__/example.js.map +1 -0
- package/build/cog.tiff.d.ts +22 -28
- package/build/cog.tiff.image.d.ts +11 -23
- package/build/cog.tiff.image.js +108 -62
- package/build/cog.tiff.image.js.map +1 -0
- package/build/cog.tiff.js +141 -97
- package/build/cog.tiff.js.map +1 -0
- package/build/const/index.d.ts +1 -2
- package/build/const/index.js +2 -2
- package/build/const/index.js.map +1 -0
- package/build/const/tiff.endian.d.ts +0 -1
- package/build/const/tiff.endian.js +1 -1
- package/build/const/tiff.endian.js.map +1 -0
- package/build/const/tiff.mime.d.ts +10 -11
- package/build/const/tiff.mime.js +22 -22
- package/build/const/tiff.mime.js.map +1 -0
- package/build/const/tiff.tag.id.d.ts +3 -3
- package/build/const/tiff.tag.id.js +4 -3
- package/build/const/tiff.tag.id.js.map +1 -0
- package/build/const/tiff.tag.value.d.ts +15 -16
- package/build/const/tiff.tag.value.js +16 -16
- package/build/const/tiff.tag.value.js.map +1 -0
- package/build/const/tiff.version.d.ts +0 -1
- package/build/const/tiff.version.js +1 -1
- package/build/const/tiff.version.js.map +1 -0
- package/build/index.d.ts +11 -6
- package/build/index.js +9 -5
- package/build/index.js.map +1 -0
- package/build/read/data.view.offset.d.ts +15 -0
- package/build/read/data.view.offset.js +19 -0
- package/build/read/data.view.offset.js.map +1 -0
- package/build/read/tiff.gdal.d.ts +9 -12
- package/build/read/tiff.gdal.js +22 -17
- package/build/read/tiff.gdal.js.map +1 -0
- package/build/read/tiff.ifd.config.d.ts +6 -4
- package/build/read/tiff.ifd.config.js +2 -2
- package/build/read/tiff.ifd.config.js.map +1 -0
- package/build/read/tiff.tag.d.ts +40 -20
- package/build/read/tiff.tag.factory.d.ts +16 -0
- package/build/read/tiff.tag.factory.js +130 -0
- package/build/read/tiff.tag.factory.js.map +1 -0
- package/build/read/tiff.tag.js +2 -37
- package/build/read/tiff.tag.js.map +1 -0
- package/build/read/tiff.value.reader.d.ts +2 -6
- package/build/read/tiff.value.reader.js +16 -54
- package/build/read/tiff.value.reader.js.map +1 -0
- package/build/source.d.ts +5 -0
- package/build/source.js +2 -0
- package/build/source.js.map +1 -0
- package/build/util/bytes.d.ts +17 -0
- package/build/util/bytes.js +42 -0
- package/build/util/bytes.js.map +1 -0
- package/build/util/util.hex.d.ts +2 -3
- package/build/util/util.hex.js +4 -5
- package/build/util/util.hex.js.map +1 -0
- package/build/vector.d.ts +0 -1
- package/build/vector.js +1 -1
- package/build/vector.js.map +1 -0
- package/package.json +25 -30
- package/src/__benchmark__/cog.read.benchmark.ts +12 -10
- package/src/__benchmark__/source.file.ts +23 -0
- package/src/__benchmark__/source.memory.ts +23 -0
- package/src/__test__/cog.image.test.ts +188 -197
- package/src/__test__/cog.read.test.ts +50 -72
- package/src/__test__/example.ts +31 -0
- package/src/cog.tiff.image.ts +456 -447
- package/src/cog.tiff.ts +142 -145
- package/src/const/index.ts +1 -1
- package/src/const/tiff.endian.ts +2 -2
- package/src/const/tiff.mime.ts +21 -21
- package/src/const/tiff.tag.id.ts +157 -156
- package/src/const/tiff.tag.value.ts +16 -16
- package/src/const/tiff.version.ts +11 -11
- package/src/index.ts +11 -5
- package/src/read/data.view.offset.ts +23 -0
- package/src/read/tiff.gdal.ts +61 -63
- package/src/read/tiff.ifd.config.ts +35 -31
- package/src/read/tiff.tag.factory.ts +163 -0
- package/src/read/tiff.tag.ts +40 -38
- package/src/read/tiff.value.reader.ts +25 -73
- package/src/source.ts +5 -0
- package/src/util/bytes.ts +44 -0
- package/src/util/util.hex.ts +5 -7
- package/src/vector.ts +5 -5
- package/tsconfig.json +8 -8
- package/build/__benchmark__/cog.read.benchmark.d.ts.map +0 -1
- package/build/__test__/cog.image.test.d.ts.map +0 -1
- package/build/__test__/cog.read.test.d.ts.map +0 -1
- package/build/cog.tiff.d.ts.map +0 -1
- package/build/cog.tiff.image.d.ts.map +0 -1
- package/build/const/index.d.ts.map +0 -1
- package/build/const/tiff.endian.d.ts.map +0 -1
- package/build/const/tiff.mime.d.ts.map +0 -1
- package/build/const/tiff.tag.id.d.ts.map +0 -1
- package/build/const/tiff.tag.value.d.ts.map +0 -1
- package/build/const/tiff.version.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/read/tag/__test__/tag.test.d.ts +0 -2
- package/build/read/tag/__test__/tag.test.d.ts.map +0 -1
- package/build/read/tag/__test__/tag.test.js +0 -23
- package/build/read/tag/tiff.tag.base.d.ts +0 -55
- package/build/read/tag/tiff.tag.base.d.ts.map +0 -1
- package/build/read/tag/tiff.tag.base.js +0 -79
- package/build/read/tag/tiff.tag.lazy.d.ts +0 -7
- package/build/read/tag/tiff.tag.lazy.d.ts.map +0 -1
- package/build/read/tag/tiff.tag.lazy.js +0 -18
- package/build/read/tag/tiff.tag.offset.d.ts +0 -21
- package/build/read/tag/tiff.tag.offset.d.ts.map +0 -1
- package/build/read/tag/tiff.tag.offset.js +0 -54
- package/build/read/tag/tiff.tag.static.d.ts +0 -8
- package/build/read/tag/tiff.tag.static.d.ts.map +0 -1
- package/build/read/tag/tiff.tag.static.js +0 -17
- package/build/read/tiff.gdal.d.ts.map +0 -1
- package/build/read/tiff.ifd.config.d.ts.map +0 -1
- package/build/read/tiff.tag.d.ts.map +0 -1
- package/build/read/tiff.value.reader.d.ts.map +0 -1
- package/build/source/cog.source.view.d.ts +0 -33
- package/build/source/cog.source.view.d.ts.map +0 -1
- package/build/source/cog.source.view.js +0 -65
- package/build/util/util.hex.d.ts.map +0 -1
- package/build/vector.d.ts.map +0 -1
- package/src/@types/ieee754.d.ts +0 -18
- package/src/read/tag/__test__/tag.test.ts +0 -27
- package/src/read/tag/tiff.tag.base.ts +0 -126
- package/src/read/tag/tiff.tag.lazy.ts +0 -17
- package/src/read/tag/tiff.tag.offset.ts +0 -61
- package/src/read/tag/tiff.tag.static.ts +0 -15
- package/src/source/cog.source.view.ts +0 -77
package/src/const/tiff.tag.id.ts
CHANGED
|
@@ -1,170 +1,171 @@
|
|
|
1
1
|
// Stolen from geotiff.js
|
|
2
2
|
export enum TiffTag {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
97
|
+
// IPTC
|
|
98
|
+
IPTC = 0x83bb,
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// ICC
|
|
101
|
+
ICCProfile = 0x8773,
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
// XMP
|
|
104
|
+
XMP = 0x02bc,
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
// GDAL
|
|
107
|
+
GdalMetadata = 0xa480,
|
|
108
|
+
GdalNoData = 0xa481,
|
|
109
|
+
LercParams = 0xc5f2,
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
// Photoshop
|
|
112
|
+
Photoshop = 0x8649,
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
123
|
export enum TiffTagGeo {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
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 { TiffTagGeo, TiffTag } 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 } 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
|
+
}
|
package/src/read/tiff.gdal.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { ByteSize } from '
|
|
2
|
-
import { CogTiff } from '../cog.tiff.js';
|
|
1
|
+
import { ByteSize } from '../util/bytes.js';
|
|
3
2
|
|
|
4
3
|
export enum GhostOption {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
+
RowMajor = 'ROW_MAJOR',
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export enum GhostOptionTileLeader {
|
|
19
|
-
|
|
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
|
-
|
|
28
|
-
source: CogTiff;
|
|
26
|
+
options: Map<string, string> = new Map();
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
get isMaskInterleaved(): boolean {
|
|
83
|
+
return this.options.get(GhostOption.MaskInterleavedWithImagery) === 'YES';
|
|
84
|
+
}
|
|
87
85
|
}
|
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
import { ByteSize } from '
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
47
|
+
[TiffVersion.BigTiff]: TagTiffBigConfig,
|
|
48
|
+
[TiffVersion.Tiff]: TagTiffConfig,
|
|
45
49
|
};
|