Friday, 15 July 2011

django - GeoDjango Bounding Box Filter with top and bottom coordinates -



django - GeoDjango Bounding Box Filter with top and bottom coordinates -

i'm creating geo app google maps , receive bounding box 2 coordinates: top left(top_lat,top_long) , bottom right (bot_lat, bot_long)

i have model pointfield.

from django.contrib.gis.db import models class shop(models.model): name = models.charfield(max_length=200) address = models.charfield(max_length=200) location = models.pointfield()

create bounding box tuple:

bbox = (top_lat,top_long, bot_lat, bot_long) geom = polygon.from_bbox(bbox)

i using bounding box geometry:

shops = shop.objects.filter(location__bbcontains=geom)

but not find coordinates, although there coordinates. please help me solve problems. thanks

your filter incorrect.

location__bbcontains=geom means geometry field (location, point) bounding box must contain bounding box created (geom, polygon). , pretty much false every time since polygon bigger bbox single point.

you're looking have: location__inside=geom returns locations within geom.

django geodjango

No comments:

Post a Comment