1. <small id='a4LcR'></small><noframes id='a4LcR'>

    1. <i id='a4LcR'><tr id='a4LcR'><dt id='a4LcR'><q id='a4LcR'><span id='a4LcR'><b id='a4LcR'><form id='a4LcR'><ins id='a4LcR'></ins><ul id='a4LcR'></ul><sub id='a4LcR'></sub></form><legend id='a4LcR'></legend><bdo id='a4LcR'><pre id='a4LcR'><center id='a4LcR'></center></pre></bdo></b><th id='a4LcR'></th></span></q></dt></tr></i><div id='a4LcR'><tfoot id='a4LcR'></tfoot><dl id='a4LcR'><fieldset id='a4LcR'></fieldset></dl></div>
      • <bdo id='a4LcR'></bdo><ul id='a4LcR'></ul>
    2. <legend id='a4LcR'><style id='a4LcR'><dir id='a4LcR'><q id='a4LcR'></q></dir></style></legend>
    3. <tfoot id='a4LcR'></tfoot>

      CLLocation 返回负速度

      时间:2023-09-02
      • <bdo id='HGtS8'></bdo><ul id='HGtS8'></ul>

          <tbody id='HGtS8'></tbody>
        <legend id='HGtS8'><style id='HGtS8'><dir id='HGtS8'><q id='HGtS8'></q></dir></style></legend>

                <tfoot id='HGtS8'></tfoot>

                <i id='HGtS8'><tr id='HGtS8'><dt id='HGtS8'><q id='HGtS8'><span id='HGtS8'><b id='HGtS8'><form id='HGtS8'><ins id='HGtS8'></ins><ul id='HGtS8'></ul><sub id='HGtS8'></sub></form><legend id='HGtS8'></legend><bdo id='HGtS8'><pre id='HGtS8'><center id='HGtS8'></center></pre></bdo></b><th id='HGtS8'></th></span></q></dt></tr></i><div id='HGtS8'><tfoot id='HGtS8'></tfoot><dl id='HGtS8'><fieldset id='HGtS8'></fieldset></dl></div>
              1. <small id='HGtS8'></small><noframes id='HGtS8'>

              2. 本文介绍了CLLocation 返回负速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在启动一个使用 coreLocation 和 mapkit 框架的新应用程序.

                I'm starting a new app which uses the coreLocation and the mapkit frameworks.

                我的问题是试图获得当前速度总是给我一个负值,我带着我的 iPhone 到了 3g 信号良好的地方,没关系,location.speed 值总是 -1.

                My problem is trying to get the current speed always returns me a negative value, i have take my iPhone with me to places with a good 3g signal and it doesn't matter, location.speed value is always -1.

                这是重要的代码:

                #define kRequiredAccuracy 1500.0 //meters
                #define kMaxAge 60.0 //seconds
                

                在init方法中:

                self.locationManager=[[CLLocationManager alloc] init];
                self.locationManager.delegate=self;
                self.locationManager.desiredAccuracy=kCLLocationAccuracyNearestTenMeters;
                

                然后didUpdateToLocation:

                then didUpdateToLocation:

                - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
                
                    NSTimeInterval ageInSeconds = [newLocation.timestamp timeIntervalSinceNow];
                    NSLog(@"Location: %@", [newLocation description]);
                
                    if( newLocation.horizontalAccuracy > kRequiredAccuracy || fabs(ageInSeconds) > kMaxAge )
                    {
                        NSLog(@"inacurate position");
                        [self.delegate inacuratePosition];
                
                    }
                    else {
                
                    [self.delegate locationUpdate:newLocation andOldLocation:oldLocation];
                    location=newLocation.coordinate;
                
                
                    }
                
                
                    if(tracking)
                    {   
                    [self updatePosition];
                    }
                    if(firstTime)
                    {
                        [self placeStartMark];
                        firstTime=FALSE;
                    }
                
                
                
                }
                

                最后在我实现协议的视图控制器中:

                and finally in the view controller in which I'm implementing the protocol:

                - (void)locationUpdate:(CLLocation *)newLocation andOldLocation:(CLLocation*)oldLocation{
                
                    double speed = [newLocation speed] *3.6;
                
                
                
                    double altitude= [newLocation altitude];
                    [self checkMaxSpeedAndAltitude:speed :altitude];
                    if(speed< 0)
                        speed=0;
                
                
                
                    locationLabel.text=[NSString stringWithFormat:@"speed: %f km/h   altitude: %f m", speed,altitude];
                }
                

                我快疯了,所以如果有人知道任何解决方案,那肯定会有所帮助.谢谢

                Im getting crazy so if anyone knows any solution it will be helpful for sure. Thanks

                推荐答案

                通常,如果使用的位置检测机制不支持,您会得到负高度和速度.例如,当使用 Wi-Fi 或小区三角测量时.你确定,你正在获取 GPS 更新,所以你是在自由的天空下测试吗?即便如此,您仍会收到 WiFi 和手机信号塔位置更新,因此您必须将它们过滤掉.

                Usually, you get negative altitude and speed if the used location detection mechanism doesn't support it. For instance, when Wi-Fi or cell triangulation is used. Are you sure, you're getting GPS updates, so are you testing under the free sky? Even then, you'll still receive WiFi and cell tower location updates so you've to filter them out.

                Wi-Fi 位置更新的典型水平精度为 65 m.

                65 m horizontal accuracy is typical for Wi-Fi location updates.

                这篇关于CLLocation 返回负速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何检测位置提供者?GPS 或网络提供商 下一篇:LocationManager 的 getLastKnownLocation 有多可靠,多久更

                相关文章

                最新文章

                  <bdo id='hsZ2O'></bdo><ul id='hsZ2O'></ul>
                <legend id='hsZ2O'><style id='hsZ2O'><dir id='hsZ2O'><q id='hsZ2O'></q></dir></style></legend>
                <tfoot id='hsZ2O'></tfoot>
                <i id='hsZ2O'><tr id='hsZ2O'><dt id='hsZ2O'><q id='hsZ2O'><span id='hsZ2O'><b id='hsZ2O'><form id='hsZ2O'><ins id='hsZ2O'></ins><ul id='hsZ2O'></ul><sub id='hsZ2O'></sub></form><legend id='hsZ2O'></legend><bdo id='hsZ2O'><pre id='hsZ2O'><center id='hsZ2O'></center></pre></bdo></b><th id='hsZ2O'></th></span></q></dt></tr></i><div id='hsZ2O'><tfoot id='hsZ2O'></tfoot><dl id='hsZ2O'><fieldset id='hsZ2O'></fieldset></dl></div>
              3. <small id='hsZ2O'></small><noframes id='hsZ2O'>