I followed the tutorial from switch2osm to create a tiles server, but this tutorial is only for an apache server.
I have a Django server and wanted to create a custom map for it. I already installed Mapnik, PostGIS and loaded OSM data into my PostGIS database.
I created a python script that, using Mapnik, creates a simple map with the following code:
#!/usr/bin/env python
import mapnik
stylesheet = 'database.xml'
image = 'database.png'
m = mapnik.Map(900, 450)
mapnik.load_map(m, stylesheet)
m.zoom_all()
mapnik.render_to_file(m, image)
print "rendered image to '%s'" % image
And the xml file:
<Map background-color="steelblue" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<Style name="My Style">
<Rule>
<PolygonSymbolizer fill="#f2eff9" />
<LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" />
</Rule>
</Style>
<Layer name="countries" status="on" srs="+proj=latlong +datum=WGS84">
<StyleName>My Style</StyleName>
<Datasource>
<Parameter name="type">postgis</Parameter>
<Parameter name="host">localhost</Parameter>
<Parameter name="dbname">db</Parameter>
<Parameter name="user">user</Parameter>
<Parameter name="password"></Parameter>
<Parameter name="table">(SELECT * from planet_osm_line where highway is not null) as foo</Parameter>
<!-- <Parameter name="extent">-180,-90,180,89.99</Parameter> -->
<!-- <Parameter name="extent">-20037508.34,-20037508.34,20037508.34,20037508.34</Parameter> -->
</Datasource>
</Layer>
</Map>
This generates the following image (I only loaded this OSM data and not the whole planet):
I was thinking of creating a something like this to create a Django view that would offer my map tiles, but it takes too long to process (3 minutes).
How can I use Mapnik to create, with Django, a tile server? Is there any Django library to make this easier?