Skip to content
Permalink
Browse files

Use QVector where possible in geometry classes

  • Loading branch information
nyalldawson committed Nov 14, 2017
1 parent 507a93c commit 5d476e51dfcbf9a2d3634cf6b7a6d5b12e93f406
Showing with 336 additions and 350 deletions.
  1. +3 −3 python/core/geometry/qgsabstractgeometry.sip
  2. +1 −1 python/core/geometry/qgscurvepolygon.sip
  3. +10 −10 python/core/geometry/qgsgeometry.sip
  4. +1 −1 python/core/geometry/qgsgeometrycollection.sip
  5. +3 −3 python/core/geometry/qgsgeometryengine.sip
  6. +2 −2 python/core/geometry/qgsgeometryutils.sip
  7. +1 −1 python/core/geometry/qgslinestring.sip
  8. +1 −1 python/core/geometry/qgsregularpolygon.sip
  9. +2 −2 python/core/qgsdistancearea.sip
  10. +2 −2 python/core/qgsgeometryvalidator.sip
  11. +3 −3 python/core/qgsvectorlayer.sip
  12. +3 −3 python/core/qgsvectorlayereditutils.sip
  13. +2 −2 python/gui/qgsmaptoolcapture.sip
  14. +1 −1 python/gui/qgsmaptooledit.sip
  15. +1 −1 src/analysis/processing/qgsalgorithmbuffer.cpp
  16. +1 −1 src/analysis/processing/qgsalgorithmclip.cpp
  17. +5 −5 src/analysis/processing/qgsalgorithmdissolve.cpp
  18. +1 −1 src/analysis/processing/qgsalgorithmdissolve.h
  19. +2 −2 src/analysis/processing/qgsalgorithmfixgeometries.cpp
  20. +8 −8 src/analysis/processing/qgsalgorithmsplitwithlines.cpp
  21. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
  22. +2 −2 src/app/qgsmaptoolfillring.cpp
  23. +6 −6 src/app/qgsmeasuredialog.cpp
  24. +2 −2 src/app/qgsmeasuretool.cpp
  25. +2 −2 src/app/qgsmeasuretool.h
  26. +2 −2 src/core/composer/qgscomposermapgrid.cpp
  27. +1 −1 src/core/expression/qgsexpressionfunction.cpp
  28. +5 −5 src/core/geometry/qgsabstractgeometry.h
  29. +22 −29 src/core/geometry/qgscompoundcurve.cpp
  30. +2 −2 src/core/geometry/qgscompoundcurve.h
  31. +20 −27 src/core/geometry/qgscurvepolygon.cpp
  32. +2 −2 src/core/geometry/qgscurvepolygon.h
  33. +21 −21 src/core/geometry/qgsgeometry.cpp
  34. +10 −10 src/core/geometry/qgsgeometry.h
  35. +3 −3 src/core/geometry/qgsgeometrycollection.cpp
  36. +1 −1 src/core/geometry/qgsgeometrycollection.h
  37. +3 −3 src/core/geometry/qgsgeometryeditutils.cpp
  38. +4 −4 src/core/geometry/qgsgeometryengine.h
  39. +1 −1 src/core/geometry/qgsgeometryfactory.cpp
  40. +6 −6 src/core/geometry/qgsgeometryutils.cpp
  41. +3 −3 src/core/geometry/qgsgeometryutils.h
  42. +10 −10 src/core/geometry/qgsgeos.cpp
  43. +6 −6 src/core/geometry/qgsgeos.h
  44. +4 −4 src/core/geometry/qgsinternalgeometryengine.cpp
  45. +1 −1 src/core/geometry/qgslinestring.cpp
  46. +1 −1 src/core/geometry/qgslinestring.h
  47. +1 −1 src/core/geometry/qgsmulticurve.cpp
  48. +1 −1 src/core/geometry/qgsmultilinestring.cpp
  49. +1 −1 src/core/geometry/qgsmultipoint.cpp
  50. +1 −1 src/core/geometry/qgsmultipolygon.cpp
  51. +1 −1 src/core/geometry/qgsmultisurface.cpp
  52. +2 −2 src/core/geometry/qgsregularpolygon.cpp
  53. +1 −1 src/core/geometry/qgsregularpolygon.h
  54. +1 −1 src/core/geometry/qgstriangle.h
  55. +2 −2 src/core/layout/qgslayoutitemmapgrid.cpp
  56. +1 −1 src/core/qgsaggregatecalculator.cpp
  57. +11 −11 src/core/qgsdistancearea.cpp
  58. +5 −5 src/core/qgsdistancearea.h
  59. +2 −2 src/core/qgsgeometryvalidator.cpp
  60. +3 −3 src/core/qgsgeometryvalidator.h
  61. +1 −1 src/core/qgssnappingutils.cpp
  62. +1 −1 src/core/qgstracer.cpp
  63. +3 −3 src/core/qgsvectorlayer.cpp
  64. +3 −3 src/core/qgsvectorlayer.h
  65. +11 −11 src/core/qgsvectorlayereditutils.cpp
  66. +4 −4 src/core/qgsvectorlayereditutils.h
  67. +1 −1 src/core/symbology/qgsinvertedpolygonrenderer.h
  68. +3 −3 src/gui/qgsmaptoolcapture.cpp
  69. +2 −2 src/gui/qgsmaptoolcapture.h
  70. +2 −2 src/gui/qgsmaptooledit.cpp
  71. +1 −1 src/gui/qgsmaptooledit.h
  72. +1 −1 src/plugins/topology/topolTest.cpp
  73. +1 −1 src/providers/arcgisrest/qgsarcgisrestutils.cpp
  74. +1 −1 tests/src/core/testqgsdistancearea.cpp
  75. +65 −65 tests/src/core/testqgsgeometry.cpp
  76. +8 −8 tests/src/core/testqgsgeometryutils.cpp
  77. +1 −1 tests/src/providers/grass/testqgsgrassprovider.cpp
@@ -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
{
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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``.

@@ -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
@@ -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.
@@ -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
@@ -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()
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

@@ -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)
@@ -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 ) )
@@ -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 ) )
@@ -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 )
@@ -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 ) )
@@ -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 ) )
{
@@ -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 );
@@ -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 );
} );
@@ -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 );
};

/**
@@ -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() )

0 comments on commit 5d476e5

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