コード例 #1
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 def Xtest_renderTable(self):
     """Test that html renders nicely. Commented out for now until we work
     out how to get webkit to do offscreen rendering nicely."""
     myFilename = 'test_floodimpact.tif'
     myLayer, myType = loadLayer(myFilename)
     CANVAS.refresh()
     del myType
     myMessage = 'Layer is not valid: %s' % myFilename
     assert myLayer.isValid(), myMessage
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myPixmap = myMap.renderImpactTable()
     assert myPixmap is not None
     myExpectedWidth = 500
     myExpectedHeight = 300
     myMessage = 'Invalid width - got %s expected %s' % (
                                 myPixmap.width(),
                                 myExpectedWidth)
     assert myPixmap.width() == myExpectedWidth, myMessage
     myMessage = 'Invalid height - got %s expected %s' % (
                                 myPixmap.height(),
                                 myExpectedHeight)
     assert myPixmap.height() == myExpectedHeight
     myPath = os.path.join(temp_dir(), 'renderImpactTable.png')
     myPixmap.save(myPath, 'PNG')
     myExpectedHash = 'c9164d5c2bb85c6081905456ab827f3e'
     assertHashForFile(myExpectedHash, myPath)
コード例 #2
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
    def test_windowsDrawingArtifacts(self):
        """Test that windows rendering does not make artifacts"""
        # sometimes spurious lines are drawn on the layout
        myMap = Map(IFACE)
        myMap.setupComposition()
        myPdfPath = os.path.join(temp_dir(), 'outArtifactsTest.pdf')
        myMap.setupPrinter(myPdfPath)

        myPixmap = QtGui.QPixmap(10, 10)
        myPixmap.fill(QtGui.QColor(250, 250, 250))
        myFilename = os.path.join(temp_dir(), 'greyBox')
        myPixmap.save(myFilename, 'PNG')
        for i in range(10, 190, 10):
            myPicture = QgsComposerPicture(myMap.composition)
            myPicture.setPictureFile(myFilename)
            myPicture.setFrame(False)
            myPicture.setItemPosition(i,  # x
                                      i,  # y
                                      10,  # width
                                      10)  # height
            myMap.composition.addItem(myPicture)
            # Same drawing drawn directly as a pixmap
            myPixmapItem = myMap.composition.addPixmap(myPixmap)
            myPixmapItem.setOffset(i, i + 20)
            # Same drawing using our drawPixmap Helper
            myWidthMM = 1
            myMap.drawPixmap(myPixmap, myWidthMM, i, i + 40)

        myMap.renderPrintout()
        myUnwantedHash = 'd05e9223d50baf8bb147475aa96d6ba3'
        myHash = hashForFile(myPdfPath)
        # when this test no longer matches our broken render hash
        # we know the issue is fixed
        myMessage = 'Windows map render still draws with artifacts.'
        assert myHash != myUnwantedHash, myMessage
コード例 #3
0
ファイル: test_map.py プロジェクト: zzpwelkin/inasafe
 def test_getMapTitle(self):
     """Getting the map title from the keywords"""
     myLayer, _ = loadLayer('test_floodimpact.tif')
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myTitle = myMap.getMapTitle()
     myExpectedTitle = 'Penduduk yang Mungkin dievakuasi'
     myMessage = 'Expected: %s\nGot:\n %s' % (myExpectedTitle, myTitle)
     assert myTitle == myExpectedTitle, myMessage
コード例 #4
0
ファイル: test_map.py プロジェクト: maning/inasafe
 def test_getMapTitle(self):
     """Getting the map title from the keywords"""
     myLayer, _ = loadLayer('test_floodimpact.tif')
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myTitle = myMap.getMapTitle()
     myExpectedTitle = 'Penduduk yang Mungkin dievakuasi'
     myMessage = 'Expected: %s\nGot:\n %s' % (myExpectedTitle, myTitle)
     assert myTitle == myExpectedTitle, myMessage
コード例 #5
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 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)
コード例 #6
0
ファイル: test_map.py プロジェクト: zzpwelkin/inasafe
 def test_handleMissingMapTitle(self):
     """Missing map title from the keywords fails gracefully"""
     # TODO running OSM Buildngs with Pendudk Jakarta
     # wasthrowing an error when requesting map title
     # that this test wasnt replicating well
     myLayer, _ = loadLayer('population_padang_1.asc')
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myTitle = myMap.getMapTitle()
     myExpectedTitle = None
     myMessage = 'Expected: %s\nGot:\n %s' % (myExpectedTitle, myTitle)
     assert myTitle == myExpectedTitle, myMessage
