Skip to content
Permalink
Browse files

Fix tests

  • Loading branch information
m-kuhn committed Jun 14, 2017
1 parent 21dae49 commit 37a306e3f273a12f313b0e6339a82287877c8844
@@ -126,6 +126,7 @@ class QgsPoint: QgsAbstractGeometry




void setX( double x );
%Docstring
Sets the point's x-coordinate.
@@ -957,8 +957,8 @@ QgsPoint QgsGeometryUtils::midpoint( const QgsPoint &pt1, const QgsPoint &pt2 )

double x = ( pt1.x() + pt2.x() ) / 2.0;
double y = ( pt1.y() + pt2.y() ) / 2.0;
double z = 0.0;
double m = 0.0;
double z = std::numeric_limits<double>::quiet_NaN();
double m = std::numeric_limits<double>::quiet_NaN();

if ( pt1.is3D() || pt2.is3D() )
{
@@ -816,7 +816,7 @@ class TestQgsExpression: public QObject
QTest::newRow( "project x" ) << "toint(x(project( make_point( 1, 2 ), 3, radians(270)))*1000000)" << false << QVariant( -2 * 1000000 );
QTest::newRow( "project y" ) << "toint(y(project( point:=make_point( 1, 2 ), distance:=3, azimuth:=radians(270)))*1000000)" << false << QVariant( 2 * 1000000 );
QTest::newRow( "project m value preserved" ) << "geom_to_wkt(project( make_point( 1, 2, 2, 5), 1, 0.0, 0.0 ) )" << false << QVariant( "PointZM (1 2 3 5)" );
QTest::newRow( "project 2D Point" ) << "geom_to_wkt(project( point:=make_point( 1, 2), distance:=1, azimuth:=radians(0), elevation:=0 ) )" << false << QVariant( "PointZ (1 2 1)" );
QTest::newRow( "project 2D Point" ) << "geom_to_wkt(project( point:=make_point( 1, 2), distance:=1, azimuth:=radians(0), elevation:=0 ) )" << false << QVariant( "PointZ (1 2 nan)" );
QTest::newRow( "project 3D Point" ) << "geom_to_wkt(project( make_point( 1, 2, 2), 5, radians(450), radians (450) ) )" << false << QVariant( "PointZ (6 2 2)" );
QTest::newRow( "inclination not geom first" ) << "inclination( 'a', make_point( 1, 2, 2 ) )" << true << QVariant();
QTest::newRow( "inclination not geom second" ) << " inclination( make_point( 1, 2, 2 ), 'a' )" << true << QVariant();
@@ -547,9 +547,9 @@ void TestQgsGeometryUtils::testMidPoint()
{
QgsPoint p1( 4, 6 );
QCOMPARE( QgsGeometryUtils::midpoint( p1, QgsPoint( 2, 2 ) ), QgsPoint( 3, 4 ) );
QCOMPARE( QgsGeometryUtils::midpoint( p1, QgsPoint( QgsWkbTypes::PointZ, 2, 2, 2 ) ), QgsPoint( QgsWkbTypes::PointZ, 3, 4, 1 ) );
QCOMPARE( QgsGeometryUtils::midpoint( p1, QgsPoint( QgsWkbTypes::PointM, 2, 2, 0, 2 ) ), QgsPoint( QgsWkbTypes::PointM, 3, 4, 0, 1 ) );
QCOMPARE( QgsGeometryUtils::midpoint( p1, QgsPoint( QgsWkbTypes::PointZM, 2, 2, 2, 2 ) ), QgsPoint( QgsWkbTypes::PointZM, 3, 4, 1, 1 ) );
QCOMPARE( QgsGeometryUtils::midpoint( QgsPoint( 4, 6, 0 ), QgsPoint( QgsWkbTypes::PointZ, 2, 2, 2 ) ), QgsPoint( QgsWkbTypes::PointZ, 3, 4, 1 ) );
QCOMPARE( QgsGeometryUtils::midpoint( QgsPoint( QgsWkbTypes::PointM, 4, 6, 0, 0 ), QgsPoint( QgsWkbTypes::PointM, 2, 2, 0, 2 ) ), QgsPoint( QgsWkbTypes::PointM, 3, 4, 0, 1 ) );
QCOMPARE( QgsGeometryUtils::midpoint( QgsPoint( QgsWkbTypes::PointZM, 4, 6, 0, 0 ), QgsPoint( QgsWkbTypes::PointZM, 2, 2, 2, 2 ) ), QgsPoint( QgsWkbTypes::PointZM, 3, 4, 1, 1 ) );
}

void TestQgsGeometryUtils::testGradient()
@@ -98,10 +98,10 @@ Point( 1 2 3 4 ),PointZM( 1 2 3 4 ),1,0,0,0,1,0,0,Point( 1 2 ),1,2,1,2,"4d coord
PointM( 4 5 6 ),PointM ( 4 5 6 ),1,0,0,0,1,0,0,POINT(4 5),4,5,4,5,
PointZ (1 2 3),POINT Z (1 2 3),1,0,0,0,1,0,0,POINT(1 2),1,2,1,2,
PointZM( 7 8 9 10 ),PointZM( 7 8 9 10 ),1,0,0,0,1,0,0,POINT( 7 8 ),7,8,7,8,
PointZ( 1 2 ),PointZ( 1 2 0 ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No z coordinate specified, set to 0"
PointM( 1 2 ),PointM( 1 2 0 ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No m value specified, set to 0"
PointZM( 1 2 ),PointZM( 1 2 0 0 ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No z or m value specified, set to 0"
PointZM( 1 2 3 ),PointZM( 1 2 3 0 ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No m value specified, set to 0"
PointZ( 1 2 ),PointZ( 1 2 nan ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No z coordinate specified, set to nan"
PointM( 1 2 ),PointM( 1 2 nan ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No m value specified, set to nan"
PointZM( 1 2 ),PointZM( 1 2 nan nan ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No z or m value specified, set to nan"
PointZM( 1 2 3 ),PointZM( 1 2 3 nan ),1,0,0,0,1,0,0,Point(1 2),1,2,1,2,"No m value specified, set to nan"
Polygon(),,,,,,,,,,,,,,Malformed WKT
Polygon,,,,,,,,,,,,,,Malformed WKT
"Polygon ((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1))","POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5),(1 1,2 1,2 2,1 2,1 1))",15,0,95,52,1,2,0,POINT(4.99473684210526 4.99473684210526),0,0,10,10,

0 comments on commit 37a306e

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