I found a Python version of the link you posted: >>> loc = GeoLocation.from_degrees(51.441642, 5.469722) >>> distance = 1000 # 1 kilometer >>> SW_loc, NE_loc = loc.bounding_locations(distance) >>> print SW_loc >>> print NE_loc >>> print loc.distance_to(SW_loc) >>> print loc.distance_to(NE_loc)
This function should create a box. Now this is the output in my terminal: (42.4584deg, -9.0379deg) = (0.741040rad, -0.157741rad) (60.4248deg, 19.9773deg) = (1.054613rad, 0.348670rad) 1483.52131402 1342.64671093 Also, I saw this post. My guess is that I should do the following: > Get the logged in users geo information (lat and long) > Get the distance away that I want to search around that person and > calculate the lat and logitudes of that area... > Find if the lat and log of the items.lat and items.long in my database are > within the regions of the users.lat and users.log and the (areas.lat and > areas.long)* for for four directions. > What values do i need to use in my query? On Fri, Nov 29, 2013 at 3:26 PM, Oscar Fonts <[email protected]> wrote: > Hi Ruud, > > > > when I fetch the records, i only want those records which have a > distance *equal to or below the given distance*. > > The usual technique in the geospatial world is to first select the points > from the containing rectangle (bounding box, or BBOX), which is a much > simpler calculation that helps discard most of the unwanted points. Then > calculate the distance against the points inside that BBOX. Something like: > > SELECT * FROM table > WHERE > LAT >= :min_lat > AND LAT <= :max_lat > AND LON >= :min_lon > AND LON <= :max_lon > HAVING (distance_calculation) <= :radius > > The HAVING condition is only checked against the rows satisfying the WHERE > conditions, so it's a good way to refine your selection with an expensive > calculation. > > Obviously you'll want to index LAT and LON fields as well. > > Details on formulae for bbox and distance calculations: > http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates > > > -- > Oscar Fonts > www.geomati.co <http://geomati.co> > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/ahO2ydF7yK0/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

