AW: [OpenLayers-Users] WMS polygon fill color

IvanBell Ivan.Bell at CCA.com
Tue May 17 18:42:12 EDT 2011


Works like a champ.  Thanks a lot.  I tried for quite a few days to find the
solution to this.


I have a follow-up about my SLD:




var sld = '<StyledLayerDescriptor version="1.0.0"';
sld += '    xsi:schemaLocation="http://www.opengis.net/sld
StyledLayerDescriptor.xsd" ';
sld += '    xmlns="http://www.opengis.net/sld" ';
sld += '    xmlns:ogc="http://www.opengis.net/ogc" ';
sld += '    xmlns:xlink="http://www.w3.org/1999/xlink" ';
sld += '    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
sld += '   <NamedLayer>';
sld += '      <Name>MyStore:MyLayer</Name>';
sld += '      <UserStyle>';
sld += '         <Name>Colored Polygon</Name>';
sld += '         <Title>Colored Polygon</Title>';
sld += '         <FeatureTypeStyle>';
sld += '            <Rule>';
sld += '               <ogc:Filter>';
sld += '                  <ogc:Or>';
sld += '                     <ogc:FeatureId fid="MyLayer.1" />';
sld += '                     <ogc:FeatureId fid="MyLayer.2" />';
sld += '                     <ogc:FeatureId fid="MyLayer.3" />';
sld += '                  </ogc:Or>';
sld += '               </ogc:Filter>';
sld += '               <PolygonSymbolizer>';
sld += '                  <Fill>';
sld += '                     <CssParameter
name="fill">#FF0000</CssParameter>';
sld += '                     <CssParameter
name="fill-opacity">0.5</CssParameter>';
sld += '                  </Fill>';
sld += '                  <Stroke>';
sld += '                     <CssParameter
name="stroke">#800000</CssParameter>';
sld += '                     <CssParameter
name="stroke-width">2</CssParameter>';
sld += '                  </Stroke>';
sld += '               </PolygonSymbolizer>';
sld += '            </Rule>';
sld += '            <Rule>';
sld += '               <ogc:Filter>';
sld += '                  <ogc:Not>';
sld += '                     <ogc:Or>';
sld += '                        <ogc:FeatureId fid="MyLayer.1" />';
sld += '                        <ogc:FeatureId fid="MyLayer.2" />';
sld += '                        <ogc:FeatureId fid="MyLayer.3" />';
sld += '                     </ogc:Or>';
sld += '                  </ogc:Not>';
sld += '               </ogc:Filter>';
sld += '               <PolygonSymbolizer>';
sld += '                  <Fill>';
sld += '                     <CssParameter
name="fill">#FFFF00</CssParameter>';
sld += '                     <CssParameter
name="fill-opacity">0.5</CssParameter>';
sld += '                  </Fill>';
sld += '                  <Stroke>';
sld += '                     <CssParameter
name="stroke">#CCCC00</CssParameter>';
sld += '                     <CssParameter
name="stroke-width">2</CssParameter>';
sld += '                  </Stroke>';
sld += '               </PolygonSymbolizer>';
sld += '            </Rule>';
sld += '         </FeatureTypeStyle>';
sld += '      </UserStyle>';
sld += '   </NamedLayer>';
sld += '</StyledLayerDescriptor>';


coloredLayer = new OpenLayers.Layer.WMS(
   "Polygons-Room", "http://localhost:8081/geoserver/wms",
   {
      layers: "MyStore:MyLayer",
      transparent: true,
      format: 'image/png',
      sld_body: sld
   },
   {
     singleTile: true,
     ratio: 1,
     isBaseLayer: false
   }
);




Referring to the two rules above, if I include one or the other they work as
expected.  However, having both of them fails to color any polygon.


E.g., if I comment out the first rule, then all of the polygons that do not
have the fid of "MyLayer.1", "MyLayer.2", or "MyLayer.3" will be colored
yellow.  If I comment out the second rule, then the "MyLayer.1",
"MyLayer.2", and "MyLayer.3" polygons will be colored red.  If both are
uncommented, then none of the polygons are colored.


Could you tell me how to write the rule(s) properly?  I.e., I want the three
polygons to be colored/highlighted red and the rest of the polygons in the
layer (for which I may/may not know the fid) to be colored/defaulted to
yellow.


Thanks in advance for your help.


Sincerely,

Ivan



--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/WMS-polygon-fill-color-tp6374589p6375545.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110517/e9ad4831/attachment.html


More information about the Users mailing list