Odd issue with drawing a shape multiple times
Sean Gillies
sgillies at FRII.COM
Tue Mar 1 13:16:52 EST 2005
Steve,
Thanks! That was it. I thought I'd been watching the shape closely
enough, but had really only been checking the bounds and not the full
geometry. Setting the layer's transform attribute to false before
drawing again also works.
cheers,
Sean
On Mar 1, 2005, at 11:09 AM, Steve Lime wrote:
> The likely problem is that the shape is being altered when drawn. I
> believe the
> shape coordinates are converted from map coordinates to image
> coordinates
> in place, and then clipped and thinned. The thinking pre-dates
> MapScript and
> was done that way to avoid ton's of coordinate copying.
>
> To fix? Make a copy of the shape in the draw methods and hand that copy
> off
> to be rendered leaving the original intact.
>
> Steve
>
>>>> Sean Gillies <sgillies at FRII.COM> 3/1/2005 10:29:30 AM >>>
> Can anyone share their insight into shape rendering with me? I'm
> finding it impossible to redraw a single shape using the same map and
> layer objects using shapeObj.draw (and msDrawShape). Is there some
> caching or other magic at work here that's tripping me up?
>
> The script is run from mapserver/tests:
>
> import mapscript
>
> mo = mapscript.mapObj('test.map')
>
> # Use the POLYGON layer to render feature
> lo = mo.getLayerByName('POLYGON')
>
> # Get one polygon shape
> lo.open()
> so = lo.getFeature(0)
> lo.close()
>
> so.classindex = 0
>
> def inspect_shape(so):
> for item in dir(so):
> print item, getattr(so, item)
>
> # render the shape
> im = mo.prepareImage()
> print "p1a\n---\n"
> inspect_shape(so)
> so.draw(mo, lo, im)
> im.save('p1a.png')
>
> # render the shape in a new image
> im = mo.prepareImage()
> print "p1b\n---\n"
> inspect_shape(so)
> so.draw(mo, lo, im)
> im.save('p1b.png')
>
> Produces the images
>
> p1a (is correct):
>
More information about the mapserver-dev
mailing list