简体   繁体   English

从英国坐标转换为标准WGS84 nmea

[英]Convert from British coordinates to standard WGS84 nmea

I was posting similar post already. 我已经发布了类似的帖子。 And I did get an answer in theory but I really need somone to help me. 我确实在理论上得到了答案,但我真的需要somone来帮助我。

So I am using this EXAMPLE for testing my GPS. 所以我使用这个例子来测试我的GPS。 What I want to do is how to get standard decimal values like 56,322415 for latitude and longitude. 我想要做的是如何获得像纬度和经度的标准十进制值,如53,522415。 Because now I am getting 5304,254 value. 因为现在我获得了5304,254的价值。

I need it in this form because I will use this for Google maps. 我需要这种形式,因为我会将其用于谷歌地图。

Can you check code and tell me what should I left out or how to convert it to WGS84 format. 你能检查代码并告诉我应该遗漏什么或如何将其转换为WGS84格式。

Thank you. 谢谢。

EDIT: 编辑:

Here is the picture that is explaining what I see when I run the program 这是解释我在运行程序时看到的内容的图片 在此输入图像描述

And this is the one that is one the codeproject page: 这是codeproject页面中的一个:

在此输入图像描述

EDIT 2: 编辑2:

So when I use THIS CONVERTER to see what decimal values I need to get when I have degrees I don't get the same values. 因此,当我使用THIS CONVERTER来查看我有学位时需要获得的十进制值时,我得不到相同的值。

This is the value that I should get : 这是我应该得到的价值:

在此输入图像描述

And this is the value that I get in the program: 这是我在该计划中获得的价值:

46.64662666666667 46.64662666666667

Any idea why I can't get same conversion? 知道为什么我不能得到相同的转换?

the following line in the ParseNMEA function is the one that does the conversion from WGS84 to the British Ordinance Survey coordinates: ParseNMEA函数中的以下行是从WGS84转换到英国条例调查坐标的行:

return Transform(deciLat, deciLon, height);

so if you remove that line and just use deciLat and deciLon values, you should be fine... 所以,如果你删除那一行并只使用deciLat和deciLon值,你应该没问题......

Addition after question update: 问题更新后添加:

The code you're referring to does not take local number formats into account, so if this goes wrong, it might be because of erroneous decimal symbol matching. 您所指的代码不考虑本地数字格式,因此如果出现这种情况,可能是因为错误的十进制符号匹配。

You can use the following functions to do the conversion, presuming the input is always in the invariant culture (with decimal points): 您可以使用以下函数进行转换,假设输入始终处于不变文化中(带小数点):

string[] arrLon = strLon.Split(new char[]{'°', '"'}, StringSplitOptions.RemoveEmptyEntries);
double dblLon = double.Parse(arrLon[0]) + double.Parse(arrLon[1], new System.Globalization.NumberFormatInfo()) / 60;
double deciLon = arrLon[2] == "E" ? dblLon : - dblLon;

Additional info: 附加信息:

NumberFormatInfo: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx NumberFormatInfo: http//msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx

It sounds like your problems are now solved, I do know that there were issues caused by different local number formatting which were raised and resolved in one of the comments: 听起来你的问题现在已经解决,我知道有些问题是由不同的本地数字格式引起的,这些格式在其中一条评论中提出并解决:

http://www.codeproject.com/Articles/13577/GPS-Deriving-British-Ordnance-Survey-Grid-Referenc?msg=2106791#xx2106791xx http://www.codeproject.com/Articles/13577/GPS-Deriving-British-Ordnance-Survey-Grid-Referenc?msg=2106791#xx2106791xx

If you simply want decimal values for lat and lon, I guess you can throw the entire thing away now and just use the solution provided by Dirk! 如果你只想要lat和lon的十进制值,我想你现在可以抛弃整个东西,只需使用Dirk提供的解决方案! =o) = O)

Alex 亚历克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM