-
Notifications
You must be signed in to change notification settings - Fork 28
/
options.go
1649 lines (1438 loc) · 41.1 KB
/
options.go
1
2
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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2021 Airbus Defence and Space
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package godal
import "sort"
// GetGeoTransformOption is an option that can be passed to Dataset.GeoTransform()
//
// Available GetGeoTransformOptions are:
// - ErrLogger
type GetGeoTransformOption interface {
setGetGeoTransformOpt(ndo *getGeoTransformOpts)
}
type getGeoTransformOpts struct {
errorHandler ErrorHandler
}
// SetGeoTransformOption is an option that can be passed to Dataset.SetGeoTransform()
//
// Available SetGeoTransformOptions are:
// - ErrLogger
type SetGeoTransformOption interface {
setSetGeoTransformOpt(ndo *setGeoTransformOpts)
}
type setGeoTransformOpts struct {
errorHandler ErrorHandler
}
// SetProjectionOption is an option that can be passed to Dataset.SetProjection
//
// Available SetProjection are:
// - ErrLogger
type SetProjectionOption interface {
setSetProjectionOpt(ndo *setProjectionOpts)
}
type setProjectionOpts struct {
errorHandler ErrorHandler
}
// SetSpatialRefOption is an option that can be passed to Dataset.SetSpatialRef
//
// Available SetProjection are:
// - ErrLogger
type SetSpatialRefOption interface {
setSetSpatialRefOpt(ndo *setSpatialRefOpts)
}
type setSpatialRefOpts struct {
errorHandler ErrorHandler
}
// SetNoDataOption is an option that can be passed to Band.SetNodata(),
// Band.ClearNodata(), Dataset.SetNodata()
//
// Available SetNoDataOptions are:
// - ErrLogger
type SetNoDataOption interface {
setSetNoDataOpt(ndo *setNodataOpts)
}
type setNodataOpts struct {
errorHandler ErrorHandler
}
// SetScaleOffsetOption is an option that can be passed to Band.SetScaleOffset(),
// Band.ClearScaleOffset(), Dataset.SetScaleOffset()
//
// Available SetScaleOffsetOptions are:
// - ErrLogger
type SetScaleOffsetOption interface {
setSetScaleOffsetOpt(so *setScaleOffsetOpts)
}
type setScaleOffsetOpts struct {
errorHandler ErrorHandler
}
// SetColorInterpOption is an option that can be passed to Band.SetColorInterpretation()
//
// Available SetColorInterpOption are:
// - ErrLogger
type SetColorInterpOption interface {
setSetColorInterpOpt(ndo *setColorInterpOpts)
}
type setColorInterpOpts struct {
errorHandler ErrorHandler
}
// SetColorTableOption is an option that can be passed to Band.SetColorTable()
//
// Available SetColorTableOption are:
// - ErrLogger
type SetColorTableOption interface {
setSetColorTableOpt(ndo *setColorTableOpts)
}
type setColorTableOpts struct {
errorHandler ErrorHandler
}
type fillBandOpts struct {
errorHandler ErrorHandler
}
// FillBandOption is an option that can be passed to Band.Fill()
//
// Available FillBandOptions are:
// - ErrLogger
type FillBandOption interface {
setFillBandOpt(o *fillBandOpts)
}
type bandCreateMaskOpts struct {
config []string
errorHandler ErrorHandler
}
// BandCreateMaskOption is an option that can be passed to Band.CreateMask()
//
// Available BandCreateMaskOptions are:
// - ConfigOption
// - ErrLogger
type BandCreateMaskOption interface {
setBandCreateMaskOpt(dcm *bandCreateMaskOpts)
}
type bandIOOpts struct {
config []string
dsWidth, dsHeight int
resampling ResamplingAlg
pixelSpacing, lineSpacing int
pixelStride, lineStride int
errorHandler ErrorHandler
}
// BandIOOption is an option to modify the default behavior of band.IO
//
// Available BandIOOptions are:
// - PixelStride
// - LineStride
// - Window
// - Resampling
// - ConfigOption
// - PixelSpacing
// - LineSpacing
type BandIOOption interface {
setBandIOOpt(ro *bandIOOpts)
}
type fillnodataOpts struct {
mask *Band
//options []string
maxDistance int
iterations int
errorHandler ErrorHandler
}
// FillNoDataOption is an option that can be passed to band.FillNoData
//
// Available FillNoDataOptions are:
// - MaxDistance(int): The maximum distance (in pixels) that the algorithm will
// search out for values to interpolate. The default is 100 pixels.
// - SmoothIterations(int): The number of 3x3 average filter smoothing iterations
// to run after the interpolation to dampen artifacts. The default is zero smoothing iterations.
// - Mask(band) to use given band as nodata mask. The default uses the internal nodata mask
type FillNoDataOption interface {
setFillnodataOpt(ro *fillnodataOpts)
}
type sieveFilterOpts struct {
mask *Band
dstBand *Band
connectedness int
errorHandler ErrorHandler
}
// SieveFilterOption is an option to modify the behavior of Band.SieveFilter
//
// Available SieveFilterOptions are:
// - EightConnected() to enable 8-connectivity. Leave out completely for 4-connectivity (default)
// - Mask(band) to use given band as nodata mask instead of the internal nodata mask
// - NoMask() to ignore the the source band's nodata value or mask band
// - Destination(band) where to output the sieved band, instead of updating in-place
type SieveFilterOption interface {
setSieveFilterOpt(sfo *sieveFilterOpts)
}
type polygonizeOpts struct {
mask *Band
options []string
pixFieldIndex int
errorHandler ErrorHandler
}
// PolygonizeOption is an option to modify the default behavior of band.Polygonize
//
// Available PolygonizeOptions are:
// - EightConnected() to enable 8-connectivity. Leave out completely for 4-connectivity (default)
// - PixelValueFieldIndex(fieldidx) to populate the fieldidx'th field of the output
// dataset with the polygon's pixel value
// - Mask(band) to use given band as nodata mask instead of the internal nodata mask
type PolygonizeOption interface {
setPolygonizeOpt(ro *polygonizeOpts)
}
type dsCreateMaskOpts struct {
config []string
errorHandler ErrorHandler
}
// DatasetCreateMaskOption is an option that can be passed to Dataset.CreateMaskBand()
//
// Available DatasetCreateMaskOptions are:
// - ConfigOption
type DatasetCreateMaskOption interface {
setDatasetCreateMaskOpt(dcm *dsCreateMaskOpts)
}
type dsTranslateOpts struct {
config []string
creation []string
driver DriverName
errorHandler ErrorHandler
}
// DatasetTranslateOption is an option that can be passed to Dataset.Translate()
//
// Available DatasetTranslateOptions are:
// - ConfigOption
// - CreationOption
// - DriverName
type DatasetTranslateOption interface {
setDatasetTranslateOpt(dto *dsTranslateOpts)
}
type dsWarpOpts struct {
config []string
creation []string
driver DriverName
errorHandler ErrorHandler
}
// DatasetWarpOption is an option that can be passed to Dataset.Warp()
//
// Available DatasetWarpOptions are:
// - ConfigOption
// - CreationOption
// - DriverName
type DatasetWarpOption interface {
setDatasetWarpOpt(dwo *dsWarpOpts)
}
// DatasetWarpIntoOption is an option that can be passed to Dataset.WarpInto()
//
// Available DatasetWarpIntoOption is:
// - ConfigOption
type DatasetWarpIntoOption interface {
setDatasetWarpIntoOpt(dwo *dsWarpIntoOpts)
}
type dsWarpIntoOpts struct {
config []string
errorHandler ErrorHandler
}
type buildOvrOpts struct {
config []string
minSize int
resampling ResamplingAlg
bands []int
levels []int
errorHandler ErrorHandler
}
// BuildOverviewsOption is an option to specify how overview building should behave.
//
// Available BuildOverviewsOptions are:
// - ConfigOption
// - Resampling
// - Levels
// - MinSize
// - Bands
type BuildOverviewsOption interface {
setBuildOverviewsOpt(bo *buildOvrOpts)
}
type clearOvrOpts struct {
errorHandler ErrorHandler
}
// ClearOverviewsOption is an option passed to Dataset.ClearOverviews
//
// Available options are:
// - ErrLogger
type ClearOverviewsOption interface {
setClearOverviewsOpt(bo *clearOvrOpts)
}
type datasetIOOpts struct {
config []string
bands []int
dsWidth, dsHeight int
resampling ResamplingAlg
bandInterleave bool //return r1r2...rn,g1g2...gn,b1b2...bn instead of r1g1b1,r2g2b2,...,rngnbn
bandSpacing, pixelSpacing, lineSpacing int
bandStride, pixelStride, lineStride int
errorHandler ErrorHandler
}
// DatasetIOOption is an option to modify the default behavior of dataset.IO
//
// Available DatasetIOOptions are:
// - PixelStride
// - LineStride
// - BandStride
// - Window
// - Resampling
// - ConfigOption
// - Bands
// - BandInterleaved
// - PixelSpacing
// - LineSpacing
// - BandSpacing
type DatasetIOOption interface {
setDatasetIOOpt(ro *datasetIOOpts)
}
type dsCreateOpts struct {
config []string
creation []string
errorHandler ErrorHandler
}
// DatasetCreateOption is an option that can be passed to Create()
//
// Available DatasetCreateOptions are:
// - CreationOption
// - ConfigOption
// - ErrLogger
type DatasetCreateOption interface {
setDatasetCreateOpt(dc *dsCreateOpts)
}
type openOpts struct {
flags uint
drivers []string //list of drivers that can be tried to open the given name
options []string //driver specific open options (see gdal docs for each driver)
siblingFiles []string //list of sidecar files
config []string
errorHandler ErrorHandler
}
// OpenOption is an option passed to Open()
//
// Available OpenOptions are:
// - Drivers
// - SiblingFiles
// - Shared
// - ConfigOption
// - Update
// - DriverOpenOption
// - RasterOnly
// - VectorOnly
type OpenOption interface {
setOpenOpt(oo *openOpts)
}
type closeOpts struct {
errorHandler ErrorHandler
}
// CloseOption is an option passed to Dataset.Close()
//
// Available options are:
// - ErrLogger
type CloseOption interface {
setCloseOpt(o *closeOpts)
}
type featureCountOpts struct {
errorHandler ErrorHandler
}
// FeatureCountOption is an option passed to Layer.FeatureCount()
//
// Available options are:
// - ErrLogger
type FeatureCountOption interface {
setFeatureCountOpt(fo *featureCountOpts)
}
type addGeometryOpts struct {
errorHandler ErrorHandler
}
type simplifyOpts struct {
errorHandler ErrorHandler
}
type bufferOpts struct {
errorHandler ErrorHandler
}
type differenceOpts struct {
errorHandler ErrorHandler
}
type intersectsOpts struct {
errorHandler ErrorHandler
}
type subGeometryOpts struct {
errorHandler ErrorHandler
}
type intersectionOpts struct {
errorHandler ErrorHandler
}
type unionOpts struct {
errorHandler ErrorHandler
}
// AddGeometryOption is an option passed to Geometry.AddGeometry()
//
// Available options are:
// - ErrLogger
type AddGeometryOption interface {
setAddGeometryOpt(ao *addGeometryOpts)
}
// SimplifyOption is an option passed to Geometry.Simplify()
//
// Available options are:
// - ErrLogger
type SimplifyOption interface {
setSimplifyOpt(so *simplifyOpts)
}
// BufferOption is an option passed to Geometry.Buffer()
//
// Available options are:
// - ErrLogger
type BufferOption interface {
setBufferOpt(bo *bufferOpts)
}
// DifferenceOption is an option passed to Geometry.Difference()
//
// Available options are:
// - ErrLogger
type DifferenceOption interface {
setDifferenceOpt(do *differenceOpts)
}
// IntersectsOption is an option passed to Geometry.Intersects()
//
// Available options are:
// - ErrLogger
type IntersectsOption interface {
setIntersectsOpt(bo *intersectsOpts)
}
// SubGeometryOption is an option passed to Geometry.SubGeometry()
//
// Available options are:
// - ErrLogger
type SubGeometryOption interface {
setSubGeometryOpt(so *subGeometryOpts)
}
// IntersectionOption is an option passed to Geometry.Intersection()
//
// Available options are:
// - ErrLogger
type IntersectionOption interface {
setIntersectionOpt(io *intersectionOpts)
}
// UnionOption is an option passed to Geometry.Union()
//
// Available options are:
// - ErrLogger
type UnionOption interface {
setUnionOpt(uo *unionOpts)
}
type setGeometryOpts struct {
errorHandler ErrorHandler
}
// SetGeometryOption is an option passed to Feature.SetGeometry()
//
// Available options are:
// - ErrLogger
type SetGeometryOption interface {
setSetGeometryOpt(so *setGeometryOpts)
}
type setFieldValueOpts struct {
errorHandler ErrorHandler
}
// SetFieldValueOption is an option passed to Feature.SetFieldValue()
//
// Available options are:
// - ErrLogger
type SetFieldValueOption interface {
setSetFieldValueOpt(so *setFieldValueOpts)
}
type vsiOpenOpts struct {
errorHandler ErrorHandler
}
// VSIOpenOption is an option passed to VSIOpen()
//
// Available options are:
// - ErrLogger
type VSIOpenOption interface {
setVSIOpenOpt(vo *vsiOpenOpts)
}
type vsiUnlinkOpts struct {
errorHandler ErrorHandler
}
// VSIUnlinkOption is an option passed to VSIUnlink()
//
// Available options are:
// - ErrLogger
type VSIUnlinkOption interface {
setVSIUnlinkOpt(vo *vsiUnlinkOpts)
}
type geometryWKTOpts struct {
errorHandler ErrorHandler
}
// GeometryWKTOption is an option passed to Geometry.WKT()
//
// Available options are:
// - ErrLogger
type GeometryWKTOption interface {
setGeometryWKTOpt(o *geometryWKTOpts)
}
type geometryWKBOpts struct {
errorHandler ErrorHandler
}
// GeometryWKBOption is an option passed to Geometry.WKB()
//
// Available options are:
// - ErrLogger
type GeometryWKBOption interface {
setGeometryWKBOpt(o *geometryWKBOpts)
}
type newGeometryOpts struct {
errorHandler ErrorHandler
}
// NewGeometryOption is an option passed when creating a geometry
//
// Available options are:
// - ErrLogger
type NewGeometryOption interface {
setNewGeometryOpt(o *newGeometryOpts)
}
type updateFeatureOpts struct {
errorHandler ErrorHandler
}
// UpdateFeatureOption is an option passed to Layer.UpdateFeature()
//
// Available options are:
// - ErrLogger
type UpdateFeatureOption interface {
setUpdateFeatureOpt(o *updateFeatureOpts)
}
type deleteFeatureOpts struct {
errorHandler ErrorHandler
}
// DeleteFeatureOption is an option passed to Layer.DeleteFeature()
//
// Available options are:
// - ErrLogger
type DeleteFeatureOption interface {
setDeleteFeatureOpt(o *deleteFeatureOpts)
}
type setGeometryColumnNameOpts struct {
errorHandler ErrorHandler
}
// SetGeometryColumnNameOption is an option passed to Layer.SetGeometryColumnName() or Feature.SetGeometryColumnName()
//
// Available options are:
// - ErrLogger
type SetGeometryColumnNameOption interface {
setGeometryColumnNameOpt(o *setGeometryColumnNameOpts)
}
type geometryTransformOpts struct {
errorHandler ErrorHandler
}
// GeometryTransformOption is an option passed to Geometry.Transform()
//
// Available options are:
// - ErrLogger
type GeometryTransformOption interface {
setGeometryTransformOpt(o *geometryTransformOpts)
}
type geometryReprojectOpts struct {
errorHandler ErrorHandler
}
// GeometryReprojectOption is an option passed to Geometry.Reproject()
//
// Available options are:
// - ErrLogger
type GeometryReprojectOption interface {
setGeometryReprojectOpt(o *geometryReprojectOpts)
}
type siblingFilesOpt struct {
files []string
}
// SiblingFiles specifies the list of files that may be opened alongside the prinicpal dataset name.
//
// files must not contain a directory component (i.e. are expected to be in the same directory as
// the main dataset)
//
// SiblingFiles may be used in 3 different manners:
// - By default, i.e. by not using the option, godal will consider that there are no sibling files
// at all and will prevent any scanning or probing of specific sibling files by passing a list of
// sibling files to gdal containing only the main file
// - By passing a list of files, only those files will be probed
// - By passing SiblingFiles() (i.e. with an empty list of files), the default gdal behavior of
//
// reading the directory content and/or probing for well-known sidecar filenames will be used.
func SiblingFiles(files ...string) interface {
OpenOption
} {
return siblingFilesOpt{files}
}
func (sf siblingFilesOpt) setOpenOpt(oo *openOpts) {
if len(sf.files) > 0 {
oo.siblingFiles = append(oo.siblingFiles, sf.files...)
} else {
oo.siblingFiles = nil
}
}
type setDescriptionOpts struct {
errorHandler ErrorHandler
}
// SetDescriptionOption is an option that can be passed to SetDescription
// Available SetDescriptionOptions are:
// - ErrLogger
type SetDescriptionOption interface {
setDescriptionOpt(mo *setDescriptionOpts)
}
type metadataOpts struct {
domain string
errorHandler ErrorHandler
}
type domainOpt struct {
domain string
}
// MetadataOption is an option that can be passed to metadata related calls
// Available MetadataOptions are:
// - Domain
type MetadataOption interface {
setMetadataOpt(mo *metadataOpts)
}
// Domain specifies the gdal metadata domain to use
func Domain(mdDomain string) interface {
MetadataOption
} {
return domainOpt{mdDomain}
}
func (mdo domainOpt) setMetadataOpt(mo *metadataOpts) {
mo.domain = mdo.domain
}
type bandOpt struct {
bnds []int
}
// Bands specifies which dataset bands should be read/written. By default all dataset bands
// are read/written.
//
// Note: bnds is 0-indexed so as to be consistent with Dataset.Bands(), whereas in GDAL terminology,
// bands are 1-indexed. i.e. for a 3 band dataset you should pass Bands(0,1,2) and not Bands(1,2,3).
func Bands(bnds ...int) interface {
DatasetIOOption
BuildOverviewsOption
RasterizeGeometryOption
BuildVRTOption
} {
ib := make([]int, len(bnds))
for i := range bnds {
ib[i] = bnds[i] + 1
}
return bandOpt{ib}
}
func (bo bandOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.bands = bo.bnds
}
func (bo bandOpt) setBuildOverviewsOpt(ovr *buildOvrOpts) {
ovr.bands = bo.bnds
}
func (bo bandOpt) setRasterizeGeometryOpt(o *rasterizeGeometryOpts) {
o.bands = bo.bnds
}
func (bo bandOpt) setBuildVRTOpt(bvo *buildVRTOpts) {
bvo.bands = bo.bnds
}
type bandSpacingOpt struct {
sp int
}
type pixelSpacingOpt struct {
sp int
}
type lineSpacingOpt struct {
sp int
}
type bandStrideOpt struct {
sp int
}
type pixelStrideOpt struct {
sp int
}
type lineStrideOpt struct {
sp int
}
func (so bandStrideOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.bandStride = so.sp
}
func (so pixelStrideOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.pixelStride = so.sp
}
func (so lineStrideOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.lineStride = so.sp
}
func (so lineStrideOpt) setBandIOOpt(bo *bandIOOpts) {
bo.lineStride = so.sp
}
func (so pixelStrideOpt) setBandIOOpt(bo *bandIOOpts) {
bo.pixelStride = so.sp
}
func (so bandSpacingOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.bandSpacing = so.sp
}
func (so pixelSpacingOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.pixelSpacing = so.sp
}
func (so lineSpacingOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.lineSpacing = so.sp
}
func (so lineSpacingOpt) setBandIOOpt(bo *bandIOOpts) {
bo.lineSpacing = so.sp
}
func (so pixelSpacingOpt) setBandIOOpt(bo *bandIOOpts) {
bo.pixelSpacing = so.sp
}
// BandSpacing sets the number of bytes from one pixel to the next band of the same pixel. If not
// provided, it will be calculated from the pixel type
//
// Warning: BandSpacing expects a stride given in *bytes*. Use BandStride to supply a stride compatible
// with indexes of the buffer slice
func BandSpacing(stride int) interface {
DatasetIOOption
} {
return bandSpacingOpt{stride}
}
// PixelSpacing sets the number of bytes from one pixel to the next pixel in the same row. If not
// provided, it will be calculated from the number of bands and pixel type
//
// Warning: PixelSpacing expects a stride given in *bytes*. Use PixelStride to supply a stride compatible
// with indexes of the buffer slice
func PixelSpacing(stride int) interface {
DatasetIOOption
BandIOOption
} {
return pixelSpacingOpt{stride}
}
// LineSpacing sets the number of bytes from one pixel to the pixel of the same band one row below. If not
// provided, it will be calculated from the number of bands, pixel type and image width
//
// Warning: LineSpacing expects a stride given in *bytes*. Use LineStride to supply a stride compatible
// with indexes of the buffer slice
func LineSpacing(stride int) interface {
DatasetIOOption
BandIOOption
} {
return lineSpacingOpt{stride}
}
// BandStride sets the offset in the provided buffer from one pixel to the next band of the same pixel. If not
// provided, it will be calculated from the pixel type
func BandStride(stride int) interface {
DatasetIOOption
} {
return bandStrideOpt{stride}
}
// PixelStride sets the offset in the provided buffer from one pixel to the next pixel in the same row. If not
// provided, it will be calculated from the number of bands and pixel type
func PixelStride(stride int) interface {
DatasetIOOption
BandIOOption
} {
return pixelStrideOpt{stride}
}
// LineStride sets the offset in the provided buffer from one pixel to the pixel of the same band one row below. If not
// provided, it will be calculated from the number of bands, pixel type and image width
func LineStride(stride int) interface {
DatasetIOOption
BandIOOption
} {
return lineStrideOpt{stride}
}
type windowOpt struct {
sx, sy int
}
// Window specifies the size of the dataset window to read/write. By default use the
// size of the input/output buffer (i.e. no resampling)
func Window(sx, sy int) interface {
DatasetIOOption
BandIOOption
} {
return windowOpt{sx, sy}
}
func (wo windowOpt) setDatasetIOOpt(ro *datasetIOOpts) {
ro.dsWidth = wo.sx
ro.dsHeight = wo.sy
}
func (wo windowOpt) setBandIOOpt(ro *bandIOOpts) {
ro.dsWidth = wo.sx
ro.dsHeight = wo.sy
}
type bandInterleaveOp struct{}
// BandInterleaved makes Read return a band interleaved buffer instead of a pixel interleaved one.
//
// For example, pixels of a three band RGB image will be returned in order
// r1r2r3...rn, g1g2g3...gn, b1b2b3...bn instead of the default
// r1g1b1, r2g2b2, r3g3b3, ... rnbngn
//
// BandInterleaved should not be used in conjunction with BandSpacing, LineSpacing, PixelSpacing,
// BandStride, LineStride, or PixelStride
func BandInterleaved() interface {
DatasetIOOption
} {
return bandInterleaveOp{}
}
func (bio bandInterleaveOp) setDatasetIOOpt(ro *datasetIOOpts) {
ro.bandInterleave = true
}
type creationOpt struct {
creation []string
}
// CreationOption are options to pass to a driver when creating a dataset, to be
// passed in the form KEY=VALUE
//
// Examples are: BLOCKXSIZE=256, COMPRESS=LZW, NUM_THREADS=8, etc...
func CreationOption(opts ...string) interface {
DatasetCreateOption
DatasetWarpOption
DatasetTranslateOption
DatasetVectorTranslateOption
GMLExportOption
RasterizeOption
} {
return creationOpt{opts}
}
func (co creationOpt) setDatasetCreateOpt(dc *dsCreateOpts) {
dc.creation = append(dc.creation, co.creation...)
}
func (co creationOpt) setDatasetWarpOpt(dc *dsWarpOpts) {
dc.creation = append(dc.creation, co.creation...)
}
func (co creationOpt) setDatasetTranslateOpt(dc *dsTranslateOpts) {
dc.creation = append(dc.creation, co.creation...)
}
func (co creationOpt) setDatasetVectorTranslateOpt(dc *dsVectorTranslateOpts) {
dc.creation = append(dc.creation, co.creation...)
}
func (co creationOpt) setGMLExportOpt(gmlo *gmlExportOpts) {
gmlo.creation = append(gmlo.creation, co.creation...)
}
func (co creationOpt) setRasterizeOpt(o *rasterizeOpts) {
o.create = append(o.create, co.creation...)
}
type configOpt struct {
config []string
}
// ConfigOption sets a configuration option for a gdal library call. See the
// specific gdal function doc page and specific driver docs for allowed values.
//
// Notable options are GDAL_NUM_THREADS=8
func ConfigOption(cfgs ...string) interface {
BuildOverviewsOption
DatasetCreateOption
DatasetWarpOption
DatasetWarpIntoOption
DatasetTranslateOption
DatasetCreateMaskOption
DatasetVectorTranslateOption
BandCreateMaskOption
OpenOption
RasterizeOption
RasterizeIntoOption
DatasetIOOption
BandIOOption
BuildVRTOption
errorAndLoggingOption
} {
return configOpt{cfgs}
}
func (co configOpt) setBuildOverviewsOpt(bo *buildOvrOpts) {
bo.config = append(bo.config, co.config...)
}
func (co configOpt) setDatasetCreateOpt(dc *dsCreateOpts) {
dc.config = append(dc.config, co.config...)
}
func (co configOpt) setDatasetWarpOpt(dc *dsWarpOpts) {
dc.config = append(dc.config, co.config...)
}
func (co configOpt) setDatasetWarpIntoOpt(dc *dsWarpIntoOpts) {
dc.config = append(dc.config, co.config...)
}
func (co configOpt) setDatasetTranslateOpt(dc *dsTranslateOpts) {
dc.config = append(dc.config, co.config...)
}
func (co configOpt) setDatasetVectorTranslateOpt(dc *dsVectorTranslateOpts) {
dc.config = append(dc.config, co.config...)
}
func (co configOpt) setDatasetCreateMaskOpt(dcm *dsCreateMaskOpts) {
dcm.config = append(dcm.config, co.config...)
}
func (co configOpt) setBandCreateMaskOpt(bcm *bandCreateMaskOpts) {
bcm.config = append(bcm.config, co.config...)
}
func (co configOpt) setOpenOpt(oo *openOpts) {
oo.config = append(oo.config, co.config...)
}
func (co configOpt) setRasterizeOpt(oo *rasterizeOpts) {
oo.config = append(oo.config, co.config...)
}
func (co configOpt) setRasterizeIntoOpt(oo *rasterizeIntoOpts) {
oo.config = append(oo.config, co.config...)
}
func (co configOpt) setDatasetIOOpt(oo *datasetIOOpts) {
oo.config = append(oo.config, co.config...)
}
func (co configOpt) setBandIOOpt(oo *bandIOOpts) {
oo.config = append(oo.config, co.config...)
}
func (co configOpt) setBuildVRTOpt(bvo *buildVRTOpts) {
bvo.config = append(bvo.config, co.config...)
}
func (co configOpt) setErrorAndLoggingOpt(elo *errorAndLoggingOpts) {
elo.config = append(elo.config, co.config...)
}
type minSizeOpt struct {
s int
}
// MinSize makes BuildOverviews automatically compute the overview levels
// until the smallest overview size is less than s.
//