ApsGis.dll

Cartesian.ConvertCartesianToGeodetic(Double, Double, Double, Double, Double, Double, Double, Double, String) Method

Converts a Cartesian coordinate to a Geodetic coordinate on the user defined reference ellipsoid.

public static bool ConvertCartesianToGeodetic(
   double semiMajorAxisAInM,
   double inverseFlattening,
   double xInM,
   double yInM,
   double zInM,
   out double latInDeg,
   out double lonInDeg,
   out double hInM,
   out string errorMessage
);

Parameters

semiMajorAxisAInM
a semi major axis A (in meters) of the user defined reference ellipsoid
inverseFlattening
an inverse flattening of the user defined reference ellipsoid
xInM
X (in meters) of the original Cartesian coordinate
yInM
Y (in meters) of the original Cartesian coordinate
zInM
Z (in meters) of the original Cartesian coordinate
latInDeg
the latitude (in decimal degrees) of the final Geodetic coordinate, passed by reference (out)
lonInDeg
the longitude (in decimal degrees) of the final Geodetic coordinate, passed by reference (out)
hInM
the height (in meters) of the final Geodetic coordinate, passed by reference (out)
errorMessage
an error message, passed by reference (out), that contains detailed error / warning information

Return Value

true - if the conversion succeeded, false - if the conversion failed

Remarks

The function verifies validity of the input arguments before running the conversion. The valid Cartesian X, Y, Z are real numbers. X, Y and Z cannot be equal to zero at the same time. X and Y cannot be equal to zero at the same time.

Example

This sample shows how to call the Cartesian.ConvertCartesianToGeodetic method from C# code:

 string errorMessage = String.Empty;
 
 double semiMajorAxisA = 6378137;
 double inverseFlattening = 298.257223563;
 
 double xInM = 1114120.60285998;
 double yInM = -4844685.62652945;
 double zInM = 3982807.8497531;

 double latInDeg = Double.NaN;
 double lonInDeg = Double.NaN;
 double hInM = Double.NaN;
 
 if (Cartesian.ConvertCartesianToGeodetic(semiMajorAxisAInM, inverseFlattening, xInM, yInM, zInM, out latInDeg, out lonInDeg, out hInM, out errorMessage))
 {
     Console.WriteLine("Conversion succeeded.");
     Console.WriteLine("LatInDeg: " + latInDeg.ToString());
     Console.WriteLine("LonInDeg: " + lonInDeg.ToString());
     Console.WriteLine("HeightInM: " + hInM.ToString());
 }
 else
 {
     Console.WriteLine("Conversion failed. " + errorMessage);
 }
 

See Also

Cartesian Class | ApsGis Namespace | Cartesian.ConvertCartesianToGeodetic Overload List