Index: location.views.inc
===================================================================
--- location.views.inc  (6.x-3.x-dev)
+++ location.views.inc  (working copy)
@@ -60,6 +60,12 @@
       'location_views_handler_filter_proximity' => array(
         'parent' => 'views_handler_filter',
       ),
+      'location_handler_argument_location_proximity' => array(
+        'parent' => 'views_handler_argument',
+      ),
+      'location_views_handler_filter_proximity' => array(
+        'parent' => 'views_handler_filter',
+      ),
       'location_handler_field_location_distance' => array(
         'parent' => 'views_handler_field',
       ),
@@ -303,6 +309,9 @@
     'sort' => array(
       'handler' => 'location_handler_sort_location_distance',
     ),
+    'argument' => array(
+      'handler' => 'location_handler_argument_location_proximity',
+    ),
     'filter' => array(
       'handler' => 'location_views_handler_filter_proximity',
     ),
ndex: handlers/location_handler_argument_location_proximity.inc
===================================================================
--- handlers/location_handler_argument_location_proximity.inc (revision 0)
+++ handlers/location_handler_argument_location_proximity.inc (revision 0)
@@ -0,0 +1,125 @@
+<?php
+// $Id: location_handler_argument_location_proximity,v 1.0 2010/02/19 12:11:09 gravisrs Exp $
+
+/**
+ * Argument handler to accept lat/lon location and distance proximity.
+ */
+class location_handler_argument_location_proximity extends views_handler_argument {
+
+ function options_form(&$form, &$form_state) {
+   parent::options_form($form, $form_state);
+
+   //turn off unhandled options
+   unset($form['default_action']['#options']['summary asc']);
+   unset($form['default_action']['#options']['summary desc']);
+   unset($form['wildcard']);
+   unset($form['wildcard_substitution']);
+
+   //proximity function used
+   $form['operator'] = array(
+     '#type' => 'select',
+     '#title' => t('Proximity type'),
+     '#weight' => -47,
+     '#description' => t('Square (faster) or circle (more accurate. Cannot be used with DD distance unit)?'),
+     '#default_value' => $this->options['operator'],
+     '#options' => array('mbr' => t('Square'),'dist' => t('Circular'))
+   );
+
+   $form['help'] = array(
+     '#type' => 'item',
+     '#weight' => -50,
+     '#title' => t('Parameter usage'),
+     '#description' => t('This parameter accepts 3 or 4 values separated by underscore:  <br/><b>lat_lon[_dist]</b><br/><br/>lat - latitude float number<br/>lon - longitude float number<br/>dist - distance in selected units: either one integer (m/km/mi), or a pair in decimal degrees (first is latitude distance, then longitude) (optional, defaults to setting below)<br><br> example usages: <br>12.345_23.456<br>12.345_23.456_100 or <br>12.345_23.456<br>12.345_23.456_1.500_10.999'),
+   );
+
+   //units used
+   $form['search_units'] = array(
+     '#type' => 'select',
+     '#title' => t('Distance unit'),
+     '#weight' => -49,
+     '#options' => array(
+       'km' => t('Kilometers'),
+       'm' => t('Meters'),
+       'mile' => t('Miles'),
+       'dd' => t('Decimal degrees'),
+     ),
+     '#default_value' => $this->options['search_units'],
+   );
+
+   //default 3rd parameter
+   $form['default_distance'] = array(
+     '#weight' => -48,
+     '#type' => 'textfield',
+     '#title' => t('Default Distance'),
+     '#default_value' => $this->options['default_distance'],
+     '#description' => t('When 3rd number is ommitted'),
+   );
+
+ }
+
+ function option_definition() {
+   $options = parent::option_definition();
+   $options['operator'] = array('default' => 'dist');
+   $options['search_units'] = array('default' => 'm');
+   $options['default_distance'] = array('default' => '100');
+   return $options;
+ }
+
+ function admin_summary() {
+   return '';
+ }
+
+ //splitting argument to 3 vals
+ function break_arg($arg) {
+   $argv = explode('_',$arg);
+   $argc = count($argv);
+   if ($argc==4) {
+     //distance is in decimal degrees, first is lat second is lon
+     return array(floatval($argv[0]),floatval($argv[1]),floatval($argv[2]),floatval($argv[3]));
+   }
+   if ($argc==3) {
+     //distance is int - see _location_convert_distance_to_meters() why
+     return array(floatval($argv[0]),floatval($argv[1]),intval($argv[2]));
+   }
+   if ($argc==2) {
+     return array(floatval($argv[0]),floatval($argv[1]),intval($this->options['default_distance']));
+   }
+   return false;
+ }
+
+
+ function query() {
+   if (!$this->coords = $this->break_arg($this->argument)) return;
+   $this->ensure_my_table();
+
+   $lat = $this->coords[0];
+   $lon = $this->coords[1];
+   if ($this->options['search_units'] =='dd') {
+     $lat_distance = $this->coords[2];
+     $lon_distance = $this->coords[3];
+     $latrange[0] = $lat - $lat_distance;
+     $latrange[1] = $lat + $lat_distance;
+     $lonrange[0] = $lon - $lon_distance;
+     $lonrange[1] = $lon + $lon_distance;
+   }
+   else {
+     $distance = $this->coords[2];
+     if ($this->options['search_units'] =='m')
+       $distance_meters = $distance;
+     else
+       $distance_meters = _location_convert_distance_to_meters($distance, $this->options['search_units']);
+
+     $latrange = earth_latitude_range($lon, $lat, $distance_meters);
+     $lonrange = earth_longitude_range($lon, $lat, $distance_meters);
+   }
+   // Add MBR check (always.)
+   $this->query->add_where($this->options['group'], "$this->table_alias.latitude > %f AND $this->table_alias.latitude < %f AND $this->table_alias.longitude > %f AND $this->table_alias.longitude < %f", $latrange[0], $latrange[1], $lonrange[0], $lonrange[1]);
+
+   if ($this->operator == 'dist') {
+     // Add radius check.
+     $this->query->add_where($this->options['group'], earth_distance_sql($lon, $lat, $this->table_alias) .' < %f', $distance_meters);
+   }
+   
+ }
+ 
+}
