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 = ISMap(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(getTempDir(), '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.10-64
                         '53e0ba1144e071ad41756595d29bf444',  # ub12.04
                         '0681c3587305074bc9272f456fb4dd09',  # ub12.04 xvfb
                         # ub11.04-64 laptop
                         '',
                         ]
     assertHashesForFile(myExpectedHashes, myPath)
Example #2
0
 def test_getRasterLegend(self):
     """Getting a legend for a raster layer works."""
     myLayer, myType = loadLayer('test_floodimpact.tif')
     del myType
     myMap = ISMap(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.getRasterLegend()
     myPath = os.path.join(getTempDir(), 'getRasterLegend.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
                         '9ead6ce0ac789adc65a6f00bd2d1f709',  # ub12.04xiner
                         '84bc3d518e3a0504f8dc36dfd620394e',  # ub11.10-64
                         'b68ccc328de852f0c66b8abe43eab3da',  # ub12.04
                         'cd5fb96f6c5926085d251400dd3b4928',  # ub12.04 xvfb
                         # ub11.04-64 laptop
                         '',
                         ]
     assertHashesForFile(myExpectedHashes, myPath)
Example #3
0
 def test_getVectorLegend(self):
     """Getting a legend for a vector layer works."""
     myLayer, myType = loadLayer('test_shakeimpact.shp')
     del myType
     myMap = ISMap(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.getVectorLegend()
     myPath = os.path.join(getTempDir(), 'getVectorLegend.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
                         'd0c3071c4babe7db4f9762b311d61184',  # ub12.04 xinr
                         'b94cfd8a10d709ff28466ada425f24c8',  # ub11.10-64
                         '00dc58aa50867de9b617ccfab0d13f21',  # ub12.04
                         'e65853e217a4c9b0c2f303dd2aadb373',  # ub12.04 xvfb
                         # ub11.04-64 laptop
                         '',
                         ]
     assertHashesForFile(myExpectedHashes, myPath)