[mapserver-users] compare date in class

Ben Madin ben at remoteinformation.com.au
Fri Jun 6 18:02:04 PDT 2008


G'day Vinc,

It might be easier to code the expression check into the SQL  
statement. I could be wrong, but I suspect that this would make the  
execution of the statements much faster as well, as increasingly  
complex expression checking I think is relatively slow in MapServer,  
but shouldn't stress a database. (If I am wrong, it would be good to  
know!!)

Off the top of my head, something like this might work:

>   DATA 'the_geom from (select the_geom, id, oid, ...., start_date   
> from table) as foo'

Would become :

DATA 'the_geom from (select the_geom, id, oid, ...., start_date,

	CASE WHEN start_date < now()
		THEN 'old'
		WHEN start_date > now()
		THEN 'future'
		ELSE  'now'
		END AS status

from table) as foo'

then make :

CLASSITEM	status

and CLASS EXPRESSION 'now'

Good luck!

cheers

Ben





On 07/06/2008, at 12:00 AM, mapserver-users-request at lists.osgeo.org  
wrote:

> From: patruno at istat.it
> Date: 6 June 2008 9:05:45 PM
> To: mapserver-users at lists.osgeo.org
> Subject: [mapserver-users] compare date in class
>
>
> Hi list!
>
> I'd like to ask you if there is a way to compare a field date (mm-gg- 
> yyyy) coming from a PostGIS query with the current date. (and above  
> all how to get the current date ....)
>
> My goal is to use a point layer with different colours depending on  
> expression result in the 'class' block.
>
> Ex:
>  CONNECTION 'dbname=xxxx user=username password=password  
> host=localhost'
>
>   DATA 'the_geom from (select the_geom, id, oid, ...., start_date   
> from table) as foo'
>
> .....
>
> CLASS
>   EXPRESSION (current_date > start_date)
>
> NAME "red"
>      TEXT ([id])
>      STYLE
>        COLOR 255 0 0
>        OUTLINECOLOR 0 0 0
>      END
> ....
>
>
>
> Thanks in advance
> Vinc
>

-- 

Ben Madin
REMOTE INFORMATION

t : +61 8 9192 5455
f : +61 8 9192 5535
m : 0448 887 220
Broome   WA   6725

ben at remoteinformation.com.au



							Out here, it pays to know...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080607/cc4ddfb1/attachment.htm>


More information about the MapServer-users mailing list