I have a multipolygon layer in GeoServer. The layer represents states within a country. I want to enable a user to search for a specific state, and then only the selected state to be displayed on the base map.

The problem is two-fold: First, how to retrieve the names of polygons in the layer to enable a user to select, and second, how to display only the selected polygon on the base map.

I'm using OpenLayers for presentation. In addition, I'm using GeoServer and PostGIS. Any pointers on how to proceed?

EDIT: From some research, I'm guessing I'll have to use GeoServer filters (CQL and ECQL) as outlined here. However, I'm still a newbie at this, and any advice will be appreciated.

2 Answers 2


In order to get the list of possible values using WFS the only way is to make a GetFeature request that asks for only the name in the propertyName parameter (it's a comma separated list of values).

This should work fine as long as all the features have unique values anyways, if you are looking to extract the list of unique values out of a dataset that has duplicates WFS is not the answer, it cannot perform aggregations, you should look in WPS instead, it has a gs:Aggregate process that can perform the aggregations for you.

  • You are right. Achieving this with WFS GetFeature is a tall order. I'm now investigating possibilities with WPS. Is there resource you'd recommend? And, thanks for the insight.
    – okello
    Commented Jun 28, 2012 at 13:30
  • There is no much docs, but you can have a look at this presentation: slideshare.net/geosolutions/the-status-of-the-geoserver-wps Commented Jun 29, 2012 at 9:12

I've found a solution to the second bit of this question. The answer lies in using CQL/ECQL filters.

To display only a specific polygon, for instance, I would have the following code:

           var wms_layer = new OpenLayers.Layer.WMS(
            "Sample WMS Layer",
            {layers: "layer_name", transparent: true},
            {isBaseLayer: false, visibility: false}
        wms_layer.mergeNewParams({'CQL_FILTER': "attr_name = 'value' AND ..."})

And you can put as many filter conditions as is needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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