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 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

2 Answers 2

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: slideshare.net/geosolutions/the-status-of-the-geoserver-wps –  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",
            "http://192.168.1.41:8081/geoserver/wms",
            {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

 
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.