diff --git a/godal.go b/godal.go index 972a64b..8e5ada8 100644 --- a/godal.go +++ b/godal.go @@ -3987,20 +3987,20 @@ func gdalGCPToGoGCPArray(gcp *C.GDAL_GCP, numGCPs int) []GCP { } // GetGCPSpatialRef runs the GDALGetGCPSpatialRef function -func (ds *Dataset) GetGCPSpatialRef() *SpatialRef { +func (ds *Dataset) GCPSpatialRef() *SpatialRef { return &SpatialRef{handle: C.godalGetGCPSpatialRef(ds.handle()), isOwned: false} } // GetGCPCount runs the GDALGetGCPCount function -func (ds *Dataset) GetGCPCount() int { +func (ds *Dataset) gcpCount() int { return int(C.godalGetGCPCount(ds.handle())) } // GetGCPs runs the GDALGetGCPs function // TODO: This makes 2 cgo calls, we could reduce it to 1 by combining `godalGetGCPs` and `GetGCPCount` -func (ds *Dataset) GetGCPs() []GCP { +func (ds *Dataset) GCPs() []GCP { hndl := C.godalGetGCPs(ds.handle()) - numGCPs := ds.GetGCPCount() + numGCPs := ds.gcpCount() if hndl != nil { return gdalGCPToGoGCPArray(hndl, numGCPs) } @@ -4008,7 +4008,7 @@ func (ds *Dataset) GetGCPs() []GCP { } // GetGCPProjection runs the GDALGetGCPProjection function -func (ds *Dataset) GetGCPProjection() string { +func (ds *Dataset) GCPProjection() string { return C.GoString(C.godalGetGCPProjection(ds.handle())) } diff --git a/godal_test.go b/godal_test.go index 5d8d41a..395b18c 100644 --- a/godal_test.go +++ b/godal_test.go @@ -4571,10 +4571,10 @@ func TestSetGCPsAddTwoGCPs(t *testing.T) { defer vrtDs.Close() // Check `Get` methods before setting GCPs - assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GetGCPSpatialRef()) - assert.Equal(t, 0, vrtDs.GetGCPCount()) - assert.Equal(t, []GCP{}, vrtDs.GetGCPs()) - assert.Equal(t, "", vrtDs.GetGCPProjection()) + assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GCPSpatialRef()) + gcps := vrtDs.GCPs() + assert.Equal(t, 0, len(gcps)) + assert.Equal(t, "", vrtDs.GCPProjection()) var gcpList []GCP = []GCP{ { @@ -4610,10 +4610,11 @@ func TestSetGCPsAddTwoGCPs(t *testing.T) { } // Check `Get` method after settings GCPs - assert.NotEqual(t, nil, vrtDs.GetGCPSpatialRef().handle) - assert.Equal(t, 2, vrtDs.GetGCPCount()) - assert.Equal(t, gcpList, vrtDs.GetGCPs()) - assert.Equal(t, srWkt, vrtDs.GetGCPProjection()) + assert.NotEqual(t, nil, vrtDs.GCPSpatialRef().handle) + gcps = vrtDs.GCPs() + assert.Equal(t, 2, len(gcps)) + assert.Equal(t, gcpList, gcps) + assert.Equal(t, srWkt, vrtDs.GCPProjection()) } func TestSetGCPsAddZeroGCPs(t *testing.T) { @@ -4625,10 +4626,10 @@ func TestSetGCPsAddZeroGCPs(t *testing.T) { defer vrtDs.Close() // Check `Get` methods before setting GCPs - assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GetGCPSpatialRef()) - assert.Equal(t, 0, vrtDs.GetGCPCount()) - assert.Equal(t, []GCP{}, vrtDs.GetGCPs()) - assert.Equal(t, "", vrtDs.GetGCPProjection()) + assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GCPSpatialRef()) + gcps := vrtDs.GCPs() + assert.Equal(t, 0, len(gcps)) + assert.Equal(t, "", vrtDs.GCPProjection()) var gcpList []GCP = []GCP{} sr, err := NewSpatialRefFromEPSG(3857) @@ -4645,10 +4646,10 @@ func TestSetGCPsAddZeroGCPs(t *testing.T) { } // Check `Get` method after settings GCPs - assert.NotEqual(t, nil, vrtDs.GetGCPSpatialRef().handle) - assert.Equal(t, 0, vrtDs.GetGCPCount()) - assert.Equal(t, gcpList, vrtDs.GetGCPs()) - assert.Equal(t, srWkt, vrtDs.GetGCPProjection()) + assert.NotEqual(t, nil, vrtDs.GCPSpatialRef().handle) + gcps = vrtDs.GCPs() + assert.Equal(t, 0, len(gcps)) + assert.Equal(t, srWkt, vrtDs.GCPProjection()) } func TestSetGCPsInvalidDataset(t *testing.T) { @@ -4685,10 +4686,10 @@ func TestSetGCPs2AddTwoGCPs(t *testing.T) { defer vrtDs.Close() // Check `Get` methods before setting GCPs - assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GetGCPSpatialRef()) - assert.Equal(t, 0, vrtDs.GetGCPCount()) - assert.Equal(t, []GCP{}, vrtDs.GetGCPs()) - assert.Equal(t, "", vrtDs.GetGCPProjection()) + assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GCPSpatialRef()) + gcps := vrtDs.GCPs() + assert.Equal(t, 0, len(gcps)) + assert.Equal(t, "", vrtDs.GCPProjection()) var gcpList []GCP = []GCP{ { @@ -4724,10 +4725,11 @@ func TestSetGCPs2AddTwoGCPs(t *testing.T) { } // Check `Get` method after settings GCPs - assert.NotEqual(t, nil, vrtDs.GetGCPSpatialRef().handle) - assert.Equal(t, 2, vrtDs.GetGCPCount()) - assert.Equal(t, gcpList, vrtDs.GetGCPs()) - assert.Equal(t, srWkt, vrtDs.GetGCPProjection()) + assert.NotEqual(t, nil, vrtDs.GCPSpatialRef().handle) + gcps = vrtDs.GCPs() + assert.Equal(t, 2, len(gcps)) + assert.Equal(t, gcpList, gcps) + assert.Equal(t, srWkt, vrtDs.GCPProjection()) } func TestSetGCPs2AddZeroGCPs(t *testing.T) { @@ -4739,10 +4741,10 @@ func TestSetGCPs2AddZeroGCPs(t *testing.T) { defer vrtDs.Close() // Check `Get` methods before setting GCPs - assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GetGCPSpatialRef()) - assert.Equal(t, 0, vrtDs.GetGCPCount()) - assert.Equal(t, []GCP{}, vrtDs.GetGCPs()) - assert.Equal(t, "", vrtDs.GetGCPProjection()) + assert.Equal(t, &SpatialRef{handle: nil, isOwned: false}, vrtDs.GCPSpatialRef()) + gcps := vrtDs.GCPs() + assert.Equal(t, 0, len(gcps)) + assert.Equal(t, "", vrtDs.GCPProjection()) var gcpList []GCP = []GCP{} sr, err := NewSpatialRefFromEPSG(3857) @@ -4759,10 +4761,10 @@ func TestSetGCPs2AddZeroGCPs(t *testing.T) { } // Check `Get` method after settings GCPs - assert.NotEqual(t, nil, vrtDs.GetGCPSpatialRef().handle) - assert.Equal(t, 0, vrtDs.GetGCPCount()) - assert.Equal(t, gcpList, vrtDs.GetGCPs()) - assert.Equal(t, srWkt, vrtDs.GetGCPProjection()) + assert.NotEqual(t, nil, vrtDs.GCPSpatialRef().handle) + gcps = vrtDs.GCPs() + assert.Equal(t, 0, len(gcps)) + assert.Equal(t, srWkt, vrtDs.GCPProjection()) } func TestSetGCPs2InvalidDataset(t *testing.T) {