[SERVER-9346] Cannot query world with 2dsphere index Created: 13/Apr/13 Updated: 09/Jul/16 Resolved: 25/Apr/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 2.4.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | William Newman | Assignee: | hari.khalsa@10gen.com |
| Resolution: | Done | Votes: | 0 |
| Labels: | geo | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OSX |
||
| Issue Links: |
|
||||||||
| Operating System: | OS X | ||||||||
| Steps To Reproduce: | db.features.insert({loc: {type: "Point", coordinates: [10, 10] } } ); ); } } }); |
||||||||
| Participants: | |||||||||
| Description |
|
I have stored some GeoJSON points in a collection, created a 2dsphere index. When I query the world I do not get back any of the points I created. I was not sure if the polygon had to be drawn in a certain direction (clockwise, counterclockwise), I tried both ways with no luck. |
| Comments |
| Comment by hari.khalsa@10gen.com [ 25/Apr/13 ] |
|
MongoDB always assumes polygons are < hemisphere. Docs updated to mention this. |
| Comment by William Newman [ 19/Apr/13 ] |
|
Dan, I read the same thing I think:
Which lead me to check out how PostGIS handled queries. I think in this case they are referring polygons stored/indexed in the database, not bounding polygons used to query. Its also worth noting that drawing the polygon in either direction using PostGIS resulted in the correct behavior. The bummer is that I could find nothing in their documentation stating the direction in which a bounding polygon should be drawn. Also thanks a ton for updating the docs! |
| Comment by Daniel Pasette (Inactive) [ 18/Apr/13 ] |
|
newmanw, I pasted the wrong link in the |
| Comment by William Newman [ 18/Apr/13 ] |
|
From https://jira.mongodb.org/browse/DOCS-1391. 'Neither SQL Server nor PostGIS handle > 180° bounding polygons. aka, the "hemisphere limitation"' I do not think that is true. PostGIS may limit the size of indexed polygons but does not limit polygons when querying. Here are a couple examples of different queries in PostGIS. – get all rows from feature table (just one for now) – get all rows over the world with envelope – get all rows over the world with geometry – sanity check with smaller polygon |
| Comment by William Newman [ 18/Apr/13 ] |
|
Thanks Hari! Some discussion here as well: |
| Comment by hari.khalsa@10gen.com [ 16/Apr/13 ] |
|
Hi! All geometries must fit within a hemisphere. If a geometry is "bigger" than a hemisphere, we interpret the geometry as the complimentary shape that is smaller. This is why your query isn't returning any results: we think you're asking for points in a very small area, where there probably are no points. Think about a small polygon, say a little box, on the earth. This really defines two areas: the area inside the polygon, and the area outside of it. If you make this box bigger, say, bigger than half the earth, we're not sure which area you really want, so we choose the smallest area. |