Skip to content

Commit

Permalink
Add qgsgeometry_cast to qgssurface
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 13, 2017
1 parent 59f270a commit b2cd9f2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/core/geometry/qgssurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ class CORE_EXPORT QgsSurface: public QgsAbstractGeometry
return mBoundingBox;
}

#ifndef SIP_RUN

/**
* Cast the \a geom to a QgsSurface.
* Should be used by qgsgeometry_cast<QgsSurface *>( geometry ).
*
* \note Not available in Python. Objects will be automatically be converted to the appropriate target type.
* \since QGIS 3.0
*/
inline const QgsSurface *cast( const QgsAbstractGeometry *geom ) const
{
if ( !geom )
return nullptr;

QgsWkbTypes::Type flatType = geom->wkbType();
if ( flatType == QgsWkbTypes::CurvePolygon
|| flatType == QgsWkbTypes::Polygon
|| flatType == QgsWkbTypes::Triangle )
return static_cast<const QgsSurface *>( geom );
return nullptr;
}
#endif
protected:

virtual void clearCache() const override { mBoundingBox = QgsRectangle(); mCoordinateSequence.clear(); QgsAbstractGeometry::clearCache(); }
Expand Down

0 comments on commit b2cd9f2

Please sign in to comment.