android中求区域内两个座标之间的距离的实现
android中求区域内两个坐标之间的距离的实现
求两个坐标之间距离
解决方案整理自****问答:http://ask.****.net/questions/703
Location对象带和距离相关的方法,求两个坐标距离: public static void distanceBetween (double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results)
详细解释见这里: distanceBetween(double, double, double, double, float[])
在大量坐标之间找最近距离的坐标
如果你用Mongodb,获取最近的坐标很简单,Mongodb自带geoNearCommand,可以参照这里:GeospatialIndexing-geoNearCommand
求两个坐标之间距离
解决方案整理自****问答:http://ask.****.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"),