【问题标题】:GPS stuck to a single sourceGPS坚持单一来源
【发布时间】:2015-09-25 15:19:38
【问题描述】:

我们正在使用针对 windows 8.1 的 VS 2012 Windows 应用程序开发跟踪应用程序。

我们正在使用 GeoCoordinateWatcher 类。出于某种原因,如果第一个修复来自 wifi,然后您关闭了 wifi,则应用程序无法获得卫星修复(观察者状态一直不返回任何数据)。它只能看到wifi位置。

如果第一个修复来自 GPS 卫星,似乎会出现同样的问题。

不确定这是硬件问题还是软件问题...但我需要观察者根据可用性使用这两种来源。

感谢您对此问题的任何见解。

以下是负责捕获 GPS 的代码部分。它调用了一个每 XX 工作一次的计时器。

private string SendingData()
    {
        try
        {

            DataXML = "";
            string result = "";
            Write_Trace_File("SendingData: Watcher Status: " + watcher.Status.ToString());
            if (watcher.Status != GeoPositionStatus.Ready)
            {
                try
                {
                    watcher.TryStart(true,TimeSpan.FromSeconds(10));
                }
                catch (Exception exp)
                {
                    Write_Trace_File(exp.Message);
                }
            }
            string cur_long = "";
            string cur_lat = "";
            string cur_speed = "";
            if (watcher.Position.Location.IsUnknown)
            {
                Write_Trace_File("SendingData: GPS not captured yet.");
                if (currlatitude.ToString() != "0.0" && currlatitude.ToString() != "" && currlatitude.ToString() != "0")
                {
                    Write_Trace_File("SendingData:Using Cached GPS.GPS last captured at" + lastPosDate);
                    cur_long = currlongtitude.ToString();
                    cur_lat = currlatitude.ToString();
                    if (speed.ToString() != "0")
                    {
                        cur_speed = speed.ToString();
                    }


                }
                else
                {
                    Write_Trace_File("SendingData:No Cached GPS.");
                    return "";
                }
            }
            else
            {
                Write_Trace_File("SendingData:Using Captured GPS.");
                cur_long = watcher.Position.Location.Longitude.ToString();
                cur_lat = watcher.Position.Location.Latitude.ToString();
                cur_speed = watcher.Position.Location.Speed.ToString();
            }


    }

【问题讨论】:

  • 这是一个非常广泛的问题,有任何代码吗?
  • 刚刚添加了负责获取GPS的代码部分。

标签: c# .net gps


【解决方案1】:

你有没有试过打电话

GeoCoordinateWatcher.Close()

GeoCoordinateWatcher.Start() 

看看这是否让它重新焕发生机的方法?

参考:https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher_methods(v=vs.110).aspx

【讨论】:

  • 谢谢本。是的,我做了,但无济于事。实际上,我必须启用/禁用整个 Windows 位置驱动程序才能切换源,或关闭并重新打开应用程序。如果旧的观察者状态为无数据,我尝试实例化一个新的观察者,但这也不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-02
  • 1970-01-01
  • 2016-06-12
  • 2017-06-25
  • 1970-01-01
相关资源
最近更新 更多