Skip to content
Permalink
Browse files

Add qgsgeometry_cast to qgssurface

  • Loading branch information
m-kuhn committed Aug 13, 2017
1 parent 59f270a commit b2cd9f2a5eecf5eed841370894fe9cf1731fc096
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/core/geometry/qgssurface.h
@@ -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(); }

0 comments on commit b2cd9f2

Please sign in to comment.
You can’t perform that action at this time.