Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
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 Jun 28 '12 at 13:30
There is no much docs, but you can have a look at this presentation: – Andrea Aime Jun 29 '12 at 9:12
Thanks. I'll check it out. – okello Jun 29 '12 at 9:53

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.

share|improve this answer

Your Answer


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.