Exemplo n.º 1
0
 def setUp(self):
     """The test fixture is a shape of one point"""
     self.points = (mapscript.pointObj(0.0, 1.0),)
     self.lines = (mapscript.lineObj(),)
     self.addPointToLine(self.lines[0], self.points[0])
     self.shape = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
     self.addLineToShape(self.shape, self.lines[0])
Exemplo n.º 2
0
 def setUp(self):
     """The test fixture is a line with two points"""
     self.points = (mapscript.pointObj(0.0, 1.0),
                    mapscript.pointObj(2.0, 3.0))
     self.line = mapscript.lineObj()
     self.addPointToLine(self.line, self.points[0])
     self.addPointToLine(self.line, self.points[1])
Exemplo n.º 3
0
 def setUp(self):
     """The test fixture is a line with two points"""
     self.points = (mapscript.pointObj(0.0,
                                       1.0), mapscript.pointObj(2.0, 3.0))
     self.line = mapscript.lineObj()
     self.addPointToLine(self.line, self.points[0])
     self.addPointToLine(self.line, self.points[1])
Exemplo n.º 4
0
 def setUp(self):
     """The test fixture is a shape of one point"""
     self.points = (mapscript.pointObj(0.0, 1.0),)
     self.lines = (mapscript.lineObj(),)
     self.addPointToLine(self.lines[0], self.points[0])
     self.shape = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
     self.addLineToShape(self.shape, self.lines[0])
Exemplo n.º 5
0
    def testGetPointWKT(self):
        # Create new instance from class data
        po = mapscript.pointObj(self.point_xy[0], self.point_xy[1])
        lo = mapscript.lineObj()
        lo.add(po)
        so = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
        so.add(lo)

        # test output WKT
        wkt = so.toWKT()
        self.assert_(wkt == self.point_wkt, wkt)
Exemplo n.º 6
0
    def testGetPointWKT(self):
        # Create new instance from class data
        po = mapscript.pointObj(self.point_xy[0], self.point_xy[1])
        lo = mapscript.lineObj()
        lo.add(po)
        so = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
        so.add(lo)

        # test output WKT
        wkt = so.toWKT()
        self.assert_(wkt == self.point_wkt, wkt)
Exemplo n.º 7
0
 def testSetPoints(self):
     """add lines of points to an existing symbol"""
     symbol = self.map.symbolset.getSymbol(1)
     assert symbol.name == 'circle'
     line = mapscript.lineObj()
     self.addPointToLine(line, mapscript.pointObj(2.0, 2.0))
     self.addPointToLine(line, mapscript.pointObj(3.0, 3.0))
     assert symbol.setPoints(line) == 2
     assert symbol.numpoints == 2
     line = symbol.getPoints()
     assert line.numpoints == 2, line.numpoints
     pt = self.getPointFromLine(line, 1)
     self.assertPointsEqual(pt, mapscript.pointObj(3.0, 3.0))
Exemplo n.º 8
0
 def testSetPoints(self):
     """add lines of points to an existing symbol"""
     symbol = self.map.symbolset.getSymbol(1)
     assert symbol.name == 'circle'
     line = mapscript.lineObj()
     self.addPointToLine(line, mapscript.pointObj(2.0, 2.0))
     self.addPointToLine(line, mapscript.pointObj(3.0, 3.0))
     assert symbol.setPoints(line) == 2
     assert symbol.numpoints == 2
     line = symbol.getPoints()
     assert line.numpoints == 2, line.numpoints
     pt = self.getPointFromLine(line, 1)
     self.assertPointsEqual(pt, mapscript.pointObj(3.0, 3.0))
Exemplo n.º 9
0
 def testAddPointFeature(self):
     """adding a point to an inline feature works correctly"""
     inline_layer = self.map.getLayerByName('INLINE')
     assert inline_layer.connectiontype == mapscript.MS_INLINE
     p = mapscript.pointObj(0.2, 51.5)
     l = mapscript.lineObj()
     self.addPointToLine(l, p)
     shape = mapscript.shapeObj(inline_layer.type)
     shape.classindex = 0
     self.addLineToShape(shape, l)
     inline_layer.addFeature(shape)
     msimg = self.map.draw()
     filename = 'testAddPointFeature.png'
     msimg.save(filename)
