bernhard: thuban/Extensions/svgexport/test test_svgmapwriter.py, 1.16, 1.17

cvs@intevation.de cvs at intevation.de
Sat Dec 18 03:37:01 CET 2004


Author: bernhard

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

Modified Files:
	test_svgmapwriter.py 
Log Message:
	svgexport 1.0.0: Treats holes and islands nicely. Documentation added.

	* Extensions/svgexport/test/test_svgmapwriter.py:
	Added new tests: test_export_polygon_with_hole() 
	and test_polygon_with_hole().

	* Extensions/svgexport/svgmapwriter.py
	(draw_polygon_shape()): Uses DrawPath correctly now.

	* Doc/manual/thuban-manual.xml: Added documentation for stable
	extention svgexport.	
	* Doc/manual/thuban-manual-de.xml: Copied English section about
	svexport over.

 	* Extensions/svgexport/__init__.py: Bumped version number to 1.0.0.

	* Extensions/svgexport/svgsaver.py,maplegend.py: 
	Moved from experimental to stable extension menu.

	* Extensions/svgexport/TODO: updated.


Index: test_svgmapwriter.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/svgexport/test/test_svgmapwriter.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- test_svgmapwriter.py	18 Dec 2004 00:29:04 -0000	1.16
+++ test_svgmapwriter.py	18 Dec 2004 02:36:59 -0000	1.17
@@ -137,6 +137,25 @@
         self.assertEquals(xmlsupport.sax_eventlist(data=data), 
                           xmlsupport.sax_eventlist(data=self.file.getvalue()))
 
+    def test_polygon_with_hole(self):
+        '''Set drawing properties and draw a polygon onto the dc.'''
+
+        holepolygon = [Point(11.1,11.1), Point(33.3,11.1), Point(22.2,22.2),
+                Point(11.1,11.1)]
+        data = ('<path style="stroke-linejoin:round; stroke:#ff00ff; '
+                'stroke-width:3; stroke-linecap:round; fill:#00ff00" ' 
+                'meta="Object:test; Label:nothing" d="\nM 5.6 5.5 '
+                'L 95.4 5.3 L 95.2 95.1 L 5.0 95.0 L 5.0 5.0 Z'
+                '\nM 11.1 11.1 L 33.3 11.1 L 22.2 22.2 L 11.1 11.1 Z"/>')
+
+        dc = self.dc
+        dc.SetPen(self.solid_pen)
+        dc.SetMeta(self.meta)
+        dc.SetBrush(self.solid_brush)
+        dc.DrawPath([self.polygon, holepolygon], 1)
+        self.assertEquals(xmlsupport.sax_eventlist(data=data), 
+                          xmlsupport.sax_eventlist(data=self.file.getvalue()))
+
     def test_rect(self):
         '''Set drawing properties and draw a rectangle'''
         data = ('<rect x="5.5" y="5.4" width="90.3" height="90.2" '
@@ -356,6 +375,43 @@
                              ("code", FIELDTYPE_INT)],
                             [("UNKNOWN", 0.0, 0)])
         shapes = [[[(0, 0), (10, 10), (0, 10), (0, 0) ]]]
+        store = SimpleShapeStore(SHAPETYPE_POLYGON, shapes, table)
+
+        map = Map("testpolygonexport")
+        self.to_destroy.append(map)
+        layer=Layer("P-Layer", store, fill=Transparent)
+        map.AddLayer(layer)
+
+        renderer = SVGRenderer(self.dc, map,
+                    scale=1.0, offset=(0,0), region=(0,0,10,10))
+        renderer.RenderMap(None, None)
+        #print (data)
+        #print (self.dc.file.getvalue())
+        self.assertEquals(data, self.dc.file.getvalue())
+
+    def test_export_polygon_with_hole(self):
+        """ Create layer with polygon ans hole and test svg rendering."""
+
+        data = ('<clipPath id="mapclip">\n'
+                '    <rect x="0" y="0" width="10" height="10"   />\n'
+                '</clipPath>\n'
+                '<g meta="Object:map"  clip-path="url(#mapclip)" '
+                'clip-rule="evenodd" transform=" scale(100.0)">\n'
+                '    <g meta="Layer:P-Layer" >\n'
+                '        <path style="stroke-linejoin:round; stroke:#000000; '
+                'stroke-width:0.01; stroke-linecap:round; fill:none" '
+                'id="P-Layer_0"'
+                '  d="\nM 0.0 0.0\nL 0.0 -10.0\nL 10.0 -10.0\nL 0.0 0.0 Z'
+                '\nM 5.0 -6.0\nL 5.0 -7.0\nL 4.0 -7.0\nL 4.0 -6.0'
+                '\nL 5.0 -6.0 Z"/>\n'
+                '    </g>\n</g>\n')
+        table = MemoryTable([("type", FIELDTYPE_STRING),
+                             ("value", FIELDTYPE_DOUBLE),
+                             ("code", FIELDTYPE_INT)],
+                            [("UNKNOWN", 0.0, 0)])
+        shapes = [[[(0, 0), (0, 10), (10, 10), (0, 0) ],
+                   [(5, 6), (5,  7), ( 4,  7), (4, 6), (5, 6)]
+                 ]]
         store = SimpleShapeStore(SHAPETYPE_POLYGON, shapes, table)
 
         map = Map("testpolygonexport")





More information about the Thuban-devel mailing list

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