[OSM-talk] Mapnik Tilecache Memory Error (Myanmar Cyclone Relief)

Brett Henderson brett at bretth.com
Mon Jun 9 07:08:20 BST 2008


Hi All,

Just to give some background on what I'm trying to do here.  I'm helping 
a team in Myanmar setup a software package called Sahana which is an 
open source disaster response package.  It will be used to help in the 
response to the recent Cyclone.
http://www.sahana.lk/

It has a map component based on OpenLayers allowing it to display maps 
of affected areas.  They wish to use OSM data to provide this because it 
provides them with the best chance of producing decent maps of the area.

A constraint they face is extremely poor and intermittent network 
connectivity.  I can limit the bandwidth required by using osmosis to 
download incremental OSM data updates into a local OSM file and 
regularly re-import it into a mapnik postgis database.

They also wish to setup users as OSM editors to directly edit OSM data 
in the region, at this point we will attempt to use JOSM's offline 
editing.  In future we might look into a full replicated OSM instance 
with a replication mechanism back to the main OSM database but this is 
complicated and lower priority right now.

The Sahana guys have already been able to get Sahana configured to 
retrieve tiles from OSM tile servers so the client side is working.  The 
next step is to render these tiles locally without requiring an Internet 
connection.  I don't want to pre-render tiles because this constrains 
the turnaround time on making new data available for display, on-demand 
rendering is far preferable because I'm expecting the load to be 
relatively low and disk space will be significantly reduced this way.

I am trying to use tilecache to generate mapnik tiles but have run into 
the issue described in my previous email.  It is probably something 
screwy with the way I've configured things but I've been unable to 
diagnose the problem.

The tilecache and mapnik software is all installed under a 
/home/tilecache directory tree.  I want to keep everything in one place 
if possible to make it easier to transfer between machines.  All 
directories and files are owned by root (will change this to a more 
limited user at some point) except the cache directory which is owned by 
apache.
* /home/tilecache/app contains the tilecache application
* /home/tilecache/mapnik contains the mapnik scripts from the osm svn
* /home/tilecache/cache contains the tilecache cache files
* /home/tilecache/world_boundaries contains the mapnik world boundary data

My tilecache.cfg file contains the following entry (I assume I should 
re-enable tms_type but have been playing with different settings):
[osm]
type=Mapnik
mapfile=/home/tilecache/mapnik/osm.xml
spherical_mercator=true
#tms_type=google

I have an apache configuration section that looks like this:

Alias /tilecache /home/tilecache/app
<Directory /home/tilecache/app>
    AddHandler python-program .py
    PythonHandler TileCache.Service
    PythonOption TileCacheConfig /home/tilecache/app/tilecache.cfg
    PythonPath "['/home/tilecache/app'] + sys.path"
    PythonDebug On
</Directory>

I create an OpenLayers layer with a code snippet like this:
layer = new OpenLayers.Layer.TMS( "OSM",
                    "tilecache.py/", {layername: 'osm', type: 'png'} );

You can test the site here:
http://www.bretth.com/tilecache/

Some tiles are working, some are failing.  Sometimes retrying fixes 
broken tiles, sometimes not.

I am running out of ideas.  If anybody has any suggestions or can help 
in any way please let me know.

Regards,
Brett

Brett Henderson wrote:
> Hi All,
>
> I'm trying to setup a server rendering mapnik tiles on demand using 
> tilecache.
>
> It seems to be working intermittently but most requests result in the 
> following response being returned to the browser when requesting new 
> tiles.
>
> An error occurred: failed mapping file: Cannot allocate memory
>  File "/home/tilecache/app/TileCache/Service.py", line 221, in 
> modPythonHandler
>    host )
>  File "/home/tilecache/app/TileCache/Service.py", line 205, in 
> dispatchRequest
>    return self.renderTile(tile, params.has_key('FORCE'))
>  File "/home/tilecache/app/TileCache/Service.py", line 138, in renderTile
>    data = layer.render(tile)
>  File "/home/tilecache/app/TileCache/Layer.py", line 411, in render
>    return self.renderTile(tile)
>  File "/home/tilecache/app/TileCache/Layers/Mapnik.py", line 38, in 
> renderTile
>    mapnik.load_map(m,self.mapfile)
>
> If I refresh the tile it eventually gets generated but sometimes takes 
> several tries.  The apache access_log shows the request as a 500.  The 
> apache error_log doesn't contain anything.  I have the PythonDebug 
> directive set to On.
>
> Any ideas what is causing this?
>
> Regards,
> Brett
>
>
>





More information about the talk mailing list