Thursday, February 21, 2008

Mapguide 2.0 - AGG versus GD Renderers

Using the AGG Renderer ( New default in MG 2.0 )

Using the GD Renderer

Here is the same layer using the different renderering engines in Mapguide 2.0. The main difference between the two is that AGG does sub-pixel rendering which give smoother lines, whereas GD is pixel level.

The AGG lines feel a bit too thick to me, they are line thickness one for a polygon boundary. Even for a straight line in the middle of the map, it's just to thick (That's SA/NT border in Australian for those aren't so familiar with Australia.) The src data is 29 MB so there is a fair amount of generalization being done but hey that might be the reason for the thicker lines.

GD is the same as earlier Mapguide Releases and is still available via changing the Renderer value in the server/bin/serverconfig.ini file.

I like the darker smoother stronger feel of the AGG lines, but i think they would be better if they were maybe 1/2 to 1/3 thinner. What do you think?

These are rendered from SDF's exported from Oracle using FDO2FDO which is now work again in Mapguide 2.0 RC4. Generally everything is working well since installing it an few hours ago, next up i will upgrade my java libs with Coldfusion 8 and do some more testing API wise.


Anonymous said...

AGG lines are thick but you should be able to thin them up in the settings?, although line widths of below 0.5mm don't render correctly. It looks a bit generalised in places and data has been lost with the AGG rendering.

I think if doing a map at this scale it would be better to use a different dataset so you already have the generalisation. Then use the AGG rendering.

Anonymous said...

I think I have an explanation for the thicker lines in the Agg rendering.

In the GD case, where no anti-antialising is used, pixels are completely filled or unfilled, based on their distance from the line being rasterized. The result is that only certain pixels along the path of a line are filled. This results in a thin, jaggy line.

In the Agg case, the coverage of all pixels intersected by the line is calculated. Pixels that are only partially covered by the line will be assigned a low-intensity. If a line is drawn once then this results in a smoother looking line. However, if the same line is rasterized more than once then problems can arise - it depends on how the results of rasterizing a single polygon are combined with the distination pixels. If the intensities in the destination pixels are replaced with those calculated for the current polygon then things will be fine. However, if they're combined with the destination pixels, eg. by increasing the intensity of destination pixels, then the repeated rendering of a line will cause all the pixels that intersect the line to get darker. The result is a much thicker line. It will also be more jagged than it should be.

The solution would be to render lines once, or to dig into the guts of Agg and specify a src-over compositing rule.