Skip to content

Commit

Permalink
add Metadata and MetadataItem for Dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Tilak committed Jul 30, 2018
1 parent f2241ca commit e5898fc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
26 changes: 0 additions & 26 deletions apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,6 @@ func GDALTranslate(

}

// func GDALWarpCreateOutput(
// nSrcCount int,
// srcDS []Dataset,
// pszFilename string,
// pszFormat string,
// papszTO []string,
// ppapszCreateOptions *[]string,
// eDT DataType,
// phTransformArg unsafe.Pointer,
// bSetColorInterpretation bool,
// psOptions GDALWarpAppOptions,

// ) GDALWarpAppOptions {

// pahSrcDs := make([]C.GDALDatasetH, len(srcDs)+1)
// for i := 0; i < len(srcDs); i++ {
// pahSrcDs[i] = srcDs[i].cval
// }
// pahSrcDs[len(srcDs)] = (C.GDALDatasetH)(unsafe.Pointer(nil))

// hDstDS := C.GDALWarpCreateOutput(
// C.int(nSrcCount),
// )
// }

func GDALWarp(
destName string,
dstDs Dataset,
Expand All @@ -105,7 +80,6 @@ func GDALWarp(
pahSrcDs := make([]C.GDALDatasetH, len(srcDs)+1)
for i := 0; i < len(srcDs); i++ {
pahSrcDs[i] = srcDs[i].cval
// defer C.free(unsafe.Pointer(pahSrcDs[i]))
}
pahSrcDs[len(srcDs)] = (C.GDALDatasetH)(unsafe.Pointer(nil))

Expand Down
35 changes: 35 additions & 0 deletions gdal.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,27 @@ func (object MajorObject) Metadata(domain string) []string {
panic("not implemented!")
return nil
}
func (dataset *Dataset) Metadata(domain string) []string {
cDomain := C.CString(domain)
defer C.free(unsafe.Pointer(cDomain))

p := C.GDALGetMetadata(
C.GDALMajorObjectH(unsafe.Pointer(dataset.cval)),
cDomain,
)
var strings []string
q := uintptr(unsafe.Pointer(p))
for {
p = (**C.char)(unsafe.Pointer(q))
if *p == nil {
break
}
strings = append(strings, C.GoString(*p))
q += unsafe.Sizeof(q)
}

return strings
}

// Set metadata
func (object MajorObject) SetMetadata(metadata []string, domain string) {
Expand Down Expand Up @@ -653,6 +674,20 @@ func (object *Driver) MetadataItem(name, domain string) string {
),
)
}
func (object *Dataset) MetadataItem(name, domain string) string {
c_name := C.CString(name)
defer C.free(unsafe.Pointer(c_name))

c_domain := C.CString(domain)
defer C.free(unsafe.Pointer(c_domain))

return C.GoString(
C.GDALGetMetadataItem(
C.GDALMajorObjectH(unsafe.Pointer(object.cval)),
c_name, c_domain,
),
)
}

/* ==================================================================== */
/* GDALDataset class ... normally this represents one file. */
Expand Down

0 comments on commit e5898fc

Please sign in to comment.