QGIS Server GetFeatureInfo custom CSS (or better: templates!)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

QGIS Server GetFeatureInfo custom CSS (or better: templates!)

Alessandro Pasotti-2
Hi,

there have been some requests in the past about custom CSS for html
GetFeatureInfo responses from QGIS Server.

Currently, the HTML response template is hardcoded and there is no way
to customize it, the Python plugin support introduced with the latest
version of QGIS Server provide some easy ways to add some custom CSS
rules or even provide custom templates.

To get you started, I've added a new filter to my example  HelloServer plugin:

https://github.com/elpaso/qgis-helloserver/blob/master/filters/GetFeatureInfoCSSFilter.py

This filter is pretty simple, if the request is a WMS GetFeatureInfo
with HTML format, it injects a STYLE tag into the HTML HEAD.

As an exercise left to the reader, you can also intercept the call in
requestReady(self), change the INFO_FORMAT to text/xml and then do
some real templating, for example by using XSLT or pasrsing the XML
and injecting the values into a custom template.



--
Alessandro Pasotti
w3:   www.itopen.it
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: QGIS Server GetFeatureInfo custom CSS (or better: templates!)

Alessandro Pasotti-2
2015-04-20 9:15 GMT+02:00 Carles Vico Blanco <[hidden email]>:
Thanks a lot for your work Alessandro! Simple filter for a big problem! Finally we have apply our styles to the GetFeatureInfo response with your GetFeatureInfoCSSFilter.py, where we have directly insert the CSS parameters (without templates).
Now, we need to increase the control about this GetFeatureInfo response in two ways:
 
The first case is that, the attributes of my layers who are URL (http://...) can be understood as links for the QGIS Server and displayed with linkstyles that I've been included in the GetFeatureInfoCSSFilter.
 
The second is that, the response of my GetFeatureInfo request, for now show me all the layers of my QGSProject, included the layers with NO INFO values at the point of my request (show me only the header of the atributte table, without info). How can I do that the response hide the headers of the attribute table layers with NO INFO values?
 
Any Filter? Templates?
 
I have seen that in the Web Client you can modify the globaloptions.js to setup some of this, but I'm not sure they take effect in the QGIS Server response, outside Web Client.
 


Hello Carles,

No, the globaloptions.js are the options for QGIS Web Client (that is an HTML/Javascript WEB GIS for the browser) and not for  QGIS server.
You can decide to manipulate the GetFeatureInfo response in the client or in the server.

In the first case, you will use the options given in QGIS Web Client (and IIRC there is one to show URLs as links), in the latter you will use a QGIS Server Python plugin.

In my article [1] you can find a working example of server side filtering, for a very simple REGEXP substitution (string injection) but also a final hint about further and more complex output filtering. From that point it's up to you but there is basically nothing left in QGIS domain: it's everything pretty standard text manipulation or XML templating/transformation. As long as you have your XML parsed into an object you can also check for the presence of  results in a layer and decide what to do in you final output.


--
Alessandro Pasotti
w3:   www.itopen.it

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer