mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Drop the cached coordinate sequence from abstract geometries
This cache was added to speed up expensive QgsAbstractGeometry::coordinateSequence calls, when we were relying on coordinateSequence() for a whole bunch of stuff like counting the number of points in a geometry. Now it's used almost no-where in the code, so this cache is unlikely to get filled and just makes geometries more memory heavy than they need to be.
This commit is contained in:
parent
0c35dde461
commit
507a93c69b
@ -45,14 +45,12 @@ bool QgsCurve::isRing() const
|
||||
|
||||
QgsCoordinateSequence QgsCurve::coordinateSequence() const
|
||||
{
|
||||
if ( !mCoordinateSequence.isEmpty() )
|
||||
return mCoordinateSequence;
|
||||
QgsCoordinateSequence sequence;
|
||||
sequence.append( QgsRingSequence() );
|
||||
sequence.back().append( QgsPointSequence() );
|
||||
points( sequence.back().back() );
|
||||
|
||||
mCoordinateSequence.append( QgsRingSequence() );
|
||||
mCoordinateSequence.back().append( QgsPointSequence() );
|
||||
points( mCoordinateSequence.back().back() );
|
||||
|
||||
return mCoordinateSequence;
|
||||
return sequence;
|
||||
}
|
||||
|
||||
bool QgsCurve::nextVertex( QgsVertexId &id, QgsPoint &vertex ) const
|
||||
@ -191,7 +189,6 @@ QPolygonF QgsCurve::asQPolygonF() const
|
||||
void QgsCurve::clearCache() const
|
||||
{
|
||||
mBoundingBox = QgsRectangle();
|
||||
mCoordinateSequence.clear();
|
||||
QgsAbstractGeometry::clearCache();
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,6 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry
|
||||
private:
|
||||
|
||||
mutable QgsRectangle mBoundingBox;
|
||||
mutable QgsCoordinateSequence mCoordinateSequence;
|
||||
};
|
||||
|
||||
#endif // QGSCURVEV2_H
|
||||
|
@ -724,32 +724,27 @@ void QgsCurvePolygon::transform( const QTransform &t )
|
||||
|
||||
QgsCoordinateSequence QgsCurvePolygon::coordinateSequence() const
|
||||
{
|
||||
if ( !mCoordinateSequence.isEmpty() )
|
||||
return mCoordinateSequence;
|
||||
|
||||
mCoordinateSequence.append( QgsRingSequence() );
|
||||
QgsCoordinateSequence sequence;
|
||||
sequence.append( QgsRingSequence() );
|
||||
|
||||
if ( mExteriorRing )
|
||||
{
|
||||
mCoordinateSequence.back().append( QgsPointSequence() );
|
||||
mExteriorRing->points( mCoordinateSequence.back().back() );
|
||||
sequence.back().append( QgsPointSequence() );
|
||||
mExteriorRing->points( sequence.back().back() );
|
||||
}
|
||||
|
||||
QList<QgsCurve *>::const_iterator it = mInteriorRings.constBegin();
|
||||
for ( ; it != mInteriorRings.constEnd(); ++it )
|
||||
{
|
||||
mCoordinateSequence.back().append( QgsPointSequence() );
|
||||
( *it )->points( mCoordinateSequence.back().back() );
|
||||
sequence.back().append( QgsPointSequence() );
|
||||
( *it )->points( sequence.back().back() );
|
||||
}
|
||||
|
||||
return mCoordinateSequence;
|
||||
return sequence;
|
||||
}
|
||||
|
||||
int QgsCurvePolygon::nCoordinates() const
|
||||
{
|
||||
if ( !mCoordinateSequence.isEmpty() )
|
||||
return QgsAbstractGeometry::nCoordinates();
|
||||
|
||||
int count = 0;
|
||||
|
||||
if ( mExteriorRing )
|
||||
|
@ -421,15 +421,12 @@ QgsRectangle QgsGeometryCollection::calculateBoundingBox() const
|
||||
void QgsGeometryCollection::clearCache() const
|
||||
{
|
||||
mBoundingBox = QgsRectangle();
|
||||
mCoordinateSequence.clear();
|
||||
QgsAbstractGeometry::clearCache();
|
||||
}
|
||||
|
||||
QgsCoordinateSequence QgsGeometryCollection::coordinateSequence() const
|
||||
{
|
||||
if ( !mCoordinateSequence.isEmpty() )
|
||||
return mCoordinateSequence;
|
||||
|
||||
QgsCoordinateSequence sequence;
|
||||
QVector< QgsAbstractGeometry * >::const_iterator geomIt = mGeometries.constBegin();
|
||||
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
|
||||
{
|
||||
@ -438,18 +435,15 @@ QgsCoordinateSequence QgsGeometryCollection::coordinateSequence() const
|
||||
QgsCoordinateSequence::const_iterator cIt = geomCoords.constBegin();
|
||||
for ( ; cIt != geomCoords.constEnd(); ++cIt )
|
||||
{
|
||||
mCoordinateSequence.push_back( *cIt );
|
||||
sequence.push_back( *cIt );
|
||||
}
|
||||
}
|
||||
|
||||
return mCoordinateSequence;
|
||||
return sequence;
|
||||
}
|
||||
|
||||
int QgsGeometryCollection::nCoordinates() const
|
||||
{
|
||||
if ( !mCoordinateSequence.isEmpty() )
|
||||
return QgsAbstractGeometry::nCoordinates();
|
||||
|
||||
int count = 0;
|
||||
|
||||
QVector< QgsAbstractGeometry * >::const_iterator geomIt = mGeometries.constBegin();
|
||||
|
@ -185,7 +185,6 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
|
||||
private:
|
||||
|
||||
mutable QgsRectangle mBoundingBox;
|
||||
mutable QgsCoordinateSequence mCoordinateSequence;
|
||||
};
|
||||
|
||||
// clazy:excludeall=qstring-allocations
|
||||
|
@ -75,9 +75,8 @@ class CORE_EXPORT QgsSurface: public QgsAbstractGeometry
|
||||
#endif
|
||||
protected:
|
||||
|
||||
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); mCoordinateSequence.clear(); QgsAbstractGeometry::clearCache(); }
|
||||
virtual void clearCache() const override { mBoundingBox = QgsRectangle(); QgsAbstractGeometry::clearCache(); }
|
||||
|
||||
mutable QgsCoordinateSequence mCoordinateSequence;
|
||||
mutable QgsRectangle mBoundingBox;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user