summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-03-01 22:06:30 -0500
committerEliot Horowitz <eliot@10gen.com>2010-03-01 22:06:30 -0500
commit0a8e1f91c83bce14480e9cda00a1f630a5c64e93 (patch)
treebe66a1f462c66f235c7efca1ee23041fc1537731 /shell
parent581980efa09ec2c6a516257c0a5ce4241e89e129 (diff)
downloadmongo-0a8e1f91c83bce14480e9cda00a1f630a5c64e93.tar.gz
handle multiple geo indexes with $near SERVER-686
Diffstat (limited to 'shell')
-rw-r--r--shell/utils.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/shell/utils.js b/shell/utils.js
index cfaa799f278..647aac7d160 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -924,3 +924,28 @@ killWithUris = function( uris ) {
}
}
}
+
+Geo = {};
+Geo.distance = function( a , b ){
+ var ax = null;
+ var ay = null;
+ var bx = null;
+ var by = null;
+
+ for ( var key in a ){
+ if ( ax == null )
+ ax = a[key];
+ else if ( ay == null )
+ ay = a[key];
+ }
+
+ for ( var key in b ){
+ if ( bx == null )
+ bx = b[key];
+ else if ( by == null )
+ by = b[key];
+ }
+
+ return Math.sqrt( Math.pow( by - ay , 2 ) +
+ Math.pow( bx - ax , 2 ) );
+}