Esempio n. 1
0
def test_rastertiles_tile_exists_false():
    """Should work as expected (create rastertiles object and check if tile exists)."""
    r = RasterTiles(raster_path)
    z = 18
    x = 8240
    y = 119094
    assert not r.tile_exists(z, x, y)
Esempio n. 2
0
def test_rastertiles_get_bounds():
    """Should work as expected (create rastertiles object and get bounds)."""
    r = RasterTiles(raster_path)
    assert r.get_bounds() == [
        -61.56738281249997,
        16.225223624120076,
        -61.5618896507246,
        16.23049792684362,
    ]
Esempio n. 3
0
def test_rastertiles_read_tile():
    """Should work as expected (create rastertiles object and read tile)."""
    r = RasterTiles(raster_path)
    z = 18
    x = 86240
    y = 119094
    data, mask = r.read_tile(z, x, y)
    assert data.shape == (3, 512, 512)
    assert mask.shape == (512, 512)
Esempio n. 4
0
def test_rastertiles_read_tile_small():
    """Should work as expected (create rastertiles object and read tile)."""
    r = RasterTiles(raster_path, tiles_size=256)
    z = 18
    x = 86240
    y = 119094
    data, mask = r.read_tile(z, x, y)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)
Esempio n. 5
0
 def get_app(self):
     """Initialize app."""
     r = RasterTiles(raster_ndvi_path, tiles_size=32)
     return TileServer(r,
                       gl_tiles_size=32,
                       scale=((-1, 1), ),
                       colormap="cfastie").app
Esempio n. 6
0
def test_rastertiles_valid_indexes_option():
    """Should work as expected (create rastertiles object)."""
    r = RasterTiles(raster_path, indexes=[1])
    assert r.path == raster_path
    assert r.indexes == [1]
    assert r.tiles_size == 512
    assert not r.nodata
Esempio n. 7
0
def test_TileServer_raster_tilesize():
    """Should work as expected (create TileServer object)."""
    r = RasterTiles(raster_path, tiles_size=256)
    app = TileServer(r)
    assert app.raster == r
    assert not app.server
    assert app.tiles_format == "png"
    assert app.gl_tiles_size == 256
Esempio n. 8
0
def glui(
    path,
    bidx,
    scale,
    colormap,
    tiles_format,
    tiles_dimensions,
    nodata,
    gl_tile_size,
    port,
    playground,
    mapbox_token,
):
    """Rasterio glui cli."""
    if scale and len(scale) not in [1, 3]:
        raise click.ClickException("Invalid number of scale values")

    raster = RasterTiles(path,
                         indexes=bidx,
                         tiles_size=tiles_dimensions,
                         nodata=nodata)

    app = server.TileServer(
        raster,
        scale=scale,
        colormap=colormap,
        tiles_format=tiles_format,
        gl_tiles_size=gl_tile_size,
        gl_tiles_minzoom=raster.get_min_zoom(),
        gl_tiles_maxzoom=raster.get_max_zoom(),
        port=port,
    )

    if playground:
        url = app.get_playground_url()
    else:
        url = app.get_template_url()

    if mapbox_token:
        url = "{}?access_token={}".format(url, mapbox_token)

    click.launch(url)
    click.echo("Inspecting {} at {}".format(path, url), err=True)
    app.start()
Esempio n. 9
0
def test_TileServer_default():
    """Should work as expected (create TileServer object)."""
    r = RasterTiles(raster_path)
    app = TileServer(r)
    assert app.raster == r
    assert app.port == 8080
    assert not app.server
    assert app.tiles_format == "png"
    assert app.gl_tiles_size == 512
    assert app.gl_tiles_minzoom == 0
    assert app.gl_tiles_maxzoom == 22
Esempio n. 10
0
def test_rastertiles_valid():
    """Should work as expected (create rastertiles object)."""
    r = RasterTiles(raster_path)
    assert r.path == raster_path
    assert r.tiles_size == 512
    assert not r.nodata
    assert r.bounds == [
        -61.56738281249997,
        16.225223624120076,
        -61.5618896507246,
        16.23049792684362,
    ]
    assert r.indexes == (1, 2, 3)
    assert r.overiew_levels == [2, 4, 8, 16, 32, 64]
