mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-03 00:04:47 -04:00
[test] Fix test for main angle expression function and fix python test for Oriented Minimum Bounding Box; address review: change 'a' by 'an' in corresponding processing help
This commit is contained in:
parent
6a288cf912
commit
9c9aa62fb4
@ -57,7 +57,7 @@ Qgis::WkbType QgsOrientedMinimumBoundingBoxAlgorithm::outputWkbType( Qgis::WkbTy
|
||||
|
||||
QString QgsOrientedMinimumBoundingBoxAlgorithm::shortHelpString() const
|
||||
{
|
||||
return QObject::tr( "This algorithm calculates the minimum area rotated rectangle which covers each feature in an input layer." ) + QStringLiteral( "\n\n" ) + QObject::tr( "For singlepart point features, the output corresponds to the bounding box of the geometry." ) + QStringLiteral( "\n\n" ) + QObject::tr( "See the 'Minimum bounding geometry' algorithm for a oriented bounding box calculation which covers the whole layer or grouped subsets of features." );
|
||||
return QObject::tr( "This algorithm calculates the minimum area rotated rectangle which covers each feature in an input layer." ) + QStringLiteral( "\n\n" ) + QObject::tr( "For singlepart point features, the output corresponds to the bounding box of the geometry." ) + QStringLiteral( "\n\n" ) + QObject::tr( "See the 'Minimum bounding geometry' algorithm for an oriented bounding box calculation which covers the whole layer or grouped subsets of features." );
|
||||
}
|
||||
|
||||
QString QgsOrientedMinimumBoundingBoxAlgorithm::shortDescription() const
|
||||
|
@ -1755,7 +1755,7 @@ class TestQgsExpression : public QObject
|
||||
QTest::newRow( "main angle polygon" ) << "round(main_angle( geom_from_wkt('POLYGON((0 0,2 9,9 2,0 0))')))" << false << QVariant( 77 );
|
||||
QTest::newRow( "main angle polygon edge case" ) << "round(main_angle( geom_from_wkt('POLYGON((353542.63843526 378974.92373469, 353544.95808017 378975.73690545, 353545.27173175 378974.84218528, 353542.95208684 378974.02901451, 353542.63843526 378974.92373469))')))" << false << QVariant( 71 );
|
||||
QTest::newRow( "main angle multi polygon" ) << "round(main_angle( geom_from_wkt('MULTIPOLYGON(((0 0,3 10,1 10,1 6,0 0)))')))" << false << QVariant( 17 );
|
||||
QTest::newRow( "main angle point" ) << "main_angle( geom_from_wkt('POINT (1.5 0.5)') )" << true << QVariant();
|
||||
QTest::newRow( "main angle point" ) << "main_angle( geom_from_wkt('POINT (1.5 0.5)') )" << false << QVariant( 0.0 );
|
||||
QTest::newRow( "main angle line" ) << "round(main_angle( geom_from_wkt('LINESTRING (-1 2, 9 12)') ))" << false << QVariant( 45 );
|
||||
QTest::newRow( "main angle not geom" ) << "main_angle('g')" << true << QVariant();
|
||||
QTest::newRow( "main angle null" ) << "main_angle(NULL)" << false << QVariant();
|
||||
|
@ -10235,10 +10235,20 @@ class TestQgsGeometry(QgisTestCase):
|
||||
bbox, area, angle, width, height = empty.orientedMinimumBoundingBox()
|
||||
self.assertFalse(bbox)
|
||||
|
||||
# not a useful geometry
|
||||
# Special case: singlepart point geometry
|
||||
point = QgsGeometry.fromWkt("Point(1 2)")
|
||||
bbox, area, angle, width, height = point.orientedMinimumBoundingBox()
|
||||
self.assertFalse(bbox)
|
||||
exp = "Polygon ((1 2, 1 2, 1 2, 1 2, 1 2))"
|
||||
result = bbox.asWkt(2)
|
||||
|
||||
self.assertTrue(
|
||||
compareWkt(result, exp),
|
||||
f"Oriented MBBR: mismatch Expected:\n{exp}\nGot:\n{result}\n",
|
||||
)
|
||||
self.assertEqual(area, 0)
|
||||
self.assertEqual(angle, 0)
|
||||
self.assertEqual(width, 0)
|
||||
self.assertEqual(height, 0)
|
||||
|
||||
# polygon
|
||||
polygon = QgsGeometry.fromWkt(
|
||||
|
Loading…
x
Reference in New Issue
Block a user