[mapserver-users] Customized layer for Mapserver/Kamap

Florin A. pianosnake at gmail.com
Wed May 14 14:38:52 EDT 2008


Hi,

In your mapfile you define the layers and the colors. See example below.

If you have an SRID (projection) for the layer use it.  You can see
what it is by  selecting this sql  in pgadmin:  "select srid(the_geom)
from cities)   .  Use the number you get here in the mapserver layer
definition and in the projection definition as well.  If you loaded
the cities with shp2pgsql then you should automatically have a gid
field on the cities table.   And  your cities table should have a
population field the type of which  should be some kind of number.


LAYER
	METADATA
		"wms_title"  "Cities layer"
	END
	NAME "cities"
        TRANSPARENCY 100
	CONNECTIONTYPE postgis
	CONNECTION "host=??? user=???  dbname=???  password='???'"
	DATA "the_geom from cities using srid=???  USING UNIQUE gid"
	TYPE POLYGON

       CLASS
		NAME "Small cities"
		EXPRESSION ( [population] <50000)
		COLOR 0 255 0
	END

	CLASS
		NAME "Medium cities"
		EXPRESSION ([population] >50000 AND [population] <1500000 )
		COLOR 255 255 0
	END

	CLASS
		NAME "Big cities"
		EXPRESSION ([population] > 1500000 )
		COLOR 255 0 0
	END


END

Hope this helps,
Florin


More information about the mapserver-users mailing list