Google Groups

Re: Geospacial 'within box' query returning error 'need an area > 0'


Sosh May 5, 2012 1:56 AM
Posted in group: mongodb-user
Hmm strange, that seems to be exactly the way I'm specifying it.  From my code (before I put the bits in):

dbMapData.ensureIndex([{ loc : "2d" }, { min : -10000 , max : 10000, bits : 32 } .....

Perhaps this is a problem with the driver?  Is there any way of forcing it so the the second parameter set is associated with the options field?

On Friday, May 4, 2012 11:37:05 PM UTC+2, Mathias Stearn wrote:
It looks like you put the min,max and bits options in the index spec rather than in the options field. The correct syntax is something like this:

db.map.ensureIndex({ loc: "2d"}, {min: -10000, max: 10000, bits: 32 })

On Friday, May 4, 2012 2:41:18 PM UTC-4, Sosh wrote:
Here's the relevant log file output:

Fri May 04 19:35:46 [conn8] build index tworld.map { loc: "2d", min: -10000, max: 10000, bits: 32 }
Fri May 04 19:35:46 [conn8] build index done 138 records 0 secs
Fri May 04 19:36:03 [clientcursormon] mem (MB) res:63 virt:140 mapped:96
Fri May 04 19:36:18 [conn8] assertion 13064 need an area > 0  ns:tworld.map query:{ loc: { $within: { $box: [ [ -100, 200 ], [ 49, 349 ] ] } } }

On Friday, May 4, 2012 7:37:47 PM UTC+2, Sosh wrote:
Bits:32 Didn't help, still failing at   box= -100,200,49,349.

On Friday, May 4, 2012 7:33:53 PM UTC+2, Sosh wrote:
Hmm.  Ok, I shouldn't have been so hasty.  There were a bunch of 2d indexes on that collection with different values (who knows where from).  I've deleted the indexes and re-ensured an index of -10 000, 10 000.   When I run the test again it spits the error out at box= -100,200,49,349   which seems suspiciously close to mongos default 2d index range of -180, 180 right?  Could it be ignoring my index?  

Do you know what the max index range is when 'bits' is left at the default value?  I'm going to change bits to 32 now (but I don't think I really need to for 10 000).  Will try and get you the console output too, but not familiar with this.

Thanks.

On Friday, May 4, 2012 12:06:13 PM UTC+2, Sosh wrote:
Hi,

I have a collection with a Geospacial index for it's a simple catesian
system (only integers).

I have my index set up like this:
dbMapData.ensureIndex([{ loc : "2d" }, { min : -10000000000 , max :
10000000000 }], true, function(err, res){}); //Abitrary large min/max

And my query:
 dbMapData.find({"loc" : {"$within" : {"$box" :
box}}}).toArray(function (err, array) {...

I'm looping though diffent box values.  This seems to work well, until
I reach a certain y value, then I am hit with the  'need an area > 0'
error.  However, I don't understand why I'm getting this error, as the
query that causes it is no different to the others.  I was wondering
if it might be an index min/max issue?

My debug output is below (box coords are x1,y1,x2,y2):

maprange request. box: -50,0,99,149
maprange request took 9 ms to query

maprange request. box: -50,50,99,199
maprange request took 6 ms to query

maprange request. box: -50,100,99,249
maprange request took 6 ms to query

maprange request. box: -50,150,99,299
maprange request took 1 ms to query

maprange request. box: -50,200,99,349
maprange request took 1 ms to query

maprange request. box: -50,250,99,399
maprange request took 24 ms to query

maprange request. box: -50,300,99,449
maprange request took 2 ms to query

maprange request. box: -50,350,99,499
maprange request took 1 ms to query

maprange request. box: -50,400,99,549
maprange request took 18 ms to query

maprange request. box: -50,450,99,599
maprange request took 6 ms to query

maprange request. box: -50,500,99,649

need an area > 0


Thank you!