[Geoserver-users] Freemarker-Teplate: Adding two expressions

Hello group!

I created a GetFeatureInfo-template for a 2-band raster layer. This works fine and i can get the band values and convert them into numbers and write the into a table:

${cell.attributes["dgm"].value?number} ${cell.attributes["wd"].value?number}

Now i want to add these two values, this is the part that does not work.

this creates a text output like n1 + n2 (n1,2 are the correct numbers)

${cell.attributes[“dgm”].value?number} + ${cell.attributes[“wd”].value?number}

This does not work:

${${cell.attributes[“dgm”].value?number} + ${cell.attributes[“wd”].value?number}}

Writing a function sum does also not work with the expressions only with fixed numbers like 10or 20:
<#function sum a b>
<#return a + b>
</#function>

${sum(${cell.attributes["dgm"].value?number},${cell.attributes["wd"].value?number})}

Changing the localization does not have an effect:
<#setting locale=“de_DE”>

Can someone give me a hint how to add two expressions with freemarker?

Thank you in advance

Uwe

Did you get any exceptions in the log to provide a clue? Looking in the manual it appears the “+” approach is correct: http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_arit

Can you report back when you get a working example so we can add it to our docs please?

···

On 30 October 2017 at 08:22, Uwe Seher <uwe.seher@anonymised.com> wrote:

Hello group!

I created a GetFeatureInfo-template for a 2-band raster layer. This works fine and i can get the band values and convert them into numbers and write the into a table:

${cell.attributes["dgm"].value?number} ${cell.attributes["wd"].value?number}

Now i want to add these two values, this is the part that does not work.

this creates a text output like n1 + n2 (n1,2 are the correct numbers)

${cell.attributes[“dgm”].value?number} + ${cell.attributes[“wd”].value?number}

This does not work:

${${cell.attributes[“dgm”].value?number} + ${cell.attributes[“wd”].value?number}}

Writing a function sum does also not work with the expressions only with fixed numbers like 10or 20:
<#function sum a b>
<#return a + b>
</#function>

${sum(${cell.attributes["dgm"].value?number},${cell.attributes["wd"].value?number})}

Changing the localization does not have an effect:
<#setting locale=“de_DE”>

Can someone give me a hint how to add two expressions with freemarker?

Thank you in advance

Uwe


Check out the vibrant tech community on one of the world’s most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

Geoserver-users@anonymised.com.382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Jody Garnett