Ejemplo n.º 1
0
def fetch_country_boundaries(request, country):
    """
    Fetch country boundaries
    """
    t1 = time.time()

    if request.method == 'GET':
        print(country)
        gadm = Boundary.objects.all().filter(country=country)
        #print type(gadm[0].geo_json)
        gj = gadm[0].geo_json
        #print(gj)
        point = (float(request.query_params["lon"]),
                 float(request.query_params["lat"]))
        geo = Geo()
        dist = geo.find_district(point, gj)
        t2 = time.time()
        print("%f seconds" % (t2 - t1))
        return Response(dist)