Skip to content
Permalink
Browse files

Convert more dynamic_casts to qgsgeometry_casts

  • Loading branch information
m-kuhn committed Aug 13, 2017
1 parent d0f33d6 commit d2076a1400c8ac0d897a9f634de0410178602b15
@@ -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( '(' ) );
@@ -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( '(' ) );
@@ -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( '(' ) );
@@ -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;
@@ -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;
@@ -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() );
@@ -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 )
{
@@ -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;

@@ -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;

@@ -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;

@@ -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() ) );
@@ -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;

@@ -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;
@@ -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;
@@ -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;
@@ -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 )
{
@@ -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();
@@ -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();

0 comments on commit d2076a1

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