Hi there,
I'm trying to put building from real lat-long in my Monogame app (4 buildings in my school, please check the image with the blue circles)
But after some convert method, it went terribly wrong (please check image)
Please help me find out what's wrong.
My code:
public List<float> Gps2Cartesian(float latitude_degree, float longitude_degree, float elevation)
{
cartesResult = new List<float>();
var longtitude_rad = DegreeToRadian(longitude_degree);
var latitude_rad = DegreeToRadian(latitude_degree);
var n = a / Math.Sqrt(1 - e2 * Math.Sin(latitude_rad) * Math.Sin(latitude_rad));
var cartes_X = (n + elevation) * Math.Cos(latitude_rad) * Math.Cos(longtitude_rad); //ECEF x (z in right - handed system) (m)
var cartes_Y = (n + elevation) * Math.Cos(latitude_rad) * Math.Sin(longtitude_rad); //ECEF y (x in right - handed system) (m)
var cartes_Z = (n * (1 - e2) + elevation) * Math.Sin(latitude_rad); //ECEF z (y in right-handed system) (m)
cartesResult.Add((float)cartes_Y);
cartesResult.Add((float)cartes_Z);
cartesResult.Add((float)cartes_X);
return cartesResult;
}
And this is debug result:
QuoteD3 X:5730549 Y:2271896 Z:-162645005
C2 X:5730621 Y:2272063 Z:-162594705
C9 X:5730595 Y:2272005 Z:-1626123
C1 X:5730521 Y:2272123 Z:-1626228
Thank you !