Common subdirectories: location-orig/contrib and location/contrib
Common subdirectories: location-orig/database and location/database
Common subdirectories: location-orig/geocoding and location/geocoding
diff -up location-orig/location.inc location/location.inc
--- location-orig/location.inc	2007-08-01 18:57:25.000000000 -0700
+++ location/location.inc	2007-10-05 15:44:24.000000000 -0700
@@ -770,16 +770,45 @@ function _location_convert_distance_to_m
  *     'lon' => is a floating point of the longitude coordinate of this location
  */
 function location_latlon_rough($location = array()) {
-  if (!isset($location['country']) || !isset($location['postal_code'])) {
-    return NULL;
-  }
-  
-  $latlon_function = 'location_latlon_rough_'. $location['country'];
-  if (function_exists($latlon_function)) {
-    return $latlon_function($location);
-  }
-  else {
-    return NULL;
+  if(isset($location['query'])) {
+    $rs = db_query("SELECT *, COUNT(*) cnt FROM {zipcodes} WHERE REPLACE(zip, ' ' ,'') LIKE ('%s') GROUP BY REPLACE(zip, ' ' ,'') ORDER BY cnt DESC");
+    if($row = db_fetch_array($rs)) {
+      return array('lat'=>$row['longitude'], 'lon'=>$row['latitude']);
+    }
+	
+    $query_str = preg_replace('/[^a-z0-9]/', ' ', $location['query']);
+    $query_str = preg_replace('/ [ ]+/', '%', $query_str);
+	
+    for($i = strlen($query_str); $i >= 0; $i--) {
+      $new_query_str = substr($query_str, 0, $i);
+      
+      if($query_str{$i} != '%') {
+        $new_query_str .= '%';
+      }
+      	
+      if(!preg_match('/%/', $new_query_str)) {
+        break;
+      }
+	
+      $rs = db_query("SELECT *, COUNT(*) cnt FROM {zipcodes} WHERE CONCAT(city, ' ', state, ' ', country) LIKE ('%s') GROUP BY CONCAT(city, ' ', state, ' ', country) ORDER BY cnt DESC", $new_query_str);
+      if($row = db_fetch_array($rs)) {
+        return array('lat'=>$row['longitude'], 'lon'=>$row['latitude']);
+      }
+    }
+      
+      return array('lat'=>null, 'lon'=>null);
+  } else {
+    if (!isset($location['country']) || !isset($location['postal_code'])) {
+      return NULL;
+    }
+    
+    $latlon_function = 'location_latlon_rough_'. $location['country'];
+    if (function_exists($latlon_function)) {
+      return $latlon_function($location);
+    }
+    else {
+      return NULL;
+    }
   }
 }
  
Only in location: location.inc~
diff -up location-orig/location.module location/location.module
--- location-orig/location.module	2007-08-22 18:09:16.000000000 -0700
+++ location/location.module	2007-10-04 12:11:57.000000000 -0700
@@ -65,13 +65,19 @@ function location_help($section) {
 
 
 function location_search_view() {
-  $location_params = array(
-    //'street' => $_GET['street'],
-    //'city' => $_GET['city'],
-    //'province' => $_GET['province'],
-    'postal_code' => $_GET['postal_code'],
-    'country' => $_GET['country'] ? $_GET['country'] : variable_get('location_default_country', 'us')
-  );
+  if(variable_get('location_search_fuzzy', 0)) {
+    $location_params = array(
+      'query' => $_GET['query'],
+    );
+  } else {
+    $location_params = array(
+      //'street' => $_GET['street'],
+      //'city' => $_GET['city'],
+      //'province' => $_GET['province'],
+      'postal_code' => $_GET['postal_code'],
+      'country' => $_GET['country'] ? $_GET['country'] : variable_get('location_default_country', 'us')
+    );  
+  }
   
   $proximity_params = array(
     'distance' => $_GET['distance'],
@@ -80,7 +86,8 @@ function location_search_view() {
   
   $output .= drupal_get_form('location_search_form', $location_params, $proximity_params);
   
-  if ($_GET['postal_code'] && $_GET['country'] && $_GET['distance'] && $_GET['country']) {
+  if ($_GET['postal_code'] && $_GET['country'] && $_GET['distance'] && $_GET['country'] || $_GET['query']) {
+
     $output .= location_search_results($location_params, $proximity_params);
   }
   
@@ -89,21 +96,30 @@ function location_search_view() {
 
 function location_search_form($location_params = array(), $proximity_params = array()) {
   $form = array();
-  
+
   $location_search_distance_unit_setting = variable_get('location_search_distance_unit', 0);
   $proximity_suppressed_values = $location_search_distaince_unit_setting ? array('unit' => $location_search_distance_unit_setting) : array();
   $form['proximity'] = location_proximity_form($proximity_params, $proximity_suppressed_values);
   
   $location_suppressed_values = variable_get('location_suppress_country', 0) ? array('country' => variable_get('location_default_country', 'us')) : array();
   
-  $form['location'] = location_form(
-    array('postal_code', 'country'),
-    $location_params,
-    array('postal_code', 'country'),
-    $location_suppressed_values,
-    '',
-    'nearby_postalcodes_bylocation'
-  );
+  if(variable_get('location_search_fuzzy', 0)) {
+    $form['location']['query'] = array(
+      '#type' => 'textfield',
+      '#title' => t('City, Province or Postal Code'),
+      '#default_value' => $location_params['query'],
+      '#size' => 20,
+    );
+  } else {
+    $form['location'] = location_form(
+      array('postal_code', 'country'),
+      $location_params,
+      array('postal_code', 'country'),
+      $location_suppressed_values,
+      '',
+      'nearby_postalcodes_bylocation'
+    );
+  }
 
   $form['submit'] = array(
     '#type' => 'submit',
@@ -118,8 +134,7 @@ function location_search_form($location_
     $form['#submit'] ? $form['#submit'] : array(),
     array('location_search_form_submit' => array())
   );
-  
-  
+    
   return $form;
 }
 
@@ -158,7 +173,11 @@ function location_search_form_submit($fo
   
   $query_string = '&distance='. $form_values['distance'] .'&unit='. $unit;
   */
-  return array('search/location', 'postal_code='. $form_values['postal_code'] .'&country='. $form_values['country'] .'&distance='. $form_values['distance'] .'&unit='. $form_values['unit']);
+  if($form_values['query']) {
+    return array('search/location', 'query='. $form_values['query'] .'&distance='. $form_values['distance'] .'&unit='. $form_values['unit']);
+  } else {
+    return array('search/location', 'postal_code='. $form_values['postal_code'] .'&country='. $form_values['country'] .'&distance='. $form_values['distance'] .'&unit='. $form_values['unit']);
+  }
 }
 
 function location_search_results($location_params, $proximity_params) {
@@ -1362,6 +1381,12 @@ function location_admin_settings() {
       '#default_value' => variable_get('location_suppress_country', 0),
       '#description' => t("If your site is specific to a country and you would like to hide the country field on search forms and content creation forms, check this box.  Doing so will automatically assume the country to be the country you have chosen for the 'default country selection' above.")
       );
+  $form['location_search_fuzzy'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Use Fuzzy Location Search'),
+      '#default_value' => variable_get('location_search_fuzzy', 0),
+      '#description' => t('Enabling this option will allow users to search by postal code or by string. (eg. "portland, oregon" or "new york")'),
+  );
   $form['location_search_distance_unit'] = array(
       '#type' => 'radios',
       '#title' => t('Distance unit for location-based searches'),
Only in location: location.module~
Only in location: README.txt
Common subdirectories: location-orig/supported and location/supported
