[GRASS-SVN] r68835 - grass-addons/grass7/vector/v.civil

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 1 18:39:06 PDT 2016


Author: jfc
Date: 2016-07-01 18:39:06 -0700 (Fri, 01 Jul 2016)
New Revision: 68835

Modified:
   grass-addons/grass7/vector/v.civil/road_base.py
   grass-addons/grass7/vector/v.civil/road_displ.py
   grass-addons/grass7/vector/v.civil/road_plant.py
   grass-addons/grass7/vector/v.civil/road_road.py
   grass-addons/grass7/vector/v.civil/road_tables.py
   grass-addons/grass7/vector/v.civil/road_terr.py
   grass-addons/grass7/vector/v.civil/road_topotools.py
   grass-addons/grass7/vector/v.civil/v.road.py
Log:
v.road changed to rewrite funtion

Modified: grass-addons/grass7/vector/v.civil/road_base.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_base.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_base.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -84,7 +84,7 @@
     c_y = 0
     for n_i in range(n_iter):
         c_x += (((-1) ** n_i * (2 * tau ** (2 * n_i + 1) /
-                 ((4 * n_i + 1) * math.factorial(2 * n_i)))) -
+                ((4 * n_i + 1) * math.factorial(2 * n_i)))) -
                 ((-1) ** n_i * (tau ** (2 * n_i + 1) /
                  math.factorial(2 * n_i + 1))))
 
@@ -188,8 +188,8 @@
 
 
 def write_objs(allrectas, radio):
+    """ Return
     """
-    """
     new2 = VectorTopo('AAAAA__' + str(int(radio)))
     # cols = [(u'cat',       'INTEGER PRIMARY KEY'),
     #        (u'elev',      'INTEGER')]
@@ -559,8 +559,8 @@
         return self.leng_accum + self.leng_obj
 
     def is_in(self, r_pnt):
+        """ Return
         """
-        """
         if self.leng_accum <= r_pnt.npk < self.leng_accum + self.leng_obj:
             return True
         else:

Modified: grass-addons/grass7/vector/v.civil/road_displ.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_displ.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_displ.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -22,8 +22,8 @@
 
 
 def write_objs(allrectas, radio):
+    """ R
     """
