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've created a GeoServer layer group. I'm using OpenLayers.Layer.WMS to retrieve the layer group, and this works fine. In addition, I'd like to pull feature info for the layer. For this, I'm using OpenLayer's GetFeatureInfo. But the GetFeatureInfo only returns feature info for only one of the layers in the layer group. Is there a way I can retrieve feature info for both layers in the group? And, is this an optimal way of dealing with layer groups?

A section of my code is shown below:

    var layer_group = new OpenLayers.Layer.WMS(
        "Sample Layer Group",
        "http://localhost:8081/geoserver/wms",
        {layers: "layer_group_name", transparent: true},
        {isBaseLayer: false, visibility: false}
    );
    map.addLayers([layer_group]);

to retrieve the layer group.

And:

    map.events.register('click', map, function (e) {
        var url =  layer_group.getFullRequestString({
            REQUEST: "GetFeatureInfo",
            EXCEPTIONS: "application/vnd.ogc.se_xml",
            BBOX: layer_group.map.getExtent().toBBOX(),
            X: e.xy.x,
            Y: e.xy.y,
            INFO_FORMAT: 'text/html',
            QUERY_LAYERS: layer_group.params.LAYERS,
            WIDTH: layer_group.map.size.w,
            HEIGHT: layer_group.map.size.h});

        window.open(url,
                "getfeatureinfo",
                "location=0,status=0,scrollbars=1,width=600,height=150"
            );
    });

To retrieve the feature info.

My environment setup: GeoServer 2.1.3, PostGIS 1.5, OpenLayers 2.11.

EDIT: The features shown are only for one layer enter image description here

Increasing FEATURE_COUNT only increases the number of instances(rows) returned. The instances are over 1M. What I'd like to achieve is have one row having feature info for all the layers in the layer group.

share|improve this question
    
have you managed to achieve this? –  Pragnesh Patel May 20 at 13:31
add comment

3 Answers 3

up vote 0 down vote accepted

There is no way to achieve what you want with a single request, a new custom behavior would need to be added that only gets only record for each layer. This would require coding, changing the GeoServer GetFeatureInfo code paths to handle a new vendor option (we cannot have such behavior by default, it's probably against the WMS spec).

The only thing I can think of is to know what layers are in the group and issue a separate GetFeatureInfo for each of the layers separately

share|improve this answer
    
Thanks @Andrea. This is very helpful. –  okello Jun 27 '12 at 21:26
add comment

GetFeatureInfo by default (per WMS standard) just returns one result, if you want more add FEATURE_COUNT to your request, e.g.:

FEATURE_COUNT: 50

share|improve this answer
    
Thanks a lot. Do you have any idea how I can retrieve features for all the layers in the layer group? –  okello Jun 26 '12 at 9:41
1  
FEATURE_COUNT only returns more features for the one layer. Feature info for the other layers in the group are not returned, regardless of the value of FEATURE_COUNT. –  okello Jun 26 '12 at 10:27
1  
Do you have more than 50 features in the first layer? I've just tried a GetFeatureInfo in the GS preview and I can get features from all the layers in the sample layer groups –  Andrea Aime Jun 26 '12 at 14:39
    
I've edited the question above to reflect what I'm getting as I increase the FEATURE_COUNT. What I'd like is have one row, for instance, having information for each of the layers forming the layer group. Or, perhaps I'm approaching this the wrong way. I'll be grateful for an advice. –  okello Jun 27 '12 at 6:03
add comment

Try

var layerlist = "layer1:inci,layer2:cableline

QUERY_LAYERS: layerlist,

share|improve this answer
    
How can this even be syntactically correct when the quotation isn't even closed? –  whuber Sep 28 '12 at 16:46
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.