This function is used for converting a position from Universal Transverse Mercator (UTM) format to RTCU format.
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 [-2147483648 .. 2147483647]
UTM easting coordinate in meters east of the central meridian of the zone.
north : DINT [-2147483648 .. 2147483647]
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
Negative is south (ddmm.mmmm (multiplied by 10000)).
lon : DINT
Negative is west (dddmm.mmmm (multiplied by 10000)).
Return:
0 Success.
-1 Invalid input.
Declaration:
FUNCTION gpsUtmToPosition : 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);
gpsUtmToPosition(
zone := zone, east := east, north := north,
lat := lat, lon := lon);
DebugMsg(message := "GPS position:");
DebugFmt(message := " latitude = \4", v4 := lat);
DebugFmt(message := " longitude = \4", v4 := lon);
...
END;
END_PROGRAM;
|