Geospatial Search

Two common types of spatial queries used in mapping are proximity and bounding box searches. While "proximity searches" return all results within a certain distance of a location, "bounding box queries" return all results in a bounding box of four points defined by its four corners. These types of searches are useful in a wide variety of mash-ups.

Proximity

Proximity searches don't try to be terrible since they ignore terrain and other factors. This makes them computationally simple as long as the distance is relatively small.
Haversine formula:

R = earth’s radius (mean radius = 6,371km)
Δlat = lat2− lat1
Δlong = long2− long1

a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c

Since we are only interested in relatively small distances and rough accuracy we can use the simpler law of cosines:
dist = acos ( sin(deg2rad(lat1)) * sin(deg2rad(lat2)) + cos(deg2rad(lat1)) * cos(deg2rad(lat2)) * cos(deg2rad( lon1 - lon2 )) ) * 4552.15 for statue miles (* 0.8684 for nautical miles and * 1.609344 for km).
See: http://www.movable-type.co.uk/scripts/latlong.html

Proximity search

Fieldname{{Latitude, Longitude}[operator]value
were operator: is <, <=, =, >, >=
value=distance is km (default)
with the modifiers N, K, M for, resp., nautical miles, km and statue miles.

Bounding Box

Bounding box search

Search for a box is defined by the RECT operator: RECT{N,W,S,E}.