Skip to content

Commit d343752

Browse files
authored
fix(OlFlatStyleParser): set fillOpacity on circle styles (#905)
1 parent c7d35a0 commit d343752

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { FlatStyle } from 'ol/style/flat';
2+
3+
const pointOpaquePoint: FlatStyle = {
4+
'circle-stroke-color': '#FF0000FF',
5+
'circle-fill-color': '#00FF0000',
6+
'circle-radius': 6
7+
};
8+
9+
export default pointOpaquePoint;

data/styles/point_opaquepoint.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Style } from 'geostyler-style';
2+
3+
const pointOpaquePoint: Style = {
4+
name: 'OL Style',
5+
rules: [
6+
{
7+
name: 'OL Style Rule 0',
8+
symbolizers: [{
9+
kind: 'Mark',
10+
wellKnownName: 'circle',
11+
strokeColor: '#FF0000',
12+
strokeOpacity: 1,
13+
color: '#00FF00',
14+
fillOpacity: 0,
15+
radius: 6
16+
}]
17+
}
18+
]
19+
};
20+
21+
export default pointOpaquePoint;

src/OlFlatStyleParser.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import lineSimpleLine from '../data/styles/line_simpleline';
77
import textPlacementLine from '../data/styles/text_placement_line';
88
import pointIconSimple from '../data/styles/point_icon_simple';
99
import pointSimplePoint from '../data/styles/point_simplepoint';
10+
import pointOpaquePoint from '../data/styles/point_opaquepoint';
1011
import multiTwoRulesSimplepoint from '../data/styles/multi_twoRulesSimplepoint';
1112
import filterSimpleFilter from '../data/styles/filter_simpleFilter';
1213
import filterNestedFilter from '../data/styles/filter_nestedFilter';
@@ -16,6 +17,7 @@ import ol_line_simpleline from '../data/olFlatStyles/line_simpleline';
1617
import ol_text_placement_line from '../data/olFlatStyles/text_placement_line';
1718
import ol_point_icon_simple from '../data/olFlatStyles/point_icon_simple';
1819
import ol_point_simplepoint from '../data/olFlatStyles/point_simplepoint';
20+
import ol_point_opaquepoint from '../data/olFlatStyles/point_opaquepoint';
1921
import ol_multi_twoRulesSimplepoint from '../data/olFlatStyles/multi_twoRulesSimplepoint';
2022
import ol_filter_simpleFilter from '../data/olFlatStyles/filter_simpleFilter';
2123
import ol_filter_nestedFilter from '../data/olFlatStyles/filter_nestedFilter';
@@ -66,6 +68,12 @@ describe('OlFlatStyleParser implements StyleParser', () => {
6668
expect(geostylerStyle).toEqual(pointSimplePoint);
6769
});
6870

71+
it('reads a FlatCircle style with fill and stroke opacity', async () => {
72+
const { output: geostylerStyle } = await styleParser.readStyle(ol_point_opaquepoint);
73+
expect(geostylerStyle).toBeDefined();
74+
expect(geostylerStyle).toEqual(pointOpaquePoint);
75+
});
76+
6977
it('reads a style from a FlatStyleArray', async () => {
7078
const { output: geostylerStyle } = await styleParser.readStyle(ol_multi_twoRulesSimplepoint);
7179
expect(geostylerStyle).toBeDefined();

src/OlFlatStyleParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class OlFlatStyleParser implements StyleParser<FlatStyleLike> {
276276
wellKnownName: 'circle',
277277
radius: OlFlatStyleUtil.olExpressionToGsExpression<number>(flatStyle['circle-radius']),
278278
color: fillColor,
279-
opacity: fillOpacity,
279+
fillOpacity,
280280
strokeColor,
281281
strokeOpacity,
282282
strokeWidth: OlFlatStyleUtil.olExpressionToGsExpression<number>(flatStyle['circle-stroke-width']),

0 commit comments

Comments
 (0)