You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the GDALDataset API, SetGCPs should return CE_None on success and CE_Failure on error, for example if the driver does not support GCP writing.
However when using SetGCPs on a HFA dataset (with a non empty GCP list), the method returns CE_None, but it seems that no GCP is added to the dataset, GetGCPCount returns 0.
GDALPAMDataset is the base class of HFADataset and HFADataset uses its implementation of SetGCPs. When calling the method, the GCP are added to the .aux.xml file. But HFADataset implements its own version of GetGCPs, which doesn't return the GCPs of the .aux.xml file.
I don't know if the HFA driver should support GCP writing, but I think the SetGCPs method should return the correct error code if it does not.
Steps to reproduce the problem.
In command line, using an input image with GCPs
gdal_translate -of HFA /inputWithGCP.tif out.img
will create a out.img.aux.xml file containing gcps, but gdalinfo will not report the GCPs
In c++
#include"gdal_priv.h"
#include<iostream>intmain(int argc, char* argv[])
{
auto inFilename = argv[1];
auto outFilename = argv[2];
auto format = argv[3];
GDALDataset *poDataset;
GDALAllRegister();
GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(format);
GDALDataset *poSrcDS = (GDALDataset *) GDALOpen( inFilename, GA_ReadOnly );
GDALDataset *poDstDS;
poDstDS = poDriver->CreateCopy( outFilename, poSrcDS, FALSE,
NULL, NULL, NULL );
// CreateCopy also set the GCPs (I suppose?), this call is just here to highlight the problemauto success = poDstDS->SetGCPs(poSrcDS->GetGCPCount(), poSrcDS->GetGCPs(), poSrcDS->GetGCPProjection());
// SetGCPs returns CE_None on success, and should report CE_Failure if the driver does not support gcp writing
std::cout << "success: " << (success == CE_None) << std::endl; // success: 1
std::cout << "Number of input gcps: " << poSrcDS->GetGCPCount() << std::endl; // Number of input gcps: 4
std::cout << "Number of output gcps: " << poDstDS->GetGCPCount() << std::endl; // Number of output gcps: 0if( poDstDS != NULL )
GDALClose( (GDALDatasetH) poDstDS );
GDALClose( (GDALDatasetH) poSrcDS );
return0;
}
Operating system
Ubuntu 20.04 64 bit
GDAL version and provenance
GDAL 3.0.4 installed with apt, also reproduced on a compiled 3.2.2 GDAL
The text was updated successfully, but these errors were encountered:
Expected behavior and actual behavior.
In the GDALDataset API,
SetGCPs
should returnCE_None
on success andCE_Failure
on error, for example if the driver does not support GCP writing.However when using
SetGCPs
on a HFA dataset (with a non empty GCP list), the method returnsCE_None
, but it seems that no GCP is added to the dataset,GetGCPCount
returns 0.GDALPAMDataset
is the base class ofHFADataset
andHFADataset
uses its implementation of SetGCPs. When calling the method, the GCP are added to the .aux.xml file. ButHFADataset
implements its own version ofGetGCPs
, which doesn't return the GCPs of the .aux.xml file.I don't know if the HFA driver should support GCP writing, but I think the
SetGCPs
method should return the correct error code if it does not.Steps to reproduce the problem.
In command line, using an input image with GCPs
will create a out.img.aux.xml file containing gcps, but gdalinfo will not report the GCPs
In c++
Operating system
Ubuntu 20.04 64 bit
GDAL version and provenance
GDAL 3.0.4 installed with apt, also reproduced on a compiled 3.2.2 GDAL
The text was updated successfully, but these errors were encountered: