Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to execute a style based on some parameter passed through WMS Rest request. What I am trying to achieve is, while requesting the tile, I want a particular country to be filled in separate color. So I would pass "USA" in ENV parameter and the tiles for USA should be colored in different color than the rest of the world. So in the final output I would have the whole world map but only USA highlighted.

Regards Sudheesh

share|improve this question
add comment

2 Answers

The easiest way to do this is to request the plain map as usual (so with a style that showed just the borders) and then make a second WMS request with either an OGC or CQL filter attached to filter down to just the country you wanted to show.

So something like

http://suite.opengeo.org/geoserver/world/wms?&LAYERS=world%3Aborders&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-240.46875,-119.203625,240.46875,112.827625&WIDTH=684&HEIGHT=330

http://suite.opengeo.org/geoserver/world/wms?&LAYERS=world%3Aborders&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-240.46875,-119.203625,240.46875,112.827625&WIDTH=684&HEIGHT=330

and

enter image description here

http://suite.opengeo.org/geoserver/world/wms?&LAYERS=world%3Aborders&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-240.46875,-119.203625,240.46875,112.827625&WIDTH=684&HEIGHT=330&CQL_FILTER=FIPS%3D'US'

share|improve this answer
    
Thanks Iant, Does that work in environment where we get tiles pf 256*256 at different zoom levels? The map control at client side would request continuous tiles based on PAN/Zoom. Basically i am not looking for a single tile of a particular area. –  Sudheesh PM Feb 21 '13 at 8:35
    
In that case you'd use tiles for the map of the whole world and a request for the full extent for the filtered layer. Tiling won't help with filtered layers (however you do it) as the cache will hold on to the previous answers. –  iant Feb 21 '13 at 8:42
add comment
up vote 0 down vote accepted

I managed to achieve this by creating rules in SLD . Passed CountryName as ENV parameter checking the values inside ogc:PropertyIsEqualTo. For default color i used same rule with ogc:PropertyIsNotEqualTo . The sample rule is as below

<Rule>
<Name>Selected Country</Name>
<Title>Highlight the country passed using ENV parameter</Title>
<ogc:Filter>
  <ogc:PropertyIsNotEqualTo>
    <ogc:PropertyName>ISO_CODE</ogc:PropertyName>
    <ogc:Function name="env">
      <ogc:Literal>country</ogc:Literal>
      <ogc:Literal>USA</ogc:Literal>
    </ogc:Function>
  </ogc:PropertyIsNotEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
  <Fill>
    <CssParameter name="fill">#BB6464</CssParameter>
  </Fill>
</PolygonSymbolizer>   </Rule>    <Rule>
<Name>Default Colour</Name>
<Title>Colour All other countries in Diffrent Colour</Title>
 <ogc:Filter>
  <ogc:PropertyIsEqualTo>
    <ogc:PropertyName>ISO_CODE</ogc:PropertyName>
    <ogc:Function name="env">
      <ogc:Literal>country</ogc:Literal>
      <ogc:Literal>USA</ogc:Literal>
    </ogc:Function>
  </ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
  <Fill>
    <CssParameter name="fill">#67D274</CssParameter>
  </Fill>
</PolygonSymbolizer>   </Rule>

Regards Sudheesh

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.