Browse Source

pygrass vector: Added to_wkt to Node class

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66028 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 9 years ago
parent
commit
329060ad89
2 changed files with 8 additions and 2 deletions
  1. 1 1
      lib/python/pygrass/vector/__init__.py
  2. 7 1
      lib/python/pygrass/vector/geometry.py

+ 1 - 1
lib/python/pygrass/vector/__init__.py

@@ -373,7 +373,7 @@ class VectorTopo(Vector):
 
         :param vtype: the name of type to query; the supported values are:
                       *areas*, *dblinks*, *faces*, *holes*, *islands*,
-                      *kernels*, *line_points*, *lines*, *nodes*,
+                      *kernels*, *line_points*, *lines*, *nodes*, *points*,
                       *update_lines*, *update_nodes*, *volumes*
         :type vtype: str
         :param idonly: variable to return only the id of features instead of

+ 7 - 1
lib/python/pygrass/vector/geometry.py

@@ -1133,7 +1133,7 @@ class Node(object):
 
            param v_id: The unique node id
            param c_mapinfo: A valid pointer to the mapinfo object
-           param **kwords: Ignored 
+           param **kwords: Ignored
         """
         self.id = v_id  # vector id
         self.c_mapinfo = c_mapinfo
@@ -1170,6 +1170,12 @@ class Node(object):
                                    ctypes.byref(y), ctypes.byref(z))
         return (x.value, y.value) if self.is2D else (x.value, y.value, z.value)
 
+    def to_wkt(self):
+        """Return a "well know text" (WKT) geometry string. ::
+        """
+        return "POINT(%s)" % ' '.join(['%f' % coord
+                                      for coord in self.coords()])
+
     def ilines(self, only_in=False, only_out=False):
         """Return a generator with all lines id connected to a node.
         The line id is negative if line is ending on the node and positive if