Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into autobuild
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Jul 15, 2016
2 parents 31e829c + c0e1450 commit 03a6e06
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
4 changes: 3 additions & 1 deletion crayfish/algs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .cf_export_grid import ExportMeshGridAlgorithm
from .cf_export_nodes import ExportMeshNodesAlgorithm
from .cf_render import RenderMeshBedElevationAlgorithm
from .cf_export_contours import ExportContoursAlgorithm

class CrayfishProcessingProvider(AlgorithmProvider):

Expand All @@ -47,7 +48,8 @@ def __init__(self):
ExportMeshElemsAlgorithm(),
ExportMeshGridAlgorithm(),
ExportMeshNodesAlgorithm(),
RenderMeshBedElevationAlgorithm()]
RenderMeshBedElevationAlgorithm(),
ExportContoursAlgorithm()]

for alg in self.alglist:
alg.provider = self
Expand Down
41 changes: 41 additions & 0 deletions crayfish/algs/cf_export_contours.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from .cf_alg import CfGeoAlgorithm
from processing.core.outputs import OutputVector
from processing.core.parameters import ParameterFile, ParameterNumber, ParameterCrs, ParameterBoolean

class ExportContoursAlgorithm(CfGeoAlgorithm):
IN_CF_MESH = 'CF_MESH'
IN_CF_MUPP = 'CF_MUPP'
IN_CF_CRS = 'CF_CRS'
IN_CF_INTERVAL = 'CF_INT'
IN_CF_LINES = 'CF_USE_LINES'
OUT_CF_SHP = "CF_SHP"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Export contours')
self.group, self.i18n_group = self.trAlgorithm('Mesh and Bed Elevation')

self.addParameter(ParameterFile(self.IN_CF_MESH, self.tr('Crayfish Mesh'), optional=False))
self.addParameter(ParameterNumber(self.IN_CF_MUPP, self.tr('Grid resolution'), default=5))
self.addParameter(ParameterNumber(self.IN_CF_INTERVAL, self.tr('Contours interval'), default=1))
self.addParameter(ParameterCrs(self.IN_CF_CRS, self.tr('CRS')))
self.addParameter(ParameterBoolean(self.IN_CF_LINES, self.tr('Use lines'), default=True))
self.addOutput(OutputVector(self.OUT_CF_SHP, self.tr('Contours shapefile')))

def processAlgorithm(self, progress):
m = self.get_mesh(self.IN_CF_MESH)
o = self.get_bed_elevation(m)

outf = self.getOutputValue(self.OUT_CF_SHP)
mupp = self.getParameterValue(self.IN_CF_MUPP)
use_lines = self.getParameterValue(self.IN_CF_LINES)
interval = self.getParameterValue(self.IN_CF_INTERVAL)
crs = self.getParameterValue(self.IN_CF_CRS)

res = o.export_contours(mupp,
interval,
outf,
crs,
use_lines,
None)
if not res:
raise CrayfishProccessingAlgorithmError("Unable to export contours")
21 changes: 0 additions & 21 deletions tools/cf_export_contours.py

This file was deleted.

0 comments on commit 03a6e06

Please sign in to comment.