Skip to content

Commit

Permalink
Convert more dynamic_casts to qgsgeometry_casts
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 13, 2017
1 parent d0f33d6 commit d2076a1
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/core/geometry/qgscompoundcurve.cpp
Expand Up @@ -222,7 +222,7 @@ QString QgsCompoundCurve::asWkt( int precision ) const
Q_FOREACH ( const QgsCurve *curve, mCurves )
{
QString childWkt = curve->asWkt( precision );
if ( dynamic_cast<const QgsLineString *>( curve ) )
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
{
// Type names of linear geometries are omitted
childWkt = childWkt.mid( childWkt.indexOf( '(' ) );
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgscurvepolygon.cpp
Expand Up @@ -255,7 +255,7 @@ QString QgsCurvePolygon::asWkt( int precision ) const
if ( mExteriorRing )
{
QString childWkt = mExteriorRing->asWkt( precision );
if ( dynamic_cast<QgsLineString *>( mExteriorRing ) )
if ( qgsgeometry_cast<QgsLineString *>( mExteriorRing ) )
{
// Type names of linear geometries are omitted
childWkt = childWkt.mid( childWkt.indexOf( '(' ) );
Expand All @@ -265,7 +265,7 @@ QString QgsCurvePolygon::asWkt( int precision ) const
Q_FOREACH ( const QgsCurve *curve, mInteriorRings )
{
QString childWkt = curve->asWkt( precision );
if ( dynamic_cast<const QgsLineString *>( curve ) )
if ( qgsgeometry_cast<const QgsLineString *>( curve ) )
{
// Type names of linear geometries are omitted
childWkt = childWkt.mid( childWkt.indexOf( '(' ) );
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometryeditutils.cpp
Expand Up @@ -123,7 +123,7 @@ int QgsGeometryEditUtils::addPart( QgsAbstractGeometry *geom, QgsAbstractGeometr
if ( QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::MultiSurface
|| QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::MultiPolygon )
{
QgsCurve *curve = dynamic_cast<QgsCurve *>( part );
QgsCurve *curve = qgsgeometry_cast<QgsCurve *>( part );
if ( curve && curve->isClosed() && curve->numPoints() >= 4 )
{
QgsCurvePolygon *poly = nullptr;
Expand Down Expand Up @@ -199,7 +199,7 @@ bool QgsGeometryEditUtils::deleteRing( QgsAbstractGeometry *geom, int ringNum, i
return false;
}

QgsCurvePolygon *cpoly = dynamic_cast<QgsCurvePolygon *>( g );
QgsCurvePolygon *cpoly = qgsgeometry_cast<QgsCurvePolygon *>( g );
if ( !cpoly )
{
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -37,18 +37,18 @@ QList<QgsLineString *> QgsGeometryUtils::extractLineStrings( const QgsAbstractGe
while ( ! geometries.isEmpty() )
{
const QgsAbstractGeometry *g = geometries.takeFirst();
if ( const QgsCurve *curve = dynamic_cast< const QgsCurve * >( g ) )
if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( g ) )
{
linestrings << static_cast< QgsLineString * >( curve->segmentize() );
}
else if ( const QgsGeometryCollection *collection = dynamic_cast< const QgsGeometryCollection * >( g ) )
else if ( const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( g ) )
{
for ( int i = 0; i < collection->numGeometries(); ++i )
{
geometries.append( collection->geometryN( i ) );
}
}
else if ( const QgsCurvePolygon *curvePolygon = dynamic_cast< const QgsCurvePolygon * >( g ) )
else if ( const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( g ) )
{
if ( curvePolygon->exteriorRing() )
linestrings << static_cast< QgsLineString * >( curvePolygon->exteriorRing()->segmentize() );
Expand Down
8 changes: 4 additions & 4 deletions src/core/geometry/qgsgeos.cpp
Expand Up @@ -1656,7 +1656,7 @@ bool QgsGeos::isSimple( QString *errorMsg ) const
GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, double precision, bool forceClose )
{
bool segmentize = false;
const QgsLineString *line = dynamic_cast<const QgsLineString *>( curve );
const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( curve );

if ( !line )
{
Expand Down Expand Up @@ -1742,7 +1742,7 @@ GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, dou

GEOSGeometry *QgsGeos::createGeosPoint( const QgsAbstractGeometry *point, int coordDims, double precision )
{
const QgsPoint *pt = dynamic_cast<const QgsPoint *>( point );
const QgsPoint *pt = qgsgeometry_cast<const QgsPoint *>( point );
if ( !pt )
return nullptr;

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

GEOSGeometry *QgsGeos::createGeosLinestring( const QgsAbstractGeometry *curve, double precision )
{
const QgsCurve *c = dynamic_cast<const QgsCurve *>( curve );
const QgsCurve *c = qgsgeometry_cast<const QgsCurve *>( curve );
if ( !c )
return nullptr;

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

GEOSGeometry *QgsGeos::createGeosPolygon( const QgsAbstractGeometry *poly, double precision )
{
const QgsCurvePolygon *polygon = dynamic_cast<const QgsCurvePolygon *>( poly );
const QgsCurvePolygon *polygon = qgsgeometry_cast<const QgsCurvePolygon *>( poly );
if ( !polygon )
return nullptr;

Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsinternalgeometryengine.cpp
Expand Up @@ -158,7 +158,7 @@ Cell *getCentroidCell( const QgsPolygonV2 *polygon )
QgsPoint surfacePoleOfInaccessibility( const QgsSurface *surface, double precision, double &distanceFromBoundary )
{
std::unique_ptr< QgsPolygonV2 > segmentizedPoly;
const QgsPolygonV2 *polygon = dynamic_cast< const QgsPolygonV2 * >( surface );
const QgsPolygonV2 *polygon = qgsgeometry_cast< const QgsPolygonV2 * >( surface );
if ( !polygon )
{
segmentizedPoly.reset( static_cast< QgsPolygonV2 *>( surface->segmentize() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgslinestring.cpp
Expand Up @@ -137,7 +137,7 @@ QgsLineString::QgsLineString( const QList<QgsPointXY> &points )

bool QgsLineString::operator==( const QgsCurve &other ) const
{
const QgsLineString *otherLine = dynamic_cast< const QgsLineString * >( &other );
const QgsLineString *otherLine = qgsgeometry_cast< const QgsLineString * >( &other );
if ( !otherLine )
return false;

Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmulticurve.cpp
Expand Up @@ -104,7 +104,7 @@ QString QgsMultiCurve::asJSON( int precision ) const

bool QgsMultiCurve::addGeometry( QgsAbstractGeometry *g )
{
if ( !dynamic_cast<QgsCurve *>( g ) )
if ( !qgsgeometry_cast<QgsCurve *>( g ) )
{
delete g;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmultipoint.cpp
Expand Up @@ -97,7 +97,7 @@ QString QgsMultiPointV2::asJSON( int precision ) const

bool QgsMultiPointV2::addGeometry( QgsAbstractGeometry *g )
{
if ( !dynamic_cast<QgsPoint *>( g ) )
if ( !qgsgeometry_cast<QgsPoint *>( g ) )
{
delete g;
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsmultipolygon.cpp
Expand Up @@ -115,7 +115,7 @@ QString QgsMultiPolygonV2::asJSON( int precision ) const

bool QgsMultiPolygonV2::addGeometry( QgsAbstractGeometry *g )
{
if ( !dynamic_cast<QgsPolygonV2 *>( g ) )
if ( !qgsgeometry_cast<QgsPolygonV2 *>( g ) )
{
delete g;
return false;
Expand Down Expand Up @@ -144,11 +144,11 @@ QgsAbstractGeometry *QgsMultiPolygonV2::boundary() const
{
QgsAbstractGeometry *polygonBoundary = polygon->boundary();

if ( QgsLineString *lineStringBoundary = dynamic_cast< QgsLineString * >( polygonBoundary ) )
if ( QgsLineString *lineStringBoundary = qgsgeometry_cast< QgsLineString * >( polygonBoundary ) )
{
multiLine->addGeometry( lineStringBoundary );
}
else if ( QgsMultiLineString *multiLineStringBoundary = dynamic_cast< QgsMultiLineString * >( polygonBoundary ) )
else if ( QgsMultiLineString *multiLineStringBoundary = qgsgeometry_cast< QgsMultiLineString * >( polygonBoundary ) )
{
for ( int j = 0; j < multiLineStringBoundary->numGeometries(); ++j )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgspolygon.cpp
Expand Up @@ -185,7 +185,7 @@ void QgsPolygonV2::addInteriorRing( QgsCurve *ring )
ring = segmented;
}

QgsLineString *lineString = dynamic_cast< QgsLineString *>( ring );
QgsLineString *lineString = qgsgeometry_cast< QgsLineString *>( ring );
if ( lineString && !lineString->isClosed() )
{
lineString->close();
Expand Down Expand Up @@ -219,7 +219,7 @@ void QgsPolygonV2::setExteriorRing( QgsCurve *ring )
ring = line;
}

QgsLineString *lineString = dynamic_cast< QgsLineString *>( ring );
QgsLineString *lineString = qgsgeometry_cast< QgsLineString *>( ring );
if ( lineString && !lineString->isClosed() )
{
lineString->close();
Expand Down

0 comments on commit d2076a1

Please sign in to comment.