WMS server hyperlinks in Virtual Data File

Victor Sotskov Victor.Sotskov at EC.GC.CA
Fri Nov 12 06:38:24 PST 2004


Here are some tips how to create hyperlinks in WMS GetFeatureInfo output
independent of WMS client.

If WMS server supports GetFeatureInfo operation then it is possible to
create HTML hyperlinks with <SrcSQL>...</SrcSQL> part of Virtual Data File
(VDF). This should work for any WMS client compliant to OGC/CGDI
specifications. WMS client has to be equipped with GetFeatureInfo request
capabilities.
The solution includes usage of concatenation and escape characters
technique in SQL string between tags <SrcSQL>...</SrcSQL>.
Concatenating operator for Oracle and PostgreSQL -  "||", for SQL Server
2000 – "+".
Escape characters for producing HTML anchors in VDF (xml based):
‘<’  ‘<’
‘>’  ‘>’
‘&’  ‘&’
‘ ” ’  ‘"’

Example of SQL string in VDF:

SELECT '<a href="http://www.google.com">' ||
TableName.FieldName || '<\a>' Hyper_Linked_FieldName_Alias FROM
TableName

This will produce the following html code in WMS GetFeatureInfo output for
the value "FieldValue" of  the field "FieldName" in the table "TableName":

<a href="http://www.google.com">FieldValue<\a>

When displayed in a web browser as HTML output we would see only the
FieldValue as an hyperlink.

If a FieldValue is null then it does not make sense to create a hyperlink
for this particular data. In this case SQL string has to include condition
for hyperlink:

SELECT

 CASE WHEN TableName.FieldName IS NULL then NULL
  ELSE
'<a href="http://www.google.com">' || TableName.FieldName
|| '<\a>'
 END
  Hyper_Linked_FieldName_Alias FROM TableName

Described syntax of SQL string in VDF (WMS server) would enable any WMS
client display data as hyperlink through GetFeatureInfo request.



More information about the MapServer-users mailing list