[Mapserver-users] bug postgis query alias

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Tue Jun 1 05:37:49 PDT 2004


Hi Vladimir,

I think I know what this might be. We had a similar problem caused by
the fact that the Mapserver lexer has a very limited set of characters
it will let through - the symptom being that Mapserver would truncate my
DATA clause at the offending characters (in our case it was a colon)
whenever I used a casting such as '::bigint' in the DATA string.

The patch we are currently running against 3.6.5 is the following:


--- mapserver-3.6.5.vanilla/maplexer.l	Wed Sep 18 16:14:17 2002
+++ mapserver-3.6.5/maplexer.l	Fri May  9 16:30:45 2003
@@ -348,7 +348,7 @@
 
 <INITIAL>[a-z/\.][a-z0-9/\._\-\=]*	       { return(MS_STRING); }
 <OBJECT_STRING>[a-z/\.][a-z0-9/\.\-\=]*	       {
return(MS_STRING); }
-<VALUE_STRING>[a-z/\.][a-z0-9/\. \-\=]*        { return(MS_STRING); }
+<VALUE_STRING>[a-z/\.][a-z0-9/\. \-\=:'<>]*    { return(MS_STRING); }
 
 <INITIAL>\n                                    { msyylineno++; }
 

This allow us to use the :'<> characers in a Mapserver DATA clause. If
you also include a \+ in the second regex to allow a + in the data
string then hopefully your query will work. I don't know whether this
has already been resolved in version 4.

I didn't submit this as a patch as I wasn't sure what effect it would
have on the other fields used by Mapserver since VALUE_STRING is not
just used for the DATA clause - one of the other developers should be
able to comment on this.


Hope this helps,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.

> -----Original Message-----
> From: mapserver-users-admin at lists.gis.umn.edu 
> [mailto:mapserver-users-admin at lists.gis.umn.edu] On Behalf Of 
> Vladimir Guzmán
> Sent: 01 June 2004 13:04
> To: mapserver-users at lists.gis.umn.edu
> Subject: Re: [Mapserver-users] bug postgis query alias
> 
> 
> Yes, the query runs fine in the pgsql monitor:
> gps=> select gid,'>' as sentido,tiempo,360-rumbo+90 as 
> rumbo,velocidad,gps_geom,oid from gps_vehi where 
> tiempo>='2004-05-31 05:00:00' and tiempo<='2004-06-02 04:59:59';
>   gid  | sentido |       tiempo        | rumbo | velocidad |
> gps_geom             |   oid
> -------+---------+---------------------+-------+-----------+--
-------------------------------+---------
> 46275 | >       | 2004-05-31 15:16:09 |   450 |         0 |
> SRID=1;POINT(-74.06318 4.67302) | 7731018
> 46276 | >       | 2004-05-31 15:16:15 |   450 |         0 |
> SRID=1;POINT(-74.06318 4.67302) | 7731019
> 46277 | >       | 2004-05-31 15:16:21 |   450 |         0 |
> SRID=1;POINT(-74.06319 4.67301) | 7731020
> ...
> ...
> 
> The error is just:
> 
> *Warning*:  MapServer Error in msDrawMap(): Failed to draw 
> layer named 
> 'puntosgps'.
> in */usr/local/apache/htdocs/gps/index.phtml* on line *33*
> 
> 
> Vladimir Ilich Guzmán R.
> ------------------------
> http://maintask.com
> 
> 
> 
> strk wrote:
> 
> >On Mon, May 31, 2004 at 03:29:45PM -0500, Vladimir Guzmán wrote:
> >  
> >
> >>Hello.
> >>I'm implementing a gps tracking system.
> >>I want to show the car's orientation like this: 
> >>http://maintask.com/test.png The layer's data is something 
> like this:
> >>-----------------------------
> >>gps_geom from (select gid,sentido,tiempo,360-rumbo+90 as 
> >>rumbo,velocidad,gps_geom,oid from gps_vehi where 
> tiempo>='2004-05-29 
> >>05:00:00' and tiempo<='2004-05-30 04:59:59') as foo using 
> unique gid 
> >>using srid=1
> >>-----------------------------
> >>The field 'sentido' contains '>'.
> >>
> >>The problem is that if I use something like this:
> >>-----------------------------
> >>gps_geom from (select gid,'>' as sentido,tiempo,360-rumbo+90 as
> >>rumbo,velocidad,gps_geom,oid from gps_vehi where 
> tiempo>='2004-05-29 
> >>05:00:00' and tiempo<='2004-05-30 04:59:59') as foo using 
> unique gid 
> >>using srid=1
> >>-----------------------------
> >>The query doesn't work.
> >>
> >>So I had to create a column in potgres called 'sentido' and all the 
> >>rows
> >>containing '>'.
> >>
> >>Is this a bug?
> >>    
> >>
> >
> >What's the error message ?
> >Can you run the query from the pgsql monitor ?
> >--strk;
> >
> >  
> >
> >>The rest of the layer:
> >>
> >>LAYER
> >> NAME "puntosgps"
> >> CONNECTIONTYPE postgis
> >> CONNECTION "user=gps password=gps dbname=gps host=localhost"  DATA 
> >>"gps_geom from (select gid,sentido,tiempo,360-rumbo+90 as 
> >>rumbo,velocidad,gps_geom,oid from gps_vehi where 
> tiempo>='2004-05-29 
> >>05:00:00' and tiempo<='2004-05-30 04:59:59') as foo using 
> unique gid 
> >>using srid=1"  TYPE POINT
> >>PROJECTION
> >> "proj=latlong"
> >> "datum=WGS84"
> >>END
> >> LABELANGLEITEM 'rumbo'
> >> LABELITEM 'sentido'
> >> CLASS
> >>   NAME 'Parado'
> >>   EXPRESSION ([velocidad] = 0)
> >>   SIZE 14
> >>   SYMBOL 'circle'
> >>   COLOR 0 0 215
> >>   OUTLINECOLOR 204 204 204
> >> END
> >> CLASS
> >>   NAME '0-10'
> >>   EXPRESSION ([velocidad] > 0 AND[velocidad] <= 10)
> >>   SIZE 14
> >>   SYMBOL 'circle'
> >>   COLOR 255 255 204
> >>   OUTLINECOLOR 204 204 204
> >>   LABEL
> >>     TYPE TRUETYPE
> >>     FORCE TRUE
> >>     FONT arial
> >>     ANTIALIAS TRUE
> >>     COLOR 0 0 0
> >>     OUTLINECOLOR 255 255 255
> >>     SIZE 8
> >>   END
> >> END
> >>...
> >>...
> >>
> >>Thanks a lot.
> >>
> >>--
> >>Vladimir Ilich Guzmán R.
> >>------------------------
> >>http://maintask.com 
> >>
> >>
> >>_______________________________________________
> >>Mapserver-users mailing list Mapserver-users at lists.gis.umn.edu
> >>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> >>    
> >>
> >_______________________________________________
> >Mapserver-users mailing list
> >Mapserver-users at lists.gis.umn.edu
> >http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> >
> >
> >  
> >
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu 
> http://lists.gis.umn.edu/mailman/listinfo/maps> erver-users
> 






More information about the MapServer-users mailing list