[GIS] Get all columns from postgis table when doing a getFeatureInfo request from mapserver’s WMS layer

getfeatureinfomapserverwms

some background:

  • im using openlayers WMSGetFeatureInfo control to get feature info from a WMS layer.
  • the data is in postgis (its a table of points).
  • im using mapserver, and you need to define a template file for getfeatureinfo request.

if i put in the template file:

any string

it works. when clicking a feature i get back this string (for any feature of course).

if i put in the template file:

[date]

it returns the current date, (not a column in the table)

if i put in the template file:

[id]

it returns a number that is not the id column of the feature, though it is different for each feature.


how can i request all columns for that feature, as if i would do a "select *" quary ?

thanks allot!

Best Answer

Attributes from source data are picked into html templates with syntax

[item name=DATE format="$value" escape=none]</td>

Use of Mapserver templates is documented in http://www.mapserver.org/mapfile/template.html. However, with templating and INFO_FORMAT=text/html it is not possible (without scripting) to automatically select all attributes into GetFeatureInfo response because all the "items" should appear in the template. I have seen that done with some scripting so that templates are created on-the-fly to suit the data.

What is easier is to use either text/plain or application/vnd.ogc.gml as INFO_FORMAT. Then all the attributes which are defined in the mapfile at LAYER level with metadata item "wms_include_items" or "gml_include_items" are written to the GetFeatureInfo response. The desired "SELECT * FROM" output is achieved for the text/plain format with this metadata setting

"wms_include_items" "all"

Full control over the advertised and allowed info_formats may require the use of metadata items "wms_getfeatureinfo_formatlist" and "wms_feature_info_mime_type" and GetFeatureInfo must be allowed in ""wms_enable_request" list. Read the documentation http://mapserver.org/ogc/wms_server.html

Related Question