【问题标题】:GPS giving wrong location on the Google MapGPS在谷歌地图上给出错误的位置
【发布时间】:2012-05-06 06:14:02
【问题描述】:

当我将 Sim548cGoogle map API 连接到 我的 C# 代码给出了距出口位置约 1KM 的错误位置,但是当我使用以下 software 时,它给出了 10m 内的出口位置浏览器。

if (s.Contains("$GPRMC"))
        {
            latlon = s.Split('*');
            int i=0;
            while (!latlon[i].Contains("GPRMC"))
            {
                i++;
            }
            //latlon = latlon[i].Split(',');
            if (latlon[i].Contains(",A,"))
            {
                latlon = latlon[i].Split(',');
                lat = latlon[3];
                lon = latlon[5];



                latt = double.Parse(lat.Substring(0,2));
                latt += double.Parse(lat.Substring(2, 2)) / 60.0;
                latt += double.Parse(lat.Substring(5)) / 3600.0/100.0;
                lonn = double.Parse(lon.Substring(0,3));
                lonn += double.Parse(lon.Substring(3, 2))/60.0;
                lonn += double.Parse(lon.Substring(6))/3600.0/100.0;


                //richTextBox1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { richTextBox1.AppendText("Write\n"); }));
                richTextBox2.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() 
                    { 
                        richTextBox2.AppendText(lonn.ToString()+","+latt.ToString()+"\n"); 
                    }));
                label1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                {
                    label1.Content = lon;
                }));
                label2.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                {
                    label2.Content = lat;
                }));
                Thread.Sleep(1000);
                webBrowser1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                    {
                        try
                        {
                            webBrowser1.InvokeScript("animate", latt.ToString(), lonn.ToString());
                        }
                        catch { }
                    })
                    );

            }

【问题讨论】:

  • 不知道如何准确定位 GPS 位置...

标签: c# wpf gps windows-mobile-gps gpsd


【解决方案1】:

我认为问题在于您将秒转换为度数

latt += double.Parse(lat.Substring(5)) / 3600.0/100.0;

你只需要将“秒”部分除以 3600

latt += double.Parse(lat.Substring(5)) / 3600.0;
lonn += double.Parse(lon.Substring(6)) / 3600.0;

另一件事您可能已经知道,如果纬度值在南侧,则纬度值为负,而经度值在西侧为负。否则,您的位置可能会出现在地球的另一侧。

【讨论】:

  • 位置在右侧,但从当前位置移开,位置在 N 和 E .. 最后一部分是圆形格式的第二部分,需要除以 100 否则开始连续指向不同的位置
  • (度数 = 分 / 60) 和 (分 = 秒 / 60)。因此 (度数 = (秒 / 60) / 60) 或 (度数 = 秒 / 3600)。如果你这样做 (Degrees = Seconds / 3600 / 100) 这意味着 (Degrees = Seconds / 360000) 偏离航向会给出错误的值。尝试仅将 Seconds 部分除以 3600,然后检查。
  • 作为参考,我在 SO stackoverflow.com/questions/3249700/… 上找到了这个较旧的问题
猜你喜欢
  • 1970-01-01
  • 2014-03-21
  • 1970-01-01
  • 1970-01-01
  • 2015-10-08
  • 1970-01-01
  • 1970-01-01
  • 2011-11-19
  • 1970-01-01
相关资源
最近更新 更多