コード例 #7
0
ファイル: test_map.py プロジェクト: maning/inasafe
 def test_handleMissingMapTitle(self):
     """Missing map title from the keywords fails gracefully"""
     # TODO running OSM Buildngs with Pendudk Jakarta
     # wasthrowing an error when requesting map title
     # that this test wasnt replicating well
     myLayer, _ = loadLayer('population_padang_1.asc')
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myTitle = myMap.getMapTitle()
     myExpectedTitle = None
     myMessage = 'Expected: %s\nGot:\n %s' % (myExpectedTitle, myTitle)
     assert myTitle == myExpectedTitle, myMessage
コード例 #8
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 def test_mmPointConversion(self):
     """Test that conversions between pixel and page dimensions work."""
     myMap = Map(IFACE)
     myDpi = 300
     myMap.pageDpi = myDpi
     myPixels = 300
     myMM = 25.4  # 1 inch
     myResult = myMap.pointsToMM(myPixels)
     myMessage = "Expected: %s\nGot: %s" % (myMM, myResult)
     assert myResult == myMM, myMessage
     myResult = myMap.mmToPoints(myMM)
     myMessage = "Expected: %s\nGot: %s" % (myPixels, myResult)
     assert myResult == myPixels, myMessage
コード例 #9
0
ファイル: test_map.py プロジェクト: maning/inasafe
 def test_printToPdf(self):
     """Test making a pdf of the map - this is the most typical use of map.
     """
     LOGGER.info('Testing printToPdf')
     myLayer, _ = loadLayer('test_shakeimpact.shp')
     myCanvasLayer = QgsMapCanvasLayer(myLayer)
     CANVAS.setLayerSet([myCanvasLayer])
     myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
     CANVAS.setExtent(myRect)
     CANVAS.refresh()
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.composeMap()
     myPath = unique_filename(prefix='mapPdfTest',
                              suffix='.pdf',
                              dir=temp_dir('test'))
     myMap.printToPdf(myPath)
     LOGGER.debug(myPath)
     myMessage = 'Rendered output does not exist: %s' % myPath
     assert os.path.exists(myPath), myMessage
     # pdf rendering is non deterministic so we can't do a hash check
     # test_renderComposition renders just the image instead of pdf
     # so we hash check there and here we just do a basic minimum file
     # size check.
     mySize = os.stat(myPath).st_size
     myExpectedSizes = [
         441541,  # as rendered on ub 13.04 post 17 May 2013
         447217,  # Nadia Linux Mint 14
         0,  # as rendered on Jenkins post 24 April 2013
         447138,  # Windows 7 SP1 AMD64
     ]
     myMessage = 'Expected rendered map pdf to be in %s, got %s' % (
         myExpectedSizes, mySize)
     self.assertIn(mySize, myExpectedSizes, myMessage)
コード例 #10
0
ファイル: test_map.py プロジェクト: nadyaoktaviani/inasafe
    def Xtest_renderTemplate(self):
        """Test that load template works"""
        # Use the template from our resources bundle
        myInPath = ":/plugins/inasafe/basic.qpt"
        myLayer, _ = loadLayer("test_shakeimpact.shp")

        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])
        myMap = Map(IFACE)
        setJakartaGeoExtent()
        myMap.setImpactLayer(myLayer)
        myPath = unique_filename(prefix="outTemplate", suffix=".pdf", dir=temp_dir("test"))
        LOGGER.debug(myPath)
        myMap.renderTemplate(myInPath, myPath)
        assert os.path.exists(myPath)
コード例 #11
0
ファイル: test_map.py プロジェクト: zzpwelkin/inasafe
 def test_printToPdf(self):
     """Test making a pdf of the map - this is the most typical use of map.
     """
     LOGGER.info('Testing printToPdf')
     myLayer, _ = loadLayer('test_shakeimpact.shp')
     myCanvasLayer = QgsMapCanvasLayer(myLayer)
     CANVAS.setLayerSet([myCanvasLayer])
     myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
     CANVAS.setExtent(myRect)
     CANVAS.refresh()
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.composeMap()
     myPath = unique_filename(prefix='mapPdfTest',
                              suffix='.pdf',
                              dir=temp_dir('test'))
     myMap.printToPdf(myPath)
     LOGGER.debug(myPath)
     myMessage = 'Rendered output does not exist: %s' % myPath
     assert os.path.exists(myPath), myMessage
     # pdf rendering is non deterministic so we can't do a hash check
     # test_renderComposition renders just the image instead of pdf
     # so we hash check there and here we just do a basic minimum file
     # size check.
     mySize = os.stat(myPath).st_size
     myExpectedSize = 352798  # as rendered on linux ub 12.04 64
     myMessage = 'Expected rendered map pdf to be at least %s, got %s' % (
         myExpectedSize, mySize)
     assert mySize >= myExpectedSize, myMessage
