Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update more expected test results
While these results are very different to the previous reference values,
the geometries measured are extremely narrow polygons which range
from ~-45 to ~45 degrees latitude, and accordingly large variations
are expected depending on the area/length measurement formula
used.

Results have been checked against the R geosphere library and
PostGIS geography type measurements, and match the measurements
calculated using those packages (which are also based on GeographicLib
calculations).
  • Loading branch information
nyalldawson committed Feb 25, 2021
1 parent 686b199 commit c3f538e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/src/core/testqgsdistancearea.cpp
Expand Up @@ -235,17 +235,29 @@ void TestQgsDistanceArea::collections()
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );

//collection of polygons

QgsGeometry poly1 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53))" ) );
result = myDa.measureArea( poly1 );
QGSCOMPARENEAR( result, 439881520607.079712, 1 );
result = myDa.measureLength( poly1 );
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );
QgsGeometry poly2 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((10 20, 15 20, 15 10, 10 20))" ) );
result = myDa.measureArea( poly2 );
QGSCOMPARENEAR( result, 290350317025.906982, 1 );
result = myDa.measureLength( poly2 );
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );

QgsGeometry polys( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ).release() );
result = myDa.measureArea( polys );
QGSCOMPARENEAR( result, 663136985074LL, 1 );
QGSCOMPARENEAR( result, 730231837632.98669, 1 );
result = myDa.measureLength( polys );
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );

//mixed collection
QgsGeometry mixed( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70), Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ).release() );
//measure area specifically
result = myDa.measureArea( mixed );
QGSCOMPARENEAR( result, 663136985075LL, 1 );
QGSCOMPARENEAR( result, 730231837632.98669, 1 );
//measure length
result = myDa.measureLength( mixed );
QGSCOMPARENEAR( result, 12006159, 1 );
Expand Down

0 comments on commit c3f538e

Please sign in to comment.