1 // $Id$
  2 
  3 /**
  4  * Offers an interface to the local parameters used by the Spatial Solr plugin.
  5  *
  6  * @see http://www.jteam.nl/news/spatialsolr
  7  *
  8  * @class AbstractSpatialWidget
  9  * @augments AjaxSolr.AbstractWidget
 10  */
 11 AjaxSolr.AbstractSpatialWidget = AjaxSolr.AbstractWidget.extend(
 12   /** @lends AjaxSolr.AbstractSpatialWidget.prototype */
 13   {
 14   /**
 15    * Sets the Spatial Solr local parameters.
 16    *
 17    * @param {Object} params The local parameters to set.
 18    * @param {Number} params.lat Latitude of the center of the search area.
 19    * @param {Number} params.lng Longitude of the center of the search area.
 20    * @param {Number} params.radius Radius of the search area.
 21    * @param {String} [params.unit] Unit the distances should be calculated in:
 22    *   "km" or "miles".
 23    * @param {String} [params.calc] <tt>GeoDistanceCalculator</tt> that will be
 24    *   used to calculate the distances. "arc" for
 25    *   <tt>ArchGeoDistanceCalculator</tt> and "plane" for
 26    *   <tt>PlaneGeoDistanceCalculator</tt>.
 27    * @param {Number} [params.threadCount] Number of threads that will be used
 28    *   by the <tt>ThreadedDistanceFilter</tt>.
 29    */
 30   set: function (params) {
 31     this.manager.store.get('q').local('type', 'spatial');
 32     this.manager.store.get('q').local('lat', params.lat);
 33     this.manager.store.get('q').local('long', params.lng);
 34     this.manager.store.get('q').local('radius', params.radius);
 35     if (params.unit !== undefined) {
 36       this.manager.store.get('q').local('unit', params.unit);
 37     }
 38     if (params.calc !== undefined) {
 39       this.manager.store.get('q').local('calc', params.calc);
 40     }
 41     if (params.threadCount !== undefined) {
 42       this.manager.store.get('q').local('threadCount', params.threadCount);
 43     }
 44   },
 45 
 46   /**
 47    * Removes the Spatial Solr local parameters.
 48    */
 49   clear: function () {
 50     this.manager.store.get('q').remove('type');
 51     this.manager.store.get('q').remove('lat');
 52     this.manager.store.get('q').remove('long');
 53     this.manager.store.get('q').remove('radius');
 54     this.manager.store.get('q').remove('unit');
 55     this.manager.store.get('q').remove('calc');
 56     this.manager.store.get('q').remove('threadCount');
 57   }
 58 });
 59