How can I evaluate the GPS signal strength? (iPhone)
Asked Answered
O

2

8

I need a way of categorising the strength of the GPS signal. So far I have come across the horizontalAccuracy property of CLLocation (Class Reference).

To be more specific I need to create something like the following; the issue I'm having is filling in the if statements.

if (someLocation.horizontalAccuracy ...)
{
    // No Signal
}
else if (someLocation.horizontalAccuracy ...)
{
    // Poor Signal
}
else if (someLocation.horizontalAccuracy ...)
{
    // Average Signal
}
else if (someLocation.horizontalAccuracy ...)
{
    // Good Signal
}
else
{
    // Excellent Signal
}

Please can someone assist me in this?

On answered 20/4, 2012 at 12:54 Comment(0)
F
10

I've used figures like this in the past:

if (someLocation.horizontalAccuracy < 0)
{
    // No Signal
}
else if (someLocation.horizontalAccuracy > 163)
{
    // Poor Signal
}
else if (someLocation.horizontalAccuracy > 48)
{
    // Average Signal
}
else
{
    // Full Signal
}

but to be honest, it didn't really work very well for users. It would show as low accuracy, but when they looked at the maps app, it would have located them almost perfectly (albeit with a circle around them).

Rather than trying to define a level of accuracy, and if your app is map based, could you do what Maps does and show the horizontal accuracy as an circular overlay? Then the user can decide for themselves if it's accurate enough.

Fallow answered 20/4, 2012 at 13:6 Comment(1)
out of curiosity, why 163 and why 48?Tappet
I
0

I stumbled upon this answer. However, the accepted answer is totally wrong with regard to the numbers of accuracy. Here is the value I used:

extern const CLLocationAccuracy kCLLocationAccuracyBestForNavigation; // (raw value: -2)
extern const CLLocationAccuracy kCLLocationAccuracyBest; // (raw value: -1)
extern const CLLocationAccuracy kCLLocationAccuracyNearestTenMeters; // (raw value: 10)
extern const CLLocationAccuracy kCLLocationAccuracyHundredMeters; // (raw value: 100)
extern const CLLocationAccuracy kCLLocationAccuracyKilometer; // (raw value: 1000)
extern const CLLocationAccuracy kCLLocationAccuracyThreeKilometers; // (raw value: 3000)

.

Check CLLocation.h for the definitions. If you want to check gps accuracy, this is what I would do:

if lastLocation?.horizontalAccuracy != nil {  
   if lastLocation?.horizontalAccuracy! <=  kCLLocationAccuracyNearestTenMeters {
    // handle good gps case
    return
}
// handle less accurate gps case here
}
Identify answered 5/5, 2022 at 17:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.