Beispiel #1
0
def get_tile(request, source: MapSource, z=0, x=0, y=0):
    if not source.is_loaded:
        print(f'Dynamically Loading Data {source.name}', file=sys.stdout)
        source.load()

    img = render_map(source, x=int(x), y=int(y), z=int(z))
    return StreamingHttpResponse(img.to_bytesio(), content_type='image/png')
Beispiel #2
0
def flask_to_tile(source: MapSource, z=0, x=0, y=0):

    if not source.is_loaded:
        print(f'Dynamically Loading Data {source.name}', file=sys.stdout)
        source.load()

    img = render_map(source, x=int(x), y=int(y), z=int(z))
    return send_file(img.to_bytesio(), mimetype='image/png')
Beispiel #3
0
def test_default_to_image(source_func):
    source = source_func()
    img = render_map(source,
                     xmin=-20e6,
                     ymin=-20e6,
                     xmax=20e6,
                     ymax=20e6,
                     width=500,
                     height=500)
    assert isinstance(img, Image)
Beispiel #4
0
def get_image(request, source: MapSource,
              xmin=-20e6, ymin=-20e6,
              xmax=20e6, ymax=20e6,
              height=500, width=500):
    if not source.is_loaded:
        source.load()

    img = render_map(source, xmin=float(xmin), ymin=float(ymin),
                     xmax=float(xmax), ymax=float(ymax),
                     height=int(height), width=int(width))
    return StreamingHttpResponse(img.to_bytesio(), content_type='image/png')
Beispiel #5
0
def flask_to_image(source: MapSource,
                   xmin=-20e6, ymin=-20e6,
                   xmax=20e6, ymax=20e6,
                   height=500, width=500):

    if not source.is_loaded:
        source.load()

    img = render_map(source, xmin=float(xmin), ymin=float(ymin),
                     xmax=float(xmax), ymax=float(ymax),
                     height=int(height), width=int(width))
    return send_file(img.to_bytesio(), mimetype='image/png')
Beispiel #6
0
def flask_to_wms(source: MapSource):

    if not source.is_loaded:
        source.load()

    height = request.args.get('height')
    width = request.args.get('width')
    bbox = request.args.get('bbox')
    xmin, ymin, xmax, ymax = bbox.split(',')
    img = render_map(source, xmin=float(xmin), ymin=float(ymin),
                     xmax=float(xmax), ymax=float(ymax),
                     height=int(height), width=int(width))
    return send_file(img.to_bytesio(), mimetype='image/png')
Beispiel #7
0
def get_wms(request, source: MapSource):

    if not source.is_loaded:
        source.load()

    height = request.GET.get('height')
    width = request.GET.get('width')
    bbox = request.GET.get('bbox', '')
    xmin, ymin, xmax, ymax = bbox.split(',')
    img = render_map(source, xmin=float(xmin), ymin=float(ymin),
                     xmax=float(xmax), ymax=float(ymax),
                     height=int(height), width=int(width))
    return StreamingHttpResponse(img.to_bytesio(), content_type='image/png')
Beispiel #8
0
def test_tile_render_edge_effects():
    source = MapSource.from_obj(elevation_source()).load()

    # this tile was bad...
    agg = create_agg(source, x=10, y=11, z=5)

    first_col = agg.data[:, 0]
    last_col = agg.data[:, -1]
    top_row = agg.data[0, :]  # TODO: do i have these flipped?
    bottom_row = agg.data[-1, :]

    assert np.all(~np.isnan(first_col))
    assert np.all(~np.isnan(last_col))
    assert np.all(~np.isnan(top_row))
    assert np.all(~np.isnan(bottom_row))

    img = render_map(source, x=10, y=11, z=5)
    assert isinstance(img, Image)
Beispiel #9
0
def test_default_to_tile(source_func):
    source = source_func()
    img = render_map(source, x=0, y=0, z=0)
    assert isinstance(img, Image)
Beispiel #10
0
def test_default_to_tile(source_func):
    source = MapSource.from_obj(source_func()).load()
    img = render_map(source, x=0, y=0, z=0, height=256, width=256)
    assert isinstance(img, Image)
def flask_to_tile(source, z=0, x=0, y=0):
    img = render_map(source, x=int(x), y=int(y), z=int(z))
    return send_file(img.to_bytesio(), mimetype='image/png')