[Mapserver-users] python styleObj classObj colorObj question in 4.x
Sean Gillies
sgillies at frii.com
Thu Jul 31 13:11:09 PDT 2003
Heitzso,
I'm going to insert my corrections into your code.
And first, don't use 'map' as name for a mapObj instance
because you may experience collision with the built-in
Python function of the same name!
On Thursday, July 31, 2003, at 01:42 PM, Heitzso wrote:
> (I'm working with cvs mapserver_dev from a couple
> weeks ago. Let me know please if that's my problem.)
>
> Trying to create a layer to display in python mapscript.
> I have the code working great with existing layers from
> the map file. But failing to draw layers created in
> code. The map will draw (when I don't have the code
> buggered with experiments) but nothing shows. I assumed
> I don't have the outline color set correctly. The layer
> I'm building up is based on a layer that works when
> accessed from the mapfile. Code snippet ...
> map = mapObj(mapFilename)
> ...
> img = map.prepareImage()
> layer = layerObj(map)
> layer.name = 'test'
> layer.connection = "a postgis conn that works in mapfile"
> layer.connectiontype = MS_POSTGIS
> layer.data = "the_geom from counties"
> layer.status = MS_ON
> layer.type = MS_LAYER_POLYGON
> c = classObj(layer)
> c.name = "testclass"
> style = styleObj(c) <-- CRASH!!!!!!!!!
> style.outlinecolor = setRGB(0,0,0)
do this instead of the previous two lines:
c.styles.outlinecolor.red = 0
c.styles.outlinecolor.green = 0
c.styles.outlinecolor.blue = 0
> c.status = MS_ON
> layer.draw(map, img)
> map.drawLabelCache(img)
> img.save(imagePath + imageFilename)
>
> I find doc confusing, cross ups between 3.x and 4.x
> version and perl/php/python variations in code style
> and doc version.
>
> For instance ...
>
> doc states styleObj constructed with classObj
> passed in, i.e. 's = styleObj(cObj)' but
> mapscript complains that method must not have
> an argument ?!
>
> doc also states that everything migrated over
> to styleObj but it's not clear if that's
> _required_ or suggested
>
> Could someone enlighten me?
>
> THANKS!
> Heitzso
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list