@@ -449,6 +449,18 @@ class TestQgsExpression: public QObject
449
449
QTest::newRow ( " reverse point" ) << " reverse(geom_from_wkt('POINT(1 2)'))" << false << QVariant ();
450
450
QTest::newRow ( " reverse polygon" ) << " reverse(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))'))" << false << QVariant ();
451
451
QTest::newRow ( " reverse line" ) << " geom_to_wkt(reverse(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)')))" << false << QVariant ( " LineString (2 2, 1 1, 0 0)" );
452
+ QTest::newRow ( " centroid polygon" ) << " geom_to_wkt(centroid( geomFromWKT('POLYGON((0 0,0 9,9 0,0 0))')))" << false << QVariant ( " Point (3 3)" );
453
+ QTest::newRow ( " centroid multi polygon" ) << " geom_to_wkt(centroid( geomFromWKT('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((2 0,2 1,3 1,3 0,2 0)))') ))" << false << QVariant ( " Point (1.5 0.5)" );
454
+ QTest::newRow ( " centroid point" ) << " geom_to_wkt(centroid( geomFromWKT('POINT (1.5 0.5)') ))" << false << QVariant ( " Point (1.5 0.5)" );
455
+ QTest::newRow ( " centroid line" ) << " geom_to_wkt(centroid( geomFromWKT('LINESTRING (-1 2, 9 12)') ))" << false << QVariant ( " Point (4 7)" );
456
+ QTest::newRow ( " centroid not geom" ) << " centroid('g')" << true << QVariant ();
457
+ QTest::newRow ( " centroid null" ) << " centroid(NULL)" << false << QVariant ();
458
+ QTest::newRow ( " point on surface polygon" ) << " geom_to_wkt(point_on_surface( geomFromWKT('POLYGON((0 0,0 9,9 0,0 0))')))" << false << QVariant ( " Point (2.25 4.5)" );
459
+ QTest::newRow ( " point on surface multi polygon" ) << " geom_to_wkt(point_on_surface( geomFromWKT('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((2 0,2 1,3 1,3 0,2 0)))') ))" << false << QVariant ( " Point (0.5 0.5)" );
460
+ QTest::newRow ( " point on surface point" ) << " geom_to_wkt(point_on_surface( geomFromWKT('POINT (1.5 0.5)') ))" << false << QVariant ( " Point (1.5 0.5)" );
461
+ QTest::newRow ( " point on surface line" ) << " geom_to_wkt(point_on_surface( geomFromWKT('LINESTRING (-1 2, 9 12)') ))" << false << QVariant ( " Point (-1 2)" );
462
+ QTest::newRow ( " point on surface not geom" ) << " point_on_surface('g')" << true << QVariant ();
463
+ QTest::newRow ( " point on surface null" ) << " point_on_surface(NULL)" << false << QVariant ();
452
464
QTest::newRow ( " make_point" ) << " geom_to_wkt(make_point(2.2,4.4))" << false << QVariant ( " Point (2.2 4.4)" );
453
465
QTest::newRow ( " make_point z" ) << " geom_to_wkt(make_point(2.2,4.4,5.5))" << false << QVariant ( " PointZ (2.2 4.4 5.5)" );
454
466
QTest::newRow ( " make_point zm" ) << " geom_to_wkt(make_point(2.2,4.4,5.5,6.6))" << false << QVariant ( " PointZM (2.2 4.4 5.5 6.6)" );
@@ -1459,10 +1471,6 @@ class TestQgsExpression: public QObject
1459
1471
geom = QgsGeometry::fromPolygon ( polygon );
1460
1472
QTest::newRow ( " symDifference" ) << " symDifference( $geometry, geomFromWKT('POLYGON((0 0, 0 10, 10 0, 0 0))') )" << ( void * ) geom << false << true << ( void * ) QgsGeometry::fromWkt ( " MULTIPOLYGON(((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))" );
1461
1473
1462
- geom = QgsGeometry::fromPolygon ( polygon );
1463
- QTest::newRow ( " centroid polygon" ) << " centroid( $geometry )" << ( void * ) geom << false << true << ( void * ) geom->centroid ();
1464
- geom = QgsGeometry::fromPolygon ( polygon );
1465
- QTest::newRow ( " centroid multi polygon" ) << " centroid( geomFromWKT('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((2 0,2 1,3 1,3 0,2 0)))') )" << ( void * ) geom << false << false << ( void * ) QgsGeometry::fromWkt ( " POINT (1.5 0.5)" );
1466
1474
geom = QgsGeometry::fromPolygon ( polygon );
1467
1475
QTest::newRow ( " convexHull simple" ) << " convexHull( $geometry )" << ( void * ) geom << false << true << ( void * ) geom->convexHull ();
1468
1476
geom = QgsGeometry::fromPolygon ( polygon );
0 commit comments