Esempio n. 1
0
    def test_filter_polygons(self):

        def ids(objects):
            return set(ob.id for ob in objects)

        poly1 = save_polygon(json.dumps(poly_data_1))
        poly2 = save_polygon(json.dumps(poly_data_2))

        assert ids(filter_polygons(1, 1, 0, 0)) == ids([])
        assert ids(filter_polygons(100, 0, 100, 0)) == ids([poly1, poly2])
        assert ids(filter_polygons(15, 0, 100, 0)) == ids([poly1])
        assert ids(filter_polygons(19, 18, 100, 0)) == ids([])
        assert ids(filter_polygons(22, 15, 22, 12)) == ids([poly1, poly2])
Esempio n. 2
0
 def read(self, request):
     """ Return all polygons inside bbox coords, default limit 50 """
     polygons = filter_polygons(**request.form.cleaned_data)
     polygon_ids = [polygon.id for polygon in polygons.all()[:50]]
     return Lan.objects.filter(geo__in=polygon_ids).all()