Hi,

I need to display in a map some features with their color according to the
value of their ID. I 've tried defining the following SLD for a line layer:

         <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">
                <ogc:PropertyName>ID</ogc:PropertyName>
              </CssParameter>
              <CssParameter name="stroke-width">
                <ogc:Literal>2</ogc:Literal>
              </CssParameter>
            </Stroke>
          </LineSymbolizer>

That solution is not working for me depending on the datasource ID type. To
solve that, I changed the class org.geotools.util.ColorConverterFactory
adding an extra "if" that handles the Long data Type. The code is the
following.

          // long to color
            if ( source.equals( Long.class ) ) {
                return new Converter() {
                    public Object convert(Object source, Class target)
throws Exception {
                        Integer rgba = new
Integer((int)((Long)source).longValue());
                        int alpha = 0xff000000 & rgba;
                        return new Color(rgba, alpha != 0 );

                    }
                };
            }

That solution works for me, but I am wondering if there is a better
alternative for that, just to avoid modifying the code on every geoTools
version update, or if that solution could be part of a future release for
geoTools.

Thanks in advance. Xevi
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to