-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: property to property comparison (#975)
* refactor: make sure function filters are parsed properly even as objects * fix: allow property to property comparison filter * fix: properly handle single arg operators in childrenToArgs * test: add test coverage for property to property comaprison filters
- Loading branch information
1 parent
853221d
commit 72c794e
Showing
6 changed files
with
247 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters