Results: Fix additional geotiff display.

scenarios
Pierre-Antoine 2026-06-16 17:27:29 +02:00
parent 7d7a05c04c
commit 32cbc6bc3e
2 changed files with 32 additions and 13 deletions

View File

@ -68,6 +68,9 @@ class PlotXY(PamhyrPlot):
self._plot_img = {}
self._geotiff_img = []
self._geotiff_bounds = []
self._parent = parent
self._timestamps = parent._timestamps
self._current_timestamp = max(self._timestamps)
@ -203,7 +206,6 @@ class PlotXY(PamhyrPlot):
self.canvas.axes.add_collection(self.line_xy_collection)
def draw_other_profiles(self, reaches):
for reach in reaches:
for xy in zip(reach.geometry.get_x(),
reach.geometry.get_y()):
@ -325,6 +327,24 @@ class PlotXY(PamhyrPlot):
alpha=0.7
)
def add_geotiff(self, img, bounds):
self._geotiff_img.append(img)
self._geotiff_bounds.append(bounds)
def draw_add_geotiff(self):
xlim = self.canvas.axes.get_xlim()
ylim = self.canvas.axes.get_ylim()
for i, img in enumerate(self._geotiff_img):
bounds = self._geotiff_bounds[i]
self.canvas.axes.imshow(img.transpose((1, 2, 0)),
extent=bounds)
self.idle()
self.canvas.axes.set_xlim(xlim)
self.canvas.axes.set_ylim(ylim)
def draw_geotiff(self):
if not _rasterio_loaded:
return
@ -361,6 +381,7 @@ class PlotXY(PamhyrPlot):
if not geotiff.is_enabled():
self._plot_img[geotiff].set(alpha=0.5)
self.draw_add_geotiff()
self.idle()
def set_reach(self, reach_id):

View File

@ -1284,24 +1284,22 @@ class ResultsWindow(PamhyrWindow):
# b[1] bottom
# b[2] right
# b[3] top
xlim = self.canvas.axes.get_xlim()
ylim = self.canvas.axes.get_ylim()
if b[2] > b[0] and b[1] < b[3]:
self.canvas.axes.imshow(img.transpose((1, 2, 0)),
extent=[b[0], b[2], b[1], b[3]])
else:
bounds = [b[0], b[2], b[1], b[3]]
if not (b[2] > b[0] and b[1] < b[3]):
xlim = self.canvas.axes.get_xlim()
ylim = self.canvas.axes.get_ylim()
dlg = CoordinatesDialog(
xlim, ylim,
trad=self._trad,
parent=self
)
if dlg.exec():
self.canvas.axes.imshow(img.transpose((1, 2, 0)),
extent=dlg.values)
self.plot_xy.idle()
self.canvas.axes.set_xlim(xlim)
self.canvas.axes.set_ylim(ylim)
return
bounds = dlg.values
self.plot_xy.add_geotiff(img, bounds)
self.plot_xy.draw_add_geotiff()
def import_data(self):
file_types = [