Skip to content
Permalink
Browse files

Update expected test results

  • Loading branch information
nyalldawson committed Oct 2, 2018
1 parent 297dbe0 commit 14b6843293126123c96676bf3b0875b4145ce0ab
@@ -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
@@ -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 );
}

@@ -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
@@ -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 );
}

@@ -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 );
@@ -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 );
@@ -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 );
@@ -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
@@ -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 );
}

@@ -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
@@ -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 );

@@ -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(
@@ -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"""
@@ -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):

0 comments on commit 14b6843

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