Skip to content

Commit

Permalink
Use QVector where possible in geometry classes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 14, 2017
1 parent 507a93c commit 5d476e5
Show file tree
Hide file tree
Showing 77 changed files with 336 additions and 350 deletions.
6 changes: 3 additions & 3 deletions python/core/geometry/qgsabstractgeometry.sip
Expand Up @@ -10,9 +10,9 @@



typedef QList< QgsPoint > QgsPointSequence;
typedef QList< QList< QgsPoint > > QgsRingSequence;
typedef QList< QList< QList< QgsPoint > > > QgsCoordinateSequence;
typedef QVector< QgsPoint > QgsPointSequence;
typedef QVector< QVector< QgsPoint > > QgsRingSequence;
typedef QVector< QVector< QVector< QgsPoint > > > QgsCoordinateSequence;

class QgsAbstractGeometry
{
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgscurvepolygon.sip
Expand Up @@ -100,7 +100,7 @@ class QgsCurvePolygon: QgsSurface
.. seealso:: exteriorRing()
%End

void setInteriorRings( const QList<QgsCurve *> &rings /Transfer/ );
void setInteriorRings( const QVector<QgsCurve *> &rings /Transfer/ );
%Docstring
Sets all interior rings (takes ownership)
%End
Expand Down
20 changes: 10 additions & 10 deletions python/core/geometry/qgsgeometry.sip
Expand Up @@ -204,7 +204,7 @@ Creates a new geometry from a QgsMultiPolygon
Creates a new geometry from a QgsRectangle
:rtype: QgsGeometry
%End
static QgsGeometry collectGeometry( const QList< QgsGeometry > &geometries );
static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
%Docstring
Creates a new multipart geometry from a list of QgsGeometry objects
:rtype: QgsGeometry
Expand Down Expand Up @@ -503,7 +503,7 @@ Returns true if WKB of the geometry is of WKBMulti* type
:rtype: float
%End

OperationResult addRing( const QList<QgsPointXY> &ring );
OperationResult addRing( const QVector<QgsPointXY> &ring );
%Docstring
Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
\param ring The ring to be added
Expand All @@ -519,7 +519,7 @@ Returns true if WKB of the geometry is of WKBMulti* type
:rtype: OperationResult
%End

OperationResult addPart( const QList<QgsPointXY> &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) /PyName=addPointsXY/;
OperationResult addPart( const QVector<QgsPointXY> &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) /PyName=addPointsXY/;
%Docstring
Adds a new part to a the geometry.
\param points points describing part to add
Expand Down Expand Up @@ -596,7 +596,7 @@ Returns true if WKB of the geometry is of WKBMulti* type
:rtype: OperationResult
%End

OperationResult splitGeometry( const QList<QgsPointXY> &splitLine, QList<QgsGeometry> &newGeometries /Out/, bool topological, QList<QgsPointXY> &topologyTestPoints /Out/ );
OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries /Out/, bool topological, QVector<QgsPointXY> &topologyTestPoints /Out/ );
%Docstring
Splits this geometry according to a given line.
\param splitLine the line that splits the geometry
Expand Down Expand Up @@ -1172,7 +1172,7 @@ Returns an extruded version of this geometry.
:rtype: QgsMultiPolygonXY
%End

QList<QgsGeometry> asGeometryCollection() const;
QVector<QgsGeometry> asGeometryCollection() const;
%Docstring
Return contents of the geometry as a list of geometries
.. versionadded:: 1.1
Expand Down Expand Up @@ -1305,7 +1305,7 @@ Returns an extruded version of this geometry.
ValidatorGeos,
};

void validateGeometry( QList<QgsGeometry::Error> &errors /Out/, ValidationMethod method = ValidatorQgisInternal ) const;
void validateGeometry( QVector<QgsGeometry::Error> &errors /Out/, ValidationMethod method = ValidatorQgisInternal ) const;
%Docstring
Validates geometry and produces a list of geometry errors.
The ``method`` argument dictates which validator to utilize.
Expand All @@ -1316,15 +1316,15 @@ Returns an extruded version of this geometry.
*
%End

static QgsGeometry unaryUnion( const QList<QgsGeometry> &geometries );
static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries );
%Docstring
Compute the unary union on a list of ``geometries``. May be faster than an iterative union on a set of geometries.
The returned geometry will be fully noded, i.e. a node will be created at every common intersection of the
input geometries. An empty geometry will be returned in the case of errors.
:rtype: QgsGeometry
%End

