3

Is it somehow possible to get layer's column name using OpenLayers? any example and documentation would be really useful?

Edit: I have already tried WMS_describeLayer topp:states layer:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE WMS_DescribeLayerResponse
  SYSTEM 'http://localhost:8080/geoserver/schemas/wms/1.1.1/WMS_DescribeLayerResponse.dtd'>
<WMS_DescribeLayerResponse version="1.1.1">
    <LayerDescription
      name="topp:states"
      owsType="WFS"
      owsURL="http://localhost:8080/geoserver/wfs/WfsDispatcher?" 
      wfs="http://localhost:8080/geoserver/wfs/WfsDispatcher?">
        <Query typeName="topp:states"/>
    </LayerDescription>
</WMS_DescribeLayerResponse>
JJD
  • 1,511
  • 1
  • 17
  • 30
kinkajou
  • 4,406
  • 11
  • 52
  • 97

2 Answers2

7

You have to use WFS describeFeatureType request for the layer (typename in the request) to retrieve information about columns (feature attributes).

http://yourserversurl/wfs?request=describeFeatureType&typename=topp:states

Since you asked how to make it with WMS I guess iant indicated how you can start from there. So first step is how to switch to wfs and for be able to do that you have to know the url of wfs. So DescribeLayer request can help there...

Ozgun Alan
  • 479
  • 2
  • 6
2

The WMS standard provides an optional DescribeLayer request which will provide you with the WFS URL and featureType(s) included in the layer. From that information you can construct a WFS getFeatureDescription request for the feature(s) and from that determine the column names.

OpenLayers may provide some tools for doing this but I've never seen them.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185