コード例 #12
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 def test_getLegend(self):
     """Getting a legend for a generic layer works."""
     myLayer, myType = loadLayer('test_shakeimpact.shp')
     del myType
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     assert myMap.layer is not None
     myLegend = myMap.getLegend()
     myPath = os.path.join(temp_dir(), 'getLegend.png')
     myLegend.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.04xiner
                         'b94cfd8a10d709ff28466ada425f24c8',  # ub11.04-64
                         '00dc58aa50867de9b617ccfab0d13f21',  # ub12.04
                         'e65853e217a4c9b0c2f303dd2aadb373',  # ub12.04 xvfb
                         'e4273364b33a943e1108f519dbe8e06c',  # ub12.04-64
                         '91177a81bee4400be4e85789e3be1e91',  # binary read
                         '57da6f81b4a55507e1bed0b73423244b',  # wVistaSP2-32
                         '']
     assertHashesForFile(myExpectedHashes, myPath)
コード例 #13
0
ファイル: test_map.py プロジェクト: maning/inasafe
    def test_windowsDrawingArtifacts(self):
        """Test that windows rendering does not make artifacts"""
        # sometimes spurious lines are drawn on the layout
        LOGGER.info('Testing windowsDrawingArtifacts')
        myPath = unique_filename(prefix='artifacts',
                                 suffix='.pdf',
                                 dir=temp_dir('test'))
        myMap = Map(IFACE)
        setupPrinter(myPath)
        myMap.setupComposition()

        myImage = QtGui.QImage(10, 10, QtGui.QImage.Format_RGB32)
        myImage.setDotsPerMeterX(dpiToMeters(300))
        myImage.setDotsPerMeterY(dpiToMeters(300))
        #myImage.fill(QtGui.QColor(250, 250, 250))
        # Look at the output, you will see antialiasing issues around some
        # of the boxes drawn...
        # myImage.fill(QtGui.QColor(200, 200, 200))
        myImage.fill(200 + 200 * 256 + 200 * 256 * 256)
        myFilename = os.path.join(temp_dir(), 'greyBox')
        myImage.save(myFilename, 'PNG')
        for i in range(10, 190, 10):
            myPicture = QgsComposerPicture(myMap.composition)
            myPicture.setPictureFile(myFilename)
            if qgisVersion() >= 10800:  # 1.8 or newer
                myPicture.setFrameEnabled(False)
            else:
                myPicture.setFrame(False)
            myPicture.setItemPosition(i,  # x
                                      i,  # y
                                      10,  # width
                                      10)  # height
            myMap.composition.addItem(myPicture)
            # Same drawing drawn directly as a pixmap
            myPixmapItem = myMap.composition.addPixmap(
                QtGui.QPixmap.fromImage(myImage))
            myPixmapItem.setOffset(i, i + 20)
            # Same drawing using our drawImage Helper
            myWidthMM = 1
            myMap.drawImage(myImage, myWidthMM, i, i + 40)

        myImagePath, _, _ = myMap.renderComposition()
        # when this test no longer matches our broken render hash
        # we know the issue is fixed

        myTolerance = 0
        myFlag, myMessage = checkImages('windowsArtifacts.png',
                                        myImagePath,
                                        myTolerance)
        myMessage += ('\nWe want these images to match, if they do not '
                      'there may be rendering artifacts in windows.\n')
        assert myFlag, myMessage
コード例 #14
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 def test_inasafeMap(self):
     """Test making a pdf using the Map class."""
     myLayer, myType = loadLayer('test_shakeimpact.shp')
     del myType
     myCanvasLayer = QgsMapCanvasLayer(myLayer)
     CANVAS.setLayerSet([myCanvasLayer])
     myMap = Map(IFACE)
     myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
     CANVAS.setExtent(myRect)
     CANVAS.refresh()
     myMap.setImpactLayer(myLayer)
     myPath = os.path.join(temp_dir(), 'outCustom.pdf')
     if os.path.exists(myPath):
         os.remove(myPath)
     myMap.makePdf(myPath)
     assert os.path.exists(myPath)
     # ,, note:: Template writing is experimental
     myMap.writeTemplate(os.path.join(temp_dir(), 'template.qpt'))
