//例如:正北、东偏南35.3度。。。
function Direction2Angle(txt: string): Double;
const
az: array [0..3] of string =('正北', '正东', '正南', '正西');
ap: array [0..3] of string =('北偏东', '东偏南', '南偏西', '西偏北');
var
I: Integer;
S: string;
begin
if Pos('正', txt) = 1 then
begin
for I := 0 to 3 do
if Copy(txt, 1, 4) = az[i] then
begin
Result := I * 90;
Exit;
end;
end else if Pos('偏', txt) = 3 then
begin
for I := 0 to 3 do
if Copy(txt, 1, 6) = ap[I] then
begin
s := StringReplace(Copy(txt, 7, MaxInt), '度', '', [rfReplaceAll]);
Result := I * 90 + StrToFloat(s);
Exit;
end;
end;
Result := -1;
end;