[GRASS-SVN] r66002 - grass/trunk/lib/python/pygrass/vector

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 24 05:27:56 PDT 2015


Author: huhabla
Date: 2015-08-24 05:27:56 -0700 (Mon, 24 Aug 2015)
New Revision: 66002

Modified:
   grass/trunk/lib/python/pygrass/vector/geometry.py
Log:
pygrass vector: Added wkt generation for Areas


Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py	2015-08-24 10:13:58 UTC (rev 66001)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py	2015-08-24 12:27:56 UTC (rev 66002)
@@ -1619,6 +1619,20 @@
             return ilist
         return [Boundary(v_id=abs(v_id), c_mapinfo=self.c_mapinfo) for v_id in ilst]
 
+
+    def get_wkt(self):
+        """Return a Well Known Text string of the Area. ::
+
+            For now the outer ring is returned
+
+            TODO: Implement inner rings detected from isles
+        """
+        line = self.get_points()
+
+        return "Polygon((%s))" % ', '.join([
+               ' '.join(['%f' % coord for coord in pnt])
+               for pnt in line.tolist()])
+
     @mapinfo_must_be_set
     def cats(self, cats=None):
         """Get area categories.



More information about the grass-commit mailing list