Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly fix legend issue in develop. #2009

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ def render_new_permission(self, op_id, u_id):
operation_desc = f'{operation["path"]} - {operation["access_level"]}'
widgetItem = QtWidgets.QListWidgetItem(operation_desc, parent=self.ui.listOperationsMSC)
widgetItem.op_id = operation["op_id"]
widgetItem.catgegory = operation["category"]
widgetItem.operation_category = operation["category"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and also in stable I wonder what it means that we don't have seen a failure popping up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, you can assign whatever you want as an attribute (yeah, duck-typing!)

widgetItem.operation_path = operation["path"]
widgetItem.access_level = operation["access_level"]
widgetItem.active_operation_description = operation["description"]
Expand Down Expand Up @@ -1575,11 +1575,11 @@ def add_operations_to_ui(self):
for operation in operations:
operation_desc = f'{operation["path"]} - {operation["access_level"]}'
widgetItem = QtWidgets.QListWidgetItem(operation_desc)
widgetItem.active_operation_description = operation["description"]
widgetItem.op_id = operation["op_id"]
widgetItem.access_level = operation["access_level"]
widgetItem.operation_path = operation["path"]
widgetItem.operation_category = operation["category"]
widgetItem.operation_path = operation["path"]
widgetItem.access_level = operation["access_level"]
widgetItem.active_operation_description = operation["description"]
try:
# compatibility to 7.x
# a newer server can distinguish older operations and move those into inactive state
Expand Down
33 changes: 15 additions & 18 deletions mslib/msui/wms_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,24 +1478,21 @@ def append_multiple_images(self, imgs):
"""
images = [x for x in imgs if x]
if images:
if hasattr(self.view, 'fig') is False:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was needed before not to crash on a different attribute than 'fig'

https://geoportal2.duisburg.de/arcgisserver/services/Luftbilder/Historische_Luftbilder/MapServer/WMSServer

now it crashes on

Fatal error in MSS 8.3.0 on Linux-6.2.0-10018-tuxedo-x86_64-with-glibc2.35
Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:23:14) [GCC 10.4.0]

Please report bugs in MSS to https://github.com/Open-MSS/MSS

Information about the fatal error:

Traceback (most recent call last):
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 1383, in continue_retrieve_image
    self.display_retrieved_image(img, legend_img, layer, style, init_time, valid_time, complete_level)
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 1629, in display_retrieved_image
    self.view.draw_legend(self.append_multiple_images(legend_imgs))
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 1484, in append_multiple_images
    max_height = int((self.view.plotter.fig.get_size_inches() * self.view.plotter.get_dpi())[1] * 0.99)
AttributeError: 'TopViewPlotter' object has no attribute 'get_dpi'

see also
#1803

QtWidgets.QMessageBox.warning(self, self.tr("Web Map Service"), "We have only fig implemented")
else:
# Add border around seperate legends
if len(images) > 1:
images = [ImageOps.expand(x, border=1, fill="black") for x in images]
max_height = int((self.view.plotter.get_size_inches() * self.view.plotter.get_dpi())[1] * 0.99)
width = max([image.width for image in images])
height = sum([image.height for image in images])
result = Image.new("RGBA", (width, height))
current_height = 0
for i, image in enumerate(images):
result.paste(image, (0, current_height - i))
current_height += image.height

if max_height < result.height:
result.thumbnail((result.width, max_height), Image.ANTIALIAS)
return result
# Add border around seperate legends
if len(images) > 1:
images = [ImageOps.expand(x, border=1, fill="black") for x in images]
max_height = int((self.view.plotter.fig.get_size_inches() * self.view.plotter.fig.get_dpi())[1] * 0.99)
width = max([image.width for image in images])
height = sum([image.height for image in images])
result = Image.new("RGBA", (width, height))
current_height = 0
for i, image in enumerate(images):
result.paste(image, (0, current_height - i))
current_height += image.height

if max_height < result.height:
result.thumbnail((result.width, max_height), Image.ANTIALIAS)
return result


class VSecWMSControlWidget(WMSControlWidget):
Expand Down