mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Consistently use unsigned int for QgsRegularPolygon
This commit is contained in:
parent
92d739619d
commit
328fc9cb8d
@ -35,7 +35,7 @@ class QgsRegularPolygon
|
||||
|
||||
QgsRegularPolygon();
|
||||
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const double radius, const double azimuth, const int numberSides, const ConstructionOption circle );
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const double radius, const double azimuth, const unsigned int numberSides, const ConstructionOption circle );
|
||||
%Docstring
|
||||
Constructs a regular polygon by ``center`` and parameters for the first vertex. An empty regular polygon is returned if ``numberSides`` < 3 or ``ConstructionOption`` isn't valid.
|
||||
\param center The center of the regular polygon.
|
||||
@ -45,7 +45,7 @@ class QgsRegularPolygon
|
||||
.. seealso:: ConstructionOption
|
||||
%End
|
||||
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const QgsPoint &pt1, const int numberSides, const ConstructionOption circle );
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const QgsPoint &pt1, const unsigned int numberSides, const ConstructionOption circle );
|
||||
%Docstring
|
||||
Constructs a regular polygon by ``center`` and another point.
|
||||
\param center The center of the regular polygon.
|
||||
@ -54,7 +54,7 @@ class QgsRegularPolygon
|
||||
\param circle Option to create the polygon inscribed in circle (the radius is the distance between the center and vertices) or circumscribed about circle (the radius is the distance from the center to the midpoints of the sides).
|
||||
%End
|
||||
|
||||
QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2, const int numberSides );
|
||||
QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2, const unsigned int numberSides );
|
||||
%Docstring
|
||||
Constructs a regular polygon by two points of the first side.
|
||||
\param pt1 The first vertex of the first side, also first vertex of the regular polygon.
|
||||
@ -102,11 +102,10 @@ A regular polygon is empty if radius equal to 0 or number of sides < 3
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
int numberSides() const;
|
||||
unsigned int numberSides() const;
|
||||
%Docstring
|
||||
Returns the number of sides of the regular polygon.
|
||||
.. seealso:: setNumberSides()
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
void setCenter( const QgsPoint ¢er );
|
||||
@ -130,7 +129,7 @@ A regular polygon is empty if radius equal to 0 or number of sides < 3
|
||||
.. seealso:: firstVertex()
|
||||
%End
|
||||
|
||||
void setNumberSides( const int numberSides );
|
||||
void setNumberSides( const unsigned int numberSides );
|
||||
%Docstring
|
||||
Sets the number of sides.
|
||||
If numberSides < 3, the number of sides is unchanged.
|
||||
|
@ -60,7 +60,7 @@ class CORE_EXPORT QgsRegularPolygon
|
||||
* \param numberSides Number of sides of the regular polygon.
|
||||
* \param circle Option to create the polygon. \see ConstructionOption
|
||||
*/
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const double radius, const double azimuth, const int numberSides, const ConstructionOption circle );
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const double radius, const double azimuth, const unsigned int numberSides, const ConstructionOption circle );
|
||||
|
||||
/** Constructs a regular polygon by \a center and another point.
|
||||
* \param center The center of the regular polygon.
|
||||
@ -68,14 +68,14 @@ class CORE_EXPORT QgsRegularPolygon
|
||||
* \param numberSides Number of sides of the regular polygon.
|
||||
* \param circle Option to create the polygon inscribed in circle (the radius is the distance between the center and vertices) or circumscribed about circle (the radius is the distance from the center to the midpoints of the sides).
|
||||
*/
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const QgsPoint &pt1, const int numberSides, const ConstructionOption circle );
|
||||
QgsRegularPolygon( const QgsPoint ¢er, const QgsPoint &pt1, const unsigned int numberSides, const ConstructionOption circle );
|
||||
|
||||
/** Constructs a regular polygon by two points of the first side.
|
||||
* \param pt1 The first vertex of the first side, also first vertex of the regular polygon.
|
||||
* \param pt2 The second vertex of the first side.
|
||||
* \param numberSides Number of sides of the regular polygon.
|
||||
*/
|
||||
QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2, const int numberSides );
|
||||
QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2, const unsigned int numberSides );
|
||||
|
||||
bool operator ==( const QgsRegularPolygon &rp ) const;
|
||||
bool operator !=( const QgsRegularPolygon &rp ) const;
|
||||
@ -109,7 +109,7 @@ class CORE_EXPORT QgsRegularPolygon
|
||||
/** Returns the number of sides of the regular polygon.
|
||||
* \see setNumberSides()
|
||||
*/
|
||||
int numberSides() const { return mNumberSides; }
|
||||
unsigned int numberSides() const { return mNumberSides; }
|
||||
|
||||
/** Sets the center point.
|
||||
* Radius is unchanged. The first vertex is reprojected from the new center.
|
||||
@ -133,7 +133,7 @@ class CORE_EXPORT QgsRegularPolygon
|
||||
* If numberSides < 3, the number of sides is unchanged.
|
||||
* \see numberSides()
|
||||
*/
|
||||
void setNumberSides( const int numberSides );
|
||||
void setNumberSides( const unsigned int numberSides );
|
||||
|
||||
/** Returns a list including the vertices of the regular polygon.
|
||||
*/
|
||||
|
@ -4313,7 +4313,7 @@ void TestQgsGeometry::regularPolygon()
|
||||
QgsRegularPolygon rp1 = QgsRegularPolygon();
|
||||
QCOMPARE( rp1.center(), QgsPoint() );
|
||||
QCOMPARE( rp1.firstVertex(), QgsPoint() );
|
||||
QCOMPARE( rp1.numberSides(), 0 );
|
||||
QCOMPARE( rp1.numberSides(), static_cast< unsigned int >( 0 ) );
|
||||
QCOMPARE( rp1.radius(), 0.0 );
|
||||
QVERIFY( rp1.isEmpty() );
|
||||
|
||||
@ -4327,7 +4327,7 @@ void TestQgsGeometry::regularPolygon()
|
||||
QVERIFY( !rp2.isEmpty() );
|
||||
QCOMPARE( rp2.center(), QgsPoint() );
|
||||
QCOMPARE( rp2.firstVertex(), QgsPoint( 0, 5 ) );
|
||||
QCOMPARE( rp2.numberSides(), 5 );
|
||||
QCOMPARE( rp2.numberSides(), static_cast< unsigned int>( 5 ) );
|
||||
QCOMPARE( rp2.radius(), 5.0 );
|
||||
QGSCOMPARENEAR( rp2.apothem(), 4.0451, 10E-4 );
|
||||
QVERIFY( rp2 == QgsRegularPolygon( QgsPoint(), -5, 0, 5, QgsRegularPolygon::InscribedCircle ) );
|
||||
@ -4367,16 +4367,16 @@ void TestQgsGeometry::regularPolygon()
|
||||
|
||||
rp7.setNumberSides( 2 );
|
||||
QVERIFY( rp7.isEmpty() );
|
||||
QCOMPARE( rp7.numberSides(), 0 );
|
||||
QCOMPARE( rp7.numberSides(), static_cast< unsigned int >( 0 ) );
|
||||
rp7.setNumberSides( 5 );
|
||||
QVERIFY( rp7.isEmpty() );
|
||||
QCOMPARE( rp7.numberSides(), 5 );
|
||||
QCOMPARE( rp7.numberSides(), static_cast< unsigned int >( 5 ) );
|
||||
rp7.setNumberSides( 2 );
|
||||
QVERIFY( rp7.isEmpty() );
|
||||
QCOMPARE( rp7.numberSides(), 5 );
|
||||
QCOMPARE( rp7.numberSides(), static_cast< unsigned int >( 5 ) );
|
||||
rp7.setNumberSides( 3 );
|
||||
QVERIFY( rp7.isEmpty() );
|
||||
QCOMPARE( rp7.numberSides(), 3 );
|
||||
QCOMPARE( rp7.numberSides(), static_cast< unsigned int >( 3 ) );
|
||||
|
||||
rp7.setRadius( -6 );
|
||||
QVERIFY( !rp7.isEmpty() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user