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

Reply via email to