[Mapserver-users] 3.7 nightly and python/mapscript errors
Sean Gillies
sgillies at frii.com
Mon Apr 14 20:52:35 PDT 2003
Jerritt,
saveImage() is long gone from the nightly MapScript. Use save().
Your script then would be something like:
#!/usr/bin/python2.1
import mapscript
def drawmap():
mymap = mapscript.mapObj("/usr/lib/cgi-bin/maps/europe.map")
mymap.width=600
mymap.height=400
myimage=mymap.draw()
# Just specify filename as argument to 'save', all other
# parameters come from the map's outputformat
save_result = myimage.save("euro.png")
# The Python way would be to raise an error instead of
# returning a value
if not save_result == mapscript.MS_SUCCESS:
raise IOError, "Could not save to euro.png in drawmap()"
drawmap()
Take a look at the latest (3.7) documentation regarding map
outputformats and you'll see how to set the transparency and
such to suit your needs.
Also, don't forget that the Python MapScript has a saveToString()
method which Perl has not. Comes in handy when you'd like to
have image data in memory rather than on disk.
image_string = myimage.saveToString()
cheers,
Sean
On Monday, April 14, 2003, at 07:04 PM, Jerritt Collord wrote:
>
> SWIG stuff I wouldn't know where to start tracking down! The mapfile
> should be fine--I use it in all other interfaces okay--and it doesn't
> smell like that kind of problem.
>
> Thanks,
>
> Jerritt
>
> gurgle:/usr/lib/cgi-bin# ./testpy.py
> Traceback (most recent call last):
> File "./testpy.py", line 14, in ?
> drawmap()
> File "./testpy.py", line 11, in drawmap
> out = myimage.saveImage("euro.png",MS_PNG,50,0,50)
> File "/usr/lib/python2.1/site-packages/mapscript.py", line 1770, in
> <lambda> __getattr__ = lambda self, name: _swig_getattr(self,
> imageObj, name) File "/usr/lib/python2.1/site-packages/mapscript.py",
> line 19, in _swig_getattr raise AttributeError,name
> AttributeError: saveImage
>
> gurgle:/usr/lib/cgi-bin# cat testpy.py
> #!/usr/bin/python2.1
> import mapscript
> def drawmap():
> mymap = mapscript.mapObj("/usr/lib/cgi-bin/maps/europe.map")
> mymap.width=600
> mymap.height=400
> myimage=mymap.draw()
> out = myimage.saveImage("euro.png",MS_PNG,50,0,50)
> return out
> drawmap()
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
>
--
Sean Gillies
sgillies at frii.com
http://www.frii.com/~sgillies
More information about the MapServer-users
mailing list