2
############################################################################
5
# AUTHOR(S): Anna Kratochvilova
6
# PURPOSE: Tool for animating a series of GRASS raster and vector maps
7
# or a space time raster dataset
8
# COPYRIGHT: (C) 2012 by Anna Kratochvilova, and the GRASS Development Team
10
# This program is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 2 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
20
############################################################################
23
#% description: Tool for animating a series of raster and vector maps or a space time raster or vector dataset.
29
#%option G_OPT_R_INPUTS
31
#% description: Raster maps to animate
35
#%option G_OPT_V_INPUTS
37
#% label: Vector maps to animate
41
#%option G_OPT_STRDS_INPUT
43
#% description: Space time raster dataset to animate
47
#%option G_OPT_STVDS_INPUT
49
#% description: Space time vector dataset to animate
58
import grass.script as grass
59
import grass.temporal as tgis
61
from core.globalvar import CheckWxVersion
62
from core.utils import _, GuiModuleMain
63
from core.giface import StandaloneGrassInterface
64
from core.layerlist import LayerList
65
from animation.frame import AnimationFrame, MAX_COUNT
66
from animation.data import AnimLayer
70
rast = options['raster']
71
vect = options['vector']
72
strds = options['strds']
73
stvds = options['stvds']
88
grass.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") %
89
("raster", "vector", "strds", "stvds"))
92
# We need to initialize the temporal framework in case
93
# a space time dataset was set on the command line so that
94
# the AnimLayer() class works correctly
97
layerList = LayerList()
100
layer.mapType = 'raster'
102
layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
103
layerList.AddLayer(layer)
106
layer.mapType = 'vector'
108
layer.cmd = ['d.vect', 'map={name=}'.format(name=vect.split(',')[0])]
109
layerList.AddLayer(layer)
112
layer.mapType = 'strds'
114
layer.cmd = ['d.rast', 'map=']
115
layerList.AddLayer(layer)
118
layer.mapType = 'stvds'
120
layer.cmd = ['d.vect', 'map=']
121
layerList.AddLayer(layer)
124
if not CheckWxVersion([2, 9]):
125
wx.InitAllImageHandlers()
127
frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
128
frame.CentreOnScreen()
130
if len(layerList) >= 1:
131
# CallAfter added since it was crashing with wxPython 3 gtk
132
wx.CallAfter(frame.SetAnimations, [layerList] + [None] * (MAX_COUNT - 1))
135
if __name__ == '__main__':
136
options, flags = grass.parser()