File tree Expand file tree Collapse file tree 5 files changed +28
-5
lines changed Expand file tree Collapse file tree 5 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -151,7 +151,13 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
151
151
*/
152
152
inline const QgsCurvePolygon *cast ( const QgsAbstractGeometry *geom ) const
153
153
{
154
- if ( geom && QgsWkbTypes::flatType ( geom->wkbType () ) == QgsWkbTypes::CurvePolygon )
154
+ if ( !geom )
155
+ return nullptr ;
156
+
157
+ QgsWkbTypes::Type flatType = geom->wkbType ();
158
+ if ( flatType == QgsWkbTypes::CurvePolygon
159
+ || flatType == QgsWkbTypes::Polygon
160
+ || flatType == QgsWkbTypes::Triangle )
155
161
return static_cast <const QgsCurvePolygon *>( geom );
156
162
return nullptr ;
157
163
}
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
146
146
*/
147
147
inline const QgsGeometryCollection *cast ( const QgsAbstractGeometry *geom ) const
148
148
{
149
- if ( geom && QgsWkbTypes::flatType ( geom->wkbType () ) == QgsWkbTypes::GeometryCollection )
149
+ if ( geom && QgsWkbTypes::isMultiType ( geom->wkbType () ) )
150
150
return static_cast <const QgsGeometryCollection *>( geom );
151
151
return nullptr ;
152
152
}
Original file line number Diff line number Diff line change @@ -62,7 +62,12 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection
62
62
*/
63
63
inline const QgsMultiCurve *cast ( const QgsAbstractGeometry *geom )
64
64
{
65
- if ( geom && QgsWkbTypes::flatType ( geom->wkbType () ) == QgsWkbTypes::MultiCurve )
65
+ if ( !geom )
66
+ return nullptr ;
67
+
68
+ QgsWkbTypes::Type flatType = QgsWkbTypes::flatType ( geom->wkbType () );
69
+ if ( flatType == QgsWkbTypes::MultiCurve
70
+ || flatType == QgsWkbTypes::MultiLineString )
66
71
return static_cast <const QgsMultiCurve *>( geom );
67
72
return nullptr ;
68
73
}
Original file line number Diff line number Diff line change @@ -58,7 +58,13 @@ class CORE_EXPORT QgsMultiSurface: public QgsGeometryCollection
58
58
*/
59
59
inline const QgsMultiSurface *cast ( const QgsAbstractGeometry *geom )
60
60
{
61
- if ( geom && QgsWkbTypes::flatType ( geom->wkbType () ) == QgsWkbTypes::MultiSurface )
61
+ if ( !geom )
62
+ return nullptr ;
63
+
64
+ QgsWkbTypes::Type flatType = QgsWkbTypes::flatType ( geom->wkbType () );
65
+
66
+ if ( flatType == QgsWkbTypes::MultiSurface
67
+ || flatType == QgsWkbTypes::MultiPolygon )
62
68
return static_cast <const QgsMultiSurface *>( geom );
63
69
return nullptr ;
64
70
}
Original file line number Diff line number Diff line change @@ -80,7 +80,13 @@ class CORE_EXPORT QgsPolygonV2: public QgsCurvePolygon
80
80
*/
81
81
inline const QgsPolygonV2 *cast ( const QgsAbstractGeometry *geom ) const
82
82
{
83
- if ( geom && QgsWkbTypes::flatType ( geom->wkbType () ) == QgsWkbTypes::Polygon )
83
+ if ( !geom )
84
+ return nullptr ;
85
+
86
+ QgsWkbTypes::Type flatType = QgsWkbTypes::flatType ( geom->wkbType () );
87
+
88
+ if ( flatType == QgsWkbTypes::Polygon
89
+ || flatType == QgsWkbTypes::Triangle )
84
90
return static_cast <const QgsPolygonV2 *>( geom );
85
91
return nullptr ;
86
92
}
You can’t perform that action at this time.
0 commit comments