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'm using GeoServer 2.1.2, and I've got a layer to which I've applied added additional WMS styles. However, I'm having trouble working out how to query the layer and retrieve the list of available styles (for use in my web app).

Any ideas?

I haven't been able to find anything in the GeoServer docs, and I'm still fairly new to the whole WMS/Geoserver thing so I'm not sure what I should be looking for on Google.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You need to make a getCapabilities request (http://localhost:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities) then look at the xml response. For each layer you will see a list of the available styles.

<Layer queryable="1">
<Name>sf:bugsites</Name>
<Title>Spearfish bug locations</Title>
<Abstract>
Sample data from GRASS, bug sites location, Spearfish, South Dakota, USA
</Abstract>
<KeywordList>
<Keyword>spearfish</Keyword>
<Keyword>sfBugsites</Keyword>
<Keyword>insects</Keyword>
<Keyword>bugsites</Keyword>
<Keyword>tiger_beetles</Keyword>
</KeywordList>
<CRS>EPSG:26713</CRS>
<CRS>CRS:84</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-103.86796131703647</westBoundLongitude>
<eastBoundLongitude>-103.63773523234195</eastBoundLongitude>
<southBoundLatitude>44.373938816704396</southBoundLatitude>
<northBoundLatitude>44.43418821380063</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-103.86796131703647" miny="44.373938816704396" maxx="-103.63773523234195" maxy="44.43418821380063"/>
<BoundingBox CRS="EPSG:26713" minx="590223.4382724703" miny="4914107.882513998" maxx="608462.4604629107" maxy="4920523.89081033"/>
<Style>
<Name>capitals</Name>
<Title>Capital cities</Title>
<Abstract/>
<LegendURL width="20" height="20">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://192.168.1.161:8080/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=bugsites"/>
</LegendURL>
</Style>
<Style>
<Name>burg</Name>
<Title>A small red flag</Title>
<Abstract>A sample of how to use an SVG based symbolizer</Abstract>
<LegendURL width="20" height="20">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://192.168.1.161:8080/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=bugsites&style=burg"/>
</LegendURL>
</Style>
<Style>
<Name>point</Name>
<Title>Default Point</Title>
<Abstract>A sample style that draws a point</Abstract>
<LegendURL width="20" height="20">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://192.168.1.161:8080/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=bugsites&style=point"/>
</LegendURL>
</Style>
</Layer>
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.