Hi 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:39 am, Martijn van der Plaat <[email protected]>
wrote:
> 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
>
> On 4 sep, 08:48, gjs <[email protected]> wrote:
>
> > Hi,
>
> > There is a description about a GeoBox algorithm & some python source
> > code located here -
>
> >http://code.google.com/appengine/articles/geosearch.html
>
> > Regards
>
> > On Sep 4, 6:42 am, String <[email protected]> wrote:
>
> > > 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
>
> > > Martijn van der Plaat wrote:
>
> > > > 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
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to