Merge pull request #683 from thefinnomenon/master

Fixed typo & added the filter units
This commit is contained in:
Raymond Feng 2015-08-06 08:50:21 -07:00
commit 62624203d1
1 changed files with 4 additions and 2 deletions

View File

@ -15,6 +15,7 @@ exports.nearFilter = function nearFilter(where) {
result = {
near: ex.near,
maxDistance: ex.maxDistance,
unit: ex.unit,
key: key
};
}
@ -31,6 +32,7 @@ exports.nearFilter = function nearFilter(where) {
exports.filter = function (arr, filter) {
var origin = filter.near;
var max = filter.maxDistance > 0 ? filter.maxDistance : false;
var unit = filter.unit;
var key = filter.key;
// create distance index
@ -50,7 +52,7 @@ exports.filter = function (arr, filter) {
if (typeof loc.lat !== 'number') return;
if (typeof loc.lng !== 'number') return;
var d = GeoPoint.distanceBetween(origin, loc);
var d = GeoPoint.distanceBetween(origin, loc, {type: unit});
if (max && d > max) {
// dont add
@ -61,7 +63,7 @@ exports.filter = function (arr, filter) {
});
return result.sort(function (objA, objB) {
var a = objB[key];
var a = objA[key];
var b = objB[key];
if (a && b) {