Skip to content

Commit e142401

Browse files
committed
[processing] added grass7 files (forgot to add them on refactoring)
1 parent 5bb522e commit e142401

File tree

180 files changed

+3273
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+3273
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
r.cost
2+
r.cost.full - Creates a raster layer of cumulative cost of moving across a raster layer whose cell values represent cost.
3+
Raster (r.*)
4+
ParameterRaster|input|Unit cost layer|False
5+
ParameterVector|start_points|Start points|0|False
6+
ParameterBoolean|-k|Use the 'Knight's move'; slower, but more accurate|False
7+
ParameterBoolean|-n|Keep null values in output raster layer|False
8+
OutputRaster|output|Cumulative cost
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FILE(GLOB PY_FILES *.py)
2+
FILE(GLOB OTHER_FILES grass7.txt)
3+
FILE(GLOB DESCR_FILES description/*.txt)
4+
5+
ADD_SUBDIRECTORY(ext)
6+
7+
PLUGIN_INSTALL(processing grass7 ${PY_FILES} ${OTHER_FILES})
8+
PLUGIN_INSTALL(processing grass7/description ${DESCR_FILES})

python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 544 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
Grass7AlgorithmProvider.py
6+
---------------------
7+
Date : April 2014
8+
Copyright : (C) 2014 by Victor Olaya
9+
Email : volayaf at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
21+
22+
__author__ = 'Victor Olaya'
23+
__date__ = 'April 2014'
24+
__copyright__ = '(C) 2014, Victor Olaya'
25+
26+
# This will get replaced with a git SHA1 when you do a git archive
27+
28+
__revision__ = '$Format:%H$'
29+
30+
import os
31+
from PyQt4.QtCore import *
32+
from PyQt4.QtGui import *
33+
from processing.core.ProcessingConfig import ProcessingConfig, Setting
34+
from processing.core.AlgorithmProvider import AlgorithmProvider
35+
from processing.core.ProcessingLog import ProcessingLog
36+
from Grass7Utils import Grass7Utils
37+
from Grass7Algorithm import Grass7Algorithm
38+
from processing.tools.system import *
39+
from nviz7 import nviz7
40+
41+
class Grass7AlgorithmProvider(AlgorithmProvider):
42+
43+
def __init__(self):
44+
AlgorithmProvider.__init__(self)
45+
self.createAlgsList() # Preloading algorithms to speed up
46+
47+
def initializeSettings(self):
48+
AlgorithmProvider.initializeSettings(self)
49+
if isWindows() or isMac():
50+
ProcessingConfig.addSetting(Setting(self.getDescription(),
51+
Grass7Utils.GRASS_FOLDER, 'GRASS7 folder',
52+
Grass7Utils.grassPath()))
53+
ProcessingConfig.addSetting(Setting(self.getDescription(),
54+
Grass7Utils.GRASS_WIN_SHELL, 'Msys folder',
55+
Grass7Utils.grassWinShell()))
56+
ProcessingConfig.addSetting(Setting(self.getDescription(),
57+
Grass7Utils.GRASS_LOG_COMMANDS,
58+
'Log execution commands', False))
59+
ProcessingConfig.addSetting(Setting(self.getDescription(),
60+
Grass7Utils.GRASS_LOG_CONSOLE,
61+
'Log console output', False))
62+
63+
def unload(self):
64+
AlgorithmProvider.unload(self)
65+
if isWindows() or isMac():
66+
ProcessingConfig.removeSetting(Grass7Utils.GRASS_FOLDER)
67+
ProcessingConfig.removeSetting(Grass7Utils.GRASS_WIN_SHELL)
68+
ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_COMMANDS)
69+
ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_CONSOLE)
70+
71+
def createAlgsList(self):
72+
self.preloadedAlgs = []
73+
folder = Grass7Utils.grassDescriptionPath()
74+
for descriptionFile in os.listdir(folder):
75+
if descriptionFile.endswith('txt'):
76+
try:
77+
alg = Grass7Algorithm(os.path.join(folder, descriptionFile))
78+
if alg.name.strip() != '':
79+
self.preloadedAlgs.append(alg)
80+
else:
81+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
82+
'Could not open GRASS GIS 7 algorithm: '
83+
+ descriptionFile)
84+
except Exception, e:
85+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
86+
'Could not open GRASS GIS 7 algorithm: '
87+
+ descriptionFile)
88+
self.preloadedAlgs.append(nviz7())
89+
90+
def _loadAlgorithms(self):
91+
self.algs = self.preloadedAlgs
92+
93+
def getDescription(self):
94+
return 'GRASS GIS 7 commands'
95+
96+
def getName(self):
97+
return 'grass70'
98+
99+
def getIcon(self):
100+
return QIcon(os.path.dirname(__file__) + '/../images/grass.png')
101+
102+
def getSupportedOutputVectorLayerExtensions(self):
103+
return ['shp']
104+
105+
def getSupportedOutputRasterLayerExtensions(self):
106+
return ['tif']
107+

0 commit comments

Comments
 (0)