Conv-Old Fashioned Degrees

From Vectorlab
Jump to: navigation, search

Returns a decimal angle (in degrees) as a string of degrees, minutes, seconds. By Petri Sakkinen

{ This function returns a decimal angle (in degrees) as a string of degrees° minutes' seconds"
© Petri Sakkinen 2009 }

FUNCTION OldFashionedDegrees (decimalAngle : REAL) : STRING;
	degrees, minutes, seconds : REAL;
	degreesS, minutesS, secondsS: STRING;

	degrees := TRUNC(decimalAngle);
	minutes := (decimalAngle-degrees)*60;
	seconds := (minutes-TRUNC(minutes))*60;
	seconds := TRUNC(seconds);
	minutes := TRUNC(minutes);

	degreesS := CONCAT(NUM2STR(0, degrees), '°');
	IF ((minutes>0) | (seconds>0)) THEN minutesS := CONCAT(NUM2STR(0, minutes), '''') ;
	IF (seconds>0) THEN secondsS := CONCAT(NUM2STR(0, seconds), '"');

	OldFashionedDegrees := CONCAT(degreesS, minutesS, secondsS);