コード例 #15
0
ファイル: test_map.py プロジェクト: gijs/inasafe
    def test_windowsDrawingArtifacts(self):
        """Test that windows rendering does not make artifacts"""
        # sometimes spurious lines are drawn on the layout
        LOGGER.info('Testing windowsDrawingArtifacts')
        myPath = unique_filename(prefix='artifacts',
                                 suffix='.pdf',
                                 dir=temp_dir('test'))
        myMap = Map(IFACE)
        setupPrinter(myPath)
        myMap.setupComposition()

        myImage = QtGui.QImage(10, 10, QtGui.QImage.Format_RGB32)
        myImage.setDotsPerMeterX(dpiToMeters(300))
        myImage.setDotsPerMeterY(dpiToMeters(300))
        #myImage.fill(QtGui.QColor(250, 250, 250))
        # Look at the output, you will see antialiasing issues around some
        # of the boxes drawn...
        # myImage.fill(QtGui.QColor(200, 200, 200))
        myImage.fill(200 + 200 * 256 + 200 * 256 * 256)
        myFilename = os.path.join(temp_dir(), 'greyBox')
        myImage.save(myFilename, 'PNG')
        for i in range(10, 190, 10):
            myPicture = QgsComposerPicture(myMap.composition)
            myPicture.setPictureFile(myFilename)
            if qgisVersion() >= 10800:  # 1.8 or newer
                myPicture.setFrameEnabled(False)
            else:
                myPicture.setFrame(False)
            myPicture.setItemPosition(i,  # x
                                      i,  # y
                                      10,  # width
                                      10)  # height
            myMap.composition.addItem(myPicture)
            # Same drawing drawn directly as a pixmap
            myPixmapItem = myMap.composition.addPixmap(
                QtGui.QPixmap.fromImage(myImage))
            myPixmapItem.setOffset(i, i + 20)
            # Same drawing using our drawImage Helper
            myWidthMM = 1
            myMap.drawImage(myImage, myWidthMM, i, i + 40)

        myImagePath, _, _ = myMap.renderComposition()
        # when this test no longer matches our broken render hash
        # we know the issue is fixed

        myControlImages = ['windowsArtifacts.png']
        myTolerance = 0
        myFlag, myMessage = checkImages(myControlImages,
                                        myImagePath,
                                        myTolerance)
        myMessage += ('\nWe want these images to match, if they do not '
                      'there may be rendering artifacts in windows.\n')
        assert myFlag, myMessage
コード例 #16
0
ファイル: test_map.py プロジェクト: rlbartolome/inasafe
    def test_renderComposition(self):
        """Test making an image of the map only."""
        LOGGER.info('Testing renderComposition')
        myLayer, _ = loadLayer('test_shakeimpact.shp')
        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])

        myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
        CANVAS.setExtent(myRect)
        CANVAS.refresh()
        myMap = Map(IFACE)
        myMap.setImpactLayer(myLayer)
        myMap.composeMap()
        myImagePath, myControlImage, myTargetArea = myMap.renderComposition()
        LOGGER.debug(myImagePath)

        assert myControlImage is not None

        myDimensions = [myTargetArea.left(),
                        myTargetArea.top(),
                        myTargetArea.bottom(),
                        myTargetArea.right()]
        myExpectedDimensions = [0.0, 0.0, 3507.0, 2480.0]
        myMessage = 'Expected target area to be %s, got %s' % (
            str(myExpectedDimensions), str(myDimensions))
        assert myExpectedDimensions == myDimensions, myMessage

        myMessage = 'Rendered output does not exist'
        assert os.path.exists(myImagePath), myMessage

        myAcceptableImages = [
            'renderComposition.png',
            'renderComposition-variantUB12.04.png',
            'renderComposition-variantUB12.10.png',
            'renderComposition-variantOSXml.png',
            'renderComposition-variantWindowsVistaSP2-32.png',
            'renderComposition-variantJenkins.png',
            'renderComposition-variantUB11.10-64.png',
            'renderComposition-variantLinuxMint-14-x86_64.png',
            'renderComposition-variantWindows7-SP1-AMD64.png',
            'renderComposition-variantUB11.04-64.png']
        # Beta version and version changes  can introduce a few extra chars
        # into the metadata section so we set a reasonable tolerance to cope
        # with this.
        myTolerance = 8000
        print myImagePath
        print myAcceptableImages
        myFlag, myMessage = checkImages(myAcceptableImages,
                                        myImagePath,
                                        myTolerance)
        assert myFlag, myMessage
