Index: earth.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/earth.inc,v
retrieving revision 1.4
diff -u -r1.4 earth.inc
--- earth.inc	8 Mar 2006 06:53:37 -0000	1.4
+++ earth.inc	21 Nov 2006 07:42:21 -0000
@@ -88,7 +88,7 @@
   return acos($cosangle) * $radius;
 }
 
-function earth_distance_sql($longitude, $latitude) {
+function earth_distance_sql($longitude, $latitude, $tbl_prefix="") {
   // Make a SQL expression that estimates the distance to the given location.
   $long = deg2rad($longitude);
   $lat = deg2rad($latitude);
@@ -98,7 +98,7 @@
   $coslat = cos($lat);
   $sinlong = sin($long);
   $sinlat = sin($lat);
-  return "(IFNULL(ACOS($coslat*COS(RADIANS(latitude))*($coslong*COS(RADIANS(longitude)) + $sinlong*SIN(RADIANS(longitude))) + $sinlat*SIN(RADIANS(latitude))), 0.00000)*$radius)";
+  return "(IFNULL(ACOS($coslat*COS(RADIANS({$tbl_prefix}latitude))*($coslong*COS(RADIANS({$tbl_prefix}longitude)) + $sinlong*SIN(RADIANS({$tbl_prefix}longitude))) + $sinlat*SIN(RADIANS({$tbl_prefix}latitude))), 0.00000)*$radius)";
 }
 
 function earth_longitude_range($longitude, $latitude, $distance) {
