TEchnical Cites

  • 01:58:01 pm on October 20, 2009 | 1
    Tags: , , , ,

    sprintf(buffer,    “SELECT * FROM POIs WHERE (ABS(lat – %f) < 0.03) AND
    (ABS(lng – %f) < 0.04);”, nLat,    nLon);

    If you REALLY need to sort them by distance then here’s a formula that
    works at any latitude

    //spherical distance in meters
    – (CGFloat) sphericalDistanceFromLat1:(CGFloat)lat1 Lon1:(CGFloat)lon1
    toLat2:(CGFloat)lat2 Lon2:(CGFloat)lon2 {
        return acos(sin(lat1 * 0.0174533) * sin(lat2 * 0.0174533) + cos(lat1
    * 0.0174533) * cos(lat2 * 0.0174533) * cos((lon2-lon1) * 0.0174533)) *
    6371000;
    }

    Blogged with the Flock Browser
    Advertisements
     

Comments

  • praveenmatanam 1:59 pm on October 20, 2009 | # | Reply

    Try CLLocation – (CLLocationDistance)getDistanceFrom:(const CLLocation
    *)location
    Should give you the distances.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: