Thanks, I tried this code

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.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";>
  <NamedLayer>
    <Name>Simple polygon</Name>
    <UserStyle>
      <Title>SLD Cook Book: Simple polygon</Title>
      <FeatureTypeStyle>
        <Rule>
          <PolygonSymbolizer>

            <Fill>
              <CssParameter name="fill">
  <ogc:PropertyName>color</ogc:PropertyName>
              </CssParameter>

            </Fill>


                     <Stroke>
           <CssParameter name="stroke">#FFFFFF</CssParameter>
           <CssParameter name="stroke-width">2</CssParameter>
         </Stroke>


          </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>


"The requested Style can not be used with this layer. The style
specifies an attribute of color and the layer is: xxxx:xxxx"

What have I done wrong?

the content of color is

 color
---------
 #f4b5f
 #a6be4c
 #31abb5
 #c98180
 #b1558c
 #db686c
 #672474
 #309cae
 #ddb933
 #1c9fea
 #871c67
 #4611fa
 #743229
 #5b1610
 #47ea59
 #8e341e


-Håvard

2011/8/29 David Winslow <[email protected]>:
> <CssParameter
> name="fill"><PropertyName>the_random_property</PropertyName></CssParameter>
>
> There's some other nice techniques in the SLD cookbook section of the
> manual, highly recommended reading for GeoServer stylists.
> http://docs.geoserver.org/stable/en/user/styling/index.html
>
> --
> David Winslow
> OpenGeo - http://opengeo.org/
>
> 2011/8/29 Håvard Wahl Kongsgård <[email protected]>
>>
>> >If you can modify your data, it might make sense to just add a column of
>> > random values to it and reference those from the SLD - that would allow you
>> > a bit more control if you find that the colors need tweaking (two similar
>> > colors in adjacent polygons, etc.)
>>
>> That would be a simple solution, in the SLD template how do I simply
>> set the color equal to database field value?
>>
>> -Håvard
>>
>> 2011/8/29 David Winslow <[email protected]>:
>> > If I wanted to achieve such a thing in Java, I would try something along
>> > the
>> > lines of:
>> >
>> > int hash = feature.getFeatureId().hashCode();
>> > String colorCode = String.format("#%06x", hash & 0xFFFFFF);
>> >
>> > I believe there is a format function exposed in GeoServer's SLD
>> > implementation - but I am not sure about a good SLD substitute for
>> > .hashCode.  If you have to, it's not hard for a Java developer to add a
>> > filter function.
>> >
>> > If you can modify your data, it might make sense to just add a column of
>> > random values to it and reference those from the SLD - that would allow
>> > you
>> > a bit more control if you find that the colors need tweaking (two
>> > similar
>> > colors in adjacent polygons, etc.)
>> >
>> > --
>> > David Winslow
>> > OpenGeo - http://opengeo.org/
>> >
>> > 2011/8/28 Håvard Wahl Kongsgård <[email protected]>
>> >>
>> >> Hi, I have a layer with multiple bordering polygons which needs to be
>> >> visually separated.
>> >>
>> >> One possibility is to create a massive SLD template, defining random
>> >> colors for specific polygons.
>> >>
>> >> However, I noticed this post
>> >>
>> >>
>> >> http://osgeo-org.1803224.n2.nabble.com/Random-function-in-SLD-td6125434.html
>> >>
>> >> The problem with that approach is that polygons change colors when
>> >> zooming, and when map tiles are enabled, polygons crossing different
>> >> tiles have multiple colors. With SLD templates is there another way to
>> >> do this?
>> >>
>> >>
>> >> <?xml version="1.0" encoding="ISO-8859-1"?>
>> >> <StyledLayerDescriptor version="1.0.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";>
>> >>  <!-- a Named Layer is the basic building block of an SLD document -->
>> >>  <NamedLayer>
>> >>    <Name>default_polygon</Name>
>> >>    <UserStyle>
>> >>    <!-- Styles can have names, titles and abstracts -->
>> >>      <Title>Default Polygon</Title>
>> >>      <Abstract>A sample style that draws a polygon</Abstract>
>> >>      <!-- FeatureTypeStyles describe how to render different features
>> >> -->
>> >>      <!-- A FeatureTypeStyle for rendering polygons -->
>> >>      <FeatureTypeStyle>
>> >>        <Rule>
>> >>          <Name>rule1</Name>
>> >>          <PolygonSymbolizer>
>> >>                 <Fill>
>> >>                   <CssParameter name="fill">
>> >>                     <ogc:Function name="numberFormat">
>> >>                       <ogc:Literal>'#'000000</ogc:Literal>
>> >>                       <ogc:Mul>
>> >>                         <ogc:Function name="random"></ogc:Function>
>> >>                         <ogc:Literal>1000000</ogc:Literal>
>> >>                       </ogc:Mul>
>> >>                     </ogc:Function>
>> >>                   </CssParameter>
>> >>                   <CssParameter name="fill-opacity">0.7</CssParameter>
>> >>                 </Fill>
>> >>            <Stroke>
>> >>              <CssParameter name="stroke">#000000</CssParameter>
>> >>              <CssParameter name="stroke-width">1</CssParameter>
>> >>            </Stroke>
>> >>          </PolygonSymbolizer>
>> >>        </Rule>
>> >>      </FeatureTypeStyle>
>> >>    </UserStyle>
>> >>  </NamedLayer>
>> >> </StyledLayerDescriptor>
>> >>
>> >> --
>> >> Håvard Wahl Kongsgård
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> EMC VNX: the world's simplest storage, starting under $10K
>> >> The only unified storage solution that offers unified management
>> >> Up to 160% more powerful than alternatives and 25% more efficient.
>> >> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> >> _______________________________________________
>> >> Geoserver-users mailing list
>> >> [email protected]
>> >> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>> >
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> EMC VNX: the world's simplest storage, starting under $10K
>> The only unified storage solution that offers unified management
>> Up to 160% more powerful than alternatives and 25% more efficient.
>> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> _______________________________________________
>> Geoserver-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
>

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to