1

I have a map with several CQL filters that a user can use in my website. When the user applies the CQL filter, I want them to be able to use getfeatureinfo which only shows features from the CQL filter. However, after applying a CQL-filter, it still gives featureinfo of all features, even the ones which are not visible. I looked for solutions here: OpenLayers CQL filter gets info about NOT VISIBLE features and here: How to add CQL filter into GetFeatureInfo request in OpenLayers, but I couldn't solve it myself.

My code looks something like this:

Ext.onReady(function() {

var control_zoom_max = new OpenLayers.Control.ZoomToMaxExtent({title:'Zoom naar het volledige kaartbeeld'});
    var control_zoom_in  = new OpenLayers.Control.ZoomIn({title:'Zoom gecentreerd in op het kaartbeeld'});
    var control_zoom_out = new OpenLayers.Control.ZoomOut({title:'Zoom gecentreerd uit op het kaartbeeld'});
    var control_zoom_box = new OpenLayers.Control.ZoomBox({title:'Zoom in met een te slepen rechthoek'});
    var control_nav_hist = new OpenLayers.Control.NavigationHistory();
    var control_drag_pan = new OpenLayers.Control.DragPan({title:'Verplaats het kaartbeeld met de linkermuisknop'});
    var control_identify = new OpenLayers.Control.WMSGetFeatureInfo({
        title : 'Klik op een punt of lijn voor informatie',
        layers : [ AmiceHerkomst, AmiceVerwerking],
        maxFeatures: 1000,
        queryVisible : true,
        infoFormat : 'application/vnd.ogc.gml',
        vendorParams: {
            buffer: 5  // geoserver buffer in pixels
        },
        eventListeners : {
            getfeatureinfo : function(event){
                showInfo(event);
            }
        }
    });
});

function updateFilter() {
    var plaatshtml = document.getElementById('filter').value.toLowerCase();
    var volumehtml = document.getElementById('volume').value;
    var volumeType = document.getElementById('filterType').value;
    var jaar = document.getElementById('Jaar').value;
    var maand = document.getElementById('Maand').value;
    var bedrijfhtml = document.getElementById('filternaam').value.toLowerCase();

    var plaatsnaam = "strToLowerCase(plaats) LIKE '%"+ plaatshtml +"%'";
    var volume = "totgw_1 "+ volumeType + " " + volumehtml;
    var datum = jaar + maand;
    var bedrijfsnaam = "strToLowerCase(straatnm) LIKE '%"+ bedrijfhtml +"%'";

    var filterParams = {                    
                    cql_filter: null                   
                };

    if (OpenLayers.String.trim(plaatshtml) != "") {                     
                    filterParams["cql_filter"] = plaatsnaam;                    
                }
    if (OpenLayers.String.trim(volumehtml) != ""){
                    filterParams["cql_filter"] += "AND " + volume;
                }   
    if (OpenLayers.String.trim(bedrijfhtml) != ""){
                    if (filterParams ["cql_filter"] != null){
                        filterParams["cql_filter"] += "AND " + bedrijfsnaam;
                    }
                    else {
                        filterParams["cql_filter"] = bedrijfsnaam;
                    }
                }
    if (OpenLayers.String.trim(jaar) != ""){
                    filterParams["cql_filter"] += "AND " + datum;
                }

    mergeNewParams(filterParams);
}

How do I add my CQL-filter parameters into my getfeatureinfo request?

EDIT this is what the getfeatureinfo request does looking via firebug: enter image description here

  • 1
    Could you write the GefFeatureInfo request that your code generates into your question? What is your GeoServer version? – user30184 Oct 10 '16 at 17:55
  • How can I see my GetFeatureInfo request? I use GeoServer version 2.5.4 – user30058 Oct 11 '16 at 7:32
  • 1
    Make your code to print it for you or use something like Firebug for monitoring what your application is doing. I am not sure when GeoServer was improved so that GetFeatureInfo is very well aware of what is really rendered on the map. Your version is rather old, this improvement may have published after 2.4 version. I would update GeoServer first to 2.9.1 and then to 2.9.2 immediately when it is out. – user30184 Oct 11 '16 at 7:45
  • Thanks, I added a picture in the Original post with, I think, the getfeatureinfo response when clicking on a point on the map. I don't know if that is what you mean? I hope it is possible to do it with this old version, since our company will not update anytime soon I'm afraid – user30058 Oct 11 '16 at 8:08
  • What I was after is the real http request like http://company.com/geoserver/wms?service=WMS&version=1.1.0&request=GetFeatureInfo&.... But anyway, I suppose that you have done it right because your map works as you wish but you can't make GetFeatureInfo to care about CQL_FILTER with GeoServer 2.4.6. I posted this also as an answer. – user30184 Oct 11 '16 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.