[Geoserver-users] SLD database-driven and GetLegendGraphic

Hi,

I tried to make a SLD for a layer with the fill color of PolygonSymbolizer
stored in an column "couleur" of a postGis table.

So, for each entity I have a color stored in hexa value wich corresponds to
a code.

My polygonSymbolizer is like this :

        <PolygonSymbolizer>
          <Fill>
            <CssParameter
name="fill"><ogc:PropertyName>couleur</ogc:PropertyName></CssParameter>
            <CssParameter name="fill-opacity">1</CssParameter>
          </Fill>
         <Stroke>
            <CssParameter name="stroke">#566cd3</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
          </Stroke>
        </PolygonSymbolizer>

The resulting wms Map is pretty good and the polygon are correctly filled.

http://www.nabble.com/file/p22953916/testSLD.jpg

But how can I do to have correct getLegendgraphic. In fact, the
GetLegendGraphic output only one empty fill square.

I tried to make different rules for each code with a filter and with the
same polygonsymbolizer. But the result is an empty square for each rule.

So how can I represents the database stored color in the GetLegendGraphic
request without hard code it in SLD?

Thanks in advance for any solution.
--
View this message in context: http://www.nabble.com/SLD-database-driven-and-GetLegendGraphic-tp22953916p22953916.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Jean-Baptiste Raynaud ha scritto:

Hi,

I tried to make a SLD for a layer with the fill color of PolygonSymbolizer
stored in an column "couleur" of a postGis table.

So, for each entity I have a color stored in hexa value wich corresponds to
a code.

My polygonSymbolizer is like this :

        <PolygonSymbolizer>
          <Fill>
            <CssParameter
name="fill"><ogc:PropertyName>couleur</ogc:PropertyName></CssParameter>
            <CssParameter name="fill-opacity">1</CssParameter>
          </Fill>
         <Stroke>
            <CssParameter name="stroke">#566cd3</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
          </Stroke>
        </PolygonSymbolizer>

The resulting wms Map is pretty good and the polygon are correctly filled.

http://www.nabble.com/file/p22953916/testSLD.jpg

But how can I do to have correct getLegendgraphic. In fact, the
GetLegendGraphic output only one empty fill square.

I tried to make different rules for each code with a filter and with the
same polygonsymbolizer. But the result is an empty square for each rule.

So how can I represents the database stored color in the GetLegendGraphic
request without hard code it in SLD?

Thanks in advance for any solution.

There is none besides hard-coding the colors in the SLD.
The GetLegendGraphics code inspects only the SLD, and with good reason:
- the dataset might be huge (datasets with a hundredth million features
   are not uncommon), generating a lengend by fully scanning them would
   take various minutes even on powerful servers
- the GetLegendGraphics afaik must generate one box per rule. But there
   is no way to tell which color it should be drawn, as each feature
   catched by the rule might be using a different one (even in the hp
   of scanning the dataset fully).

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.