iOS/Objective - C

중앙값 찾기

DevBabamba 2018. 2. 8. 10:57
반응형
//find rect that encloses all coords

float maxLat = -200;
float maxLong = -200;
float minLat = MAXFLOAT;
float minLong = MAXFLOAT;

for (int i=0 ; i<[locations count] ; i++) {
    CLLocationCoordinate2D location = [locations objectAtIndex:i];

    if (location.latitude < minLat) {
        minLat = location.latitude;
    }

    if (location.longitude < minLong) {
        minLong = location.longitude;
    }

    if (location.latitude > maxLat) {
        maxLat = location.latitude;
    }

    if (location.longitude > maxLong) {
        maxLong = location.longitude;
    }
}

//Center point

CLLocationCoordinate2D center = CLLocationCoordinate2DMake((maxLat + minLat) * 0.5, (maxLong + minLong) * 0.5);

오류 부분 있을 수 있습니다~

반응형