@@ -357,22 +357,21 @@ const (
357
357
DMD_EXTENSION = string (C .GDAL_DMD_EXTENSION )
358
358
DMD_CREATIONOPTIONLIST = string (C .GDAL_DMD_CREATIONOPTIONLIST )
359
359
DMD_CREATIONDATATYPES = string (C .GDAL_DMD_CREATIONDATATYPES )
360
-
361
- DCAP_CREATE = string (C .GDAL_DCAP_CREATE )
362
- DCAP_CREATECOPY = string (C .GDAL_DCAP_CREATECOPY )
363
- DCAP_VIRTUALIO = string (C .GDAL_DCAP_VIRTUALIO )
360
+ DCAP_CREATE = string (C .GDAL_DCAP_CREATE )
361
+ DCAP_CREATECOPY = string (C .GDAL_DCAP_CREATECOPY )
362
+ DCAP_VIRTUALIO = string (C .GDAL_DCAP_VIRTUALIO )
364
363
)
365
364
366
365
// Open an existing dataset
367
- func Open (filename string , access Access ) (Dataset , error ) {
366
+ func Open (filename string , access Access ) (* Dataset , error ) {
368
367
cFilename := C .CString (filename )
369
368
defer C .free (unsafe .Pointer (cFilename ))
370
369
371
370
dataset := C .GDALOpen (cFilename , C .GDALAccess (access ))
372
371
if dataset == nil {
373
- return Dataset { nil } , fmt .Errorf ("Error: dataset '%s' open error" , filename )
372
+ return nil , fmt .Errorf ("Error: dataset '%s' open error" , filename )
374
373
}
375
- return Dataset {dataset }, nil
374
+ return & Dataset {dataset }, nil
376
375
}
377
376
378
377
// Open a shared existing dataset
@@ -385,7 +384,7 @@ func OpenShared(filename string, access Access) Dataset {
385
384
}
386
385
387
386
// TODO(kyle): deprecate Open(), rename OpenEx->Open
388
- func OpenEx (filename string , flags Access , allowedDrivers []string , options []string , siblingFiles []string ) (Dataset , error ) {
387
+ func OpenEx (filename string , flags Access , allowedDrivers []string , options []string , siblingFiles []string ) (* Dataset , error ) {
389
388
cFilename := C .CString (filename )
390
389
defer C .free (unsafe .Pointer (cFilename ))
391
390
@@ -433,9 +432,9 @@ func OpenEx(filename string, flags Access, allowedDrivers []string, options []st
433
432
(* * C .char )(unsafe .Pointer (& cSiblings [0 ])))
434
433
}
435
434
if dataset == nil {
436
- return Dataset { nil } , fmt .Errorf ("Error: dataset '%s' open error" , filename )
435
+ return nil , fmt .Errorf ("Error: dataset '%s' open error" , filename )
437
436
}
438
- return Dataset {dataset }, nil
437
+ return & Dataset {dataset }, nil
439
438
}
440
439
441
440
// Unimplemented: DumpOpenDatasets
@@ -492,7 +491,7 @@ func (object MajorObject) SetMetadataItem(name, value, domain string) {
492
491
return
493
492
}
494
493
495
- func (dataset Dataset ) Metadata (domain string ) []string {
494
+ func (dataset * Dataset ) Metadata (domain string ) []string {
496
495
c_domain := C .CString (domain )
497
496
defer C .free (unsafe .Pointer (c_domain ))
498
497
@@ -567,12 +566,12 @@ func (object *Driver) MetadataItem(name, domain string) string {
567
566
/* ==================================================================== */
568
567
569
568
// Get the driver to which this dataset relates
570
- func (dataset Dataset ) Driver () * Driver {
569
+ func (dataset * Dataset ) Driver () * Driver {
571
570
return & Driver {C .GDALGetDatasetDriver (dataset .cval )}
572
571
}
573
572
574
573
// Fetch files forming the dataset.
575
- func (dataset Dataset ) FileList () []string {
574
+ func (dataset * Dataset ) FileList () []string {
576
575
p := C .GDALGetFileList (dataset .cval )
577
576
var strings []string
578
577
q := uintptr (unsafe .Pointer (p ))
@@ -588,27 +587,24 @@ func (dataset Dataset) FileList() []string {
588
587
}
589
588
590
589
// Close the dataset
591
- func (dataset Dataset ) Close () {
590
+ func (dataset * Dataset ) Close () {
592
591
C .GDALClose (dataset .cval )
593
592
return
594
593
}
595
594
596
595
// Fetch X size of raster
597
- func (dataset Dataset ) RasterXSize () int {
598
- xSize := int (C .GDALGetRasterXSize (dataset .cval ))
599
- return xSize
596
+ func (dataset * Dataset ) RasterXSize () int {
597
+ return int (C .GDALGetRasterXSize (dataset .cval ))
600
598
}
601
599
602
600
// Fetch Y size of raster
603
- func (dataset Dataset ) RasterYSize () int {
604
- ySize := int (C .GDALGetRasterYSize (dataset .cval ))
605
- return ySize
601
+ func (dataset * Dataset ) RasterYSize () int {
602
+ return int (C .GDALGetRasterYSize (dataset .cval ))
606
603
}
607
604
608
605
// Fetch the number of raster bands in the dataset
609
- func (dataset Dataset ) RasterCount () int {
610
- count := int (C .GDALGetRasterCount (dataset .cval ))
611
- return count
606
+ func (dataset * Dataset ) RasterCount () int {
607
+ return int (C .GDALGetRasterCount (dataset .cval ))
612
608
}
613
609
614
610
// ErrInvalidBand represents an invalid band number when requested. It is set
@@ -620,7 +616,7 @@ var ErrIllegalBand = errors.New("illegal band #")
620
616
// 0 > band >= Dataset.RasterCount()
621
617
//
622
618
// If the band is invalid, nil and ErrInvalidBand is returned
623
- func (dataset Dataset ) RasterBand (band int ) (* RasterBand , error ) {
619
+ func (dataset * Dataset ) RasterBand (band int ) (* RasterBand , error ) {
624
620
p := C .GDALGetRasterBand (dataset .cval , C .int (band ))
625
621
if p == nil {
626
622
return nil , ErrIllegalBand
@@ -629,7 +625,7 @@ func (dataset Dataset) RasterBand(band int) (*RasterBand, error) {
629
625
}
630
626
631
627
// Add a band to a dataset
632
- func (dataset Dataset ) AddBand (dataType DataType , options []string ) error {
628
+ func (dataset * Dataset ) AddBand (dataType DataType , options []string ) error {
633
629
length := len (options )
634
630
cOptions := make ([]* C.char , length + 1 )
635
631
for i := 0 ; i < length ; i ++ {
@@ -655,28 +651,23 @@ const (
655
651
GRA_Lanczos = ResampleAlg (4 )
656
652
)
657
653
658
- func (dataset Dataset ) AutoCreateWarpedVRT (srcWKT , dstWKT string , resampleAlg ResampleAlg ) (Dataset , error ) {
654
+ func (dataset * Dataset ) AutoCreateWarpedVRT (srcWKT , dstWKT string , resampleAlg ResampleAlg ) (* Dataset , error ) {
659
655
c_srcWKT := C .CString (srcWKT )
660
656
defer C .free (unsafe .Pointer (c_srcWKT ))
661
657
c_dstWKT := C .CString (dstWKT )
662
658
defer C .free (unsafe .Pointer (c_dstWKT ))
663
- /*
664
-
665
- */
666
659
h := C .GDALAutoCreateWarpedVRT (dataset .cval , c_srcWKT , c_dstWKT , C .GDALResampleAlg (resampleAlg ), 0.0 , nil )
667
- d := Dataset {h }
668
660
if h == nil {
669
- return d , fmt .Errorf ("AutoCreateWarpedVRT failed" )
661
+ return nil , fmt .Errorf ("AutoCreateWarpedVRT failed" )
670
662
}
671
- return d , nil
672
-
663
+ return & Dataset {h }, nil
673
664
}
674
665
675
666
// Unimplemented: GDALBeginAsyncReader
676
667
// Unimplemented: GDALEndAsyncReader
677
668
678
669
// Read / write a region of image data from multiple bands
679
- func (dataset Dataset ) IO (
670
+ func (dataset * Dataset ) IO (
680
671
rwFlag RWFlag ,
681
672
xOff , yOff , xSize , ySize int ,
682
673
buffer interface {},
@@ -730,7 +721,7 @@ func (dataset Dataset) IO(
730
721
}
731
722
732
723
// Advise driver of upcoming read requests
733
- func (dataset Dataset ) AdviseRead (
724
+ func (dataset * Dataset ) AdviseRead (
734
725
rwFlag RWFlag ,
735
726
xOff , yOff , xSize , ySize , bufXSize , bufYSize int ,
736
727
dataType DataType ,
@@ -758,36 +749,35 @@ func (dataset Dataset) AdviseRead(
758
749
}
759
750
760
751
// Fetch the projection definition string for this dataset
761
- func (dataset Dataset ) ProjectionRef () string {
762
- proj := C .GoString (C .GDALGetProjectionRef (dataset .cval ))
763
- return proj
752
+ func (dataset * Dataset ) ProjectionRef () string {
753
+ return C .GoString (C .GDALGetProjectionRef (dataset .cval ))
764
754
}
765
755
766
756
// Set the projection reference string
767
- func (dataset Dataset ) SetProjection (proj string ) error {
757
+ func (dataset * Dataset ) SetProjection (proj string ) error {
768
758
cProj := C .CString (proj )
769
759
defer C .free (unsafe .Pointer (cProj ))
770
760
771
761
return C .GDALSetProjection (dataset .cval , cProj ).Err ()
772
762
}
773
763
774
764
// Get the affine transformation coefficients
775
- func (dataset Dataset ) GeoTransform () [6 ]float64 {
765
+ func (dataset * Dataset ) GeoTransform () [6 ]float64 {
776
766
var transform [6 ]float64
777
767
C .GDALGetGeoTransform (dataset .cval , (* C .double )(unsafe .Pointer (& transform [0 ])))
778
768
return transform
779
769
}
780
770
781
771
// Set the affine transformation coefficients
782
- func (dataset Dataset ) SetGeoTransform (transform [6 ]float64 ) error {
772
+ func (dataset * Dataset ) SetGeoTransform (transform [6 ]float64 ) error {
783
773
return C .GDALSetGeoTransform (
784
774
dataset .cval ,
785
775
(* C .double )(unsafe .Pointer (& transform [0 ])),
786
776
).Err ()
787
777
}
788
778
789
779
// Return the inverted transform
790
- func (dataset Dataset ) InvGeoTransform () [6 ]float64 {
780
+ func (dataset * Dataset ) InvGeoTransform () [6 ]float64 {
791
781
return InvGeoTransform (dataset .GeoTransform ())
792
782
}
793
783
@@ -799,17 +789,16 @@ func InvGeoTransform(transform [6]float64) [6]float64 {
799
789
}
800
790
801
791
// Get number of GCPs
802
- func (dataset Dataset ) GDALGetGCPCount () int {
803
- count := C .GDALGetGCPCount (dataset .cval )
804
- return int (count )
792
+ func (dataset * Dataset ) GDALGetGCPCount () int {
793
+ return int (C .GDALGetGCPCount (dataset .cval ))
805
794
}
806
795
807
796
// Unimplemented: GDALGetGCPProjection
808
797
// Unimplemented: GDALGetGCPs
809
798
// Unimplemented: GDALSetGCPs
810
799
811
800
// Fetch a format specific internally meaningful handle
812
- func (dataset Dataset ) GDALGetInternalHandle (request string ) unsafe.Pointer {
801
+ func (dataset * Dataset ) GDALGetInternalHandle (request string ) unsafe.Pointer {
813
802
cRequest := C .CString (request )
814
803
defer C .free (unsafe .Pointer (cRequest ))
815
804
@@ -818,19 +807,19 @@ func (dataset Dataset) GDALGetInternalHandle(request string) unsafe.Pointer {
818
807
}
819
808
820
809
// Add one to dataset reference count
821
- func (dataset Dataset ) GDALReferenceDataset () int {
810
+ func (dataset * Dataset ) GDALReferenceDataset () int {
822
811
count := C .GDALReferenceDataset (dataset .cval )
823
812
return int (count )
824
813
}
825
814
826
815
// Subtract one from dataset reference count
827
- func (dataset Dataset ) GDALDereferenceDataset () int {
816
+ func (dataset * Dataset ) GDALDereferenceDataset () int {
828
817
count := C .GDALDereferenceDataset (dataset .cval )
829
818
return int (count )
830
819
}
831
820
832
821
// Build raster overview(s)
833
- func (dataset Dataset ) BuildOverviews (
822
+ func (dataset * Dataset ) BuildOverviews (
834
823
resampling string ,
835
824
nOverviews int ,
836
825
overviewList []int ,
@@ -859,19 +848,19 @@ func (dataset Dataset) BuildOverviews(
859
848
// Unimplemented: GDALGetOpenDatasets
860
849
861
850
// Return access flag
862
- func (dataset Dataset ) Access () Access {
851
+ func (dataset * Dataset ) Access () Access {
863
852
accessVal := C .GDALGetAccess (dataset .cval )
864
853
return Access (accessVal )
865
854
}
866
855
867
856
// Write all write cached data to disk
868
- func (dataset Dataset ) FlushCache () {
857
+ func (dataset * Dataset ) FlushCache () {
869
858
C .GDALFlushCache (dataset .cval )
870
859
return
871
860
}
872
861
873
862
// Adds a mask band to the dataset
874
- func (dataset Dataset ) CreateMaskBand (flags int ) error {
863
+ func (dataset * Dataset ) CreateMaskBand (flags int ) error {
875
864
return C .GDALCreateDatasetMaskBand (dataset .cval , C .int (flags )).Err ()
876
865
}
877
866
0 commit comments