1

I am using MapServer 7.4.2 and I am trying to setup a WMS GetFeatureInfo using OUTPUTFORMAT instead of direct TEMPLATE but variables are not replaced

On MapServer file layer definition using:

TEMPLATE 'html.tmpl'

and with a html.tmpl:

<!-- MapServer Template -->
:
<b>Value: </b>[value_0]<br>
:

I have the proper value reply on QGIS 2.18

Value:125

When I try to implement it by replacing the template location with

TEMPLATE 'getfeatureinfo_html'

and creating an OUTPUTFORMAT option as follows

OUTPUTFORMAT
 NAME "getfeatureinfo_html"
 DRIVER "TEMPLATE"
 FORMATOPTION "FILE=html.tmpl"
 MIMETYPE "text/html"
END

The server replies with the correct template BUT the variable is not replaced, resulting in an output like:

<b>Value: </b>[value_0]<br>

Therefore the variable is not being replace and on logs (level 5) I have no indication or an error.

It looks like MapServer is not aware the layer from where to pull the value. Looked at documentation and examples but is not clear how to achieve it (missing layer information).

Later I would like to have a GetFeatureInfo for WMS with multiple mimetype options

Any tips or solutions?

2
1

It looks like MapServer is not aware the layer from where to pull the value

You need to reference the template in the layer like:

LAYER
     NAME "GBR_BGS_625k_BLT" #Bedrock lithology
     TYPE POLYGON
     STATUS ON
     DATA "bedrock625ll"
     TRANSPARENCY 100
     TOLERANCE 0
     TOLERANCEUNITS pixels
     TRANSFORM TRUE
     PROCESSING "CLOSE_CONNECTION=DEFER"
     HEADER "tmpl/bedrock_lithology_query_header.html"
     TEMPLATE "tmpl/bedrock_lithology_query_body.html"
     FOOTER "tmpl/bedrock_lithology_query_footer.html"
     PROJECTION
         ...
0

On the mapserver mailing there was several suggestion but this worked for mapserver 7.6.0

The template file for JSON named wrb.js ( see here mapserver geojson template ) has a result set for each layer,

// mapserver template
[resultset layer="Acrisols"]{
  "type": "FeatureCollection",
  "features": [
    [feature trimlast=","]
    {
      "type": "Feature",
      "id": "[qlayer]",
      "geometry": {
        "type": "Point",
        "coordinates": [
          {
            "type": "Point",
            "coordinates": [[x], [y]]
          }
        ]
      }
[/feature]
  ]}
[/resultset]
[resultset layer="Albeluvisols"]{
:
:
[/resultset]

Then the mapfile:

MAP
:
    OUTPUTFORMAT
        NAME "geojson"
        DRIVER "TEMPLATE"
        MIMETYPE "application/geo+json"
        FORMATOPTION "FILE=wrb.js"
    END
    
    OUTPUTFORMAT
        NAME "html"
        DRIVER "TEMPLATE"
        MIMETYPE "text/html"
        FORMATOPTION "FILE=wrb.html"
    END
:


  WEB
:
       'wms_feature_info_mime_type' 'text/html,application/geo+json'
:

 LAYER
      NAME "Acrisols"
:
      TYPE RASTER
      TEMPLATE 'DUMMY'
      STATUS  ON

Tried to use [include file=common.js] for eache layer but it didnt worked

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.