[OpenLayers-Users] getFeatureInfo not working

Gerson Galang gerson.sapac at gmail.com
Wed Nov 2 07:44:54 EDT 2011


Hi guys,

I've been trying to add a getFeatureInfo capability to my web application
but I couldn't get openlayers to show me Geoserver's response to my
getFeatureInfo query.

After clicking on a point in the map, I could see that the actual
getFeatureInfo request is getting through to geoserver.

02 Nov 15:46:25 DEBUG [diskquota.CacheCleanerTask] - Won't launch global
quota enforcement task, 1.075GiB used out of 1.5GiB configured for the whole
cache size.
02 Nov 15:46:28 DEBUG [geoserver.filters] - filtering
http://maximus:8088/geoserver/wms
02 Nov 15:46:28 DEBUG [ows.OWSHandlerMapping] - Looking up handler for
[/wms]
02 Nov 15:46:28 DEBUG [ows.OWSHandlerMapping] - Looking up handler for
[/wms]
02 Nov 15:46:28 DEBUG [ows.OWSHandlerMapping] - Looking up handler for
[/wms]
02 Nov 15:46:28 INFO [geoserver.wms] -
Request: getServiceInfo
02 Nov 15:46:28 DEBUG [geoserver.ows] - Getting layers and styles from
LAYERS and STYLES
02 Nov 15:46:28 DEBUG [geotools.styling] - number of fts set 1
02 Nov 15:46:28 DEBUG [geoserver.ows] - establishing black_white_point style
for geofabric:capim_sensor_locations
02 Nov 15:46:28 DEBUG [geotools.styling] - number of fts set 1
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CREATE CONNECTION
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CLOSE CONNECTION
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CREATE CONNECTION
02 Nov 15:46:28 TRACE [geotools.core] - ENTRY 7
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting PropertyName
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting LiteralExpression
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting PropertyName
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting LiteralExpression
02 Nov 15:46:28 DEBUG [geotools.jdbc] - SELECT count(*) AS gt_result_ FROM
(SELECT * FROM "public"."capim_locations" WHERE "location_vicgrid94" &&
ST_GeomFromText('POLYGON ((2540474.4436591477 2420798.4504962005,
2560092.6641884143 2420680.920371125, 2559915.851910859 2395985.0522185704,
2540355.354604555 2396102.2365315673, 2540474.4436591477
2420798.4504962005))', 3111) AND ST_Intersects("location_vicgrid94",
ST_GeomFromText('POLYGON ((2540474.4436591477 2420798.4504962005,
2560092.6641884143 2420680.920371125, 2559915.851910859 2395985.0522185704,
2540355.354604555 2396102.2365315673, 2540474.4436591477
2420798.4504962005))', 3111)) LIMIT 10) gt_limited_
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CLOSE CONNECTION
02 Nov 15:46:28 INFO [geoserver.wms] -
Request: getFeatureInfo
    GetMapRequest =
GetMap Request
 version: 1.1.1
 output format: image/png
 width height: 820,500
 bbox: ReferencedEnvelope[137.175422 : 153.762939, -41.627088 : -31.512749]
 layers: geofabric:capim_sensor_locations
 styles: black_white_point
    QueryLayers = [org.geoserver.wms.MapLayerInfo at 7d69e1fb]
    XPixel = 415
    YPixel = 312
    FeatureCount = 10
    InfoFormat = text/html
    Exceptions = application/vnd.ogc.se_xml
    Version = 1.1.1
    Request = GetFeatureInfo
    BaseUrl = http://maximus:8088/geoserver/
    Get = false
    RawKvp = {INFO_FORMAT=text/html,
BBOX=137.175422,-41.627088,153.762939,-31.512749,
QUERY_LAYERS=geofabric:capim_sensor_locations, SERVICE=WMS, HEIGHT=500,
REQUEST=GetFeatureInfo, STYLES=, WIDTH=820, FEATURE_COUNT=10, VERSION=1.1.1,
FORMAT=image/png, LAYERS=geofabric:capim_sensor_locations, Y=312, X=415,
SRS=EPSG:4283}
    RequestCharset = null
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CREATE CONNECTION
02 Nov 15:46:28 TRACE [geotools.core] - ENTRY 7
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting PropertyName
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting LiteralExpression
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting PropertyName
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting LiteralExpression
02 Nov 15:46:28 DEBUG [geotools.jdbc] - SELECT count(*) AS gt_result_ FROM
(SELECT * FROM "public"."capim_locations" WHERE "location_vicgrid94" &&
ST_GeomFromText('POLYGON ((2540474.4436591477 2420798.4504962005,
2560092.6641884143 2420680.920371125, 2559915.851910859 2395985.0522185704,
2540355.354604555 2396102.2365315673, 2540474.4436591477
2420798.4504962005))', 3111) AND ST_Intersects("location_vicgrid94",
ST_GeomFromText('POLYGON ((2540474.4436591477 2420798.4504962005,
2560092.6641884143 2420680.920371125, 2559915.851910859 2395985.0522185704,
2540355.354604555 2396102.2365315673, 2540474.4436591477
2420798.4504962005))', 3111)) LIMIT 10) gt_limited_
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CLOSE CONNECTION
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CREATE CONNECTION
02 Nov 15:46:28 INFO [geotools.jdbc] - Unable to find aggregate function
matching visitor: class org.geotools.data.DataUtilities$3
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CLOSE CONNECTION
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CREATE CONNECTION
02 Nov 15:46:28 TRACE [geotools.core] - ENTRY 7
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting PropertyName
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting LiteralExpression
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting PropertyName
02 Nov 15:46:28 DEBUG [geotools.filter] - exporting LiteralExpression
02 Nov 15:46:28 DEBUG [geotools.jdbc] - SELECT
"id","version","name","subdivision","mappublicationid","mapreference","water
courseid","watercoursestageid","watercoursetypeid","accessroad","nearesttown
","region","northing","easting","latitude","longitude","howtofind","howtosam
ple",encode(ST_AsBinary(ST_Force_2D("location_vicgrid94")),'base64') as
"location_vicgrid94" FROM "public"."capim_locations" WHERE
"location_vicgrid94" && ST_GeomFromText('POLYGON ((2540474.4436591477
2420798.4504962005, 2560092.6641884143 2420680.920371125, 2559915.851910859
2395985.0522185704, 2540355.354604555 2396102.2365315673, 2540474.4436591477
2420798.4504962005))', 3111) AND ST_Intersects("location_vicgrid94",
ST_GeomFromText('POLYGON ((2540474.4436591477 2420798.4504962005,
2560092.6641884143 2420680.920371125, 2559915.851910859 2395985.0522185704,
2540355.354604555 2396102.2365315673, 2540474.4436591477
2420798.4504962005))', 3111)) LIMIT 10
02 Nov 15:46:28 DEBUG [geotools.jdbc] - CLOSE CONNECTION
02 Nov 15:46:35 DEBUG [diskquota.CacheCleanerTask] - Won't launch global
quota enforcement task, 1.075GiB used out of 1.5GiB configured for the whole
cache size.
02 Nov 15:46:45 DEBUG [diskquota.CacheCleanerTask] - Won't launch global
quota enforcement task, 1.075GiB used out of 1.5GiB configured for the whole
cache size.
02 Nov 15:46:55 DEBUG [diskquota.CacheCleanerTask] - Won't launch global
quota enforcement task, 1.075GiB used out of 1.5GiB configured for the whole
cache size.

