I have the following trivial code, which transforms coordinates from Geographic CS (EPSG 4230, ED50
) to Projected CS (EPSG 23021 ED50 / UTM zone 31N
)
#include <ogr_spatialref.h>
#include <ogr_core.h>
#include <ogr_srs_api.h>
int main(int argc, char *argv[])
{
double coord[3] = {11.0, 60.0, 0.0};
int res;
OGRCoordinateTransformationH transform = NULL;
OGRSpatialReference oSRS, iSRS;
oSRS.importFromEPSG(23031);
iSRS.SetWellKnownGeogCS( "EPSG:4230" );
transform = OCTNewCoordinateTransformation(OGRSpatialReference::ToHandle(&iSRS), OGRSpatialReference::ToHandle(&oSRS));
OCTTransform(transform, 1, coord+0, coord+1, coord+2);
printf("%lf %lf %lf\n", coord[0], coord[1]);
}
Linking this against gday version below 3.x prints the correct result:
945515.849694 6678568.489194
However, if I use any gdal 3.x, I get the following values, which are wrong:
7952467.873008 2186283.396945
I can't see what I'm doing wrong. Is this a bug, or is there a mistake in my code?