From 775d3e37b478e6b458a249b5cf8fb345cc4bad1e Mon Sep 17 00:00:00 2001 From: pprev94 Date: Fri, 21 Jun 2024 13:28:57 +0200 Subject: [PATCH] Offset Y for Textsymbolizer (#932) * fix: offset y for textsymbolizer #566 * fix: few tests changed --- data/styles/geoserver/poi.ts | 2 +- data/styles/multi_simplelineLabel.ts | 2 +- data/styles/point_styledLabel_elementOrder.ts | 2 +- data/styles/point_styledLabel_literalOpenCurlyBraces.ts | 2 +- data/styles/point_styledLabel_literalPlaceholder.ts | 2 +- data/styles/point_styledlabel.ts | 2 +- src/SldStyleParser.ts | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/styles/geoserver/poi.ts b/data/styles/geoserver/poi.ts index a2d59d6f..67b44de2 100644 --- a/data/styles/geoserver/poi.ts +++ b/data/styles/geoserver/poi.ts @@ -37,7 +37,7 @@ const style: Style = { haloColor: '#FFFFFF', offset: [ 0, - -15 + 15 ], font: [ 'Arial' diff --git a/data/styles/multi_simplelineLabel.ts b/data/styles/multi_simplelineLabel.ts index 0915c943..ea73c967 100644 --- a/data/styles/multi_simplelineLabel.ts +++ b/data/styles/multi_simplelineLabel.ts @@ -16,7 +16,7 @@ const multiSimplelineLabel: Style = { label: '{{name}}', font: ['Arial'], size: 12, - offset: [0, 5], + offset: [0, -5], fontStyle: 'normal', fontWeight: 'bold', placement: 'point' diff --git a/data/styles/point_styledLabel_elementOrder.ts b/data/styles/point_styledLabel_elementOrder.ts index cab6c787..442d6c79 100644 --- a/data/styles/point_styledLabel_elementOrder.ts +++ b/data/styles/point_styledLabel_elementOrder.ts @@ -10,7 +10,7 @@ const pointStyledLabel: Style = { label: 'prefix: {{name}}{{title}} entity', font: ['Arial'], size: 12, - offset: [0, 5], + offset: [0, -5], haloColor: '#000000', haloWidth: 5, opacity: 1, diff --git a/data/styles/point_styledLabel_literalOpenCurlyBraces.ts b/data/styles/point_styledLabel_literalOpenCurlyBraces.ts index 329447d3..1431f800 100644 --- a/data/styles/point_styledLabel_literalOpenCurlyBraces.ts +++ b/data/styles/point_styledLabel_literalOpenCurlyBraces.ts @@ -10,7 +10,7 @@ const pointStyledLabel: Style = { label: 'entity {{ xx', font: ['Arial'], size: 12, - offset: [0, 5], + offset: [0, -5], haloColor: '#000000', haloWidth: 5, opacity: 1, diff --git a/data/styles/point_styledLabel_literalPlaceholder.ts b/data/styles/point_styledLabel_literalPlaceholder.ts index 4ad0aafa..c409e68f 100644 --- a/data/styles/point_styledLabel_literalPlaceholder.ts +++ b/data/styles/point_styledLabel_literalPlaceholder.ts @@ -10,7 +10,7 @@ const pointStyledLabel: Style = { label: 'foo {{name}}{{prop}} entity {{bar}}', font: ['Arial'], size: 12, - offset: [0, 5], + offset: [0, -5], haloColor: '#000000', haloWidth: 5, haloOpacity: 1, diff --git a/data/styles/point_styledlabel.ts b/data/styles/point_styledlabel.ts index b045251b..5ed122b0 100644 --- a/data/styles/point_styledlabel.ts +++ b/data/styles/point_styledlabel.ts @@ -11,7 +11,7 @@ const pointStyledLabel: Style = { label: '{{name}}', font: ['Arial'], size: 12, - offset: [0, 5], + offset: [0, -5], haloColor: '#000000', haloWidth: 5, haloOpacity: 1, diff --git a/src/SldStyleParser.ts b/src/SldStyleParser.ts index 9864af53..e6f55a01 100644 --- a/src/SldStyleParser.ts +++ b/src/SldStyleParser.ts @@ -826,7 +826,7 @@ export class SldStyleParser implements StyleParser { const y = get(displacement, 'DisplacementY.#text'); textSymbolizer.offset = [ Number.isFinite(x) ? numberExpression(x) : 0, - Number.isFinite(y) ? numberExpression(y) : 0, + Number.isFinite(y) ? -numberExpression(y) : 0, ]; } const rotation = get(pointPlacement, 'Rotation.#text'); @@ -2016,7 +2016,7 @@ export class SldStyleParser implements StyleParser { }] }, { [DisplacementY]: [{ - '#text': textSymbolizer.offset[1].toString() + '#text': (-textSymbolizer.offset[1]).toString() }] }] });