Skip to content

Commit

Permalink
An improved TileClient that avoids the REST interface where possible (#…
Browse files Browse the repository at this point in the history
…156)

* Improve local use

* Docs updates

* BaseTileClient -> BaseTileClientInterface

* Re-enable rest-based local client

* Bump version to 1.0.0

* Fix data paths
  • Loading branch information
banesullivan authored Jun 3, 2023
1 parent 131c3ea commit e4ce481
Show file tree
Hide file tree
Showing 22 changed files with 641 additions and 76 deletions.
8 changes: 4 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
graft localtileserver/tileserver/static
graft localtileserver/tileserver/templates
graft localtileserver/web/static
graft localtileserver/web/templates
global-exclude *.pyc
graft localtileserver/tileserver/data
exclude localtileserver/tileserver/data/*.aux.xml
graft localtileserver/tiler/data
exclude localtileserver/tiler/data/*.aux.xml
2 changes: 1 addition & 1 deletion doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Python Client
.. autofunction:: localtileserver.get_or_create_tile_client


.. autoclass:: localtileserver.client.BaseTileClient
.. autoclass:: localtileserver.client.BaseTileClientInterface
:members:
:undoc-members:

Expand Down
5 changes: 1 addition & 4 deletions doc/source/user-guide/hillshade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ see in a terrain model. Hillshades are often used as an underlay in a map, to
make the data appear more 3-Dimensional.


This example was adopted from `EarthPy <https://earthpy.readthedocs.io/en/latest/gallery_vignettes/plot_dem_hillshade.html>`_


.. note::

This example requires ``rasterio`` to be installed.
This example was adopted from `EarthPy <https://earthpy.readthedocs.io/en/latest/gallery_vignettes/plot_dem_hillshade.html>`_


.. code:: python
Expand Down
14 changes: 14 additions & 0 deletions doc/source/user-guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ Here is the "one-liner" to visualize a large geospatial image with
The :class:`localtileserver.TileClient` class utilizes the ``_ipython_display_``
method to automatically display the tiles with ``ipyleaflet`` in a Notebook.

You can also get a single tile by:

.. jupyter-execute::

# z, x, y
client.get_tile(10, 163, 395)


And get a thumbnail preview by:

.. jupyter-execute::

client.thumbnail()


🍃 ``ipyleaflet`` Tile Layers
-----------------------------
Expand Down
14 changes: 14 additions & 0 deletions doc/source/user-guide/rasterio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ This will only work when opening a raster in read-mode.
m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m
``localtileserver`` actually uses ``rasterio`` under the hood for everything
and keeps a reference to a ``rasterio.DatasetReader`` for all clients.


.. code-block:: python
from localtileserver import examples
# Load example tile layer from publicly available DEM source
client = examples.get_elevation()
client.rasterio
18 changes: 18 additions & 0 deletions doc/source/user-guide/rgb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ viewing a different set of bands:
# First, create TileClient using example file
client = examples.get_landsat()


.. jupyter-execute::

client.thumbnail(band=[7, 5, 4])


.. jupyter-execute::

client.thumbnail(band=[5, 3, 2])


.. jupyter-execute::

# Create 2 tile layers from same raster viewing different bands
l = get_leaflet_tile_layer(client, band=[7, 5, 4])
r = get_leaflet_tile_layer(client, band=[5, 3, 2])
Expand Down Expand Up @@ -49,6 +62,11 @@ See https://girder.github.io/large_image/tilesource_options.html#style
]
}

client.thumbnail(style=style)


.. jupyter-execute::

l = get_leaflet_tile_layer(client, style=style)

m = Map(center=client.center(), zoom=client.default_zoom)
Expand Down
2 changes: 1 addition & 1 deletion flask.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export FLASK_APP=localtileserver/tileserver/__init__.py
export FLASK_APP=localtileserver/web/__init__.py
export FLASK_ENV=development
2 changes: 1 addition & 1 deletion localtileserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from localtileserver._version import __version__
from localtileserver.client import RemoteTileClient, TileClient, get_or_create_tile_client
from localtileserver.report import Report
from localtileserver.tiler.utilities import get_cache_dir, make_vsi, purge_cache
from localtileserver.tiler import get_cache_dir, make_vsi, purge_cache
from localtileserver.validate import validate_cog
from localtileserver.widgets import (
LocalTileServerLayerMixin,
Expand Down
Loading

0 comments on commit e4ce481

Please sign in to comment.