Skip to content

Commit

Permalink
Fix add raster fit_bounds bug (#836)
Browse files Browse the repository at this point in the history
* Fix add raster bug

* Fix Layer Editor bug
  • Loading branch information
giswqs authored Jul 19, 2024
1 parent 32392ea commit 767e0e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
13 changes: 2 additions & 11 deletions leafmap/leafmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2369,19 +2369,11 @@ def add_raster(
tile_layer.visible = visible

self.add(tile_layer, index=layer_index)
bounds = tile_client.bounds() # [ymin, ymax, xmin, xmax]
bounds = (
bounds[2],
bounds[0],
bounds[3],
bounds[1],
) # [minx, miny, maxx, maxy]
if zoom_to_layer:
self.zoom_to_bounds(bounds)
self.center = tile_client.center()
self.zoom = tile_client.default_zoom

arc_add_layer(tile_layer.url, layer_name, True, 1.0)
if zoom_to_layer:
arc_zoom_to_extent(bounds[0], bounds[1], bounds[2], bounds[3])

if not hasattr(self, "cog_layer_dict"):
self.cog_layer_dict = {}
Expand All @@ -2400,7 +2392,6 @@ def add_raster(
"indexes": indexes,
"vis_bands": vis_bands,
"band_names": tile_client.band_names,
"bounds": bounds,
"vmin": vmin,
"vmax": vmax,
"nodata": nodata,
Expand Down
28 changes: 14 additions & 14 deletions leafmap/map_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,21 @@ def on_apply_click(self):

self._host_map.remove(old_layer)

if self._layer_dict["type"] == "LOCAL":
self._host_map.add_raster(
self._filename,
indexes=vis["indexes"],
colormap=vis["colormap"],
vmin=vis["vmin"],
vmax=vis["vmax"],
opacity=vis["opacity"],
nodata=self._nodata,
layer_name=self._layer_name,
zoom_to_layer=False,
layer_index=layer_index,
)
# Add support for hyperspectral data via HyperCoast
if self._xds is not None:
elif self._xds is not None:
self._host_map.add_hyper(
self._xds,
type=self._layer_dict["hyper"],
Expand Down Expand Up @@ -907,19 +920,6 @@ def on_apply_click(self):
fit_bounds=False,
layer_index=layer_index,
)
else:
self._host_map.add_raster(
self._filename,
indexes=vis["indexes"],
colormap=vis["colormap"],
vmin=vis["vmin"],
vmax=vis["vmax"],
opacity=vis["opacity"],
nodata=self._nodata,
layer_name=self._layer_name,
zoom_to_layer=False,
layer_index=layer_index,
)

def _remove_control(key):
if widget := self._layer_dict.get(key, None):
Expand Down

0 comments on commit 767e0e7

Please sign in to comment.