1

I need to chage layer style depending on attribute value on wms call. Like this

<Fill>
  <CssParameter name="fill">       
    <ogc:Function name="Recode">
     <!-- Value to transform -->
     <ogc:Function name="strTrim">
       <ogc:PropertyName>ward_no</ogc:PropertyName>
     </ogc:Function>

     <!-- Map of input to output values -->
     <ogc:Literal>28</ogc:Literal>
     <ogc:Literal>#6495ED</ogc:Literal>

     <ogc:Literal>10</ogc:Literal>
     <ogc:Literal>#B0C4DE</ogc:Literal>

     <ogc:Literal>6</ogc:Literal>
     <ogc:Literal>#F5DEB3</ogc:Literal>

     <ogc:Literal>11</ogc:Literal>
     <ogc:Literal>#F4A460</ogc:Literal>

     <ogc:Literal>14</ogc:Literal>
     <ogc:Literal>#87CEEB</ogc:Literal>

   </ogc:Function>
 </CssParameter>
</Fill>

But the attribute value [28,10,6,11,14] cal also be change dynamically. By using ENV value I can change color of each and every attribute, like this

<ogc:Function name="property">                
    <ogc:Function name="env">
         <ogc:Literal>28</ogc:Literal>
         <ogc:Literal>#6495ED</ogc:Literal>
    </ogc:Function> 
 </ogc:Function>

But how to change all input attribute? Or is their any way to create a attribute based style on wms call??

The attribute value list can also increase or decrease also depending on request

0

1 Answer 1

1

You can use the env function for each break:

<Fill>
  <CssParameter name="fill">
    <ogc:Function name="Interpolate">
      <!-- Property to transform -->
      <ogc:PropertyName>POP</ogc:PropertyName>
      <!-- Mapping curve definition pairs (input, output) -->
      <ogc:Function name="env">
        <ogc:Literal>minpop</ogc:Literal>
        <ogc:Literal>64000</ogc:Literal>
      </ogc:Function> 
      <ogc:Literal>#06E852</ogc:Literal>
      <ogc:Function name="env">
        <ogc:Literal>maxpop</ogc:Literal>
        <ogc:Literal>100000000</ogc:Literal>
      </ogc:Function> 
      <ogc:Literal>#FF0303</ogc:Literal> 
      <!-- Interpolation method -->
      <ogc:Literal>color</ogc:Literal>
      <!-- Interpolation mode - defaults to linear -->
    </ogc:Function>
  </CssParameter> 
</Fill>

Edit

If you need to change the number of breaks in the style too, you will probably need to create a new SLD "file" in your client and send that with the WMS request. This is done using the SLD-BODY parameter in the request or via SLD=url if you can make it publicly available.

1
  • But my problem is i don't know how many break will be their, if has to include another break say avgpop which is not present in my style how can i add that when call wms?? Commented Jun 21, 2018 at 20:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.