Ejemplo n.º 1
0
def map_loader():
    while not map_loader_stop:
        filename = map_queue_in.get()
        if map_lock.acquire():
            map_queue_proc[filename] = True
            del map_queue_wait[map_queue_wait.index(filename)]
            map_lock.release()

        # get texture
        x1, y1, zoom, texx, texy, provider = filename.rsplit('.', 1)[0].split('=')
        x1, y1, zoom = map(float, (x1, y1, zoom))
        texx, texy = map(int, (texx, texy))
        provider = ModestMaps.builtinProviders[provider]()
        dim = ModestMaps.Core.Point(texx, texy)
        coord = ModestMaps.Core.Coordinate(x1, y1, zoom)
        mapCoord, mapOffset = ModestMaps.calculateMapCenter(provider, coord)
        mmap = ModestMaps.Map(provider, dim, mapCoord, mapOffset)
        image = mmap.draw(nocenter=True)

        # convert to gl texture (from pyglet)
        if image.mode not in ('RGB', 'RGBA'):
            raise Exception('Unsupported mode "%s"' % image.mode)

        if map_lock.acquire():
            map_queue_out[filename] = image
            try:
                del map_queue_proc[filename]
            except:
                pass
            map_lock.release()
        else:
            print 'FAILED'