function SingleCoordString(value: Double; IsLatitude: Boolean): String;
var sDeg, sMin: String;
begin
DegToDegMinStr(Abs(value), sDeg, sMin);
case IsLatitude of
false: if value < 0 then
Result := 'W ' + Right(sDeg,3,'0') + '° ' + Right(sMin,6,'0')+''''
else Result := 'E ' + Right(sDeg,3,'0') + '° ' + Right(sMin,6,'0')+'''';
true : if value < 0 then
Result := 'S ' + Right(sDeg,2,'0') + '° ' + Right(sMin,6,'0')+''''
else Result := 'N ' + Right(sDeg,2,'0') + '° ' + Right(sMin,6,'0')+'''';
end;
end;
function DegMinStrToDeg(sDeg, sMin: String; Direction: Char): Double;
var Sign: Double;
dDeg: Double;
dMin: Double;
bkDecSep : char;
begin
ReplaceInString(sMin, ',', '.');
bkDecSep := DecimalSeparator;
DecimalSeparator := '.';
if Direction in ['W','S'] then Sign := -1.0 else Sign := 1.0;
try
dDeg := StrToFloat(sDeg);
dMin := StrToFloat(sMin);
result := (dDeg + dMin / 60) * Sign;
except
result := -999;
end;
DecimalSeparator := bkDecSep;
end;
function ReplaceInString(var sSource: String; sSearch, sReplace: String): Integer;
var nRes: Integer;
apos: Integer;
sRest: String;
begin
nRes := 0;
repeat
apos := Pos(sSearch, sSource);
if (apos > 0) then
begin
Inc(nRes);
sRest := Copy(sSource, apos + Length(sSearch),
Length(sSource) - apos - Length(sSearch) + 1);
sSource := Copy(sSource, 1, apos - 1) + sReplace + sRest;
end;
until (apos < 1) or (nRes > 9999);
result := nRes;
end;
FUNCTION Right(Instring : String; max : Byte; Filler : Char) : String;
{ Diese Funktion füllt Instring mit max Fillchar rechtsbündig auf }
VAR Rzeile : String;
i : Integer;
BEGIN {--- OF FUNCTION Right }
RZeile := '';
InString := Trim(InString);
i := (max - Length(Instring));
If i > 0 Then
For i := 1 To (max - Length(Instring)) Do
Rzeile := Rzeile + Filler;
Right := Rzeile + Instring;
END; {--- OF FUNCTION Right }
function CoordStrToFloat(sWert:String):Double;
// Umwandeln eines Koordinatenwertes X DD° MM.MMM' in DD.DDDDD
var HR, sDeg, sMin : String;
begin
HR := Wort(sWert, 1);
sDeg := Wort(sWert, 2);
sMin := Wort(sWert, 3);
ReplaceInString(sDeg, '°','');
ReplaceInString(sMin, '''','');
Result := DegMinStrToDeg(sDeg,sMin, HR[1]);
end;
function DegMinStrToDeg(sDeg, sMin: String; Direction: Char): Double;
var Sign: Double;
dDeg: Double;
dMin: Double;
bkDecSep : char;
begin
ReplaceInString(sMin, ',', '.');
bkDecSep := DecimalSeparator;
DecimalSeparator := '.';
if Direction in ['W','S'] then Sign := -1.0 else Sign := 1.0;
try
dDeg := StrToFloat(sDeg);
dMin := StrToFloat(sMin);
result := (dDeg + dMin / 60) * Sign;
except
result := -999;
end;
DecimalSeparator := bkDecSep;
end;