Index: handlers/location_handler_field_location_distance.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/handlers/location_handler_field_location_distance.inc,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 location_handler_field_location_distance.inc
--- handlers/location_handler_field_location_distance.inc	21 Jan 2009 21:39:16 -0000	1.2.2.1
+++ handlers/location_handler_field_location_distance.inc	30 Nov 2009 18:34:46 -0000
@@ -107,12 +107,12 @@
 
     $this->ensure_my_table();
 
-    if (empty($latitude) && empty($longitude)) {
-      // We don't know the distance.
-      $this->field_alias = $this->query->add_field(NULL, "'Unknown'", "{$this->table_alias}_{$this->field}_{$this->position}");
+    if (isset($latitude) && isset($longitude)) {
+      $this->field_alias = $this->query->add_field(NULL, earth_distance_sql($longitude, $latitude, $this->table_alias), "{$this->table_alias}_{$this->field}_{$this->position}");
     }
     else {
-      $this->field_alias = $this->query->add_field(NULL, earth_distance_sql($longitude, $latitude, $this->table_alias), "{$this->table_alias}_{$this->field}_{$this->position}");
+      // We don't know the distance.
+      $this->field_alias = $this->query->add_field(NULL, "'Unknown'", "{$this->table_alias}_{$this->field}_{$this->position}");
     }
   }
 }
