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