gpsUtmToSemicircle (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.80 / 1.00.00


This function is used for converting a position from Universal Transverse Mercator (UTM) format to semi-circle format - this can be used with e.g. the navigation API.

 

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

 

 

Input:

zone : INT [-60 .. 60]

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.

 

Output:

lat : DINT

The latitude of the position in semi-circle format.

 

lon : DINT

The longitude of the position in semi-circle format.

 

 

Return:

0        Success.
-1        Invalid input.

 

Declaration:

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

 

 

Example:

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