求两个坐标之间距离

解决方案整理自CSDN问答:http://ask.csdn.net/questions/703

Location对象带和距离相关的方法,求两个坐标距离:public static void distanceBetween (double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results)

ParametersstartLatitude   the starting latitudestartLongitude  the starting longitudeendLatitude the ending latitudeendLongitude    the ending longituderesults an array of floats to hold the results

详细解释见这里:distanceBetween(double, double, double, double, float[])

在大量坐标之间找最近距离的坐标

如果你用Mongodb,获取最近的坐标很简单,Mongodb自带geoNearCommand,可以参照这里:GeospatialIndexing-geoNearCommand

> db.runCommand( { geoNear : "places" , near : [50,50], num : 10 } );> db.runCommand({geoNear:"asdf", near:[50,50]}){        "ns" : "test.places",        "near" : "1100110000001111110000001111110000001111110000001111",        "results" : [                {                        "dis" : 69.29646421910687,                        "obj" : {                                "_id" : ObjectId("4b8bd6b93b83c574d8760280"),                                "y" : [                                        1,                                        1                                ],                                "category" : "Coffee"                        }                },                {                        "dis" : 69.29646421910687,                        "obj" : {                                "_id" : ObjectId("4b8bd6b03b83c574d876027f"),                                "y" : [                                        1,                                        1                                ]                        }                }        ],        "stats" : {                "time" : 0,                "btreelocs" : 1,                "btreelocs" : 1,                "nscanned" : 2,                "nscanned" : 2,                "objectsLoaded" : 2,                "objectsLoaded" : 2,                "avgDistance" : 69.29646421910687        },        "ok" : 1}

PS. 这里有很多计算GEO距离相关的公式:http://www.movable-type.co.uk/scripts/latlong.html

更多相关文章

  1. android aidl通讯两个APP之间的应用
  2. 通话距离感应实现源码
  3. android view的触摸事件坐标
  4. Android 坐标系统
  5. 学个明白--Android世界的坐标系
  6. Android简单实现加减乘除(两个EditText,两个TextView,四个button)
  7. android获取gps坐标
  8. LinearLayout中实现水平方向上的两个textview一个居左,一个居右的
  9. Android View系列 - 坐标系

随机推荐

  1. JavaScript - 检查是否在全局上下文中
  2. 将一个youtube iframe放在另一个具有关闭
  3. 隐藏时如何暂停jquery计时器
  4. res.json返回无意中修改的输入
  5. Aptana Studio 3 IDE中有运行JavaScript
  6. 使用异步库汇编数据库中的所有标记
  7. 在angularjs中动态添加/删除checked属性
  8. HTML最简单的隐藏/显示和类过滤器
  9. javascript阻塞加载问题【转】
  10. AngularJS:登录cookie过期时如何注销