![](/img/trans.png)
[英]how to calculate all points(longitude,latitude) within a given radius from given point (longitude,latitude)?
[英]Given the geo location from the GPS, how to find the latitude and longitude within a given x meter radius
我正在编写一个android应用程序,我想知道是否有任何API可以帮助插入从GPS获得的纬度和经度,并且还可以插入半径R,以非常高精度找到新的纬度和经度。 最好是Java代码。 举例来说,假设当前位置是curX和curY,现在该位置半径200米以内的位置可以是maxX和maxY。 因此,如果我有条目列表,我将仅打印最大范围内的条目。 因此,为了比较正确,精度应该很高。 有没有可以做到这一点的API? 有公式吗? (在Java中)
So the function is
findNewLatitude(curLat,curLong,oldList,radius)
{
do bla bla bla; //Find a newList with respect to current Geo points on MAP and considering the radius
}
output: newList such that distance between (lat,long) in newList and
(curLat,curLong) is equal to radius
尝试这个 :
Geocoder coder = new Geocoder(this);
List<Address> address;
try {
address = coder.getFromLocationName(strAddress,5);
if (address == null) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
return p1;
}
我想您正在寻找这种方法:
这将计算2个给定位置之间的距离
List<Location> filter(Location current, List<Location> locations, int radius) {
List<Location> results = new ArrayList<Location>();
for (Location loc : locations) {
if (current.distanceTo(loc) <= radius) {
results.add(loc);
}
}
return results;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.