Example #1
0
 def test_addClassToLegend(self):
     """Test we can add a class to the map legend."""
     myLayer, myType = loadLayer('test_shakeimpact.shp')
     del myType
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.legend = None
     myColour = QtGui.QColor(12, 34, 126)
     myMap.addClassToLegend(myColour,
                            theMin=None,
                            theMax=None,
                            theCategory=None,
                            theLabel='bar')
     myMap.addClassToLegend(myColour,
                            theMin=None,
                            theMax=None,
                            theCategory=None,
                            theLabel='foo')
     myPath = os.path.join(temp_dir(), 'addClassToLegend.png')
     myMap.legend.save(myPath, 'PNG')
     # As we have discovered, different versions of Qt and
     # OS platforms cause different output, so hashes are a list
     # of 'known good' renders.
     myExpectedHashes = ['',  # win
                         '67c0f45792318298664dd02cc0ac94c3',  # ub12.04xiner
                         'ea0702782c2ed5d950c427fbe1743858',  # ub11.04-64
                         '53e0ba1144e071ad41756595d29bf444',  # ub12.04
                         '0681c3587305074bc9272f456fb4dd09',  # ub12.04 xvfb
                         'a37443d70604bdc8c279576b424a158c',  # ub12.04-64
                         # ub11.04-64 laptop
                         '944cee3eb9d916816b60ef41e8069683',  # binary read
                         'de3ceb6547ffc6c557d031c0b7ee9e75',  # wVistaSP2-32
                         '',
                         ]
     assertHashesForFile(myExpectedHashes, myPath)
Example #2
0
 def addSymbolToLegend(self):
     """Test we can add a symbol to the legend."""
     myLayer, myType = loadLayer('test_floodimpact.tif')
     del myType
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.legend = None
     mySymbol = QgsSymbol()
     mySymbol.setColor(QtGui.QColor(12, 34, 56))
     myMap.addSymbolToLegend(mySymbol,
                             theMin=0,
                             theMax=2,
                             theCategory=None,
                             theLabel='Foo')
     myPath = os.path.join(temp_dir(), 'addSymbolToLegend.png')
     myMap.legend.save(myPath, 'PNG')
     myExpectedHash = '1234'
     assertHashForFile(myExpectedHash, myPath)