求两个坐标之间距离
解决方案整理自CSDN问答:http://ask.csdn.net/questions/703
Location对象带和距离相关的方法,求两个坐标距离: public static void distanceBetween (double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results)
Parameters
startLatitude the starting latitude
startLongitude the starting longitude
endLatitude the ending latitude
endLongitude the ending longitude
results 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.htmlandroid
解决方案整理自CSDN问答:http://ask.csdn.net/questions/703
Location对象带和距离相关的方法,求两个坐标距离: public static void distanceBetween (double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results)
Parameters
startLatitude the starting latitude
startLongitude the starting longitude
endLatitude the ending latitude
endLongitude the ending longitude
results 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.htmlandroid
解决方案 »
- 求一个tab导航样式的UI,高分跪求!
- android 自动定位时用 NETWORK_PROVIDER方式获取经纬度
- 怎么修改2.3android系统中的通讯录Contacts
- 怎样在图片下面显示文字啊?求方法或代码?我图片已从数据库中得到病显示了,现在只想将从数据库中得到的电影名字显示在对应的电影图片下面
- wordpress Android客户端
- Android总是报些不知名的错误!!
- opengl 阴影怎么实现?
- 为啥我在4.2模拟器上运行程序弹出的对话框样子还是2.3的样子
- 异常消息处理
- listview 加入 animation 出现重复
- android 如何在彩信中的“幻灯片”中插入文本?
- apn开关可以通过enableDataConnectivity(); 实现,如果有两个卡怎样分别开启数据连接呢?
解决方案整理自CSDN问答:http://ask.csdn.net/questions/703
Location对象带和距离相关的方法,求两个坐标距离: public static void distanceBetween (double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results)
Java code?