Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Sep 13, 2024
1 parent becde0a commit 54be7dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 3 additions & 4 deletions localtileserver/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from collections.abc import Iterable
import json
import logging
import pathlib
from typing import List, Optional, Union
from matplotlib.colors import Colormap

from matplotlib.colors import Colormap
import rasterio
import requests
from rio_tiler.io import Reader
Expand Down Expand Up @@ -442,16 +443,14 @@ def get_tile_url(
The value from the band to use to interpret as not valid data.
"""
import json
# First handle query parameters to check for errors
params = {}
if indexes is not None:
params["indexes"] = indexes
if colormap is not None:

if isinstance(colormap, Colormap):
colormap = json.dumps(
{k:tuple(v.tolist()) for k,v in enumerate(colormap(range(256),1,1))}
{k: tuple(v.tolist()) for k, v in enumerate(colormap(range(256), 1, 1))}
)
elif isinstance(colormap, list):
colormap = json.dumps(colormap)
Expand Down
7 changes: 4 additions & 3 deletions localtileserver/tiler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,19 @@ def _render_image(
img_format: str = "PNG",
):
import json

from matplotlib.colors import LinearSegmentedColormap

if colormap in cmap.list():
colormap = cmap.get(colormap)
elif colormap:
c = json.loads(colormap)
if isinstance(c, list):
c = LinearSegmentedColormap.from_list('', c, N=256)
colormap = {k:tuple(v) for k,v in enumerate(c(range(256),1,1))}
c = LinearSegmentedColormap.from_list("", c, N=256)
colormap = {k: tuple(v) for k, v in enumerate(c(range(256), 1, 1))}
else:
colormap = {}
for key,value in c.items():
for key, value in c.items():
colormap[int(key)] = tuple(value)

if (
Expand Down
2 changes: 1 addition & 1 deletion localtileserver/widgets.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import pathlib
from typing import List, Optional, Union
from matplotlib.colors import Colormap
import warnings

from matplotlib.colors import Colormap
import rasterio

from localtileserver.client import TileClient, get_or_create_tile_client
Expand Down

0 comments on commit 54be7dc

Please sign in to comment.