Coordinate Conversion Error

classic Classic list List threaded Threaded
3 messages Options
SkyOSG SkyOSG
Reply | Threaded
Open this post in threaded view
|

Coordinate Conversion Error

hi,I'm using osgEarth2.10 and gdal3.0,I want to Convert WGS84 and CGSC2000 to Spherical-mercator,Code:
void Test1()
{
        osgEarth::SpatialReference* pMercator = osgEarth::SpatialReference::create("epsg:900913");
        osgEarth::SpatialReference* pWGS = osgEarth::SpatialReference::create("epsg:4326");
        osgEarth::SpatialReference* pCGCS = osgEarth::SpatialReference::create("epsg:4490");

        {
                void* _handl1 = pWGS->getHandle();
                void* _handl2 = pMercator->getHandle();

                double* x1 = new double[1];
                x1[0] = 119.0;
                double* y1 = new double[1];
                y1[0] = 39.9;

                void* xform_handle = OCTNewCoordinateTransformation(_handl1, _handl2);
                OCTTransform(xform_handle, 1, x1, y1, 0L);

                std::cout << std::setprecision(15) << x1[0] << std::endl;
                std::cout << std::setprecision(15) << y1[0] << std::endl;
        }

        {
                void* _handl1 = pCGCS->getHandle();
                void* _handl2 = pMercator->getHandle();

                double* x1 = new double[1];
                x1[0] = 119.0;
                double* y1 = new double[1];
                y1[0] = 39.9;

                void* xform_handle = OCTNewCoordinateTransformation(_handl1, _handl2);
                OCTTransform(xform_handle, 1, x1, y1, 0L);

                std::cout << std::setprecision(15) << x1[0] << std::endl;
                std::cout << std::setprecision(15) << y1[0] << std::endl;
        }
}

Output:
wgs84:13247019.4043996,4823995.02914481
cgcs2000:13247019.4043996,4851421.17518336

The result of WGS84 is not right?Why?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Coordinate Conversion Error

Hi,
osgEarth doesn't support GDAL 3.0 yet. It uses the PROJ6 library which yields different results than the previous version. Your test should yield the correct results under GDAL 2.4.x.
Glenn Waldron / Pelican Mapping
SkyOSG SkyOSG
Reply | Threaded
Open this post in threaded view
|

Re: Coordinate Conversion Error

Thank you! I'm using gdal2.4 is OK。