1

I simply try to convert a point from local Cartesian ENU centered on a point with lat,lon coordinates to geocentric ECEF coordinates. With proj from command line all works well. I use strings from proj to create QGIS CRS. But using QGIS I receive:

Error transforming "forward transform of\n (inf,inf)\n Error: Fallback transformation failed"

So I'm wondering, does QGIS 3.22 support conversion from a local Cartesian to ECEF?

void geoutils::TopoToECEF(const QgsPointXY &origin, const QgsPointXY &point, QgsPointXY &point_wgs)
{

    try {

        QgsCoordinateReferenceSystem geocentricCRS;

        QString projStringGeocentric = "+proj=cart +ellps=GRS80";  //ECEF CRS
        bool res= geocentricCRS.createFromProj(projStringGeocentric);
        qDebug() << "result 1 is " << res << geocentricCRS.toProj();  // this return true !!!

        QgsCoordinateReferenceSystem topocentricCRS;

        QString projStringTopocentric = "+proj=topocentric +ellps=WGS84";
        projStringTopocentric += " +lon_0=9"; // origin lon
        projStringTopocentric += " +lat_0=44"; // origin lat
        projStringTopocentric += " +h_0=0 +units=m"; //

        res = topocentricCRS.createFromProj(projStringTopocentric);

        qDebug() << "result 2 is " << res << topocentricCRS.toProj(); //this return true !!!

        QgsProject::instance()->setCrs(geocentricCRS);

        QgsCoordinateTransform *xformerFromToTopocentricToWgs84 = new QgsCoordinateTransform(topocentricCRS, geocentricCRS, QgsProject::instance());  // src, dest, proj

        qDebug() << "TopoToECEF Input point x: " << point.x() << " y: "<< point.y();
        point_wgs = xformerFromToTopocentricToWgs84->transform(point);   // this BOOOMMMSS !!

        qDebug() << "TopoToECEF -  Output x: " << point_wgs.x() << "  y: "<< point_wgs.y();

    }  catch (const QgsException& e) {
        qDebug() << "error transforming " << e.what();

    }
 }

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.