Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#1816 closed defect (fixed)

Mapscript mapObj.save() to write out multiple outputformats

Reported by: shoaib@… Owned by: warmerdam
Priority: high Milestone:
Component: MapScript Version: 4.8
Severity: normal Keywords:
Cc: shoaib@…

Description

Shoaib Burq <hydromap@gmail.com>  Sat, Jul 1, 2006 at 11:26 PM  
To: MAPSERVER-USERS@lists.umn.edu  
Hi all

we are trying to create a mapfile on the fly and need to add multiple
outputformats to the mapfile. we can use the
appendOutputFormat(new_OF) in python-mapscript. However when using the
mapObj.save(mymapfile.map) to write our map object to file, it only
writes-out the last format appened.

The only relavent code i found was in:
mapserver/mapscript/python/tests/cases/outputformattest.py
But this only tests if the current outputformat is defined correctly ...

Does anyone know if we can use the mapObj.save() function to create
mapfiles with multiple OUTPUTFORMAT definitions and if not anyone know
where the save() function's defined and if its easy to extend it to do
this?

thanks heaps
shoaib
--
http://nomad-labs.com
 

---------------
Frank Warmerdam <warmerdam@pobox.com>  Mon, Jul 3, 2006 at 7:52 PM  
To: Shoaib Burq <hydromap@gmail.com> 
Cc: MAPSERVER-USERS@lists.umn.edu  
[Quoted text hidden]
Shoaib,

I think this is a bug.  If you could submit a bugzilla entry on this and
ensure it is assigned to me I'll look into fixing it.   At least in 4.9.

Best regards,

Change History (3)

comment:1 by shoaib@…, 18 years ago

Summary: Mapscript mapObj.save() to write out multiple outputformats Mapscript mapObj.save() to write out multiple outputformats
Here's a test-case to reporoduce the problem:

---------------------
#!/usr/bin/python

import mapscript

m1 = mapscript.mapObj()

# create 1st outputFormat
of1 = mapscript.outputFormatObj('GDAL/Gtiff', 'myGTiff')
of1.setExtension('tif')
of1.setMimetype('image/tiff')
of1.imagemode = mapscript.MS_IMAGEMODE_BYTE

# create 2nd outputFormat
of2 = mapscript.outputFormatObj('GD/PNG', 'myPNG')
of2.setExtension('png')
of2.setMimetype('image/png')
of2.imagemode = mapscript.MS_IMAGEMODE_BYTE

# add to the OF's mapObj
m1.appendOutputFormat(of1)
m1.appendOutputFormat(of2)

# Select one of the above OF, if this is not done the default is PC256 GIF
m1.selectOutputFormat('myPNG')

m1.save('test.map')
-------------------

The m1.save() will only write out the 'of2' above.

comment:2 by fwarmerdam, 18 years ago

Resolution: fixed
Status: newclosed
Shoaib,

I discovered that outputFormatObj's now have a field called "inmapfile".
You can make the output format objs appear in the map file by setting
this to 1 (MS_TRUE).  So, that should give you a work around.

I have also modified the mapcript/swiginc/outputformat.i constructor so
that any outputFormatObj created via mapscript will have this set to MS_TRUE
by default.  This change is only going into 4.9 (aka CVS head) for now. 

Thanks for the easy to use test script demonstrating the problem.

comment:3 by fwarmerdam, 18 years ago

I'm applying this fix in 4.8 as well to get it into 4.8.4.
Note: See TracTickets for help on using tickets.