The issue is OpenLayers is not even getting anything back from Geoserver.
I'm not really if the issue sits within OpenLayers or Geoserver. Firebug
shows me that OpenLayers is sending the correct message to Geoserver. If I
copy the actual URL request on another tab on my browser, I get the
getFeatureInfo response table back.

Will you be able to tell me if there's anything wrong with my code below or
just giv eme a tip on how else I can track what's causing the issue?

    var map = null;

    // declare box as a global variable so we can use its value when
removing
    // the bounding box from the old location and redrawing a new box in the
new
    // selected location.
    var box = null;

    // base layer...
    var statesGwc = new OpenLayers.Layer.WMS('State',
            '${geoserverWmsGwcUrl}',
            {
              layers: 'gwc_victoria_state',
              format: 'image/png'
            },
            {
              buffer : 0,
              displayOutsideMaxExtent : false
            });

    // overlay...
    var sensorLocations = new OpenLayers.Layer.WMS('Sensor Locations',
            '${geoserverWmsUrl}',
            {
                layers : 'geofabric:capim_sensor_locations',
                transparent : true
            },
            {
                buffer : 0,
                displayOutsideMaxExtent : false,
                opacity : 0.8,
                isBaseLayer : false,
                visibility : true

            });

    var info = new OpenLayers.Control.WMSGetFeatureInfo({
        url: '${geoserverWmsUrl}',
        title: 'Identify features by clicking',
        queryVisible: true,
        eventListeners: {
            getfeatureinfo: function(event) {
                alert('x: ' + event.xy.x);
                alert('y: ' + event.xy.y);
                // I don't get anything hereŠ just 'text: '
                alert('text: ' + event.text);
                map.addPopup(new OpenLayers.Popup.FramedCloud(
                    "chicken",
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true
                ));
            }
        }
    });

    function <portlet:namespace/>createMap() {
        // maxExtent will always be Victoria's bounding box
        //var bounds = new OpenLayers.Bounds(138.0000, -44.0000, 154.0000,
-28.0000);

        // bbox according to ABS...
        var bounds = new OpenLayers.Bounds(140.961681984,
-39.159189527500004, 149.976679008, -33.980647586);
        OpenLayers.DOTS_PER_INCH = 90.71428571428572;
        var options = {
                    maxExtent : bounds,
                    resolutions: [0.020228679458984378,
0.010114339729492189, 0.005057169864746094, 0.002528584932373047,
0.0012642924661865236, 6.321462330932618E-4, 3.160731165466309E-4,
1.5803655827331545E-4, 7.901827913665773E-5, 3.950913956832886E-5,
1.975456978416443E-5, 9.877284892082216E-6, 4.938642446041108E-6,
2.469321223020554E-6, 1.234660611510277E-6, 6.173303057551385E-7,
3.0866515287756924E-7, 1.5433257643878462E-7, 7.716628821939231E-8,
3.8583144109696155E-8, 1.9291572054848077E-8, 9.645786027424039E-9,
4.822893013712019E-9, 2.4114465068560097E-9, 1.2057232534280048E-9,
6.028616267140024E-10, 3.014308133570012E-10, 1.507154066785006E-10,
7.53577033392503E-11, 3.767885166962515E-11],
                    maxResolution : 0.2433281250000001,
                    projection : 'EPSG:4283',
                    units : 'degrees'
                    //allOverlays : false
                };

        map = new OpenLayers.Map('map',options);
        map.addLayers([statesGwc,sensorLocations]);
        map.addControl(info);
        info.activate();
    }

I just thought I should mention that the projection used by sensorLocations
is in EPSG:3111 while statesGwc is in EPSG:4283. I don't see that causing
any issue as geoserver does the projection transformation behind the scenes.

Thanks,
Gerson



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111102/9f386c2b/attachment-0001.html


More information about the Users mailing list