<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">It seems that if you specify an empty filter like FILTER "", Mapserver take it instead to ignore it. <br><br>That means Mapserver construct a SQL statement with the WHERE clause empty (without conditionants).<br><br><div><strong><font color="#0000bf">IC Carlos Ruiz</font></strong></div><div><strong><font color="#0000bf"></font></strong> <br></div><br>--- On <b>Wed, 8/6/08, kreshna_iceheart@yahoo.com <i><kreshna_iceheart@yahoo.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: kreshna_iceheart@yahoo.com <kreshna_iceheart@yahoo.com><br>Subject: Re: [mapserver-users] Still cannot display postGIS layers using ms4w(MapServer 5.0.2 on WinXP).<br>To: "Kusum" <kusum@infobase.in><br>Cc: mapserver-users@lists.osgeo.org<br>Date: Wednesday, August 6, 2008, 4:20 AM<br><br><pre>I am
 an idiot.<br><br>Well I don't have a database named postgis on the first place (only<br>template_postgis), but I tried to apply your first DATA line to my own database<br>(test_mapserv).<br><br>Then I realized: your file don't have FILTER "" clause. At the<br>same time, someone from postGIS mailing list told me that an empty FILTER clause<br>will just confuse postGIS. So I remove it from my mapfile and suddenly<br>everything works!<br><br>Thanks,<br>-Kresh<br><br><br>--- On Wed, 8/6/08, Kusum <kusum@infobase.in> wrote:<br><br>> From: Kusum <kusum@infobase.in><br>> Subject: Re: [mapserver-users] Still cannot display postGIS layers using<br>ms4w(MapServer 5.0.2 on WinXP).<br>> To: kreshna_iceheart@yahoo.com<br>> Date: Wednesday, August 6, 2008, 3:18 AM<br>> Try this format :-<br>> LAYER<br>>   NAME "route"<br>>   STATUS ON<br>>   TYPE line<br>>   CONNECTIONTYPE postgis<br>>   CONNECTION "user=postgres
 dbname=postgis<br>> host=localhost port=5432 <br>> password=postgres"<br>>   DATA "the_geom from ind_road"<br>> #DATA "the_geom from (SELECT the_geom, gid from <br>> shortest_path_as_geometry('hr_road', 1, 50)) as<br>> route using unique gid using <br>> srid=-1"<br>> #DATA "the_geom from (SELECT the_geom from<br>> routing_results) as thing using <br>> unique gid using srid=-1"<br>>  #DATA "the_geom from (SELECT gid, the_geom from<br>> routing_results) as foo <br>> using unique gid using srid=-1"<br>> <br>>  TEMPLATE "t"<br>>   PROJECTION<br>>     "proj=latlong"<br>>     "ellps=WGS84"<br>>      "datum=WGS84"<br>>   END<br>> <br>> --------------------------------------------------<br>> From: <kreshna_iceheart@yahoo.com><br>> Sent: Wednesday, August 06, 2008 12:40 PM<br>> To: <mapserver-users@lists.osgeo.org><br>> Subject: [mapserver-users] Still cannot display
 postGIS<br>> layers using <br>> ms4w(MapServer 5.0.2 on WinXP).<br>> <br>> > Help. Somebody please help. Somebody. Anybody. :-(<br>> ><br>> > I am using postgreSQL 8.2.5 for Windows with postGIS.<br>> The database was <br>> > installed using Windows .msi installation package. I<br>> am also using ms4w <br>> > 2.2.7 that comes with MapServer 5.0.2. All installed<br>> on Windows XP Service <br>> > Pack 2.<br>> ><br>> > The MapServer does support postGIS. When I executed<br>> mapserv -v, I got the <br>> > following:<br>> > MapServer version 5.0.2 OUTPUT=GIF OUTPUT=PNG<br>> OUTPUT=JPEG OUTPUT=WBMP <br>> > OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ<br>> SUPPORTS=AGG <br>> > SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER<br>> SUPPORTS=WMS_CLIENT <br>> > SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT<br>> SUPPORTS=WCS_SERVER <br>> > SUPPORTS=SOS_SERVER
 SUPPORTS=FASTCGI SUPPORTS=THREADS<br>> SUPPORTS=GEOS <br>> > INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL<br>> INPUT=SHAPEFILE<br>> ><br>> > In the postgreSQL database, I have created a database<br>> named test_mapserv. <br>> > I also created a schema named rencana, and a table<br>> named kawasanbencana. <br>> > The name of the geometry column is the_geom.<br>> > I have created a spatial index (kawasanbencanaspix) on<br>> the geometry <br>> > column. I also use lowercase to write the<br>> 'from' statement.<br>> ><br>> > The problem is: MapServer always gives the<br>> "..Query error. Error executing <br>> > POSTGIS DECLARE.." error message, no matter what<br>> I do. And I have tried <br>> > everything ad nauseam.<br>> ><br>> > I have tried specifying the DATA line without USING<br>> UNIQUE ... USING SRID <br>> > line. I have tried specifying
 the DATA line with USING<br>> UNIQUE ...USING <br>> > SRID. I have tried using double apostrophe (")<br>> and single apostrophe ('). <br>> > It doesn't matter. Everything I have tried has<br>> failed, and I still get the <br>> > error message no matter what I did.<br>> ><br>> > My mapfiles are attached in this mail. Each reflect my<br>> futile attempt, and <br>> > all of them generated the error message.<br>> ><br>> ><br>> > My first attempt:<br>> > =================<br>> ><br>> > This is my first attempt. I have both the mapfile and<br>> the error message <br>> > attached on this mail.<br>> >    CONNECTIONTYPE postgis<br>> >    CONNECTION 'host=localhost user=rtrw<br>> password=123456 port=5432 <br>> > dbname=test_mapserver'<br>> >    DATA 'the_geom from rencana.kawasanbencana'<br>> ><br>> > And I got the following error
 message:<br>> > msDrawMap(): Image handling error. Failed to draw<br>> layer named <br>> > 'kawasanbencana'. prepare_database(): Query<br>> error. Error executing POSTGIS <br>> > DECLARE (the actual query) statement: 'DECLARE<br>> mycursor BINARY CURSOR FOR <br>> > SELECT<br>> asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text<br>> from <br>> > rencana.kawasanbencana WHERE () and (the_geom<br>> && setSRID( <br>> > 'BOX3D(528635.525378392 9074209,609092.162121608 <br>> ><br>><br>9134520)'::BOX3D,find_srid('','rencana.kawasanbencana','the_geom')<br>> ))' <br>> > Postgresql reports the error as 'ERROR: syntax<br>> error at or near ")" LINE <br>> > 1: ...DR'),gid::text from rencana.kawasanbencana<br>> WHERE () and (the... ^ ' <br>> > More Help: Error with POSTGIS data variable. You<br>> specified 'check your <br>> > .map file'. Standard
 ways of specifiying are : (1)<br>> 'geometry_column from <br>> > geometry_table' (2) 'geometry_column from (sub<br>> query) as foo using unique <br>> > column name using SRID=srid#' Make sure you put in<br>> the 'using unique <br>> > column name' and 'using SRID=#' clauses<br>> in. For more help, please see<br>> > http://postgis.refractions.net/documentation/<br>> Mappostgis.c - version of <br>> > Jan 23/2004.<br>> ><br>> ><br>> > My second attempt:<br>> > ==================<br>> ><br>> > I tried adding USING UNIQUE to my DATA line. There is<br>> something odd with <br>> > my spatial table though: whenever I view the data<br>> contents with pgAdmin, I <br>> > can always see the oid column. However, I cannot find<br>> the oid column when <br>> > viewing the table's column definition. I attached<br>> the screenshots <br>> > accordingly. The
 question is: does my table have oid<br>> column or not? And <br>> > does it have something to do with the error?<br>> ><br>> > Nonethless, here's my lines:<br>> >    CONNECTIONTYPE postgis<br>> >    CONNECTION 'host=localhost user=rtrw<br>> password=123456 port=5432 <br>> > dbname=test_mapserver'<br>> >    DATA 'the_geom from rencana.kawasanbencana<br>> using unique oid'<br>> ><br>> ><br>> > And I still get the same error message as above. The<br>> difference is that <br>> > the error message now says 'oid' instead of<br>> 'gid'. For instance, <br>> > "(the_geom)),'NDR'),gid" becomes<br>> "(the_geom)),'NDR'),oid", but everything <br>> > else remains the same.<br>> ><br>> ><br>> > My third attempt:<br>> > =================<br>> ><br>> > Like I said in my second attempt, I'm not sure<br>> whether my table has oid <br>>
 > column or not. Thus, in my third attempt I used the<br>> gid column instead, <br>> > especially since the gid column is my primary key<br>> column anyway. This is <br>> > my lines:<br>> >    CONNECTIONTYPE postgis<br>> >    CONNECTION 'host=localhost user=rtrw<br>> password=123456 port=5432 <br>> > dbname=test_mapserver'<br>> >    DATA 'the_geom from rencana.kawasanbencana<br>> using unique gid'<br>> ><br>> > And I got exactly the same error message as my first<br>> attempt.<br>> ><br>> ><br>> > My fourth attempt:<br>> > ==================<br>> ><br>> > In my fourth attempt, I used the gid column for my<br>> unique id, and I am <br>> > using SRID=1. Here is the lines:<br>> >    CONNECTIONTYPE postgis<br>> >    CONNECTION 'host=localhost user=rtrw<br>> password=123456 port=5432 <br>> > dbname=test_mapserver'<br>> >  
  DATA 'the_geom from rencana.kawasanbencana<br>> using unique gid using <br>> > SRID=1'<br>> ><br>> > Well I still got the error message. This time, the<br>> error message is <br>> > slightly different. Instead of getting<br>> "::BOX3D,find_srid", I got <br>> > "::BOX3D,1".<br>> ><br>> > Here is the complete error message:<br>> > msDrawMap(): Image handling error. Failed to draw<br>> layer named <br>> > 'kawasanbencana'. prepare_database(): Query<br>> error. Error executing POSTGIS <br>> > DECLARE (the actual query) statement: 'DECLARE<br>> mycursor BINARY CURSOR FOR <br>> > SELECT<br>> asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text<br>> from <br>> > rencana.kawasanbencana WHERE () and (the_geom<br>> && setSRID( <br>> > 'BOX3D(528635.525378392 9074209,609092.162121608<br>> 9134520)'::BOX3D,1) )' <br>> > Postgresql
 reports the error as 'ERROR: syntax<br>> error at or near ")" LINE <br>> > 1: ...DR'),gid::text from rencana.kawasanbencana<br>> WHERE () and (the... ^ ' <br>> > More Help: Error with POSTGIS data variable. You<br>> specified 'check your <br>> > .map file'. Standard ways of specifiying are : (1)<br>> 'geometry_column from <br>> > geometry_table' (2) 'geometry_column from (sub<br>> query) as foo using unique <br>> > column name using SRID=srid#' Make sure you put in<br>> the 'using unique <br>> > column name' and 'using SRID=#' clauses<br>> in. For more help, please see <br>> > http://postgis.refractions.net/documentation/<br>> > Mappostgis.c - version of Jan 23/2004.<br>> ><br>> ><br>> > My fifth attempt:<br>> > =================<br>> ><br>> > Now I had been pretty much desperate, I just wrote<br>> using SRID=#, closed my <br>> > eyes, and
 hoped for the best. Here's the lines:<br>> >    CONNECTIONTYPE postgis<br>> >    CONNECTION 'host=localhost user=rtrw<br>> password=123456 port=5432 <br>> > dbname=test_mapserver'<br>> >    DATA 'the_geom from rencana.kawasanbencana<br>> using unique gid using <br>> > SRID=#'<br>> ><br>> > I still get an error message. This time, the error<br>> message is different <br>> > altogether. Here's the message:<br>> > msDrawMap(): Image handling error. Failed to draw<br>> layer named <br>> > 'kawasanbencana'. msPOSTGISLayerParseData():<br>> Query error. Error parsing <br>> > POSTGIS data variable: You specified 'using<br>> SRID=#' but didnt have any <br>> > numbers! More Help: Error with POSTGIS data variable.<br>> You specified <br>> > 'the_geom from rencana.kawasanbencana using unique<br>> gid using SRID=#'. <br>> > Standard ways of specifiying are :
 (1)<br>> 'geometry_column from <br>> > geometry_table' (2) 'geometry_column from (sub<br>> query) as foo using unique <br>> > column name using SRID=srid#' Make sure you put in<br>> the 'using unique <br>> > column name' and 'using SRID=#' clauses<br>> in. For more help, please see <br>> > http://postgis.refractions.net/documentation/<br>> Mappostgis.c - version of <br>> > Jan 23/2004.<br>> ><br>> ><br>> > I'm pretty much desperate. Could somebody please<br>> tell what's wrong on my <br>> > mapfile? Or maybe ms4w just cannot display postGIS<br>> data? Do I need to <br>> > install postGIS and MapServer on Linux, in order to<br>> get them work <br>> > together? Please help. :-(<br>> ><br>> ><br>> > Thanks,<br>> > -Kresh<br>> ><br>> ><br>> ><br>> ><br>> <br>> <br>> <br>> >
 _______________________________________________<br>> > mapserver-users mailing list<br>> > mapserver-users@lists.osgeo.org<br>> ><br>> http://lists.osgeo.org/mailman/listinfo/mapserver-users<br>> ><br><br><br>      <br>_______________________________________________<br>mapserver-users mailing list<br>mapserver-users@lists.osgeo.org<br>http://lists.osgeo.org/mailman/listinfo/mapserver-users<br></pre></blockquote></td></tr></table><br>