Пример #1
0
 def testDrawPoints(self):
     """DrawProgrammedStylesTestCase.testDrawPoints: point drawing with styles works as advertised"""
     points = [mapscript.pointObj(-0.2, 51.6), mapscript.pointObj(0.0, 51.2), mapscript.pointObj(0.2, 51.6)]
     colors = [mapscript.colorObj(255, 0, 0), mapscript.colorObj(0, 255, 0), mapscript.colorObj(0, 0, 255)]
     img = self.map.prepareImage()
     layer = self.map.getLayerByName("POINT")
     # layer.draw(self.map, img)
     class0 = layer.getClass(0)
     for i in range(len(points)):
         style0 = class0.getStyle(0)
         style0.color = colors[i]
         # style0.color.pen = -4
         assert style0.color.toHex() == colors[i].toHex()
         points[i].draw(self.map, layer, img, 0, "foo")
     img.save("test_draw_points.png")
Пример #2
0
 def testDrawPoints(self):
     """DrawProgrammedStylesTestCase.testDrawPoints: point drawing with styles works as advertised"""
     points = [mapscript.pointObj(-0.2, 51.6),
               mapscript.pointObj(0.0, 51.2),
               mapscript.pointObj(0.2, 51.6)]
     colors = [mapscript.colorObj(255,0,0),
               mapscript.colorObj(0,255,0),
               mapscript.colorObj(0,0,255)]
     img = self.map.prepareImage()
     layer = self.map.getLayerByName('POINT')
     #layer.draw(self.map, img)
     class0 = layer.getClass(0)
     for i in range(len(points)):
         style0 = class0.getStyle(0)
         style0.color = colors[i]
         #style0.color.pen = -4
         assert style0.color.toHex() == colors[i].toHex()
         points[i].draw(self.map, layer, img, 0, "foo")
     img.save('test_draw_points.png')
Пример #3
0
 def testColorObjSetHexLower(self):
     """a color can be set using lower case hex"""
     c = mapscript.colorObj()
     c.setHex('#ffffff64')
     assert (c.red, c.green, c.blue, c.alpha) == (255, 255, 255, 100)
Пример #4
0
 def testColorObjSetRGB(self):
     """a color can be set using setRGB method"""
     c = mapscript.colorObj()
     c.setRGB(255, 255, 255, 100)
     assert (c.red, c.green, c.blue, c.alpha) == (255, 255, 255, 100)
Пример #5
0
 def testColorObjToHexBadly(self):
     """raise an error in the case of an undefined color"""
     c = mapscript.colorObj(-1,-1,-1)
     self.assertRaises(mapscript.MapServerError, c.toHex)
Пример #6
0
 def testColorObjToHex(self):
     """a color can be outputted as hex"""
     c = mapscript.colorObj(255, 255, 255)
     assert c.toHex() == '#ffffff'
Пример #7
0
 def testColorObjConstructorArgs(self):
     """a color can be initialized with arguments"""
     c = mapscript.colorObj(1, 2, 3, 4)
     assert (c.red, c.green, c.blue, c.alpha) == (1, 2, 3, 4)
Пример #8
0
 def testColorObjConstructorNoArgs(self):
     """a color can be initialized with no arguments"""
     c = mapscript.colorObj()
     assert (c.red, c.green, c.blue, c.alpha) == (0, 0, 0, 255)
Пример #9
0
 def testColorObjToHex(self):
     """a color can be outputted as hex"""
     c = mapscript.colorObj(255, 255, 255)
     assert c.toHex() == '#ffffff'
Пример #10
0
 def testColorObjSetHexBadly(self):
     """invalid hex color string raises proper error"""
     c = mapscript.colorObj()
     self.assertRaises(mapscript.MapServerError, c.setHex, '#fffffg')
Пример #11
0
 def testColorObjSetHexUpper(self):
     """a color can be set using upper case hex"""
     c = mapscript.colorObj()
     c.setHex('#FFFFFF')
     assert (c.red, c.green, c.blue) == (255, 255, 255)
Пример #12
0
 def testColorObjSetHexLower(self):
     """a color can be set using lower case hex"""
     c = mapscript.colorObj()
     c.setHex('#ffffff')
     assert (c.red, c.green, c.blue, c.pen) == (255, 255, 255, -4)
Пример #13
0
 def testColorObjSetRGB(self):
     """a color can be set using setRGB method"""
     c = mapscript.colorObj()
     c.setRGB(255, 255, 255)
     assert (c.red, c.green, c.blue, c.pen) == (255, 255, 255, -4)
Пример #14
0
 def testColorObjToHexBadly(self):
     """raise an error in the case of an undefined color"""
     c = mapscript.colorObj(-1,-1,-1)
     self.assertRaises(mapscript.MapServerError, c.toHex)
Пример #15
0
 def testColorObjSetHexUpper(self):
     """a color can be set using upper case hex"""
     c = mapscript.colorObj()
     c.setHex('#FFFFFF')
     assert (c.red, c.green, c.blue) == (255, 255, 255)
Пример #16
0
 def testColorObjSetHexBadly(self):
     """invalid hex color string raises proper error"""
     c = mapscript.colorObj()
     self.assertRaises(mapscript.MapServerError, c.setHex, '#fffffg')
Пример #17
0
 def testColorObjConstructorArgs(self):
     """a color can be initialized with arguments"""
     c = mapscript.colorObj(1, 2, 3)
     assert (c.red, c.green, c.blue, c.pen) == (1, 2, 3, -4)