[Geoserver-users] SLD strMatches problem

I'm not sure if this is the right place to as.

I tried to create a style using a regex to match the values in a postgis table.

I wrote the following:

<ogc:PropertyIsEqualTo>
  <ogc:Function name="strMatches">
   <ogc:PropertyName>tags</ogc:PropertyName>
     <ogc:Literal>\b(15|3|8)\b</ogc:Literal>
   </ogc:Function>
  <ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>

The field "tags" is a varchar and the values in it are integers separated by a comma:
6,4
8,16,3
42,15
9

If one of the numbers matches 15, 3 or 8 the function should return true.
The regex works on a test site but it doesn't work on my sld.

I'm don't know if the regex is managed by geoserver/java or is passed to postgis/posgresql.
In postgresql \b is not used, I had to use another expression in a query.

Any help?

thank you

   maxx

Hi Emmex,
filter functions are generally not translated down in SQL.

Postgis is actually the one exception that has a handful of sample
functions translated to sql, but strMatches is not one of them.

Even if there was this ability, you’d still have to specify the
matching pattern using the Java Pattern syntax, and the
SQL translator would have to turn it into the native one instead

Cheers
Andrea

···

On Sat, Nov 1, 2014 at 1:02 PM, emmexx <emmexx@anonymised.com749…> wrote:

I’m not sure if this is the right place to as.

I tried to create a style using a regex to match the values in a postgis
table.

I wrote the following:

ogc:PropertyIsEqualTo
<ogc:Function name=“strMatches”>
ogc:PropertyNametags</ogc:PropertyName>
ogc:Literal\b(15|3|8)\b</ogc:Literal>
</ogc:Function>
ogc:Literaltrue</ogc:Literal>
</ogc:PropertyIsEqualTo>

The field “tags” is a varchar and the values in it are integers
separated by a comma:
6,4
8,16,3
42,15
9

If one of the numbers matches 15, 3 or 8 the function should return true.
The regex works on a test site but it doesn’t work on my sld.

I’m don’t know if the regex is managed by geoserver/java or is passed to
postgis/posgresql.
In postgresql \b is not used, I had to use another expression in a query.

Any help?

thank you

maxx



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

==

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 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

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.


Il 11/01/2014 02:01 PM, Andrea Aime scrisse:

Even if there was this ability, you'd still have to specify the
matching pattern using the Java Pattern syntax, and the
SQL translator would have to turn it into the native one instead

Thank you Andrea,

from what I read (google, forums, javadoc) the syntax \b(15|3|8)\b seems to be right.

http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

\b A word boundary
X|Y Either X or Y
(X) X, as a capturing group

Is there some problem with character encodings? Should I specify other parameters?

bye
  maxx

On Sat, Nov 1, 2014 at 2:15 PM, emmexx <emmexx@anonymised.com> wrote:

Il 11/01/2014 02:01 PM, Andrea Aime scrisse:
>
> Even if there was this ability, you'd still have to specify the
> matching pattern using the Java Pattern syntax, and the
> SQL translator would have to turn it into the native one instead

Thank you Andrea,

from what I read (google, forums, javadoc) the syntax \b(15|3|8)\b seems
to be right.

http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

\b A word boundary
X|Y Either X or Y
(X) X, as a capturing group

Hum... I believe strMatch matches the whole string, so you should add .*
before and after your pattern:

<ogc:PropertyIsEqualTo>
  <ogc:Function name="strMatches">
   <ogc:PropertyName>tags</ogc:PropertyName>
     <ogc:Literal>.*\b(15|3|8)\b.*</ogc:Literal>
   </ogc:Function>
  <ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 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

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

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

Il 11/01/2014 02:40 PM, Andrea Aime scrisse:

Hum... I believe strMatch matches the whole string, so you should add .*
before and after your pattern:

That's it!

Thank you

  maxx