Skip to content

Commit

Permalink
[GRASS] qgis.v.upgrade.py - upgrade vectors from 6
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Oct 6, 2015
1 parent a213b03 commit 484f94c
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/plugins/grass/modules/default.qgc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<grass name="db.in.ogr"/>
</section>
</section>
<section label="Upgrade from from GRASS 6" version_min="7">
<grass name="qgis.v.upgrade"/>
</section>
<section label="Export from GRASS">
<section label="Export raster from GRASS">
<grass name="r.out.gdal.gtiff"/>
Expand Down
Binary file added src/plugins/grass/modules/qgis.v.upgrade.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/plugins/grass/modules/qgis.v.upgrade.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/plugins/grass/modules/qgis.v.upgrade.qgm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">

<qgisgrassmodule label="Upgrade all vectors from GRASS 6 to GRASS 7" module="qgis.v.upgrade.py">
</qgisgrassmodule>
7 changes: 7 additions & 0 deletions src/plugins/grass/qgsgrassmoduleoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
confDomNode = confDomNode.nextSibling();
}

if ( mParams.size() == 0 )
{
QLabel *label = new QLabel(this);
label->setText( tr("This module has no options") );
mypSimpleLayout->addWidget( label );
}

if ( mypAdvancedLayout->count() == 0 )
{
mypAdvancedPushButtonFrame->hide();
Expand Down
73 changes: 73 additions & 0 deletions src/plugins/grass/scripts/qgis.v.upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
***************************************************************************
qgis.v.upgrade.py
---------------------
Date : October 2015
Copyright : (C) 2015 by Radim Blazek
Email : radim.blazek@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Radim Blazek'
__date__ = 'October 2015'
__copyright__ = '(C) 2015 by Radim Blazek'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


############################################################################
#
# MODULE: qgis.v.upgrade.py
# AUTHOR(S): Radim Blazek
#
# PURPOSE: Upgrade all vectors from GRASS 6 to GRASS 7
#
# COPYRIGHT: (C) 2015 by Radim Blazek
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
#############################################################################

#%Module
#% description: Upgrade all vectors from GRASS 6 to GRASS 7
#% keywords: vector, upgrade
#%End

import os
try:
from grass.script import core as grass
except ImportError:
import grass
except:
raise Exception("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4")

def main():
# see https://grasswiki.osgeo.org/wiki/Convert_all_GRASS_6_vector_maps_to_GRASS_7
grass.message('Building topology')
if grass.run_command('v.build.all') != 0:
grass.warning('Cannot build topology')

grass.message('Creating new DB connection')
if grass.run_command('db.connect', flags='d') != 0:
grass.warning('Cannot create new DB connection')
return

grass.message('Transfering tables to the new DB')
if grass.run_command('v.db.reconnect.all', flags='cd') != 0:
grass.warning('Cannot transfer tables')

if __name__ == "__main__":
options, flags = grass.parser()
main()

0 comments on commit 484f94c

Please sign in to comment.