Windows Phone 8 gps /高度问题 [英] Windows phone 8 gps / altitude problems

查看:166
本文介绍了Windows Phone 8 gps /高度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:使用这里的示例 - http://code.msdn。 microsoft.com/wpapps/Location-sample-f11aa4e7 并添加高度读数,我得到的代码与我的代码相同。准确度不佳正在减少50英尺。在720(正确)和300英尺之间来回移动意味着错误。我只是无法看到在哪里......



我开始为windows phone 8制作一个GPS跟踪应用程序,但有些事情正在发生故障。在我的应用程序中(和示例位置应用程序中),我得到了一些正确的读数,而其他的读数没有。一般来说,高度在〜95和〜215之间来回跳动(215是正确的)。我得到的距离也非常不准确,当坐在我的办公桌前或在外面走动时,很快跳到了几英里。

我不确定要发布什么代码,因为它与示例代码相同。如果您认为有其他相关部分,我应该发布让我知道,我会添加它。

  double maxSpeed = 0.0; 
double maxAlt = -9999999.0;
double minAlt = 9999999.0;
double curDistance = 0.0;
GeoCoordinate lastCoord = null;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if((bool)IsolatedStorageSettings.ApplicationSettings [LocationConsent]!= true)
{
//用户已选择退出位置。
return;


$ b if(App.Geolocator == null)
{
//使用应用程序的全局Geolocator变量
App.Geolocator = new Geolocator();
}

App.Geolocator.DesiredAccuracy = PositionAccuracy.High;
//App.Geolocator.MovementThreshold = 1; //单位是米。
App.Geolocator.ReportInterval = 1000;
//App.Geolocator.DesiredAccuracyInMeters = 50;
App.Geolocator.StatusChanged + = geolocator_StatusChanged;
App.Geolocator.PositionChanged + = geolocator_PositionChanged;

/ *
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
//geolocator.MovementThreshold = 1; //单位是米。
geolocator.ReportInterval = 1000;
geolocator.StatusChanged + = geolocator_StatusChanged;
geolocator.PositionChanged + = geolocator_PositionChanged;
*
* * /
logging = true;

startTime = DateTime.Now;



public static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate)
{
return new GeoCoordinate

geocoordinate.Latitude,
geocoordinate.Longitude,
geocoordinate.Altitude ?? Double.NaN,
geocoordinate.Accuracy,
geocoordinate.AltitudeAccuracy ?? Double.NaN,
geocoordinate.Speed? ?Double.NaN,
geocoordinate.Heading ?? Double.NaN
);

void geolocator_PositionChanged(Geolocator sender,PositionChangedEventArgs args)
{
Dispatcher.BeginInvoke(()=>
{
if(lastCoord == null)
{
lastCoord = ConvertGeocoordinate(args.Position.Coordinate);
}
DateTime currentTime = DateTime.Now;

TimeSpan totalTime = currentTime - startTime;

timeValue.Text = totalTime.ToString(@hh\:mm\:ss);


System.Diagnostics.Debug .WriteLine(args.Position.Coordinate.Altitude.ToString());


GeoCoordinate thisLocation = ConvertGeocoordinate(args.Position.Coordinate);



if(true)// units check true = standard
{
double speed =(double)thisLocation.Speed;
speed * = 2.23694; // m / s - > mph
speedValue.T ext = speed.ToString(0);

double alt =(double)thisLocation.Altitude;
if(alt> maxAlt)
{
maxAlt = alt;
}
if(alt< minAlt)
{
minAlt = alt;
}
/ *
double currentAlt =(maxAlt - minAlt);
currentAlt * = 3.28084; // m - > ft
* * /
alt * = 3.28084;
altValue.Text = alt.ToString(0);

double distance = thisLocation.GetDistanceTo(lastCoord);

curDistance + =距离;

距离= curDistance * 0.000621371; // m - > miles

distanceValue.Text = distance.ToString(0.00);

distanceUnits.Text =(mi);
speedUnits.Text =(mph);
altUnits.Text =(ft);

}


});
}

编辑:我没有提到,但速度完全正常仅供参考。 lat / long在一般情况下非常接近我的位置,所以我不认为这是硬件问题。



更新:在调试器中停止时检查值而不是打印它,它给出了这个:



Altitude =在评估方法Windows.Devices.Geolocation.Geocoordinate.get_Altitude()时发生内部错误



我尝试搜索这个,但是在互联网上找不到这个错误...

该文件指出,高度和其他一些不能保证,但它也表示,如果不存在,值将为空。我检查,并且它从不为空。它总是打印一个值,要么是正确的,要么是400英尺。


$ b

