@@ -1620,7 +1620,7 @@ static QVariant fcnGeomZ( const QVariantList &values, const QgsExpressionContext
1620
1620
// if single point, return the point's z coordinate
1621
1621
if ( geom.type () == QgsWkbTypes::PointGeometry && !geom.isMultipart () )
1622
1622
{
1623
- QgsPoint *point = dynamic_cast < QgsPoint * >( geom.geometry () );
1623
+ QgsPoint *point = qgsgeometry_cast < QgsPoint * >( geom.geometry () );
1624
1624
if ( point )
1625
1625
return point->z ();
1626
1626
}
@@ -1637,7 +1637,7 @@ static QVariant fcnGeomM( const QVariantList &values, const QgsExpressionContext
1637
1637
// if single point, return the point's m value
1638
1638
if ( geom.type () == QgsWkbTypes::PointGeometry && !geom.isMultipart () )
1639
1639
{
1640
- QgsPoint *point = dynamic_cast < QgsPoint * >( geom.geometry () );
1640
+ QgsPoint *point = qgsgeometry_cast < QgsPoint * >( geom.geometry () );
1641
1641
if ( point )
1642
1642
return point->m ();
1643
1643
}
@@ -1769,7 +1769,7 @@ static QVariant fcnInteriorRingN( const QVariantList &values, const QgsExpressio
1769
1769
if ( geom.isNull () )
1770
1770
return QVariant ();
1771
1771
1772
- QgsCurvePolygon *curvePolygon = dynamic_cast < QgsCurvePolygon * >( geom.geometry () );
1772
+ QgsCurvePolygon *curvePolygon = qgsgeometry_cast < QgsCurvePolygon * >( geom.geometry () );
1773
1773
if ( !curvePolygon )
1774
1774
return QVariant ();
1775
1775
@@ -1791,7 +1791,7 @@ static QVariant fcnGeometryN( const QVariantList &values, const QgsExpressionCon
1791
1791
if ( geom.isNull () )
1792
1792
return QVariant ();
1793
1793
1794
- QgsGeometryCollection *collection = dynamic_cast < QgsGeometryCollection * >( geom.geometry () );
1794
+ QgsGeometryCollection *collection = qgsgeometry_cast < QgsGeometryCollection * >( geom.geometry () );
1795
1795
if ( !collection )
1796
1796
return QVariant ();
1797
1797
@@ -1938,7 +1938,7 @@ static QVariant fcnMakeLine( const QVariantList &values, const QgsExpressionCont
1938
1938
if ( geom.type () != QgsWkbTypes::PointGeometry || geom.isMultipart () )
1939
1939
continue ;
1940
1940
1941
- QgsPoint *point = dynamic_cast < QgsPoint * >( geom.geometry () );
1941
+ QgsPoint *point = qgsgeometry_cast < QgsPoint * >( geom.geometry () );
1942
1942
if ( !point )
1943
1943
continue ;
1944
1944
@@ -1961,7 +1961,7 @@ static QVariant fcnMakePolygon( const QVariantList &values, const QgsExpressionC
1961
1961
return QVariant ();
1962
1962
1963
1963
QgsPolygonV2 *polygon = new QgsPolygonV2 ();
1964
- polygon->setExteriorRing ( dynamic_cast < QgsCurve * >( outerRing.geometry ()->clone () ) );
1964
+ polygon->setExteriorRing ( qgsgeometry_cast < QgsCurve * >( outerRing.geometry ()->clone () ) );
1965
1965
1966
1966
for ( int i = 1 ; i < values.count (); ++i )
1967
1967
{
@@ -1972,7 +1972,7 @@ static QVariant fcnMakePolygon( const QVariantList &values, const QgsExpressionC
1972
1972
if ( ringGeom.type () != QgsWkbTypes::LineGeometry || ringGeom.isMultipart () || ringGeom.isNull () )
1973
1973
continue ;
1974
1974
1975
- polygon->addInteriorRing ( dynamic_cast < QgsCurve * >( ringGeom.geometry ()->clone () ) );
1975
+ polygon->addInteriorRing ( qgsgeometry_cast < QgsCurve * >( ringGeom.geometry ()->clone () ) );
1976
1976
}
1977
1977
1978
1978
return QVariant::fromValue ( QgsGeometry ( polygon ) );
@@ -1993,7 +1993,7 @@ static QVariant fcnMakeTriangle( const QVariantList &values, const QgsExpression
1993
1993
if ( geom.type () != QgsWkbTypes::PointGeometry || geom.isMultipart () )
1994
1994
return QVariant ();
1995
1995
1996
- QgsPoint *point = dynamic_cast < QgsPoint * >( geom.geometry () );
1996
+ QgsPoint *point = qgsgeometry_cast < QgsPoint * >( geom.geometry () );
1997
1997
if ( !point )
1998
1998
return QVariant ();
1999
1999
@@ -2022,7 +2022,7 @@ static QVariant fcnMakeCircle( const QVariantList &values, const QgsExpressionCo
2022
2022
parent->setEvalErrorString ( QObject::tr ( " Segment must be greater than 2" ) );
2023
2023
return QVariant ();
2024
2024
}
2025
- QgsPoint *point = static_cast < QgsPoint * >( geom.geometry () );
2025
+ QgsPoint *point = qgsgeometry_cast < QgsPoint * >( geom.geometry () );
2026
2026
QgsCircle circ ( *point, radius );
2027
2027
return QVariant::fromValue ( QgsGeometry ( circ.toPolygon ( segment ) ) );
2028
2028
}
@@ -2045,7 +2045,7 @@ static QVariant fcnMakeEllipse( const QVariantList &values, const QgsExpressionC
2045
2045
parent->setEvalErrorString ( QObject::tr ( " Segment must be greater than 2" ) );
2046
2046
return QVariant ();
2047
2047
}
2048
- QgsPoint *point = static_cast < QgsPoint * >( geom.geometry () );
2048
+ QgsPoint *point = qgsgeometry_cast < QgsPoint * >( geom.geometry () );
2049
2049
QgsEllipse elp ( *point, majorAxis, minorAxis, azimuth );
2050
2050
return QVariant::fromValue ( QgsGeometry ( elp.toPolygon ( segment ) ) );
2051
2051
}
@@ -2080,8 +2080,8 @@ static QVariant fcnMakeRegularPolygon( const QVariantList &values, const QgsExpr
2080
2080
parent->setEvalErrorString ( QObject::tr ( " Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2081
2081
return QVariant ();
2082
2082
}
2083
- QgsPoint *center = static_cast < QgsPoint * >( pt1.geometry () );
2084
- QgsPoint *corner = static_cast < QgsPoint * >( pt2.geometry () );
2083
+ QgsPoint *center = qgsgeometry_cast < QgsPoint * >( pt1.geometry () );
2084
+ QgsPoint *corner = qgsgeometry_cast < QgsPoint * >( pt2.geometry () );
2085
2085
2086
2086
QgsRegularPolygon rp = QgsRegularPolygon ( *center, *corner, nbEdges, option );
2087
2087
@@ -2245,17 +2245,17 @@ static QVariant fcnGeomNumInteriorRings( const QVariantList &values, const QgsEx
2245
2245
if ( geom.isNull () )
2246
2246
return QVariant ();
2247
2247
2248
- QgsCurvePolygon *curvePolygon = dynamic_cast < QgsCurvePolygon * >( geom.geometry () );
2248
+ QgsCurvePolygon *curvePolygon = qgsgeometry_cast < QgsCurvePolygon * >( geom.geometry () );
2249
2249
if ( curvePolygon )
2250
2250
return QVariant ( curvePolygon->numInteriorRings () );
2251
2251
2252
- QgsGeometryCollection *collection = dynamic_cast < QgsGeometryCollection * >( geom.geometry () );
2252
+ QgsGeometryCollection *collection = qgsgeometry_cast < QgsGeometryCollection * >( geom.geometry () );
2253
2253
if ( collection )
2254
2254
{
2255
2255
// find first CurvePolygon in collection
2256
2256
for ( int i = 0 ; i < collection->numGeometries (); ++i )
2257
2257
{
2258
- curvePolygon = dynamic_cast < QgsCurvePolygon *>( collection->geometryN ( i ) );
2258
+ curvePolygon = qgsgeometry_cast < QgsCurvePolygon *>( collection->geometryN ( i ) );
2259
2259
if ( !curvePolygon )
2260
2260
continue ;
2261
2261
@@ -2273,19 +2273,19 @@ static QVariant fcnGeomNumRings( const QVariantList &values, const QgsExpression
2273
2273
if ( geom.isNull () )
2274
2274
return QVariant ();
2275
2275
2276
- QgsCurvePolygon *curvePolygon = dynamic_cast < QgsCurvePolygon * >( geom.geometry () );
2276
+ QgsCurvePolygon *curvePolygon = qgsgeometry_cast < QgsCurvePolygon * >( geom.geometry () );
2277
2277
if ( curvePolygon )
2278
2278
return QVariant ( curvePolygon->ringCount () );
2279
2279
2280
2280
bool foundPoly = false ;
2281
2281
int ringCount = 0 ;
2282
- QgsGeometryCollection *collection = dynamic_cast < QgsGeometryCollection * >( geom.geometry () );
2282
+ QgsGeometryCollection *collection = qgsgeometry_cast < QgsGeometryCollection * >( geom.geometry () );
2283
2283
if ( collection )
2284
2284
{
2285
2285
// find CurvePolygons in collection
2286
2286
for ( int i = 0 ; i < collection->numGeometries (); ++i )
2287
2287
{
2288
- curvePolygon = dynamic_cast < QgsCurvePolygon *>( collection->geometryN ( i ) );
2288
+ curvePolygon = qgsgeometry_cast < QgsCurvePolygon *>( collection->geometryN ( i ) );
2289
2289
if ( !curvePolygon )
2290
2290
continue ;
2291
2291
@@ -2350,7 +2350,7 @@ static QVariant fcnIsClosed( const QVariantList &values, const QgsExpressionCont
2350
2350
if ( fGeom .isNull () )
2351
2351
return QVariant ();
2352
2352
2353
- QgsCurve *curve = dynamic_cast < QgsCurve * >( fGeom .geometry () );
2353
+ QgsCurve *curve = qgsgeometry_cast < QgsCurve * >( fGeom .geometry () );
2354
2354
if ( !curve )
2355
2355
return QVariant ();
2356
2356
@@ -2544,7 +2544,7 @@ static QVariant fcnReverse( const QVariantList &values, const QgsExpressionConte
2544
2544
if ( fGeom .isNull () )
2545
2545
return QVariant ();
2546
2546
2547
- QgsCurve *curve = dynamic_cast < QgsCurve * >( fGeom .geometry () );
2547
+ QgsCurve *curve = qgsgeometry_cast < QgsCurve * >( fGeom .geometry () );
2548
2548
if ( !curve )
2549
2549
return QVariant ();
2550
2550
@@ -2559,7 +2559,7 @@ static QVariant fcnExteriorRing( const QVariantList &values, const QgsExpression
2559
2559
if ( fGeom .isNull () )
2560
2560
return QVariant ();
2561
2561
2562
- QgsCurvePolygon *curvePolygon = dynamic_cast < QgsCurvePolygon * >( fGeom .geometry () );
2562
+ QgsCurvePolygon *curvePolygon = qgsgeometry_cast < QgsCurvePolygon * >( fGeom .geometry () );
2563
2563
if ( !curvePolygon || !curvePolygon->exteriorRing () )
2564
2564
return QVariant ();
2565
2565
@@ -2622,8 +2622,8 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
2622
2622
QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry ( values.at ( 0 ), parent );
2623
2623
QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry ( values.at ( 1 ), parent );
2624
2624
2625
- const QgsPoint *pt1 = dynamic_cast <const QgsPoint *>( fGeom1 .geometry () );
2626
- const QgsPoint *pt2 = dynamic_cast <const QgsPoint *>( fGeom2 .geometry () );
2625
+ const QgsPoint *pt1 = qgsgeometry_cast <const QgsPoint *>( fGeom1 .geometry () );
2626
+ const QgsPoint *pt2 = qgsgeometry_cast <const QgsPoint *>( fGeom2 .geometry () );
2627
2627
2628
2628
if ( !pt1 || !pt2 )
2629
2629
{
@@ -2705,8 +2705,8 @@ static QVariant fcnInclination( const QVariantList &values, const QgsExpressionC
2705
2705
QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry ( values.at ( 0 ), parent );
2706
2706
QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry ( values.at ( 1 ), parent );
2707
2707
2708
- const QgsPoint *pt1 = dynamic_cast <const QgsPoint *>( fGeom1 .geometry () );
2709
- const QgsPoint *pt2 = dynamic_cast <const QgsPoint *>( fGeom2 .geometry () );
2708
+ const QgsPoint *pt1 = qgsgeometry_cast <const QgsPoint *>( fGeom1 .geometry () );
2709
+ const QgsPoint *pt2 = qgsgeometry_cast <const QgsPoint *>( fGeom2 .geometry () );
2710
2710
2711
2711
if ( ( fGeom1 .type () != QgsWkbTypes::PointGeometry ) || ( fGeom2 .type () != QgsWkbTypes::PointGeometry ) ||
2712
2712
!pt1 || !pt2 )
@@ -2774,7 +2774,7 @@ static QVariant fcnOrderParts( const QVariantList &values, const QgsExpressionCo
2774
2774
unconstedContext = new QgsExpressionContext ();
2775
2775
}
2776
2776
2777
- QgsGeometryCollection *collection = dynamic_cast <QgsGeometryCollection *>( fGeom .geometry () );
2777
+ QgsGeometryCollection *collection = qgsgeometry_cast <QgsGeometryCollection *>( fGeom .geometry () );
2778
2778
Q_ASSERT ( collection ); // Should have failed the multipart check above
2779
2779
2780
2780
QgsFeatureRequest::OrderBy orderBy;
@@ -2791,7 +2791,7 @@ static QVariant fcnOrderParts( const QVariantList &values, const QgsExpressionCo
2791
2791
2792
2792
sorter.sortFeatures ( partFeatures, unconstedContext );
2793
2793
2794
- QgsGeometryCollection *orderedGeom = dynamic_cast <QgsGeometryCollection *>( fGeom .geometry ()->clone () );
2794
+ QgsGeometryCollection *orderedGeom = qgsgeometry_cast <QgsGeometryCollection *>( fGeom .geometry ()->clone () );
2795
2795
2796
2796
Q_ASSERT ( orderedGeom );
2797
2797
0 commit comments