-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug
Describe the bug
The <Format> tag is missing when converting from geostyler to SLD.
To Reproduce
const { SldStyleParser } = await import("geostyler-sld-parser");
const geostyle = {
rules: [
{
name: 'MissingFormat',
symbolizers: [{kind: "Icon", image: '/path/to/icon.png'}],
},
]
}
const parser = new SldStyleParser({ builderOptions: { format: true }});
parser.writeStyle(geostyle).then(({ output: sld }) => console.log(sld));Result:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 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" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<Name/>
<UserStyle>
<Name/>
<Title/>
<FeatureTypeStyle>
<Rule>
<Name>MissingFormat</Name>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/path/to/icon.png"/>
</ExternalGraphic>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>Expected behavior
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 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" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<Name/>
<UserStyle>
<Name/>
<Title/>
<FeatureTypeStyle>
<Rule>
<Name>MissingFormat</Name>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/path/to/icon.png"/>
<Format>image/png</Format>
</ExternalGraphic>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>Additional context
Node v20.8.0
Debian
geostler-sld-parser v5.1.0
My fix
diff --git a/src/SldStyleParser.ts b/src/SldStyleParser.ts
index 0373158..eb0ccfa 100644
--- a/src/SldStyleParser.ts
+++ b/src/SldStyleParser.ts
@@ -1739,13 +1739,13 @@ export class SldStyleParser implements StyleParser<string> {
case 'png':
case 'jpeg':
case 'gif':
- graphic[0][ExternalGraphic][0][Format] = [`image/${iconExt}`];
+ graphic[0][ExternalGraphic][1] = { [Format]: [{ '#text': `image/${iconExt}` }] };
break;
case 'jpg':
- graphic[0][ExternalGraphic][0][Format] = ['image/jpeg'];
+ graphic[0][ExternalGraphic][1] = { [Format]: [{ '#text': `image/jpeg` }] };
break;
case 'svg':
- graphic[0][ExternalGraphic][0][Format] = ['image/svg+xml'];
+ graphic[0][ExternalGraphic][1] = { [Format]: [{ '#text': `image/svg+xml` }] };
break;
default:
break;PS: Thank you for your awesome work !!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working