In this chapter, we explored the Mapnik map-generation toolkit in depth. We learned that maps are composed of multiple layers, drawn one on top of the other using the painter's algorithm. We saw that each layer has a data source and a list of styles that determine how the data is to be displayed. Styles are referred to by name, so they can be shared between the various map layers.
We learned that each style has a list of rules associated with it, where each rule can optionally have a filter limiting the set of features to be displayed as well as a list of symbolizers that control how the matching features are to be drawn.
We then saw how the mapnik.Map object combines the styles and map layers and how the map can be used to zoom in to a particular area of the world before rendering an image based on the map's contents.
We put all these concepts together into a simple map-generating program before delving deeper into the Mapnik library. We examined four of the major types of data sources: Shapefile, PostGIS, Gdal, and MemoryDatasource. We saw how rules, filters, and styles work together and examined the major types of symbolizers you are likely to use in your programs: the PointSymbolizer for drawing point geometries, the LineSymbolizer for drawing linear features and the outline of a polygon, the PolygonSymbolizer for filling the interior of a polygon, the TextSymbolizer for drawing textual labels, and the RasterSymbolizer for drawing raster images into a map.
We then looked at how the map and layer objects can work together, including how to use scale factors to selectively show or hide map layers, and finished by looking at the various ways in which a map image can be rendered.
In the next chapter, we will combine spatial databases with Mapnik to build a sophisticated geospatial application called DISTAL.