Exemplo n.º 1
0
def lookupBounds(request):
    nwpoint = request.GET.get('nw')
    sepoint = request.GET.get('se')
    if nwpoint.find(',') < 0 or sepoint.find(',') < 0:
        return HttpResponseBadRequest('Malformed coordinates')
    xmin, ymax = [float(x) for x in nwpoint.split(',')]
    xmax, ymin = [float(x) for x in sepoint.split(',')]
    bbox = (xmin, ymin, xmax, ymax)
    dispatch = placeListToFeatureCollection(
        Place.objects.filter(location__contained = Polygon.from_bbox(bbox)))
    return HttpResponse(geojson.dumps(dispatch), content_type = 'application/json')
Exemplo n.º 2
0
def lookupAround(request):
    center = request.GET.get('center')
    radius = request.GET.get('radius')
    if center.find(',') < 0:
        return HttpResponseBadRequest('Malformed center coordinates')
    centerx, centery = [float(x) for x in center.split(',')]

    dispatch = placeListToFeatureCollection(
        Place.objects.filter(location__distance_lt=(Point(centerx, centery),
                                                    D(m=radius))))

    return HttpResponse(geojson.dumps(dispatch), content_type = 'application/json')
Exemplo n.º 3
0
def lookupToken(request, key, value):
    dispatch = placeListToFeatureCollection(
        Place.objects.filter(placetoken__key = key, placetoken__value = value))
    return HttpResponse(geojson.dumps(dispatch), content_type = 'application/json')