[Geoserver-users] SLD - dasharray and properties

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


Hi,

I think I was having the same issue:
http://osgeo-org.1560.x6.nabble.com/SLD-Stroke-Dasharray-Property-td5083512.html

Basically the dash array property only supports literal expressions (I
am in doubt if PropertyName is or not supported ...)

I solve the problem prepared the patch and so on, but I still waiting
that some in an higher position than me sign the contribution
agreement ...

Best regards,

Nuno Oliveira

Le mercredi 12 novembre 2014 à 12:18 +0000, Jones, Spencer R a écrit :

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:PropertyName>DASHARRAY</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&quot;
xmlns:sld="http://www.opengis.net/sld&quot;
xmlns:ogc="http://www.opengis.net/ogc&quot;
xmlns:gml="http://www.opengis.net/gml&quot; version="1.0.0">
<sld:NamedLayer>
<sld:Name>SWW_StyledLines</sld:Name>
<sld:UserStyle>
<sld:Name>SWW_StyledLines</sld:Name>
<sld:Title>SWW styled lines</sld:Title>
<sld:IsDefault>1</sld:IsDefault>
<sld:Abstract>SWW styled lines</sld:Abstract>
<sld:FeatureTypeStyle>
<sld:Name>TSColouredAndStyledByData</sld:Name>
<sld:Rule>
<sld:Name>Rule 1</sld:Name>
<sld:Title>ColouredAndStyledByDataDashed</sld:Title>
<sld:Abstract>Colour and style in fields MS_WEIGHT, HEXCOLOR and
DASHARRAY</sld:Abstract>
<sld:MinScaleDenominator>1</sld:MinScaleDenominator>
<sld:MaxScaleDenominator>100000.0</sld:MaxScaleDenominator>
<ogc:Filter>
<ogc:PropertyIsNotEqualTo>

<ogc:PropertyName>DASHARRAY</ogc:PropertyName>

<Literal>none</Literal>
</ogc:PropertyIsNotEqualTo>
</ogc:Filter>
<sld:LineSymbolizer>
<sld:Stroke>
<sld:CssParameter
name="stroke"><ogc:PropertyName>HEXCOLOR</ogc:PropertyName></sld:CssParameter>
<sld:CssParameter
name="stroke-width"><ogc:PropertyName>MS_WEIGHT</ogc:PropertyName></sld:CssParameter>
<sld:CssParameter
name="stroke-dasharray"><ogc:PropertyName>DASHARRAY</ogc:PropertyName></sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
</sld:Rule>
<sld:Rule>
<sld:Name>Rule 2</sld:Name>
<sld:Title>ColouredAndStyledByDataSolid</sld:Title>
<sld:Abstract>Colour and style in fields MS_WEIGHT,
HEXCOLOR</sld:Abstract>
<sld:MinScaleDenominator>1</sld:MinScaleDenominator>
<sld:MaxScaleDenominator>100000.0</sld:MaxScaleDenominator>
<ogc:Filter>
<ogc:PropertyIsEqualTo>

<ogc:PropertyName>DASHARRAY</ogc:PropertyName>

<Literal>none</Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<sld:LineSymbolizer>
<sld:Stroke>
<sld:CssParameter
name="stroke"><ogc:PropertyName>HEXCOLOR</ogc:PropertyName></sld:CssParameter>
<sld:CssParameter
name="stroke-width"><ogc:PropertyName>MS_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

________________________________________________________

Hi,
dasharray is one of the properties OGC made a static value, it’s thus not possible to link it to a
database attribute.

There is a patch to add support for it in the GeoTools Jira tracker,
http://jira.codehaus.org/browse/GEOT-3776

but it involves an API breakage and the procedure to authorize it has not been followed,
so it just stayed there.

Someone needs to make a proposal to break the GeoTools API in the geotools-devel API,
get it approved, refresh the patch (it it over a year old) and make a pull request to
get it included.

Cheers
Andrea

···

On Wed, Nov 12, 2014 at 1:18 PM, Jones, Spencer R <srjones@anonymised.com> wrote:

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



Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

==

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

==

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.