[Mapserver-users] mapscript and float32 geotiffs

Sean Gillies sgillies at frii.com
Thu Jun 10 09:28:28 EDT 2004


On Jun 10, 2004, at 4:53 AM, John Beisley - RSG wrote:

> Hi,
>
> I'm trying to produce a 32-bit floating point geotiff as output from a 
> Python-Mapscript program. A similar thing used to work with the CGI 
> mapserv program with the OUTPUTFORMAT set as following:
>
> OUTPUTFORMAT
>   NAME FGTiff
>   DRIVER "GDAL/GTiff"
>   MIMETYPE "image/tiff"
>   IMAGEMODE FLOAT32
>   EXTENSION "tif"
> END
>
> However, I need to do a similar thing in mapscript and I run into a 
> segmentation fault. The top of the stacktrace looks like:
> #0  0x4073c39d in msImageInitGD (image=0x823f700, 
> background=0x40d72ea4)
>    at mapgd.c:137
> #1  0x407369bc in msDrawMap (map=0x40d4a008) at mapdraw.c:142
> #2  0x406c19ea in mapObj_draw (self=0x0) at mapscript_wrap.c:2403
> #3  0x406e41ac in _wrap_mapObj_draw (self=0x0, args=0x0)
>    at mapscript_wrap.c:18792
> #4  0x080f3469 in PyCFunction_Call (func=0x405d198c, arg=0x407a7aec, 
> kw=0x0)
>    at Objects/methodobject.c:108
>
> My code to setup the output format object is as follows:
>
> formatObj = mapscript.outputFormatObj("GDAL/GTiff")
> formatObj.name = "fgtiff"
> formatObj.imagemode = mapscript.MS_IMAGEMODE_FLOAT32
> formatObj.mimetype = "image/tiff"
> formatObj.extension = "tif"
> mapObj.outputformat = formatObj
>
> Any ideas why this might be happening or how to fix it?
>
> Many thanks,
>
> - John
>

Hi John,

The Python MapScript maintainer (me) and the GDAL guru (Frank)
are both away from work at the users meeting.  I don't have
the resources to test, but I do see several things right away.

Here is 4.2 code that should work.  Note the differences

     # format name should be passed as an arg to factory
     new_format = mapscript.outputFormatObj('GDAL/GTiff', 'fgtiff')
     new_format.imagemode = mapscript.MS_IMAGEMODE_FLOAT32

     # Everything else is OK, no need to set mimetype or extension

	# Insert into map.
     your_map.appendOutputFormat(new_format)

     # Activate
     your_map.setImageType('fgtiff')

I can't help but make a style suggestion -- mapscript.mapObj is
a class.  If you name instances of this class mapObj as well, you
will eventually run into trouble right?  Or maybe you are using
the experimental next generation API with 'Map', 'Layer', etc, in
which case carry on. :)

Back to follow up on Monday.
cheers,
Sean

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




More information about the mapserver-users mailing list