Skip to content

Commit b080ffa

Browse files
authored
Merge pull request #186 from NieuwlandGeo/parse-description
Parse SLD 1.1 Description elements
2 parents ea5730e + feb390f commit b080ffa

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

docs/assets/sldreader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@
687687
Name: addPropWithTextContent,
688688
Title: addPropWithTextContent,
689689
Abstract: addPropWithTextContent,
690+
Description: readNode,
690691
MaxScaleDenominator: addNumericProp,
691692
MinScaleDenominator: addNumericProp},
692693
FilterParsers,

src/Reader/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ const parsers = {
407407
Name: addPropWithTextContent,
408408
Title: addPropWithTextContent,
409409
Abstract: addPropWithTextContent,
410+
Description: readNode,
410411
MaxScaleDenominator: addNumericProp,
411412
MinScaleDenominator: addNumericProp,
412413
...FilterParsers,

test/Reader.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,24 @@ describe('Reads xml sld 11', () => {
195195
expect(symbolizer).to.be.an.instanceof(Object);
196196
expect(symbolizer.fill).to.be.an.instanceof(Object);
197197
});
198+
describe('Metadata', () => {
199+
let rule;
200+
beforeEach(() => {
201+
rule = result.layers[0].styles[0].featuretypestyles[0].rules[0];
202+
});
203+
204+
it('Rule name', () => {
205+
expect(rule.name).to.equal('Other');
206+
});
207+
208+
it('Takes Rule title from description', () => {
209+
expect(rule.title).to.equal('Other provinces');
210+
});
211+
212+
it('Takes Rule abstract from description', () => {
213+
expect(rule.abstract).to.equal('This rule matches all other provinces');
214+
});
215+
});
198216
});
199217

200218
describe('Other reader tests', () => {

test/data/test11.sld.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const sld11 = `<?xml version="1.0" encoding="UTF-8"?>
88
<se:Rule>
99
<se:Name>Other</se:Name>
1010
<se:Description>
11-
<se:Title>Other</se:Title>
11+
<se:Title>Other provinces</se:Title>
12+
<se:Abstract>This rule matches all other provinces</se:Abstract>
1213
</se:Description>
1314
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
1415
<ogc:PropertyIsNotEqualTo>

0 commit comments

Comments
 (0)