Skip to content

Commit

Permalink
Add a bunch of missing geometry cache clears
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 21, 2016
1 parent 50f01a2 commit 6116fdc
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 18 deletions.
4 changes: 2 additions & 2 deletions python/core/geometry/qgscurvepolygonv2.sip
Expand Up @@ -32,8 +32,8 @@ class QgsCurvePolygonV2: public QgsSurfaceV2

//curve polygon interface
int numInteriorRings() const;
QgsCurveV2* exteriorRing() const;
QgsCurveV2* interiorRing( int i ) const;
const QgsCurveV2* exteriorRing() const;
const QgsCurveV2* interiorRing( int i ) const;
virtual QgsPolygonV2* toPolygon() const;

/** Sets the exterior ring of the polygon. The CurvePolygon type will be updated to match the dimensionality
Expand Down
16 changes: 16 additions & 0 deletions src/core/geometry/qgscircularstringv2.cpp
Expand Up @@ -62,6 +62,7 @@ void QgsCircularStringV2::clear()
mZ.clear();
mM.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache();
}

QgsRectangle QgsCircularStringV2::calculateBoundingBox() const
Expand Down Expand Up @@ -216,6 +217,7 @@ bool QgsCircularStringV2::fromWkb( QgsConstWkbPtr wkbPtr )
{
return false;
}
clearCache();
mWkbType = type;

//type
Expand Down Expand Up @@ -418,6 +420,8 @@ void QgsCircularStringV2::points( QList<QgsPointV2>& pts ) const

void QgsCircularStringV2::setPoints( const QList<QgsPointV2>& points )
{
clearCache();

if ( points.size() < 1 )
{
mWkbType = QgsWKBTypes::Unknown;
Expand Down Expand Up @@ -609,6 +613,8 @@ void QgsCircularStringV2::draw( QPainter& p ) const

void QgsCircularStringV2::transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d )
{
clearCache();

double* zArray = mZ.data();

bool hasZ = is3D();
Expand All @@ -630,6 +636,8 @@ void QgsCircularStringV2::transform( const QgsCoordinateTransform& ct, QgsCoordi

void QgsCircularStringV2::transform( const QTransform& t )
{
clearCache();

int nPoints = numPoints();
for ( int i = 0; i < nPoints; ++i )
{
Expand Down Expand Up @@ -788,6 +796,7 @@ void QgsCircularStringV2::deleteVertex( int i )
{
mM.remove( i );
}
clearCache();
}

double QgsCircularStringV2::closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const
Expand Down Expand Up @@ -975,6 +984,7 @@ void QgsCircularStringV2::insertVertexBetween( int after, int before, int pointO
{
mM.insert( before, ( mM[after] + mM[before] ) / 2.0 );
}
clearCache();
}

double QgsCircularStringV2::vertexAngle( QgsVertexId vId ) const
Expand Down Expand Up @@ -1053,6 +1063,7 @@ bool QgsCircularStringV2::addZValue( double zValue )
if ( QgsWKBTypes::hasZ( mWkbType ) )
return false;

clearCache();
mWkbType = QgsWKBTypes::addZ( mWkbType );

int nPoints = numPoints();
Expand All @@ -1070,6 +1081,7 @@ bool QgsCircularStringV2::addMValue( double mValue )
if ( QgsWKBTypes::hasM( mWkbType ) )
return false;

clearCache();
mWkbType = QgsWKBTypes::addM( mWkbType );

int nPoints = numPoints();
Expand All @@ -1087,6 +1099,8 @@ bool QgsCircularStringV2::dropZValue()
if ( !QgsWKBTypes::hasZ( mWkbType ) )
return false;

clearCache();

mWkbType = QgsWKBTypes::dropZ( mWkbType );
mZ.clear();
return true;
Expand All @@ -1097,6 +1111,8 @@ bool QgsCircularStringV2::dropMValue()
if ( !QgsWKBTypes::hasM( mWkbType ) )
return false;

clearCache();

mWkbType = QgsWKBTypes::dropM( mWkbType );
mM.clear();
return true;
Expand Down
11 changes: 11 additions & 0 deletions src/core/geometry/qgscompoundcurvev2.cpp
Expand Up @@ -61,6 +61,7 @@ QgsCompoundCurveV2& QgsCompoundCurveV2::operator=( const QgsCompoundCurveV2 & cu
{
if ( &curve != this )
{
clearCache();
QgsCurveV2::operator=( curve );
Q_FOREACH ( const QgsCurveV2* c, curve.mCurves )
{
Expand All @@ -80,6 +81,7 @@ void QgsCompoundCurveV2::clear()
qDeleteAll( mCurves );
mCurves.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache();
}

QgsRectangle QgsCompoundCurveV2::calculateBoundingBox() const
Expand Down Expand Up @@ -388,6 +390,7 @@ void QgsCompoundCurveV2::addCurve( QgsCurveV2* c )
{
setZMTypeFromSubGeometry( c, QgsWKBTypes::CompoundCurve );
}
clearCache();
}
}

Expand All @@ -400,6 +403,7 @@ void QgsCompoundCurveV2::removeCurve( int i )

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

void QgsCompoundCurveV2::addVertex( const QgsPointV2& pt )
Expand Down Expand Up @@ -432,6 +436,7 @@ void QgsCompoundCurveV2::addVertex( const QgsPointV2& pt )
line = static_cast<QgsLineStringV2*>( lastCurve );
}
line->addVertex( pt );
clearCache();
}

void QgsCompoundCurveV2::draw( QPainter& p ) const
Expand All @@ -449,6 +454,7 @@ void QgsCompoundCurveV2::transform( const QgsCoordinateTransform& ct, QgsCoordin
{
curve->transform( ct, d );
}
clearCache();
}

void QgsCompoundCurveV2::transform( const QTransform& t )
Expand All @@ -457,6 +463,7 @@ void QgsCompoundCurveV2::transform( const QTransform& t )
{
curve->transform( t );
}
clearCache();
}

void QgsCompoundCurveV2::addToPainterPath( QPainterPath& path ) const
Expand Down Expand Up @@ -659,6 +666,7 @@ bool QgsCompoundCurveV2::addZValue( double zValue )
{
curve->addZValue( zValue );
}
clearCache();
return true;
}

Expand All @@ -673,6 +681,7 @@ bool QgsCompoundCurveV2::addMValue( double mValue )
{
curve->addMValue( mValue );
}
clearCache();
return true;
}

Expand All @@ -686,6 +695,7 @@ bool QgsCompoundCurveV2::dropZValue()
{
curve->dropZValue();
}
clearCache();
return true;
}

Expand All @@ -699,6 +709,7 @@ bool QgsCompoundCurveV2::dropMValue()
{
curve->dropMValue();
}
clearCache();
return true;
}

16 changes: 14 additions & 2 deletions src/core/geometry/qgscurvepolygonv2.cpp
Expand Up @@ -53,6 +53,7 @@ QgsCurvePolygonV2& QgsCurvePolygonV2::operator=( const QgsCurvePolygonV2 & p )
{
if ( &p != this )
{
clearCache();
QgsSurfaceV2::operator=( p );
if ( p.mExteriorRing )
{
Expand All @@ -79,6 +80,7 @@ void QgsCurvePolygonV2::clear()
qDeleteAll( mInteriorRings );
mInteriorRings.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache();
}


Expand Down Expand Up @@ -438,12 +440,12 @@ int QgsCurvePolygonV2::numInteriorRings() const
return mInteriorRings.size();
}

QgsCurveV2* QgsCurvePolygonV2::exteriorRing() const
const QgsCurveV2* QgsCurvePolygonV2::exteriorRing() const
{
return mExteriorRing;
}

QgsCurveV2* QgsCurvePolygonV2::interiorRing( int i ) const
const QgsCurveV2* QgsCurvePolygonV2::interiorRing( int i ) const
{
if ( i < 0 || i >= mInteriorRings.size() )
{
Expand Down Expand Up @@ -484,6 +486,7 @@ void QgsCurvePolygonV2::setExteriorRing( QgsCurveV2* ring )
else
ring->dropMValue();
}
clearCache();
}

void QgsCurvePolygonV2::setInteriorRings( const QList<QgsCurveV2*>& rings )
Expand All @@ -496,6 +499,7 @@ void QgsCurvePolygonV2::setInteriorRings( const QList<QgsCurveV2*>& rings )
{
addInteriorRing( ring );
}
clearCache();
}

void QgsCurvePolygonV2::addInteriorRing( QgsCurveV2* ring )
Expand All @@ -515,6 +519,7 @@ void QgsCurvePolygonV2::addInteriorRing( QgsCurveV2* ring )
ring->addMValue();

mInteriorRings.append( ring );
clearCache();
}

bool QgsCurvePolygonV2::removeInteriorRing( int nr )
Expand All @@ -524,6 +529,7 @@ bool QgsCurvePolygonV2::removeInteriorRing( int nr )
return false;
}
delete mInteriorRings.takeAt( nr );
clearCache();
return true;
}

Expand Down Expand Up @@ -561,6 +567,7 @@ void QgsCurvePolygonV2::transform( const QgsCoordinateTransform& ct, QgsCoordina
{
curve->transform( ct, d );
}
clearCache();
}

void QgsCurvePolygonV2::transform( const QTransform& t )
Expand All @@ -574,6 +581,7 @@ void QgsCurvePolygonV2::transform( const QTransform& t )
{
curve->transform( t );
}
clearCache();
}

void QgsCurvePolygonV2::coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord ) const
Expand Down Expand Up @@ -792,6 +800,7 @@ bool QgsCurvePolygonV2::addZValue( double zValue )
{
curve->addZValue( zValue );
}
clearCache();
return true;
}

Expand All @@ -808,6 +817,7 @@ bool QgsCurvePolygonV2::addMValue( double mValue )
{
curve->addMValue( mValue );
}
clearCache();
return true;
}

Expand All @@ -823,6 +833,7 @@ bool QgsCurvePolygonV2::dropZValue()
{
curve->dropZValue();
}
clearCache();
return true;
}

Expand All @@ -838,5 +849,6 @@ bool QgsCurvePolygonV2::dropMValue()
{
curve->dropMValue();
}
clearCache();
return true;
}
4 changes: 2 additions & 2 deletions src/core/geometry/qgscurvepolygonv2.h
Expand Up @@ -58,8 +58,8 @@ class CORE_EXPORT QgsCurvePolygonV2: public QgsSurfaceV2

//curve polygon interface
int numInteriorRings() const;
QgsCurveV2* exteriorRing() const;
QgsCurveV2* interiorRing( int i ) const;
const QgsCurveV2* exteriorRing() const;
const QgsCurveV2* interiorRing( int i ) const;
virtual QgsPolygonV2* toPolygon() const;

/** Sets the exterior ring of the polygon. The CurvePolygon type will be updated to match the dimensionality
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgscurvev2.h
Expand Up @@ -113,7 +113,7 @@ class CORE_EXPORT QgsCurveV2: public QgsAbstractGeometryV2

protected:

virtual void clearCache() const override { mBoundingBox = QgsRectangle(); }
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); QgsAbstractGeometryV2::clearCache(); }

private:

Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsgeometrycollectionv2.cpp
Expand Up @@ -46,6 +46,7 @@ QgsGeometryCollectionV2& QgsGeometryCollectionV2::operator=( const QgsGeometryCo
{
if ( &c != this )
{
clearCache();
QgsAbstractGeometryV2::operator=( c );
int nGeoms = c.mGeometries.size();
mGeometries.resize( nGeoms );
Expand Down Expand Up @@ -87,6 +88,7 @@ const QgsAbstractGeometryV2* QgsGeometryCollectionV2::geometryN( int n ) const

QgsAbstractGeometryV2* QgsGeometryCollectionV2::geometryN( int n )
{
clearCache();
return mGeometries.value( n );
}

Expand Down Expand Up @@ -590,6 +592,7 @@ bool QgsGeometryCollectionV2::addZValue( double zValue )
{
geom->addZValue( zValue );
}
clearCache();
return true;
}

Expand All @@ -604,6 +607,7 @@ bool QgsGeometryCollectionV2::addMValue( double mValue )
{
geom->addMValue( mValue );
}
clearCache();
return true;
}

Expand All @@ -618,6 +622,7 @@ bool QgsGeometryCollectionV2::dropZValue()
{
geom->dropZValue();
}
clearCache();
return true;
}

Expand All @@ -631,5 +636,6 @@ bool QgsGeometryCollectionV2::dropMValue()
{
geom->dropMValue();
}
clearCache();
return true;
}
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometrycollectionv2.h
Expand Up @@ -139,7 +139,7 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
bool fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType = QString() );

virtual QgsRectangle calculateBoundingBox() const override;
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); }
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); QgsAbstractGeometryV2::clearCache(); }

private:

Expand Down

0 comments on commit 6116fdc

Please sign in to comment.