Rename minimum area paremeter, fix docs for QgsCurvePolygon::removeInteriorRing

This commit is contained in:
Nyall Dawson 2016-11-29 08:43:23 +10:00
parent fef15e0165
commit 45a52dfacd
5 changed files with 29 additions and 15 deletions

View File

@ -54,16 +54,23 @@ class QgsCurvePolygon: public QgsSurface
void setInteriorRings( const QList<QgsCurve*>& rings );
/** Adds an interior ring to the geometry (takes ownership)*/
virtual void addInteriorRing( QgsCurve* ring /Transfer/ );
/** Removes ring. Exterior ring is 0, first interior ring 1, ...*/
bool removeInteriorRing( int nr );
/**
* Removes the interior rings from the polygon. If the minimumRingArea
* Removes an interior ring from the polygon. The first interior ring has index 0.
* The corresponding ring is removed from the polygon and deleted. If a ring was successfully removed
* the function will return true. It is not possible to remove the exterior ring using this method.
* @see removeInteriorRings()
*/
bool removeInteriorRing( int ringIndex );
/**
* Removes the interior rings from the polygon. If the minimumAllowedArea
* parameter is specified then only rings smaller than this minimum
* area will be removed.
* @note added in QGIS 3.0
* @see removeInteriorRing()
*/
void removeInteriorRings( double minimumRingArea = -1 );
void removeInteriorRings( double minimumAllowedArea = -1 );
virtual void draw( QPainter& p ) const;
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,

View File

@ -346,12 +346,12 @@ class QgsGeometry
int addPart( const QgsGeometry& newPart ) /PyName=addPartGeometry/;
/**
* Removes the interior rings from a (multi)polygon geometry. If the minimumRingArea
* Removes the interior rings from a (multi)polygon geometry. If the minimumAllowedArea
* parameter is specified then only rings smaller than this minimum
* area will be removed.
* @note added in QGIS 3.0
*/
QgsGeometry removeInteriorRings( double minimumRingArea = -1 ) const;
QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
/** Translate this geometry by dx, dy
@return 0 in case of success*/

View File

@ -546,17 +546,17 @@ bool QgsCurvePolygon::removeInteriorRing( int nr )
return true;
}
void QgsCurvePolygon::removeInteriorRings( double minimumRingArea )
void QgsCurvePolygon::removeInteriorRings( double minimumAllowedArea )
{
for ( int ringIndex = mInteriorRings.size() - 1; ringIndex >= 0; --ringIndex )
{
if ( minimumRingArea < 0 )
if ( minimumAllowedArea < 0 )
delete mInteriorRings.takeAt( ringIndex );
else
{
double area;
mInteriorRings.at( ringIndex )->sumUpArea( area );
if ( area < minimumRingArea )
if ( area < minimumAllowedArea )
delete mInteriorRings.takeAt( ringIndex );
}
}

View File

@ -80,16 +80,23 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
void setInteriorRings( const QList<QgsCurve*>& rings );
//! Adds an interior ring to the geometry (takes ownership)
virtual void addInteriorRing( QgsCurve* ring );
//! Removes ring. Exterior ring is 0, first interior ring 1, ...
bool removeInteriorRing( int nr );
/**
* Removes the interior rings from the polygon. If the minimumRingArea
* Removes an interior ring from the polygon. The first interior ring has index 0.
* The corresponding ring is removed from the polygon and deleted. If a ring was successfully removed
* the function will return true. It is not possible to remove the exterior ring using this method.
* @see removeInteriorRings()
*/
bool removeInteriorRing( int ringIndex );
/**
* Removes the interior rings from the polygon. If the minimumAllowedArea
* parameter is specified then only rings smaller than this minimum
* area will be removed.
* @note added in QGIS 3.0
* @see removeInteriorRing()
*/
void removeInteriorRings( double minimumRingArea = -1 );
void removeInteriorRings( double minimumAllowedArea = -1 );
virtual void draw( QPainter& p ) const override;
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,

View File

@ -399,12 +399,12 @@ class CORE_EXPORT QgsGeometry
int addPart( const QgsGeometry& newPart );
/**
* Removes the interior rings from a (multi)polygon geometry. If the minimumRingArea
* Removes the interior rings from a (multi)polygon geometry. If the minimumAllowedArea
* parameter is specified then only rings smaller than this minimum
* area will be removed.
* @note added in QGIS 3.0
*/
QgsGeometry removeInteriorRings( double minimumRingArea = -1 ) const;
QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
/** Translate this geometry by dx, dy
@return 0 in case of success*/