更新:示例代码:

  void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Altitude.ToString()); (!!App.RunningInBackground)
{
Dispatcher.BeginInvoke(()=>
{
LatitudeTextBlock.Text =



$ b) args.Position.Coordinate.Latitude.ToString(0.00);
LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString(0.00);

});
}
else
{
Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
toast.Content = args.Position.Coordinate.Latitude.ToString(0.00);
toast.Title =位置:;
toast.NavigationUri = new Uri(/ MainPage.xaml,UriKind.Relative);
toast.Show();


$ b


解决方案

您可能会看到不同的问题(但是),但GPS高度并不十分可靠。我有几个Garmin设备,他们都在这个地方跳。你真的需要一个晴雨表来提高体面的高度准确性。
以下是GPS姿态不准确的链接 GPS Elevation


UPDATE: using the sample from here - http://code.msdn.microsoft.com/wpapps/Location-sample-f11aa4e7 and adding an altitude readout I get the same thing as my code. Poor accuracy is being off by 50ft. Going back and forth between 720 (correct) and 300 ft means something is wrong. I just can't see where...

I'm starting to make a GPS tracking app for windows phone 8 but something is going haywire. In my app, (and in the sample location app) i get some readings that are correct and others that are not. In general, the altitude jumps back and forth between ~95 and ~215 (with 215 being correct). The distance I'm getting is hugely inaccurate as well, quickly jumping to several miles while sitting at my desk or walking around outside.

I'm not sure what code to post, as it is identical to the sample code. If you think there is another relevant section i should post let me know and I'll add it.

    double maxSpeed = 0.0;
    double maxAlt = -9999999.0;
    double minAlt = 9999999.0;
    double curDistance = 0.0;
    GeoCoordinate lastCoord = null;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] != true)
        {
            // The user has opted out of Location.
            return;
        }


        if (App.Geolocator == null)
        {
            // Use the app's global Geolocator variable
            App.Geolocator = new Geolocator();
        }

        App.Geolocator.DesiredAccuracy = PositionAccuracy.High;
        //App.Geolocator.MovementThreshold = 1; // The units are meters.
        App.Geolocator.ReportInterval = 1000;
        //App.Geolocator.DesiredAccuracyInMeters = 50;
        App.Geolocator.StatusChanged += geolocator_StatusChanged;
        App.Geolocator.PositionChanged += geolocator_PositionChanged;

        /*
        geolocator = new Geolocator();
        geolocator.DesiredAccuracy = PositionAccuracy.High;
        //geolocator.MovementThreshold = 1; // The units are meters.
        geolocator.ReportInterval = 1000;
        geolocator.StatusChanged += geolocator_StatusChanged;
        geolocator.PositionChanged += geolocator_PositionChanged;
         * 
         * */
        logging = true;

        startTime = DateTime.Now;


    }
public static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate)
    {
        return new GeoCoordinate
            (
            geocoordinate.Latitude,
            geocoordinate.Longitude,
            geocoordinate.Altitude ?? Double.NaN,
            geocoordinate.Accuracy,
            geocoordinate.AltitudeAccuracy ?? Double.NaN,
            geocoordinate.Speed ?? Double.NaN,
            geocoordinate.Heading ?? Double.NaN
            );
    }
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
    {
        Dispatcher.BeginInvoke(() =>
        {
            if (lastCoord == null)
            {
                lastCoord = ConvertGeocoordinate(args.Position.Coordinate);
            }
            DateTime currentTime = DateTime.Now;

            TimeSpan totalTime = currentTime - startTime;

            timeValue.Text = totalTime.ToString(@"hh\:mm\:ss");


            System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Altitude.ToString());


            GeoCoordinate thisLocation = ConvertGeocoordinate(args.Position.Coordinate);



            if (true)  //units check true = standard
            {
                double speed = (double)thisLocation.Speed;
                speed *= 2.23694; //m/s -> mph
                speedValue.Text = speed.ToString("0");

                double alt = (double)thisLocation.Altitude;
                if (alt > maxAlt)
                {
                    maxAlt = alt;
                }
                if (alt < minAlt)
                {
                    minAlt = alt;
                }
                /*
                double currentAlt = (maxAlt - minAlt);
                currentAlt *= 3.28084; //m -> ft
                 * */
                alt *= 3.28084;
                altValue.Text = alt.ToString("0");

                double distance = thisLocation.GetDistanceTo(lastCoord);

                curDistance += distance;

                distance = curDistance * 0.000621371; // m -> miles

                distanceValue.Text = distance.ToString("0.00");

                distanceUnits.Text = "(mi)";
                speedUnits.Text = "(mph)";
                altUnits.Text = "(ft)";

            }


        });
    }

EDIT: I didn't mention, but the speed is perfectly fine as an fyi. the lat / long is pretty close in general to where i am as well, so I don't think it's a hardware issue.

UPDATE: When stopping in the debugger to check the value instead of just printing it, it gives this:

Altitude = An internal error has occurred while evaluating method Windows.Devices.Geolocation.Geocoordinate.get_Altitude()

I tried to search for this, but the error is nowhere to be found on the internet...

The documentation states that altitude and a few others aren't guaranteed, but it also says that the value will be null if it isn't there. I check, and it's never null. It always prints a value, either correct or ~400 ft off.

UPDATE: Sample code:

void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
    {
        System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Altitude.ToString());


        if (!App.RunningInBackground)
        {
            Dispatcher.BeginInvoke(() =>
            {
                LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00");
                LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00");

            });
        }
        else
        {
            Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
            toast.Content = args.Position.Coordinate.Latitude.ToString("0.00");
            toast.Title = "Location: ";
            toast.NavigationUri = new Uri("/MainPage.xaml", UriKind.Relative);
            toast.Show();

        }
    }

解决方案

You might be seeing a different issues (too) but GPS altitudes are not very reliable. I have a few Garmin devices and they all jump about all over the place. You really need a barometer for decent altitude accuracy. Here is a link on GPS attitude inaccuracy GPS Elevation

这篇关于Windows Phone 8 gps /高度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