bernhard: thuban/Extensions/svgexport svgmapwriter.py,1.11,1.12
cvs@intevation.de
cvs at intevation.de
Sat Dec 18 01:29:06 CET 2004
Author: bernhard
Update of /thubanrepository/thuban/Extensions/svgexport
In directory doto:/tmp/cvs-serv14941/Extensions/svgexport
Modified Files:
svgmapwriter.py
Log Message:
Refactored in svgexport:
DrawPath replaces DrawPolygon; added newline in front of "M" in paths.
* Extensions/svgexport/svgmapwriter.py
Added verbosity level 3 to print out polygon points.
(class Point): added __repr__
(class Brush, __str__()): Added space after ,.
(DrawPolygon): Renamed to DrawPath()
(DrawPath): Takes list of polygons as input now, adds \n before "M"s.
(DrawLines): Using DrawPath now.
* Extensions/svgexport/test/test_svgmapwriter.py:
Replaced DrawPolygon() calls with DrawPath() and put the first argument
inside another list. Adapted test data with a newline before "M".
Index: svgmapwriter.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/svgexport/svgmapwriter.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- svgmapwriter.py 11 Dec 2004 03:24:36 -0000 1.11
+++ svgmapwriter.py 18 Dec 2004 00:29:04 -0000 1.12
@@ -21,7 +21,7 @@
import sys
-# Verboseness level for debugging.
+# Verboseness level for debugging. Useful values: 0,1,2,3
verbose=0
log=sys.stdout.write
@@ -63,6 +63,9 @@
self.x = xp
self.y = yp
+ def __repr__(self):
+ return "Point(%s, %s)" % (str(self.x), str(self.y))
+
class Trafo:
"""Class for transformation properties transfer."""
def __init__(self):
@@ -125,7 +128,7 @@
self.pattern = bpattern
def __str__(self):
- return "Brush(" + str(self.fill) + "," + str(self.pattern) + ")"
+ return "Brush(" + str(self.fill) + ", " + str(self.pattern) + ")"
def GetColor(self):
return self.fill
@@ -217,15 +220,14 @@
if verbose > 1:
log("drawing polygon with brush %s and pen %s\n" %
(str(brush), str(pen)) )
+ if verbose > 2:
+ log("points: %s\n" %(repr(points)))
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)
-
+ self.dc.DrawPath([parts],closed=1)
+
def draw_point_shape(self, layer, points, pen, brush, size=2):
"""Draw a point shape from layer with the given brush and pen
@@ -239,7 +241,7 @@
points = self.projected_points(layer, points)
if not points:
return
-
+
radius = self.factor * size
self.dc.SetBrush(brush)
self.dc.SetPen(pen)
@@ -687,22 +689,24 @@
"""Draw some points into a Buffer that will be
written before the next object.
"""
- self.DrawPolygon(points,0)
+ self.DrawPath([points],0)
- def DrawPolygon(self, polygon, closed=1):
- """Draw a polygon onto the virtual dc."""
+ def DrawPath(self, path, closed=1):
+ """Draw a polygon with sonto the virtual dc."""
self.write_indent('<path %s ' % (self.make_style(1,1,0)))
data = []
- i = 0
- for point in polygon:
- if i is 0:
- data.append('M %s %s' % (point.x, point.y))
- i+=1
- else:
- # SVG 1.1 Spec 8.3.1 recommends that lines length <= 255
- data.append('\nL %s %s' % (point.x, point.y))
- if closed:
- data.append(' Z')
+ for subpath in path:
+ i = 0
+ for point in subpath:
+ 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
+ data.append('\nL %s %s' % (point.x, point.y))
+ if closed:
+ data.append(' Z')
+
# Put everything together and write it to the file
self.file.write('%s %s d="%s"/>\n' % (self.make_id(),
self.make_meta(), join(data, '') ) )
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)