Skip to content

Commit

Permalink
Update expected test results
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 3, 2018
1 parent 297dbe0 commit 14b6843
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tests/src/app/testqgsattributetable.cpp
Expand Up @@ -160,7 +160,7 @@ void TestQgsAttributeTable::testFieldCalculationArea()
QgsFeatureIterator fit = tempLayer->dataProvider()->getFeatures();
QgsFeature f;
QVERIFY( fit.nextFeature( f ) );
double expected = 1009089817.0;
double expected = 1005721496.78008;
QGSCOMPARENEAR( f.attribute( "col1" ).toDouble(), expected, 1.0 );

// change project area unit, check calculation respects unit
Expand All @@ -172,7 +172,7 @@ void TestQgsAttributeTable::testFieldCalculationArea()
// check result
fit = tempLayer->dataProvider()->getFeatures();
QVERIFY( fit.nextFeature( f ) );
expected = 389.6117565069;
expected = 388.311240;
QGSCOMPARENEAR( f.attribute( "col1" ).toDouble(), expected, 0.001 );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/app/testqgsfieldcalculator.cpp
Expand Up @@ -164,7 +164,7 @@ void TestQgsFieldCalculator::testAreaCalculations()
QgsFeatureIterator fit = tempLayer->dataProvider()->getFeatures();
QgsFeature f;
QVERIFY( fit.nextFeature( f ) );
double expected = 1009089817.0;
double expected = 1005721496.780080;
QGSCOMPARENEAR( f.attribute( "col1" ).toDouble(), expected, 1.0 );

// change project area unit, check calculation respects unit
Expand All @@ -179,7 +179,7 @@ void TestQgsFieldCalculator::testAreaCalculations()
// check result
fit = tempLayer->dataProvider()->getFeatures();
QVERIFY( fit.nextFeature( f ) );
expected = 389.6117565069;
expected = 388.311240;
QGSCOMPARENEAR( f.attribute( "col1" ).toDouble(), expected, 0.001 );
}

Expand Down
6 changes: 3 additions & 3 deletions tests/src/app/testqgsmaptoolidentifyaction.cpp
Expand Up @@ -449,7 +449,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation()
QCOMPARE( result.length(), 1 );
QString derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Ellipsoidal, WGS84)" )];
double area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
QGSCOMPARENEAR( area, 1009089817.0, 1.0 );
QGSCOMPARENEAR( area, 1005721496.780000, 1.0 );
derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Cartesian)" )];
area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
QGSCOMPARENEAR( area, 1005640568.0, 1.0 );
Expand All @@ -460,7 +460,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation()
QCOMPARE( result.length(), 1 );
derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Ellipsoidal, WGS84)" )];
area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
QGSCOMPARENEAR( area, 389.6117, 0.001 );
QGSCOMPARENEAR( area, 388.311000, 0.001 );
derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Cartesian)" )];
area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
QGSCOMPARENEAR( area, 388.280000, 0.001 );
Expand All @@ -472,7 +472,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation()
QCOMPARE( result.length(), 1 );
derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Ellipsoidal, WGS84)" )];
area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
QGSCOMPARENEAR( area, 389.6117, 0.001 );
QGSCOMPARENEAR( area, 388.311000, 0.001 );
derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Cartesian)" )];
area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
QGSCOMPARENEAR( area, 388.280000, 0.001 );
Expand Down
4 changes: 2 additions & 2 deletions tests/src/app/testqgsmeasuretool.cpp
Expand Up @@ -200,7 +200,7 @@ void TestQgsMeasureTool::testAreaCalculation()
// check result
QString measureString = dlg->editTotal->text();
double measured = measureString.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
double expected = 1009089817.0;
double expected = 1005721496.780000;
QGSCOMPARENEAR( measured, expected, 1.0 );

// change project area unit, check calculation respects unit
Expand All @@ -219,7 +219,7 @@ void TestQgsMeasureTool::testAreaCalculation()
// check result
measureString = dlg2->editTotal->text();
measured = measureString.remove( ',' ).split( ' ' ).at( 0 ).toDouble();
expected = 389.6117565069;
expected = 388.311000;
QGSCOMPARENEAR( measured, expected, 0.001 );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -2209,7 +2209,7 @@ class TestQgsExpression: public QObject
QgsExpression expArea2( QStringLiteral( "$area" ) );
expArea2.setGeomCalculator( &da );
vArea = expArea2.evaluate( &context );
expected = 1009089817.0;
expected = 1005721496.780085;
QGSCOMPARENEAR( vArea.toDouble(), expected, 1.0 );
// test unit conversion
expArea2.setAreaUnits( QgsUnitTypes::AreaSquareMeters ); //default units should be square meters
Expand All @@ -2219,7 +2219,7 @@ class TestQgsExpression: public QObject
vArea = expArea2.evaluate( &context );
QGSCOMPARENEAR( vArea.toDouble(), expected, 1.0 );
expArea2.setAreaUnits( QgsUnitTypes::AreaSquareMiles );
expected = 389.6117565069;
expected = 388.311241;
vArea = expArea2.evaluate( &context );
QGSCOMPARENEAR( vArea.toDouble(), expected, 0.001 );

Expand Down
8 changes: 4 additions & 4 deletions tests/src/python/test_qgsdistancearea.py
Expand Up @@ -551,12 +551,12 @@ def testAreaMeasureAndUnits(self):

print(("measured {} in {}".format(area, QgsUnitTypes.toString(units))))
# should always be in Meters Squared
self.assertAlmostEqual(area, 37416879192.9, delta=0.1)
self.assertAlmostEqual(area, 36918093794.121284, delta=0.1)
self.assertEqual(units, QgsUnitTypes.AreaSquareMeters)

# test converting the resultant area
area = da.convertAreaMeasurement(area, QgsUnitTypes.AreaSquareMiles)
self.assertAlmostEqual(area, 14446.7378, delta=0.001)
self.assertAlmostEqual(area, 14254.155703182701, delta=0.001)

# now try with a source CRS which is in feet
polygon = QgsGeometry.fromPolygonXY(
Expand All @@ -582,12 +582,12 @@ def testAreaMeasureAndUnits(self):
area = da.measureArea(polygon)
units = da.areaUnits()
print(("measured {} in {}".format(area, QgsUnitTypes.toString(units))))
self.assertAlmostEqual(area, 184149.37, delta=1.0)
self.assertAlmostEqual(area, 185818.59096575077, delta=1.0)
self.assertEqual(units, QgsUnitTypes.AreaSquareMeters)

# test converting the resultant area
area = da.convertAreaMeasurement(area, QgsUnitTypes.AreaSquareYards)
self.assertAlmostEqual(area, 220240.8172549, delta=1.0)
self.assertAlmostEqual(area, 222237.18521272976, delta=1.0)

def testFormatDistance(self):
"""Test formatting distances"""
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsvectorlayer.py
Expand Up @@ -1894,13 +1894,13 @@ def test_ExpressionFieldEllipsoidAreaCalculation(self):

# check value
f = next(temp_layer.getFeatures())
expected = 1009089817.0
expected = 1005721496.7800847
self.assertAlmostEqual(f['area'], expected, delta=1.0)

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

def test_ExpressionFilter(self):
Expand Down

0 comments on commit 14b6843

Please sign in to comment.