Route web service 的世界
Map Services(WMS,WFS) +Route plan Services(WPS)+ Route drving directions Services(WPS)+ Route Visualization Services(WPS)=Route web services

Mapnik configuration XML

General

Comments can be placed in the configuration file using the default xml <!-- --> syntax

Map

The Map object defines the master object of a mapnik configuration XML. It defines map wide parameters and serves as the envelope for Style and Layer definitions.

  • Element: Map
  • Element type: Root element
  • Attributes:
    • bgcolor: HTML color code for the background-color of the map (for instance #000000)
    • srs: Coordinate system in which the map is rendered (for instance '+proj=latlong+datum=WGS84' for a WGS84 Geographic coordinate system)
    • buffer_size: Default 0; Good value is usually tile size/2 to help avoid cut labels. This influences envelope used by placement detector ( i.e. 'avoid_edges' parameter)
  • xmlcomment: (Ignored by Mapnik)
  • xmlattr: (Ignored by Mapnik)

Style

A Style object defines the way objects can be rendered. A Mapnik configuration file can have an unlimited number of Style objects. Style objects are referenced by Layer objects in order to actualy be rendered.

  • Element: Style
  • Element type: Collection of Rules
  • Attributes
    • name: Name for this Style object. Needs to be unique per configuration file. A Style is referenced by a Layer through the corresponding StyleName? parameter. If a name is ommited, what will happen?
  • Children:
  • xmlcomment: (Ignored by Mapnik)
  • xmlattr: (Ignored by Mapnik)

Layer

  • Attributes:
    • name: The Name of the layer
    • status: Default "off"; on or off, "0" or "1"
    • clear_label_cache: Default "off". Setting this to "on" clears the internal placement detector list, causing the items of this layer, and from this layer on, to be rendered without taking previous rendered items into account ('clear collision avoidance list')
    • srs: Default inherits from map.srs; Reference system from the the project [Proj.4]. e.g. +proj=latlong +datum=WGS84
    • abstract: Default
    • title: Default
    • minzoom: Default 0.0
    • maxzoom: Default 1.797693134862316e+308
  • Children:
    • StyleName?: The name of a defined style. The style must contain the same string in the attribute name.
    • Datasource: See Datasource

Datasource

See also the 0.6.0 Python API docs

  • Element: Datasource
  • Element type:
  • Attributes: none
  • Generic Parameters:
    • type: Specifies the format of the data source
      • Possible values:
        • shape : ESRI shapefile
        • postgis : Postgis table or query
        • gdal : GDAL supported raster dataset
        • ogr : OGR supported vector datasource
        • raster : Tiled or stripped TIFF
        • osm : Open Street Map (not included by default)
    • estimate_extent: boolean to tell Mapnik to estimate the extent of the layer (true) or not (false)
    • extent: manually enter an extent if estimate_extent is set to false
  • Additional parameters for type postgis
    • host: The name of the postgis-server
    • port: The port of the postgis-server
    • dbname: database name
    • user: username to access the postgis database
    • password: The password of the username to access the postgis database
    • table: Name of the table or postgis query. subquery has to use sytax of: '( ) as table'
    • geometry_field: Use the geometry_field parameter to specify which field to use if you have >1 geometry in the table/query (added in r769).

  • Additional parameters for type shape
    • file: For shape type; location and name (without extension) of the ESRI shapefile
  • Additional parameters for type osm
    • file: location and name (with extension) of the OSM Filename
    • parser: Parser for the xml file. (Should be 'libxml2')

Rule

  • Element: Rule
  • Element type:
  • Attributes
    • name
    • title

Also see SymbologySupport for more info on Symbolizers

 

 

 

LineSymbolizer

A LineSymbolizer is used to render a "stroke" along a linear geometry.

parameter value description unit default
stroke CSS colour A Color value such as 'green' or #A3D979 - "black"
stroke-width 0.0 - n Width of line pixels 1.0
stroke-opacity 0.0 - 1.0 1 is fully opaque while zero is fully transparent and .5 would be 50% transparent transparency 1.0
stroke-linejoin miter, round, bevel See http://www.w3.org/TR/SVG/painting.html#propdef-stroke-linejoin for an example for each value - miter
stroke-linecap round, butt, square See http://www.w3.org/TR/SVG/painting.html#propdef-stroke-linecap for an example for each value - butt
stroke-dasharray 0.0 - n,0.0 - n A pair of length values [a,b], where (a) is the dash length and (b) is the gap length respectively. More than two values are supported as well (e.g. to start the line not with a stroke, but with a gap). pixels none

Examples

line_symbolizer_2.png

Default


World borders data with default LineSymbolizer

<LineSymbolizer />

XML

<LineSymbolizer>
<CssParameter name="stroke">#0000ff</CssParameter>
<CssParameter name="stroke-width">4</CssParameter>
</LineSymbolizer>

Python

l = LineSymbolizer(Color('green'),0.1)
l.stroke.add_dash(.1,.1)
l.stroke.opacity = .5

Fetch all the possible methods like:

>>> from mapnik import LineSymbolizer
>>> dir(LineSymbolizer().stroke)

C++

FIXME

Attachments

 

PointSymbolizer

A PointSymbolizer specifies the rendering of a "graphic symbol" at a point.

parameter value default
file path to image file none
width px 4
height px 4
type png tiff none
allow_overlap allow text to overlap the point image; true/false false

 

 

Mapnik Output Formats

Mapnik supports rendering with both AGG and Cairo (see MapnikRenderers for more detail), and can create maps or map tiles in a variety of formats.

Tradeoffs

Mapnik Format Renderer Type Visual Quality Rendering Speed* Size* Relevant Code
png AGG 32-bit png 0.12 s 16 KB source:trunk/include/mapnik/png_io.hpp
png256 AGG 8-bit png256 0.12 s 8 KB source:trunk/include/mapnik/png_io.hpp
jpeg AGG ? jpeg 0.12 s 8 KB source:trunk/include/mapnik/jpeg_io.hpp
ARGB32 (png) CAIRO 32 bit png24 0.24 s 20 KB source:trunk/include/mapnik/cairo_renderer.hpp
RGB24 (png) CAIRO 24 bit alpha png32 0.24 s 20 KB source:trunk/include/mapnik/cairo_renderer.hpp
svg CAIRO N/A svg 0.28 s 980 KB source:trunk/include/mapnik/cairo_renderer.hpp
pdf CAIRO N/A pdf 0.40 s 232 KB source:trunk/include/mapnik/cairo_renderer.hpp
ps CAIRO N/A postscript 0.36 s 1.4 MB source:trunk/include/mapnik/cairo_renderer.hpp

 

posted on 2009-04-17 03:42  xiaomoon  阅读(849)  评论(0)    收藏  举报