Home > mapserver > Playing with Mapserver AGG Rendering…

Playing with Mapserver AGG Rendering…

August 19th, 2007 rupert

cybersoft_map_agg.png

Summary
One of the upcoming power features of Mapserver 5.0 is its AGG Rendering engine. Above is an example image of the AGG rendering capabilities of Mapserver. Below is a list of my experiences with Mapserer 5.0 AGG

  • Slower than GD ofcourse, but cartographic quality is really impressive…
  • You need to have SUPPORT=AGG to be able to use AGG. So far, I was not able to compile mapserver source with AGG, however using mapserver-beta-3 for linux and ms4w betas worked fine.
  • Layer Transparency. I was not able to get transparency for my roads overlaying on top of my basemap. Tbonfort from IRC suggested I use RGBA for the outputformat, but it still breaks. Hope Im not missing anything important here…

The Mapfile
Currently, the mapfile ( map_all_agg.map ) contains 2,587 lines! The lengthy mapfile consists of the ff: districts or political boundaries, water bodies, greens or open spaces, roads, subway lines, subway stops. The roads is classified into 12 categories ( Expressway, Class-1, Class-2, Class-3, Class-4, Major Road, Main, Secondary, Minor, CommunityRoad(w/name), CommunityRoad, ParkRoads). Class1-4 is a classification for Roads outside the 5th Ring Road of Beijing. While Major Roads – Minor Roads is a classification inside the 5th Ring. The roads were drawn as a line layer and not as a polygon.

How to achieve the overlapping of road intersections?
The technique is to seperate the road boundary layer from the actual road line. A mixture of widths and color management was employed to achieve the effect. Essentially, we started with the ff:

1. road boundary layer
2. road layer

Further , trial and error resulted in refining the road boundary layer with different minscales and maxscales. The same was adapted with the road layer. Download map_all_agg.txt. My next iteration, would be to refactor some of the road layers if possible.

A couple of notes to myself, we could speed things up by trying out the ff:

  • Using SHPTREE
  • Simplifying the geometry as you change scales

Testing Methodology
1. Use Firefox and install firebug.
2. Download YSlow from Yahoo.
3. View load times using “net” tab
firebug-1.png

Using SHPTREE
1. The utility specifies indexes as it slices the shapefile into quadrants as specified from its definition. To run shptree, do the ff:

$ shptree roads.shp
creating index of new LSB format

2. It would generate a roads.qix. No changes need to be made with the mapfile. Mapserver loads the shapefile without the extension.

3. Testing… Significant speed improvements were made as shown below:

  • Before: 29.44 secs
  • After: 5.91 secs
Categories: mapserver Tags:
  1. aileen
    August 23rd, 2007 at 20:49 | #1

    Ano gamit mo pang-convert? mapinfo or arc gis? napansin kasi namin you used shptree roads.shp.

  2. rupert
    August 24th, 2007 at 19:46 | #2

    Neither of the two. SHPTREE is a mapserver utility. http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?ShpTree

  3. August 29th, 2007 at 19:31 | #3

    I have added the ff outputformats to the mapfile.

    OUTPUTFORMAT
    NAME ‘AGG’
    DRIVER AGG/PNG
    IMAGEMODE RGB
    END

    OUTPUTFORMAT
    NAME ‘AGGA’
    DRIVER AGG/PNG
    IMAGEMODE RGBA
    END

    OUTPUTFORMAT
    NAME ‘AGG_JPEG’
    DRIVER AGG/JPEG
    IMAGEMODE RGB
    FORMATOPTION “QUANTIZE_FORCE=ON”
    FORMATOPTION “QUANTIZE_DITHER=OFF”
    FORMATOPTION “QUANTIZE_COLORS=256″
    END

    Significant reduce in kb size when switching from AGG(200KB)/AGGA(217KB) to AGG_JPEG(75KB)

  4. rupert
    January 5th, 2008 at 19:57 | #4

    My mapfile now consists of includes for better organization. Please see http://mapserver.gis.umn.edu/docs/reference/mapfile/Include

Comments are closed.