[Mapserver-users] Python Mapscript: Get All Outputformat in Mapfile

Sean Gillies sgillies at frii.com
Wed Jul 7 09:44:55 EDT 2004


On Jul 7, 2004, at 6:24 AM, Jan Schüngel wrote:

> Hi,
>
> i am coding a python program to edit the mapscript. Now I am searching 
> for a way to get all outputformats in the mapfile and which 
> outputformats are supported too.
>
> when i use mymap.outputformats i only get the one which is set by 
> imagetype.  And i can get the outputformat by 
> mymap.getOutputFormatByName(mymap.imagetype).
>
> the numoutputformats gives me the number 6 when i create a new empty 
> mapfile (mymap = mapscript.mapObj("") but i have found no way to find 
> out which outputformats are these.
>
> I only can get the outputformat by name, but i don't know the names of 
> the formats.
> Is there anybody who can help me ?
>
> Greets
> J. S.
>
> P.S.: Sorry for my bad english.

Hi Jan,

You write english well.  Do not be sorry :)

The mapscript module now lacks a method to iterate over the formats
in mapObj.formats.  The most likely names for built-in formats are

['gif', 'png', 'png24', 'jpeg', 'wbmp', 'swf', 'pdf', 'imagemap']

to find out what you have in the map, you do something like this:

formats = []
for fmtname in ['gif', 'png', 'png24', ...]:
	format = mymap.getOutputFormatByName(fmtname)
     if format:
         formats.append(format)

In the future, we should probably have a getOutputFormat() method
that works like getLayer() and that would allow

     formats = [mymap.getOutputFormat(i) for i in 
range(maymap.numoutputformats)]

but this will not be available until the 4.4 release at the soonest.

cheers,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies




More information about the mapserver-users mailing list