From ed40f47ac945fc30eefed72b5f82ab419303f1b2 Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Tue, 17 Dec 2024 14:49:05 +0700 Subject: [PATCH 1/4] PB-1278: Use the raw graphicOffset. Also allow width to be negative (e.g. offset). --- src/api/print.api.js | 7 +++---- src/utils/styleUtils.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/print.api.js b/src/api/print.api.js index 1495bf22bd..3905b687fe 100644 --- a/src/api/print.api.js +++ b/src/api/print.api.js @@ -134,10 +134,9 @@ class GeoAdminCustomizer extends BaseCustomizer { ) : 0 // don't ask why it works, but that's the best I could do. - - 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. + // Per issue 1278, it's correct. But Martin did it differently, but all test is pass. + symbolizer.graphicYOffset = symbolizer.graphicYOffset ? symbolizer.graphicYOffset : 0 } if (size) { symbolizer.graphicWidth = adjustWidth(size[0] * scale, this.printResolution) diff --git a/src/utils/styleUtils.js b/src/utils/styleUtils.js index 3545c09aa5..799e259a9a 100644 --- a/src/utils/styleUtils.js +++ b/src/utils/styleUtils.js @@ -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) { return 0 } From ec0bc1ae34a9a228bdc5ca53c0a459d1324ae0a7 Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Wed, 18 Dec 2024 11:12:26 +0700 Subject: [PATCH 2/4] PB-1278: Simplify code. --- src/api/print.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/print.api.js b/src/api/print.api.js index 3905b687fe..4b5718a9c8 100644 --- a/src/api/print.api.js +++ b/src/api/print.api.js @@ -136,7 +136,7 @@ class GeoAdminCustomizer extends BaseCustomizer { // don't ask why it works, but that's the best I could do. // Note(IS): I'm not sure if this is the best way to handle the Y offset. Need to be tested of different case. // Per issue 1278, it's correct. But Martin did it differently, but all test is pass. - symbolizer.graphicYOffset = symbolizer.graphicYOffset ? symbolizer.graphicYOffset : 0 + symbolizer.graphicYOffset = symbolizer.graphicYOffset ?? 0 } if (size) { symbolizer.graphicWidth = adjustWidth(size[0] * scale, this.printResolution) From c9ae34ce14e9bc86c56f55abd52b5622ff271291 Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Tue, 7 Jan 2025 06:19:03 +0700 Subject: [PATCH 3/4] PB-1278: Address PR review. --- src/api/print.api.js | 4 +--- src/utils/styleUtils.js | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/print.api.js b/src/api/print.api.js index 4b5718a9c8..ae071c0861 100644 --- a/src/api/print.api.js +++ b/src/api/print.api.js @@ -134,9 +134,7 @@ class GeoAdminCustomizer extends BaseCustomizer { ) : 0 // don't ask why it works, but that's the best I could do. - // Note(IS): I'm not sure if this is the best way to handle the Y offset. Need to be tested of different case. - // Per issue 1278, it's correct. But Martin did it differently, but all test is pass. - symbolizer.graphicYOffset = symbolizer.graphicYOffset ?? 0 + symbolizer.graphicYOffset = Math.round(symbolizer.graphicYOffset) ?? 0 } if (size) { symbolizer.graphicWidth = adjustWidth(size[0] * scale, this.printResolution) diff --git a/src/utils/styleUtils.js b/src/utils/styleUtils.js index 799e259a9a..c0f577fc33 100644 --- a/src/utils/styleUtils.js +++ b/src/utils/styleUtils.js @@ -164,6 +164,8 @@ export 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) } From a7cd57ff49ce7638c9b624faabd2465b1764fb7f Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Tue, 7 Jan 2025 17:32:32 +0700 Subject: [PATCH 4/4] PB-1278: fix round issue. --- src/api/print.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/print.api.js b/src/api/print.api.js index ae071c0861..a71befac57 100644 --- a/src/api/print.api.js +++ b/src/api/print.api.js @@ -134,7 +134,7 @@ class GeoAdminCustomizer extends BaseCustomizer { ) : 0 // don't ask why it works, but that's the best I could do. - symbolizer.graphicYOffset = Math.round(symbolizer.graphicYOffset) ?? 0 + symbolizer.gaphicYOffset = Math.round(1000 * symbolizer.gaphicYOffset ?? 0) / 1000 } if (size) { symbolizer.graphicWidth = adjustWidth(size[0] * scale, this.printResolution)