Details
-
Improvement
-
Resolution: Won't Do
-
Minor - P4
-
None
-
None
Description
There are discrepancies on the units used for various fields for $geoNear.
The description for the distanceMultiplier field for $geoNear says
The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth.
Also, the description for minDistance says,
Specify the distance in meters for GeoJSON data and in radians for legacy coordinate pairs
however a 2dsphere index will convert legacy coordinate pairs to GeoJSON Point. So I can have a field like this:
"p": [ -100.8, 33.1875 ]
|
whose 2dsphere index will convert it into
{ type: "Point", coordinates: [ -100.8, 33.1875 ] }
|
such that I can specify minDistance in meters even though the documentation says it should be in radians.
The near field sheds some light:
If using a 2dsphere index, you can specify the point as either a GeoJSON point or legacy coordinate pair. If using a 2d index, specify the point as a legacy coordinate pair.
So the main factor appears to be the index used (2dsphere vs 2d) instead of whether the point is GeoJSON or legacy coordinate pair.
Comment on: "reference/operator/aggregation/geoNear.txt"