[mapserver-users] Expression Syntax

Lime, Steve D (DNR) Steve.Lime at state.mn.us
Fri Dec 11 07:29:00 PST 2009


The =~ is the regex operator. It's referenced in a "Note" just below all the other logical expressions... Probably
should just be inlined with the other examples.

You can write case insensitive regex's the brute force way, e.g.:

  /hello/ => /[Hh][Ee][Ll][Ll][Oo]/

Bit of a pain though. Also, if you could isolate the regex somehow and remove your block test then you could do a 
straight regex expression and use case insensitivity. For example,

FILTERITEM 'block'
FILTER '%idOwnerQueryBLOCK%’
CLASSITEM 'USE1_DESC'
CLASS
  EXPRESSION /.*%idOwnerQueryDESC%.*/i
END

Might even see better performance...

Steve
________________________________________
From: Jay Kapalczynski [jkapalczynski at ci.maple-grove.mn.us]
Sent: Friday, December 11, 2009 9:17 AM
To: Lime, Steve D (DNR)
Cc: mapserver-users at lists.osgeo.org
Subject: RE: [mapserver-users] Expression Syntax

Thanks Steve for you response

I have been scouring the documentation on expressions and was getting confused..

This is from Mapserver

( ( ... ) AND ( ... ) ) ( ( ... ) && ( ... ) ) ... will become true when both of the two logical expressions in the innermost brackets are true.

Although my solution followed (...AND...)   NOT   ((...) AND (...))

I didn’t see the ~ in the documentation...what is that doing is signifying?

I had to remove the i so I am not longer case insensitive.....thats a drag...guess I have to modify my attributes to LCase to get around that...

Any other thoughts about the case sensitive issue...any way around that with the Logical Expression...

Thanks again everyone for you help and suggestions.

-----Original Message-----
From: Lime, Steve D (DNR) [mailto:Steve.Lime at state.mn.us]
Sent: Friday, December 11, 2009 8:55 AM
To: Jay Kapalczynski
Cc: mapserver-users at lists.osgeo.org
Subject: RE: [mapserver-users] Expression Syntax



Try:



  FILTER (‘[USE1_DESC]’ =~  /.*%idOwnerQueryDESC%.*/i AND ‘[BLOCK]’=’%idOwnerQueryBLOCK%’)



I've not tried case insensitive regex in a logical expression though. You might have to remove the i...



Steve



________________________________________

From: mapserver-users-bounces at lists.osgeo.org [mapserver-users-bounces at lists.osgeo.org] On Behalf Of Jay Kapalczynski [jkapalczynski at ci.maple-grove.mn.us]

Sent: Friday, December 11, 2009 8:37 AM

To: Fawcett, David (MPCA); 'Emiliano Castañeda'

Cc: mapserver-users at lists.osgeo.org

Subject: RE: [mapserver-users] Expression Syntax



Thanks for all your help yesterday….very appreciated…seems I always get botched up with the syntax….

Ugggg…I have tried 20 different ways and I just seem to be missing something..



I guess the question is, Can I use a wild card search in a logical expression?



This works (WILD CARD )

FILTER /.*%idOwnerQueryDESC%.*/i



This works (NO WILD CARD)

FILTER (‘[USE1_DESC]’=’%idOwnerQueryDESC%’ AND ‘[BLOCK]’=’%idOwnerQueryBLOCK%’)



This DOSENT work (Cant get the wild card into this)

FILTER (‘[USE1_DESC]’=’ /.*%idOwnerQueryDESC%.*/i’ AND ‘[BLOCK]’=’%idOwnerQueryBLOCK%’)





Any thoughts?



Thanks











From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Jay Kapalczynski

Sent: Thursday, December 10, 2009 3:57 PM

To: 'Fawcett, David (MPCA)'; 'Emiliano Castañeda'

Cc: mapserver-users at lists.osgeo.org

Subject: RE: [mapserver-users] Expression Syntax



Thanks all for your thoughts….



Got it…I had to add ‘ ‘ around the textbox id as well when referencing the textbox id names

Notice( ’%idOwnerQueryDESC%’ and ’%idOwnerQueryBLOCK%’ )



FILTER (‘[USE1_DESC]’=’%idOwnerQueryDESC%’ AND ‘[BLOCK]’=’%idOwnerQueryBLOCK%’)



Dan thanks for your thoughts…I am going to be moving to 2.x soon….but have to have the time to lean this all over again…moving to open layers that is….

