python mapscript segfault

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Thu Nov 9 03:01:58 EST 2006


On 11/9/06, John Cartwright <John.C.Cartwright at noaa.gov> wrote:
> Hello All,
>
> I'm trying to use python mapscript (4.10.0) on MacOS 10.4 to create a
> map dynamically and output the image.  Code seems to segfault at the
> termination of the program. Can anyone see what I'm doing wrong or
> suggest a method of tracing the problem?

John,
you are not doing anything wrong, simply mapsscript doesn't have
properly implemented memory management so creating maps dinamically is
not supported (even though it could work).
I think in your case you should get the image correctly drawn anyway,
so you could ignore the (annoying) segfault at program exit.

Umberto

>
> Thanks!
>
> -- john
>
>
> import mapscript;
>
> map = mapscript.mapObj()
> map.name = "CustomMap"
> map.setSize(600,300)
> map.setExtent(-180.0,-90.0,180.0,90.0)
> map.imagecolor.setRGB(180,180,250)
> map.units = mapscript.MS_DD
>
> layer = mapscript.layerObj(map)
> layer.name = "countries"
> layer.type = mapscript.MS_LAYER_POLYGON
> layer.status = mapscript.MS_DEFAULT
> layer.data = "/usr/local/shapefiles/country.shp"
>
> class1 = mapscript.classObj(layer)
> class1.name = "Countries"
>
> style = mapscript.styleObj(class1)
> style.outlinecolor.setRGB(100,100,100)
> style.color.setRGB(200,200,200)
>
> map_image = map.draw()
> filename = 'test.' + map_image.format.extension
> map_image.save(filename)
>



More information about the mapserver-users mailing list