[Mapserver-users] Mapscript $layerObj->draw($imageObj) bug?

Homme Zwaagstra hrz at geodata.soton.ac.uk
Tue Jun 1 10:47:22 PDT 2004


--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

I have a mapscript problem:

Using the draw method of a layerObj instance doesn't seem to correctly
draw scaled symbols; I am attempting to set a point layer's SIZEUNITS
property to KILOMETERS in an effort to draw a scaled buffer (see
attached test.map for minimalist mapfile).

Calling shp2img on this mapfile produces an image with a correctly
scaled symbol. Creating the image with the the mapObj's draw method
also works correctly (see attached output image map_draw.png). Using
the layerObj's draw method, however, seems to ignore the SIZEUNITS
setting and uses the default scaling of pixels (see attached output
image layer_draw.png). 

This issue exists in PHP mapscript and Python mapscript. See the
attached files test.php and test.py for scripts demonstrating the
problem.

I'm using mapscript and mapserver 4.2.0. This problem manifested
itself in 4.0.1 but I upgraded before investigating further. 

I've searched the archives but could find no mention of this
problem. Am I missing something here or is this a bug? If I don't hear
back I'll file it in bugzilla...

Kind regards,

Homme Zwaagstra

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test.map"

MAP
	NAME TEST
	STATUS ON
	#EXTENT 418917.11 64936.18 494853.73 115804.77 # large extent
    EXTENT 439537 89319.1 460612 104483            # small extent
	UNITS METERS
	IMAGECOLOR 200 200 255
    SIZE 261 175 
    SYMBOLSET "test.sym"

	LAYER
		NAME "point"
		TYPE POINT
		STATUS ON
        SIZEUNITS KILOMETERS

        FEATURE
           POINTS 450074 97030 END
        END

		CLASS
		  STYLE
			OUTLINECOLOR 255 0 0
			COLOR 255 0 0
            SIZE 4
            SYMBOL "circle"
		  END
		END
    END
END
--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test.sym"

SYMBOL
  NAME "circle"
  TYPE ELLIPSE
  FILLED TRUE
  POINTS
    1 1
  END
END
--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test.php"

<?php

dl('php_mapscript.so');

// returns an imageObj
function get_image($map) 
{
	return $map->draw();		// comment out this line to return imageObj with buggy symbol

	$image = $map->prepareImage();
	$layer = $map->getLayerByName('point');
	$layer->draw($image);
	return $image;
}

$map = ms_newMapObj('test.map');
$image = get_image($map);		// get the imageObj
$image->saveImage('/tmp/test.png');

?>
--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test.py"

# returns an imageObj
def get_image(map):
	return map.draw()					# comment out this line to return imageObj with buggy symbol

	image = map.prepareImage()
	layer = map.getLayerByName('point')
	layer.draw(map, image)
	return image

import mapscript

map = mapscript.mapObj('test.map')
image = get_image(map)					# get the imageObj
image.save('/tmp/test.png')


--vkogqOf2sHV7VnPd
Content-Type: image/png
Content-Disposition: attachment; filename="map_draw.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAQUAAACvAQMAAAG5r2l4AAAABlBMVEXIyP//AADhJLQQAAAA
9UlEQVR4nO2XzQ2DMAyFiXLgmG7QURgNRssoGYEjB1S3IEHAjuqgQoSq9x0s62ElxvmvqsP4
yZgwWdtvbIj65XSxR2mNL5KDih0Wz42r95JevX6twvVZ3ZM4ZnW/eC5Rv2emt6n42kps+S4z
BJyBI6405JlC1O8FQzRoiiUatRipyL4S+cicAQAlsXzhbs7khYY6prSJvSVoikntP0yxqf2n
mJKTYc6fJuojayjrLMcCAAAAKMpDC2jEjZ/xOTmV670jeXDyTuTDYk9L4nki0/ieiJ0jup8i
6jnC/0XEGfXQq66PXMbo6zNIn4X6TM5YDQAAkMsb0b7VKG9JJp4AAAAASUVORK5CYII=

--vkogqOf2sHV7VnPd
Content-Type: image/png
Content-Disposition: attachment; filename="layer_draw.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAQUAAACvAQMAAAG5r2l4AAAABlBMVEXIyP//AADhJLQQAAAA
NklEQVR4nO3OoREAIAwEwZSFpBRKpxQcJggEM0Tsyp8THwHAwfh9AGDraZkXDQBAPe1BAUBh
Cxh0AjG8NnTVAAAAAElFTkSuQmCC

--vkogqOf2sHV7VnPd--



More information about the MapServer-users mailing list