Skip to content

Commit

Permalink
Merge branch 'geostyler:main' into feature-add-wellknownnames
Browse files Browse the repository at this point in the history
  • Loading branch information
terry-longmacch authored Feb 1, 2025
2 parents 2714f24 + 368cde7 commit c3c62fe
Show file tree
Hide file tree
Showing 14 changed files with 461 additions and 47 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## [7.2.1](https://github.com/geostyler/geostyler-sld-parser/compare/v7.2.0...v7.2.1) (2025-01-14)


### Bug Fixes

* linting ([#976](https://github.com/geostyler/geostyler-sld-parser/issues/976)) ([f0563be](https://github.com/geostyler/geostyler-sld-parser/commit/f0563be94455bda70c1394e9dc6a4fe204ff047c))

## [7.2.0](https://github.com/geostyler/geostyler-sld-parser/compare/v7.1.0...v7.2.0) (2025-01-14)


### Features

* property to property comparison ([#975](https://github.com/geostyler/geostyler-sld-parser/issues/975)) ([72c794e](https://github.com/geostyler/geostyler-sld-parser/commit/72c794e2524f8ad0f8068d9f0d24a11f853980b1))

## [7.1.0](https://github.com/geostyler/geostyler-sld-parser/compare/v7.0.0...v7.1.0) (2025-01-13)


### Features

* add vendor-option graphic-margin ([#971](https://github.com/geostyler/geostyler-sld-parser/issues/971)) ([be950ea](https://github.com/geostyler/geostyler-sld-parser/commit/be950eae89dd262e2018fbdca9fab6ceba75d83d))


### Bug Fixes

* update image format handling ([0093c6b](https://github.com/geostyler/geostyler-sld-parser/commit/0093c6b979affc4db005d7fb0868c87f9504a063))

## [7.0.0](https://github.com/geostyler/geostyler-sld-parser/compare/v6.1.2...v7.0.0) (2024-10-09)


Expand Down
61 changes: 61 additions & 0 deletions data/slds/1.0/function_filter_property_to_property.sld
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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 StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>Function Property to Property</Name>
<UserStyle>
<Name>Function Property to Property</Name>
<FeatureTypeStyle>
<Rule>
<Name>Property Comparison Rule</Name>
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>posledni_hodnota</ogc:PropertyName>
<ogc:PropertyName>posledni_hodnota_sekundarni</ogc:PropertyName>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>value1</ogc:PropertyName>
<ogc:PropertyName>value2</ogc:PropertyName>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>count1</ogc:PropertyName>
<ogc:PropertyName>count2</ogc:PropertyName>
</ogc:PropertyIsLessThan>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>threshold1</ogc:PropertyName>
<ogc:PropertyName>threshold2</ogc:PropertyName>
</ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:Function name="lessThanOrEqualTo">
<ogc:PropertyName>posledni_hodnota</ogc:PropertyName>
<ogc:PropertyName>spa1h</ogc:PropertyName>
</ogc:Function>
<ogc:PropertyIsNotEqualTo>
<ogc:PropertyName>status</ogc:PropertyName>
<ogc:Literal>NULL</ogc:Literal>
</ogc:PropertyIsNotEqualTo>
</ogc:And>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>square</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</Mark>
<Size>5</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
62 changes: 62 additions & 0 deletions data/slds/1.1/function_filter_property_to_property.sld
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.1.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>
<se:Name>Function Property to Property</se:Name>
<UserStyle>
<se:Name>Function Property to Property</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>Property Comparison Rule</se:Name>
<Filter xmlns="http://www.opengis.net/ogc">
<And>
<PropertyIsEqualTo>
<PropertyName>posledni_hodnota</PropertyName>
<PropertyName>posledni_hodnota_sekundarni</PropertyName>
</PropertyIsEqualTo>
<PropertyIsGreaterThan>
<PropertyName>value1</PropertyName>
<PropertyName>value2</PropertyName>
</PropertyIsGreaterThan>
<PropertyIsLessThan>
<PropertyName>count1</PropertyName>
<PropertyName>count2</PropertyName>
</PropertyIsLessThan>
<PropertyIsGreaterThanOrEqualTo>
<PropertyName>threshold1</PropertyName>
<PropertyName>threshold2</PropertyName>
</PropertyIsGreaterThanOrEqualTo>
<Function name="lessThanOrEqualTo">
<PropertyName>posledni_hodnota</PropertyName>
<PropertyName>spa1h</PropertyName>
</Function>
<PropertyIsNotEqualTo>
<PropertyName>status</PropertyName>
<Literal>NULL</Literal>
</PropertyIsNotEqualTo>
</And>
</Filter>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>square</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#FF0000</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>5</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
37 changes: 37 additions & 0 deletions data/slds/geoserver/pattern_polygon.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>
64 changes: 64 additions & 0 deletions data/styles/function_filter_property_to_property.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Style } from 'geostyler-style';

const functionFilterPropertyToProperty: Style = {
name: 'Function Property to Property',
rules: [{
name: 'Property Comparison Rule',
filter: ['&&',
// Basic property to property comparison
['==', {
name: 'property',
args: ['posledni_hodnota']
}, {
name: 'property',
args: ['posledni_hodnota_sekundarni']
}],
// Different comparison operators
['>', {
name: 'property',
args: ['value1']
}, {
name: 'property',
args: ['value2']
}],
['<', {
name: 'property',
args: ['count1']
}, {
name: 'property',
args: ['count2']
}],
['>=', {
name: 'property',
args: ['threshold1']
}, {
name: 'property',
args: ['threshold2']
}],

[
'<=',
{
name: 'property',
args: ['posledni_hodnota']
},
{
name: 'property',
args: ['spa1h']
}
],
// Mixed with property-to-literal
['!=', 'status', 'NULL']
],
symbolizers: [{
kind: 'Mark',
wellKnownName: 'square',
color: '#FF0000',
radius: 2.5,
strokeColor: '#000000',
strokeWidth: 1
}]
}]
};

export default functionFilterPropertyToProperty;
1 change: 0 additions & 1 deletion data/styles/geoserver/default_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ const style: Style = {
]
};


export default style;
24 changes: 24 additions & 0 deletions data/styles/geoserver/pattern_polygon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'pattern_polygon',
rules: [
{
name: 'Polygon with spaced purple circle symbols',
symbolizers: [
{
kind: 'Fill',
graphicFill: {
kind: 'Mark',
wellKnownName: 'circle',
color: '#880088',
radius: 3
},
graphicFillPadding: [4, 6, 2, 3],
}
]
}
]
};

export default style;
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "geostyler-sld-parser",
"version": "7.0.0",
"version": "7.2.1",
"description": "GeoStyler Style Parser implementation for SLD",
"type": "module",
"main": "dist/SldStyleParser.js",
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"fast-xml-parser": "^4.4.1",
"geostyler-style": "^9.1.0",
"geostyler-style": "^9.2.0",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand Down
22 changes: 20 additions & 2 deletions src/SldStyleParser.geoserver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import restricted from '../data/styles/geoserver/restricted';
import simple_streams from '../data/styles/geoserver/simple_streams';
import simpleRoads from '../data/styles/geoserver/simpleRoads';
import tiger_roads from '../data/styles/geoserver/tiger_roads';
import pattern_polygon from '../data/styles/geoserver/pattern_polygon';

it('SldStyleParser is defined', () => {
expect(SldStyleParser).toBeDefined();
Expand All @@ -36,7 +37,7 @@ describe('SldStyleParser implements StyleParser', () => {
let styleParser: SldStyleParser;

beforeEach(() => {
styleParser = new SldStyleParser({sldVersion: '1.0.0'});
styleParser = new SldStyleParser({sldVersion: '1.0.0', withGeoServerVendorOption: true});
});

describe('#readStyle', () => {
Expand Down Expand Up @@ -178,6 +179,12 @@ describe('SldStyleParser implements StyleParser', () => {
expect(geoStylerStyle).toBeDefined();
expect(geoStylerStyle).toEqual(tiger_roads);
});
it('can read the geoserver pattern_polygon.sld', async () => {
const sld = fs.readFileSync('./data/slds/geoserver/pattern_polygon.sld', 'utf8');
const { output: geoStylerStyle } = await styleParser.readStyle(sld);
expect(geoStylerStyle).toBeDefined();
expect(geoStylerStyle).toEqual(pattern_polygon);
});
});

describe('#writeStyle', () => {
Expand Down Expand Up @@ -536,7 +543,18 @@ describe('SldStyleParser implements StyleParser', () => {
const { output: readStyle} = await styleParser.readStyle(sldString!);
expect(readStyle).toEqual(tiger_roads);
});

it('can write the geoserver pattern_polygon.sld', async () => {
const {
output: sldString,
errors
} = await styleParser.writeStyle(pattern_polygon);
expect(sldString).toBeDefined();
expect(errors).toBeUndefined();
// As string comparison between two XML-Strings is awkward and nonsens
// we read it again and compare the json input with the parser output
const { output: readStyle} = await styleParser.readStyle(sldString!);
expect(readStyle).toEqual(pattern_polygon);
});
});

});
Loading

0 comments on commit c3c62fe

Please sign in to comment.