|
I'm working with Hal on this issue (he's out of town right now).
We started with simple tests written in groovy...here is an example we converted and ran directly from the Mongo shell:
use testDb
|
|
db.locations.save( { loc: { x: 1, y: 1 } } )
|
db.locations.save( { loc: { x: 2, y: 0 } } )
|
db.locations.save( { loc: { x: 3, y: 1 } } )
|
|
db.locations.find()
|
|
db.locations.ensureIndex( { loc: "2d" } )
|
|
box = [ [0, 0], [3, 3] ]
|
db.locations.find( { "loc": { "$within": { "$box": box } } } )
|
|
polygon = [ [0, 0], [2, 2], [4, 0] ]
|
db.locations.find( { "loc": { "$within": { "$polygon": polygon } } } )
|
When I run the example above, the box search finds all the saved points as expected.
The polygon search, however, only finds points (2, 0) and (3, 1).
Point (1, 1) should have been found also.
We have also tested using more saved points and search polygons created with different rotation. These tests have consistently failed to find all points. If you need more examples, please let me know. The simple test above seemed like a good place to start.
|