Exemplo n.º 10
0
 def testAddPointFeature(self):
     """adding a point to an inline feature works correctly"""
     inline_layer = self.map.getLayerByName('INLINE')
     assert inline_layer.connectiontype == mapscript.MS_INLINE
     p = mapscript.pointObj(0.2, 51.5)
     l = mapscript.lineObj()
     self.addPointToLine(l, p)
     shape = mapscript.shapeObj(inline_layer.type)
     shape.classindex = 0
     self.addLineToShape(shape, l)
     inline_layer.addFeature(shape)
     msimg = self.map.draw()
     filename = 'testAddPointFeature.png'
     msimg.save(filename)
Exemplo n.º 11
0
    def testSettingFonts(self):
        mo = mapscript.mapObj()
        assert mo.fontset.numfonts == 0
        mo.fontset.fonts.set('Vera', os.path.join(TESTS_PATH, 'vera',
                                                  'Vera.ttf'))
        # NB: this does *not* increment the fonset.numfonts -- new bug
                                                  
        mo.setSize(300, 300)
        mo.setExtent(-1.0, -1.0, 1.0, 1.0)
        
        lo = mapscript.layerObj()
        lo.type = mapscript.MS_LAYER_POINT
        lo.connectiontype = mapscript.MS_INLINE
        lo.status = mapscript.MS_DEFAULT

        co = mapscript.classObj()
        lbl =mapscript.labelObj() 
        lbl.type = mapscript.MS_TRUETYPE
        lbl.font = 'Vera'
        lbl.size = 10
        lbl.color.setHex('#000000')
        co.addLabel(lbl)

        so = mapscript.styleObj()
        so.symbol = 0
        so.color.setHex('#000000')
        
        co.insertStyle(so)
        lo.insertClass(co)
        li = mo.insertLayer(lo)
        lo = mo.getLayer(li)

        point = mapscript.pointObj(0,0)
        line = mapscript.lineObj()
        line.add(point)
        shape = mapscript.shapeObj(lo.type)
        shape.add(line)
        shape.setBounds()
        shape.text = 'Foo'
        shape.classindex = 0

        lo.addFeature(shape)
        im = mo.draw()
        
        #im = mo.prepareImage()
        #shape.draw(mo, lo, im)
        im.save('testSettingFonts.png')
Exemplo n.º 12
0
    def testSettingFonts(self):
        mo = mapscript.mapObj()
        assert mo.fontset.numfonts == 0
        mo.fontset.fonts.set('Vera',
                             os.path.join(TESTS_PATH, 'vera', 'Vera.ttf'))
        # NB: this does *not* increment the fonset.numfonts -- new bug

        mo.setSize(300, 300)
        mo.setExtent(-1.0, -1.0, 1.0, 1.0)

        lo = mapscript.layerObj()
        lo.type = mapscript.MS_LAYER_POINT
        lo.connectiontype = mapscript.MS_INLINE
        lo.status = mapscript.MS_DEFAULT

        co = mapscript.classObj()
        lbl = mapscript.labelObj()
        lbl.type = mapscript.MS_TRUETYPE
        lbl.font = 'Vera'
        lbl.size = 10
        lbl.color.setHex('#000000')
        co.addLabel(lbl)

        so = mapscript.styleObj()
        so.symbol = 0
        so.color.setHex('#000000')

        co.insertStyle(so)
        lo.insertClass(co)
        li = mo.insertLayer(lo)
        lo = mo.getLayer(li)

        point = mapscript.pointObj(0, 0)
        line = mapscript.lineObj()
        line.add(point)
        shape = mapscript.shapeObj(lo.type)
        shape.add(line)
        shape.setBounds()
        shape.text = 'Foo'
        shape.classindex = 0

        lo.addFeature(shape)
        im = mo.draw()

        #im = mo.prepareImage()
        #shape.draw(mo, lo, im)
        im.save('testSettingFonts.png')