Skip to content
Permalink
Browse files

Merge pull request #5238 from nyalldawson/geometry_coverage

Geometry unit test coverage + fixes
  • Loading branch information
nyalldawson committed Sep 22, 2017
2 parents a6b1c3e + cbca7c9 commit 22eddfd4c0f538d30d196204612e3722bc816e17
@@ -28,14 +28,10 @@ class QgsPolygonV2: QgsCurvePolygon

virtual void clear();


virtual bool fromWkb( QgsConstWkbPtr &wkb );



virtual QByteArray asWkb() const;


virtual QgsPolygonV2 *surfaceToPolygon() const /Factory/;


@@ -73,7 +73,7 @@ int QgsCompoundCurve::dimension() const

QgsCompoundCurve::QgsCompoundCurve( const QgsCompoundCurve &curve ): QgsCurve( curve )
{
mWkbType = QgsWkbTypes::CompoundCurve;
mWkbType = curve.wkbType();
for ( const QgsCurve *c : curve.mCurves )
{
mCurves.append( static_cast<QgsCurve *>( c->clone() ) );
@@ -385,7 +385,7 @@ QgsLineString *QgsCompoundCurve::curveToLine( double tolerance, SegmentationTole

const QgsCurve *QgsCompoundCurve::curveAt( int i ) const
{
if ( i >= mCurves.size() )
if ( i < 0 || i >= mCurves.size() )
{
return nullptr;
}
@@ -396,34 +396,41 @@ void QgsCompoundCurve::addCurve( QgsCurve *c )
{
if ( c )
{
mCurves.append( c );

if ( mWkbType == QgsWkbTypes::Unknown )
if ( mCurves.empty() )
{
setZMTypeFromSubGeometry( c, QgsWkbTypes::CompoundCurve );
}

mCurves.append( c );

if ( QgsWkbTypes::hasZ( mWkbType ) && !QgsWkbTypes::hasZ( c->wkbType() ) )
{
c->addZValue();
}
else if ( !QgsWkbTypes::hasZ( mWkbType ) && QgsWkbTypes::hasZ( c->wkbType() ) )
{
c->dropZValue();
}
if ( QgsWkbTypes::hasM( mWkbType ) && !QgsWkbTypes::hasM( c->wkbType() ) )
{
c->addMValue();
}
else if ( !QgsWkbTypes::hasM( mWkbType ) && QgsWkbTypes::hasM( c->wkbType() ) )
{
c->dropMValue();
}
clearCache();
}
}

void QgsCompoundCurve::removeCurve( int i )
{
if ( mCurves.size() - 1 < i )
if ( i < 0 || i >= mCurves.size() )
{
return;
}

delete ( mCurves.at( i ) );
mCurves.removeAt( i );
delete mCurves.takeAt( i );
clearCache();
}

@@ -776,9 +783,9 @@ double QgsCompoundCurve::vertexAngle( QgsVertexId vertex ) const
QgsCompoundCurve *QgsCompoundCurve::reversed() const
{
QgsCompoundCurve *clone = new QgsCompoundCurve();
for ( QgsCurve *curve : mCurves )
for ( int i = mCurves.count() - 1; i >= 0; --i )
{
QgsCurve *reversedCurve = curve->reversed();
QgsCurve *reversedCurve = mCurves.at( i )->reversed();
clone->addCurve( reversedCurve );
}
return clone;
@@ -626,12 +626,12 @@ void QgsCurvePolygon::removeInteriorRings( double minimumAllowedArea )

void QgsCurvePolygon::draw( QPainter &p ) const
{
if ( !mExteriorRing )
return;

if ( mInteriorRings.empty() )
{
if ( mExteriorRing )
{
mExteriorRing->drawAsPolygon( p );
}
mExteriorRing->drawAsPolygon( p );
}
else
{
@@ -35,17 +35,8 @@ class CORE_EXPORT QgsPolygonV2: public QgsCurvePolygon
QString geometryType() const override;
QgsPolygonV2 *clone() const override SIP_FACTORY;
void clear() override;

bool fromWkb( QgsConstWkbPtr &wkb ) override;

// inherited: bool fromWkt( const QString &wkt );

QByteArray asWkb() const override;
// inherited: QString asWkt( int precision = 17 ) const;
// inherited: QDomElement asGML2( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const;
// inherited: QDomElement asGML3( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const;
// inherited: QString asJSON( int precision = 17 ) const;

QgsPolygonV2 *surfaceToPolygon() const override SIP_FACTORY;

/** Returns the geometry converted to the more generic curve type QgsCurvePolygon

0 comments on commit 22eddfd

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