Skip to content

Commit

Permalink
Add Int8 support (since gdal>=3.7.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvaroquauxads committed Jun 26, 2024
1 parent 787a092 commit d063b83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ func Example_rasterTutorial() {
poDstDS.Bands()[0].Write(0, 0, abyRaster, 512, 512)
poDstDS.Close()

if godal.Int8 != -1 { // Test valid for gdal > 3.7.0
poDstDSInt8, _ := godal.Create(godal.GTiff, pszDstFilename, 1, godal.Int8, 512, 512)
defer poDstDSInt8.Close() //Close can be defered / called more than once (second+ calls are no-ops)

// ... now populate with data
poDstDSInt8.Bands()[0].Write(0, 0, abyRaster, 512, 512)
poDstDSInt8.Close()
}
// Output:
// Size is 10x10x3
// Projection is 'GEOGCS["WGS 84",DATU...'
Expand Down
2 changes: 2 additions & 0 deletions godal.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const (
Byte = DataType(C.GDT_Byte)
//UInt16 DataType
UInt16 = DataType(C.GDT_UInt16)
//Int8 DataType
Int8 = DataType(C.GDT_Int8)
//Int16 DataType
Int16 = DataType(C.GDT_Int16)
//UInt32 DataType
Expand Down
4 changes: 4 additions & 0 deletions godal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

#if GDAL_VERSION_NUM < 3000000
#error "this code is only compatible with gdal version >= 3.0"
#elif GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3, 7, 0)
typedef enum {
/*! 8-bit signed integer (GDAL >= 3.7) */ GDT_Int8 = -1
} FutureGDALDataType;
#endif

#ifdef __cplusplus
Expand Down

0 comments on commit d063b83

Please sign in to comment.