Skip to content

Commit

Permalink
Add read/write support for fill line dashes and read support for stro…
Browse files Browse the repository at this point in the history
…ke-opacity
  • Loading branch information
rdewit committed Oct 15, 2020
1 parent 8cb34c6 commit fe74b58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/OlStyleParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,16 @@ export class OlStyleParser implements StyleParser {
getFillSymbolizerFromOlStyle(olStyle: any): FillSymbolizer {
const olFillStyle = olStyle.getFill();
const olStrokeStyle = olStyle.getStroke();
// getLineDash returns null not undefined. So we have to double check
const outlineDashArray = olStrokeStyle ? olStrokeStyle.getLineDash() : undefined;

return {
kind: 'Fill',
color: olFillStyle ? OlStyleUtil.getHexColor(olFillStyle.getColor() as string) : undefined,
opacity: olFillStyle ? OlStyleUtil.getOpacity(olFillStyle.getColor() as string) : undefined,
outlineColor: olStrokeStyle ? olStrokeStyle.getColor() as string : undefined,
outlineColor: olStrokeStyle ? OlStyleUtil.getHexColor(olStrokeStyle.getColor() as string) : undefined,
outlineDasharray: outlineDashArray ? outlineDashArray : undefined,
outlineOpacity: olStrokeStyle ? OlStyleUtil.getOpacity(olStrokeStyle.getColor() as string) : undefined,
outlineWidth: olStrokeStyle ? olStrokeStyle.getWidth() as number : undefined
};
}
Expand Down Expand Up @@ -956,7 +960,8 @@ export class OlStyleParser implements StyleParser {
const stroke = symbolizer.outlineColor ? new this.OlStyleStrokeConstructor({
color: (symbolizer.outlineOpacity !== null && symbolizer.outlineOpacity !== undefined) ?
OlStyleUtil.getRgbaColor(symbolizer.outlineColor, symbolizer.outlineOpacity) : symbolizer.outlineColor,
width: symbolizer.outlineWidth
width: symbolizer.outlineWidth,
lineDash: symbolizer.outlineDasharray,
}) : null;

return new this.OlStyleConstructor({
Expand Down

0 comments on commit fe74b58

Please sign in to comment.