Skip to content
Permalink
Browse files
Fix tests
  • Loading branch information
nyalldawson committed Jan 22, 2017
1 parent 46f2ea1 commit 4a800a13c2ffa23ee3c9300647a2fd29a39480f4
@@ -44,7 +44,7 @@
import struct
import glob

dash_url = 'http://dash.orfeo-toolbox.org'
dash_url = 'https://dash.orfeo-toolbox.org'


def error(msg):
@@ -61,7 +61,7 @@ def colorDiff(c1, c2):


def imageFromPath(path):
if (path[:7] == 'http://' or path[:7] == 'file://'):
if (path[:7] == 'https://' or path[:7] == 'file://'):
# fetch remote image
data = urllib.request.urlopen(path).read()
image = QImage()
@@ -181,7 +181,7 @@ def load_images(self, control_image_path, rendered_image_path, mask_image_path):
),
self.rendered_image.width(
),
self.rendered_image.height()))
self.rendered_image.height()))

max_width = min(
self.rendered_image.width(), self.control_image.width())
@@ -53,43 +53,6 @@ def testEncodeDecodePoint(self):
s2 = QgsSymbolLayerUtils.decodePoint('')
self.assertEqual(s2, QPointF())

def testConvertToMapUnits(self):
# test QgsSymbolLayerUtils::convertToMapUnits() without QgsMapUnitScale

ms = QgsMapSettings()
ms.setExtent(QgsRectangle(0, 0, 100, 100))
ms.setOutputSize(QSize(100, 50))
ms.setOutputDpi(300)
r = QgsRenderContext.fromMapSettings(ms)

# renderer scale should be about 1:291937841
size = QgsSymbolLayerUtils.convertToMapUnits(r, 2, QgsUnitTypes.RenderMapUnits)
self.assertEqual(size, 2.0)
size = QgsSymbolLayerUtils.convertToMapUnits(r, 2, QgsUnitTypes.RenderMillimeters)
self.assertAlmostEqual(size, 47.244094, places=5)
size = QgsSymbolLayerUtils.convertToMapUnits(r, 5.66929, QgsUnitTypes.RenderPoints)
self.assertAlmostEqual(size, 47.2440833, places=5)
size = QgsSymbolLayerUtils.convertToMapUnits(r, 2, QgsUnitTypes.RenderPixels)
self.assertAlmostEqual(size, 4.0, places=5)

def testConvertFromMapUnits(self):
# test QgsSymbolLayerUtils::convertToMapUnits() without QgsMapUnitScale

ms = QgsMapSettings()
ms.setExtent(QgsRectangle(0, 0, 100, 100))
ms.setOutputSize(QSize(100, 50))
ms.setOutputDpi(300)
r = QgsRenderContext.fromMapSettings(ms)

# renderer scale should be about 1:291937841
size = QgsSymbolLayerUtils.convertFromMapUnits(r, 2, QgsUnitTypes.RenderMapUnits)
self.assertEqual(size, 2.0)
size = QgsSymbolLayerUtils.convertFromMapUnits(r, 50, QgsUnitTypes.RenderMillimeters)
self.assertAlmostEqual(size, 2.1166666666, places=5)
size = QgsSymbolLayerUtils.convertFromMapUnits(r, 50, QgsUnitTypes.RenderPoints)
self.assertAlmostEqual(size, 6.0000000015, places=5)
size = QgsSymbolLayerUtils.convertFromMapUnits(r, 4, QgsUnitTypes.RenderPixels)
self.assertAlmostEqual(size, 2.0, places=5)

if __name__ == '__main__':
unittest.main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 4a800a1

Please sign in to comment.