Skip to content

Commit

Permalink
fix: support spaces as separator for vendor-option graphic-margin
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfrey committed Feb 21, 2025
1 parent b5f983e commit 9e357b1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
37 changes: 37 additions & 0 deletions data/slds/geoserver/pattern_polygon_alternative_margin.sld
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>

<Name>Pattern polygon</Name>

<UserStyle>
<Name>pattern_polygon</Name>
<Title>Pattern polygon</Title>
<Abstract>Polygon with spaced purple circle symbols</Abstract>
<FeatureTypeStyle>
<Rule>
<Name>Polygon with spaced purple circle symbols</Name>
<Abstract>Polygon with spaced purple circle symbols</Abstract>
<PolygonSymbolizer>
<VendorOption name="graphic-margin">4 6 2 3</VendorOption>
<Fill>
<GraphicFill>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#880088</CssParameter>
</Fill>
</Mark>
<Size>6</Size>
</Graphic>
</GraphicFill>
</Fill>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
6 changes: 6 additions & 0 deletions src/SldStyleParser.geoserver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ describe('SldStyleParser implements StyleParser', () => {
expect(geoStylerStyle).toBeDefined();
expect(geoStylerStyle).toEqual(pattern_polygon);
});
it('can read the geoserver pattern_polygon_alternative_margin.sld', async () => {
const sld = fs.readFileSync('./data/slds/geoserver/pattern_polygon_alternative_margin.sld', 'utf8');
const { output: geoStylerStyle } = await styleParser.readStyle(sld);
expect(geoStylerStyle).toBeDefined();
expect(geoStylerStyle).toEqual(pattern_polygon);
});
});

describe('#writeStyle', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/SldStyleParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ export class SldStyleParser implements StyleParser<string> {
if (this.withGeoServerVendorOption) {
const graphicFillPadding = getVendorOptionValue(sldSymbolizer, 'graphic-margin');
if (!isNil(graphicFillPadding)) {
fillSymbolizer.graphicFillPadding = graphicFillPadding.split(',').map(numberExpression);
fillSymbolizer.graphicFillPadding = graphicFillPadding.split(/[,\s]/).map(numberExpression);
}
}
if (!isNil(color)) {
Expand Down

0 comments on commit 9e357b1

Please sign in to comment.