Skip to content

Commit

Permalink
fix!: opacity is not longer forced on text symbolizer
Browse files Browse the repository at this point in the history
BREAKING CHANGE: opacity is not longer forced to be 1 on text
symbolizer.
  • Loading branch information
ger-benjamin committed Oct 8, 2024
1 parent 5d11f43 commit 43fc38a
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion data/styles/geoserver/poi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const style: Style = {
kind: 'Text',
label: '{{NAME}}',
color: '#000000',
opacity: 1,
haloWidth: 2,
haloColor: '#FFFFFF',
offset: [
Expand Down
1 change: 0 additions & 1 deletion data/styles/geoserver/poly_landmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ const style: Style = {
kind: 'Text',
label: '{{LANAME}}',
color: '#000000',
opacity: 1,
haloWidth: 2,
haloColor: '#FDE5A5',
haloOpacity: 0.75,
Expand Down
1 change: 0 additions & 1 deletion data/styles/geoserver/pophatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const style: Style = {
kind: 'Text',
label: '{{STATE_ABBR}}',
color: '#000000',
opacity: 1,
haloWidth: 2,
haloColor: '#FFFFFF',
font: [
Expand Down
1 change: 0 additions & 1 deletion data/styles/geoserver/popshade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const style: Style = {
kind: 'Text',
label: '{{STATE_ABBR}}',
color: '#000000',
opacity: 1,
font: [
'Times New Roman'
],
Expand Down
1 change: 0 additions & 1 deletion data/styles/geoserver/tiger_roads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const style: Style = {
kind: 'Text',
label: '{{NAME}}',
color: '#000000',
opacity: 1,
haloWidth: 2,
haloColor: '#FFFFFF',
haloOpacity: 0.85,
Expand Down
1 change: 0 additions & 1 deletion data/styles/multi_simplelineLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const multiSimplelineLabel: Style = {
}, {
kind: 'Text',
color: '#000000',
opacity: 1,
label: '{{name}}',
font: ['Arial'],
size: 12,
Expand Down
1 change: 0 additions & 1 deletion data/styles/point_simpleLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const pointStyledLabel: Style = {
name: '',
symbolizers: [{
color: '#000000',
opacity: 1,
kind: 'Text',
label: 'myText'
}]
Expand Down
1 change: 0 additions & 1 deletion data/styles/point_styledLabel_literalPlaceholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const pointStyledLabel: Style = {
haloColor: '#000000',
haloWidth: 5,
haloOpacity: 1,
opacity: 1,
rotate: 45,
fontStyle: 'normal',
fontWeight: 'bold',
Expand Down
1 change: 0 additions & 1 deletion data/styles/point_styledlabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const pointStyledLabel: Style = {
symbolizers: [{
kind: 'Text',
color: '#000000',
opacity: 1,
label: '{{name}}',
font: ['Arial'],
size: 12,
Expand Down
1 change: 0 additions & 1 deletion data/styles/text_lineplacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const pointStyledLabel: Style = {
name: '',
symbolizers: [{
color: '#000000',
opacity: 1,
kind: 'Text',
label: 'myText',
placement: 'line'
Expand Down
1 change: 0 additions & 1 deletion data/styles/text_pointplacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const pointStyledLabel: Style = {
name: '',
symbolizers: [{
color: '#000000',
opacity: 1,
kind: 'Text',
label: 'myText',
placement: 'point'
Expand Down
23 changes: 14 additions & 9 deletions src/SldStyleParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,10 @@ export class SldStyleParser implements StyleParser<string> {
}

textSymbolizer.color = color ? color : '#000000';
textSymbolizer.opacity = isNil(opacity) ? 1 : numberExpression(opacity);

if (!isNil(opacity)) {
textSymbolizer.opacity = numberExpression(opacity);
}

const haloRadius = get(sldSymbolizer, 'Halo.Radius.#text');
if (!isNil(haloRadius)) {
Expand Down Expand Up @@ -2099,15 +2102,17 @@ export class SldStyleParser implements StyleParser<string> {
':@': {
'@_name': 'fill'
}
},
{
[CssParameter]: [{
'#text': Number.isFinite(textSymbolizer.opacity) ? textSymbolizer.opacity : '1',
}],
':@': {
'@_name': 'fill-opacity'
}
}];
if (Number.isFinite(textSymbolizer.opacity)) {
fill.push({
[CssParameter]: [{
'#text': `${textSymbolizer.opacity}`,
}],
':@': {
'@_name': 'fill-opacity'
},
});
}
sldTextSymbolizer.push({
[Fill]: fill
});
Expand Down

0 comments on commit 43fc38a

Please sign in to comment.