my request has coordinates that form a polygon.
plist = []
...
plist.append(fromstr('POINT(%s)' %(value)))
...
p = Polygon(plist)
using the GeoDjango I'd like to select all the objects (places.objects.all()
) from a table that are contained in the polygon.
going over the documentation I'm finding ways how to verify if a single point intersect or is contained with the polygon (p.mpoly.contains(pnt)
)but not something that works on a collection of points
is there a way to achieve that or should I use store procedure for that?
I think the GeoQuerySet within filter is what you're looking for:
Assuming that
geom
is your geometry column.Alternatively, you could use contained but this only considers the polygon bounding box, which may be sufficient for you depending on your use case.