0

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. Preferably a Java code. So say for example the current location is curX and curY now within 200 meter radius of this location can be maxX and 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? Any formula? (in 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
Cœur
  • 34,719
  • 24
  • 185
  • 251
ExceptionHandler
  • 205
  • 1
  • 8
  • 22
  • Is this what you want? Among a given Set S of locations find those locations L within a radius R of a given location CURRENT, and among L find the location with the greatest distance to CURRENT. – Stefan Mar 01 '12 at 08:06
  • @Stefan Your rephrasing is partially right. As in, find L within a Radius R of given location CURRENT. This much is my main objective. – ExceptionHandler Mar 01 '12 at 08:09
  • Ok, then the answer from Gabriel Negut (see below) solves your problem, I guess. – Stefan Mar 01 '12 at 08:50
  • See my answer here: http://gis.stackexchange.com/a/21100/6020 – TreyA Mar 01 '12 at 15:59

3 Answers3

1

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?

How to change 1 meter to pixel distance?

Community
  • 1
  • 1
Shruti
  • 8,785
  • 12
  • 54
  • 93
0

I guess you are looking for this method:

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

This will compute distance between 2 given locations

Konstantin Pribluda
  • 12,178
  • 1
  • 28
  • 35
0
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;
}
Gabriel Negut
  • 13,422
  • 4
  • 36
  • 44