ApsGis.dll

Cartesian.ConvertGeodeticToCartesian(GeoEllipsoid, Double, Double, Double, Double, Double, Double, String) Method

Converts a Geodetic coordinate to a Cartesian coordinate on a reference ellipsoid.

public static bool ConvertGeodeticToCartesian(
   GeoEllipsoid ge,
   double latInDeg,
   double lonInDeg,
   double hInM,
   out double xInM,
   out double yInM,
   out double zInM,
   out string errorMessage
);

Parameters

ge
a predefined reference ellipsoid (GeoEllipsoid)
latInDeg
the latitude (in decimal degrees) of the original Geodetic coordinate
lonInDeg
the longitude (in decimal degrees) of the original Geodetic coordinate
hInM
the height (in meters) of the original Geodetic coordinate
xInM
X (in meters) of the final Cartesian coordinate, passed by reference (out)
yInM
Y (in meters) of the final Cartesian coordinate, passed by reference (out)
zInM
Z (in meters) of the final Cartesian 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 latitude is a real number in the range from -90.0 (inclusive) to 90.0 (inclusive). The valid longitude is a real number in the range from -180.0 (inclusive) to 180.0 (inclusive).

Example

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

 string errorMessage = String.Empty;
 
 GeoEllipsoid ge = GeoEllipsoid.WE;

 double latInDeg = 38.889139;
 double lonInDeg = -77.049;
 double hInM = 100;
 
 double xInM = Double.NaN;
 double yInM = Double.NaN;
 double zInM = Double.NaN;

 if (Cartesian.ConvertGeodeticToCartesian(ge, latInDeg, lonInDeg, hInM, out xInM, out yInM, out zInM, out errorMessage))
 {
     Console.WriteLine("Conversion succeeded.");
     Console.WriteLine("X, in m: " + xInM.ToString());
     Console.WriteLine("Y, in m: " + yInM.ToString());
     Console.WriteLine("Z, in m: " + zInM.ToString());
 }
 else
 {
     Console.WriteLine("Conversion failed. " + errorMessage);
 }
 

See Also

Cartesian Class | ApsGis Namespace | Cartesian.ConvertGeodeticToCartesian Overload List