gpsSemicircleToUtm (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

2.80 / 1.00.00


This function is used for converting a position from semi-circle format to Universal Transverse Mercator (UTM) format.

 

For the calculation, the WGS-84 ellipsoid is used to model the Earth in the UTM coordinate system.

 

 

Input:

lat : DINT [-954437176 .. 1002159035]

The latitude of the position in semi-circle format.

This value is limited to the range matching 80 deg. south to 84 deg. north as UTM works differently at the poles.

 

lon : DINT [-2147483648 .. 2147483647]

The longitude of the position in semi-circle format.
 

 

Output:

zone : INT
UTM zone number.
>0        The position is on the northern hemisphere.

<0        The position is on the southern hemisphere.

 

east : DINT
UTM easting coordinate in meters east of the central meridian of the zone.

 

north : DINT
UTM northing coordinate in meters north of the Equator on the northern hemisphere. On the southern hemisphere, it is 10,000 km minus the distance to the Equator.

 

 

Return:

0        Success.
-1        Invalid input.

 

 

Declaration:

FUNCTION gpsSemicircleToUtm : INT;
VAR_INPUT
   lat    DINT;
   lon    DINT
   zone   ACCESS INT;
   east   : ACCESS DINT;
   north  ACCESS DINT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
PROGRAM sample;
VAR
   lat,lon     : DINT;
   zone        : INT;
   east,north  : DINT;
END_VAR;
 
BEGIN
  ...   
  DebugMsg(message := "Semi-circle position:");
  DebugFmt(message := "   latitude = \4", v4 := lat);
  DebugFmt(message := "   longitude = \4", v4 := lon);
      
  gpsSemicircleToUtm(
     lat := latlon := lonzone := zone,
     east := eastnorth := north);
      
  DebugMsg(message := "UTM position:");
  DebugFmt(message := "   zone  = \1", v1 := zone);
  DebugFmt(message := "   east  = \4", v4 := east);
  DebugFmt(message := "   north = \4", v4 := north);
  ...
END;
END_PROGRAM;