Skip to content
zouf edited this page Aug 28, 2012 · 2 revisions

A page collecting some of the 'gotchyas'

Location based filtering

Can be VERY tricky. I try to use the Geodjango stuff wherever possible. There appears to be a support-nightmare here. Postgis (different versions) have different features. And these are completely separate in some cases from what's in MySQL. api.views.search_businesses has a lot of examples.

    from django.contrib.gis.measure import D
    from django.contrib.gis.geos.factory import fromstr
    lng = 40
    lat = -71
    pnt = fromstr('POINT( '+str(lng)+' '+str(lat)+')')
    dist_limit = D(mi=5)
    businesses = Business.objects.filter(geom__distance_lte=(pnt,dist_limit)).distance(pnt).order_by('distance')

A very common bug is mistaking latitude and longitude or having the signs flipped. West and South should be negative.

This website has some great info on using geoanchor with Sphinx http://www.zen4ever.com/?tag=sphinx

Clone this wiki locally