bernhard: thuban/Extensions/svgexport svgmapwriter.py,1.6,1.7

cvs@intevation.de cvs at intevation.de
Mon Nov 22 12:17:49 CET 2004


Author: bernhard

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

Modified Files:
	svgmapwriter.py 
Log Message:
Fixing #2698 (transparent polygons are not exported to svg file)

	* Extensions/svgexport/svgmapwriter.py:
	Added verbose variable and some logging depending on it.
	(class VirtualDC(XMLWriter)): Minor improvement in the polygon loop, 
	because counting i is not necessary.
	(class Pen, class Brush): Added simple __str__ methods.
	(SVGRenderer.draw_polygone_shape): Fix #2698 (transparent polygons are
	not exported to svg file) Note: holes still unhandled.

	* Extensions/svgexport/test/test_svgmapwriter.py:
	        Made a baseclass TestWithDC for test needed a DC.
		Added tests for bug #2698 (transparent polygons are not
		exported to svg file):
		Testobjectexport.test_transparent_polygon()


Index: svgmapwriter.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/svgexport/svgmapwriter.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- svgmapwriter.py	15 Nov 2004 16:27:41 -0000	1.6
+++ svgmapwriter.py	22 Nov 2004 11:17:47 -0000	1.7
@@ -19,6 +19,11 @@
 # $Source$
 # $Id$
 
+import sys
+
+# Verboseness level for debugging.
+verbose=0
+log=sys.stdout.write
 
 # Regular expressions used with Fontnames
 import re
@@ -88,6 +93,11 @@
         self.dashes = pdashes
         self.join = 'round' 
         self.cap = 'round'
+
+    def __str__(self):
+        return "Pen(%s,%s,%s,%s,%s)" % \
+            (str(self.color), str(self.width), str(self.dashes), 
+             str(self.join), str(self.cap))
     
     def GetColor(self):
         return self.color
@@ -112,10 +122,13 @@
         """Init the brush with the given values."""
         self.fill = bfill
         self.pattern = bpattern
-    
+
+    def __str__(self):
+        return "Brush(" + str(self.fill) + "," + str(self.pattern) + ")"
+
     def GetColor(self):
         return self.fill
-    
+
     def GetPattern(self):
         return self.pattern
 
@@ -200,11 +213,17 @@
         """
         points = self.projected_points(layer, points)
 
-        if brush is not TRANSPARENT_BRUSH:
-            self.dc.SetBrush(brush)
-            self.dc.SetPen(pen)
-            for part in points:
-                self.dc.DrawLines(part)
+        if verbose > 1:
+            log("drawing polygon with brush %s and pen %s\n" % 
+                (str(brush), str(pen)) )
+
+        self.dc.SetBrush(brush)
+        self.dc.SetPen(pen)
+        # FIXME: understand what BaseRenderer.draw_polygon_shape does
+        #        so complicated here and fix it here, too.
+        #        Maybe that is handling of holes?
+        for parts in points:
+            self.dc.DrawPolygon(parts,closed=1)
     
     def draw_point_shape(self, layer, points, pen, brush):
         """Draw a point shape from layer with the given brush and pen
@@ -248,6 +267,8 @@
             # faster since we don't need the attribute information at
             # all.
             field = None
+            if verbose > 0: 
+                log("layer %s has no classification\n" % layer.Title())
 
         # Determine which render function to use.
         useraw, draw_func, draw_func_param = \
@@ -274,11 +295,11 @@
 
             if not group.IsVisible():
                 continue
-            
+
             # Render classification
             shapeType = layer.ShapeType()
             props = group.GetProperties()
-            
+
             # put meta infos into DC
             if field and value:
                 dc.SetMeta({field:value, })
@@ -295,6 +316,7 @@
                 data = shape.RawData()
             else:
                 data = shape.Points()
+            if verbose > 0 : log("Using draw_func %s\n"%(repr(draw_func)))
             draw_func(draw_func_param, data, pen, brush)
             # compatibility
             if 0:
@@ -668,9 +690,9 @@
         for point in polygon:
             if i is 0:
                 data.append('M %s %s ' % (point.x, point.y))
+                i+=1
             else:
                 data.append('L %s %s ' % (point.x, point.y))
-            i+=1
         # FIXME: Determine if path is closed
         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)