コード例 #1
0
def test():
    import shutil

    from core.layerlist import LayerList, Layer
    from animation.data import AnimLayer
    from animation.utils import layerListToCmdsMatrix
    import grass.temporal as tgis
    tgis.init()

    layerList = LayerList()
    layer = AnimLayer()
    layer.mapType = 'strds'
    layer.name = 'JR'
    layer.cmd = ['d.rast', 'map=elev_2007_1m']
    layerList.AddLayer(layer)

    layer = Layer()
    layer.mapType = 'vector'
    layer.name = 'buildings_2009_approx'
    layer.cmd = ['d.vect', 'map=buildings_2009_approx', 'color=grey']
    layer.opacity = 50
    layerList.AddLayer(layer)

    bPool = BitmapPool()
    mapFilesPool = MapFilesPool()

    tempDir = '/tmp/test'
    if os.path.exists(tempDir):
        shutil.rmtree(tempDir)
    os.mkdir(tempDir)
    # comment this line to keep the directory after prgm ends
    #    cleanUp = CleanUp(tempDir)
    #    import atexit
    #    atexit.register(cleanUp)

    prov = BitmapProvider(bPool,
                          mapFilesPool,
                          tempDir,
                          imageWidth=640,
                          imageHeight=480)
    prov.renderingStarted.connect(lambda count: sys.stdout.write(
        "Total number of maps: {c}\n".format(c=count)))
    prov.renderingContinues.connect(lambda current, text: sys.stdout.write(
        "Current number: {c}\n".format(c=current)))
    prov.compositionStarted.connect(lambda count: sys.stdout.write(
        "Composition: total number of maps: {c}\n".format(c=count)))
    prov.compositionContinues.connect(lambda current, text: sys.stdout.write(
        "Composition: Current number: {c}\n".format(c=current)))
    prov.mapsLoaded.connect(
        lambda: sys.stdout.write("Maps loading finished\n"))
    cmdMatrix = layerListToCmdsMatrix(layerList)
    prov.SetCmds(cmdMatrix, [l.opacity for l in layerList])
    app = wx.App()

    prov.Load(bgcolor=(13, 156, 230), nprocs=4)

    for key in bPool.keys():
        if key is not None:
            bPool[key].SaveFile(os.path.join(tempDir, key + '.png'),
                                wx.BITMAP_TYPE_PNG)
コード例 #2
0
ファイル: data.py プロジェクト: caomw/grass
 def __init__(self):
     Layer.__init__(self)
     self._mapTypes.extend(['strds', 'stvds', 'str3ds'])
     self._maps = []
コード例 #3
0
ファイル: data.py プロジェクト: pesekon2/grass
 def __init__(self):
     Layer.__init__(self)
     self._mapTypes.extend(['strds', 'stvds', 'str3ds'])
     self._maps = []
コード例 #4
0
 def __init__(self):
     Layer.__init__(self)
     self._mapTypes.extend(["strds", "stvds", "str3ds"])
     self._maps = []