One step at a time…I have a ton programmed into 1.6 that’s going to take me some time to convert…



Thanks again all….very appreciated





From: Fawcett, David (MPCA) [mailto:David.Fawcett at state.mn.us]

Sent: Thursday, December 10, 2009 3:26 PM

To: Jay Kapalczynski; 'Emiliano Castañeda'

Cc: mapserver-users at lists.osgeo.org

Subject: RE: [mapserver-users] Expression Syntax



At a minimum, I think that you will need to add quotes around the query columns.  (just use single quotes, not the fancy Microsofty ones below…)



FILTER (‘[USE1_DESC]’=%idOwnerQueryDESC% AND ‘[BLOCK]’=%idOwnerQueryBLOCK%)



Try setting a filter with static values from your data to get the filter format working before you add the complexity of passing the values in with variables.



FILTER (‘[USE1_DESC]’=’myUse’ AND ‘[BLOCK]’=’myBlock’)



David.



From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Jay Kapalczynski

Sent: Thursday, December 10, 2009 3:21 PM

To: 'Emiliano Castañeda'

Cc: mapserver-users at lists.osgeo.org

Subject: RE: [mapserver-users] Expression Syntax



Emiliano thanks for the response….yea I looked at the documentation and it was a bit fuzzy to me…



If I do them individually it works:

                #FILTERITEM 'USE1_DESC'

                #FILTER /.*%idOwnerQueryDESC%.*/i

                #FILTERITEM 'BLOCK'

                #FILTER /.*%idOwnerQueryBLOCK%.*/i



FILTER ([USE1_DESC]=%idOwnerQueryDESC% AND [BLOCK]=%idOwnerQueryBLOCK%)

ERROR: msEvalExpression: Expression parser error.  Failed to parse expression: =Residential AND  =006



FILTER (USE1_DESC=%idOwnerQueryDESC% AND BLOCK=%idOwnerQueryBLOCK%)

I seemed to get a bunch of returns that were incorrect...seems like it grabbed all of them.



Thoughts?





From: Emiliano Castañeda [mailto:emilianocastaneda at suremptec.com.ar]

Sent: Thursday, December 10, 2009 2:13 PM

To: Jay Kapalczynski

Cc: mapserver-users at lists.osgeo.org

Subject: Re: [mapserver-users] Expression Syntax



Jay,



you must use FILTERITEM only for simple FILTER expressions (string comparison only)

for example:

FILTER "2005" ->fieldvalue

FILTERITEM "year" ->fieldname



For Logical FILTER expressions you do not define FILTERITEM. In this case you must place the FILTER between parentheses, and fieldnames between brackets



for example:

FILTER ([field1]<4000 AND "[field2]"=="Museum") -->observe quotes on both sides on text fields



See http://mapserver.org/mapfile/expressions.html#expressions for detail on how to build logical expressions



Regards,

Emiliano

2009/12/10 Jay Kapalczynski <jkapalczynski at ci.maple-grove.mn.us<mailto:jkapalczynski at ci.maple-grove.mn.us>>

I looked on map server website in the documentation and cant get the synstax correct



I have two textboxes idOwner and idOwner2

I am a bit confused on the FILTERITEM because I am trying to write the expression to include two fields.



USE1_DESC and BLOCK are the two fields that form the query



  LAYER # Parcels Owner Layer

                    NAME 'Parcels'

                    DATA 'parcels/parcels.shp'

                    STATUS DEFAULT

                    TYPE POLYGON

                    METADATA

                                qstring_validation_pattern '.'

                    END

                    TEMPLATE 'parcels/itemquery_parcels_Owner.html'



                    FILTERITEM 'USE1_DESC'



                    FILTER (* WHERE USE1_DESC = '%idOwner%' and BLOCK = '%idOwner2%')



  END







_______________________________________________

mapserver-users mailing list

mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>

http://lists.osgeo.org/mailman/listinfo/mapserver-users







--

Ing. Emiliano Castañeda

SUR Emprendimientos Tecnológicos



Ing. Huergo 1189 (C1007AOL)

Ciudad de Buenos Aires, Argentina

Tel. +54 (11) 5811-4552   ext. 107

emilianocastaneda at suremptec.com.ar<mailto:emilianocastaneda at suremptec.com.ar>

www.suremptec.com<http://www.suremptec.com>




More information about the MapServer-users mailing list