Esempio n. 11
0
def glui(
    path,
    bidx,
    tiles_format,
    tiles_dimensions,
    nodata,
    gl_tile_size,
    port,
    playground,
    mapbox_token,
):
    """Rasterio glui cli."""
    raster = RasterTiles(path,
                         indexes=bidx,
                         tiles_size=tiles_dimensions,
                         nodata=nodata)

    app = server.TileServer(
        raster,
        tiles_format=tiles_format,
        gl_tiles_size=gl_tile_size,
        gl_tiles_minzoom=raster.get_min_zoom(),
        gl_tiles_maxzoom=raster.get_max_zoom(),
        port=port,
    )

    if playground:
        url = app.get_playround_url()
    else:
        url = app.get_template_url()

    if mapbox_token:
        url = "{}?access_token={}".format(url, mapbox_token)

    click.launch(url)
    click.echo("Inspecting {} at {}".format(path, url), err=True)
    app.start()
Esempio n. 12
0
def test_TileServer_options():
    """Should work as expected (create TileServer object)."""
    r = RasterTiles(raster_path)
    app = TileServer(
        r,
        tiles_format="jpg",
        gl_tiles_minzoom=13,
        gl_tiles_maxzoom=19,
        gl_tiles_size=256,
        port=5000,
    )
    assert app.raster == r
    assert app.port == 5000
    assert not app.server
    assert app.tiles_format == "jpg"
    assert app.gl_tiles_size == 256
    assert app.gl_tiles_minzoom == 13
    assert app.gl_tiles_maxzoom == 19
Esempio n. 13
0
def test_TileServer_1b():
    """Should work as expected (create TileServer object)."""
    r = RasterTiles(raster_ndvi_path)
    app = TileServer(
        r,
        tiles_format="jpg",
        gl_tiles_minzoom=13,
        gl_tiles_maxzoom=19,
        gl_tiles_size=256,
        scale=((-1, 1), ),
        colormap="cfastie",
        port=5000,
    )
    assert app.raster == r
    assert app.port == 5000
    assert not app.server
    assert app.tiles_format == "jpg"
    assert app.gl_tiles_size == 256
    assert app.gl_tiles_minzoom == 13
    assert app.gl_tiles_maxzoom == 19
Esempio n. 14
0
def test_rastertiles_valid_size_option():
    """Should work as expected (create rastertiles object)."""
    r = RasterTiles(raster_path, tiles_size=256)
    assert r.path == raster_path
    assert r.tiles_size == 256
    assert not r.nodata
Esempio n. 15
0
def test_rastertiles_invalidcogeo():
    """Should error with invalid Cogeo format."""
    with pytest.raises(Exception):
        RasterTiles(invalid_raster_path)
Esempio n. 16
0
 def get_app(self):
     """Initialize app."""
     r = RasterTiles(raster_path)
     return TileServer(r).app
Esempio n. 17
0
 def get_app(self):
     """Initialize app."""
     r = RasterTiles(raster_path)
     return TileServer(r, scale=((1, 240), )).app
Esempio n. 18
0
def test_TileServer_get_playground_url():
    """Should work as expected (create TileServer object and get playground url)."""
    r = RasterTiles(raster_path)
    app = TileServer(r)
    assert app.get_playground_url() == "http://127.0.0.1:8080/playground.html"
Esempio n. 19
0
def test_TileServer_get_template_url():
    """Should work as expected (create TileServer object and get template url)."""
    r = RasterTiles(raster_path)
    app = TileServer(r)
    assert app.get_template_url() == "http://127.0.0.1:8080/index.html"
Esempio n. 20
0
def test_TileServer_get_tiles_url():
    """Should work as expected (create TileServer object and get tiles endpoint)."""
    r = RasterTiles(raster_path)
    app = TileServer(r)
    assert app.get_tiles_url() == "http://127.0.0.1:8080/tiles/{z}/{x}/{y}.png"
Esempio n. 21
0
def test_rastertiles_valid_nodata_option():
    """Should work as expected (create rastertiles object)."""
    r = RasterTiles(raster_path, nodata=0)
    assert r.path == raster_path
    assert r.nodata == 0
Esempio n. 22
0
def test_rastertiles_get_centers():
    """Should work as expected (create rastertiles object and get center)."""
    r = RasterTiles(raster_path)
    assert r.get_center() == [-61.56463623161228, 16.227860775481847]
Esempio n. 23
0
def test_TileServer_raster_get_center():
    """Should work as expected."""
    r = RasterTiles(raster_path)
    app = TileServer(r)
    assert app.raster == r
    assert app.get_center() == r.get_center()
Esempio n. 24
0
def test_rastertiles_get_min_zoom():
    """Should work as expected (create rastertiles object and get_min_zoom)."""
    r = RasterTiles(raster_path)
    assert r.get_min_zoom() == 12