Skip to content
Permalink
Browse files

Fix failing test

  • Loading branch information
nyalldawson committed Mar 14, 2017
1 parent 0afc88e commit 730d10a153b9cd0fc8ddc098918425e327ea037e
Showing with 8 additions and 12 deletions.
  1. +8 −12 tests/src/python/test_qgsvectorlayer.py
@@ -1495,11 +1495,9 @@ def test_ExpressionFieldEllipsoidLengthCalculation(self):

# set project CRS and ellipsoid
srs = QgsCoordinateReferenceSystem(3111, QgsCoordinateReferenceSystem.EpsgCrsId)
QgsProject.instance().writeEntry("SpatialRefSys", "/ProjectCRSProj4String", srs.toProj4())
QgsProject.instance().writeEntry("SpatialRefSys", "/ProjectCRSID", srs.srsid())
QgsProject.instance().writeEntry("SpatialRefSys", "/ProjectCrs", srs.authid())
QgsProject.instance().writeEntry("Measure", "/Ellipsoid", "WGS84")
QgsProject.instance().writeEntry("Measurement", "/DistanceUnits", QgsUnitTypes.encodeUnit(QgsUnitTypes.DistanceMeters))
QgsProject.instance().setCrs(srs)
QgsProject.instance().setEllipsoid("WGS84")
QgsProject.instance().setDistanceUnits(QgsUnitTypes.DistanceMeters)

idx = temp_layer.addExpressionField('$length', QgsField('length', QVariant.Double)) # NOQA

@@ -1509,7 +1507,7 @@ def test_ExpressionFieldEllipsoidLengthCalculation(self):
self.assertAlmostEqual(f['length'], expected, 3)

# change project length unit, check calculation respects unit
QgsProject.instance().writeEntry("Measurement", "/DistanceUnits", QgsUnitTypes.encodeUnit(QgsUnitTypes.DistanceFeet))
QgsProject.instance().setDistanceUnits(QgsUnitTypes.DistanceFeet)
f = next(temp_layer.getFeatures())
expected = 88360.0918635
self.assertAlmostEqual(f['length'], expected, 3)
@@ -1525,11 +1523,9 @@ def test_ExpressionFieldEllipsoidAreaCalculation(self):

# set project CRS and ellipsoid
srs = QgsCoordinateReferenceSystem(3111, QgsCoordinateReferenceSystem.EpsgCrsId)
QgsProject.instance().writeEntry("SpatialRefSys", "/ProjectCRSProj4String", srs.toProj4())
QgsProject.instance().writeEntry("SpatialRefSys", "/ProjectCRSID", srs.srsid())
QgsProject.instance().writeEntry("SpatialRefSys", "/ProjectCrs", srs.authid())
QgsProject.instance().writeEntry("Measure", "/Ellipsoid", "WGS84")
QgsProject.instance().writeEntry("Measurement", "/AreaUnits", QgsUnitTypes.encodeUnit(QgsUnitTypes.AreaSquareMeters))
QgsProject.instance().setCrs(srs)
QgsProject.instance().setEllipsoid("WGS84")
QgsProject.instance().setAreaUnits(QgsUnitTypes.AreaSquareMeters)

idx = temp_layer.addExpressionField('$area', QgsField('area', QVariant.Double)) # NOQA

@@ -1539,7 +1535,7 @@ def test_ExpressionFieldEllipsoidAreaCalculation(self):
self.assertAlmostEqual(f['area'], expected, delta=1.0)

# change project area unit, check calculation respects unit
QgsProject.instance().writeEntry("Measurement", "/AreaUnits", QgsUnitTypes.encodeUnit(QgsUnitTypes.AreaSquareMiles))
QgsProject.instance().setAreaUnits(QgsUnitTypes.AreaSquareMiles)
f = next(temp_layer.getFeatures())
expected = 389.6117565069
self.assertAlmostEqual(f['area'], expected, 3)

0 comments on commit 730d10a

Please sign in to comment.
You can’t perform that action at this time.