[SERVER-6853] Make order of geo coordinates customizable when querying using $nearSphere Created: 24/Aug/12 Updated: 10/Dec/14 Resolved: 18/Apr/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Fredrik Björk | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
We're currently using $near to query our geo spatial collections which uses the order lat, lon. We need to switch to $nearSphere to make sure results are ordered by distance, which they aren't when using $near due to it not being spherical. Currently $nearSphere requires the indexed field to be in order of lon, lat. I would rather not change the order of all our collections from lat, lon to lon, lat as it would introduce all sorts of issues down the line in the code bases accessing the collections. Is there anyway the order of the geo coordinates could be configured or customized? If not perhaps you could create another spherical query that is using lat, lon. |
| Comments |
| Comment by Greg Studer [ 18/Apr/14 ] |
|
With support for GeoJSON, it would be very confusing to allow different long/lat ordering. The ordering is actually designed to make flat/spherical queries transfer more easily given a standard cylindrical projection - "x" corresponds to longitude, "y" corresponds to latitude. |
| Comment by Michael Goulbourn [ 04/Oct/12 ] |
|
I agree this does seem to make it impossible to conduct queries using both of the spherical nature and the non-spherical nature. I'm using queries for within the mapbounds (so a box) which uses lat, lon points and circle queries which use lon, lat, which at present aren't actually possible. |