Skip to content

unexpected behaviour for version 0.5 and polygon intersection #17

Description

@luca-penasa

I noticed a slightly "unexpected" behaviour in version 0.5, not present in version 0.4.4.

Issue

the user need to press Define polygon style prior to Intersect in the polygon intersection dialog. Otherwise there is an unhandled KeyError that qProf does not intercept correctly.
This behaviour is unexpected for 1) the unhandled exception 2) in version 0.4.4 it was working differently (so the user would expect the same behavior).

Details

When the user performs a polygon intersection the dictionary holding the unit-to-color conversion (i.e. the content of plot_addit_params["polygon_class_colors"]) is empty until the user presses Define polygon style and accepts the style.

It is my understanding that this step was not needed in version 0.4.4. So I thought this is an unwanted effect of latest changes worth of reporting.

The issue I believe is that if the user do not perform the color assignment by hand the qProf raises a KeyError as it is then assuming the dict is populated correctly. As this error does not help much the user in understanding what he/she is missing the default behaviour could be to just generate the default color mapping.

btw, going through the code I noticed there is a check in place:

if plot_addit_params["polygon_class_colors"] is None:
        color = "red"
    else:
        print(plot_addit_params["polygon_class_colors"])
        color = plot_addit_params["polygon_class_colors"][str(classification)]

as the plot_addit_params["polygon_class_colors"] dict is present but empty the color red is never used in place of the color style. That's why then the KeyError is raised later.
I'd suggest to change it to:

if not plot_addit_params["polygon_class_colors"]:
        color = "red"
    else:
        print(plot_addit_params["polygon_class_colors"])
        color = plot_addit_params["polygon_class_colors"][str(classification)]

this way plot_addit_params["polygon_class_colors"] will evaluate to False both in case the dict is empty or None.

btw I see version 0.5 is not present here. Is it developed somewhere else now?

Hope it helps
Best, and thank you for this plugin!

Luca

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions