Skip to content

Commit

Permalink
Sets default values for opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
mholthausen committed May 17, 2021
1 parent 20fe693 commit 7f60cfb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion data/styles/polygon_simple_polygon.ts
Expand Up @@ -7,7 +7,9 @@ const polygonStyle: Style = {
symbolizers: [{
kind: 'Fill',
color: '#00FF00',
outlineColor: '#555555'
fillOpacity: 1,
outlineColor: '#555555',
outlineOpacity: 1
}]
}]
};
Expand Down
5 changes: 3 additions & 2 deletions data/styles/polygon_simple_polygon_outline.ts
Expand Up @@ -6,12 +6,13 @@ const polygonStyle: Style = {
{
name: '',
symbolizers: [
{ kind: 'Fill', outlineOpacity: 0, color: '#00FF00' },
{ kind: 'Fill', outlineOpacity: 0, color: '#00FF00', fillOpacity: 1 },
{
kind: 'Fill',
outlineColor: '#555555',
fillOpacity: 0,
outlineWidth: 0.1
outlineWidth: 0.1,
outlineOpacity: 1
}
]
}
Expand Down
10 changes: 7 additions & 3 deletions src/MapfileStyleParser.ts
Expand Up @@ -624,11 +624,16 @@ export class MapfileStyleParser implements StyleParser {
fillSymbolizer.graphicFill = this.getPointSymbolizerFromMapfileStyle(mapfileStyle);
}

if (mapfileStyle.color && !mapfileStyle.outlinecolor) {
fillSymbolizer.outlineOpacity = 0;
if (mapfileStyle.color) {
fillSymbolizer.fillOpacity = mapfileStyle.opacity / 100 || 1;

if (!mapfileStyle.outlinecolor) {
fillSymbolizer.outlineOpacity = 0;
}
}

if (mapfileStyle.outlinecolor) {
fillSymbolizer.outlineOpacity = mapfileStyle.opacity / 100 || 1;
fillSymbolizer.outlineColor = isHex(mapfileStyle.outlinecolor)
? mapfileStyle.outlinecolor
: rgbToHex(mapfileStyle.outlinecolor);
Expand Down Expand Up @@ -838,7 +843,6 @@ export class MapfileStyleParser implements StyleParser {
this.checkWarnDropRule('MAXSCALEDENOM', 'LABEL', mapfileLabel.maxscaledenom);
});
}

return symbolizers;
}

Expand Down

0 comments on commit 7f60cfb

Please sign in to comment.