Gabe wrote:
> Thankyou Armin that works perfectly and seems obvious now that I see it. I
> have used the other type of filter on tab files and they have worked - I
> guess postgis access through mapscript still needs a bit of work.

as already mentioned, the filter and expression part in mapserver is a 
bit messy sometimes. The problem is mainly the lack of full 
documentation. I don't know why the docs are not migrated into a wiki 
where users could modify missing or ambiguous parts.


> The filter that worked came from this line
>    $farmLayer->setFilter("c_farm = '$farmid'");
> Resulting in       FILTER "c_farm = '8009'"
> 
> One issue I can see that will come up soon with this filter is that I wanted
> to put a regular expression as the filter   I am thinking I will get around
> this by having a more complex SQL type filter ie instead of 
> FILTERITEM "c_farm"
> FILTER /9001|9003|9544/
> 
> I will try
> FILTER "c_farm = '9001' OR c_farm='9003' OR c_farm='9544'"
> 


Postgis supports also regular expressions through the '~'. Something like
FILTER "c_farm ~ '9001|9003|9544'"

Alternatively you could try to use

FILTER "c_farm in ('9001','9003','9544')"

Normally the FILTER should be passed without modification to the WHERE 
clause that is sent to the respective database backend.

armin


>> -----Original Message-----
>> From: Gabe [mailto:[EMAIL PROTECTED]
>> Sent: Friday, 29 June 2007 2:06 PM
>> To: '[EMAIL PROTECTED]'
>> Subject: RE: Filtering a postgis layer
>>
>> Thanks I will try that
>>
>>> -----Original Message-----
>>> From: Armin Burger [mailto:[EMAIL PROTECTED]
>>> Sent: Wednesday, 27 June 2007 4:37 PM
>>> To: Gabe
>>> Cc: [email protected]
>>> Subject: Re: Filtering a postgis layer
>>>
>>> It *is* a Mapscript error. I thought it had been fixed in MS 4.10.2.
>> In
>>> my opinion this error should just happen after an attribute query .
>> But
>>> you don't say this explicitly. In any case report it to the MS
>>> developers and ask when it will be fixed.
>>>
>>> I never use filters like that on Postgis, but like
>>>
>>> FILTER "c_farm = 8010"
>>>
>>> If it still does not work try
>>>
>>> FILTER '"c_farm = 8010"'
>>>
>>> armin
>>>
>>>
>>> Gabe wrote:
>>>> Hi Armin, Pmapper-users
>>>>
>>>> This is probably a mapscript or mapserver thing but ...
>>>>
>>>> I am using pmapper 3.1, on mapscript 4.10.2, php 5.2.3.  I have a
>>> layer that
>>>> works fine unfiltered but when I try to put a plain text filter on
>> it
>>> I get
>>>> this error:
>>>>
>>>> [27-Jun-2007 14:39:06] PHP Warning:  [MapServer Error]:
>> msDrawMap():
>>> Failed
>>>> to draw layer named 'Paddocks'.
>>>>  in D:\dev\nusphere\pmapper\incphp\map.php on line 316
>>>> [27-Jun-2007 14:39:06] PHP Warning:  [MapServer Error]:
>>> prepare_database():
>>>> Error executing POSTGIS DECLARE (the actual query) statement:
>>> 'DECLARE
>>>> mycursor BINARY CURSOR FOR SELECT
>>>>
>> "isfallow"::text,"c_farm"::text,"c_linkcode"::text,asbinary(force_colle
>>> ction
>>>> (force_2d(the_geom)),'NDR'),oid::text from p.v_pad_export WHERE
>>> (8010) and
>>>> (the_geom && setSRID( 'BOX3D(153.403139097172
>>>> -28.30966067574,153.431890713834 -28.28477832426)'::BOX3D,-1) )'
>>>>
>>>> Postgresql reports the error as 'ERROR:  argument of AND must be
>> type
>>>> boolean, not type integer
>>>> '
>>>>
>>>> The Filter is:
>>>>
>>>> FILTERITEM "c_farm"
>>>> FILTER "8010"
>>>>
>>>> The error happens because of this part of the query
>>>> ... WHERE (8010) ...
>>>> It should read WHERE (c_farm='8010')
>>>>
>>>> Any help will be much appreciated
>>>>
>>>> Thanks
>>>> Gabe
>>>>
>>>>
> 
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
pmapper-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmapper-users

Reply via email to