Fixed broken .overlaps() query.
This commit is contained in:
parent
04bed12052
commit
abd06fc0e2
|
@ -20,11 +20,11 @@ class FeatureSearchManager(models.GeoManager):
|
|||
def overlaps(self, (minx, miny, maxx, maxy), text=None, srid=4326):
|
||||
bbox = Polygon(((minx,miny),(minx,maxy),(maxx,maxy),(maxx,miny),(minx,miny)),srid=srid)
|
||||
if srid != 4326: bbox.transform(4326) # convert to lon/lat
|
||||
qset = super(FeatureSearchManager, self).get_query_set().filter(geometry__bboverlaps=bbox)
|
||||
qset = models.GeoManager.get_query_set(self).filter(geometry__bboverlaps=bbox)
|
||||
if text:
|
||||
text = text.replace("'", "''") # escape the '
|
||||
# use the pg_trgm index
|
||||
qset = qset.extra(where="[preferred_name %% '%s']" % text)
|
||||
qset = qset.extra(where=["preferred_name %%%% '%s'" % text])
|
||||
return qset
|
||||
|
||||
class Feature(models.Model):
|
||||
|
|
Loading…
Reference in New Issue
Block a user