Пример #1
0
def raw_points(latitude, longitude, radius, points):
    res = geo.points_on_a_radius(float(latitude), float(longitude), float(radius), int(points))
    p = [Point(x[0], x[1]).__dict__ for x in res]
    p = json.dumps(p)
    output = make_response(p)
    output.headers["Content-type"] = "application/json"
    return output
Пример #2
0
def points():
    form = PointsInRadiusForm()
    if form.validate_on_submit():
        app.logger.info('user submitted: Latitude: {0}, Longitude: {1}, Radius: {2}, Number of Points: {3}'
                        .format(form.latitude.data, form.longitude.data, form.radius.data, form.num_of_points.data))
        res = geo.points_on_a_radius(form.latitude.data, form.longitude.data, form.radius.data, form.num_of_points.data)
        app.logger.info('obtained results')
        app.logger.info('writing to csv')
        si = StringIO.StringIO()
        cw = csv.writer(si)
        cw.writerow(['longitude', 'latitude'])
        cw.writerows(res)
        output = make_response(si.getvalue())
        output.headers["Content-Disposition"] = "attachment; filename=%s" % name_generator()
        output.headers["Content-type"] = "text/csv"
        output.headers["Location"] = "/"
        app.logger.info('returning the results')
        return output