0

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!

  • Would it be OK to use text/plain or GML as outputformat or do you absolutely need text/html? – user30184 Jun 17 '14 at 18:34
  • gml or plain text are perfect. point is that if i put "wms_feature_info_mime_type" "text/plain" in the web metadata tag i get Unsupported INFO_FORMAT value (text/html).. only if i put "text/html" it returns something.. – dowi Jun 18 '14 at 7:08
  • INFO_FORMAT must match the mime type so use text/plain there. The columns to show are selected in layer metadata with "wms_include_items" – user30184 Jun 18 '14 at 7:15
  • thanks! i had to write infoFormat: "text/plain" and not INFO_FORMAT: 'text/plain' in openlayers and now it returns plain text. but with "wms_include_items" "all" i see only: Layer 'wmstry' Feature 8061: Cluster:FeatureCount = '1' Cluster:Group = '' and not all columns. should i still use a template tag?? – dowi Jun 18 '14 at 7:40
  • 1
    yes - when i removed the clustering and then clicked a feature i get now all its columns... so thanks allot for that!! i wonder is there a way to keep the clustering? i mean i clicked a single feature – dowi Jun 18 '14 at 7:45
1

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

  • just a comment: this works if the layer is not clustered and the parameter in openlayers is called infoFormat. thanks allot! – dowi Jun 18 '14 at 11:19
  • Clusters are newcomers for WMS and others have had problems with those too, see gis.stackexchange.com/questions/98536/…. When user hits the cluster symbol on a map the server should compute in reverse order from what data the cluster was built which may not be simple. – user30184 Jun 18 '14 at 11:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.