Geonode: GNIP 77 - GetFeatureInfo Templating For GeoNode

Created on 9 Jun 2020  Â·  20Comments  Â·  Source: GeoNode/geonode

GNIP 77 - GetFeatureInfo Templating For GeoNode

Overview

This proposal aims to improve the way GeoNode injects a “GetFeatureInfo” Template into the maps created with MapStore2.

What is a “GetFeatureInfo” Template and how is it working now?

When “clicking” over a feature of a Layer into a GeoNode Map, an info window popups showing a formatted representation of the raw data identified by the coordinates (see Fig. 1)

image

The way how such information is presented to the user is defined by what we call “GetFeatureInfo Template”. The latter is basically an HTML snippet containing some placeholders and special inline codes that instruct GeoServer on how to generate the raw data output.

The outcome is a rendered HTML snippet with the real values replacing the placeholders of the Template.

Currently, GeoNode allows a very simple mechanism to customize the “GetFeatureInfo Template” of a Layer.

It is possible, through the Layer Metadata Editor Wizard, to assign a name and a label to the attributes we want to display on the GetFeatureInfo output.

Notice that the attributes without a label and name, in case others are present, won’t be rendered at all.

As an instance, by using the example above, we can customize a bit the Layer Metadata as shown in Fig. 2

image

The “GetFeatureInfo” output will change accordingly as shown in Fig. 3

image

Proposed By

@afabiani

Assigned to Release

This proposal is for GeoNode 3.1.

State

  • [x] Under Discussion
  • [x] In Progress
  • [x] Completed
  • [ ] Rejected
  • [ ] Deferred

Motivation

Current GetFeatureInfo Templates are limited to labels and order. The idea would be to allow GetFeatureInfo to be able to render also images, links, maybe other media in the future, and also to allow the user to customize the HTML template in a fancy way.

Proposal

Implement widget based visualization of attributes for GetFeatureInfo response

  1. Add a new "Widget" column to the Dataset Attributes step of the Metadata Wizard, where "Link" or "Image" widgets can be selected (see Fig. 4).

  2. GeoNode already inflates an HTML template if custom dataset attributes are defined. We need to extend this automatically created template to include HTML fragment to show the selected widget.

This is a simplified approach, which assumes that the specific attribute value is directly usable as a <a href="value"> or a <img src="value">.

In both cases, we assume absolute URLs.

image

Implement custom HTML template for visualization of GetFeatureInfo response

As an alternative to the use of aliases and widgets (see above) for the visualization of GetFeatureInfo response, we implement the option to configure a template as HTML code.

A textarea for the editing of the template will be placed below the table of attributes inside the Dataset Attributes step of the Metadata Wizard

In this case, GeoNode will not generate the GetFeatureInfo template for MapStore itself, rather the custom HTML will be used.

NOTICE: Attributes configurations and HTML templates are mutually exclusive options.

image

Backwards Compatibility

No backward compatibility.

Future evolution

  • Move the template editor on the GIS client in order to make easier the access to the UI.
  • Allow the GetFeatureInfo template to render other media types like videos and sounds.

Feedback

Update this section with relevant feedbacks, if any.

Voting

Project Steering Committee:

  • Alessio Fabiani: +1
  • Francesco Bartoli: +1 (mail in dev list)
  • Giovanni Allegri:
  • Simone Dalmasso:
  • Toni Schoenbuchner: +1
  • Florian Hoedt: +1

Links

Remove unused links below.

feature gnip

Most helpful comment

The tynimce html editor seems to be able to escape code already

image

image

All 20 comments

Great Feature.
Imho:

Implement widget based visualization of attributes for GetFeatureInfo response

is more user friendly where

Implement custom HTML template for visualization of GetFeatureInfo response

might suit better for users which can write at least a little HTML code. I'm a bit more in favor for the later but do not have an objective view

@t-book actually the idea is to implement both.

For the time being, I've implemented something like this:

image

image

image

@afabiani Nice even better!

Added video and audio too

image

@afabiani would it work with an iframe from vimeo or youtube or require the video to be uploaded to the server?

I like the improvement as this adds a further connection between layers and document section. One could upload a PDF or some image and show it with a layer

@t-book you can put whatever you want inside the HTML template, even completely unrelated to the attributes values :)

Added an iframe property too

image

it will render something like this

image

Otherwise, you can use the HTML editor

This is great!

Will these be enabled for the WMS GetFeature Infos, too? Like the GeoServer implementation described here: https://docs.geoserver.org/stable/en/user/tutorials/GetFeatureInfo/index.html

@gannebamm unfortunately not at this stage. It's in our plans to refactor this side and improve the integration with MapStore's client to align GetFeatureInfo and GetFeature (attributes table) responses.

@giohappy @afabiani As this allows a vast variety of user-added content we should double-check bulletproof server-side validation to prevent xss. The used tiny-mce has two known vulnerabilities, which I, fortunately -even if tampering the request- could not reproduce.

Where I am unsure is if allowing iframe is a good thing at all. You could not stop users to spoil maps with porn or other things. Here are more reasons.

I agree with you @t-book, I was having the same concerns.
@afabiani I would remove the iframe option from the widgets.
For the free html template I guess we could to a bit of static analysis of the submitted markup, and refuse to save code containing

@ahmednosman as mentioned before we have plans to extend the management of layer presets, including those regarding getfeatureinfo and getfeature response. It won't happen very soon but the plans are on our tables and will be shared with the community as soon they're in a good shape.

image

right now i try add/show picture and link manually from edit data table with simple

The tynimce html editor seems to be able to escape code already

image

image

@ahmednosman https://github.com/GeoNode/geonode/issues/6182#issuecomment-641931566

I suggest a different take on this, I would like to suggest the getfeatureinfo template(identify popup template) to apply at the presentation level and not the layer meta data level (so we can have more than one template defined). A user can have multiple presentations (SLDs) for the same layer, for each presentation the user wants a different featureInfo template [...]

This is a good point though. One layer may have several SLDs to actually render the information. We for example have monitoring data with a great number of attributes. These usually get hosted as one layer and displayed with many different SLDs. I would not know how to create one single feature-info to cover them all.

@afabiani It looks this issue has been accidently closed? I do reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

capooti picture capooti  Â·  8Comments

cezio picture cezio  Â·  6Comments

t-book picture t-book  Â·  5Comments

capooti picture capooti  Â·  8Comments

jondoig picture jondoig  Â·  8Comments