Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#2001 closed defect (fixed)

PHP MapScript getWMSFeatureInfoURL() error

Reported by: armin.burger@… Owned by: tomkralidis
Priority: high Milestone: 5.2 release
Component: MapScript-PHP Version: 4.8
Severity: normal Keywords:
Cc: tomkralidis, dmorissette, assefa

Description (last modified by dmorissette)

I have defined a WMS based layer in the map file:

CONNECTIONTYPE WMS
CONNECTION "http://myserver/cgi-bin/mapserv?map=owstest.map&"

When trying to use the PHP MapScript (MapServer 4.10) function 
'getWMSFeatureInfoURL()' for querying this layer, I get the error

msBuildWMSLayerURL(): WMS Connection String must contain the 
QUERY_LAYERS parameter to support GetFeatureInfo requests (with name in 
uppercase).

The function is only working correctly if I already put the 
"QUERY_LAYERS=layer1,layer2" to the CONNECTION string of the WMS layer 
definition in the map file. Is that an intended behaviour or a bug?

Best regards

Armin

Change History (6)

comment:1 by tomkralidis, 17 years ago

This is happenning in mapwmslayer.c, the code assumes that QUERY_LAYERS should be part of the CONNECTION string. Maybe Dan or Assefa can comment here whether this should be the case or whether MapServer should set this automagically. If the former, the docs should be updated to say this.

comment:2 by tomkralidis, 16 years ago

Cc: tomkralidis dmorissette assefa added

Looking this again, since getWMSFeatureInfoURL() is a method of layerObj, it makes sense to automagically set QUERY_LAYERS to LAYER.METADATA.wms_name.

Comments?

comment:3 by dmorissette, 16 years ago

Description: modified (diff)
Milestone: 5.2 release

Tom, I agree that we should probably use the metadata when a simple connection string with no params is used. It is very likely that we missed the update of getWMSFeatureInfoURL() when we added the ability to setup a CONNECTIONTYPE WMS layer using metadata.

Setting milestone to 5.2... hoping one of us has time to take care of it.

comment:4 by tomkralidis, 16 years ago

Owner: changed from mapserverbugs to tomkralidis
Status: newassigned

Fixed in r7645. I verified this with the following test cases in php and python:

[devgeo:/home/tkralidi/foss4g/mapserver/bugs/2001]$ cat ./test.map 
MAP
  NAME "mstrac-2001"
  STATUS ON
  EXTENT -180.0 -90.0 180.0 90.0
  SIZE 400 250
  IMAGECOLOR 200 200 200
  IMAGETYPE png
  UNITS DD
  DEBUG ON
  PROJECTION
    "init=epsg:4326"
  END

  WEB
    IMAGEPATH "/tmp/"
    IMAGEURL "/ms_tmp/"
  END

  LAYER
    NAME "carts"
    TYPE RASTER
    DEBUG TRUE
    STATUS DEFAULT
    MINSCALE 20000
    CONNECTION "http://localhost/cgi-bin/mapserv/carts" # QUERY_LAYERS set from LAYER.METADATA.wms_name
    # CONNECTION "http://localhost/cgi-bin/mapserv/carts?QUERY_LAYERS=carts" # QUERY_LAYERS set in connection string
    CONNECTIONTYPE WMS
    METADATA
      "wms_srs"            "EPSG:4326"
      "wms_name"           "carts"
      "wms_server_version" "1.1.1"
      "wms_format"         "image/png"
    END
  END
END
[devgeo:/home/tkralidi/foss4g/mapserver/bugs/2001]$ cat dd.php 
<?php

dl("php_mapscript.so");

$m = ms_newMapObj("test.map");
$l = $m->getLayerByName("carts");

$s = $l->getWMSFeatureInfoURL(m, 30, 30, 20, "application/vnd.ogc.gml");

echo "$s\n";

?>
[devgeo:/home/tkralidi/foss4g/mapserver/bugs/2001]$ cat dd.py
#!/usr/bin/python

import mapscript;

m = mapscript.mapObj("test.map");
l = m.getLayerByName("carts");

s = l.getWMSFeatureInfoURL(m, 30, 30, 20, "application/vnd.ogc.gml");

print s;
[devgeo:/home/tkralidi/foss4g/mapserver/bugs/2001]$ ./dd.py
http://localhost/cgi-bin/mapserv/carts?LAYERS=carts&REQUEST=GetFeatureInfo&SERVICE=WMS&FORMAT=image/png&STYLES=&HEIGHT=250&QUERY_LAYERS=carts&VERSION=1.1.1&SRS=EPSG:4326&WIDTH=400&BBOX=-180,-90,180,90&TRANSPARENT=TRUE&FEATURE_COUNT=20&INFO_FORMAT=application%2Fvnd.ogc.gml&X=30&EXCEPTIONS=application/vnd.ogc.se_xml&Y=30
[devgeo:/home/tkralidi/foss4g/mapserver/bugs/2001]$ php ./dd.php
http://localhost/cgi-bin/mapserv/carts?LAYERS=carts&REQUEST=GetFeatureInfo&SERVICE=WMS&FORMAT=image/png&STYLES=&HEIGHT=250&QUERY_LAYERS=carts&VERSION=1.1.1&SRS=EPSG:4326&WIDTH=400&BBOX=-180,-90,180,90&TRANSPARENT=TRUE&FEATURE_COUNT=30&INFO_FORMAT=20&X=0&EXCEPTIONS=application/vnd.ogc.se_xml&Y=30
[devgeo:/home/tkralidi/foss4g/mapserver/bugs/2001]$ 

If someone else can test and verify, that would be great.

comment:5 by tomkralidis, 16 years ago

Resolution: fixed
Status: assignedclosed

comment:6 by tomkralidis, 16 years ago

P.S. in the php example above you can omit first arg to getWMSFeatureInfoURL(). FYI the fix supports both setting QUERY_LAYERS in the CONNECTION string as well as automagically adding it if you don't.

Note: See TracTickets for help on using tickets.