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

PB-1278: Fix Icon with offset (pin) changes positon #1174

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ismailsunni
Copy link
Contributor

@ismailsunni ismailsunni commented Dec 17, 2024

Need to be reviewd by @ltkum as this revert his change in #1015

Test link

Sample on 1:500 and 1:5000. Looks good
image

Test link

Copy link

cypress bot commented Dec 17, 2024

web-mapviewer    Run #4129

Run Properties:  status check passed Passed #4129  •  git commit 9111943ef0: PB-1278: Simplify code.
Project web-mapviewer
Branch Review pb-1278-icon-offset
Run status status check passed Passed #4129
Run duration 05m 40s
Commit git commit 9111943ef0: PB-1278: Simplify code.
Committer Ismail Sunni
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 21
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 217
View all changes introduced in this branch ↗︎

@ismailsunni ismailsunni marked this pull request as ready for review December 17, 2024 08:14
@ismailsunni ismailsunni requested review from ltkum and pakb December 17, 2024 08:14
src/api/print.api.js Outdated Show resolved Hide resolved
@@ -161,7 +161,7 @@ export const highlightPointStyle = new Style({
// Change a width according to the change of DPI (from the old geoadmin)
// Originally introduced here https://github.com/geoadmin/mf-geoadmin3/pull/3280
export function adjustWidth(width, dpi) {
if (!width || isNaN(width) || width <= 0.0 || !dpi || isNaN(dpi) || dpi <= 0) {
if (!width || isNaN(width) || !dpi || isNaN(dpi) || dpi <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe @ltkum can better tell if this might break something or not...
I think that was a "trade-off" fix so that we would not have to add some fixes to the mapfishprint library or backend. I'll let him tell us what was the state on that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I need @ltkum to the changes in this PR.

For this code, I remove it because for offset, it might be a negative number.

Copy link
Contributor

@ltkum ltkum Dec 19, 2024

Choose a reason for hiding this comment

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

From what I remember and can see :

The width <= 0.0 line was here because, afterwards, we use a math.max to set the scale size to its minimal value if it's smaller than it (as very small numbers would break the print). Currently, you don't check anymore if it's negative, which means it will set its offset to min scale when it's negative.

what I would do :

function adjustWidth(width, dpi) {
if (!width || isNaN(width)  || !dpi || isNaN(dpi) || dpi <= 0) {return 0}
if (width <= 0) {return -adjustWidth(-width, dpi}
return Math.max((width * PRINT_DPI_COMPENSATION) / dpi, MIN_PRINT_SCALE_SIZE)
}

that way, your offsets are not set to 0, nor to MIN_PRINT_SCALE_SIZE

symbolizer.graphicYOffset = symbolizer.graphicYOffset
? (symbolizer.graphicYOffset = adjustWidth(-size[1], this.printResolution))
: 0
// Note(IS): I'm not sure if this is the best way to handle the Y offset. Need to be tested of different case.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @ltkum what do you think about this one?

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.

3 participants