[mapserver-users] PostGIS performance

Jan Hartmann jhart at frw.uva.nl
Wed Oct 9 05:44:31 EDT 2002


Alexander Pucher wrote:
> I think the problem is in the use of the EXPRESSION with a PostGIS 
> layer. In the documentation I found a line, saying that CLASSITEM is not 
> used in a PostGIS layer. One has to use the field name in the EXPRESSION 
> tag!!
> 

Where did you read that??? Anyway, it's not true. My test-mapfile (a 
small world file with the continents) runs as follows:

LAYER
   NAME CONTINENTS
   CONNECTIONTYPE POSTGIS
   CONNECTION "user=xxx dbname=world password=xxx host=xxx"
   DATA "the_geom from (select map.the_geom,map.oid,map.continent, case 
when map.continent='Europe' then 1 when map.continent='Africa' then 2 
else 3 end as cnt from continents as map) as foo"
   TYPE POLYGON
   CLASSITEM cnt
   CLASS
     NAME "Asia: black"
     EXPRESSION ('[continent]' = 'Asia')
     COLOR 0 0 0
     OUTLINECOLOR 0 0 0
   END
   CLASS
     NAME "Europe: red"
     EXPRESSION "1"
#   EXPRESSION /1/               # OK
#   EXPRESSION 1                 # Doesn't work
     COLOR 255 0 0
     OUTLINECOLOR 0 0 0
   END
   CLASS
     NAME "Africa: magenta"
     EXPRESSION "2"
     COLOR 255 0 255
     OUTLINECOLOR 0 0 0
   END
   CLASS
     NAME "Rest of the World: yellow"
     EXPRESSION ([cnt] = 3)
#   EXPRESSION ("[cnt]" = "3")    # OK
     COLOR 255  255 0
     OUTLINECOLOR 0 0 0
   END
   STATUS DEFAULT
END

To be noted:

1) You can use both an EXPRESSION from a CLASSITEM and a logical EXPRESSION.
2) You can use both an original variable and a computed one, provided 
you have named them in the subselect.
3) In literal EXPRESSIONS numeric variables have to be quoted or 
constructed as regex.
4) In logical EXPRESSIONS you can use numeric variables as numeric or as 
strings.

Cheers,

Jan Hartmann
Department of Geography
University of Amsterdam
jhart at frw.uva.nl




More information about the mapserver-users mailing list