Exemplo n.º 1
0
Arquivo: gdal.go Projeto: kikht/gdal
func (dataset Dataset) AutoCreateWarpedVRT(srcWKT, dstWKT string, resampleAlg ResampleAlg) (Dataset, error) {
	c_srcWKT := C.CString(srcWKT)
	defer C.free(unsafe.Pointer(c_srcWKT))
	c_dstWKT := C.CString(dstWKT)
	defer C.free(unsafe.Pointer(c_dstWKT))
	/*

	 */
	h := C.GDALAutoCreateWarpedVRT(dataset.cval, c_srcWKT, c_dstWKT, C.GDALResampleAlg(resampleAlg), 0.0, nil)
	d := Dataset{h}
	if h == nil {
		return d, fmt.Errorf("AutoCreateWarpedVRT failed")
	}
	return d, nil

}
Exemplo n.º 2
0
// Reproject image
func (src Dataset) ReprojectImage(
	srcProjWKT string,
	dst Dataset,
	dstProjWKT string,
	resampleAlg ResampleAlg,
	memLimit, maxError float64,
	progress ProgressFunc,
	data interface{},
	options WarpOptions,
) error {
	var pf C.GDALProgressFunc
	var pa unsafe.Pointer
	if progress != nil {
		pf = C.goGDALProgressFuncProxyB()
		pa = unsafe.Pointer(&goGDALProgressFuncProxyArgs{progress, data})
	}

	var c_srcWKT, c_dstWKT *C.char
	if srcProjWKT != "" {
		c_srcWKT = C.CString(srcProjWKT)
		defer C.free(unsafe.Pointer(c_srcWKT))
	}
	if dstProjWKT != "" {
		c_dstWKT = C.CString(dstProjWKT)
		defer C.free(unsafe.Pointer(c_dstWKT))
	}

	err := C.GDALReprojectImage(
		src.cval,
		c_srcWKT,
		dst.cval,
		c_dstWKT,
		C.GDALResampleAlg(resampleAlg),
		C.double(memLimit),
		C.double(maxError),
		pf,
		pa,
		options,
	)
	if err != 0 {
		return error(err)
	}
	return nil
}