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