[Geoserver-users] SLD - using the if_then_else as an else-if

Hi List,
While waiting on an answer to my other thread, I decided to try and tackle the anchor problem. I came up with the following which, in theory at least, seems like it should work to get my se:AnchorPointY:

Pseudocode version:

If ANCHOR_PT == 0, 3 or 6
return 0
else if ANCHOR_PT == 1, 4 or 7
return 0.5
else
return 1

SLD version:

<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal0</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal3</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal6</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0</ogc:Literal>
<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal1</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal4</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal7</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0.5</ogc:Literal>
ogc:Literal1</ogc:Literal>
</ogc:Function>
</ogc:Function>

Unfortunately it’s failing validation:

The “unable to find function” is particularly ominous though all referenced functions are in my wfs GetCapabilities.

Anyone able to advise? What am I doing wrong?
Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

The if_then_else function is a bit of a hack, and has corresponding test functions (like equals()) that must be used with it instead of the normal Filter elements (SLD disallows Filters as children of Expressions.) See this gist (including an SLD style and the CSS I used to generate it): https://gist.github.com/dwins/5859628

Alternatively you could just have multiple rules representing the different branches of the if-then-else tree. That would look like this gist: https://gist.github.com/dwins/5859680

Hope it helps.

···

On Tue, Jun 25, 2013 at 11:46 AM, Jonathan Moules <jonathanmoules@…4942…> wrote:

Hi List,
While waiting on an answer to my other thread, I decided to try and tackle the anchor problem. I came up with the following which, in theory at least, seems like it should work to get my se:AnchorPointY:

Pseudocode version:

If ANCHOR_PT == 0, 3 or 6
return 0
else if ANCHOR_PT == 1, 4 or 7
return 0.5
else
return 1

SLD version:

<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal0</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal3</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal6</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0</ogc:Literal>
<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal1</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal4</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal7</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0.5</ogc:Literal>
ogc:Literal1</ogc:Literal>
</ogc:Function>
</ogc:Function>

Unfortunately it’s failing validation:

The “unable to find function” is particularly ominous though all referenced functions are in my wfs GetCapabilities.

Anyone able to advise? What am I doing wrong?
Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


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

On Tue, Jun 25, 2013 at 5:46 PM, Jonathan Moules <
jonathanmoules@anonymised.com> wrote:

Hi List,
  While waiting on an answer to my other thread, I decided to try and
tackle the anchor problem. I came up with the following which, in theory at
least, seems like it should work to get my se:AnchorPointY:

First thing first: anchor point for what? We only support it for text
symbolizers, not for point ones (anchor point in point symbolizers
is new in SE 1.1, but remember, we only support SE as long as syntax goes,
but don't support any new functionality of it, the engine
really works in SLD 1.0)

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 David,
Your in3 example worked perfectly as far as I can see.

Suddenly looking at how simple the CSS is, your CSS module is looking quite tempting. :slight_smile:

Many thanks!

Andrea: It’s for a text symbolizer. Thanks for the clarification though.

Jonathan

···

On Tue, Jun 25, 2013 at 11:46 AM, Jonathan Moules <jonathanmoules@…4942…> wrote:

Hi List,
While waiting on an answer to my other thread, I decided to try and tackle the anchor problem. I came up with the following which, in theory at least, seems like it should work to get my se:AnchorPointY:

Pseudocode version:

If ANCHOR_PT == 0, 3 or 6
return 0
else if ANCHOR_PT == 1, 4 or 7
return 0.5
else
return 1

SLD version:

<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal0</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal3</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal6</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0</ogc:Literal>
<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal1</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal4</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal7</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0.5</ogc:Literal>
ogc:Literal1</ogc:Literal>
</ogc:Function>
</ogc:Function>

Unfortunately it’s failing validation:

The “unable to find function” is particularly ominous though all referenced functions are in my wfs GetCapabilities.

Anyone able to advise? What am I doing wrong?
Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


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

Hi List,
Further weirdness happening. I have the below, the premise of which is - if it’s a certain layer then the max scale threshold is different from the default which is the “else”. Problem is GeoServer is giving me various problems.

se:MaxScaleDenominator

<ogc:Function name=“if_then_else”>
<ogc:Function name=“equalTo”>
ogc:PropertyNameCODE</ogc:PropertyName>
ogc:Literal5422</ogc:Literal>
</ogc:Function>
ogc:Literal150000</ogc:Literal>
ogc:Literal300000</ogc:Literal>
</ogc:Function>
</se:MaxScaleDenominator>

At validation I get:

  • Parsing failed for MaxScaleDenominator: java.lang.NumberFormatException: empty String
  • line 20: cvc-type.3.1.2: Element ‘se:MaxScaleDenominator’ is a simple type, so it must have no element information item [children].
  • line 20: cvc-datatype-valid.1.2.1: ‘’ is not a valid value for ‘double’.
  • line 20: cvc-type.3.1.3: The value ‘’ of element ‘se:MaxScaleDenominator’ is not valid.

the WMS itself returns an exception:
java.io.IOException
null
Parsing failed for MaxScaleDenominator: java.lang.NumberFormatException: empty String
empty String

Am I not allowed to use a function inside a MaxScaleDenominator? It works fine for my anchoring from yesterday.

Thanks,
Jonathan

···

On Tue, Jun 25, 2013 at 11:46 AM, Jonathan Moules <jonathanmoules@…4942…> wrote:

Hi List,
While waiting on an answer to my other thread, I decided to try and tackle the anchor problem. I came up with the following which, in theory at least, seems like it should work to get my se:AnchorPointY:

Pseudocode version:

If ANCHOR_PT == 0, 3 or 6
return 0
else if ANCHOR_PT == 1, 4 or 7
return 0.5
else
return 1

SLD version:

<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal0</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal3</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal6</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0</ogc:Literal>
<ogc:Function name=“if_then_else”>
ogc:Or
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal1</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal4</ogc:Literal>
</ogc:Function>
<ogc:Function name=“EqualTo”>
ogc:PropertyNameANCHOR_PT</ogc:PropertyName>
ogc:Literal7</ogc:Literal>
</ogc:Function>
</ogc:Or>
ogc:Literal0.5</ogc:Literal>
ogc:Literal1</ogc:Literal>
</ogc:Function>
</ogc:Function>

Unfortunately it’s failing validation:

The “unable to find function” is particularly ominous though all referenced functions are in my wfs GetCapabilities.

Anyone able to advise? What am I doing wrong?
Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


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

On Thu, Jun 27, 2013 at 3:26 PM, Jonathan Moules <
jonathanmoules@anonymised.com> wrote:

Am I not allowed to use a function inside a MaxScaleDenominator? It works
fine for my anchoring from yesterday.

Nope, you're not. The SLD specification does not allow it, and it would be
hard to allow
as an extension too, since the scale denominators are evaluated _before_ we
start reading
the features (mind, not impossible, but we'd have to make significant
changes to how we
process the data access, recognize rules that use dynamic scale
denominators,
and treat them in a special way).

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

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

Thanks. I guess I’ll just have to explicitly define the rule twice using a regular filter.

Cheers,
Jonathan

···

Am I not allowed to use a function inside a MaxScaleDenominator? It works fine for my anchoring from yesterday.

Nope, you’re not. The SLD specification does not allow it, and it would be hard to allow
as an extension too, since the scale denominators are evaluated before we start reading
the features (mind, not impossible, but we’d have to make significant changes to how we
process the data access, recognize rules that use dynamic scale denominators,
and treat them in a special way).

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