Skip to content

Commit

Permalink
after first review
Browse files Browse the repository at this point in the history
  • Loading branch information
ghtmtt committed May 15, 2019
1 parent b3a8d8f commit 9b3b61a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions python/plugins/processing/algs/qgis/Climb.py
Expand Up @@ -67,7 +67,7 @@ def name(self):
return 'climbalongline'

def displayName(self):
return self.tr("Climb Along Line")
return self.tr('Climb Along Line')

def group(self):
return self.tr('Vector analysis')
Expand Down Expand Up @@ -145,15 +145,15 @@ def processAlgorithm(self, parameters, context, feedback):

# Skip fields with names that are equal to the generated ones
for field in source.fields():
if str(field.name()) == str(self.CLIMBATTRIBUTE):
feedback.pushInfo("Warning: existing " +
if field.name() == self.CLIMBATTRIBUTE:
feedback.pushWarning(self.tr(
str(self.CLIMBATTRIBUTE) +
" attribute found and removed")
' attribute found and removed'))
climbindex = fieldnumber
elif str(field.name()) == str(self.DESCENTATTRIBUTE):
feedback.pushInfo("Warning: existing " +
elif field.name() == self.DESCENTATTRIBUTE:
feedback.pushWarning(self.tr(
str(self.DESCENTATTRIBUTE) +
" attribute found and removed")
' attribute found and removed'))
descentindex = fieldnumber
else:
thefields.append(field)
Expand All @@ -180,6 +180,8 @@ def processAlgorithm(self, parameters, context, feedback):
minelevation = float('Infinity')
maxelevation = float('-Infinity')

no_z_nodes = []

for current, feature in enumerate(features):
# Stop the algorithm if cancelled
if feedback.isCanceled():
Expand All @@ -189,14 +191,15 @@ def processAlgorithm(self, parameters, context, feedback):
minelev = float('Infinity')
maxelev = float('-Infinity')
# In case of multigeometries we need to do the parts
for part in feature.geometry().constParts():
parts = feature.geometry().constParts()
for part in parts:
# Calculate the climb
first = True
zval = 0
for v in part.vertices():
for idx, v in enumerate(part.vertices()):
zval = v.z()
if math.isnan(zval):
feedback.pushInfo("Missing Z value")
no_z_nodes.append(idx)
continue
if first:
prevz = zval
Expand Down Expand Up @@ -239,6 +242,8 @@ def processAlgorithm(self, parameters, context, feedback):
# Update the progress bar
if fcount > 0:
feedback.setProgress(int(100 * current / fcount))

feedback.pushInfo(self.tr('Following nodes miss Z value ') + str(no_z_nodes))
# Return the results
return {self.OUTPUT: dest_id, self.TOTALCLIMB: totalclimb,
self.TOTALDESCENT: totaldescent,
Expand Down

0 comments on commit 9b3b61a

Please sign in to comment.