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")
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')
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)
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)
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)
def testColorObjToHex(self): """a color can be outputted as hex""" c = mapscript.colorObj(255, 255, 255) assert c.toHex() == '#ffffff'
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)
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)
def testColorObjSetHexBadly(self): """invalid hex color string raises proper error""" c = mapscript.colorObj() self.assertRaises(mapscript.MapServerError, c.setHex, '#fffffg')
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)
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)
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)
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)