2010-06-25 2 views
0

기본적으로 내 앱의 위치 컨트롤러가 작동합니다. 그러나 오랜 시간이 지나면 그것을 인식하지 않고 잘못된 위치를 얻습니다. 나는 gps- 버퍼 오버 플로우 나 그런 종류라고 생각한다.GPS가 잘못되었습니다 위치

여기 didUpdate-이벤트

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

//nonvalid 
if (signbit(newLocation.horizontalAccuracy)) 
    return; 

//0.0 is no valid location here 
if ((abs(newLocation.coordinate.latitude) < 1.0e-05) || (abs(newLocation.coordinate.longitude) < 1.0e-05)) 
    return; 

if (newLocation.horizontalAccuracy > DBL_MAX) 
    return; 


@synchronized(self) 
{ 
    currentCoordinate.latitude = newLocation.coordinate.latitude; 
    currentCoordinate.longitude = newLocation.coordinate.longitude; 
} 

}

내 코드는이 위치 버퍼를 플러시 할 수있어? 또는 삼각형 모양의 값으로 위치를 제어 하시겠습니까?

+0

"iphone"태그를 추가하면 제목에 "iPhone"을 포함 할 필요가 없습니다. :) – Emil

+0

얼마나 오랫동안 얘기하고 있습니까? 이것이 애플에 의해 철저히 테스트되지는 않을 것 같다.) – deanWombourne

답변

1

또한 위치 데이터의 수명을 테스트해야합니다. 캐시를 플러시하는 데 가장 가까운 방법입니다 (불가능 함). timestamp 속성을 확인하고 너무 오래된 경우 업데이트를 거부하십시오.

// check that the location data isn't older than 60 seconds 
if ([newLocation.timestamp timeIntervalSinceReferenceDate] < [NSDate timeIntervalSinceReferenceDate] - 60) { 
    return; 
} 
관련 문제