[MapServer-users] converting an expression to an OGC filter

Eichner, Andreas - SID Andreas.Eichner at sid.sachsen.de
Fri Dec 2 06:45:00 PST 2022


Your pattern seems to be wrong. You originally used a case insensitive regex 0..$ meaning a value shall end with a '0' and to other arbitrary characters. Your PropertyIsLike filter is translated into an SQL "like": (for Postgres)
  postcode::text ilike '_%0__'
meaning a string as a whole shall consist of an arbitrary character followed by zero or more arbitrary characters followed by a '0' and two additional arbitrary characters. The corresponding regex would look like ^..*0..$
So I guess you would like want to use *0.. as pattern:
  <PropertyIsLike wildcard="*" singleChar="." escapeChar="\" matchCase="false">
    <PropertyName>postcode</PropertyName>
    <Literal>*0..</Literal>
  </PropertyIsLike>

Regards, Andreas

-----Ursprüngliche Nachricht-----
Von: MapServer-users <mapserver-users-bounces at lists.osgeo.org> Im Auftrag von Ian Turton
Gesendet: Freitag, 2. Dezember 2022 10:48
An: steve.lime at state.mn.us; mapserver-users at lists.osgeo.org
Betreff: Re: [MapServer-users] converting an expression to an OGC filter


On Thu, 1 Dec 2022 at 22:13, Lime, Steve D (MNIT) <steve.lime at state.mn.us <mailto:steve.lime at state.mn.us> > wrote:


	Hi Ian: What’s the backend (e.g. shapefile, PostGIS, etc…)? MapServer expressions don’t support a wildcard operator (outside of a regex) so I’m not sure off the top of my head and things may vary by driver.


It's a postgis database on the backend, the original expression works fine but not when it's input as an OGC expression.

Ian 


	

	 

	--Steve

	 

	From: MapServer-users <mapserver-users-bounces at lists.osgeo.org <mailto:mapserver-users-bounces at lists.osgeo.org> > On Behalf Of Ian Turton
	Sent: Thursday, December 1, 2022 9:50 AM
	To: mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org> 
	Subject: [MapServer-users] converting an expression to an OGC filter

	 

	I currently have an expression in my mapfile EXPRESSION ('[postcode]' ~* '0..$') and I'm in the process of moving to using SLD for styling - I thought I could convert that expression to 

	 

	     <PropertyIsLike wildcard="*" singleChar="." escapeChar="\" matchCase="false">
	        <PropertyName>postcode</PropertyName>
	        <Literal>.*0..</Literal>
	      </PropertyIsLike>
	Which I think should match from the start of the string (.*) to a 0 and then two characters (..) to the end of the string. But it doesn't work - neither does any variant on this work either.
	Is there some issue with conversions between SLD Filters and internal expressions that I'm missing or is there something else I should know about LIKE filters?

	Thanks

	 

	Ian

	-- 

	Ian Turton



-- 

Ian Turton

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2500 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20221202/c0e347dc/attachment.bin>


More information about the MapServer-users mailing list