Skip to content

Commit

Permalink
Rename minimum area paremeter, fix docs for QgsCurvePolygon::removeIn…
Browse files Browse the repository at this point in the history
…teriorRing
  • Loading branch information
nyalldawson committed Nov 28, 2016
1 parent fef15e0 commit 45a52df
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
15 changes: 11 additions & 4 deletions python/core/geometry/qgscurvepolygon.sip
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions python/core/geometry/qgsgeometry.sip
Expand Up @@ -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*/
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgscurvepolygon.cpp
Expand Up @@ -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 );
}
}
Expand Down
15 changes: 11 additions & 4 deletions src/core/geometry/qgscurvepolygon.h
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometry.h
Expand Up @@ -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*/
Expand Down

0 comments on commit 45a52df

Please sign in to comment.