[Geoserver-users] Freemarker expression support in KML description.ftl

Is it possible to use comparison expressions in a description.ftl to alter the content of the description balloon based on attribute values?

For example:

<#if ${COUNTRY.value} = ‘Australia’>
The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
<#else>
Nothing found.
</#if>

(which doesn’t work btw)


Roger André
GIS Developer/Analyst
Enterprise Management Solutions

CH2M HILL
1100 112th Avenue NE
Suite 400
Bellevue, WA 98004
Direct 425.233.3042
roger.andre@anonymised.com

Developing People through Challenging Projects

Hi Roger,

I believe the issue is the ${...} with the reference to the variable. I
believe that this will work:

<#if COUNTRY.value = 'Australia'>

You only need to dereference the variable with "$" when outside of a
control statement. Hope that helps.

-Justin

Roger.Andre@anonymised.com wrote:

Is it possible to use comparison expressions in a description.ftl to
alter the content of the description balloon based on attribute values?

For example:

<#if ${COUNTRY.value} = 'Australia'>
  The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
<#else>
  Nothing found.
</#if>
(which doesn't work btw)

--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions

CH2M HILL
1100 112th Avenue NE
Suite 400
Bellevue, WA 98004
Direct 425.233.3042
roger.andre@anonymised.com <mailto:roger.andre@anonymised.com>

Developing People through Challenging Projects

!DSPAM:4007,47855b61134821431913854!

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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

!DSPAM:4007,47855b61134821431913854!

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

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

!DSPAM:4007,47855b61134821431913854!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Should be. I believe the templates give you everything you can do in freemarker, you can see the full range here: http://freemarker.org/docs/dgui_template_exp.html

(we love open source :wink:

Comparisons are talked about here: http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_comparison

It looks like what you're trying to do would be:

<#if ${COUNTRY.value} = "Australia">
    The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
</#if>
<#if ${COUNTRY.value} != "Australia">
   Nothing found
</#if>

So not a nice else statement, but I think you can get at the same thing. If that doesn't work let us know.

Chris

Roger.Andre@anonymised.com wrote:

Is it possible to use comparison expressions in a description.ftl to alter the content of the description balloon based on attribute values?
For example:
<#if ${COUNTRY.value} = 'Australia'>
  The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
<#else>
  Nothing found.
</#if>
(which doesn't work btw)
--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions
CH2M HILL
1100 112th Avenue NE
Suite 400
Bellevue, WA 98004
Direct 425.233.3042
roger.andre@anonymised.com <mailto:roger.andre@anonymised.com>
Developing People through Challenging Projects
!DSPAM:4005,47855b60134751637810514!

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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

!DSPAM:4005,47855b60134751637810514!

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

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

!DSPAM:4005,47855b60134751637810514!

Hi Chris,

Indeed, we do love open source. <grin>

Thanks for the link to the freemarker docs. I've found them very useful already, and I *thought* I was grokking them correctly, but maybe not. I was basing my example on this one in that doc, http://www.freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_test

Your logic would work for me as well, but unfortunately the example you sent doesn't work either.

Any other ideas for how I could test this out?
--

-----Original Message-----
From: Chris Holmes [mailto:cholmes@anonymised.com]
Sent: Wednesday, January 09, 2008 3:48 PM
To: Andre, Roger/SEA
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Freemarker expression support in KML description.ftl

Should be. I believe the templates give you everything you can do in freemarker, you can see the full range here:
http://freemarker.org/docs/dgui_template_exp.html

(we love open source :wink:

Comparisons are talked about here:
http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_comparison

It looks like what you're trying to do would be:

<#if ${COUNTRY.value} = "Australia">
    The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
</#if>
<#if ${COUNTRY.value} != "Australia">
   Nothing found
</#if>

So not a nice else statement, but I think you can get at the same thing.
  If that doesn't work let us know.

Chris

Roger.Andre@anonymised.com wrote:

Is it possible to use comparison expressions in a description.ftl to
alter the content of the description balloon based on attribute values?

For example:

<#if ${COUNTRY.value} = 'Australia'>
  The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
<#else>
  Nothing found.
</#if>
(which doesn't work btw)

--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions

CH2M HILL
1100 112th Avenue NE
Suite 400
Bellevue, WA 98004
Direct 425.233.3042
roger.andre@anonymised.com <mailto:roger.andre@anonymised.com>

Developing People through Challenging Projects

!DSPAM:4005,47855b60134751637810514!

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

----------------------------------------------------------------------
--- Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for just about anything
Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marke
tplace

!DSPAM:4005,47855b60134751637810514!

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

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

!DSPAM:4005,47855b60134751637810514!

Hmmm... Are you getting any kind of error message? That's a bummer my example didn't work, though yeah, it looks like yours should too, I didn't see that else section.

Might be good to test out an expression that doesn't depend on our attribute values, like

> <#if "Austria" = "Australia">
> The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
> </#if>
> <#if "Austria != "Australia">
> Nothing found
> </#if>

And flip those around, to see that both are working to confirm that freemarker is doing things properly. That will tell us whether it's a problem with freemarker or how we're turning attributes in to freemarker variables.

C

Roger.Andre@anonymised.com wrote:

Hi Chris,

Indeed, we do love open source. <grin>

Thanks for the link to the freemarker docs. I've found them very useful already, and I *thought* I was grokking them correctly, but maybe not. I was basing my example on this one in that doc, http://www.freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_test

Your logic would work for me as well, but unfortunately the example you sent doesn't work either.

Any other ideas for how I could test this out?
--

-----Original Message-----
From: Chris Holmes [mailto:cholmes@anonymised.com] Sent: Wednesday, January 09, 2008 3:48 PM
To: Andre, Roger/SEA
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Freemarker expression support in KML description.ftl

Should be. I believe the templates give you everything you can do in freemarker, you can see the full range here: http://freemarker.org/docs/dgui_template_exp.html

(we love open source :wink:

Comparisons are talked about here: http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_comparison

It looks like what you're trying to do would be:

<#if ${COUNTRY.value} = "Australia">
    The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
</#if>
<#if ${COUNTRY.value} != "Australia">
   Nothing found
</#if>

So not a nice else statement, but I think you can get at the same thing. If that doesn't work let us know.

Chris

Roger.Andre@anonymised.com wrote:

Is it possible to use comparison expressions in a description.ftl to alter the content of the description balloon based on attribute values?
For example:
<#if ${COUNTRY.value} = 'Australia'>
  The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
<#else>
  Nothing found.
</#if>
(which doesn't work btw)
--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions
CH2M HILL
1100 112th Avenue NE
Suite 400
Bellevue, WA 98004
Direct 425.233.3042
roger.andre@anonymised.com <mailto:roger.andre@anonymised.com>
Developing People through Challenging Projects

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

----------------------------------------------------------------------
--- Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marke
tplace

!DSPAM:4005,47855b60134751637810514!

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

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

!DSPAM:4005,47855b60134751637810514!

!DSPAM:4005,47855fae142221439371379!

That's EXACTLY IT! I feel like a dork now, but thanks for pointing out the error. :wink:
--
Roger

-----Original Message-----
From: Justin Deoliveira [mailto:jdeolive@anonymised.com]
Sent: Wednesday, January 09, 2008 8:47 AM
To: Andre, Roger/SEA
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Freemarker expression support in KML description.ftl

Hi Roger,

I believe the issue is the ${...} with the reference to the variable. I believe that this will work:

<#if COUNTRY.value = 'Australia'>

You only need to dereference the variable with "$" when outside of a control statement. Hope that helps.

-Justin

Roger.Andre@anonymised.com wrote:

Is it possible to use comparison expressions in a description.ftl to
alter the content of the description balloon based on attribute values?

For example:

<#if ${COUNTRY.value} = 'Australia'>
  The Country is ${COUNTRY.value}, the currency is ${CURR_TYPE.value}.
<#else>
  Nothing found.
</#if>
(which doesn't work btw)

--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions

CH2M HILL
1100 112th Avenue NE
Suite 400
Bellevue, WA 98004
Direct 425.233.3042
roger.andre@anonymised.com <mailto:roger.andre@anonymised.com>

Developing People through Challenging Projects

!DSPAM:4007,47855b61134821431913854!

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

----------------------------------------------------------------------
--- Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for just about anything
Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marke
tplace

!DSPAM:4007,47855b61134821431913854!

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

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

!DSPAM:4007,47855b61134821431913854!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org