[Tilecache] Where in TC code is metatile cutting?

Roger André randre at gmail.com
Wed Jan 20 13:43:34 EST 2010


Hi Ivan,

One thing I've started looking at is to have GDAL do the image cutting.
GDAL preserves the palette information exactly, as you can test by taking an
image generated by MapServer and cropping it with gdal_translate.  The
problem lies in getting the MapServer image data fed directly into GDAL,
without creating a file on disk for it to read.  The best I've been able to
do so far is to embed the WMS request URL directly into the GDAL api call.
So you get something that looks like this:

url = "
http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/sav0656/basemap.map&layers=Ditches&styles=&service=WMS&width=1056&format=image%2Fpng&request=GetMap&height=1056&srs=EPSG%3A900913&version=1.1.1&bbox=19411336.2028%2C19411336.2028%2C60738697.1524%2C60738697.1524
"

gdal.Open(url)

>From there, you can use GDAL to operate on the image directly.   I haven't
figured out all of the cropping sysntax yet, but all of the information
needed to do it is present in the Metatile info.

Roger
--



On Tue, Jan 19, 2010 at 11:52 PM, Ivan Mincik <ivan.mincik at gista.sk> wrote:

>
> > Ivan,
> >
> > Using PythonMagick, I was able to create the following image:
> >
> > http://img35.imageshack.us/img35/6583/testyi.png
> >
> > using this code:
> >
> > import PythonMagick
> > import urllib
> >
> > data = urllib.urlopen("http://gista.sk/dl/test.png")
> > blob = PythonMagick.Blob(data.read())
> > image = PythonMagick.Image(blob);
> > image.quantizeColors(256)
> > image.quantizeDither(False)
> > image.quantize()
> > image.write("/tmp/test.png")
> >
> > PythonMagick can be somewhat difficult to unstall, although it was
> > trivial on Ubuntu server as a package already exists for it.
>
> Thanks a lot for this example.
> I seems that original quantized image from UMN Mapserver is loaded by
> ImageMagick to some internal structure and than it
> can be processed (cut metaTiles to tiles, ...). If I want to save it to
> same format as it was produced by UMN Mapserver
> I need to use quantize again in ImageMagick. Resulting palette is totally
> different to original so UMN Mapserver
> quantization is lost/replaced by ImageMagick and therefore is not needed -
> I rather can produce RGBA images from UMN
> Mapserver to save CPU.
>
> Still, we don't have a solution for cutting quantized metaTiles in python
> and saving them back without any changes to
> palette.
>
> > You appear to have better results with MapServer and indexed RGB
> > output.  I was never able to get the fonts looking good, hence the
> > post-processing to reduce the color depth with ImageMagick.  Can you
> > share your OUTPUTFORMAT section of your map file?
>
> My outputformat section. Using UMN Mapserver 5.2.x
>
>        OUTPUTFORMAT
>                NAME "PNG_AGGAQ"
>                DRIVER "AGG/PNG"
>                MIMETYPE "image/png"
>                IMAGEMODE RGBA
>                FORMATOPTION "QUANTIZE_FORCE=ON"
>                FORMATOPTION "QUANTIZE_DITHER=OFF"
>                FORMATOPTION "QUANTIZE_COLORS=256"
>                FORMATOPTION  "INTERLACE=OFF"
>                EXTENSION "png"
>        END
>
> Ivan
>
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/tilecache/attachments/20100120/c3679dc8/attachment.html


More information about the Tilecache mailing list