All
I’ve been attempting with not much luck to get a database property to control our map’s line-style (i.e. dots, dashes etc) through SLD. If I use:
<sld:CssParameter name=“stroke-dasharray”>ogc:PropertyNameDASHARRAY</ogc:PropertyName></sld:CssParameter>
…the line always ends up as solid, as if it’s completely ignoring the property (or possibly the whole rule), even though the GeoServer logs do not indicate a problem. If I specify the stroke-dasharray explicitly, like this:
<sld:CssParameter name=“stroke-dasharray”>5 2</sld:CssParameter>
…then the whole SLD works perfectly, but obviously with a fixed dash, which is not what I want. The underlying table has a field called ‘DASHARRAY’ which contains values such as ‘5 1’, ‘5 2 3 2’,’none’ etc etc. The first rule below takes the records where DASHARRAY doesn’t equal ‘none’ and ties to assign the DASHARRAY value to the CSS - the second rule takes the DASHARRAY ‘none’ records and processes them without the stroke-dasharray element
If anyone knows how to successfully achieve this, please let me know. I’ve included below both the SLD and a sample of the data in the DASHARRAY database field:
SLD
<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns=“http://www.opengis.net/sld” xmlns:sld=“http://www.opengis.net/sld” xmlns:ogc=“http://www.opengis.net/ogc” xmlns:gml=“http://www.opengis.net/gml” version=“1.0.0”>
sld:NamedLayer
sld:NameSWW_StyledLines</sld:Name>
sld:UserStyle
sld:NameSWW_StyledLines</sld:Name>
sld:TitleSWW styled lines</sld:Title>
sld:IsDefault1</sld:IsDefault>
sld:AbstractSWW styled lines</sld:Abstract>
sld:FeatureTypeStyle
sld:NameTSColouredAndStyledByData</sld:Name>
sld:Rule
sld:NameRule 1</sld:Name>
sld:TitleColouredAndStyledByDataDashed</sld:Title>
sld:AbstractColour and style in fields MS_WEIGHT, HEXCOLOR and DASHARRAY</sld:Abstract>
sld:MinScaleDenominator1</sld:MinScaleDenominator>
sld:MaxScaleDenominator100000.0</sld:MaxScaleDenominator>
ogc:Filter
ogc:PropertyIsNotEqualTo
ogc:PropertyNameDASHARRAY</ogc:PropertyName>
none
</ogc:PropertyIsNotEqualTo>
</ogc:Filter>
sld:LineSymbolizer
sld:Stroke
<sld:CssParameter name=“stroke”>ogc:PropertyNameHEXCOLOR</ogc:PropertyName></sld:CssParameter>
<sld:CssParameter name=“stroke-width”>ogc:PropertyNameMS_WEIGHT</ogc:PropertyName></sld:CssParameter>
<sld:CssParameter name=“stroke-dasharray”>ogc:PropertyNameDASHARRAY</ogc:PropertyName></sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
</sld:Rule>
sld:Rule
sld:NameRule 2</sld:Name>
sld:TitleColouredAndStyledByDataSolid</sld:Title>
sld:AbstractColour and style in fields MS_WEIGHT, HEXCOLOR</sld:Abstract>
sld:MinScaleDenominator1</sld:MinScaleDenominator>
sld:MaxScaleDenominator100000.0</sld:MaxScaleDenominator>
ogc:Filter
ogc:PropertyIsEqualTo
ogc:PropertyNameDASHARRAY</ogc:PropertyName>
none
</ogc:PropertyIsEqualTo>
</ogc:Filter>
sld:LineSymbolizer
sld:Stroke
<sld:CssParameter name=“stroke”>ogc:PropertyNameHEXCOLOR</ogc:PropertyName></sld:CssParameter>
<sld:CssParameter name=“stroke-width”>ogc:PropertyNameMS_WEIGHT</ogc:PropertyName></sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
Sample data from DASHARRAY field (Oracle varchar2(20))
none
4 1
4 1
5 2 1 2
5 2 1 2
5 2 1 2
4 1
4 1
5 2 1 2
4 1
4 1
5 2 1 2
5 2 1 2
none
4 1
none
none
5 2 1 2
Thanks
Spencer Jones
GIS Tech Admin
South West Water
The information and documents sent in this email from South West Water Ltd are sent in confidence and are intended only for the use of the individual or entity named above. Please note that the contents may contain privileged, personal and/or confidential information and are not to be disclosed to any person other than the addressee. If you are not the intended recipient you are notified that any use, dissemination, distribution or copying of the information and documents contained in this email is strictly prohibited. If you have received this email in error, please return it and any copies immediately, without reading any attachments, and confirm that immediately upon returning the email, you will delete all copies on your system and network.
South West Water Limited - Registered in England No: 2366665
Registered Office:
Peninsula House
Rydon Lane
Exeter
Devon EX2 7HR