Skip to content

Commit 484f94c

Browse files
committedOct 6, 2015
[GRASS] qgis.v.upgrade.py - upgrade vectors from 6
1 parent a213b03 commit 484f94c

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed
 

‎src/plugins/grass/modules/default.qgc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
<grass name="db.in.ogr"/>
7171
</section>
7272
</section>
73+
<section label="Upgrade from from GRASS 6" version_min="7">
74+
<grass name="qgis.v.upgrade"/>
75+
</section>
7376
<section label="Export from GRASS">
7477
<section label="Export raster from GRASS">
7578
<grass name="r.out.gdal.gtiff"/>
2.86 KB
Loading
2.86 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
3+
4+
<qgisgrassmodule label="Upgrade all vectors from GRASS 6 to GRASS 7" module="qgis.v.upgrade.py">
5+
</qgisgrassmodule>

‎src/plugins/grass/qgsgrassmoduleoptions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
298298
confDomNode = confDomNode.nextSibling();
299299
}
300300

301+
if ( mParams.size() == 0 )
302+
{
303+
QLabel *label = new QLabel(this);
304+
label->setText( tr("This module has no options") );
305+
mypSimpleLayout->addWidget( label );
306+
}
307+
301308
if ( mypAdvancedLayout->count() == 0 )
302309
{
303310
mypAdvancedPushButtonFrame->hide();
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
***************************************************************************
6+
qgis.v.upgrade.py
7+
---------------------
8+
Date : October 2015
9+
Copyright : (C) 2015 by Radim Blazek
10+
Email : radim.blazek@gmail.com
11+
***************************************************************************
12+
* *
13+
* This program is free software; you can redistribute it and/or modify *
14+
* it under the terms of the GNU General Public License as published by *
15+
* the Free Software Foundation; either version 2 of the License, or *
16+
* (at your option) any later version. *
17+
* *
18+
***************************************************************************
19+
"""
20+
21+
__author__ = 'Radim Blazek'
22+
__date__ = 'October 2015'
23+
__copyright__ = '(C) 2015 by Radim Blazek'
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
__revision__ = '$Format:%H$'
26+
27+
28+
############################################################################
29+
#
30+
# MODULE: qgis.v.upgrade.py
31+
# AUTHOR(S): Radim Blazek
32+
#
33+
# PURPOSE: Upgrade all vectors from GRASS 6 to GRASS 7
34+
#
35+
# COPYRIGHT: (C) 2015 by Radim Blazek
36+
#
37+
# This program is free software under the GNU General Public
38+
# License (>=v2). Read the file COPYING that comes with GRASS
39+
# for details.
40+
#
41+
#############################################################################
42+
43+
#%Module
44+
#% description: Upgrade all vectors from GRASS 6 to GRASS 7
45+
#% keywords: vector, upgrade
46+
#%End
47+
48+
import os
49+
try:
50+
from grass.script import core as grass
51+
except ImportError:
52+
import grass
53+
except:
54+
raise Exception("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4")
55+
56+
def main():
57+
# see https://grasswiki.osgeo.org/wiki/Convert_all_GRASS_6_vector_maps_to_GRASS_7
58+
grass.message('Building topology')
59+
if grass.run_command('v.build.all') != 0:
60+
grass.warning('Cannot build topology')
61+
62+
grass.message('Creating new DB connection')
63+
if grass.run_command('db.connect', flags='d') != 0:
64+
grass.warning('Cannot create new DB connection')
65+
return
66+
67+
grass.message('Transfering tables to the new DB')
68+
if grass.run_command('v.db.reconnect.all', flags='cd') != 0:
69+
grass.warning('Cannot transfer tables')
70+
71+
if __name__ == "__main__":
72+
options, flags = grass.parser()
73+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.