As a first try I would do 2 retrieves
If enough results take the locations that are in both lists (Union).
Calculate the distance for that (quick google: d = acos( sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2)*cos(lon2-lon1) ) * R)
Sort on the distance.
Things to solve: meridian and equator.
Maybe this helps if you can use SQL directly
The suggested SQL = Select Id, Postcode, Lat, Lon, acos(sin(:lat)sin(radians(Lat)) + cos(:lat)cos(radians(Lat))cos(radians(Lon)-:lon)) * :R As D From MyTable Where acos(sin(:lat)sin(radians(Lat)) + cos(:lat)cos(radians(Lat))cos(radians(Lon)-:lon)) * :R < :rad
Does anyone know if this will also work in OQL.?