mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Fix additional geotiff display.
parent
7d7a05c04c
commit
32cbc6bc3e
|
|
@ -68,6 +68,9 @@ class PlotXY(PamhyrPlot):
|
||||||
|
|
||||||
self._plot_img = {}
|
self._plot_img = {}
|
||||||
|
|
||||||
|
self._geotiff_img = []
|
||||||
|
self._geotiff_bounds = []
|
||||||
|
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self._timestamps = parent._timestamps
|
self._timestamps = parent._timestamps
|
||||||
self._current_timestamp = max(self._timestamps)
|
self._current_timestamp = max(self._timestamps)
|
||||||
|
|
@ -203,7 +206,6 @@ class PlotXY(PamhyrPlot):
|
||||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
self.canvas.axes.add_collection(self.line_xy_collection)
|
||||||
|
|
||||||
def draw_other_profiles(self, reaches):
|
def draw_other_profiles(self, reaches):
|
||||||
|
|
||||||
for reach in reaches:
|
for reach in reaches:
|
||||||
for xy in zip(reach.geometry.get_x(),
|
for xy in zip(reach.geometry.get_x(),
|
||||||
reach.geometry.get_y()):
|
reach.geometry.get_y()):
|
||||||
|
|
@ -325,6 +327,24 @@ class PlotXY(PamhyrPlot):
|
||||||
alpha=0.7
|
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):
|
def draw_geotiff(self):
|
||||||
if not _rasterio_loaded:
|
if not _rasterio_loaded:
|
||||||
return
|
return
|
||||||
|
|
@ -361,6 +381,7 @@ class PlotXY(PamhyrPlot):
|
||||||
if not geotiff.is_enabled():
|
if not geotiff.is_enabled():
|
||||||
self._plot_img[geotiff].set(alpha=0.5)
|
self._plot_img[geotiff].set(alpha=0.5)
|
||||||
|
|
||||||
|
self.draw_add_geotiff()
|
||||||
self.idle()
|
self.idle()
|
||||||
|
|
||||||
def set_reach(self, reach_id):
|
def set_reach(self, reach_id):
|
||||||
|
|
|
||||||
|
|
@ -1284,24 +1284,22 @@ class ResultsWindow(PamhyrWindow):
|
||||||
# b[1] bottom
|
# b[1] bottom
|
||||||
# b[2] right
|
# b[2] right
|
||||||
# b[3] top
|
# b[3] top
|
||||||
|
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()
|
xlim = self.canvas.axes.get_xlim()
|
||||||
ylim = self.canvas.axes.get_ylim()
|
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:
|
|
||||||
dlg = CoordinatesDialog(
|
dlg = CoordinatesDialog(
|
||||||
xlim, ylim,
|
xlim, ylim,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
if dlg.exec():
|
if dlg.exec():
|
||||||
self.canvas.axes.imshow(img.transpose((1, 2, 0)),
|
bounds = dlg.values
|
||||||
extent=dlg.values)
|
|
||||||
self.plot_xy.idle()
|
self.plot_xy.add_geotiff(img, bounds)
|
||||||
self.canvas.axes.set_xlim(xlim)
|
self.plot_xy.draw_add_geotiff()
|
||||||
self.canvas.axes.set_ylim(ylim)
|
|
||||||
return
|
|
||||||
|
|
||||||
def import_data(self):
|
def import_data(self):
|
||||||
file_types = [
|
file_types = [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue