2014年1月10日 星期五

判斷GPS訊號強度

/*
* @ 取得指定 Location 的 GPS 訊號強度
* - Judge the Gps singal strength of limit location.
*/
-(KRGpsSingalStrength)singalStrengthWithLocation:(CLLocation *)_location
{
    //水平精度
    //CLLocationAccuracy horizontal = newLocation.horizontalAccuracy;
    //垂直精度
    //CLLocationAccuracy vertical = newLocation.verticalAccuracy;
   
    CLLocationAccuracy _horizontalAccuracy = _location.horizontalAccuracy;
    KRGpsSingalStrength _singalStrength = KRGpsSingalStrengthNone;
    if( (_horizontalAccuracy > 0.0f) && (_horizontalAccuracy <= 10.0f) )
    {
        _singalStrength = KRGpsSingalStrengthPerfect;
    }
    else if( (_horizontalAccuracy > 10.0f) && (_horizontalAccuracy <= 30.0f) )
    {
        _singalStrength = KRGpsSingalStrengthStrong;
    }
    else if( (_horizontalAccuracy > 30.0f) && (_horizontalAccuracy <= 60.0f) )
    {
        _singalStrength = KRGpsSingalStrengthHigh;
    }
    else if( (_horizontalAccuracy > 60.0f ) && (_horizontalAccuracy <= 100.0f) )
    {
        _singalStrength = KRGpsSingalStrengthMiddle;
    }
    else if( (_horizontalAccuracy > 100.0f) && (_horizontalAccuracy <= 200.0f))
    {
        _singalStrength = KRGpsSingalStrengthLow;
    }
    return _singalStrength;
}

沒有留言:

張貼留言