0

I'm writing a custom annotation view for my latest iOS 5 app and I'm looking for the latest SDK friendly way to compare 2 CLLocationCoordinate2D coordinates?

CLLocationCoordinate2D coordinate = (CLLocationCoordinate2D){33.0,-112.4};
CLLocationCoordinate2D coordinate = (CLLocationCoordinate2D){33.0,-112.3};

Is there a built in method to determine something like this?

4

1 に答える 1

2

組み込みメソッドは必要ありません。緯度を比較するだけです:

CLLocationCoordinate2D coordinate1 = (CLLocationCoordinate2D){33.0,-112.4};
CLLocationCoordinate2D coordinate2 = (CLLocationCoordinate2D){34.0,-112.3};

CLLocationCoordinate2D furthestNorth;
if (coordinate1.latitude > coordinate2.latitude) {
    furthestNorth = coordinate1;
} else {
    furthestNorth = coordinate2;
}
// OR
furthestNorth = (coordinate1.latitude > coordinate2.latitude) ? coordinate1 : coordinate2;
于 2012-05-17T01:09:11.110 に答える