简体   繁体   English

根据GPS的地理位置,如何找到给定x米半径内的纬度和经度

[英]Given the geo location from the GPS, how to find the latitude and longitude within a given x meter radius

I was writing an android app and I was wondering if there is any API that helps to plugin a latitude and longitude obtained from the GPS and also plugin a radius R, find the new latitude and longitude with a very high precision. 我正在编写一个android应用程序,我想知道是否有任何API可以帮助插入从GPS获得的纬度和经度,并且还可以插入半径R,以非常高精度找到新的纬度和经度。 Preferably a Java code. 最好是Java代码。 So say for example the current location is curX and curY now within 200 meter radius of this location can be maxX and maxY. 举例来说,假设当前位置是curX和curY,现在该位置半径200米以内的位置可以是maxX和maxY。 So if I have a list of entries, I will print only the entries within the max Range. 因此,如果我有条目列表,我将仅打印最大范围内的条目。 So for comparison to be right, the precision should be high. 因此,为了比较正确,精度应该很高。 Is there any API that can do this? 有没有可以做到这一点的API? Any formula? 有公式吗? (in Java) (在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

try this : 尝试这个 :

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;
}

see this answer How to get city name from latitude and longitude coordinates in Google Maps? 查看此答案如何从Google Maps中的经纬度坐标获取城市名称?

How to change 1 meter to pixel distance? 如何改变1米至像素距离?

I guess you are looking for this method: 我想您正在寻找这种方法:

http://developer.android.com/reference/android/location/Location.html#distanceTo%28android.location.Location%29 http://developer.android.com/reference/android/location/Location.html#distanceTo%28android.location.Location%29

This will compute distance between 2 given locations 这将计算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.

相关问题 如何从给定点(经度,纬度)计算给定半径内的所有点(经度,纬度)? - how to calculate all points(longitude,latitude) within a given radius from given point (longitude,latitude)? 从给定的纬度,经度和半径值中查找java中的最小和最大纬度和经度 - Find min and max latitude and longitude in java from given latitude , longitude and radius values 查找距给定 Lat Lng 位置一定距离内的所有纬度经度位置 - find all Latitude Longitude locations within a certain distance from a given Lat Lng location 使用Java程序查找具有指定半径的给定纬度(即位置)周围的纬度和纬度值 - Find surrounding the latitude and latitude values of given latitude and longitude(i.e: location) with specified radius using java program 给定点与点之间的距离,如何从给定点查找其纬度和经度? - How to find the latitude and longitude of a point from a given point, given the distance between the two? 获得给定半径(米)和位置的最大经度和经度 - Get the max latitude and longitude given radius (meters) and position 通过给定的x和y笛卡尔点和以米为单位的半径计算面积 - Calculate area by given x and y Cartesian Point and radius in meter 如何在美国将给定纬度经度映射到州际 - How to map given latitude longitude to interstate in USA 如何找到半径为16(x; z)的给定点的中心点? - How to find center dots of given dots in radius of 16 (x;z)? 给定纬度和经度点,找到边缘点和多边形区域 - given latitude and longitude points, find edge points and polygon area
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM