OCMapView 1.0
Simple and easy to use clustering mapView.
/Users/Boti/Documents/coding/iPhone Development/OCMapView+Sample/OCMapView/OCDistance.m
Go to the documentation of this file.
00001 //
00002 //  OEDistance.h
00003 //  openClusterMapView
00004 //
00005 //  Created by Botond Kis on 14.02.11.
00006 //
00007 
00008 #import "OCDistance.h"
00009 
00010 //
00011 // calculates the distance
00012 // between two given coordinates
00013 CLLocationDistance getDistance(CLLocationCoordinate2D firstLocation, CLLocationCoordinate2D secondLocation){
00014     // Calculate differences of the to annotations
00015     CLLocationDistance distance;
00016     
00017     CLLocationDistance deltaLat = firstLocation.latitude - secondLocation.latitude;
00018     CLLocationDistance deltaLon = firstLocation.longitude - secondLocation.longitude;
00019     distance = sqrt(deltaLat*deltaLat + deltaLon*deltaLon);
00020     
00021     return distance;
00022 }
00023 
00024 
00025 //
00026 // This c function returns true if the distance
00027 // between two given locations is shorter
00028 // or equal than the designated distance.
00029 // The distance represents the cluster size.
00030 BOOL isLocationNearToOtherLocation(CLLocationCoordinate2D firstLocation, CLLocationCoordinate2D secondLocation, CLLocationDistance distanceInGeoCoordinates){
00031         // Return value
00032         BOOL retVal = YES;
00033         
00034         // get distance
00035         CLLocationDistance distance = getDistance(firstLocation, secondLocation);
00036 
00037         // If the distance between these two things is longer than the
00038         // requested distanceInGeoCoordinates, the two annotations are not near to each other.
00039         if (distance > distanceInGeoCoordinates) {
00040                 retVal = NO;
00041         }
00042         
00043         return retVal;
00044 }
 All Data Structures Files Functions Variables Enumerations Enumerator Properties