forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv.build.all.py
executable file
·59 lines (49 loc) · 1.56 KB
/
v.build.all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
############################################################################
#
# MODULE: v.build.all
# AUTHOR(S): Glynn Clements, Radim Blazek
# PURPOSE: Build all vectors in current mapset
# COPYRIGHT: (C) 2004, 2008-2009 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
#############################################################################
# %module
# % description: Rebuilds topology on all vector maps in the current mapset.
# % keyword: vector
# % keyword: topology
# %end
import sys
from grass.script import core as grass
from grass.exceptions import CalledModuleError
def main():
env = grass.gisenv()
mapset = env["MAPSET"]
ret = 0
vectors = grass.list_grouped("vect")[mapset]
num_vectors = len(vectors)
if grass.verbosity() < 2:
quiet = True
else:
quiet = False
i = 1
for vect in vectors:
map = "%s@%s" % (vect, mapset)
grass.message(
_("%s\nBuilding topology for vector map <%s> (%d of %d)...\n%s")
% ("-" * 80, map, i, num_vectors, "-" * 80)
)
grass.verbose(_("v.build map=%s") % map)
try:
grass.run_command("v.build", map=map, quiet=quiet)
except CalledModuleError:
grass.error(_("Building topology for vector map <%s> failed") % map)
ret = 1
i += 1
return ret
if __name__ == "__main__":
options, flags = grass.parser()
sys.exit(main())