Skip to content

Commit 6116fdc

Browse files
committed
Add a bunch of missing geometry cache clears
1 parent 50f01a2 commit 6116fdc

14 files changed

+77
-18
lines changed

python/core/geometry/qgscurvepolygonv2.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
3232

3333
//curve polygon interface
3434
int numInteriorRings() const;
35-
QgsCurveV2* exteriorRing() const;
36-
QgsCurveV2* interiorRing( int i ) const;
35+
const QgsCurveV2* exteriorRing() const;
36+
const QgsCurveV2* interiorRing( int i ) const;
3737
virtual QgsPolygonV2* toPolygon() const;
3838

3939
/** Sets the exterior ring of the polygon. The CurvePolygon type will be updated to match the dimensionality

src/core/geometry/qgscircularstringv2.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void QgsCircularStringV2::clear()
6262
mZ.clear();
6363
mM.clear();
6464
mWkbType = QgsWKBTypes::Unknown;
65+
clearCache();
6566
}
6667

6768
QgsRectangle QgsCircularStringV2::calculateBoundingBox() const
@@ -216,6 +217,7 @@ bool QgsCircularStringV2::fromWkb( QgsConstWkbPtr wkbPtr )
216217
{
217218
return false;
218219
}
220+
clearCache();
219221
mWkbType = type;
220222

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

419421
void QgsCircularStringV2::setPoints( const QList<QgsPointV2>& points )
420422
{
423+
clearCache();
424+
421425
if ( points.size() < 1 )
422426
{
423427
mWkbType = QgsWKBTypes::Unknown;
@@ -609,6 +613,8 @@ void QgsCircularStringV2::draw( QPainter& p ) const
609613

610614
void QgsCircularStringV2::transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d )
611615
{
616+
clearCache();
617+
612618
double* zArray = mZ.data();
613619

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

631637
void QgsCircularStringV2::transform( const QTransform& t )
632638
{
639+
clearCache();
640+
633641
int nPoints = numPoints();
634642
for ( int i = 0; i < nPoints; ++i )
635643
{
@@ -788,6 +796,7 @@ void QgsCircularStringV2::deleteVertex( int i )
788796
{
789797
mM.remove( i );
790798
}
799+
clearCache();
791800
}
792801

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

980990
double QgsCircularStringV2::vertexAngle( QgsVertexId vId ) const
@@ -1053,6 +1063,7 @@ bool QgsCircularStringV2::addZValue( double zValue )
10531063
if ( QgsWKBTypes::hasZ( mWkbType ) )
10541064
return false;
10551065

1066+
clearCache();
10561067
mWkbType = QgsWKBTypes::addZ( mWkbType );
10571068

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

1084+
clearCache();
10731085
mWkbType = QgsWKBTypes::addM( mWkbType );
10741086

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

1102+
clearCache();
1103+
10901104
mWkbType = QgsWKBTypes::dropZ( mWkbType );
10911105
mZ.clear();
10921106
return true;
@@ -1097,6 +1111,8 @@ bool QgsCircularStringV2::dropMValue()
10971111
if ( !QgsWKBTypes::hasM( mWkbType ) )
10981112
return false;
10991113

1114+
clearCache();
1115+
11001116
mWkbType = QgsWKBTypes::dropM( mWkbType );
11011117
mM.clear();
11021118
return true;

src/core/geometry/qgscompoundcurvev2.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ QgsCompoundCurveV2& QgsCompoundCurveV2::operator=( const QgsCompoundCurveV2 & cu
6161
{
6262
if ( &curve != this )
6363
{
64+
clearCache();
6465
QgsCurveV2::operator=( curve );
6566
Q_FOREACH ( const QgsCurveV2* c, curve.mCurves )
6667
{
@@ -80,6 +81,7 @@ void QgsCompoundCurveV2::clear()
8081
qDeleteAll( mCurves );
8182
mCurves.clear();
8283
mWkbType = QgsWKBTypes::Unknown;
84+
clearCache();
8385
}
8486

8587
QgsRectangle QgsCompoundCurveV2::calculateBoundingBox() const
@@ -388,6 +390,7 @@ void QgsCompoundCurveV2::addCurve( QgsCurveV2* c )
388390
{
389391
setZMTypeFromSubGeometry( c, QgsWKBTypes::CompoundCurve );
390392
}
393+
clearCache();
391394
}
392395
}
393396

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

401404
delete( mCurves.at( i ) );
402405
mCurves.removeAt( i );
406+
clearCache();
403407
}
404408

405409
void QgsCompoundCurveV2::addVertex( const QgsPointV2& pt )
@@ -432,6 +436,7 @@ void QgsCompoundCurveV2::addVertex( const QgsPointV2& pt )
432436
line = static_cast<QgsLineStringV2*>( lastCurve );
433437
}
434438
line->addVertex( pt );
439+
clearCache();
435440
}
436441

437442
void QgsCompoundCurveV2::draw( QPainter& p ) const
@@ -449,6 +454,7 @@ void QgsCompoundCurveV2::transform( const QgsCoordinateTransform& ct, QgsCoordin
449454
{
450455
curve->transform( ct, d );
451456
}
457+
clearCache();
452458
}
453459

454460
void QgsCompoundCurveV2::transform( const QTransform& t )
@@ -457,6 +463,7 @@ void QgsCompoundCurveV2::transform( const QTransform& t )
457463
{
458464
curve->transform( t );
459465
}
466+
clearCache();
460467
}
461468

462469
void QgsCompoundCurveV2::addToPainterPath( QPainterPath& path ) const
@@ -659,6 +666,7 @@ bool QgsCompoundCurveV2::addZValue( double zValue )
659666
{
660667
curve->addZValue( zValue );
661668
}
669+
clearCache();
662670
return true;
663671
}
664672

@@ -673,6 +681,7 @@ bool QgsCompoundCurveV2::addMValue( double mValue )
673681
{
674682
curve->addMValue( mValue );
675683
}
684+
clearCache();
676685
return true;
677686
}
678687

@@ -686,6 +695,7 @@ bool QgsCompoundCurveV2::dropZValue()
686695
{
687696
curve->dropZValue();
688697
}
698+
clearCache();
689699
return true;
690700
}
691701

@@ -699,6 +709,7 @@ bool QgsCompoundCurveV2::dropMValue()
699709
{
700710
curve->dropMValue();
701711
}
712+
clearCache();
702713
return true;
703714
}
704715

src/core/geometry/qgscurvepolygonv2.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ QgsCurvePolygonV2& QgsCurvePolygonV2::operator=( const QgsCurvePolygonV2 & p )
5353
{
5454
if ( &p != this )
5555
{
56+
clearCache();
5657
QgsSurfaceV2::operator=( p );
5758
if ( p.mExteriorRing )
5859
{
@@ -79,6 +80,7 @@ void QgsCurvePolygonV2::clear()
7980
qDeleteAll( mInteriorRings );
8081
mInteriorRings.clear();
8182
mWkbType = QgsWKBTypes::Unknown;
83+
clearCache();
8284
}
8385

8486

@@ -438,12 +440,12 @@ int QgsCurvePolygonV2::numInteriorRings() const
438440
return mInteriorRings.size();
439441
}
440442

441-
QgsCurveV2* QgsCurvePolygonV2::exteriorRing() const
443+
const QgsCurveV2* QgsCurvePolygonV2::exteriorRing() const
442444
{
443445
return mExteriorRing;
444446
}
445447

446-
QgsCurveV2* QgsCurvePolygonV2::interiorRing( int i ) const
448+
const QgsCurveV2* QgsCurvePolygonV2::interiorRing( int i ) const
447449
{
448450
if ( i < 0 || i >= mInteriorRings.size() )
449451
{
@@ -484,6 +486,7 @@ void QgsCurvePolygonV2::setExteriorRing( QgsCurveV2* ring )
484486
else
485487
ring->dropMValue();
486488
}
489+
clearCache();
487490
}
488491

489492
void QgsCurvePolygonV2::setInteriorRings( const QList<QgsCurveV2*>& rings )
@@ -496,6 +499,7 @@ void QgsCurvePolygonV2::setInteriorRings( const QList<QgsCurveV2*>& rings )
496499
{
497500
addInteriorRing( ring );
498501
}
502+
clearCache();
499503
}
500504

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

517521
mInteriorRings.append( ring );
522+
clearCache();
518523
}
519524

520525
bool QgsCurvePolygonV2::removeInteriorRing( int nr )
@@ -524,6 +529,7 @@ bool QgsCurvePolygonV2::removeInteriorRing( int nr )
524529
return false;
525530
}
526531
delete mInteriorRings.takeAt( nr );
532+
clearCache();
527533
return true;
528534
}
529535

@@ -561,6 +567,7 @@ void QgsCurvePolygonV2::transform( const QgsCoordinateTransform& ct, QgsCoordina
561567
{
562568
curve->transform( ct, d );
563569
}
570+
clearCache();
564571
}
565572

566573
void QgsCurvePolygonV2::transform( const QTransform& t )
@@ -574,6 +581,7 @@ void QgsCurvePolygonV2::transform( const QTransform& t )
574581
{
575582
curve->transform( t );
576583
}
584+
clearCache();
577585
}
578586

579587
void QgsCurvePolygonV2::coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord ) const
@@ -792,6 +800,7 @@ bool QgsCurvePolygonV2::addZValue( double zValue )
792800
{
793801
curve->addZValue( zValue );
794802
}
803+
clearCache();
795804
return true;
796805
}
797806

@@ -808,6 +817,7 @@ bool QgsCurvePolygonV2::addMValue( double mValue )
808817
{
809818
curve->addMValue( mValue );
810819
}
820+
clearCache();
811821
return true;
812822
}
813823

@@ -823,6 +833,7 @@ bool QgsCurvePolygonV2::dropZValue()
823833
{
824834
curve->dropZValue();
825835
}
836+
clearCache();
826837
return true;
827838
}
828839

@@ -838,5 +849,6 @@ bool QgsCurvePolygonV2::dropMValue()
838849
{
839850
curve->dropMValue();
840851
}
852+
clearCache();
841853
return true;
842854
}

src/core/geometry/qgscurvepolygonv2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class CORE_EXPORT QgsCurvePolygonV2: public QgsSurfaceV2
5858

5959
//curve polygon interface
6060
int numInteriorRings() const;
61-
QgsCurveV2* exteriorRing() const;
62-
QgsCurveV2* interiorRing( int i ) const;
61+
const QgsCurveV2* exteriorRing() const;
62+
const QgsCurveV2* interiorRing( int i ) const;
6363
virtual QgsPolygonV2* toPolygon() const;
6464

6565
/** Sets the exterior ring of the polygon. The CurvePolygon type will be updated to match the dimensionality

src/core/geometry/qgscurvev2.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class CORE_EXPORT QgsCurveV2: public QgsAbstractGeometryV2
113113

114114
protected:
115115

116-
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); }
116+
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); QgsAbstractGeometryV2::clearCache(); }
117117

118118
private:
119119

src/core/geometry/qgsgeometrycollectionv2.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ QgsGeometryCollectionV2& QgsGeometryCollectionV2::operator=( const QgsGeometryCo
4646
{
4747
if ( &c != this )
4848
{
49+
clearCache();
4950
QgsAbstractGeometryV2::operator=( c );
5051
int nGeoms = c.mGeometries.size();
5152
mGeometries.resize( nGeoms );
@@ -87,6 +88,7 @@ const QgsAbstractGeometryV2* QgsGeometryCollectionV2::geometryN( int n ) const
8788

8889
QgsAbstractGeometryV2* QgsGeometryCollectionV2::geometryN( int n )
8990
{
91+
clearCache();
9092
return mGeometries.value( n );
9193
}
9294

@@ -590,6 +592,7 @@ bool QgsGeometryCollectionV2::addZValue( double zValue )
590592
{
591593
geom->addZValue( zValue );
592594
}
595+
clearCache();
593596
return true;
594597
}
595598

@@ -604,6 +607,7 @@ bool QgsGeometryCollectionV2::addMValue( double mValue )
604607
{
605608
geom->addMValue( mValue );
606609
}
610+
clearCache();
607611
return true;
608612
}
609613

@@ -618,6 +622,7 @@ bool QgsGeometryCollectionV2::dropZValue()
618622
{
619623
geom->dropZValue();
620624
}
625+
clearCache();
621626
return true;
622627
}
623628

@@ -631,5 +636,6 @@ bool QgsGeometryCollectionV2::dropMValue()
631636
{
632637
geom->dropMValue();
633638
}
639+
clearCache();
634640
return true;
635641
}

src/core/geometry/qgsgeometrycollectionv2.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
139139
bool fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType = QString() );
140140

141141
virtual QgsRectangle calculateBoundingBox() const override;
142-
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); }
142+
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); QgsAbstractGeometryV2::clearCache(); }
143143

144144
private:
145145

0 commit comments

Comments
 (0)