MongoDB geo distance/radius to useful units

前端 未结 3 771
感情败类
感情败类 2021-02-10 00:41

I\'m using MongoDB geospatial queries -- $near, geoNear, etc. -- and I\'d like to know how to turn the dis result of the geoNear

3条回答
  •  礼貌的吻别
    2021-02-10 01:30

    if your data is in geographic coordinates (i.e. 30.47921 N -121.45724 W) then you need to convert your underlying projection with the units you want (choose a projection that preserves distance) or you need to convert the distance in coordinates to something like miles.

    Use the Haversine formula for calculations http://www.movable-type.co.uk/scripts/latlong.html

提交回复
热议问题