-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Place open function in dedicated module
- Loading branch information
1 parent
0bffdf3
commit f762f01
Showing
3 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pathlib | ||
from typing import Union | ||
|
||
import rasterio | ||
|
||
from localtileserver.client import TileClient, get_or_create_tile_client | ||
|
||
|
||
def open( | ||
source: Union[ | ||
pathlib.Path, | ||
str, | ||
TileClient, | ||
rasterio.io.DatasetReaderBase, | ||
], | ||
port: Union[int, str] = "default", | ||
debug: bool = False, | ||
): | ||
"""Open a raster file as a TileClient. | ||
Parameters | ||
---------- | ||
source : pathlib.Path, str, TileClient, rasterio.io.DatasetReaderBase | ||
The source dataset to use for the tile client. | ||
port : int | ||
The port on your host machine to use for the tile server. This defaults | ||
to getting an available port. | ||
debug : bool | ||
Run the tile server in debug mode. | ||
""" | ||
return get_or_create_tile_client(source, port=port, debug=debug)[0] |