Hi,
I'm afraid it's not possible to use any type of expression in a vendor
option.
At the Java API level, vendor options values are just static strings, they
cannot contain
dynamic behavior. It's technically feasible to switch from String to
Expression (which would
allow function usage), but also a large change. It would be a pretty good
improvement though!

Going back to sorting, with the current capabilities, you can only provide
a field name. So,
a way to achieve what you want, if your data source is a database, is to
create a view,
either in the database or as a GeoServer SQL view, that computes the
sorting score as a new attribute.
Then you use the sortBy against this new attribute. That should do it.

Cheers
Andrea


On Tue, Jun 1, 2021 at 8:33 AM Sexton Michael <michael.sex...@ga.gov.au>
wrote:

> Hi Geoserver User list
>
>
>
> I have a layer where I want certain rules to be rendered higher in the
> z-order, using the vendor option ‘sortBy’, as described here
> <https://docs.geoserver.org/latest/en/user/styling/sld/extensions/z-order/index.html>.
> However the field I wish to sort on is text, not numeric.
>
>
>
> I thought I could do this using the Recode function, as follows:
>
>
>
> <*sld**:VendorOption **name**="sortBy"*>
>     <*ogc**:Function **name**="Recode"*>
>         <*ogc**:PropertyName*>OPERATING_STATUS</*ogc**:PropertyName*>
>         <*ogc**:Literal*>mineral deposit</*ogc**:Literal*>
>         <*ogc**:Literal*>50</*ogc**:Literal*>
>         <*ogc**:Literal*>historic mine</*ogc**:Literal*>
>         <*ogc**:Literal*>60</*ogc**:Literal*>
>         <*ogc**:Literal*>closed</*ogc**:Literal*>
>         <*ogc**:Literal*>70</*ogc**:Literal*>
>         <*ogc**:Literal*>under development</*ogc**:Literal*>
>         <*ogc**:Literal*>80</*ogc**:Literal*>
>         <*ogc**:Literal*>feasibility</*ogc**:Literal*>
>         <*ogc**:Literal*>80</*ogc**:Literal*>
>         <*ogc**:Literal*>care and maintenance</*ogc**:Literal*>
>         <*ogc**:Literal*>90</*ogc**:Literal*>
>         <*ogc**:Literal*>operating mine</*ogc**:Literal*>
>         <*ogc**:Literal*>100</*ogc**:Literal*>
>     </*ogc**:Function*>
> </*sld**:VendorOption*>
>
>
>
> But this seems to do nothing. Is there a way to sort a text field
> according to a preset numerical ordering?
>
>
>
> Thanks
>
>
>
> Michael
>
> Geoscience Australia Disclaimer: This e-mail (and files transmitted with
> it) is intended only for the person or entity to which it is addressed. If
> you are not the intended recipient, then you have received this e-mail by
> mistake and any use, dissemination, forwarding, printing or copying of this
> e-mail and its file attachments is prohibited. The security of emails
> transmitted cannot be guaranteed; by forwarding or replying to this email,
> you acknowledge and accept these risks.
> _______________________________________________
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to
> this list:
> - Earning your support instead of buying it, but Ian Turton:
> http://www.ianturton.com/talks/foss4g.html#/
> - The GeoServer user list posting guidelines:
> http://geoserver.org/comm/userlist-guidelines.html
>
> If you want to request a feature or an improvement, also see this:
> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>


-- 

Regards, Andrea Aime

== GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf
Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa
(LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549
http://www.geo-solutions.it http://twitter.com/geosolutions_it
------------------------------------------------------- *Con riferimento
alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
circostanza inerente alla presente email (il suo contenuto, gli eventuali
allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
sarei comunque grato se potesse darmene notizia. This email is intended
only for the person or entity to which it is addressed and may contain
information that is privileged, confidential or otherwise protected from
disclosure. We remind that - as provided by European Regulation 2016/679
“GDPR” - copying, dissemination or use of this e-mail or the information
herein by anyone other than the intended recipient is prohibited. If you
have received this email by mistake, please notify us immediately by
telephone or e-mail.*
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


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

Reply via email to