GPS coordinates within certain radius based on current location

by Martijn van der Plaat » Fri, 04 Sep 2009 01:44:37 GMT


Sponsored Links
 Dear all,

In my application I have a list of +400 GPS coordinates which I
retrieve from addresses. The application should give me the top X
nearest coordinates based on my current location.

This application is possible (I think) with the distanceBetween
function. But (I think) the application is really inefficient when i
iterate through the list of 400 coordinates and check the distance
within a certain time interval.
Another option is (I think) the proximityAlert function? All
coordinates are loaded in this function and when my current location
comes in the radius of a coordinate an alert is given. But the
downside of this solution (I think) is the high memory usage which
implies a short battery life of the Android phone?

Please can anybody help me to make the right decision?

Greets,
Martijn

--~--~---------~--~----~------------~-------~--~----~



GPS coordinates within certain radius based on current location

by String » Fri, 04 Sep 2009 04:43:36 GMT


 This is a common problem in GIS. I'd suggest doing a simple check for
whether each point is within a simple lat/lon box - that should be
fast enough with only 400 points, and should narrow down the list
enough to be able to check the distance on just those few.

If you're doing this a lot, put the data in SQLite with indexes on lat
& lon; that way you can do this initial "box" query easily &
efficiently.

String



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


GPS coordinates within certain radius based on current location

by gjs » Fri, 04 Sep 2009 14:49:19 GMT


 Hi,

There is a description about a GeoBox algorithm & some python source
code located here -

 http://code.google.com/appengine/articles/geosearch.html 

Regards




--~--~---------~--~----~------------~-------~--~----~



GPS coordinates within certain radius based on current location

by Martijn van der Plaat » Fri, 04 Sep 2009 16:40:48 GMT


 Thank you Gary,

Is it true that, when i use SQLite and not the Google App Engine, the
first algorithm in that GeoBOX story is good enough, because i dont
use App Engine?

SELECT *
FROM Business
WHERE Lat > (position_lat - d) AND
      Lat < (position_lat + d) AND
      Lon > (position_lon - d) AND
      Lon < (position_lon + d);

Last thing i need to know is how to calculate the variable "d" in the
above query, if the box is -say- a 1 mile radius.

Greets,
Martijn






--~--~---------~--~----~------------~-------~--~----~



GPS coordinates within certain radius based on current location

by Neil » Fri, 04 Sep 2009 17:12:05 GMT


 i Martijn

I did it like this:


private double[] getBoundingBox(final double pLatitude, final
double pLongitude, final int pDistanceInMeters) {

final double[] boundingBox = new double[4];

final double latRadian = Math.toRadians(pLatitude);

final double degLatKm = 110.574235;
final double degLongKm = 110.572833 * Math.cos(latRadian);
final double deltaLat = pDistanceInMeters / 1000.0 / degLatKm;
final double deltaLong = pDistanceInMeters / 1000.0 /
degLongKm;

final double minLat = pLatitude - deltaLat;
final double minLong = pLongitude - deltaLong;
final double maxLat = pLatitude + deltaLat;
final double maxLong = pLongitude + deltaLong;

boundingBox[0] = minLat;
boundingBox[1] = minLong;
boundingBox[2] = maxLat;
boundingBox[3] = maxLong;

return boundingBox;
}


The code is copied from mini_osm.py which you can find here:
http://gagravarr.org/code/


Regards

Neil

http://l6n.org/android/




On Sep 4, 10:39am, Martijn van der Plaat <martijnpl...@gmail.com>
wrote:
--~--~---------~--~----~------------~-------~--~----~



GPS coordinates within certain radius based on current location

by Nils » Sat, 05 Sep 2009 06:02:02 GMT


 nother possibility would to have the 400 points on a server, and then
just upload your own position and let the server do all the
calculations.
/Smartass

On Sep 4, 11:11am, Neil <neilb...@gmail.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Make a call without dial in background

Hi,

Is possible to make a call programaticaly without the dial? I want to
make an app that in background make a call, but i need that don't show
the Dial app, only my own app.

Anyone can help me?

Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~

2. Do we get any event in the Activity when the activity gets re-sized?

Do we get any event in the Activity when the activity gets resized?
like when Virtual keyboard appears on the screen.



Thanks,
AJ
--~--~---------~--~----~------------~-------~--~----~

3. tanya flash ROM magicke hero lag

4. Lupakan BlackBerry, Kini Era Android

5. Remote Process Question

6. Viewing Requests Made by Another App

7. How can I extends InputMethodService and using its feature without setting system keyboard??