static QgsGeometry polygonize( const QList< QgsGeometry> &geometries );
static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
%Docstring
Creates a GeometryCollection geometry containing possible polygons formed from the constituent
linework of a set of ``geometries``. The input geometries must be fully noded (i.e. nodes exist
Expand Down Expand Up @@ -1579,14 +1579,14 @@ Returns an extruded version of this geometry.
:rtype: QgsGeometryEngine
%End

static void convertPointList( const QList<QgsPointXY> &input, QgsPointSequence &output );
static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
%Docstring
Upgrades a point list from QgsPointXY to QgsPoint
\param input list of QgsPointXY objects to be upgraded
\param output destination for list of points converted to QgsPoint
%End

static void convertPointList( const QgsPointSequence &input, QList<QgsPointXY> &output );
static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
%Docstring
Downgrades a point list from QgsPoint to QgsPointXY
\param input list of QgsPoint objects to be downgraded
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsgeometrycollection.sip
Expand Up @@ -190,7 +190,7 @@ Adds a geometry and takes ownership. Returns true in case of success.
:rtype: bool
%End

bool fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometry *> &subtypes, const QString &defaultChildWkbType = QString() );
bool fromCollectionWkt( const QString &wkt, const QVector<QgsAbstractGeometry *> &subtypes, const QString &defaultChildWkbType = QString() );
%Docstring
Reads a collection from a WKT string.
:rtype: bool
Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsgeometryengine.sip
Expand Up @@ -77,15 +77,15 @@ class QgsGeometryEngine
:rtype: QgsAbstractGeometry
%End

