bernhard: thuban/Extensions/svgexport svgmapwriter.py,1.13,1.14

cvs@intevation.de cvs at intevation.de
Sun Dec 19 11:14:40 CET 2004


Author: bernhard

Update of /thubanrepository/thuban/Extensions/svgexport
In directory doto:/tmp/cvs-serv326/Extensions/svgexport

Modified Files:
	svgmapwriter.py 
Log Message:
	svgexport: Improved code quality, mainly by better naming.

	* Extensions/svgexport/svgmapwriter.py:
	DrawPath() renamed to DrawPolygonPath(),
	added documentation, improved comments and variable names.
	
	* Extensions/svgexport/svgmapwriter.py,
	  Extensions/svgexport/test/test_svgmapwriter.py:
	All using DrawPolygonPath() now, the default parameter closed=True
	omitted.

	* Extensions/svgexport/test/test_svgmapwriter.py:
	renamed test_polygon_opened() to test_polyline()
	renamed test_transparent_polygon() to test_transparent_polyline()


Index: svgmapwriter.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/svgexport/svgmapwriter.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- svgmapwriter.py	18 Dec 2004 02:36:59 -0000	1.13
+++ svgmapwriter.py	19 Dec 2004 10:14:38 -0000	1.14
@@ -225,7 +225,7 @@
 
         self.dc.SetBrush(brush)
         self.dc.SetPen(pen)
-        self.dc.DrawPath(points,closed=1)
+        self.dc.DrawPolygonPath(points)
 
     def draw_point_shape(self, layer, points, pen, brush, size=2):
         """Draw a point shape from layer with the given brush and pen
@@ -688,20 +688,27 @@
         """Draw some points into a Buffer that will be 
         written before the next object.
         """
-        self.DrawPath([points],0)
+        self.DrawPolygonPath([points], closed=False)
     
-    def DrawPath(self, path, closed=1):
-        """Draw a polygon with sonto the virtual dc."""
+    def DrawPolygonPath(self, polys, closed=True):
+        """Draw a list of polygons or polylines as one SVG path.
+
+        Parameter:
+        polys    list of poly- gons/lines; each consisting of a list of points
+        closed   Boolean; optional; Default: True
+                 False will leave each subpath open thus making it polylines.
+        """
         self.write_indent('<path %s ' % (self.make_style(1,1,0)))
         data = []
-        for subpath in path:
+        for poly in polys:
             i = 0
-            for point in subpath:
+            for point in poly:
                 if i is 0:
                     data.append('\nM %s %s' % (point.x, point.y))
                     i+=1
                 else:
                     # SVG 1.1 Spec 8.3.1 recommends that lines length <= 255
+                    # we make a best effort in throwing in a few newlines
                     data.append('\nL %s %s' % (point.x, point.y))
             if closed:
                 data.append(' Z')





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)