I also came across this, and here is a pretty good way to transform coordinates.
Note GDAL Documentation :
, GDALDataset:: GetProjectionRef() , , GDALDataset:: GetGeoTransform().
OGRCoordinateTransformation, .
:
dataset = (GDALDataset *) GDALOpen( mapfile, GA_ReadOnly );
OGRSpatialReference *poSRS_Geog = new OGRSpatialReference();
poSRS_Geog->importFromEPSG( 4326 );
const char *sProj = dataset->GetProjectionRef();
OGRSpatialReference *poSRS_Proj = new OGRSpatialReference( sProj );
OGRCoordinateTransformation *poCT_Geog2Proj;
poCT_Geog2Proj = OGRCreateCoordinateTransformation( poSRS_Geog, poSRS_Proj );
double x = lon;
double y = lat;
poCT_Geog2Proj->Transform( 1, &x, &y );
, / . , Transform() . , - x y. .
, :
// Set up the coordinate transform (projected-to-geographic).
OGRCoordinateTransformation *poCT_Proj2Geog;
poCT_Proj2Geog = OGRCreateCoordinateTransformation( poSRS_Proj, poSRS_Geog );