virtual QgsAbstractGeometry *combine( const QList<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const = 0 /Factory/;
virtual QgsAbstractGeometry *combine( const QVector<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const = 0 /Factory/;
%Docstring
Calculate the combination of this and ``geometries``.

.. versionadded:: 3.0
:rtype: QgsAbstractGeometry
%End

virtual QgsAbstractGeometry *combine( const QList< QgsGeometry > &geometries, QString *errorMsg = 0 ) const = 0 /Factory/;
virtual QgsAbstractGeometry *combine( const QVector< QgsGeometry > &geometries, QString *errorMsg = 0 ) const = 0 /Factory/;
%Docstring
Calculate the combination of this and ``geometries``.

Expand Down Expand Up @@ -266,7 +266,7 @@ class QgsGeometryEngine
%End

virtual QgsGeometryEngine::EngineOperationResult splitGeometry( const QgsLineString &splitLine,
QList<QgsGeometry > &newGeometries /Out/,
QVector<QgsGeometry > &newGeometries /Out/,
bool topological,
QgsPointSequence &topologyTestPoints, QString *errorMsg = 0 ) const;
%Docstring
Expand Down
4 changes: 2 additions & 2 deletions python/core/geometry/qgsgeometryutils.sip
Expand Up @@ -23,7 +23,7 @@ class QgsGeometryUtils
%End
public:

static QList<QgsLineString *> extractLineStrings( const QgsAbstractGeometry *geom ) /Factory/;
static QVector<QgsLineString *> extractLineStrings( const QgsAbstractGeometry *geom ) /Factory/;
%Docstring
Returns list of linestrings extracted from the passed geometry. The returned objects
have to be deleted by the caller.
Expand Down Expand Up @@ -191,7 +191,7 @@ Calculates the direction angle of a circle tangent (clockwise from north in radi
%End

static void segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3,
QList<QgsPoint> &points /Out/, double tolerance = M_PI_2 / 90,
QVector<QgsPoint> &points /Out/, double tolerance = M_PI_2 / 90,
QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle,
bool hasZ = false, bool hasM = false );
%Docstring
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgslinestring.sip
Expand Up @@ -45,7 +45,7 @@ class QgsLineString: QgsCurve
.. versionadded:: 3.0
%End

QgsLineString( const QList<QgsPointXY> &points );
QgsLineString( const QVector<QgsPointXY> &points );
%Docstring
Construct a linestring from list of points.
This constructor is more efficient then calling setPoints()
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsregularpolygon.sip
Expand Up @@ -164,7 +164,7 @@ A regular polygon is empty if radius equal to 0 or number of sides < 3
:rtype: QgsTriangle
%End

QList<QgsTriangle> triangulate() const;
QVector<QgsTriangle> triangulate() const;
%Docstring
Returns a triangulation (vertices from sides to the center) of the regular polygon.
An empty list is returned if the regular polygon is empty.
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsdistancearea.sip
Expand Up @@ -160,7 +160,7 @@ Constructor
:rtype: float
%End

double measureLine( const QList<QgsPointXY> &points ) const;
double measureLine( const QVector<QgsPointXY> &points ) const;
%Docstring
Measures the length of a line with multiple segments.
\param points list of points in line
Expand Down Expand Up @@ -213,7 +213,7 @@ Constructor
:rtype: QgsUnitTypes.AreaUnit
%End

double measurePolygon( const QList<QgsPointXY> &points ) const;
double measurePolygon( const QVector<QgsPointXY> &points ) const;
%Docstring
Measures the area of the polygon described by a set of points.
:rtype: float
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsgeometryvalidator.sip
Expand Up @@ -16,7 +16,7 @@ class QgsGeometryValidator : QThread
%End
public:

QgsGeometryValidator( const QgsGeometry &geoemtry, QList<QgsGeometry::Error> *errors = 0, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
QgsGeometryValidator( const QgsGeometry &geoemtry, QVector<QgsGeometry::Error> *errors = 0, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
%Docstring
Constructor for QgsGeometryValidator.
%End
Expand All @@ -26,7 +26,7 @@ class QgsGeometryValidator : QThread

void stop();

static void validateGeometry( const QgsGeometry &geometry, QList<QgsGeometry::Error> &errors /Out/, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors /Out/, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
%Docstring
Validate geometry and produce a list of geometry errors
%End
Expand Down
6 changes: 3 additions & 3 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -1043,7 +1043,7 @@ Return the provider type for this layer
:rtype: bool
%End

int addRing( const QList<QgsPointXY> &ring, QgsFeatureId *featureId = 0 );
int addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = 0 );
%Docstring
:rtype: int
%End
Expand Down Expand Up @@ -1081,12 +1081,12 @@ Return the provider type for this layer
:rtype: int
%End

int splitParts( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
int splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
%Docstring
:rtype: int
%End

int splitFeatures( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
int splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
%Docstring
:rtype: int
%End
Expand Down
6 changes: 3 additions & 3 deletions python/core/qgsvectorlayereditutils.sip
Expand Up @@ -62,7 +62,7 @@ class QgsVectorLayerEditUtils
:rtype: QgsVectorLayer.EditResult
%End

QgsGeometry::OperationResult addRing( const QList<QgsPointXY> &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = 0 );
QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = 0 );
%Docstring
Adds a ring to polygon/multipolygon features
\param ring ring to add
Expand Down Expand Up @@ -142,7 +142,7 @@ class QgsVectorLayerEditUtils
:rtype: int
%End

QgsGeometry::OperationResult splitParts( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
%Docstring
Splits parts cut by the given line
\param splitLine line that splits the layer feature parts
Expand All @@ -158,7 +158,7 @@ class QgsVectorLayerEditUtils
:rtype: QgsGeometry.OperationResult
%End

QgsGeometry::OperationResult splitFeatures( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
%Docstring
Splits features cut by the given line
\param splitLine line that splits the layer features
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsmaptoolcapture.sip
Expand Up @@ -151,14 +151,14 @@ Removes the last vertex from mRubberBand and mCaptureList
:rtype: int
%End

QList<QgsPointXY> points();
QVector<QgsPointXY> points();
%Docstring
List of digitized points
:return: List of points
:rtype: list of QgsPointXY
%End

void setPoints( const QList<QgsPointXY> &pointList );
void setPoints( const QVector<QgsPointXY> &pointList );
%Docstring
Set the points on which to work

Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmaptooledit.sip
Expand Up @@ -69,7 +69,7 @@ Returns the current vector layer of the map canvas or 0
:rtype: QgsVectorLayer
%End

int addTopologicalPoints( const QList<QgsPointXY> &geom );
int addTopologicalPoints( const QVector<QgsPointXY> &geom );
%Docstring
Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
\param geom list of points (in layer coordinate system)
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmbuffer.cpp
Expand Up @@ -96,7 +96,7 @@ QVariantMap QgsBufferAlgorithm::processAlgorithm( const QVariantMap &parameters,
double step = count > 0 ? 100.0 / count : 1;
int current = 0;

QList< QgsGeometry > bufferedGeometriesForDissolve;
QVector< QgsGeometry > bufferedGeometriesForDissolve;
QgsAttributes dissolveAttrs;

while ( it.nextFeature( f ) )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmclip.cpp
Expand Up @@ -79,7 +79,7 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap &parameters, Q
return QVariantMap();

// first build up a list of clip geometries
QList< QgsGeometry > clipGeoms;
QVector< QgsGeometry > clipGeoms;
QgsFeatureIterator it = maskSource->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QList< int >() ).setDestinationCrs( featureSource->sourceCrs() ) );
QgsFeature f;
while ( it.nextFeature( f ) )
Expand Down
10 changes: 5 additions & 5 deletions src/analysis/processing/qgsalgorithmdissolve.cpp
Expand Up @@ -24,7 +24,7 @@
//

QVariantMap QgsCollectorAlgorithm::processCollection( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback,
const std::function<QgsGeometry( const QList< QgsGeometry >& )> &collector, int maxQueueLength )
const std::function<QgsGeometry( const QVector< QgsGeometry >& )> &collector, int maxQueueLength )
{
std::unique_ptr< QgsFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( !source )
Expand All @@ -51,7 +51,7 @@ QVariantMap QgsCollectorAlgorithm::processCollection( const QVariantMap &paramet
// dissolve all - not using fields
bool firstFeature = true;
// we dissolve geometries in blocks using unaryUnion
QList< QgsGeometry > geomQueue;
QVector< QgsGeometry > geomQueue;
QgsFeature outputFeature;

while ( it.nextFeature( f ) )
Expand Down Expand Up @@ -97,7 +97,7 @@ QVariantMap QgsCollectorAlgorithm::processCollection( const QVariantMap &paramet
}

QHash< QVariant, QgsAttributes > attributeHash;
QHash< QVariant, QList< QgsGeometry > > geometryHash;
QHash< QVariant, QVector< QgsGeometry > > geometryHash;

while ( it.nextFeature( f ) )
{
Expand Down Expand Up @@ -207,7 +207,7 @@ QgsDissolveAlgorithm *QgsDissolveAlgorithm::createInstance() const

QVariantMap QgsDissolveAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
return processCollection( parameters, context, feedback, []( const QList< QgsGeometry > &parts )->QgsGeometry
return processCollection( parameters, context, feedback, []( const QVector< QgsGeometry > &parts )->QgsGeometry
{
return QgsGeometry::unaryUnion( parts );
}, 10000 );
Expand Down Expand Up @@ -239,7 +239,7 @@ QString QgsCollectAlgorithm::group() const

QVariantMap QgsCollectAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
return processCollection( parameters, context, feedback, []( const QList< QgsGeometry > &parts )->QgsGeometry
return processCollection( parameters, context, feedback, []( const QVector< QgsGeometry > &parts )->QgsGeometry
{
return QgsGeometry::collectGeometry( parts );
} );
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmdissolve.h
Expand Up @@ -33,7 +33,7 @@ class QgsCollectorAlgorithm : public QgsProcessingAlgorithm
protected:

QVariantMap processCollection( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback,
const std::function<QgsGeometry( const QList<QgsGeometry>& )> &collector, int maxQueueLength = 0 );
const std::function<QgsGeometry( const QVector<QgsGeometry>& )> &collector, int maxQueueLength = 0 );
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmfixgeometries.cpp
Expand Up @@ -86,8 +86,8 @@ QgsFeature QgsFixGeometriesAlgorithm::processFeature( const QgsFeature &feature,
QgsWkbTypes::flatType( outputGeometry.wkbType() ) == QgsWkbTypes::GeometryCollection )
{
// keep only the parts of the geometry collection with correct type
const QList< QgsGeometry > tmpGeometries = outputGeometry.asGeometryCollection();
QList< QgsGeometry > matchingParts;
const QVector< QgsGeometry > tmpGeometries = outputGeometry.asGeometryCollection();
QVector< QgsGeometry > matchingParts;
for ( const QgsGeometry &g : tmpGeometries )
{
if ( g.type() == feature.geometry().type() )
Expand Down

0 comments on commit 5d476e5

Please sign in to comment.