Browse Source

pygrass vector: Added wkt generation for Areas

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66002 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 9 years ago
parent
commit
79cd907f82
1 changed files with 14 additions and 0 deletions
  1. 14 0
      lib/python/pygrass/vector/geometry.py

+ 14 - 0
lib/python/pygrass/vector/geometry.py

@@ -1619,6 +1619,20 @@ class Area(Geo):
             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.