func (sr SpatialReference) SemiMinorAxis() (float64, error) {
	var cErr C.OGRErr
	axis := C.OSRGetSemiMinor(sr.cval, &cErr)
	return float64(axis), cErr.Err()
}
Get spheroid semi-minor axis
package gdal
import "C"
import (
	"reflect"
	"unsafe"
)
type SpatialReference struct {
	cval C.OGRSpatialReferenceH
}
func CreateSpatialReference(wkt string) SpatialReference {
	cString := C.CString(wkt)
	defer C.free(unsafe.Pointer(cString))
	sr := C.OSRNewSpatialReference(cString)
	return SpatialReference{sr}
}
func (sr SpatialReference) FromWKT(wkt string) error {
	cString := C.CString(wkt)
	defer C.free(unsafe.Pointer(cString))
	return C.OSRImportFromWkt(sr.cval, &cString).Err()
}
func (sr SpatialReference) ToWKT() (string, error) {
	var p *C.char
	err := C.OSRExportToWkt(sr.cval, &p).Err()
	wkt := C.GoString(p)
	return wkt, err
}
func (sr SpatialReference) ToPrettyWKT(simplify bool) (string, error) {
	var p *C.char
	err := C.OSRExportToPrettyWkt(
		sr.cval, &p, BoolToCInt(simplify),
	).Err()
	wkt := C.GoString(p)
	return wkt, err
}
func (sr SpatialReference) FromEPSG(code int) error {
	return C.OSRImportFromEPSG(sr.cval, C.int(code)).Err()
}
func (sr SpatialReference) FromEPSGA(code int) error {
	return C.OSRImportFromEPSGA(sr.cval, C.int(code)).Err()
}
func (sr SpatialReference) Destroy() {
	C.OSRDestroySpatialReference(sr.cval)
}
func (sr SpatialReference) Clone() SpatialReference {
	newSR := C.OSRClone(sr.cval)
	return SpatialReference{newSR}
}
func (sr SpatialReference) CloneGeogCS() SpatialReference {
	newSR := C.OSRCloneGeogCS(sr.cval)
	return SpatialReference{newSR}
}
func (sr SpatialReference) Reference() int {
	count := C.OSRReference(sr.cval)
	return int(count)
}
func (sr SpatialReference) Dereference() int {
	count := C.OSRDereference(sr.cval)
	return int(count)
}
func (sr SpatialReference) Release() {
	C.OSRRelease(sr.cval)
}
func (sr SpatialReference) Validate() error {
	return C.OSRValidate(sr.cval).Err()
}
func (sr SpatialReference) FromProj4(input string) error {
	cString := C.CString(input)
	defer C.free(unsafe.Pointer(cString))
	return C.OSRImportFromProj4(sr.cval, cString).Err()
}
func (sr SpatialReference) ToProj4() (string, error) {
	var p *C.char
	err := C.OSRExportToProj4(sr.cval, &p).Err()
	proj4 := C.GoString(p)
	return proj4, err
}
func (sr SpatialReference) FromESRI(input string) error {
	cString := C.CString(input)
	defer C.free(unsafe.Pointer(cString))
	return C.OSRImportFromProj4(sr.cval, cString).Err()
}
func (sr SpatialReference) FromPCI(proj, units string, params []float64) error {
	cProj := C.CString(proj)
	defer C.free(unsafe.Pointer(cProj))
	cUnits := C.CString(units)
	defer C.free(unsafe.Pointer(cUnits))
	return C.OSRImportFromPCI(
		sr.cval,
		cProj,
		cUnits,
		(*C.double)(unsafe.Pointer(&params[0])),
	).Err()
}
func (sr SpatialReference) FromUSGS(projsys, zone int, params []float64, datum int) error {
	return C.OSRImportFromUSGS(
		sr.cval,
		C.long(projsys),
		C.long(zone),
		(*C.double)(unsafe.Pointer(&params[0])),
		C.long(datum),
	).Err()
}
func (sr SpatialReference) FromXML(xml string) error {
	cXml := C.CString(xml)
	defer C.free(unsafe.Pointer(cXml))
	return C.OSRImportFromXML(sr.cval, cXml).Err()
}
func (sr SpatialReference) FromERM(proj, datum, units string) error {
	cProj := C.CString(proj)
	defer C.free(unsafe.Pointer(cProj))
	cDatum := C.CString(datum)
	defer C.free(unsafe.Pointer(cDatum))
	cUnits := C.CString(units)
	defer C.free(unsafe.Pointer(cUnits))
	return C.OSRImportFromERM(sr.cval, cProj, cDatum, cUnits).Err()
}
func (sr SpatialReference) FromURL(url string) error {
	cURL := C.CString(url)
	defer C.free(unsafe.Pointer(cURL))
	return C.OSRImportFromXML(sr.cval, cURL).Err()
}
func (sr SpatialReference) ToPCI() (proj, units string, params []float64, errVal error) {
	var p, u *C.char
	err := C.OSRExportToPCI(
		sr.cval, &p, &u, (**C.double)(unsafe.Pointer(&params[0])),
	).Err()
	header := (*reflect.SliceHeader)(unsafe.Pointer(&params))
	header.Cap = 17
	header.Len = 17
	defer C.free(unsafe.Pointer(p))
	defer C.free(unsafe.Pointer(u))
	return C.GoString(p), C.GoString(u), params, err
}
func (sr SpatialReference) ToUSGS() (proj, zone int, params []float64, datum int, errVal error) {
	err := C.OSRExportToUSGS(
		sr.cval,
		(*C.long)(unsafe.Pointer(&proj)),
		(*C.long)(unsafe.Pointer(&zone)),
		(**C.double)(unsafe.Pointer(&params[0])),
		(*C.long)(unsafe.Pointer(&datum)),
	).Err()
	header := (*reflect.SliceHeader)(unsafe.Pointer(&params))
	header.Cap = 15
	header.Len = 15
	return proj, zone, params, datum, err
}
func (sr SpatialReference) ToXML() (xml string, errVal error) {
	var x *C.char
	err := C.OSRExportToXML(sr.cval, &x, nil).Err()
	defer C.free(unsafe.Pointer(x))
	return C.GoString(x), err
}
func (sr SpatialReference) ToMICoordSys() (output string, errVal error) {
	var x *C.char
	err := C.OSRExportToMICoordSys(sr.cval, &x).Err()
	defer C.free(unsafe.Pointer(x))
	return C.GoString(x), err
}
func (sr SpatialReference) MorphToESRI() error {
	return C.OSRMorphToESRI(sr.cval).Err()
}
func (sr SpatialReference) MorphFromESRI() error {
	return C.OSRMorphFromESRI(sr.cval).Err()
}
func (sr SpatialReference) AttrValue(key string, child int) (value string, ok bool) {
	cKey := C.CString(key)
	defer C.free(unsafe.Pointer(cKey))
	val := C.OSRGetAttrValue(sr.cval, cKey, C.int(child))
	return C.GoString(val), val != nil
}
func (sr SpatialReference) SetAttrValue(path, value string) error {
	cPath := C.CString(path)
	defer C.free(unsafe.Pointer(cPath))
	cValue := C.CString(value)
	defer C.free(unsafe.Pointer(cValue))
	return C.OSRSetAttrValue(sr.cval, cPath, cValue).Err()
}
func (sr SpatialReference) SetAngularUnits(units string, radians float64) error {
	cUnits := C.CString(units)
	defer C.free(unsafe.Pointer(cUnits))
	return C.OSRSetAngularUnits(sr.cval, cUnits, C.double(radians)).Err()
}
func (sr SpatialReference) AngularUnits() (string, float64) {
	var x *C.char
	factor := C.OSRGetAngularUnits(sr.cval, &x)
	defer C.free(unsafe.Pointer(x))
	return C.GoString(x), float64(factor)
}
func (sr SpatialReference) SetLinearUnits(name string, toMeters float64) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetLinearUnits(sr.cval, cName, C.double(toMeters)).Err()
}
func (sr SpatialReference) SetTargetLinearUnits(target, units string, toMeters float64) error {
	cTarget := C.CString(target)
	defer C.free(unsafe.Pointer(cTarget))
	cUnits := C.CString(units)
	defer C.free(unsafe.Pointer(cUnits))
	return C.OSRSetTargetLinearUnits(sr.cval, cTarget, cUnits, C.double(toMeters)).Err()
}
func (sr SpatialReference) SetLinearUnitsAndUpdateParameters(name string, toMeters float64) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetLinearUnitsAndUpdateParameters(sr.cval, cName, C.double(toMeters)).Err()
}
func (sr SpatialReference) LinearUnits() (string, float64) {
	var x *C.char
	factor := C.OSRGetLinearUnits(sr.cval, &x)
	defer C.free(unsafe.Pointer(x))
	return C.GoString(x), float64(factor)
}
func (sr SpatialReference) TargetLinearUnits(target string) (string, float64) {
	cTarget := C.CString(target)
	defer C.free(unsafe.Pointer(cTarget))
	var x *C.char
	factor := C.OSRGetTargetLinearUnits(sr.cval, cTarget, &x)
	defer C.free(unsafe.Pointer(x))
	return C.GoString(x), float64(factor)
}
func (sr SpatialReference) PrimeMeridian() (string, float64) {
	var x *C.char
	offset := C.OSRGetPrimeMeridian(sr.cval, &x)
	defer C.free(unsafe.Pointer(x))
	return C.GoString(x), float64(offset)
}
func (sr SpatialReference) IsGeographic() bool {
	val := C.OSRIsGeographic(sr.cval)
	return val != 0
}
func (sr SpatialReference) IsLocal() bool {
	val := C.OSRIsLocal(sr.cval)
	return val != 0
}
func (sr SpatialReference) IsProjected() bool {
	val := C.OSRIsProjected(sr.cval)
	return val != 0
}
func (sr SpatialReference) IsCompound() bool {
	val := C.OSRIsCompound(sr.cval)
	return val != 0
}
func (sr SpatialReference) IsGeocentric() bool {
	val := C.OSRIsGeocentric(sr.cval)
	return val != 0
}
func (sr SpatialReference) IsVertical() bool {
	val := C.OSRIsVertical(sr.cval)
	return val != 0
}
func (sr SpatialReference) IsSameGeographicCS(other SpatialReference) bool {
	val := C.OSRIsSameGeogCS(sr.cval, other.cval)
	return val != 0
}
func (sr SpatialReference) IsSameVerticalCS(other SpatialReference) bool {
	val := C.OSRIsSameVertCS(sr.cval, other.cval)
	return val != 0
}
func (sr SpatialReference) IsSame(other SpatialReference) bool {
	val := C.OSRIsSame(sr.cval, other.cval)
	return val != 0
}
func (sr SpatialReference) SetLocalCS(name string) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetLocalCS(sr.cval, cName).Err()
}
func (sr SpatialReference) SetProjectedCS(name string) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetProjCS(sr.cval, cName).Err()
}
func (sr SpatialReference) SetGeocentricCS(name string) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetGeocCS(sr.cval, cName).Err()
}
func (sr SpatialReference) SetWellKnownGeographicCS(name string) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetWellKnownGeogCS(sr.cval, cName).Err()
}
func (sr SpatialReference) SetFromUserInput(name string) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetFromUserInput(sr.cval, cName).Err()
}
func (sr SpatialReference) CopyGeographicCSFrom(other SpatialReference) error {
	return C.OSRCopyGeogCSFrom(sr.cval, other.cval).Err()
}
func (sr SpatialReference) SetTOWGS84(dx, dy, dz, ex, ey, ez, ppm float64) error {
	return C.OSRSetTOWGS84(
		sr.cval,
		C.double(dx),
		C.double(dy),
		C.double(dz),
		C.double(ex),
		C.double(ey),
		C.double(ez),
		C.double(ppm),
	).Err()
}
func (sr SpatialReference) TOWGS84() (coeff [7]float64, err error) {
	err = C.OSRGetTOWGS84(sr.cval, (*C.double)(unsafe.Pointer(&coeff[0])), 7).Err()
	return
}
func (sr SpatialReference) SetCompoundCS(
	name string,
	horizontal, vertical SpatialReference,
) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	return C.OSRSetCompoundCS(sr.cval, cName, horizontal.cval, vertical.cval).Err()
}
func (sr SpatialReference) SetGeographicCS(
	geogName, datumName, spheroidName string,
	semiMajor, flattening float64,
	pmName string,
	offset float64,
	angularUnits string,
	toRadians float64,
) error {
	cGeogName := C.CString(geogName)
	defer C.free(unsafe.Pointer(cGeogName))
	cDatumName := C.CString(datumName)
	defer C.free(unsafe.Pointer(cDatumName))
	cSpheroidName := C.CString(spheroidName)
	defer C.free(unsafe.Pointer(cSpheroidName))
	cPMName := C.CString(pmName)
	defer C.free(unsafe.Pointer(cPMName))
	cAngularUnits := C.CString(angularUnits)
	defer C.free(unsafe.Pointer(cAngularUnits))
	return C.OSRSetGeogCS(
		sr.cval,
		cGeogName,
		cDatumName,
		cSpheroidName,
		C.double(semiMajor),
		C.double(flattening),
		cPMName,
		C.double(offset),
		cAngularUnits,
		C.double(toRadians),
	).Err()
}
func (sr SpatialReference) SetVerticalCS(csName, datumName string, datumType int) error {
	cCSName := C.CString(csName)
	defer C.free(unsafe.Pointer(cCSName))
	cDatumName := C.CString(datumName)
	defer C.free(unsafe.Pointer(cDatumName))
	return C.OSRSetVertCS(sr.cval, cCSName, cDatumName, C.int(datumType)).Err()
}
func (sr SpatialReference) SemiMajorAxis() (float64, error) {
	var cErr C.OGRErr
	axis := C.OSRGetSemiMajor(sr.cval, &cErr)
	return float64(axis), cErr.Err()
}