[Geoserver-users] App-Schema Custom GetFeatureInfo HTML

Hello,

Apologies for asking the same question twice, I was unsure if my question below had reached the mailing list – if anyone could provide me with any information regarding the query below, it would be really appreciated :slight_smile:

Many thanks,

Ryan

From: Ryan Moody [mailto:ryan.moody@anonymised.com]
Sent: 08 November 2013 16:34
To: geoserver-users@lists.sourceforge.net
Cc: Francoise Kingman; Neil Kirk
Subject: [Geoserver-users] App-Schema Custom GetFeatureInfo HTML

Hello,

Having successfully got my App-Schema based WMS to return a PNG image, I now wish to override the GetFeatureInfo request to output custom HTML. I’ve defined the following content.ftl template:

=== Begin content.ftl

<#list features as feature>

  • ${feature.fid}
    • <#list feature.attributes as attribute>

      <#if attribute.name != “the_geom”>

    • ${attribute.name} = ${attribute.value}
    • </#if>

      </#list>

</#list>

=== End content.ftl

This template gives me the bullet point list I expect to see for the tutorial (non App-Schema) data layers when I invoke a GetFeatureInfo request by clicking on the OpenLayers map, however, when I use the same content.ftl for my App-Schema data layer, the default HTML (a table of attributes instead of my custom bulleted list) is displayed.

Does App-Schema support the use of a custom content.ftl template? If so, what modifications do I need to make to make to the template above in order to display the bulleted list?

Best Regards,

Ryan

On Wed, Nov 20, 2013 at 5:23 PM, Ryan Moody <ryan.moody@anonymised.com> wrote:

Hello,

Apologies for asking the same question twice, I was unsure if my question
below had reached the mailing list – if anyone could provide me with any
information regarding the query below, it would be really appreciated :slight_smile:

As far as I can see, if the feature is a complex one, a different template
is used, complex_content.ftl.

The default one seems to contain this:

<#--
Macro's used for content
-->

<#macro property node>
    <#if !node.isGeometry>
       <#if node.isComplex>
       <td> <@feature node=node.rawValue type=node.type /> </td>
      <#else>
      <td>${node.value?string}</td>
      </#if>
    </#if>
</#macro>

<#macro header typenode>
<caption class="featureInfo">${typenode.name}</caption>
  <tr>
  <th>fid</th>
<#list typenode.attributes as attribute>
  <#if !attribute.isGeometry>
    <#if attribute.prefix == "">
    <th >${attribute.name}</th>
    <#else>
    <th >${attribute.prefix}:${attribute.name}</th>
    </#if>
  </#if>
</#list>
  </tr>
</#macro>

<#macro feature node type>
<table class="featureInfo">
  <@header typenode=type />
  <tr>
  <td>${node.fid}</td>
  <#list node.attributes as attribute>
      <@property node=attribute />
  </#list>
  </tr>
</table>
</#macro>

<#--
Body section of the GetFeatureInfo template, it's provided with one feature
collection, and
will be called multiple times if there are various feature collections
-->
<table class="featureInfo">
  <@header typenode=type />

<#assign odd = false>
<#list features as feature>
  <#if odd>
    <tr class="odd">
  <#else>
    <tr>
  </#if>
  <#assign odd = !odd>

  <td>${feature.fid}</td>
  <#list feature.attributes as attribute>
    <@property node=attribute />
  </#list>
  </tr>
</#list>
</table>
<br/>

Hope this helps

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Andrea, you’re a star! I’ve renamed my template from content.ftl to complex_content.ftl and this has worked perfectly – thank you very much :slight_smile:

Best Regards,

Ryan

From: andrea.aime@anonymised.com84… [mailto:andrea.aime@anonymised.com] On Behalf Of Andrea Aime
Sent: 20 November 2013 16:38
To: Ryan Moody
Cc: GeoServer Mailing List List; Francoise Kingman; Neil Kirk
Subject: Re: [Geoserver-users] App-Schema Custom GetFeatureInfo HTML

On Wed, Nov 20, 2013 at 5:23 PM, Ryan Moody <ryan.moody@anonymised.com> wrote:

Hello,

Apologies for asking the same question twice, I was unsure if my question below had reached the mailing list – if anyone could provide me with any information regarding the query below, it would be really appreciated :slight_smile:

As far as I can see, if the feature is a complex one, a different template is used, complex_content.ftl.

The default one seems to contain this:

<#–

Macro’s used for content

<#macro property node>

<#if !node.isGeometry>

<#if node.isComplex>

<@feature node=node.rawValue type=node.type />

<#else>

${node.value?string}

</#if>

</#if>

</#macro>

<#macro header typenode>

${[typenode.name](http://typenode.name)} fid

<#list typenode.attributes as attribute>

<#if !attribute.isGeometry>

<#if attribute.prefix == “”>

${[attribute.name](http://attribute.name)}

<#else>

${attribute.prefix}:${[attribute.name](http://attribute.name)}

</#if>

</#if>

</#list>

</#macro>

<#macro feature node type>

<@header typenode=type />

<#list node.attributes as attribute>

<@property node=attribute />

</#list>

${node.fid}

</#macro>

<#–

Body section of the GetFeatureInfo template, it’s provided with one feature collection, and

will be called multiple times if there are various feature collections

<@header typenode=type />

<#assign odd = false>

<#list features as feature>

<#if odd>

<#else>

</#if>

<#assign odd = !odd>

<#list feature.attributes as attribute>

<@property node=attribute />

</#list>

</#list>

${feature.fid}

Hope this helps

Cheers

Andrea

==

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

==

Ing. Andrea Aime

@geowolf

Technical Lead

GeoSolutions S.A.S.

Via Poggio alle Viti 1187

55054 Massarosa (LU)

Italy

phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

http://www.geo-solutions.it

http://twitter.com/geosolutions_it


On Mon, Nov 25, 2013 at 10:44 AM, Ryan Moody <ryan.moody@anonymised.com> wrote:

Andrea, you’re a star! I’ve renamed my template from content.ftl to
complex_content.ftl and this has worked perfectly – thank you very much :slight_smile:

Happy to be of help.
If you have time, could you open a ticket at
http://jira.codehaus.org/browse/GEOS to report the missing bit in the
documentation?
(or if you have even more time, provide a patch for the docs? :-p )

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Hi,

Sorry I just only saw this email. I implemented this.

This is in fact already documented:

http://docs.geoserver.org/latest/en/user/data/app-schema/wms-support.html#getfeatureinfo

Regards
Niels

On 25/11/13 10:58, Andrea Aime wrote:

On Mon, Nov 25, 2013 at 10:44 AM, Ryan Moody <ryan.moody@anonymised.com <mailto:ryan.moody@anonymised.com>> wrote:

    Andrea, you're a star! I've renamed my template from content.ftl
    to complex_content.ftl and this has worked perfectly -- thank you
    very much :slight_smile:

Happy to be of help.
If you have time, could you open a ticket at http://jira.codehaus.org/browse/GEOS to report the missing bit in the documentation?
(or if you have even more time, provide a patch for the docs? :-p )

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users