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

Added small section to fix an issue with QGIS expression #251

Closed
wants to merge 1 commit into from

Conversation

svenjr
Copy link

@svenjr svenjr commented Aug 15, 2019

I was seeing a bug that was berried deep in the QGIS symbols. When the expression it built like [path]+[icon_name]... the icon name was keeping the 'b' from the byte date after the http_get(). This small section will just check and make sure there is no standalone 'b' and if there is then it will remove. The QGIS expressions are no longer invalid after this fix.

To check for this issue in QGIS, you go to a symbol layer that is using icons, click on an icon > SVG Marker > scroll down to the expression that was inserted by the script and if that is red, it is invalid. That is this bug presenting. These few lines should fix that but also not cause other issues for examples where this is not happening.

@mnboos
Copy link
Collaborator

mnboos commented Aug 15, 2019

Thanks for the PR and the hint for the issue. I would prefer a solution that not just removes a stringified 'b' char but one that assures, that not a bytes string will be incorrectly stringified in the first place. Would you mind doing that? Otherwise I can do it myself.

@svenjr
Copy link
Author

svenjr commented Aug 15, 2019

Thanks for the PR and the hint for the issue. I would prefer a solution that not just removes a stringified 'b' char but one that assures, that not a bytes string will be incorrectly stringified in the first place. Would you mind doing that? Otherwise I can do it myself.

I will look into this

@mnboos
Copy link
Collaborator

mnboos commented Aug 15, 2019

I will look into this

Awesome, thanks a lot!

@svenjr
Copy link
Author

svenjr commented Aug 15, 2019

I am having a hard time tracking down where the byte object if being converted to a string. I would have bet money that the fix below in the _load_sprite_data would have fixed it since str('byte object') is not the proper way to convert but it must be elsewhere. Any idea would help because you know the code better but I will keep looking.

    `if not image_definition_data:
        raise "No image definitions found at: {}".format(image_definition_data)
    else:
        #I believe this is the issue with byte object. You need to decode
        #to get to str and you can't just force it in I don't think
        image_definition_data = image_definition_data.content.decode("utf-8")
        image_definition_data = json.loads(image_definition_data)
return image_data, image_definition_data`

@mnboos
Copy link
Collaborator

mnboos commented Aug 15, 2019

How about this?

Sorry I'm not a big help at the moment. I currently don't have a computer at home until next week.

@svenjr
Copy link
Author

svenjr commented Aug 15, 2019

How about this?

Sorry I'm not a big help at the moment. I currently don't have a computer at home until next week.

It is happening even when icon creation is not triggered so it is not in that section. It is weird because the layer names are labeled correctly it is just the QGIS expressions that are failing with that pesky 'b'. I have a feeling it is somewhere in the _parse_expr() function or the _get_qgis_fields() function

@svenjr
Copy link
Author

svenjr commented Aug 15, 2019

How about this?

Sorry I'm not a big help at the moment. I currently don't have a computer at home until next week.

And no worries on the help - you have certainly done a lot more work on this than me haha. I am just trying to find this thing. I am afraid it is going to be such a small thing that just leaving the b_string removal option would be less time but I will continue to hunt.

@mnboos
Copy link
Collaborator

mnboos commented Oct 1, 2019

Texts are now rendered correctly (see #211)

@mnboos
Copy link
Collaborator

mnboos commented Oct 1, 2019

Icons are still not rendered (see #255)

@svenjr svenjr closed this Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants