ApsGis.dll

TM.ConvertGeodeticToTransverseMercator(Double, Double, Double, Double, Double, Double, Double, String) Method

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

public static bool ConvertGeodeticToTransverseMercator(
   double semiMajorAxisAInM,
   double inverseFlattening,
   double cmInDeg,
   double latInDeg,
   double lonInDeg,
   out double xInM,
   out double yInM,
   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
cmInDeg
a central meridian (in decimal degrees) to validate
latInDeg
the latitude (in decimal degrees) of the original Geodetic coordinate
lonInDeg
the longitude (in decimal degrees) of the original Geodetic coordinate
xInM
X (in meters) of the TM coordinate, passed by reference (out)
yInM
Y (in meters) of the TM 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 semi major axis A (in meters) is a real number greater than 0. The valid inverse flattening is a real number greater than 0. The valid central meridian (in degrees) is a real number in the range from -180.0 (inclusive) to 180.0 (inclusive). The valid latitude (in degrees) is a real number in the range from -MaxLat (exclusive) to MaxLat (exclusive). The MaxLat is the function of the reference ellipsoid. The valid longitude (in degrees) is a real number in the range from -(cmInDeg - 4.0) (inclusive) to (cmInDeg + 4.0) (inclusive).

Example

This sample shows how to call the TM.ConvertGeodeticToTransverseMercator method from C# code:

 string errorMessage = String.Empty;
 
 double semiMajorAxisA = 6378137;
 double inverseFlattening = 298.257223563;

 double cmInDeg = -70.5;
 double latInDeg = 38.889139;
 double lonInDeg = -77.049;
 
 double xInM = Double.NaN;
 double yInM = Double.NaN;

 if (TM.ConvertGeodeticToTransverseMercator(semiMajorAxisA, inverseFlattening, cmInDeg, latInDeg, lonInDeg, out xInM, out yInM, out errorMessage))
 {
     Console.WriteLine("Conversion succeeded.");
     Console.WriteLine("X, in m: " + xInM.ToString());
     Console.WriteLine("Y, in m: " + yInM.ToString());
 }
 else
 {
     Console.WriteLine("Conversion failed. " + errorMessage);
 }
 

See Also

TM Class | ApsGis Namespace | TM.ConvertGeodeticToTransverseMercator Overload List