如何在delphi7中将WGS84转换为lat long

时间:2017-02-02 13:59:17

标签: delphi gps wgs84

我想在Delphi7中将WGS84 coord值转换为lat long,如何制作?

感谢。

我从gps设备(comport)收到了WGS84格式的coord,但需要投影(对于地图)lat long,我收到了这个coord:

  

$ GPGNS,080219.00,4054.34347,N,02916.99092,E,AN,11,0.89,134.1,37.7 ,, * 7B Map Lat:40.9057 Map Long:29.2831

1 个答案:

答案 0 :(得分:1)

描述'GNS'消息,例如here

我们可以从您的留言中提取

  

4054.34347,N,=纬度

     

02916.99092,E,=经度

<强>纬度:

纬度(样本中为40)的两个第一个数字(如果需要填充0)是度数。 其余的(54.34347)是分钟。 'N'是北半球('S'将是南半球)。

将double转换为double将是

function TGpsMsg.LatStrToDouble(Lat: string; NS: char): double;
begin
  result := StrToFloat(LeftStr(Lat, 2));
  result := result + StrToFloat(MidStr(Lat, 3, 8))/60;
  if (NS = 'S') or (NS = 's') then
    result := -result;
end;

您的样本是40.9057245 N

<强>经度:

经度(029)的三个第一个数字(如果需要,用0填充)是度数。 其余的(16.99092)是分钟。 'E'位于0子午线(格林威治)以东('W'将是西)。

function TGpsMsg.LngStrToDouble(Lng: string; EW: char): double;
begin
  result := StrToFloat(LeftStr(Lng, 3));
  result := result + StrToFloat(MidStr(Lng, 4, 8))/60;
  if (EW = 'W') or (EW = 'w') then
    result := -result;
end;

您的样本是29.283182 E