コード例 #17
0
ファイル: test_map.py プロジェクト: zzpwelkin/inasafe
    def test_renderComposition(self):
        """Test making an image of the map only."""
        LOGGER.info('Testing renderComposition')
        myLayer, _ = loadLayer('test_shakeimpact.shp')
        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])

        myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
        CANVAS.setExtent(myRect)
        CANVAS.refresh()
        myMap = Map(IFACE)
        myMap.setImpactLayer(myLayer)
        myMap.composeMap()
        myImagePath, myControlImage, myTargetArea = myMap.renderComposition()
        LOGGER.debug(myImagePath)

        assert myControlImage is not None

        myDimensions = [
            myTargetArea.left(),
            myTargetArea.top(),
            myTargetArea.bottom(),
            myTargetArea.right()
        ]
        myExpectedDimensions = [0.0, 0.0, 3507.0, 2480.0]
        myMessage = 'Expected target area to be %s, got %s' % (
            str(myExpectedDimensions), str(myDimensions))
        assert myExpectedDimensions == myDimensions, myMessage

        myMessage = 'Rendered output does not exist'
        assert os.path.exists(myImagePath), myMessage

        myAcceptableImages = [
            'renderComposition.png', 'renderComposition-variantUB12.04.png',
            'renderComposition-variantWindosVistaSP2-32.png',
            'renderComposition-variantJenkins.png',
            'renderComposition-variantUB11.10-64.png',
            'renderComposition-variantUB11.04-64.png'
        ]
        # Beta version and version changes  can introduce a few extra chars
        # into the metadata section so we set a reasonable tolerance to cope
        # with this.
        myTolerance = 8000
        myFlag, myMessage = checkImages(myAcceptableImages, myImagePath,
                                        myTolerance)
        assert myFlag, myMessage
コード例 #18
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 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)
コード例 #19
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
    def test_renderTemplate(self):
        """Test that load template works"""
        #Use the template from our resources bundle
        myInPath = ':/plugins/inasafe/basic.qpt'
        myLayer, myType = loadLayer('test_shakeimpact.shp')
        del myType

        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])
        myMap = Map(IFACE)
        setJakartaGeoExtent()
        myMap.setImpactLayer(myLayer)
        myOutPath = os.path.join(temp_dir(), 'outTemplate.pdf')
        if os.path.exists(myOutPath):
            os.remove(myOutPath)
        myMap.renderTemplate(myInPath, myOutPath)
        assert os.path.exists(myOutPath)
コード例 #20
0
ファイル: test_map.py プロジェクト: maning/inasafe
    def Xtest_renderTemplate(self):
        """Test that load template works"""
        #Use the template from our resources bundle
        myInPath = ':/plugins/inasafe/basic.qpt'
        myLayer, _ = loadLayer('test_shakeimpact.shp')

        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])
        myMap = Map(IFACE)
        setJakartaGeoExtent()
        myMap.setImpactLayer(myLayer)
        myPath = unique_filename(prefix='outTemplate',
                                 suffix='.pdf',
                                 dir=temp_dir('test'))
        LOGGER.debug(myPath)
        myMap.renderTemplate(myInPath, myPath)
        assert os.path.exists(myPath)
コード例 #21
0
ファイル: test_map.py プロジェクト: ingenieroariel/inasafe
 def test_getRasterLegend(self):
     """Getting a legend for a raster layer works."""
     myLayer, myType = loadLayer('test_floodimpact.tif')
     del myType
     myMap = Map(IFACE)
     myMap.setImpactLayer(myLayer)
     myMap.getRasterLegend()
     myPath = os.path.join(temp_dir(), '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.04-64
                         'b68ccc328de852f0c66b8abe43eab3da',  # ub12.04
                         'cd5fb96f6c5926085d251400dd3b4928',  # ub12.04 xvfb
                         'a654d0dcb6b6d14b0a7a62cd979c16b9',  # ub12.04-64
                         # ub11.04-64 laptop
                         '9692ba8dbf909b8fe3ed27a8f4924b78',  # binary read
                         '5f4ef033bb1d6f36af4c08db55ca63be',  # wVistaSP2-32
                         '',
                         ]
     assertHashesForFile(myExpectedHashes, myPath)