On 06/15/2011 06:45 PM, Dane Springmeyer wrote:
>>>>
>>>> I just noticed a strange behaviour when trying to render 8-Bit
>>>> PNGs: Mapnik seems to stop drawing features when it runs out of
>>>> colors (or at least that is my interpretation so far).
>>
>> In the end it turned out that it this probably wasn't related to
>> PNG rendering at all but to some rather strange multithreading/IO
>> issues when generating tiles from shapefiles on my machine.
>
> Yep, it looks like during rendering the map extent was changed. This
> indicates that the same map was likely being shared between two
> different threads. This should not be happening with
> generate_tiles.py. Were you maybe using TileCache or TileStache? Both
> of these applications cache a single map instance so they need to be
> deployed within apache in multiprocess mode. Let me know if you need
> more details on this.
Ah, I see! I have actually hacked generate_tiles.py to use a map
instance I pass in from my own python scripts which configure the styles
and layers (instead of the XML loading used in the original script -
indeed I was wondering why multiple map instances were used).
So with your hint I was able to modify the script to (shallow) clone the
map for all threads but the first:
def render_tiles(bbox, mmap, tile_dir, ... ):
...
import copy
for i in range(num_threads):
if i > 0:
print "Cloning map for thread #%i" % (i+1)
mmap = copy.copy(mmap)
renderer = RenderThread(tile_dir, mmap, queue, ... )
...
works like a charm! Thanks for saving me some time by utilizing both of
my cores again :)
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users