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. sdk help

hello ,
i will sound very basic but i really dont know.where do we see the
android sdk help about its all classes n api n its sample
application.i installed it on xp but i doesnt found any in my android
folder.looking forward to your reply

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

2. How to switch eclipse logcat from emulator to device and back again

Does anyone know how to get the eclipse logcat output to switch from
emulator to device and back again?

I am often developing, and using emulator and device in tandem, mainly
because I can trace the http comms on the emulator and not on the
device, and logcat gets stuck on whichever is launched first from
eclipse.  Right now the only way to get logcat output switched over is
to restart eclipse, which is a little time-consuming.  Anyone know
another way to achieve the same thing?

Many thanks in advance
CHEERS> SAM
--~--~---------~--~----~------------~-------~--~----~

3. Reloading our Activities State after firing Intent to camera

4. Who will be viewing apps during Round 1 and Round 2 of the ADC2

5. It's not working on USB for Android system building

6. RE : Developing and debugging on HTC Hero

7. String array declared in xml does not accept styling tags <b> <i> <u> ?