[GRASS-SVN] r69870 - grass-addons/grass7/raster/r.green/r.green.hydro/libhydro

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 22 09:06:00 PST 2016


Author: Giulia
Date: 2016-11-22 09:06:00 -0800 (Tue, 22 Nov 2016)
New Revision: 69870

Modified:
   grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py
Log:
r.green: add a maximum length of the water diversion

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py	2016-11-22 17:02:05 UTC (rev 69869)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py	2016-11-22 17:06:00 UTC (rev 69870)
@@ -93,7 +93,7 @@
     return line
 
 
-def splitline(line, point):
+def splitline(line, point, max_dist):
     """Split a line using a point. return two lines that start with the point.
 
                   point
@@ -107,7 +107,8 @@
     dist = line.distance(point)
     l0 = line.segment(0, dist.sldist)
     l0.reverse()
-    l1 = line.segment(dist.sldist, line.length())
+    max_l = min([max_dist, line.length()-dist.sldist])
+    l1 = line.segment(dist.sldist, dist.sldist+max_l)
     return l0, l1
 
 
@@ -211,7 +212,6 @@
                     levels.append(closest(itk.elevation, ndigits=ndigits,
                                           resolution=resolution))
             levels = sorted(set(levels))
-
             # generate the contur line that pass to the point
             r.contour(input='%s@%s' % (elev.name, elev.mapset),
                       output=contour, step=0, levels=levels, overwrite=True)
@@ -487,7 +487,8 @@
             return conduct, penstock
 
         def get_all_structs(contur, itk, res):
-            l0, l1 = splitline(contur, itk.point)
+            l0, l1 = splitline(contur, itk.point,
+                               3*itk.point.distance(res.point))
             # get structs
             c0, p0 = get_struct(l0, res.point)
             c1, p1 = get_struct(l1, res.point)



More information about the grass-commit mailing list