[mapserver-dev] Using mapserver.a to generate tiles

Stephen Woodbridge woodbri at swoodbridge.com
Thu Aug 26 00:11:12 EDT 2010


On 8/25/2010 11:05 PM, Stephen Woodbridge wrote:
> Hi all,
>
> I guess these questions might be targeted at Steve L and/or Thomas
> Bonfort, but I'll take info from anyone that might know.
>
> I have written a C program that uses mapserver.a and generates tiles for
> seeding a tile cache. It works great with GD and AGG rendering when I
> quantize the output images as 8-bit png images that can be transparent
> or not.
>
> I have run into two problems:
>
> Rendering transparent overlays with AGG and then palettizing the image
> leaves dark pixels along the lines as an artifact of the anti aliasing
> and the palettization. But I can chop these meta tiles into tiles with
> no problems.
>
> If I try to generate RGBA tiles, these artifacts are not seen in the
> meta tile if I leave the image as RGBA, but when I chop the metatile
> into tiles the background is no longer transparent (I'm guessing it is
> RGB and not RGBA.
>
> The code makes calls like these:
>
> // read the mapfile, and setup the layers, extents, outputformat, then
> oImg = msDrawMap(map, MS_FALSE);
>
> // save the image to force color reduction
> // for the RGBA case ie: not palettized
> // this appears to change buffer_format = 7 to buffer_format = 1
> ret = msSaveImage(NULL, oImg, szMetaImg);
>
> // we cycle through the rows, cols of the metatile write the tiles
> oTile = msImageCreateGD(tileWidth, tileHeight, oImg->format, NULL, NULL,
> map->resolution, map->defresolution);

Ok, I get marginally closer to the solution if I change the call above to:

oTile = msImageCreateGD(tileWidth, tileHeight, oImg->format, NULL, NULL, 
map);

Now the tiles in agg_32png are transparent, but the lines also appear to 
be transparent with only the anti-aliasing pixels showing up. I still 
think I have a problem to buffer_format being in the wrong setting after 
saving the metatile.

-Steve

> msImageCopyMerge(oTile, oImg, 0, 0, tileLeft, tileTop, tileWidth,
> tileHeight, 100);
>
> ret = msSaveImage(NULL, oTile, qtp);
> msFreeImage(oTile);
>
>
> So, I'm guessing that the change in buffer_format is somehow affecting
> the behavior of msImageCreateGD() or msImageCopyMerge() that is
> affecting the alpha transparency when I create the tiles. Can anyone
> shed some light on that and how I might work around that.
>
> Second, since the RGBA tile issue was an attempt to work around the dark
> speck artifacts on the anti aliased lines that get palleted, any
> thoughts on how to remove the specks.
>
> Third, but less important at the moment, I am aware this all changes in
> 6.0 and I am curious about what happens when the GD code is removed. But
> I can probably wait till that is in trunk and go digging after that.
>
> My mapfile looks like the following. I have tried various combinations
> of options on the various OUTPUTFORMATs.
>
> -Steve W
>
> MAP
> NAME "Statesp020"
> EXTENT -19941038.1 1999506.7 20013931.8 11539767.3
> SIZE 700 550
> SHAPEPATH "/u/data/flytecomm/gisdata/"
> #SYMBOLSET "/u/data/maps/symbols/symbols.sym"
> #FONTSET "/u/data/maps/fontset.txt"
> IMAGECOLOR 0 0 0
> # IMAGETYPE 'agg_qn' # this leaves artifacts along the lines
> # IMAGETYPE 'PNG8' # no artifacts but lines are not anti aliased
> # IMAGETYPE 'agg_32png' # metatile is ok, tiles have black bgcolor
> IMAGETYPE 'agg_32png' # tile are not transparent
> TRANSPARENT ON
> UNITS METERS
> # DEBUG 5
> # CONFIG MS_EEORFILE "stderr"
>
> OUTPUTFORMAT
> NAME "agg_qn"
> DRIVER "AGG/PNG"
> EXTENSION "png"
> MIMETYPE "image/png"
> IMAGEMODE RGBA
> TRANSPARENT ON
> FORMATOPTION "INTERLACE=false"
> FORMATOPTION "QUANTIZE_NEW=ON"
> FORMATOPTION "QUANTIZE_FORCE=ON"
> FORMATOPTION "QUANTIZE_DITHER=OFF"
> FORMATOPTION "QUANTIZE_COLORS=256"
> FORMATOPTION "TRANSPARENT=ON"
> END
>
> OUTPUTFORMAT
> NAME "agg_32png"
> DRIVER "AGG/PNG"
> EXTENSION "png"
> MIMETYPE "image/png"
> IMAGEMODE RGBA
> TRANSPARENT ON # comment or not does not help
> FORMATOPTION "INTERLACE=OFF"
> FORMATOPTION "TRANSPARENT=ON" # comment or not does not help
> END
>
> OUTPUTFORMAT
> NAME PNG8
> DRIVER "GD/PNG"
> EXTENSION "png"
> MIMETYPE "image/png"
> IMAGEMODE RGBA
> TRANSPARENT ON
> FORMATOPTION "INTERLACE=false"
> FORMATOPTION "QUANTIZE_NEW=ON"
> FORMATOPTION "QUANTIZE_FORCE=ON"
> FORMATOPTION "QUANTIZE_DITHER=OFF"
> FORMATOPTION "QUANTIZE_COLORS=256"
> FORMATOPTION "TRANSPARENT=ON"
> END
>
> # PROJECTION
> # # Sperical Mercator
> # "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0
> +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
> # END
>
> SYMBOL
> NAME 'circle'
> TYPE ELLIPSE
> POINTS 1 1 END
> FILLED true
> END
>
> LAYER
> NAME "states"
> TYPE POLYGON
> STATUS DEFAULT
> TRANSPARENCY ALPHA
> DATA "states/statesp020-900913"
> CLASS
> STYLE
> WIDTH 1.0
> #SIZE 3.0
> #SYMBOL 'circle'
> #COLOR "#b5d29c"
> OUTLINECOLOR "#88ff88"
> END
> END
> END
>
> END
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev



More information about the mapserver-dev mailing list