-    """
     new2 = VectorTopo('AACC__' + str(int(radio)))
     # cols = [(u'cat',       'INTEGER PRIMARY KEY'),
     #        (u'elev',      'INTEGER')]
@@ -418,7 +418,7 @@
         else:
             return 'right'
 
-    def _find_superelev(self, index, r_pnt, elev, dist_displ):
+    def _find_superelev(self, r_pnt, elev, dist_displ):
         """Return
         """
         for line in self.plant.superelev_lim:
@@ -429,7 +429,7 @@
             dist1, dist2, bom1, peralte, bom2, radio = line
             pks_1 = dist1 + dist2
 
-            if (pks_1[0] < r_pnt.npk < pks_1[-1]):
+            if pks_1[0] < r_pnt.npk < pks_1[-1]:
                 break
 
 #        pend_1 = [-bom1, 0, bom1, peralte, peralte, bom2, 0, -bom2]
@@ -484,13 +484,13 @@
 #                                        dist_displ)
 #
 #        else:
-        elev = self.elev_lim[index] + ((r_pnt.npk - self.list_lim[index]) *
-                                       (self.elev_lim[index + 1] -
-                                       self.elev_lim[index])) / \
-                                      (self.list_lim[index + 1] -
-                                       self.list_lim[index])
+        elev = self.elev_lim[index] + \
+            ((r_pnt.npk - self.list_lim[index]) *
+             (self.elev_lim[index + 1] - self.elev_lim[index])) / \
+            (self.list_lim[index + 1] - self.list_lim[index])
+
         if self.plant.bombeo:
-            elev = self._find_superelev(index, r_pnt, elev, dist_displ)
+            elev = self._find_superelev(r_pnt, elev, dist_displ)
 
         return elev
 

Modified: grass-addons/grass7/vector/v.civil/road_plant.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_plant.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_plant.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -242,7 +242,7 @@
             if ali is not None:
 
                 list_attrs.append([ali.get_leng_accum2(),
-                           r_pnt.get_azi(), r_pnt.p_type, 'L=0'])
+                                   r_pnt.get_azi(), r_pnt.p_type, 'L=0'])
                 break
         return list_obj, list_attrs
 
@@ -605,7 +605,7 @@
         else:
             raise ValueError("Error: For change the radio sing a straight must be \
                              between the radios")
-            return None, None, None
+#            return [None, None, None]
 
         pnt_t1 = pnt_center.project(abs(dat1['radio'] + out_local['y_o']),
                                     azi_in - out_local['tau'])
@@ -655,7 +655,7 @@
         else:
             raise ValueError("Error: For change the radio sing a straight \
                              must be between the radios")
-            return None, None, None
+#            return (None, None, None)
 
         pnt_t1 = pnt_center.project(abs(dat1['radio'] + out_local['y_o']),
                                     azi_in + out_local['tau'])
@@ -669,8 +669,8 @@
         pnt_c2 = pnt_t2.project(abs(dat2['radio'] + in_local['y_o']),
                                 azi_in + out_local['tau'] + 2 * g90)
 
-        pnt_ra2 = pnt_c2.project(abs(dat2['radio']), azi_in + out_local['tau']
-                                 - in_local['tau'] + alpha)
+        pnt_ra2 = pnt_c2.project(abs(dat2['radio']), azi_in +
+                                 out_local['tau'] - in_local['tau'] + alpha)
 
         if dat1['a_out'] != 0:
             cloth = Base.Clothoid(dat1['a_out'], dat1['radio'],
@@ -778,7 +778,7 @@
             list_pnt.append(pnt)
         return list_pnt
 
-    @time_func
+    # @time_func
     def set_roadline(self, start, end, intr, intc):
         """ Return
         """
@@ -791,8 +791,8 @@
     def add_pks(self, list_pks):
         """ Return
         """
-        for pk in list_pks:
-            self.roadline.insert(self.get_roadpoint(pk))
+        for npk in list_pks:
+            self.roadline.insert(self.get_roadpoint(npk))
 
 
 if __name__ == '__main__':

Modified: grass-addons/grass7/vector/v.civil/road_road.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_road.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_road.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -77,7 +77,7 @@
     def __repr__(self):
         return str(self.mapa)
 
-    @time_func
+    # @time_func
     def plant_generate(self, table_to_plant=False, bombeo=0):
         """Set plant.
         """
@@ -111,7 +111,7 @@
         objs, values = self.plant.get_curves_centers()
         self.rtab.new_map(map_out, 3, '__Plant_C', objs, values)
 
-    @time_func
+    # @time_func
     def elev_generate(self):
         """ Return
         """
@@ -130,7 +130,7 @@
         objs, values = self.vert.get_charact_pnts()
         self.rtab.new_map(map_out, 2, '__Vertical_PC', objs, values)
 
-    @time_func
+    # @time_func
     def displ_generate(self, tab_subname=''):
         """ Return
         """
@@ -159,13 +159,13 @@
         objs, values = self.displ.get_areas(opts)
         self.rtab.new_map(map_out, 1, tab_sufix, objs, values, tab_subname)
 
-    @time_func
+    # @time_func
     def terr_generate(self, dem_map):
         """ Return
         """
         self.terr = Terr.Terrain(dem_map)
 
-    @time_func
+    # @time_func
     def trans_generate(self):
         """ Return
         """
@@ -198,7 +198,7 @@
                                                       self.terr)
         self.rtab.new_map(map_out, 3, '__Trans_PT', objs, values)
 
-    @time_func
+    # @time_func
     def taludes_generate(self):
         """ Return
         """
@@ -221,7 +221,7 @@
         objs, values = self.taludes.get_areas(self.displ)
         self.rtab.new_map(map_out, 1, '__Slopes_Areas', objs, values)
 
-    @time_func
+    # @time_func
     def long_profile_generate(self, options, scale, offset):
         """Return
         """
@@ -248,7 +248,7 @@
         objs, vals = self.long_prof.get_axes_marks(self.plant.roadline)
         self.rtab.new_map(map_out, 4, '__LProfile_Ticks', objs, vals)
 
-    @time_func
+    # @time_func
     def trans_profiles_generate(self, options1, options2, scale, offset):
         """Return
         """
@@ -277,7 +277,7 @@
         objs, vals = self.trans_prof.get_axes_marks()
         self.rtab.new_map(map_out, 4, '__TProfile_Ticks', objs, vals)
 
-    @time_func
+    # @time_func
     def marks_generate(self, tab_subname=''):
         """ Return
         """

Modified: grass-addons/grass7/vector/v.civil/road_tables.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_tables.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_tables.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -337,7 +337,7 @@
     def __len__(self):
         return len(self.rows)
 
-#    @time_func
+    # @time_func
     def _init_table(self):
         """Return
         """
@@ -460,7 +460,7 @@
         table.conn.commit()
         self.polygon.close()
 
-#    @time_func
+    # @time_func
     def rewrite_obj(self, obj, attrs):
         """Return
         """
@@ -472,8 +472,8 @@
             type_obj = 'lines'
 
         obj_org = self.polygon.cat(attrs[0], type_obj, self.layer)[0]
-
-        self.polygon.rewrite(obj_org, obj, attrs[1:])
+        obj_org.x, obj_org.y, obj_org.z = obj.x, obj.y, obj.z
+        self.polygon.rewrite(obj_org, attrs[0], attrs[1:])
         self.polygon.table.conn.commit()
         self.polygon.close()
 
@@ -777,7 +777,7 @@
                 names.append([self.road_name, tab_name, ''])
         return names
 
-    @time_func
+    # @time_func
     def new_map(self, mapa, layer, tab_sufix, objs, values, tab_subname=''):
         """Return
         """
@@ -808,7 +808,7 @@
         map_out.table.conn.commit()
         map_out.close()
 
-    @time_func
+    # @time_func
     def gen_tables(self):
         """Return None
         """
@@ -821,7 +821,7 @@
                 RoadTable(self.polygon, self.polyline, i + 1, name[0] +
                           name[1] + name[2], name[1])
 
-    @time_func
+    # @time_func
     def update_tables(self):
         """Return None
         """
@@ -831,7 +831,7 @@
             elif name != 'first':
                 tab.update_table()
 
-    @time_func
+    # @time_func
     def update_tables_pnts(self, plant):
         """Return None
         """

Modified: grass-addons/grass7/vector/v.civil/road_terr.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_terr.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_terr.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -13,10 +13,11 @@
 
 from grass.pygrass.vector.geometry import Point
 from grass.pygrass.gis.region import Region
-from grass.pygrass.vector.geometry import Line
+# from grass.pygrass.vector.geometry import Line
 from grass.pygrass.vector.geometry import Boundary
-from grass.pygrass.vector.geometry import Area
+# from grass.pygrass.vector.geometry import Area
 
+
 def get_rgb(type_terr):
     """ Return
     """

Modified: grass-addons/grass7/vector/v.civil/road_topotools.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_topotools.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/road_topotools.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -328,7 +328,7 @@
                           output=self.namecurved,
                           overwrite=True, quiet=True)
 
-    @time_func
+    # @time_func
     def get_tin_maxmin(self, map_info):
         """ Return
         """
@@ -352,7 +352,7 @@
                 max_z = max_ptos
         return [int(math.floor(min_z)), int(math.ceil(max_z))]
 
-    @time_func
+    # @time_func
     def get_rectas(self, map_info):
         """ Return
         """

Modified: grass-addons/grass7/vector/v.civil/v.road.py
===================================================================
--- grass-addons/grass7/vector/v.civil/v.road.py	2016-07-02 00:50:57 UTC (rev 68834)
+++ grass-addons/grass7/vector/v.civil/v.road.py	2016-07-02 01:39:06 UTC (rev 68835)
@@ -521,11 +521,15 @@
 import os
 import sys
 
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'v.road'))
+#sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'v.road'))
+import grass.script as grass
+from grass.pygrass.utils import get_lib_path
 
-# import math
-# import road as Road
-import grass.script as grass
+path = get_lib_path(modname='v.road')
+if path is None:
+    grass.fatal("Not able to find the modis library directory.")
+sys.path.append(path)
+
 import road_road as Road
 import road_crosstools as Tools2
 import road_topotools as Topotools



More information about the grass-commit mailing list