@@ -10,67 +10,67 @@ import (
1010 _ "github.com/google/tiff/bigtiff"
1111)
1212
13- type SubfileType uint32
13+ type subfileType uint32
1414
1515const (
16- SubfileTypeNone = 0
17- SubfileTypeReducedImage = 1
18- SubfileTypePage = 2
19- SubfileTypeMask = 4
16+ subfileTypeNone = 0
17+ subfileTypeReducedImage = 1
18+ subfileTypePage = 2
19+ subfileTypeMask = 4
2020)
2121
22- type PlanarConfiguration uint16
22+ type planarConfiguration uint16
2323
2424const (
25- PlanarConfigurationContig = 1
26- PlanarConfigurationSeparate = 2
25+ planarConfigurationContig = 1
26+ planarConfigurationSeparate = 2
2727)
2828
29- type Predictor uint16
29+ type predictor uint16
3030
3131const (
32- PredictorNone = 1
33- PredictorHorizontal = 2
34- PredictorFloatingPoint = 3
32+ predictorNone = 1
33+ predictorHorizontal = 2
34+ predictorFloatingPoint = 3
3535)
3636
37- type SampleFormat uint16
37+ type sampleFormat uint16
3838
3939const (
40- SampleFormatUInt = 1
41- SampleFormatInt = 2
42- SampleFormatIEEEFP = 3
43- SampleFormatVoid = 4
44- SampleFormatComplexInt = 5
45- SampleFormatComplexIEEEFP = 6
40+ sampleFormatUInt = 1
41+ sampleFormatInt = 2
42+ sampleFormatIEEEFP = 3
43+ sampleFormatVoid = 4
44+ sampleFormatComplexInt = 5
45+ sampleFormatComplexIEEEFP = 6
4646)
4747
48- type ExtraSamples uint16
48+ type extraSamples uint16
4949
5050const (
51- ExtraSamplesUnspecified = 0
52- ExtraSamplesAssocAlpha = 1
53- ExtraSamplesUnassAlpha = 2
51+ extraSamplesUnspecified = 0
52+ extraSamplesAssocAlpha = 1
53+ extraSamplesUnassAlpha = 2
5454)
5555
56- type PhotometricInterpretation uint16
56+ type photometricInterpretation uint16
5757
5858const (
59- PhotometricInterpretationMinIsWhite = 0
60- PhotometricInterpretationMinIsBlack = 1
61- PhotometricInterpretationRGB = 2
62- PhotometricInterpretationPalette = 3
63- PhotometricInterpretationMask = 4
64- PhotometricInterpretationSeparated = 5
65- PhotometricInterpretationYCbCr = 6
66- PhotometricInterpretationCIELab = 8
67- PhotometricInterpretationICCLab = 9
68- PhotometricInterpretationITULab = 10
69- PhotometricInterpretationLOGL = 32844
70- PhotometricInterpretationLOGLUV = 32845
59+ photometricInterpretationMinIsWhite = 0
60+ photometricInterpretationMinIsBlack = 1
61+ photometricInterpretationRGB = 2
62+ photometricInterpretationPalette = 3
63+ photometricInterpretationMask = 4
64+ photometricInterpretationSeparated = 5
65+ photometricInterpretationYCbCr = 6
66+ photometricInterpretationCIELab = 8
67+ photometricInterpretationICCLab = 9
68+ photometricInterpretationITULab = 10
69+ photometricInterpretationLOGL = 32844
70+ photometricInterpretationLOGLUV = 32845
7171)
7272
73- type IFD struct {
73+ type ifd struct {
7474 //Any field added here should also be accounted for in WriteIFD and ifd.Fieldcount
7575 SubfileType uint32 `tiff:"field,tag=254"`
7676 ImageWidth uint64 `tiff:"field,tag=256"`
@@ -106,8 +106,8 @@ type IFD struct {
106106 LERCParams []uint32 `tiff:"field,tag=50674"`
107107 RPCs []float64 `tiff:"field,tag=50844"`
108108
109- overview * IFD
110- masks []* IFD
109+ overview * ifd
110+ masks []* ifd
111111
112112 ntags uint64
113113 ntilesx , ntilesy uint64
@@ -131,8 +131,8 @@ func (ifd *IFD) StrileSize() uint64 {
131131}
132132*/
133133
134- func (ifd * IFD ) AddOverview (ovr * IFD ) {
135- ovr .SubfileType = SubfileTypeReducedImage
134+ func (ifd * ifd ) AddOverview (ovr * ifd ) {
135+ ovr .SubfileType = subfileTypeReducedImage
136136 ovr .ModelPixelScaleTag = nil
137137 ovr .ModelTiePointTag = nil
138138 ovr .ModelTransformationTag = nil
@@ -141,15 +141,15 @@ func (ifd *IFD) AddOverview(ovr *IFD) {
141141 ovr .GeoKeyDirectoryTag = nil
142142 ifd .overview = ovr
143143}
144- func (ifd * IFD ) AddMask (msk * IFD ) error {
144+ func (ifd * ifd ) AddMask (msk * ifd ) error {
145145 if len (msk .masks ) > 0 || msk .overview != nil {
146146 return fmt .Errorf ("cannot add mask with overviews or masks" )
147147 }
148148 switch ifd .SubfileType {
149- case SubfileTypeNone :
150- msk .SubfileType = SubfileTypeMask
151- case SubfileTypeReducedImage :
152- msk .SubfileType = SubfileTypeMask | SubfileTypeReducedImage
149+ case subfileTypeNone :
150+ msk .SubfileType = subfileTypeMask
151+ case subfileTypeReducedImage :
152+ msk .SubfileType = subfileTypeMask | subfileTypeReducedImage
153153 default :
154154 return fmt .Errorf ("invalid subfiledtype" )
155155 }
@@ -163,7 +163,7 @@ func (ifd *IFD) AddMask(msk *IFD) error {
163163 return nil
164164}
165165
166- func (ifd * IFD ) structure (bigtiff bool ) (tagCount , ifdSize , strileSize uint64 ) {
166+ func (ifd * ifd ) structure (bigtiff bool ) (tagCount , ifdSize , strileSize uint64 ) {
167167 cnt := uint64 (0 )
168168 size := uint64 (16 ) //8 for field count + 8 for next ifd offset
169169 tagSize := uint64 (20 )
@@ -298,26 +298,26 @@ func (ifd *IFD) structure(bigtiff bool) (tagCount, ifdSize, strileSize uint64) {
298298 return cnt , size , strileSize
299299}
300300
301- type TagData struct {
301+ type tagData struct {
302302 bytes.Buffer
303303 Offset uint64
304304}
305305
306- func (t * TagData ) NextOffset () uint64 {
306+ func (t * tagData ) NextOffset () uint64 {
307307 return t .Offset + uint64 (t .Buffer .Len ())
308308}
309309
310- type COG struct {
310+ type cog struct {
311311 enc binary.ByteOrder
312- ifd * IFD
312+ ifd * ifd
313313 bigtiff bool
314314}
315315
316- func New () * COG {
317- return & COG {enc : binary .LittleEndian }
316+ func new () * cog {
317+ return & cog {enc : binary .LittleEndian }
318318}
319319
320- func (cog * COG ) writeHeader (w io.Writer ) error {
320+ func (cog * cog ) writeHeader (w io.Writer ) error {
321321 if cog .bigtiff {
322322 buf := [16 ]byte {}
323323 if cog .enc == binary .LittleEndian {
@@ -346,24 +346,24 @@ func (cog *COG) writeHeader(w io.Writer) error {
346346}
347347
348348const (
349- TByte = 1
350- TAscii = 2
351- TShort = 3
352- TLong = 4
353- TRational = 5
354- TSByte = 6
355- TUndefined = 7
356- TSShort = 8
357- TSLong = 9
358- TSRational = 10
359- TFloat = 11
360- TDouble = 12
361- TLong8 = 16
362- TSLong8 = 17
363- TIFD8 = 18
349+ tByte = 1
350+ tAscii = 2
351+ tShort = 3
352+ tLong = 4
353+ tRational = 5
354+ tSByte = 6
355+ tUndefined = 7
356+ tSShort = 8
357+ tSLong = 9
358+ tSRational = 10
359+ tFloat = 11
360+ tDouble = 12
361+ tLong8 = 16
362+ tSLong8 = 17
363+ tIFD8 = 18
364364)
365365
366- func (cog * COG ) computeStructure () {
366+ func (cog * cog ) computeStructure () {
367367 ifd := cog .ifd
368368 for ifd != nil {
369369 ifd .ntags , ifd .tagsSize , ifd .strileSize = ifd .structure (cog .bigtiff )
@@ -382,7 +382,7 @@ func (cog *COG) computeStructure() {
382382 }
383383}
384384
385- func (cog * COG ) computeImageryOffsets () error {
385+ func (cog * cog ) computeImageryOffsets () error {
386386 ifd := cog .ifd
387387 for ifd != nil {
388388 if cog .bigtiff {
@@ -423,7 +423,7 @@ func (cog *COG) computeImageryOffsets() error {
423423 }
424424
425425 datas := cog .dataInterlacing ()
426- tiles := datas .Tiles ()
426+ tiles := datas .tiles ()
427427 for tile := range tiles {
428428 tileidx := tile .x + tile .y * tile .ifd .ntilesx
429429 cnt := uint64 (tile .ifd .TileByteCounts [tileidx ])
@@ -451,7 +451,7 @@ func (cog *COG) computeImageryOffsets() error {
451451 return nil
452452}
453453
454- func (cog * COG ) Write (out io.Writer ) error {
454+ func (cog * cog ) write (out io.Writer ) error {
455455
456456 err := cog .computeImageryOffsets ()
457457 if err != nil {
@@ -460,7 +460,7 @@ func (cog *COG) Write(out io.Writer) error {
460460
461461 //compute start of strile data, and offsets to subIFDs
462462 //striles are placed after all ifds
463- strileData := & TagData {Offset : 16 }
463+ strileData := & tagData {Offset : 16 }
464464 if ! cog .bigtiff {
465465 strileData .Offset = 8
466466 }
@@ -504,7 +504,7 @@ func (cog *COG) Write(out io.Writer) error {
504504 }
505505
506506 datas := cog .dataInterlacing ()
507- tiles := datas .Tiles ()
507+ tiles := datas .tiles ()
508508 buf := & bytes.Buffer {}
509509 for tile := range tiles {
510510 buf .Reset ()
@@ -525,7 +525,7 @@ func (cog *COG) Write(out io.Writer) error {
525525 return err
526526}
527527
528- func (cog * COG ) writeIFD (w io.Writer , ifd * IFD , offset uint64 , striledata * TagData , next bool ) error {
528+ func (cog * cog ) writeIFD (w io.Writer , ifd * ifd , offset uint64 , striledata * tagData , next bool ) error {
529529
530530 nextOff := uint64 (0 )
531531 if next {
@@ -534,7 +534,7 @@ func (cog *COG) writeIFD(w io.Writer, ifd *IFD, offset uint64, striledata *TagDa
534534 var err error
535535 // Make space for "pointer area" containing IFD entry data
536536 // longer than 4 bytes.
537- overflow := & TagData {
537+ overflow := & tagData {
538538 Offset : offset + 8 + 20 * ifd .ntags + 8 ,
539539 }
540540 if ! cog .bigtiff {
@@ -787,33 +787,33 @@ func (cog *COG) writeIFD(w io.Writer, ifd *IFD, offset uint64, striledata *TagDa
787787}
788788
789789type tile struct {
790- ifd * IFD
790+ ifd * ifd
791791 x , y uint64
792792}
793793
794- type datas [][]* IFD
794+ type datas [][]* ifd
795795
796- func (cog * COG ) dataInterlacing () datas {
796+ func (cog * cog ) dataInterlacing () datas {
797797 //count overviews
798- ifd := cog .ifd
798+ ifdo := cog .ifd
799799 count := 0
800- for ifd != nil {
800+ for ifdo != nil {
801801 count ++
802- ifd = ifd .overview
802+ ifdo = ifdo .overview
803803 }
804- ret := make ([][]* IFD , count )
805- ifd = cog .ifd
804+ ret := make ([][]* ifd , count )
805+ ifdo = cog .ifd
806806 for idx := count - 1 ; idx >= 0 ; idx -- {
807- ret [idx ] = append (ret [idx ], ifd )
808- for _ , mi := range ifd .masks {
807+ ret [idx ] = append (ret [idx ], ifdo )
808+ for _ , mi := range ifdo .masks {
809809 ret [idx ] = append (ret [idx ], mi )
810810 }
811- ifd = ifd .overview
811+ ifdo = ifdo .overview
812812 }
813813 return ret
814814}
815815
816- func (d datas ) Tiles () chan tile {
816+ func (d datas ) tiles () chan tile {
817817 ch := make (chan tile )
818818 go func () {
819819 defer close (ch )
0 commit comments