Skip to content

Commit d2076a1

Browse files
committed
Convert more dynamic_casts to qgsgeometry_casts
1 parent d0f33d6 commit d2076a1

11 files changed

+21
-21
lines changed

src/core/geometry/qgscompoundcurve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ QString QgsCompoundCurve::asWkt( int precision ) const
222222
Q_FOREACH ( const QgsCurve *curve, mCurves )
223223
{
224224
QString childWkt = curve->asWkt( precision );
225-
if ( dynamic_cast<const QgsLineString *>( curve ) )
225+
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
226226
{
227227
// Type names of linear geometries are omitted
228228
childWkt = childWkt.mid( childWkt.indexOf( '(' ) );

src/core/geometry/qgscurvepolygon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ QString QgsCurvePolygon::asWkt( int precision ) const
255255
if ( mExteriorRing )
256256
{
257257
QString childWkt = mExteriorRing->asWkt( precision );
258-
if ( dynamic_cast<QgsLineString *>( mExteriorRing ) )
258+
if ( qgsgeometry_cast<QgsLineString *>( mExteriorRing ) )
259259
{
260260
// Type names of linear geometries are omitted
261261
childWkt = childWkt.mid( childWkt.indexOf( '(' ) );
@@ -265,7 +265,7 @@ QString QgsCurvePolygon::asWkt( int precision ) const
265265
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
266266
{
267267
QString childWkt = curve->asWkt( precision );
268-
if ( dynamic_cast<const QgsLineString *>( curve ) )
268+
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
269269
{
270270
// Type names of linear geometries are omitted
271271
childWkt = childWkt.mid( childWkt.indexOf( '(' ) );

src/core/geometry/qgsgeometryeditutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int QgsGeometryEditUtils::addPart( QgsAbstractGeometry *geom, QgsAbstractGeometr
123123
if ( QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::MultiSurface
124124
|| QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::MultiPolygon )
125125
{
126-
QgsCurve *curve = dynamic_cast<QgsCurve *>( part );
126+
QgsCurve *curve = qgsgeometry_cast<QgsCurve *>( part );
127127
if ( curve && curve->isClosed() && curve->numPoints() >= 4 )
128128
{
129129
QgsCurvePolygon *poly = nullptr;
@@ -199,7 +199,7 @@ bool QgsGeometryEditUtils::deleteRing( QgsAbstractGeometry *geom, int ringNum, i
199199
return false;
200200
}
201201

202-
QgsCurvePolygon *cpoly = dynamic_cast<QgsCurvePolygon *>( g );
202+
QgsCurvePolygon *cpoly = qgsgeometry_cast<QgsCurvePolygon *>( g );
203203
if ( !cpoly )
204204
{
205205
return false;

src/core/geometry/qgsgeometryutils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ QList<QgsLineString *> QgsGeometryUtils::extractLineStrings( const QgsAbstractGe
3737
while ( ! geometries.isEmpty() )
3838
{
3939
const QgsAbstractGeometry *g = geometries.takeFirst();
40-
if ( const QgsCurve *curve = dynamic_cast< const QgsCurve * >( g ) )
40+
if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( g ) )
4141
{
4242
linestrings << static_cast< QgsLineString * >( curve->segmentize() );
4343
}
44-
else if ( const QgsGeometryCollection *collection = dynamic_cast< const QgsGeometryCollection * >( g ) )
44+
else if ( const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( g ) )
4545
{
4646
for ( int i = 0; i < collection->numGeometries(); ++i )
4747
{
4848
geometries.append( collection->geometryN( i ) );
4949
}
5050
}
51-
else if ( const QgsCurvePolygon *curvePolygon = dynamic_cast< const QgsCurvePolygon * >( g ) )
51+
else if ( const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( g ) )
5252
{
5353
if ( curvePolygon->exteriorRing() )
5454
linestrings << static_cast< QgsLineString * >( curvePolygon->exteriorRing()->segmentize() );

src/core/geometry/qgsgeos.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ bool QgsGeos::isSimple( QString *errorMsg ) const
16561656
GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, double precision, bool forceClose )
16571657
{
16581658
bool segmentize = false;
1659-
const QgsLineString *line = dynamic_cast<const QgsLineString *>( curve );
1659+
const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( curve );
16601660

16611661
if ( !line )
16621662
{
@@ -1742,7 +1742,7 @@ GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, dou
17421742

17431743
GEOSGeometry *QgsGeos::createGeosPoint( const QgsAbstractGeometry *point, int coordDims, double precision )
17441744
{
1745-
const QgsPoint *pt = dynamic_cast<const QgsPoint *>( point );
1745+
const QgsPoint *pt = qgsgeometry_cast<const QgsPoint *>( point );
17461746
if ( !pt )
17471747
return nullptr;
17481748

@@ -1796,7 +1796,7 @@ GEOSGeometry *QgsGeos::createGeosPointXY( double x, double y, bool hasZ, double
17961796

17971797
GEOSGeometry *QgsGeos::createGeosLinestring( const QgsAbstractGeometry *curve, double precision )
17981798
{
1799-
const QgsCurve *c = dynamic_cast<const QgsCurve *>( curve );
1799+
const QgsCurve *c = qgsgeometry_cast<const QgsCurve *>( curve );
18001800
if ( !c )
18011801
return nullptr;
18021802

@@ -1815,7 +1815,7 @@ GEOSGeometry *QgsGeos::createGeosLinestring( const QgsAbstractGeometry *curve, d
18151815

18161816
GEOSGeometry *QgsGeos::createGeosPolygon( const QgsAbstractGeometry *poly, double precision )
18171817
{
1818-
const QgsCurvePolygon *polygon = dynamic_cast<const QgsCurvePolygon *>( poly );
1818+
const QgsCurvePolygon *polygon = qgsgeometry_cast<const QgsCurvePolygon *>( poly );
18191819
if ( !polygon )
18201820
return nullptr;
18211821

src/core/geometry/qgsinternalgeometryengine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Cell *getCentroidCell( const QgsPolygonV2 *polygon )
158158
QgsPoint surfacePoleOfInaccessibility( const QgsSurface *surface, double precision, double &distanceFromBoundary )
159159
{
160160
std::unique_ptr< QgsPolygonV2 > segmentizedPoly;
161-
const QgsPolygonV2 *polygon = dynamic_cast< const QgsPolygonV2 * >( surface );
161+
const QgsPolygonV2 *polygon = qgsgeometry_cast< const QgsPolygonV2 * >( surface );
162162
if ( !polygon )
163163
{
164164
segmentizedPoly.reset( static_cast< QgsPolygonV2 *>( surface->segmentize() ) );

src/core/geometry/qgslinestring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ QgsLineString::QgsLineString( const QList<QgsPointXY> &points )
137137

138138
bool QgsLineString::operator==( const QgsCurve &other ) const
139139
{
140-
const QgsLineString *otherLine = dynamic_cast< const QgsLineString * >( &other );
140+
const QgsLineString *otherLine = qgsgeometry_cast< const QgsLineString * >( &other );
141141
if ( !otherLine )
142142
return false;
143143

src/core/geometry/qgsmulticurve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ QString QgsMultiCurve::asJSON( int precision ) const
104104

105105
bool QgsMultiCurve::addGeometry( QgsAbstractGeometry *g )
106106
{
107-
if ( !dynamic_cast<QgsCurve *>( g ) )
107+
if ( !qgsgeometry_cast<QgsCurve *>( g ) )
108108
{
109109
delete g;
110110
return false;

src/core/geometry/qgsmultipoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ QString QgsMultiPointV2::asJSON( int precision ) const
9797

9898
bool QgsMultiPointV2::addGeometry( QgsAbstractGeometry *g )
9999
{
100-
if ( !dynamic_cast<QgsPoint *>( g ) )
100+
if ( !qgsgeometry_cast<QgsPoint *>( g ) )
101101
{
102102
delete g;
103103
return false;

src/core/geometry/qgsmultipolygon.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ QString QgsMultiPolygonV2::asJSON( int precision ) const
115115

116116
bool QgsMultiPolygonV2::addGeometry( QgsAbstractGeometry *g )
117117
{
118-
if ( !dynamic_cast<QgsPolygonV2 *>( g ) )
118+
if ( !qgsgeometry_cast<QgsPolygonV2 *>( g ) )
119119
{
120120
delete g;
121121
return false;
@@ -144,11 +144,11 @@ QgsAbstractGeometry *QgsMultiPolygonV2::boundary() const
144144
{
145145
QgsAbstractGeometry *polygonBoundary = polygon->boundary();
146146

147-
if ( QgsLineString *lineStringBoundary = dynamic_cast< QgsLineString * >( polygonBoundary ) )
147+
if ( QgsLineString *lineStringBoundary = qgsgeometry_cast< QgsLineString * >( polygonBoundary ) )
148148
{
149149
multiLine->addGeometry( lineStringBoundary );
150150
}
151-
else if ( QgsMultiLineString *multiLineStringBoundary = dynamic_cast< QgsMultiLineString * >( polygonBoundary ) )
151+
else if ( QgsMultiLineString *multiLineStringBoundary = qgsgeometry_cast< QgsMultiLineString * >( polygonBoundary ) )
152152
{
153153
for ( int j = 0; j < multiLineStringBoundary->numGeometries(); ++j )
154154
{

0 commit comments

Comments
 (0)