User:Moresby/Understanding Mapnik/Revisiting our examples in XML
Jump to navigation
Jump to search
Understanding Mapnik
A Mapnik tutorial
Starting with Python
Using XML and CSS
CartoCSS and PostGIS
Any map design built up using Python objects should also be representable using XML. For completeness, here are the XML files corresponding to our previous exercises:
110-background.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'/>
120-points.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='basic_style'>
<Rule>
<PointSymbolizer/>
</Rule>
</Style>
<Layer name='main_map'>
<StyleName>basic_style</StyleName>
<Datasource>
<Parameter name='file'>data-places.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
121-points-images.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='basic_style'>
<Rule>
<PointSymbolizer file='circle_red_16x16.png'/>
</Rule>
</Style>
<Layer name='main_map'>
<StyleName>basic_style</StyleName>
<Datasource>
<Parameter name='file'>data-places.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
130-lines.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='basic_style'>
<Rule>
<LineSymbolizer/>
</Rule>
</Style>
<Layer name='main_map'>
<StyleName>basic_style</StyleName>
<Datasource>
<Parameter name='file'>data-roads.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
131-lines-colour.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='basic_style'>
<Rule>
<LineSymbolizer stroke='green' stroke-width='2'/>
</Rule>
</Style>
<Layer name='main_map'>
<StyleName>basic_style</StyleName>
<Datasource>
<Parameter name='file'>data-roads.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
132-lines-stroke.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='basic_style'>
<Rule>
<LineSymbolizer stroke='green' stroke-width='2' stroke-dasharray='6, 2'/>
</Rule>
</Style>
<Layer name='main_map'>
<StyleName>basic_style</StyleName>
<Datasource>
<Parameter name='file'>data-roads.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
140-layers.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='line_style'>
<Rule>
<LineSymbolizer/>
</Rule>
</Style>
<Style name='point_style'>
<Rule>
<PointSymbolizer file='circle_red_16x16.png'/>
</Rule>
</Style>
<Layer name='line_layer'>
<StyleName>line_style</StyleName>
<Datasource>
<Parameter name='file'>data-roads.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
<Layer name='point_layer'>
<StyleName>point_style</StyleName>
<Datasource>
<Parameter name='file'>data-places.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
150-filters.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='line_style'>
<Rule>
<Filter>[type]='rail'</Filter>
<LineSymbolizer stroke-width='2' stroke-dasharray='6, 2'/>
</Rule>
<Rule>
<Filter>[type]='road'</Filter>
<LineSymbolizer/>
</Rule>
<Rule>
<Filter>[type]='mainroad'</Filter>
<LineSymbolizer stroke-width='2'/>
</Rule>
<Rule>
<Filter>[type]='motorway'</Filter>
<LineSymbolizer stroke='lightblue' stroke-width='4'/>
</Rule>
</Style>
<Style name='point_style'>
<Rule>
<Filter>[type]='town'</Filter>
<PointSymbolizer file='circle_red_8x8.png'/>
</Rule>
<Rule>
<Filter>[type]='city'</Filter>
<PointSymbolizer file='circle_red_16x16.png'/>
</Rule>
</Style>
<Layer name='line_layer'>
<StyleName>line_style</StyleName>
<Datasource>
<Parameter name='file'>data-roads.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
<Layer name='point_layer'>
<StyleName>point_style</StyleName>
<Datasource>
<Parameter name='file'>data-places.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>
160-text.xml
<?xml version='1.0'?>
<Map background-color='ghostwhite'>
<Style name='line_style'>
<Rule>
<Filter>[type]='rail'</Filter>
<LineSymbolizer stroke-width='2' stroke-dasharray='6, 2'/>
</Rule>
<Rule>
<Filter>[type]='road'</Filter>
<LineSymbolizer/>
<TextSymbolizer face-name='DejaVu Sans Book' halo-radius='2' placement='line'>[name]</TextSymbolizer>
</Rule>
<Rule>
<Filter>[type]='mainroad'</Filter>
<LineSymbolizer stroke-width='2'/>
<TextSymbolizer face-name='DejaVu Sans Book' halo-radius='2' placement='line'>[name]</TextSymbolizer>
</Rule>
<Rule>
<Filter>[type]='motorway'</Filter>
<LineSymbolizer stroke='lightblue' stroke-width='4'/>
<TextSymbolizer face-name='DejaVu Sans Book' halo-radius='2' placement='line'>[name]</TextSymbolizer>
</Rule>
</Style>
<Style name='point_style'>
<Rule>
<Filter>[type]='town'</Filter>
<PointSymbolizer file='circle_red_8x8.png'/>
<TextSymbolizer face-name='DejaVu Sans Book' halo-radius='3' dy='7'>[name]</TextSymbolizer>
</Rule>
<Rule>
<Filter>[type]='city'</Filter>
<PointSymbolizer file='circle_red_16x16.png'/>
<TextSymbolizer face-name='DejaVu Sans Book' size='12' fill='red' halo-radius='3' dy='11'>[name]</TextSymbolizer>
</Rule>
</Style>
<Layer name='line_layer'>
<StyleName>line_style</StyleName>
<Datasource>
<Parameter name='file'>data-roads.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
<Layer name='point_layer'>
<StyleName>point_style</StyleName>
<Datasource>
<Parameter name='file'>data-places.csv</Parameter>
<Parameter name='type'>csv</Parameter>
</Datasource>
</Layer>
</Map>